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

# account.h

    00001 /*
    00002  * This file is part of TelepathyQt4
    00003  *
    00004  * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
    00005  * Copyright (C) 2008 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_account_h_HEADER_GUARD_
    00023 #define _TelepathyQt4_account_h_HEADER_GUARD_
    00024
    00025 #ifndef IN_TELEPATHY_QT4_HEADER
    00026 #error IN_TELEPATHY_QT4_HEADER
    00027 #endif
    00028
    00029 #include <TelepathyQt4/_gen/cli-account.h>
    00030
    00031 #include <TelepathyQt4/Connection>
    00032 #include <TelepathyQt4/ConnectionFactory>
    00033 #include <TelepathyQt4/ContactFactory>
    00034 #include <TelepathyQt4/ChannelFactory>
    00035 #include <TelepathyQt4/DBus>
    00036 #include <TelepathyQt4/DBusProxy>
    00037 #include <TelepathyQt4/FileTransferChannelCreationProperties>
    00038 #include <TelepathyQt4/OptionalInterfaceFactory>
    00039 #include <TelepathyQt4/ReadinessHelper>
    00040 #include <TelepathyQt4/ReadyObject>
    00041 #include <TelepathyQt4/Types>
    00042 #include <TelepathyQt4/Constants>
    00043 #include <TelepathyQt4/SharedPtr>
    00044
    00045 #include <QSet>
    00046 #include <QString>
    00047 #include <QStringList>
    00048 #include <QVariantMap>
    00049
    00050 namespace Tp
    00051 {
    00052
    00053 class Account;
    00054 class Connection;
    00055 class PendingChannelRequest;
    00056 class PendingConnection;
    00057 class PendingOperation;
    00058 class PendingReady;
    00059 class PendingStringList;
    00060 class ProtocolInfo;
    00061
    00062 class TELEPATHY_QT4_EXPORT Account : public StatelessDBusProxy,
    00063                 public OptionalInterfaceFactory<Account>,
    00064                 public ReadyObject,
    00065                 public RefCounted
    00066
    00067 {
    00068     Q_OBJECT
    00069     Q_DISABLE_COPY(Account)
    00070     Q_PROPERTY(bool valid READ isValidAccount NOTIFY validityChanged)
    00071     Q_PROPERTY(bool enabled READ isEnabled NOTIFY stateChanged)
    00072     Q_PROPERTY(QString cmName READ cmName)
    00073     Q_PROPERTY(QString protocolName READ protocolName)
    00074     Q_PROPERTY(QString serviceName READ serviceName NOTIFY serviceNameChanged)
    00075     Q_PROPERTY(ProfilePtr profile READ profile NOTIFY profileChanged)
    00076     Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
    00077     Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged)
    00078     Q_PROPERTY(QString nickname READ nickname NOTIFY nicknameChanged)
    00079     Q_PROPERTY(Avatar avatar READ avatar NOTIFY avatarChanged)
    00080     Q_PROPERTY(QVariantMap parameters READ parameters NOTIFY parametersChanged)
    00081     Q_PROPERTY(ProtocolInfo* protocolInfo READ protocolInfo)
    00082     Q_PROPERTY(ConnectionCapabilities* capabilities READ capabilities NOTIFY capabilitiesChanged)
    00083     Q_PROPERTY(bool hasBeenOnline READ hasBeenOnline)
    00084     Q_PROPERTY(bool connectsAutomatically READ connectsAutomatically NOTIFY connectsAutomaticallyPropertyChanged)
    00085     // FIXME: (API/ABI break) Use Connection::Status
    00086     Q_PROPERTY(ConnectionStatus connectionStatus READ connectionStatus)
    00087     Q_PROPERTY(ConnectionStatusReason connectionStatusReason READ connectionStatusReason)
    00088     Q_PROPERTY(QString connectionError READ connectionError)
    00089     // FIXME: (API/ABI break) Use Connection::ErrorDetails
    00090     Q_PROPERTY(QVariantMap connectionErrorDetails READ connectionErrorDetails)
    00091     Q_PROPERTY(bool haveConnection READ _deprecated_haveConnection NOTIFY haveConnectionChanged)
    00092     Q_PROPERTY(ConnectionPtr connection READ connection NOTIFY connectionChanged)
    00093     Q_PROPERTY(bool changingPresence READ isChangingPresence NOTIFY changingPresence)
    00094     Q_PROPERTY(SimplePresence automaticPresence READ automaticPresence NOTIFY automaticPresenceChanged)
    00095     Q_PROPERTY(SimplePresence currentPresence READ currentPresence NOTIFY currentPresenceChanged)
    00096     Q_PROPERTY(SimplePresence requestedPresence READ requestedPresence NOTIFY requestedPresenceChanged)
    00097     Q_PROPERTY(bool online READ isOnline NOTIFY onlinenessChanged)
    00098     Q_PROPERTY(QString uniqueIdentifier READ uniqueIdentifier)
    00099     // FIXME: (API/ABI break) Remove connectionObjectPath
    00100     Q_PROPERTY(QString connectionObjectPath READ _deprecated_connectionObjectPath)
    00101     Q_PROPERTY(QString normalizedName READ normalizedName NOTIFY normalizedNameChanged)
    00102
    00103 public:
    00104     static const Feature FeatureCore;
    00105     static const Feature FeatureAvatar;
    00106     static const Feature FeatureProtocolInfo;
    00107     static const Feature FeatureCapabilities;
    00108     static const Feature FeatureProfile;
    00109
    00110     // FIXME: (API/ABI break) Remove both constructors that don't take factories as params.
    00111     static AccountPtr create(const QString &busName,
    00112             const QString &objectPath);
    00113     TELEPATHY_QT4_DEPRECATED static AccountPtr create(const QDBusConnection &bus,
    00114             const QString &busName, const QString &objectPath);
    00115
    00116     // FIXME: (API/ABI break) collapse these with the above variants and have all factories be
    00117     //        default params for the non-bus version
    00118     static AccountPtr create(const QString &busName, const QString &objectPath,
    00119             const ConnectionFactoryConstPtr &connectionFactory,
    00120             const ChannelFactoryConstPtr &channelFactory =
    00121                 ChannelFactory::create(QDBusConnection::sessionBus()),
    00122             const ContactFactoryConstPtr &contactFactory =
    00123                 ContactFactory::create());
    00124     // The bus-taking variant should never have default factories unless the bus is the last param
    00125     // which would be illogical?
    00126     static AccountPtr create(const QDBusConnection &bus,
    00127             const QString &busName, const QString &objectPath,
    00128             const ConnectionFactoryConstPtr &connectionFactory,
    00129             const ChannelFactoryConstPtr &channelFactory,
    00130             const ContactFactoryConstPtr &contactFactory =
    00131                 ContactFactory::create());
    00132
    00133     virtual ~Account();
    00134
    00135     ConnectionFactoryConstPtr connectionFactory() const;
    00136     ChannelFactoryConstPtr channelFactory() const;
    00137     ContactFactoryConstPtr contactFactory() const;
    00138
    00139     bool isValidAccount() const;
    00140
    00141     bool isEnabled() const;
    00142     PendingOperation *setEnabled(bool value);
    00143
    00144     QString cmName() const;
    00145
    00146     TELEPATHY_QT4_DEPRECATED QString protocol() const;
    00147     QString protocolName() const;
    00148
    00149     QString serviceName() const;
    00150     PendingOperation *setServiceName(const QString &value);
    00151
    00152     ProfilePtr profile() const;
    00153
    00154     QString displayName() const;
    00155     PendingOperation *setDisplayName(const QString &value);
    00156
    00157     TELEPATHY_QT4_DEPRECATED QString icon() const;
    00158     QString iconName() const;
    00159     TELEPATHY_QT4_DEPRECATED PendingOperation *setIcon(const QString &value);
    00160     PendingOperation *setIconName(const QString &value);
    00161
    00162     QString nickname() const;
    00163     PendingOperation *setNickname(const QString &value);
    00164
    00165     // TODO: We probably want to expose the avatar file name once we have the avatar token and MC
    00166     //       starts sharing the cache used by tp-qt4 and tp-glib and use Tp::AvatarData to represent
    00167     //       it as used in Tp::Contact
    00168     const Avatar &avatar() const;
    00169     PendingOperation *setAvatar(const Avatar &avatar);
    00170
    00171     QVariantMap parameters() const;
    00172     PendingStringList *updateParameters(const QVariantMap &set,
    00173             const QStringList &unset);
    00174
    00175     // FIXME: (API/ABI break) Use ProtocolInfoPtr
    00176     ProtocolInfo *protocolInfo() const;
    00177
    00178     // FIXME: (API/ABI break) Use ConnectionCapabilitiesPtr
    00179     ConnectionCapabilities *capabilities() const;
    00180
    00181     bool connectsAutomatically() const;
    00182     PendingOperation *setConnectsAutomatically(bool value);
    00183
    00184     bool hasBeenOnline() const;
    00185
    00186     // FIXME: (API/ABI break) Use Connection::Status
    00187     ConnectionStatus connectionStatus() const;
    00188     ConnectionStatusReason connectionStatusReason() const;
    00189     QString connectionError() const;
    00190     // FIXME: (API/ABI break) Use Connection::ErrorDetails
    00191     QVariantMap connectionErrorDetails() const;
    00192     TELEPATHY_QT4_DEPRECATED bool haveConnection() const;
    00193     ConnectionPtr connection() const;
    00194
    00195     bool isChangingPresence() const;
    00196
    00197     // FIXME: (API/ABI break) Use Presence instead of SimplePresence everywhere
    00198     // TODO: Add overload methods to set presence from a Profile::Presence
    00199     // TODO: Add usablePresences() that would return a list of presences that could be set on the
    00200     //       account
    00201     SimplePresence automaticPresence() const;
    00202     PendingOperation *setAutomaticPresence(
    00203             const SimplePresence &value);
    00204
    00205     SimplePresence currentPresence() const;
    00206
    00207     SimplePresence requestedPresence() const;
    00208     PendingOperation *setRequestedPresence(
    00209             const SimplePresence &value);
    00210
    00211     bool isOnline() const;
    00212
    00213     QString uniqueIdentifier() const;
    00214
    00215     TELEPATHY_QT4_DEPRECATED QString connectionObjectPath() const;
    00216
    00217     QString normalizedName() const;
    00218
    00219     PendingOperation *reconnect();
    00220
    00221     PendingOperation *remove();
    00222
    00223     PendingChannelRequest *ensureTextChat(
    00224             const QString &contactIdentifier,
    00225             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00226             const QString &preferredHandler = QString());
    00227     PendingChannelRequest *ensureTextChat(
    00228             const ContactPtr &contact,
    00229             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00230             const QString &preferredHandler = QString());
    00231
    00232     PendingChannelRequest *ensureTextChatroom(
    00233             const QString &roomName,
    00234             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00235             const QString &preferredHandler = QString());
    00236
    00237     PendingChannelRequest *ensureStreamedMediaCall(
    00238             const QString &contactIdentifier,
    00239             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00240             const QString &preferredHandler = QString());
    00241     PendingChannelRequest *ensureStreamedMediaCall(
    00242             const ContactPtr &contact,
    00243             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00244             const QString &preferredHandler = QString());
    00245
    00246     PendingChannelRequest *ensureStreamedMediaAudioCall(
    00247             const QString &contactIdentifier,
    00248             QDateTime userActionTime = QDateTime::currentDateTime(),
    00249             const QString &preferredHandler = QString());
    00250     PendingChannelRequest *ensureStreamedMediaAudioCall(
    00251             const ContactPtr &contact,
    00252             QDateTime userActionTime = QDateTime::currentDateTime(),
    00253             const QString &preferredHandler = QString());
    00254
    00255     PendingChannelRequest *ensureStreamedMediaVideoCall(
    00256             const QString &contactIdentifier,
    00257             bool withAudio = true,
    00258             QDateTime userActionTime = QDateTime::currentDateTime(),
    00259             const QString &preferredHandler = QString());
    00260     PendingChannelRequest *ensureStreamedMediaVideoCall(
    00261             const ContactPtr &contact,
    00262             bool withAudio = true,
    00263             QDateTime userActionTime = QDateTime::currentDateTime(),
    00264             const QString &preferredHandler = QString());
    00265
    00266     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureMediaCall(
    00267             const QString &contactIdentifier,
    00268             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00269             const QString &preferredHandler = QString());
    00270     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureMediaCall(
    00271             const ContactPtr &contact,
    00272             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00273             const QString &preferredHandler = QString());
    00274
    00275     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureAudioCall(
    00276             const QString &contactIdentifier,
    00277             QDateTime userActionTime = QDateTime::currentDateTime(),
    00278             const QString &preferredHandler = QString());
    00279     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureAudioCall(
    00280             const ContactPtr &contact,
    00281             QDateTime userActionTime = QDateTime::currentDateTime(),
    00282             const QString &preferredHandler = QString());
    00283
    00284     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureVideoCall(
    00285             const QString &contactIdentifier,
    00286             bool withAudio = true,
    00287             QDateTime userActionTime = QDateTime::currentDateTime(),
    00288             const QString &preferredHandler = QString());
    00289     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *ensureVideoCall(
    00290             const ContactPtr &contact,
    00291             bool withAudio = true,
    00292             QDateTime userActionTime = QDateTime::currentDateTime(),
    00293             const QString &preferredHandler = QString());
    00294
    00295     PendingChannelRequest *createFileTransfer(
    00296             const QString &contactIdentifier,
    00297             const FileTransferChannelCreationProperties &properties,
    00298             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00299             const QString &preferredHandler = QString());
    00300     PendingChannelRequest *createFileTransfer(
    00301             const ContactPtr &contact,
    00302             const FileTransferChannelCreationProperties &properties,
    00303             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00304             const QString &preferredHandler = QString());
    00305
    00306     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *createConferenceMediaCall(
    00307             const QList<ChannelPtr> &channels,
    00308             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00309             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00310             const QString &preferredHandler = QString());
    00311     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *createConferenceMediaCall(
    00312             const QList<ChannelPtr> &channels,
    00313             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00314             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00315             const QString &preferredHandler = QString());
    00316     PendingChannelRequest *createConferenceStreamedMediaCall(
    00317             const QList<ChannelPtr> &channels,
    00318             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00319             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00320             const QString &preferredHandler = QString());
    00321     PendingChannelRequest *createConferenceStreamedMediaCall(
    00322             const QList<ChannelPtr> &channels,
    00323             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00324             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00325             const QString &preferredHandler = QString());
    00326
    00327     PendingChannelRequest *createConferenceTextChat(
    00328             const QList<ChannelPtr> &channels,
    00329             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00330             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00331             const QString &preferredHandler = QString());
    00332     PendingChannelRequest *createConferenceTextChat(
    00333             const QList<ChannelPtr> &channels,
    00334             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00335             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00336             const QString &preferredHandler = QString());
    00337
    00338     PendingChannelRequest *createConferenceTextChatRoom(
    00339             const QString &roomName,
    00340             const QList<ChannelPtr> &channels,
    00341             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00342             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00343             const QString &preferredHandler = QString());
    00344     PendingChannelRequest *createConferenceTextChatRoom(
    00345             const QString &roomName,
    00346             const QList<ChannelPtr> &channels,
    00347             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00348             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00349             const QString &preferredHandler = QString());
    00350
    00351     PendingChannelRequest *createContactSearch(
    00352             const QString &server = QString(),
    00353             uint limit = 0,
    00354             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00355             const QString &preferredHandler = QString());
    00356     TELEPATHY_QT4_DEPRECATED PendingChannelRequest *createContactSearchChannel(
    00357             const QString &server = QString(),
    00358             uint limit = 0,
    00359             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00360             const QString &preferredHandler = QString());
    00361
    00362     // advanced
    00363     PendingChannelRequest *createChannel(
    00364             const QVariantMap &requestedProperties,
    00365             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00366             const QString &preferredHandler = QString());
    00367     PendingChannelRequest *ensureChannel(
    00368             const QVariantMap &requestedProperties,
    00369             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00370             const QString &preferredHandler = QString());
    00371
    00372     TELEPATHY_QT4_DEPRECATED inline Client::DBus::PropertiesInterface *propertiesInterface() const
    00373     {
    00374         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
    00375     }
    00376
    00377     TELEPATHY_QT4_DEPRECATED inline Client::AccountInterfaceAvatarInterface *avatarInterface(
    00378             InterfaceSupportedChecking check = CheckInterfaceSupported) const
    00379     {
    00380         return optionalInterface<Client::AccountInterfaceAvatarInterface>(check);
    00381     }
    00382
    00383 Q_SIGNALS:
    00384     void removed();
    00385     void serviceNameChanged(const QString &serviceName);
    00386     void profileChanged(const Tp::ProfilePtr &profile);
    00387     void displayNameChanged(const QString &displayName);
    00388     // FIXME: (API/ABI break) Remove iconChanged in favor of iconNameChanged
    00389     void iconChanged(const QString &iconName);
    00390     void iconNameChanged(const QString &iconName);
    00391     void nicknameChanged(const QString &nickname);
    00392     void normalizedNameChanged(const QString &normalizedName);
    00393     void validityChanged(bool validity);
    00394     void stateChanged(bool state);
    00395     void capabilitiesChanged(Tp::ConnectionCapabilities *capabilities);
    00396     void connectsAutomaticallyPropertyChanged(bool connectsAutomatically);
    00397     void firstOnline();
    00398     // FIXME: (API/ABI break) Use high-level class for parameters
    00399     void parametersChanged(const QVariantMap &parameters);
    00400     void changingPresence(bool value);
    00401     // FIXME: (API/ABI break) Remove const
    00402     void automaticPresenceChanged(const Tp::SimplePresence &automaticPresence) const;
    00403     // FIXME: (API/ABI break) Remove const
    00404     void currentPresenceChanged(const Tp::SimplePresence &currentPresence) const;
    00405     // FIXME: (API/ABI break) Remove const
    00406     void requestedPresenceChanged(const Tp::SimplePresence &requestedPresence) const;
    00407     void onlinenessChanged(bool online);
    00408     void avatarChanged(const Tp::Avatar &avatar);
    00409     void connectionStatusChanged(Tp::Connection::Status status);
    00410     // FIXME: (API/ABI break) Remove connectionStatusChanged in favor of connectionStatusChanged
    00411     //        taking error and errorDetails as params.
    00412     void connectionStatusChanged(Tp::ConnectionStatus status,
    00413             Tp::ConnectionStatusReason statusReason);
    00414     // FIXME: (API/ABI break) Remove statusChanged in favor of connectionStatusChanged
    00415     //        taking error and errorDetails as params.
    00416     void statusChanged(Tp::ConnectionStatus status,
    00417             Tp::ConnectionStatusReason statusReason,
    00418             const QString &error, const QVariantMap &errorDetails);
    00419     void connectionChanged(const Tp::ConnectionPtr &connection);
    00420     // FIXME: (API/ABI break) Remove haveConnectionChanged in favor of connectionChanged
    00421     void haveConnectionChanged(bool haveConnection);
    00422
    00423     // TODO: (API/ABI break) Move this to Tp::Object probably
    00424     void propertyChanged(const QString &propertyName);
    00425
    00426 protected:
    00427     TELEPATHY_QT4_DEPRECATED Account(const QString &busName, const QString &objectPath);
    00428     TELEPATHY_QT4_DEPRECATED Account(const QDBusConnection &bus,
    00429             const QString &busName, const QString &objectPath);
    00430     Account(const QDBusConnection &bus,
    00431             const QString &busName, const QString &objectPath,
    00432             const ConnectionFactoryConstPtr &connectionFactory,
    00433             const ChannelFactoryConstPtr &channelFactory,
    00434             const ContactFactoryConstPtr &contactFactory);
    00435
    00436     Client::AccountInterface *baseInterface() const;
    00437
    00438     // FIXME: (API/ABI break) Remove connectNotify
    00439     void connectNotify(const char *);
    00440
    00441 private Q_SLOTS:
    00442     void gotMainProperties(QDBusPendingCallWatcher *);
    00443     void gotAvatar(QDBusPendingCallWatcher *);
    00444     void onAvatarChanged();
    00445     void onConnectionManagerReady(Tp::PendingOperation *);
    00446     void onConnectionReady(Tp::PendingOperation *);
    00447     void onPropertyChanged(const QVariantMap &delta);
    00448     void onRemoved();
    00449     void onConnectionBuilt(Tp::PendingOperation *);
    00450
    00451 private:
    00452     struct Private;
    00453     friend struct Private;
    00454
    00455     // TODO: (API/ABI break) Move this to Tp::Object probably
    00456     void notify(const char *propertyName);
    00457
    00458     QString _deprecated_connectionObjectPath() const;
    00459     bool _deprecated_haveConnection() const;
    00460
    00461     Private *mPriv;
    00462 };
    00463
    00464 } // Tp
    00465
    00466 #endif