interfaces Library API Documentation

kimproxy.h

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., 59 Temple Place - Suite 330, 00021 Boston, MA 02111-1307, USA. 00022 */ 00023 00024 #ifndef KIMPROXY_H 00025 #define KIMPROXY_H 00026 00027 #include <qdict.h> 00028 #include <qmap.h> 00029 #include <qptrdict.h> 00030 #include <qstringlist.h> 00031 00032 00033 #define IM_SERVICE_TYPE "DCOP/InstantMessenger" 00034 #define IM_CLIENT_PREFERENCES_FILE "default_components" 00035 #define IM_CLIENT_PREFERENCES_SECTION "InstantMessenger" 00036 #define IM_CLIENT_PREFERENCES_ENTRY "imClient" 00037 00038 #include "kimproxyiface.h" 00039 00040 class DCOPClient; 00041 class KIMIface_stub; 00042 class KURL; 00043 00044 typedef QMap<QCString, int> AppPresence; // appId->presence; contains all applications' ideas of a user's presence 00045 typedef QDict<AppPresence> PresenceMap; // uid->AppPresence; contains a AppPresences for all users 00046 typedef QMap<int, QString> PresenceStringMap; 00047 00068 class KIMProxy : public QObject, virtual public KIMProxyIface 00069 { 00070 Q_OBJECT 00071 00072 template<class> friend class KStaticDeleter; 00073 ~KIMProxy(); 00074 00075 public: 00085 static KIMProxy * instance( DCOPClient * client ); 00086 00092 bool initialize(); 00093 00099 QStringList allContacts(); 00100 00106 QStringList reachableContacts(); 00107 00113 QStringList onlineContacts(); 00114 00120 QStringList fileTransferContacts(); 00121 00127 bool isPresent( const QString& uid ); 00128 00135 QString displayName( const QString& uid ); 00136 00142 int presenceNumeric( const QString& uid ); 00143 00149 QString presenceString( const QString& uid ); 00150 00156 QPixmap presenceIcon( const QString& uid ); 00157 00163 bool canReceiveFiles( const QString & uid ); 00164 00170 bool canRespond( const QString & uid ); 00171 00179 QString locate( const QString & contactId, const QString & protocol ); 00180 00186 QString context( const QString & uid ); 00187 00192 void chatWithContact( const QString& uid ); 00193 00201 void messageContact( const QString& uid, const QString& message ); 00202 00210 void sendFile(const QString &uid, const KURL &sourceURL, const QString &altFileName = QString::null, uint fileSize = 0); 00211 00218 bool addContact( const QString &contactId, const QString &protocol ); 00219 00224 bool imAppsAvailable(); 00225 00230 bool startPreferredApp(); 00231 00235 void contactPresenceChanged( QString uid, QCString appId, int presence ); 00236 00237 public slots: 00238 void registeredToDCOP( const QCString& appId ); 00239 void unregisteredFromDCOP( const QCString& appId ); 00240 signals: 00245 void sigContactPresenceChanged( const QString &uid ); 00246 00251 void sigPresenceInfoExpired(); 00252 protected: 00256 void pollAll( const QString &uid ); 00257 00261 bool updatePresence( const QString &uid, const QCString &appId, int presence ); 00262 00266 QString preferredApp(); 00267 00271 KIMIface_stub * stubForUid( const QString &uid ); 00272 00277 KIMIface_stub * stubForProtocol( const QString &protocol ); 00278 00279 private: 00280 // client stubs used to get presence 00281 // appId (from DCOP) -> KIMIface_stub 00282 QDict<KIMIface_stub> m_im_client_stubs; 00283 // map containing numeric presence and the originating application ID for each KABC uid we know of 00284 // KABC Uid -> (appId, numeric presence )(AppPresence) 00285 PresenceMap m_presence_map; 00286 // cache of the client strings in use by each application 00287 // dictionary of KIMIface_stub -> map of numeric presence -> string presence 00288 QPtrDict<PresenceStringMap> m_client_presence_strings; 00289 DCOPClient *m_dc; 00290 bool m_apps_available; 00291 bool m_initialized; 00295 KIMProxy( DCOPClient * client); 00296 static KIMProxy * s_instance; 00297 }; 00298 00299 #endif 00300
KDE Logo
This file is part of the documentation for interfaces Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:32:15 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003