libqutim  0.3.1.0
account.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef ACCOUNT_H
27 #define ACCOUNT_H
28 
29 #include "configbase.h"
30 #include "menucontroller.h"
31 #include "status.h"
32 #include <QMetaType>
33 
34 namespace qutim_sdk_0_3
35 {
36 class ChatUnit;
37 class Contact;
38 class Protocol;
39 class Conference;
40 class AccountPrivate;
41 class GroupChatManager;
42 class ContactsFactory;
43 class InfoRequestFactory;
44 
45 class Account;
46 typedef QList<Account*> AccountList;
47 
48 #ifndef Q_QDOC
49 class AccountHook : public MenuController
50 {
51 public:
52  virtual const QMetaObject *metaObject() const;
53  virtual void *qt_metacast(const char *);
54  virtual int qt_metacall(QMetaObject::Call, int, void **);
55 
56 private:
57  AccountHook(AccountPrivate &p, Protocol *protocol);
58  Q_DECLARE_PRIVATE(Account)
59  friend class Account;
60 };
61 #endif
62 
66 class LIBQUTIM_EXPORT Account
67 #ifndef Q_QDOC
68  : public AccountHook
69 #else
70  : public MenuController
71 #endif
72 {
73  Q_DECLARE_PRIVATE(Account)
74  Q_OBJECT
75  Q_PROPERTY(QString id READ id)
76  Q_PROPERTY(qutim_sdk_0_3::Protocol* protocol READ protocol CONSTANT)
77  Q_PROPERTY(qutim_sdk_0_3::Status status READ status WRITE setStatus NOTIFY statusChanged)
78  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
79  Q_PROPERTY(QVariantMap parameters READ parameters WRITE updateParameters NOTIFY parametersChanged)
80 public:
82  // all values below are reserved for MenuController
83  ReadParametersHook = 0x100,
84  UpdateParametersHook
85  };
86 
88  {
89  QVariantMap parameters;
90  QStringList reconnectionRequired;
91  };
92 
98  Account(const QString &id, Protocol *protocol);
99  Account(AccountPrivate &p, Protocol *protocol);
103  virtual ~Account();
107  QString id() const;
111  virtual QString name() const;
116  Config config();
121  ConfigGroup config(const QString &name);
125  Status status() const;
129  Protocol *protocol();
133  const Protocol *protocol() const;
139  virtual void setStatus(Status status);
144  virtual ChatUnit *getUnitForSession(ChatUnit *unit);
152  virtual ChatUnit *getUnit(const QString &unitId, bool create = false) = 0;
153 
154  Q_INVOKABLE inline qutim_sdk_0_3::ChatUnit *unit(const QString &unitId, bool create = false);
155 
156  QVariantMap parameters() const;
157  Q_INVOKABLE QStringList updateParameters(const QVariantMap &parameters);
158 
159  static AccountList all();
165  GroupChatManager *groupChatManager();
166  ContactsFactory *contactsFactory();
167  InfoRequestFactory *infoRequestFactory() const;
168 protected:
174  void resetGroupChatManager(GroupChatManager *manager = 0);
175  void setContactsFactory(ContactsFactory *factory);
176  void setInfoRequestFactory(InfoRequestFactory *factory);
177 signals:
181  void contactCreated(qutim_sdk_0_3::Contact *contact);
185  void conferenceCreated(qutim_sdk_0_3::Conference *conference);
189  void nameChanged(const QString &current, const QString &previous);
193  void statusChanged(const qutim_sdk_0_3::Status &current, const qutim_sdk_0_3::Status &previous);
199  void groupChatManagerChanged(qutim_sdk_0_3::GroupChatManager *manager);
200  void parametersChanged(const QVariantMap &parameters);
201 };
202 
203 ChatUnit *Account::unit(const QString &unitId, bool create)
204 {
205  return getUnit(unitId, create);
206 }
207 }
208 
210 Q_DECLARE_METATYPE(QList<qutim_sdk_0_3::Account*>)
211 
212 #endif // ACCOUNT_H
213 

Generated by Doxygen