Home · Modules · All Classes · All Namespaces
base-protocol.h
1 
23 #ifndef _TelepathyQt_base_protocol_h_HEADER_GUARD_
24 #define _TelepathyQt_base_protocol_h_HEADER_GUARD_
25 
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29 
30 #include <TelepathyQt/AvatarSpec>
31 #include <TelepathyQt/Callbacks>
32 #include <TelepathyQt/DBusService>
33 #include <TelepathyQt/Global>
34 #include <TelepathyQt/PresenceSpecList>
35 #include <TelepathyQt/ProtocolParameterList>
36 #include <TelepathyQt/RequestableChannelClassSpecList>
37 #include <TelepathyQt/Types>
38 
39 #include <QDBusConnection>
40 
41 class QString;
42 class QStringList;
43 
44 namespace Tp
45 {
46 
47 class TP_QT_EXPORT BaseProtocol : public DBusService
48 {
49  Q_OBJECT
50  Q_DISABLE_COPY(BaseProtocol)
51 
52 public:
53  static BaseProtocolPtr create(const QString &name)
54  {
55  return BaseProtocolPtr(new BaseProtocol(QDBusConnection::sessionBus(), name));
56  }
57  template<typename BaseProtocolSubclass>
58  static SharedPtr<BaseProtocolSubclass> create(const QString &name)
59  {
60  return SharedPtr<BaseProtocolSubclass>(new BaseProtocolSubclass(
61  QDBusConnection::sessionBus(), name));
62  }
63  static BaseProtocolPtr create(const QDBusConnection &dbusConnection, const QString &name)
64  {
65  return BaseProtocolPtr(new BaseProtocol(dbusConnection, name));
66  }
67  template<typename BaseProtocolSubclass>
68  static SharedPtr<BaseProtocolSubclass> create(const QDBusConnection &dbusConnection,
69  const QString &name)
70  {
71  return SharedPtr<BaseProtocolSubclass>(new BaseProtocolSubclass(dbusConnection, name));
72  }
73 
74  virtual ~BaseProtocol();
75 
76  QString name() const;
77 
78  QVariantMap immutableProperties() const;
79 
80  // Proto
81  QStringList connectionInterfaces() const;
82  void setConnectionInterfaces(const QStringList &connInterfaces);
83 
84  ProtocolParameterList parameters() const;
85  void setParameters(const ProtocolParameterList &parameters);
86 
87  RequestableChannelClassSpecList requestableChannelClasses() const;
88  void setRequestableChannelClasses(const RequestableChannelClassSpecList &rccSpecs);
89 
90  QString vcardField() const;
91  void setVCardField(const QString &vcardField);
92 
93  QString englishName() const;
94  void setEnglishName(const QString &englishName);
95 
96  QString iconName() const;
97  void setIconName(const QString &iconName);
98 
99  QStringList authenticationTypes() const;
100  void setAuthenticationTypes(const QStringList &authenticationTypes);
101 
103  void setCreateConnectionCallback(const CreateConnectionCallback &cb);
104  Tp::BaseConnectionPtr createConnection(const QVariantMap &parameters, DBusError *error);
105 
107  void setIdentifyAccountCallback(const IdentifyAccountCallback &cb);
108  QString identifyAccount(const QVariantMap &parameters, DBusError *error);
109 
111  void setNormalizeContactCallback(const NormalizeContactCallback &cb);
112  QString normalizeContact(const QString &contactId, DBusError *error);
113 
114  QList<AbstractProtocolInterfacePtr> interfaces() const;
115  AbstractProtocolInterfacePtr interface(const QString & interfaceName) const;
116  bool plugInterface(const AbstractProtocolInterfacePtr &interface);
117 
118 protected:
119  BaseProtocol(const QDBusConnection &dbusConnection, const QString &name);
120 
121  virtual bool registerObject(const QString &busName, const QString &objectPath,
122  DBusError *error);
123 
124 private:
125  friend class BaseConnectionManager;
126  class Adaptee;
127  friend class Adaptee;
128  struct Private;
129  friend struct Private;
130  Private *mPriv;
131 };
132 
134 {
135  Q_OBJECT
136  Q_DISABLE_COPY(AbstractProtocolInterface)
137 
138 public:
139  AbstractProtocolInterface(const QString &interfaceName);
140  virtual ~AbstractProtocolInterface();
141 
142 private:
143  friend class BaseProtocol;
144 
145  struct Private;
146  friend struct Private;
147  Private *mPriv;
148 };
149 
151 {
152  Q_OBJECT
153  Q_DISABLE_COPY(BaseProtocolAddressingInterface)
154 
155 public:
156  static BaseProtocolAddressingInterfacePtr create()
157  {
158  return BaseProtocolAddressingInterfacePtr(new BaseProtocolAddressingInterface());
159  }
160  template<typename BaseProtocolAddressingInterfaceSubclass>
162  {
164  new BaseProtocolAddressingInterfaceSubclass());
165  }
166 
168 
169  QStringList addressableVCardFields() const;
170  void setAddressableVCardFields(const QStringList &vcardFields);
171 
172  QStringList addressableUriSchemes() const;
173  void setAddressableUriSchemes(const QStringList &uriSchemes);
174 
176  void setNormalizeVCardAddressCallback(const NormalizeVCardAddressCallback &cb);
177  QString normalizeVCardAddress(const QString &vcardField, const QString &vcardAddress, DBusError *error);
178 
180  void setNormalizeContactUriCallback(const NormalizeContactUriCallback &cb);
181  QString normalizeContactUri(const QString &uri, DBusError *error);
182 
183 protected:
185 
186 private:
187  void createAdaptor();
188 
189  class Adaptee;
190  friend class Adaptee;
191  struct Private;
192  friend struct Private;
193  Private *mPriv;
194 };
195 
197 {
198  Q_OBJECT
199  Q_DISABLE_COPY(BaseProtocolAvatarsInterface)
200 
201 public:
202  static BaseProtocolAvatarsInterfacePtr create()
203  {
204  return BaseProtocolAvatarsInterfacePtr(new BaseProtocolAvatarsInterface());
205  }
206  template<typename BaseProtocolAvatarsInterfaceSubclass>
208  {
210  new BaseProtocolAvatarsInterfaceSubclass());
211  }
212 
213  virtual ~BaseProtocolAvatarsInterface();
214 
215  QVariantMap immutableProperties() const;
216 
217  AvatarSpec avatarDetails() const;
218  void setAvatarDetails(const AvatarSpec &spec);
219 
220 protected:
222 
223 private:
224  void createAdaptor();
225 
226  class Adaptee;
227  friend class Adaptee;
228  struct Private;
229  friend struct Private;
230  Private *mPriv;
231 };
232 
234 {
235  Q_OBJECT
236  Q_DISABLE_COPY(BaseProtocolPresenceInterface)
237 
238 public:
239  static BaseProtocolPresenceInterfacePtr create()
240  {
241  return BaseProtocolPresenceInterfacePtr(new BaseProtocolPresenceInterface());
242  }
243  template<typename BaseProtocolPresenceInterfaceSubclass>
245  {
247  new BaseProtocolPresenceInterfaceSubclass());
248  }
249 
251 
252  QVariantMap immutableProperties() const;
253 
254  PresenceSpecList statuses() const;
255  void setStatuses(const PresenceSpecList &statuses);
256 
257 protected:
259 
260 private:
261  void createAdaptor();
262 
263  class Adaptee;
264  friend class Adaptee;
265  struct Private;
266  friend struct Private;
267  Private *mPriv;
268 };
269 
270 }
271 
272 #endif
Base class for protocol implementations.
Definition: base-protocol.h:47
static BaseProtocolPresenceInterfacePtr create()
Definition: base-protocol.h:239
Base class for D-Bus services.
Definition: dbus-service.h:46
static BaseProtocolPtr create(const QDBusConnection &dbusConnection, const QString &name)
Definition: base-protocol.h:63
static SharedPtr< BaseProtocolPresenceInterfaceSubclass > create()
Definition: base-protocol.h:244
Callback2< QString, const QString &, DBusError * > NormalizeContactCallback
Definition: base-protocol.h:110
Callback2< BaseConnectionPtr, const QVariantMap &, DBusError * > CreateConnectionCallback
Definition: base-protocol.h:102
Base class for implementations of Protocol.Interface.Presence.
Definition: base-protocol.h:233
static BaseProtocolAddressingInterfacePtr create()
Definition: base-protocol.h:156
Base class for all the Protocol object interface implementations.
Definition: base-protocol.h:133
Base class for D-Bus service interfaces.
Definition: dbus-service.h:73
Callback2< QString, const QVariantMap &, DBusError * > IdentifyAccountCallback
Definition: base-protocol.h:106
Callback2< QString, const QString &, DBusError * > NormalizeContactUriCallback
Definition: base-protocol.h:179
static BaseProtocolAvatarsInterfacePtr create()
Definition: base-protocol.h:202
static SharedPtr< BaseProtocolSubclass > create(const QString &name)
Definition: base-protocol.h:58
The RequestableChannelClassSpecList class represents a list of RequestableChannelClassSpec.
Definition: requestable-channel-class-spec.h:101
The PresenceSpecList class represents a list of PresenceSpec.
Definition: presence.h:125
Callback3< QString, const QString &, const QString &, DBusError * > NormalizeVCardAddressCallback
Definition: base-protocol.h:175
static BaseProtocolPtr create(const QString &name)
Definition: base-protocol.h:53
Base class for implementations of Protocol.Interface.Avatars.
Definition: base-protocol.h:196
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
static SharedPtr< BaseProtocolAvatarsInterfaceSubclass > create()
Definition: base-protocol.h:207
Base class for implementations of Protocol.Interface.Addressing.
Definition: base-protocol.h:150
static SharedPtr< BaseProtocolSubclass > create(const QDBusConnection &dbusConnection, const QString &name)
Definition: base-protocol.h:68
Small container class, containing a D-Bus error.
Definition: dbus-error.h:35
Base class for connection manager implementations.
Definition: base-connection-manager.h:41
static SharedPtr< BaseProtocolAddressingInterfaceSubclass > create()
Definition: base-protocol.h:161
Definition: abstract-adaptor.cpp:31
The AvatarSpec class represents a Telepathy avatar information supported by a protocol.
Definition: avatar.h:51
QList< ProtocolParameter > ProtocolParameterList
Definition: protocol-parameter.h:85