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

account.h

    00001
    00023 #ifndef _TelepathyQt_account_h_HEADER_GUARD_
    00024 #define _TelepathyQt_account_h_HEADER_GUARD_
    00025
    00026 #ifndef IN_TP_QT_HEADER
    00027 #error IN_TP_QT_HEADER
    00028 #endif
    00029
    00030 #include <TelepathyQt/_gen/cli-account.h>
    00031
    00032 #include <TelepathyQt/ChannelRequestHints>
    00033 #include <TelepathyQt/Connection>
    00034 #include <TelepathyQt/ConnectionCapabilities>
    00035 #include <TelepathyQt/ConnectionFactory>
    00036 #include <TelepathyQt/ContactFactory>
    00037 #include <TelepathyQt/ChannelFactory>
    00038 #include <TelepathyQt/ChannelDispatcherInterface>
    00039 #include <TelepathyQt/DBus>
    00040 #include <TelepathyQt/DBusProxy>
    00041 #include <TelepathyQt/FileTransferChannelCreationProperties>
    00042 #include <TelepathyQt/OptionalInterfaceFactory>
    00043 #include <TelepathyQt/Presence>
    00044 #include <TelepathyQt/PresenceSpec>
    00045 #include <TelepathyQt/ProtocolInfo>
    00046 #include <TelepathyQt/ReadinessHelper>
    00047 #include <TelepathyQt/Types>
    00048 #include <TelepathyQt/Constants>
    00049 #include <TelepathyQt/SharedPtr>
    00050
    00051 #include <QSet>
    00052 #include <QString>
    00053 #include <QStringList>
    00054 #include <QVariantMap>
    00055
    00056 namespace Tp
    00057 {
    00058
    00059 class Account;
    00060 class Connection;
    00061 class PendingChannel;
    00062 class PendingChannelRequest;
    00063 class PendingConnection;
    00064 class PendingOperation;
    00065 class PendingReady;
    00066 class PendingStringList;
    00067
    00068 class TP_QT_EXPORT Account : public StatelessDBusProxy,
    00069                 public OptionalInterfaceFactory<Account>
    00070 {
    00071     Q_OBJECT
    00072     Q_DISABLE_COPY(Account)
    00073     Q_PROPERTY(bool valid READ isValidAccount NOTIFY validityChanged)
    00074     Q_PROPERTY(bool enabled READ isEnabled NOTIFY stateChanged)
    00075     Q_PROPERTY(QString cmName READ cmName)
    00076     Q_PROPERTY(QString protocolName READ protocolName)
    00077     Q_PROPERTY(QString serviceName READ serviceName NOTIFY serviceNameChanged)
    00078     Q_PROPERTY(ProfilePtr profile READ profile NOTIFY profileChanged)
    00079     Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
    00080     Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged)
    00081     Q_PROPERTY(QString nickname READ nickname NOTIFY nicknameChanged)
    00082     Q_PROPERTY(AvatarSpec avatarRequirements READ avatarRequirements)
    00083     Q_PROPERTY(Avatar avatar READ avatar NOTIFY avatarChanged)
    00084     Q_PROPERTY(QVariantMap parameters READ parameters NOTIFY parametersChanged)
    00085     Q_PROPERTY(ProtocolInfo protocolInfo READ protocolInfo)
    00086     Q_PROPERTY(ConnectionCapabilities capabilities READ capabilities NOTIFY capabilitiesChanged)
    00087     Q_PROPERTY(bool hasBeenOnline READ hasBeenOnline)
    00088     Q_PROPERTY(bool connectsAutomatically READ connectsAutomatically NOTIFY connectsAutomaticallyPropertyChanged)
    00089     Q_PROPERTY(ConnectionStatus connectionStatus READ connectionStatus NOTIFY connectionStatusChanged)
    00090     Q_PROPERTY(ConnectionStatusReason connectionStatusReason READ connectionStatusReason)
    00091     Q_PROPERTY(QString connectionError READ connectionError)
    00092     Q_PROPERTY(Tp::Connection::ErrorDetails connectionErrorDetails READ connectionErrorDetails)
    00093     Q_PROPERTY(ConnectionPtr connection READ connection NOTIFY connectionChanged)
    00094     Q_PROPERTY(bool changingPresence READ isChangingPresence NOTIFY changingPresence)
    00095     Q_PROPERTY(Presence automaticPresence READ automaticPresence NOTIFY automaticPresenceChanged)
    00096     Q_PROPERTY(Presence currentPresence READ currentPresence NOTIFY currentPresenceChanged)
    00097     Q_PROPERTY(Presence requestedPresence READ requestedPresence NOTIFY requestedPresenceChanged)
    00098     Q_PROPERTY(bool online READ isOnline NOTIFY onlinenessChanged)
    00099     Q_PROPERTY(QString uniqueIdentifier READ uniqueIdentifier)
    00100     Q_PROPERTY(QString normalizedName READ normalizedName NOTIFY normalizedNameChanged)
    00101
    00102 public:
    00103     static const Feature FeatureCore;
    00104     static const Feature FeatureAvatar;
    00105     static const Feature FeatureProtocolInfo;
    00106     static const Feature FeatureCapabilities;
    00107     static const Feature FeatureProfile;
    00108
    00109     static AccountPtr create(const QString &busName, const QString &objectPath,
    00110             const ConnectionFactoryConstPtr &connectionFactory =
    00111                 ConnectionFactory::create(QDBusConnection::sessionBus()),
    00112             const ChannelFactoryConstPtr &channelFactory =
    00113                 ChannelFactory::create(QDBusConnection::sessionBus()),
    00114             const ContactFactoryConstPtr &contactFactory =
    00115                 ContactFactory::create());
    00116     static AccountPtr create(const QDBusConnection &bus,
    00117             const QString &busName, const QString &objectPath,
    00118             const ConnectionFactoryConstPtr &connectionFactory,
    00119             const ChannelFactoryConstPtr &channelFactory,
    00120             const ContactFactoryConstPtr &contactFactory =
    00121                 ContactFactory::create());
    00122     virtual ~Account();
    00123
    00124     ConnectionFactoryConstPtr connectionFactory() const;
    00125     ChannelFactoryConstPtr channelFactory() const;
    00126     ContactFactoryConstPtr contactFactory() const;
    00127
    00128     bool isValidAccount() const;
    00129
    00130     bool isEnabled() const;
    00131     PendingOperation *setEnabled(bool value);
    00132
    00133     QString cmName() const;
    00134
    00135     QString protocolName() const;
    00136
    00137     QString serviceName() const;
    00138     PendingOperation *setServiceName(const QString &value);
    00139
    00140     ProfilePtr profile() const;
    00141
    00142     QString displayName() const;
    00143     PendingOperation *setDisplayName(const QString &value);
    00144
    00145     QString iconName() const;
    00146     PendingOperation *setIconName(const QString &value);
    00147
    00148     QString nickname() const;
    00149     PendingOperation *setNickname(const QString &value);
    00150
    00151     AvatarSpec avatarRequirements() const;
    00152     // TODO: We probably want to expose the avatar file name once we have the avatar token and MC
    00153     //       starts sharing the cache used by tp-qt and tp-glib and use Tp::AvatarData to represent
    00154     //       it as used in Tp::Contact
    00155     const Avatar &avatar() const;
    00156     PendingOperation *setAvatar(const Avatar &avatar);
    00157
    00158     QVariantMap parameters() const;
    00159     PendingStringList *updateParameters(const QVariantMap &set,
    00160             const QStringList &unset);
    00161
    00162     ProtocolInfo protocolInfo() const;
    00163
    00164     ConnectionCapabilities capabilities() const;
    00165
    00166     bool connectsAutomatically() const;
    00167     PendingOperation *setConnectsAutomatically(bool value);
    00168
    00169     bool hasBeenOnline() const;
    00170
    00171     ConnectionStatus connectionStatus() const;
    00172     ConnectionStatusReason connectionStatusReason() const;
    00173     QString connectionError() const;
    00174     Connection::ErrorDetails connectionErrorDetails() const;
    00175     ConnectionPtr connection() const;
    00176
    00177     bool isChangingPresence() const;
    00178
    00179     PresenceSpecList allowedPresenceStatuses(bool includeAllStatuses = false) const;
    00180     uint maxPresenceStatusMessageLength() const;
    00181
    00182     // TODO: Add overload methods to set presence from a Profile::Presence
    00183     // TODO: Add usablePresences() that would return a list of presences that could be set on the
    00184     //       account
    00185     Presence automaticPresence() const;
    00186     PendingOperation *setAutomaticPresence(const Presence &presence);
    00187
    00188     Presence currentPresence() const;
    00189
    00190     Presence requestedPresence() const;
    00191     PendingOperation *setRequestedPresence(const Presence &presence);
    00192
    00193     bool isOnline() const;
    00194
    00195     QString uniqueIdentifier() const;
    00196
    00197     QString normalizedName() const;
    00198
    00199     PendingOperation *reconnect();
    00200
    00201     PendingOperation *remove();
    00202
    00203     bool supportsRequestHints() const;
    00204     bool requestsSucceedWithChannel() const;
    00205
    00206     PendingChannelRequest *ensureTextChat(
    00207             const QString &contactIdentifier,
    00208             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00209             const QString &preferredHandler = QString(),
    00210             const ChannelRequestHints &hints = ChannelRequestHints());
    00211     PendingChannelRequest *ensureTextChat(
    00212             const ContactPtr &contact,
    00213             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00214             const QString &preferredHandler = QString(),
    00215             const ChannelRequestHints &hints = ChannelRequestHints());
    00216
    00217     PendingChannelRequest *ensureTextChatroom(
    00218             const QString &roomName,
    00219             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00220             const QString &preferredHandler = QString(),
    00221             const ChannelRequestHints &hints = ChannelRequestHints());
    00222
    00223     PendingChannelRequest *ensureStreamedMediaCall(
    00224             const QString &contactIdentifier,
    00225             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00226             const QString &preferredHandler = QString(),
    00227             const ChannelRequestHints &hints = ChannelRequestHints());
    00228     PendingChannelRequest *ensureStreamedMediaCall(
    00229             const ContactPtr &contact,
    00230             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00231             const QString &preferredHandler = QString(),
    00232             const ChannelRequestHints &hints = ChannelRequestHints());
    00233     PendingChannelRequest *ensureStreamedMediaAudioCall(
    00234             const QString &contactIdentifier,
    00235             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00236             const QString &preferredHandler = QString(),
    00237             const ChannelRequestHints &hints = ChannelRequestHints());
    00238     PendingChannelRequest *ensureStreamedMediaAudioCall(
    00239             const ContactPtr &contact,
    00240             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00241             const QString &preferredHandler = QString(),
    00242             const ChannelRequestHints &hints = ChannelRequestHints());
    00243     PendingChannelRequest *ensureStreamedMediaVideoCall(
    00244             const QString &contactIdentifier,
    00245             bool withAudio = true,
    00246             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00247             const QString &preferredHandler = QString(),
    00248             const ChannelRequestHints &hints = ChannelRequestHints());
    00249     PendingChannelRequest *ensureStreamedMediaVideoCall(
    00250             const ContactPtr &contact,
    00251             bool withAudio = false,
    00252             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00253             const QString &preferredHandler = QString(),
    00254             const ChannelRequestHints &hints = ChannelRequestHints());
    00255
    00256     PendingChannelRequest *createFileTransfer(
    00257             const QString &contactIdentifier,
    00258             const FileTransferChannelCreationProperties &properties,
    00259             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00260             const QString &preferredHandler = QString(),
    00261             const ChannelRequestHints &hints = ChannelRequestHints());
    00262     PendingChannelRequest *createFileTransfer(
    00263             const ContactPtr &contact,
    00264             const FileTransferChannelCreationProperties &properties,
    00265             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00266             const QString &preferredHandler = QString(),
    00267             const ChannelRequestHints &hints = ChannelRequestHints());
    00268
    00269     PendingChannelRequest *createStreamTube(
    00270             const QString &contactIdentifier,
    00271             const QString &service,
    00272             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00273             const QString &preferredHandler = QString(),
    00274             const ChannelRequestHints &hints = ChannelRequestHints());
    00275     PendingChannelRequest *createStreamTube(
    00276             const ContactPtr &contact,
    00277             const QString &service,
    00278             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00279             const QString &preferredHandler = QString(),
    00280             const ChannelRequestHints &hints = ChannelRequestHints());
    00281
    00282     PendingChannelRequest *createConferenceStreamedMediaCall(
    00283             const QList<ChannelPtr> &channels,
    00284             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00285             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00286             const QString &preferredHandler = QString(),
    00287             const ChannelRequestHints &hints = ChannelRequestHints());
    00288     PendingChannelRequest *createConferenceStreamedMediaCall(
    00289             const QList<ChannelPtr> &channels,
    00290             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00291             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00292             const QString &preferredHandler = QString(),
    00293             const ChannelRequestHints &hints = ChannelRequestHints());
    00294
    00295     PendingChannelRequest *createConferenceTextChat(
    00296             const QList<ChannelPtr> &channels,
    00297             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00298             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00299             const QString &preferredHandler = QString(),
    00300             const ChannelRequestHints &hints = ChannelRequestHints());
    00301     PendingChannelRequest *createConferenceTextChat(
    00302             const QList<ChannelPtr> &channels,
    00303             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00304             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00305             const QString &preferredHandler = QString(),
    00306             const ChannelRequestHints &hints = ChannelRequestHints());
    00307
    00308     PendingChannelRequest *createConferenceTextChatroom(
    00309             const QString &roomName,
    00310             const QList<ChannelPtr> &channels,
    00311             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00312             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00313             const QString &preferredHandler = QString(),
    00314             const ChannelRequestHints &hints = ChannelRequestHints());
    00315     PendingChannelRequest *createConferenceTextChatroom(
    00316             const QString &roomName,
    00317             const QList<ChannelPtr> &channels,
    00318             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00319             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00320             const QString &preferredHandler = QString(),
    00321             const ChannelRequestHints &hints = ChannelRequestHints());
    00322
    00323     PendingChannelRequest *createContactSearch(
    00324             const QString &server,
    00325             uint limit = 0,
    00326             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00327             const QString &preferredHandler = QString(),
    00328             const ChannelRequestHints &hints = ChannelRequestHints());
    00329
    00330     PendingChannel *ensureAndHandleTextChat(
    00331             const QString &contactIdentifier,
    00332             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00333     PendingChannel *ensureAndHandleTextChat(
    00334             const ContactPtr &contact,
    00335             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00336
    00337     PendingChannel *ensureAndHandleTextChatroom(
    00338             const QString &roomName,
    00339             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00340
    00341     PendingChannel *ensureAndHandleStreamedMediaCall(
    00342             const QString &contactIdentifier,
    00343             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00344     PendingChannel *ensureAndHandleStreamedMediaCall(
    00345             const ContactPtr &contact,
    00346             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00347
    00348     PendingChannel *ensureAndHandleStreamedMediaAudioCall(
    00349             const QString &contactIdentifier,
    00350             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00351     PendingChannel *ensureAndHandleStreamedMediaAudioCall(
    00352             const ContactPtr &contact,
    00353             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00354
    00355     PendingChannel *ensureAndHandleStreamedMediaVideoCall(
    00356             const QString &contactIdentifier,
    00357             bool withAudio = true,
    00358             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00359     PendingChannel *ensureAndHandleStreamedMediaVideoCall(
    00360             const ContactPtr &contact,
    00361             bool withAudio = true,
    00362             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00363
    00364     PendingChannel *createAndHandleFileTransfer(
    00365             const QString &contactIdentifier,
    00366             const FileTransferChannelCreationProperties &properties,
    00367             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00368     PendingChannel *createAndHandleFileTransfer(
    00369             const ContactPtr &contact,
    00370             const FileTransferChannelCreationProperties &properties,
    00371             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00372
    00373     PendingChannel *createAndHandleStreamTube(
    00374             const QString &contactIdentifier,
    00375             const QString &service,
    00376             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00377     PendingChannel *createAndHandleStreamTube(
    00378             const ContactPtr &contact,
    00379             const QString &service,
    00380             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00381
    00382     PendingChannel *createAndHandleConferenceTextChat(
    00383             const QList<ChannelPtr> &channels,
    00384             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00385             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00386     PendingChannel *createAndHandleConferenceTextChat(
    00387             const QList<ChannelPtr> &channels,
    00388             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00389             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00390
    00391     PendingChannel *createAndHandleConferenceTextChatroom(
    00392             const QString &roomName,
    00393             const QList<ChannelPtr> &channels,
    00394             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00395             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00396     PendingChannel *createAndHandleConferenceTextChatroom(
    00397             const QString &roomName,
    00398             const QList<ChannelPtr> &channels,
    00399             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00400             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00401
    00402     PendingChannel *createAndHandleConferenceStreamedMediaCall(
    00403             const QList<ChannelPtr> &channels,
    00404             const QStringList &initialInviteeContactsIdentifiers = QStringList(),
    00405             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00406     PendingChannel *createAndHandleConferenceStreamedMediaCall(
    00407             const QList<ChannelPtr> &channels,
    00408             const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
    00409             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00410
    00411     PendingChannel *createAndHandleContactSearch(
    00412             const QString &server = QString(),
    00413             uint limit = 0,
    00414             const QDateTime &userActionTime = QDateTime::currentDateTime());
    00415
    00416     // advanced
    00417     PendingChannelRequest *createChannel(
    00418             const QVariantMap &requestedProperties,
    00419             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00420             const QString &preferredHandler = QString(),
    00421             const ChannelRequestHints &hints = ChannelRequestHints());
    00422
    00423     PendingChannelRequest *ensureChannel(
    00424             const QVariantMap &requestedProperties,
    00425             const QDateTime &userActionTime = QDateTime::currentDateTime(),
    00426             const QString &preferredHandler = QString(),
    00427             const ChannelRequestHints &hints = ChannelRequestHints());
    00428
    00429     PendingChannel *createAndHandleChannel(
    00430             const QVariantMap &requestedProperties,
    00431             const QDateTime &userActionTime);
    00432     PendingChannel *ensureAndHandleChannel(
    00433             const QVariantMap &requestedProperties,
    00434             const QDateTime &userActionTime);
    00435
    00436 Q_SIGNALS:
    00437     void removed();
    00438     void serviceNameChanged(const QString &serviceName);
    00439     void profileChanged(const Tp::ProfilePtr &profile);
    00440     void displayNameChanged(const QString &displayName);
    00441     void iconNameChanged(const QString &iconName);
    00442     void nicknameChanged(const QString &nickname);
    00443     void normalizedNameChanged(const QString &normalizedName);
    00444     void validityChanged(bool validity);
    00445     void stateChanged(bool state);
    00446     void capabilitiesChanged(const Tp::ConnectionCapabilities &capabilities);
    00447     void connectsAutomaticallyPropertyChanged(bool connectsAutomatically);
    00448     void firstOnline();
    00449     void parametersChanged(const QVariantMap &parameters);
    00450     void changingPresence(bool value);
    00451     void automaticPresenceChanged(const Tp::Presence &automaticPresence);
    00452     void currentPresenceChanged(const Tp::Presence &currentPresence);
    00453     void requestedPresenceChanged(const Tp::Presence &requestedPresence);
    00454     void onlinenessChanged(bool online);
    00455     void avatarChanged(const Tp::Avatar &avatar);
    00456     void connectionStatusChanged(Tp::ConnectionStatus status);
    00457     void connectionChanged(const Tp::ConnectionPtr &connection);
    00458
    00459 protected:
    00460     friend class PendingChannelRequest; // to access dispatcherInterface()
    00461
    00462     Account(const QDBusConnection &bus,
    00463             const QString &busName, const QString &objectPath,
    00464             const ConnectionFactoryConstPtr &connectionFactory,
    00465             const ChannelFactoryConstPtr &channelFactory,
    00466             const ContactFactoryConstPtr &contactFactory,
    00467             const Feature &coreFeature);
    00468
    00469     Client::AccountInterface *baseInterface() const;
    00470     Client::ChannelDispatcherInterface *dispatcherInterface() const;
    00471
    00472 private Q_SLOTS:
    00473     TP_QT_NO_EXPORT void onDispatcherIntrospected(Tp::PendingOperation *op);
    00474     TP_QT_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *);
    00475     TP_QT_NO_EXPORT void gotAvatar(QDBusPendingCallWatcher *);
    00476     TP_QT_NO_EXPORT void onAvatarChanged();
    00477     TP_QT_NO_EXPORT void onConnectionManagerReady(Tp::PendingOperation *);
    00478     TP_QT_NO_EXPORT void onConnectionReady(Tp::PendingOperation *);
    00479     TP_QT_NO_EXPORT void onPropertyChanged(const QVariantMap &delta);
    00480     TP_QT_NO_EXPORT void onRemoved();
    00481     TP_QT_NO_EXPORT void onConnectionBuilt(Tp::PendingOperation *);
    00482
    00483 private:
    00484     struct Private;
    00485     friend struct Private;
    00486
    00487     Private *mPriv;
    00488 };
    00489
    00490 } // Tp
    00491
    00492 #endif