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