akonadi/contact
improtocols.cpp
00001 /* 00002 This file is part of Akonadi Contact. 00003 00004 Copyright (c) 2010 Tobias Koenig <tokoe@kde.org> 00005 00006 This library is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Library General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or (at your 00009 option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to the 00018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301, USA. 00020 */ 00021 00022 #include "improtocols.h" 00023 00024 #include <kiconloader.h> 00025 #include <kservicetypetrader.h> 00026 00027 IMProtocols* IMProtocols::mSelf = 0; 00028 00029 IMProtocols::IMProtocols() 00030 { 00031 KIconLoader::global()->addAppDir( QLatin1String( "akonadi/contact" ) ); 00032 00033 const QList<KPluginInfo> list = KPluginInfo::fromServices( KServiceTypeTrader::self()->query( QString::fromLatin1( "KABC/IMProtocol" ) ) ); 00034 00035 // sort the protocol information by user visible name 00036 QMap<QString, KPluginInfo> sortingMap; 00037 foreach ( const KPluginInfo &info, list ) { 00038 sortingMap.insert( info.name(), info ); 00039 00040 mPluginInfos.insert( info.property( QLatin1String( "X-KDE-InstantMessagingKABCField" ) ).toString(), info ); 00041 } 00042 00043 QMapIterator<QString, KPluginInfo> it( sortingMap ); 00044 while ( it.hasNext() ) { 00045 it.next(); 00046 mSortedProtocols.append( it.value().property( QLatin1String( "X-KDE-InstantMessagingKABCField" ) ).toString() ); 00047 } 00048 } 00049 00050 IMProtocols::~IMProtocols() 00051 { 00052 } 00053 00054 00055 IMProtocols* IMProtocols::self() 00056 { 00057 if ( !mSelf ) 00058 mSelf = new IMProtocols; 00059 00060 return mSelf; 00061 } 00062 00063 QStringList IMProtocols::protocols() const 00064 { 00065 return mSortedProtocols; 00066 } 00067 00068 QString IMProtocols::name( const QString &protocol ) const 00069 { 00070 if ( !mPluginInfos.contains( protocol ) ) 00071 return QString(); 00072 00073 return mPluginInfos.value( protocol ).name(); 00074 } 00075 00076 QString IMProtocols::icon( const QString &protocol ) const 00077 { 00078 if ( !mPluginInfos.contains( protocol ) ) 00079 return QString(); 00080 00081 return mPluginInfos.value( protocol ).icon(); 00082 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:19:26 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:19:26 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.