libqutim
0.3.2.0
|
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::Protocol* protocol READ protocol CONSTANT) 00077 Q_PROPERTY(qutim_sdk_0_3::Status status READ status WRITE setStatus NOTIFY statusChanged) 00078 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 00079 Q_PROPERTY(QVariantMap parameters READ parameters WRITE updateParameters NOTIFY parametersChanged) 00080 public: 00081 enum AccountHookEnum { 00082 // all values below are reserved for MenuController 00083 ReadParametersHook = 0x100, 00084 UpdateParametersHook 00085 }; 00086 00087 struct UpdateParametersArgument 00088 { 00089 QVariantMap parameters; 00090 QStringList reconnectionRequired; 00091 }; 00092 00098 Account(const QString &id, Protocol *protocol); 00099 Account(AccountPrivate &p, Protocol *protocol); 00103 virtual ~Account(); 00107 QString id() const; 00111 virtual QString name() const; 00116 Config config(); 00121 ConfigGroup config(const QString &name); 00125 Status status() const; 00129 Protocol *protocol(); 00133 const Protocol *protocol() const; 00139 virtual void setStatus(Status status); 00144 virtual ChatUnit *getUnitForSession(ChatUnit *unit); 00152 virtual ChatUnit *getUnit(const QString &unitId, bool create = false) = 0; 00153 00154 Q_INVOKABLE inline qutim_sdk_0_3::ChatUnit *unit(const QString &unitId, bool create = false); 00155 00156 QVariantMap parameters() const; 00157 Q_INVOKABLE QStringList updateParameters(const QVariantMap ¶meters); 00158 00159 static AccountList all(); 00165 GroupChatManager *groupChatManager(); 00166 ContactsFactory *contactsFactory(); 00167 InfoRequestFactory *infoRequestFactory() const; 00168 protected: 00174 void resetGroupChatManager(GroupChatManager *manager = 0); 00175 void setContactsFactory(ContactsFactory *factory); 00176 void setInfoRequestFactory(InfoRequestFactory *factory); 00177 signals: 00181 void contactCreated(qutim_sdk_0_3::Contact *contact); 00185 void conferenceCreated(qutim_sdk_0_3::Conference *conference); 00189 void nameChanged(const QString ¤t, const QString &previous); 00193 void statusChanged(const qutim_sdk_0_3::Status ¤t, const qutim_sdk_0_3::Status &previous); 00199 void groupChatManagerChanged(qutim_sdk_0_3::GroupChatManager *manager); 00200 void parametersChanged(const QVariantMap ¶meters); 00201 }; 00202 00203 ChatUnit *Account::unit(const QString &unitId, bool create) 00204 { 00205 return getUnit(unitId, create); 00206 } 00207 } 00208 00209 Q_DECLARE_METATYPE(qutim_sdk_0_3::Account*) 00210 Q_DECLARE_METATYPE(QList<qutim_sdk_0_3::Account*>) 00211 00212 #endif // ACCOUNT_H 00213