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 Contact;
00052 class ContactManager;
00053 class PendingChannel;
00054 class PendingContactAttributes;
00055 class PendingHandles;
00056 class PendingOperation;
00057 class PendingReady;
00058 
00059 class Connection : public StatefulDBusProxy,
00060                    public OptionalInterfaceFactory<Connection>,
00061                    public ReadyObject,
00062                    public RefCounted
00063 {
00064     Q_OBJECT
00065     Q_DISABLE_COPY(Connection)
00066     Q_ENUMS(Status)
00067 
00068 public:
00069     static const Feature FeatureCore;
00070     static const Feature FeatureSelfContact;
00071     static const Feature FeatureSimplePresence;
00072     static const Feature FeatureRoster;
00073     static const Feature FeatureRosterGroups;
00074 
00075     enum Status {
00076         StatusDisconnected = ConnectionStatusDisconnected,
00077         StatusConnecting = ConnectionStatusConnecting,
00078         StatusConnected = ConnectionStatusConnected,
00079         StatusUnknown = 0xFFFFFFFF
00080     };
00081 
00082     static ConnectionPtr create(const QString &busName,
00083             const QString &objectPath);
00084     static ConnectionPtr create(const QDBusConnection &bus,
00085             const QString &busName, const QString &objectPath);
00086 
00087     virtual ~Connection();
00088 
00089     uint status() const;
00090     uint statusReason() const;
00091 
00092     uint selfHandle() const;
00093     ContactPtr selfContact() const;
00094 
00095     SimpleStatusSpecMap allowedPresenceStatuses() const;
00096     PendingOperation *setSelfPresence(const QString &status, const QString &statusMessage);
00097 
00098     PendingChannel *createChannel(const QVariantMap &request);
00099     PendingChannel *ensureChannel(const QVariantMap &request);
00100 
00101     PendingReady *requestConnect(const Features &requestedFeatures = Features());
00102     PendingOperation *requestDisconnect();
00103 
00104     PendingHandles *requestHandles(uint handleType, const QStringList &names);
00105     PendingHandles *referenceHandles(uint handleType, const UIntList &handles);
00106 
00107     PendingContactAttributes *getContactAttributes(const UIntList &handles,
00108             const QStringList &interfaces, bool reference = true);
00109     QStringList contactAttributeInterfaces() const;
00110     ContactManager *contactManager() const;
00111 
00112     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00113     {
00114         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00115     }
00116 
00117     inline Client::ConnectionInterfaceAliasingInterface *aliasingInterface(
00118             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00119     {
00120         return optionalInterface<Client::ConnectionInterfaceAliasingInterface>(check);
00121     }
00122 
00123     inline Client::ConnectionInterfaceAvatarsInterface *avatarsInterface(
00124             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00125     {
00126         return optionalInterface<Client::ConnectionInterfaceAvatarsInterface>(check);
00127     }
00128 
00129     inline Client::ConnectionInterfaceCapabilitiesInterface *capabilitiesInterface(
00130             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00131     {
00132         return optionalInterface<Client::ConnectionInterfaceCapabilitiesInterface>(check);
00133     }
00134 
00135     inline Client::ConnectionInterfacePresenceInterface *presenceInterface(
00136             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00137     {
00138         return optionalInterface<Client::ConnectionInterfacePresenceInterface>(check);
00139     }
00140 
00141     inline Client::ConnectionInterfaceSimplePresenceInterface *simplePresenceInterface(
00142             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00143     {
00144         return optionalInterface<Client::ConnectionInterfaceSimplePresenceInterface>(check);
00145     }
00146 
00147     inline Client::ConnectionInterfaceRequestsInterface *requestsInterface(
00148             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00149     {
00150         return optionalInterface<Client::ConnectionInterfaceRequestsInterface>(check);
00151     }
00152 
00153 Q_SIGNALS:
00154     void statusChanged(uint newStatus, uint newStatusReason);
00155     void selfHandleChanged(uint newHandle);
00156     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00157     void selfContactChanged();
00158 
00159 protected:
00160     Connection(const QString &busName, const QString &objectPath);
00161     Connection(const QDBusConnection &bus, const QString &busName,
00162             const QString &objectPath);
00163 
00164     Client::ConnectionInterface *baseInterface() const;
00165 
00166 private Q_SLOTS:
00167     void onStatusReady(uint);
00168     void onStatusChanged(uint, uint);
00169     void gotStatus(QDBusPendingCallWatcher *watcher);
00170     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00171     void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00172     void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00173     void gotSelfContact(Tp::PendingOperation *);
00174     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00175     void gotContactListsHandles(Tp::PendingOperation *);
00176     void gotContactListChannel(Tp::PendingOperation *);
00177     void contactListChannelReady();
00178     void onNewChannels(const Tp::ChannelDetailsList &);
00179     void onContactListGroupChannelReady(Tp::PendingOperation *);
00180     void gotChannels(QDBusPendingCallWatcher *);
00181 
00182     void doReleaseSweep(uint type);
00183 
00184     void onSelfHandleChanged(uint);
00185 
00186 private:
00187     class PendingConnect;
00188     friend class PendingChannel;
00189     friend class PendingConnect;
00190     friend class PendingContactAttributes;
00191     friend class PendingContacts;
00192     friend class PendingHandles;
00193     friend class ReferencedHandles;
00194 
00195     void refHandle(uint type, uint handle);
00196     void unrefHandle(uint type, uint handle);
00197     void handleRequestLanded(uint type);
00198 
00199     struct Private;
00200     friend struct Private;
00201     Private *mPriv;
00202 };
00203 
00204 } // Tp
00205 
00206 #endif


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