libqutim 0.2.80.1
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef ACCOUNT_H 00027 #define ACCOUNT_H 00028 00029 #include "configbase.h" 00030 #include "menucontroller.h" 00031 #include "status.h" 00032 #include <QMetaType> 00033 00034 namespace qutim_sdk_0_3 00035 { 00036 class ChatUnit; 00037 class Contact; 00038 class Protocol; 00039 class Conference; 00040 class AccountPrivate; 00041 class GroupChatManager; 00042 class ContactsFactory; 00043 class InfoRequestFactory; 00044 00045 class Account; 00046 typedef QList<Account*> AccountList; 00047 00048 #ifndef Q_QDOC 00049 class AccountHook : public MenuController 00050 { 00051 public: 00052 virtual const QMetaObject *metaObject() const; 00053 virtual void *qt_metacast(const char *); 00054 virtual int qt_metacall(QMetaObject::Call, int, void **); 00055 00056 private: 00057 AccountHook(AccountPrivate &p, Protocol *protocol); 00058 Q_DECLARE_PRIVATE(Account) 00059 friend class Account; 00060 }; 00061 #endif 00062 00066 class LIBQUTIM_EXPORT Account 00067 #ifndef Q_QDOC 00068 : public AccountHook 00069 #else 00070 : public MenuController 00071 #endif 00072 { 00073 Q_DECLARE_PRIVATE(Account) 00074 Q_OBJECT 00075 Q_PROPERTY(QString id READ id) 00076 Q_PROPERTY(qutim_sdk_0_3::Status status READ status WRITE setStatus NOTIFY statusChanged) 00077 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 00078 Q_PROPERTY(QVariantMap parameters READ parameters WRITE updateParameters NOTIFY parametersChanged) 00079 public: 00080 enum AccountHookEnum { 00081 // all values below are reserved for MenuController 00082 ReadParametersHook = 0x100, 00083 UpdateParametersHook 00084 }; 00085 00086 struct UpdateParametersArgument 00087 { 00088 QVariantMap parameters; 00089 QStringList reconnectionRequired; 00090 }; 00091 00097 Account(const QString &id, Protocol *protocol); 00098 Account(AccountPrivate &p, Protocol *protocol); 00102 virtual ~Account(); 00106 QString id() const; 00110 virtual QString name() const; 00115 Config config(); 00120 ConfigGroup config(const QString &name); 00124 Status status() const; 00128 Protocol *protocol(); 00132 const Protocol *protocol() const; 00138 virtual void setStatus(Status status); 00143 virtual ChatUnit *getUnitForSession(ChatUnit *unit); 00151 virtual ChatUnit *getUnit(const QString &unitId, bool create = false) = 0; 00152 00153 Q_INVOKABLE inline qutim_sdk_0_3::ChatUnit *unit(const QString &unitId, bool create = false); 00154 00155 QVariantMap parameters() const; 00156 Q_INVOKABLE QStringList updateParameters(const QVariantMap ¶meters); 00157 00158 static AccountList all(); 00164 GroupChatManager *groupChatManager(); 00165 ContactsFactory *contactsFactory(); 00166 InfoRequestFactory *infoRequestFactory() const; 00167 protected: 00173 void resetGroupChatManager(GroupChatManager *manager = 0); 00174 void setContactsFactory(ContactsFactory *factory); 00175 void setInfoRequestFactory(InfoRequestFactory *factory); 00176 signals: 00180 void contactCreated(qutim_sdk_0_3::Contact *contact); 00184 void conferenceCreated(qutim_sdk_0_3::Conference *conference); 00188 void nameChanged(const QString ¤t, const QString &previous); 00192 void statusChanged(const qutim_sdk_0_3::Status ¤t, const qutim_sdk_0_3::Status &previous); 00198 void groupChatManagerChanged(qutim_sdk_0_3::GroupChatManager *manager); 00199 void parametersChanged(const QVariantMap ¶meters); 00200 }; 00201 00202 ChatUnit *Account::unit(const QString &unitId, bool create) 00203 { 00204 return getUnit(unitId, create); 00205 } 00206 } 00207 00208 Q_DECLARE_METATYPE(qutim_sdk_0_3::Account*) 00209 Q_DECLARE_METATYPE(QList<qutim_sdk_0_3::Account*>) 00210 00211 #endif // ACCOUNT_H 00212