Home · All Classes · All Namespaces · Modules · Functions · Files

connection.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2008, 2009 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2008, 2009 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_connection_h_HEADER_GUARD_
00023 #define _TelepathyQt4_connection_h_HEADER_GUARD_
00024 
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028 
00029 #include <TelepathyQt4/_gen/cli-connection.h>
00030 
00031 #include <TelepathyQt4/Contact>
00032 #include <TelepathyQt4/DBus>
00033 #include <TelepathyQt4/DBusProxy>
00034 #include <TelepathyQt4/OptionalInterfaceFactory>
00035 #include <TelepathyQt4/ReadinessHelper>
00036 #include <TelepathyQt4/ReadyObject>
00037 #include <TelepathyQt4/Types>
00038 #include <TelepathyQt4/SharedPtr>
00039 
00040 #include <TelepathyQt4/Constants>
00041 #include <TelepathyQt4/Types>
00042 
00043 #include <QSet>
00044 #include <QString>
00045 #include <QStringList>
00046 
00047 namespace Tp
00048 {
00049 
00050 class Channel;
00051 class ConnectionCapabilities;
00052 class Contact;
00053 class ContactManager;
00054 class PendingChannel;
00055 class PendingContactAttributes;
00056 class PendingHandles;
00057 class PendingOperation;
00058 class PendingReady;
00059 
00060 class TELEPATHY_QT4_EXPORT Connection : public StatefulDBusProxy,
00061                    public OptionalInterfaceFactory<Connection>,
00062                    public ReadyObject,
00063                    public RefCounted
00064 {
00065     Q_OBJECT
00066     Q_DISABLE_COPY(Connection)
00067     Q_ENUMS(Status)
00068 
00069 public:
00070     static const Feature FeatureCore;
00071     static const Feature FeatureSelfContact;
00072     static const Feature FeatureSimplePresence;
00073     static const Feature FeatureRoster;
00074     static const Feature FeatureRosterGroups;
00075 
00076     enum Status {
00077         StatusDisconnected = ConnectionStatusDisconnected,
00078         StatusConnecting = ConnectionStatusConnecting,
00079         StatusConnected = ConnectionStatusConnected,
00080         StatusUnknown = 0xFFFFFFFF
00081     };
00082 
00083     static ConnectionPtr create(const QString &busName,
00084             const QString &objectPath);
00085     static ConnectionPtr create(const QDBusConnection &bus,
00086             const QString &busName, const QString &objectPath);
00087 
00088     virtual ~Connection();
00089 
00090     Status status() const;
00091     ConnectionStatusReason statusReason() const;
00092 
00093     uint selfHandle() const;
00094     ContactPtr selfContact() const;
00095 
00096     SimpleStatusSpecMap allowedPresenceStatuses() const;
00097     PendingOperation *setSelfPresence(const QString &status, const QString &statusMessage);
00098 
00099     ConnectionCapabilities *capabilities() const;
00100 
00101     PendingChannel *createChannel(const QVariantMap &request);
00102     PendingChannel *ensureChannel(const QVariantMap &request);
00103 
00104     PendingReady *requestConnect(const Features &requestedFeatures = Features());
00105     PendingOperation *requestDisconnect();
00106 
00107     PendingHandles *requestHandles(uint handleType, const QStringList &names);
00108     PendingHandles *referenceHandles(uint handleType, const UIntList &handles);
00109 
00110     PendingContactAttributes *contactAttributes(const UIntList &handles,
00111             const QStringList &interfaces, bool reference = true);
00112     QStringList contactAttributeInterfaces() const;
00113     ContactManager *contactManager() const;
00114 
00115     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00116     {
00117         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00118     }
00119 
00120     inline Client::ConnectionInterfaceAliasingInterface *aliasingInterface(
00121             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00122     {
00123         return optionalInterface<Client::ConnectionInterfaceAliasingInterface>(check);
00124     }
00125 
00126     inline Client::ConnectionInterfaceAvatarsInterface *avatarsInterface(
00127             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00128     {
00129         return optionalInterface<Client::ConnectionInterfaceAvatarsInterface>(check);
00130     }
00131 
00132     inline Client::ConnectionInterfaceCapabilitiesInterface *capabilitiesInterface(
00133             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00134     {
00135         return optionalInterface<Client::ConnectionInterfaceCapabilitiesInterface>(check);
00136     }
00137 
00138     inline Client::ConnectionInterfaceContactCapabilitiesInterface *contactCapabilitiesInterface(
00139             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00140     {
00141         return optionalInterface<Client::ConnectionInterfaceContactCapabilitiesInterface>(check);
00142     }
00143 
00144     inline Client::ConnectionInterfacePresenceInterface *presenceInterface(
00145             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00146     {
00147         return optionalInterface<Client::ConnectionInterfacePresenceInterface>(check);
00148     }
00149 
00150     inline Client::ConnectionInterfaceSimplePresenceInterface *simplePresenceInterface(
00151             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00152     {
00153         return optionalInterface<Client::ConnectionInterfaceSimplePresenceInterface>(check);
00154     }
00155 
00156     inline Client::ConnectionInterfaceRequestsInterface *requestsInterface(
00157             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00158     {
00159         return optionalInterface<Client::ConnectionInterfaceRequestsInterface>(check);
00160     }
00161 
00162 Q_SIGNALS:
00163     void statusChanged(Tp::Connection::Status newStatus,
00164             Tp::ConnectionStatusReason newStatusReason);
00165     void selfHandleChanged(uint newHandle);
00166     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00167     void selfContactChanged();
00168 
00169 protected:
00170     Connection(const QString &busName, const QString &objectPath);
00171     Connection(const QDBusConnection &bus, const QString &busName,
00172             const QString &objectPath);
00173 
00174     Client::ConnectionInterface *baseInterface() const;
00175 
00176 private Q_SLOTS:
00177     void onStatusReady(uint);
00178     void onStatusChanged(uint, uint);
00179     void onConnectionError(const QString &, const QVariantMap &);
00180     void gotStatus(QDBusPendingCallWatcher *watcher);
00181     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00182     void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00183     void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00184     void gotSelfContact(Tp::PendingOperation *);
00185     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00186     void gotCapabilities(QDBusPendingCallWatcher *watcher);
00187     void gotContactListsHandles(Tp::PendingOperation *);
00188     void gotContactListChannel(Tp::PendingOperation *);
00189     void contactListChannelReady();
00190     void onNewChannels(const Tp::ChannelDetailsList &);
00191     void onContactListGroupChannelReady(Tp::PendingOperation *);
00192     void gotChannels(QDBusPendingCallWatcher *);
00193 
00194     void doReleaseSweep(uint type);
00195 
00196     void onSelfHandleChanged(uint);
00197 
00198 private:
00199     class PendingConnect;
00200     friend class PendingChannel;
00201     friend class PendingConnect;
00202     friend class PendingContactAttributes;
00203     friend class PendingContacts;
00204     friend class PendingHandles;
00205     friend class ReferencedHandles;
00206 
00207     void refHandle(uint type, uint handle);
00208     void unrefHandle(uint type, uint handle);
00209     void handleRequestLanded(uint type);
00210 
00211     struct Private;
00212     friend struct Private;
00213     Private *mPriv;
00214 };
00215 
00216 } // Tp
00217 
00218 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.2.1