00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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 }