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 class ContactPresenceListCurrent;
00044 
00046 typedef QMap<QCString, int> AppPresence;        // appId->presence; contains all applications' ideas of a user's presence
00047 typedef QDict<AppPresence> PresenceMap;         // uid->AppPresence; contains a AppPresences for all users
00049 typedef QMap<QString, ContactPresenceListCurrent> PresenceStringMap;
00050 
00071 class KIMPROXY_EXPORT KIMProxy : public QObject, virtual public KIMProxyIface
00072 {
00073     Q_OBJECT
00074     struct Private;
00075 
00076     template<class> friend class KStaticDeleter;
00077     ~KIMProxy();
00078 
00079     public:
00089         static KIMProxy * instance( DCOPClient * client );
00090 
00096         bool initialize();
00097 
00103         QStringList allContacts();
00104 
00110         QStringList reachableContacts();
00111 
00117         QStringList onlineContacts();
00118 
00124         QStringList fileTransferContacts();
00125 
00131         bool isPresent( const QString& uid );
00132 
00139         QString displayName( const QString& uid );
00140 
00146         int presenceNumeric( const QString& uid );
00147 
00153         QString presenceString( const QString& uid );
00154 
00160         QPixmap presenceIcon( const QString& uid );
00161 
00167         bool canReceiveFiles( const QString & uid );
00168 
00174         bool canRespond( const QString & uid );
00175 
00183         QString locate( const QString & contactId, const QString & protocol );
00184 
00190         QString context( const QString & uid );
00191 
00196         void chatWithContact( const QString& uid );
00197 
00205         void messageContact( const QString& uid, const QString& message );
00206 
00214         void sendFile(const QString &uid, const KURL &sourceURL, const QString &altFileName = QString::null, uint fileSize = 0);
00215 
00222         bool addContact( const QString &contactId, const QString &protocol );
00223 
00228         bool imAppsAvailable();
00229 
00234         bool startPreferredApp();
00235 
00239         void contactPresenceChanged( QString uid, QCString appId, int presence );
00240 
00241     public slots:
00242         void registeredToDCOP( const QCString& appId );
00243         void unregisteredFromDCOP( const QCString& appId );
00244     signals:
00249         void sigContactPresenceChanged( const QString &uid );
00250 
00255         void sigPresenceInfoExpired();
00256     protected:
00260         void pollApp( const QCString & appId );
00264         void pollAll( const QString &uid );
00265 
00269         bool updatePresence( const QString &uid, const QCString &appId, int presence );
00270 
00274         QString preferredApp();
00275 
00279         KIMIface_stub * stubForUid( const QString &uid );
00280 
00285         KIMIface_stub * stubForProtocol( const QString &protocol );
00286 
00287     private:
00288         // client stubs used to get presence
00289         // appId (from DCOP) -> KIMIface_stub
00290         QDict<KIMIface_stub> m_im_client_stubs;
00291         // map containing numeric presence and the originating application ID for each KABC uid we know of
00292         // KABC Uid -> (appId, numeric presence )(AppPresence)
00293         PresenceMap m_presence_map;
00294         // cache of the client strings in use by each application
00295         // dictionary of KIMIface_stub -> map of numeric presence -> string presence
00296         // FIXME: remove for KDE4 - UNUSED but maintained for binary compatibility in KDE 3.4
00297         QPtrDict<int> m_client_presence_strings;
00298         Private * d;
00299         bool m_apps_available;
00300         bool m_initialized;
00304         KIMProxy( DCOPClient * client);
00305         static KIMProxy * s_instance;
00306 };
00307 
00308 #endif
00309 
KDE Logo
This file is part of the documentation for interfaces Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Jun 12 11:47:52 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003