kitchensync
actionpartservice.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 00005 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include "actionpartservice.h" 00024 00025 #include <kdebug.h> 00026 #include <ktrader.h> 00027 00028 using namespace KSync; 00029 00030 bool ActionPartService::mAvailablePartsRead = false; 00031 ActionPartService::List ActionPartService::mAvailableParts; 00032 00033 const ActionPartService::List &ActionPartService::availableParts() 00034 { 00035 if ( !mAvailablePartsRead ) { 00036 KTrader::OfferList offers = KTrader::self()->query( 00037 QString::fromLatin1("KitchenSync/ActionPart"), QString::null ); 00038 00039 KTrader::OfferList::ConstIterator it; 00040 for ( it = offers.begin(); it != offers.end(); ++it ) { 00041 kdDebug() << "DESKTOP: " << (*it)->desktopEntryName() << endl; 00042 ActionPartService ser( *it ); 00043 mAvailableParts.append( ser ); 00044 } 00045 00046 mAvailablePartsRead = true; 00047 } 00048 00049 return mAvailableParts; 00050 } 00051 00052 ActionPartService ActionPartService::partForId( const QString &id ) 00053 { 00054 availableParts(); 00055 00056 ActionPartService::List::ConstIterator it; 00057 for( it = mAvailableParts.begin(); it != mAvailableParts.end(); ++it ) { 00058 kdDebug() << "id: " << (*it).id() << endl; 00059 00060 if ( (*it).id() == id ) return *it; 00061 } 00062 00063 kdDebug() << "ActionPartService: No part for name '" << id << "'" << endl; 00064 00065 return ActionPartService(); 00066 } 00067 00068 ActionPartService::ActionPartService() 00069 { 00070 } 00071 00072 ActionPartService::ActionPartService( const KService::Ptr &service ) 00073 : m_id( service->desktopEntryName() ), m_name( service->name() ), 00074 m_comment( service->comment() ), 00075 m_iconName( service->icon() ), m_libName( service->library() ) 00076 { 00077 kdDebug() << "xx: " << m_id << endl; 00078 } 00079 00080 ActionPartService::~ActionPartService() 00081 { 00082 } 00083 00084 QString ActionPartService::name() const 00085 { 00086 return m_name; 00087 } 00088 00089 QString ActionPartService::id() const 00090 { 00091 return m_id; 00092 } 00093 00094 QString ActionPartService::comment() const 00095 { 00096 return m_comment; 00097 } 00098 00099 QString ActionPartService::libraryName() const 00100 { 00101 return m_libName; 00102 } 00103 00104 QString ActionPartService::iconName() const 00105 { 00106 return m_iconName; 00107 } 00108 00109 void ActionPartService::setId( const QString &id ) 00110 { 00111 m_id = id; 00112 } 00113 00114 void ActionPartService::setName( const QString &name ) 00115 { 00116 m_name = name; 00117 } 00118 00119 void ActionPartService::setComment( const QString &comment ) 00120 { 00121 m_comment = comment; 00122 } 00123 00124 void ActionPartService::setLibraryName( const QString &libName ) 00125 { 00126 m_libName = libName; 00127 } 00128 00129 void ActionPartService::setIconName( const QString &icon ) 00130 { 00131 m_iconName = icon; 00132 } 00133 00134 ActionPartService &ActionPartService::operator=( const ActionPartService &man1 ) 00135 { 00136 m_name = man1.m_name; 00137 m_comment = man1.m_comment; 00138 m_iconName = man1.m_iconName; 00139 m_libName = man1.m_libName; 00140 return *this; 00141 } 00142 00143 bool ActionPartService::operator== ( const ActionPartService &par2 ) 00144 { 00145 return name() == par2.name(); 00146 } 00147 00148 bool ActionPartService::operator== ( const ActionPartService &par2 ) const 00149 { 00150 return name() == par2.name(); 00151 }