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     static const Feature FeatureAccountBalance;
00076 
00077     enum Status {
00078         StatusDisconnected = ConnectionStatusDisconnected,
00079         StatusConnecting = ConnectionStatusConnecting,
00080         StatusConnected = ConnectionStatusConnected,
00081         StatusUnknown = 0xFFFFFFFF
00082     };
00083 
00084     static ConnectionPtr create(const QString &busName,
00085             const QString &objectPath);
00086     static ConnectionPtr create(const QDBusConnection &bus,
00087             const QString &busName, const QString &objectPath);
00088 
00089     virtual ~Connection();
00090 
00091     Status status() const;
00092     ConnectionStatusReason statusReason() const;
00093 
00094     uint selfHandle() const;
00095     ContactPtr selfContact() const;
00096 
00097     SimpleStatusSpecMap allowedPresenceStatuses() const;
00098     PendingOperation *setSelfPresence(const QString &status, const QString &statusMessage);
00099 
00100     CurrencyAmount accountBalance() const;
00101 
00102     ConnectionCapabilities *capabilities() const;
00103 
00104     PendingChannel *createChannel(const QVariantMap &request);
00105     PendingChannel *ensureChannel(const QVariantMap &request);
00106 
00107     PendingReady *requestConnect(const Features &requestedFeatures = Features());
00108     PendingOperation *requestDisconnect();
00109 
00110     PendingHandles *requestHandles(uint handleType, const QStringList &names);
00111     PendingHandles *referenceHandles(uint handleType, const UIntList &handles);
00112 
00113     PendingContactAttributes *contactAttributes(const UIntList &handles,
00114             const QStringList &interfaces, bool reference = true);
00115     QStringList contactAttributeInterfaces() const;
00116     ContactManager *contactManager() const;
00117 
00118     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00119     {
00120         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00121     }
00122 
00123     inline Client::ConnectionInterfaceAliasingInterface *aliasingInterface(
00124             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00125     {
00126         return optionalInterface<Client::ConnectionInterfaceAliasingInterface>(check);
00127     }
00128 
00129     inline Client::ConnectionInterfaceAnonymityInterface *anonymityInterface(
00130             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00131     {
00132         return optionalInterface<Client::ConnectionInterfaceAnonymityInterface>(check);
00133     }
00134 
00135     inline Client::ConnectionInterfaceAvatarsInterface *avatarsInterface(
00136             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00137     {
00138         return optionalInterface<Client::ConnectionInterfaceAvatarsInterface>(check);
00139     }
00140 
00141     inline Client::ConnectionInterfaceCapabilitiesInterface *capabilitiesInterface(
00142             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00143     {
00144         return optionalInterface<Client::ConnectionInterfaceCapabilitiesInterface>(check);
00145     }
00146 
00147     inline Client::ConnectionInterfaceContactCapabilitiesInterface *contactCapabilitiesInterface(
00148             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00149     {
00150         return optionalInterface<Client::ConnectionInterfaceContactCapabilitiesInterface>(check);
00151     }
00152 
00153     inline Client::ConnectionInterfaceLocationInterface *locationInterface(
00154             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00155     {
00156         return optionalInterface<Client::ConnectionInterfaceLocationInterface>(check);
00157     }
00158 
00159     inline Client::ConnectionInterfaceContactInfoInterface *contactInfoInterface(
00160             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00161     {
00162         return optionalInterface<Client::ConnectionInterfaceContactInfoInterface>(check);
00163     }
00164 
00165     inline Client::ConnectionInterfacePresenceInterface *presenceInterface(
00166             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00167     {
00168         return optionalInterface<Client::ConnectionInterfacePresenceInterface>(check);
00169     }
00170 
00171     inline Client::ConnectionInterfaceServicePointInterface *servicePointInterface(
00172             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00173     {
00174         return optionalInterface<Client::ConnectionInterfaceServicePointInterface>(check);
00175     }
00176 
00177     inline Client::ConnectionInterfaceSimplePresenceInterface *simplePresenceInterface(
00178             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00179     {
00180         return optionalInterface<Client::ConnectionInterfaceSimplePresenceInterface>(check);
00181     }
00182 
00183     inline Client::ConnectionInterfaceRequestsInterface *requestsInterface(
00184             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00185     {
00186         return optionalInterface<Client::ConnectionInterfaceRequestsInterface>(check);
00187     }
00188 
00189     inline Client::ConnectionInterfaceBalanceInterface *balanceInterface(
00190             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00191     {
00192         return optionalInterface<Client::ConnectionInterfaceBalanceInterface>(check);
00193     }
00194 
00195     inline Client::ConnectionInterfaceCellularInterface *cellularInterface(
00196             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00197     {
00198         return optionalInterface<Client::ConnectionInterfaceCellularInterface>(check);
00199     }
00200 
00201 Q_SIGNALS:
00202     void statusChanged(Tp::Connection::Status newStatus,
00203             Tp::ConnectionStatusReason newStatusReason);
00204     void selfHandleChanged(uint newHandle);
00205     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00206     void selfContactChanged();
00207 
00208     void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
00209 
00210 protected:
00211     Connection(const QString &busName, const QString &objectPath);
00212     Connection(const QDBusConnection &bus, const QString &busName,
00213             const QString &objectPath);
00214 
00215     Client::ConnectionInterface *baseInterface() const;
00216 
00217 private Q_SLOTS:
00218     void onStatusReady(uint);
00219     void onStatusChanged(uint, uint);
00220     void onConnectionError(const QString &, const QVariantMap &);
00221     void gotStatus(QDBusPendingCallWatcher *watcher);
00222     void gotInterfaces(QDBusPendingCallWatcher *watcher);
00223     void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00224     void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00225     void gotSelfContact(Tp::PendingOperation *);
00226     void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00227     void gotCapabilities(QDBusPendingCallWatcher *watcher);
00228     void gotContactListsHandles(Tp::PendingOperation *);
00229     void gotContactListChannel(Tp::PendingOperation *);
00230     void contactListChannelReady();
00231     void onNewChannels(const Tp::ChannelDetailsList &);
00232     void onContactListGroupChannelReady(Tp::PendingOperation *);
00233     void gotChannels(QDBusPendingCallWatcher *);
00234 
00235     void doReleaseSweep(uint type);
00236 
00237     void onSelfHandleChanged(uint);
00238 
00239     void gotBalance(QDBusPendingCallWatcher *watcher);
00240     void onBalanceChanged(const Tp::CurrencyAmount &);
00241 
00242 private:
00243     class PendingConnect;
00244     friend class PendingChannel;
00245     friend class PendingConnect;
00246     friend class PendingContactAttributes;
00247     friend class PendingContacts;
00248     friend class PendingHandles;
00249     friend class ReferencedHandles;
00250 
00251     void refHandle(uint type, uint handle);
00252     void unrefHandle(uint type, uint handle);
00253     void handleRequestLanded(uint type);
00254 
00255     struct Private;
00256     friend struct Private;
00257     Private *mPriv;
00258 };
00259 
00260 } // Tp
00261 
00262 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.3.6