Interfaces
kimproxy.h
Go to the documentation of this file.
00001 /* 00002 kimproxy.h 00003 00004 IM service library for KDE 00005 00006 Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk> 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 00024 #ifndef KIMPROXY_H 00025 #define KIMPROXY_H 00026 00027 #include <QtCore/QHash> 00028 #include <QtCore/QMap> 00029 #include <QtCore/QStringList> 00030 #include <QtGui/QPixmap> 00031 00032 #include <kimproxy_export.h> 00033 00034 #define IM_SERVICE_TYPE "DBUS/InstantMessenger" 00035 #define IM_CLIENT_PREFERENCES_FILE "default_components" 00036 #define IM_CLIENT_PREFERENCES_SECTION "InstantMessenger" 00037 #define IM_CLIENT_PREFERENCES_ENTRY "imClient" 00038 00039 class KUrl; 00040 class ContactPresenceListCurrent; 00041 class OrgKdeKIMInterface; 00042 00044 typedef QMap<QString, int> AppPresence; // appId->presence; contains all applications' ideas of a user's presence 00045 typedef QHash<QString, AppPresence*> PresenceMap; // uid->AppPresence; contains a AppPresences for all users 00047 typedef QMap<QString, ContactPresenceListCurrent> PresenceStringMap; 00048 00068 class KIMPROXY_EXPORT KIMProxy : public QObject 00069 { 00070 Q_OBJECT 00071 public: 00072 ~KIMProxy(); 00077 static KIMProxy * instance(); 00078 00084 bool initialize(); 00085 00086 public Q_SLOTS: 00092 QStringList allContacts(); 00093 00099 QStringList reachableContacts(); 00100 00106 QStringList onlineContacts(); 00107 00113 QStringList fileTransferContacts(); 00114 00120 bool isPresent( const QString& uid ); 00121 00128 QString displayName( const QString& uid ); 00129 00135 int presenceNumeric( const QString& uid ); 00136 00142 QString presenceString( const QString& uid ); 00143 00149 QPixmap presenceIcon( const QString& uid ); 00150 00156 bool canReceiveFiles( const QString & uid ); 00157 00163 bool canRespond( const QString & uid ); 00164 00172 QString locate( const QString & contactId, const QString & protocol ); 00173 00179 QString context( const QString & uid ); 00180 00185 void chatWithContact( const QString& uid ); 00186 00194 void messageContact( const QString& uid, const QString& message ); 00195 00203 void sendFile(const QString &uid, const QString &sourceURL, const QString &altFileName = QString(), uint fileSize = 0); 00204 00211 bool addContact( const QString &contactId, const QString &protocol ); 00212 00217 bool imAppsAvailable(); 00218 00223 bool startPreferredApp(); 00224 00228 void contactPresenceChanged( const QString& uid, const QString& appId, int presence ); 00229 00230 private Q_SLOTS: 00231 void nameOwnerChanged( const QString &name, const QString &oldOwner, const QString &newOwner); 00232 Q_SIGNALS: 00237 void sigContactPresenceChanged( const QString &uid ); 00238 00243 void sigPresenceInfoExpired(); 00244 protected: 00248 void pollApp( const QString & appId ); 00252 void pollAll( const QString &uid ); 00253 00257 bool updatePresence( const QString &uid, const QString &appId, int presence ); 00258 00262 QString preferredApp(); 00263 00267 OrgKdeKIMInterface * stubForUid( const QString &uid ); 00268 00273 OrgKdeKIMInterface * stubForProtocol( const QString &protocol ); 00274 00275 private: 00276 // client stubs used to get presence 00277 // appId (from D-Bus) -> KIMIface_stub 00278 QHash<QString, OrgKdeKIMInterface*> m_im_client_stubs; 00279 // map containing numeric presence and the originating application ID for each KABC uid we know of 00280 // KABC Uid -> (appId, numeric presence )(AppPresence) 00281 PresenceMap m_presence_map; 00282 // cache of the client strings in use by each application 00283 // dictionary of KIMIface_stub -> map of numeric presence -> string presence 00284 class Private; 00285 00286 Private * const d; 00287 bool m_apps_available; 00288 bool m_initialized; 00292 KIMProxy(); 00293 }; 00294 00295 #endif 00296
KDE 4.6 API Reference