00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TelepathyQt4_Prototype_Connection_H_
00023 #define TelepathyQt4_Prototype_Connection_H_
00024
00025 #include <QDBusObjectPath>
00026 #include <QDBusPendingReply>
00027 #include <QObject>
00028 #include <QPointer>
00029 #include <QVariantMap>
00030
00031 #include <TelepathyQt4/Constants>
00032
00033 #ifdef DEPRECATED_ENABLED__
00034 #define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
00035 #else
00036 #define ATTRIBUTE_DEPRECATED
00037 #endif
00038
00039 namespace Telepathy
00040 {
00041 namespace Client
00042 {
00043 class ConnectionInterface;
00044 }
00045 }
00046
00055 namespace TpPrototype {
00056
00057 class ConnectionPrivate;
00058 class ContactManager;
00059 class PresenceManager;
00060 class CapabilitiesManager;
00061 class AvatarManager;
00062 class Account;
00070 class Connection : public QObject
00071 {
00072 Q_OBJECT
00073 Q_PROPERTY( bool valid READ isValid )
00074 public:
00075
00076 ~Connection();
00077
00082 bool isValid();
00083
00089 Telepathy::ConnectionStatus status();
00090
00096 Telepathy::ConnectionStatusReason reason();
00097
00104 bool requestConnect();
00105
00109 bool requestDisconnect();
00110
00118 ContactManager* contactManager();
00119
00131 PresenceManager* presenceManager();
00132
00144 CapabilitiesManager* capabilitiesManager();
00145
00157 AvatarManager* avatarManager();
00158
00164 Account* account() const;
00165
00166 signals:
00175 void signalStatusChanged( TpPrototype::Connection* connection,
00176 Telepathy::ConnectionStatus newStatus,
00177 Telepathy::ConnectionStatus oldStatus );
00178
00179 protected slots:
00180 void slotStatusChanged( uint status, uint reason );
00181 void slotNewChannel( const QDBusObjectPath& objectPath, const QString& channelType, uint handleType, uint handle, bool suppressHandler );
00182
00183 protected:
00189 Connection( TpPrototype::Account* account, QObject* parent );
00190
00196 QString handle() const;
00197
00202 Telepathy::Client::ConnectionInterface* interface();
00203
00210 QList<uint> RequestHandles( Telepathy::HandleType handletype, QStringList& handlestrings);
00211
00215 bool managerSupported( const QString& managerName );
00216
00217 template <class Manager>
00218 inline Manager* createManager( QPointer<Manager>& pManager, const QString& managerName )
00219 {
00220 if ( pManager && pManager->isValid() )
00221 { return pManager; }
00222
00223
00224 if ( pManager && !pManager->isValid() )
00225 {
00226 delete pManager;
00227 pManager = NULL;
00228 }
00229
00230 if ( status() != Telepathy::ConnectionStatusConnected )
00231 { return NULL; }
00232
00233 pManager = new Manager( this, interface(), this );
00234 Q_ASSERT( pManager );
00235
00236 if ( pManager->isValid() )
00237 { return pManager; }
00238
00239
00240 delete pManager;
00241 pManager = NULL;
00242 return NULL;
00243 }
00244
00245
00246 private:
00247 void init( TpPrototype::Account* account );
00248 void startupInit();
00249 ConnectionPrivate * const d;
00250
00251 friend class Account;
00252 };
00253
00254 }
00255
00256 #endif