libqutim  0.3.1.0
protocol.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 PROTOCOL_H
27 #define PROTOCOL_H
28 
29 #include "configbase.h"
30 #include <QStringList>
31 
32 class QWizardPage;
33 
34 namespace qutim_sdk_0_3
35 {
36 class ExtensionInfo;
37 class Contact;
38 class Account;
39 class ProtocolPrivate;
40 
41 class Protocol;
42 typedef QHash<QString, Protocol *> ProtocolHash;
43 
44 class LIBQUTIM_EXPORT AccountCreationWizard : public QObject
45 {
46  Q_OBJECT
47 public:
49  virtual ~AccountCreationWizard();
50  virtual QList<QWizardPage *> createPages(QWidget *parent) = 0;
51  ExtensionInfo info() const;
52 protected:
53  void setInfo(const ExtensionInfo &info);
54  virtual void virtual_hook(int id, void *data);
55 };
56 
57 class LIBQUTIM_EXPORT Protocol : public QObject
58 {
59  Q_OBJECT
60  Q_DECLARE_PRIVATE(Protocol)
61  Q_PROPERTY(QString id READ id)
62  Q_PROPERTY(QStringList supportedAccountParameters READ supportedAccountParameters CONSTANT)
63  // Q_FLAGS(DataType DataTypes)
64  // Q_FLAGS(RemoveFlag RemoveFlags)
65 public:
66  enum DataType {
68  ProtocolContainsContacts
69  };
70  enum RemoveFlag {
71  DeleteAccount = 0x01
72  };
73  enum ProtocolHook {
75  CreateAccountHook
76  };
77 
79  {
80  QString id;
81  QVariantMap parameters;
83  };
84 
85  // Q_DECLARE_FLAGS(RemoveFlags, RemoveFlag)
86  // Q_DECLARE_FLAGS(DataTypes, DataType)
87  Protocol();
88  Protocol(ProtocolPrivate &p);
89  virtual ~Protocol();
90  Config config();
91  ConfigGroup config(const QString &group);
92  QString id() const;
93  QStringList supportedAccountParameters() const;
94  Q_INVOKABLE Account *createAccount(const QString &id, const QVariantMap &parameters);
95  Q_INVOKABLE virtual QList<qutim_sdk_0_3::Account*> accounts() const = 0;
96  Q_INVOKABLE virtual qutim_sdk_0_3::Account *account(const QString &id) const = 0;
97  virtual QVariant data(DataType type);
103  Q_INVOKABLE virtual void removeAccount(qutim_sdk_0_3::Account *account, RemoveFlag flags = DeleteAccount);
104  static ProtocolHash all();
105 signals:
106  void accountCreated(qutim_sdk_0_3::Account *);
107  void accountRemoved(qutim_sdk_0_3::Account *);
108 protected:
109  virtual void virtual_hook(int id, void *data);
110 private:
111  virtual void loadAccounts() = 0;
112  friend class ModuleManager;
113 protected:
114  QScopedPointer<ProtocolPrivate> d_ptr;
115 };
116 }
117 
118 #endif // PROTOCOL_H
119 

Generated by Doxygen