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_cli_account_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_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/DBus>
00033 #include <TelepathyQt4/DBusProxy>
00034 #include <TelepathyQt4/OptionalInterfaceFactory>
00035 #include <TelepathyQt4/ReadinessHelper>
00036 #include <TelepathyQt4/ReadyObject>
00037 #include <TelepathyQt4/Types>
00038 #include <TelepathyQt4/Constants>
00039 #include <TelepathyQt4/SharedPtr>
00040 
00041 #include <QSet>
00042 #include <QString>
00043 #include <QStringList>
00044 #include <QVariantMap>
00045 
00046 namespace Tp
00047 {
00048 
00049 class Account;
00050 class Connection;
00051 class PendingConnection;
00052 class PendingOperation;
00053 class PendingReady;
00054 class ProtocolInfo;
00055 
00056 class Account : public StatelessDBusProxy,
00057                 private OptionalInterfaceFactory<Account>,
00058                 public ReadyObject,
00059                 public RefCounted
00060 
00061 {
00062     Q_OBJECT
00063     Q_DISABLE_COPY(Account)
00064 
00065 public:
00066     static const Feature FeatureCore;
00067     static const Feature FeatureAvatar;
00068     static const Feature FeatureProtocolInfo;
00069 
00070     static AccountPtr create(const QDBusConnection &bus,
00071             const QString &busName, const QString &objectPath);
00072     static AccountPtr create(const QString &busName,
00073             const QString &objectPath);
00074 
00075     virtual ~Account();
00076 
00077     bool isValidAccount() const;
00078 
00079     bool isEnabled() const;
00080     PendingOperation *setEnabled(bool value);
00081 
00082     QString cmName() const;
00083 
00084     QString protocol() const;
00085 
00086     QString displayName() const;
00087     PendingOperation *setDisplayName(const QString &value);
00088 
00089     QString icon() const;
00090     PendingOperation *setIcon(const QString &value);
00091 
00092     QString nickname() const;
00093     PendingOperation *setNickname(const QString &value);
00094 
00095     // requires spec 0.17.16
00096     const Avatar &avatar() const;
00097     PendingOperation *setAvatar(const Avatar &avatar);
00098 
00099     QVariantMap parameters() const;
00100     PendingOperation *updateParameters(const QVariantMap &set,
00101             const QStringList &unset);
00102 
00103     // comes from the ConnectionManager
00104     ProtocolInfo *protocolInfo() const;
00105 
00106     bool connectsAutomatically() const;
00107     PendingOperation *setConnectsAutomatically(bool value);
00108 
00109     bool hasBeenOnline() const;
00110 
00111     ConnectionStatus connectionStatus() const;
00112     ConnectionStatusReason connectionStatusReason() const;
00113     bool haveConnection() const;
00114     ConnectionPtr connection() const;
00115 
00116     SimplePresence automaticPresence() const;
00117     PendingOperation *setAutomaticPresence(
00118             const SimplePresence &value);
00119 
00120     SimplePresence currentPresence() const;
00121 
00122     SimplePresence requestedPresence() const;
00123     PendingOperation *setRequestedPresence(
00124             const SimplePresence &value);
00125 
00126     QString uniqueIdentifier() const;
00127 
00128     // doc as for advanced users
00129     QString connectionObjectPath() const;
00130 
00131     QString normalizedName() const;
00132 
00133     PendingOperation *remove();
00134 
00135     QStringList interfaces() const;
00136 
00137     template <class Interface>
00138     inline Interface *optionalInterface(
00139             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00140     {
00141         // Check for the remote object supporting the interface
00142         QString name(Interface::staticInterfaceName());
00143         if (check == CheckInterfaceSupported && !interfaces().contains(name)) {
00144             return 0;
00145         }
00146 
00147         // If present or forced, delegate to OptionalInterfaceFactory
00148         return OptionalInterfaceFactory<Account>::interface<Interface>();
00149     }
00150 
00151     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00152     {
00153         return optionalInterface<Client::DBus::PropertiesInterface>(BypassInterfaceCheck);
00154     }
00155 
00156     inline Client::AccountInterfaceAvatarInterface *avatarInterface(
00157             InterfaceSupportedChecking check = CheckInterfaceSupported) const
00158     {
00159         return optionalInterface<Client::AccountInterfaceAvatarInterface>(check);
00160     }
00161 
00162 Q_SIGNALS:
00163     void displayNameChanged(const QString &);
00164     void iconChanged(const QString &);
00165     void nicknameChanged(const QString &);
00166     void normalizedNameChanged(const QString &);
00167     void validityChanged(bool);
00168     void stateChanged(bool);
00169     void connectsAutomaticallyPropertyChanged(bool);
00170     void firstOnline();
00171     void parametersChanged(const QVariantMap &);
00172     void automaticPresenceChanged(const Tp::SimplePresence &) const;
00173     void currentPresenceChanged(const Tp::SimplePresence &) const;
00174     void requestedPresenceChanged(const Tp::SimplePresence &) const;
00175     void avatarChanged(const Tp::Avatar &);
00176     void connectionStatusChanged(Tp::ConnectionStatus,
00177             Tp::ConnectionStatusReason);
00178     void haveConnectionChanged(bool haveConnection);
00179 
00180 protected:
00181     Account(const QString &busName, const QString &objectPath);
00182     Account(const QDBusConnection &bus,
00183             const QString &busName, const QString &objectPath);
00184 
00185     Client::AccountInterface *baseInterface() const;
00186 
00187 private Q_SLOTS:
00188     void gotMainProperties(QDBusPendingCallWatcher *);
00189     void gotAvatar(QDBusPendingCallWatcher *);
00190     void onAvatarChanged();
00191     void onConnectionManagerReady(Tp::PendingOperation *);
00192     void onPropertyChanged(const QVariantMap &delta);
00193     void onRemoved();
00194 
00195 private:
00196     struct Private;
00197     friend struct Private;
00198     Private *mPriv;
00199 };
00200 
00201 } // Tp
00202 
00203 #endif


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