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