00001
00023 #ifndef _TelepathyQt_base_protocol_h_HEADER_GUARD_
00024 #define _TelepathyQt_base_protocol_h_HEADER_GUARD_
00025
00026 #ifndef IN_TP_QT_HEADER
00027 #error IN_TP_QT_HEADER
00028 #endif
00029
00030 #include <TelepathyQt/AvatarSpec>
00031 #include <TelepathyQt/Callbacks>
00032 #include <TelepathyQt/DBusService>
00033 #include <TelepathyQt/Global>
00034 #include <TelepathyQt/PresenceSpecList>
00035 #include <TelepathyQt/ProtocolParameterList>
00036 #include <TelepathyQt/RequestableChannelClassSpecList>
00037 #include <TelepathyQt/Types>
00038
00039 #include <QDBusConnection>
00040
00041 class QString;
00042 class QStringList;
00043
00044 namespace Tp
00045 {
00046
00047 class TP_QT_EXPORT BaseProtocol : public DBusService
00048 {
00049 Q_OBJECT
00050 Q_DISABLE_COPY(BaseProtocol)
00051
00052 public:
00053 static BaseProtocolPtr create(const QString &name)
00054 {
00055 return BaseProtocolPtr(new BaseProtocol(QDBusConnection::sessionBus(), name));
00056 }
00057 template<typename BaseProtocolSubclass>
00058 static SharedPtr<BaseProtocolSubclass> create(const QString &name)
00059 {
00060 return SharedPtr<BaseProtocolSubclass>(new BaseProtocolSubclass(
00061 QDBusConnection::sessionBus(), name));
00062 }
00063 static BaseProtocolPtr create(const QDBusConnection &dbusConnection, const QString &name)
00064 {
00065 return BaseProtocolPtr(new BaseProtocol(dbusConnection, name));
00066 }
00067 template<typename BaseProtocolSubclass>
00068 static SharedPtr<BaseProtocolSubclass> create(const QDBusConnection &dbusConnection,
00069 const QString &name)
00070 {
00071 return SharedPtr<BaseProtocolSubclass>(new BaseProtocolSubclass(dbusConnection, name));
00072 }
00073
00074 virtual ~BaseProtocol();
00075
00076 QString name() const;
00077
00078 QVariantMap immutableProperties() const;
00079
00080
00081 QStringList connectionInterfaces() const;
00082 void setConnectionInterfaces(const QStringList &connInterfaces);
00083
00084 ProtocolParameterList parameters() const;
00085 void setParameters(const ProtocolParameterList ¶meters);
00086
00087 RequestableChannelClassSpecList requestableChannelClasses() const;
00088 void setRequestableChannelClasses(const RequestableChannelClassSpecList &rccSpecs);
00089
00090 QString vcardField() const;
00091 void setVCardField(const QString &vcardField);
00092
00093 QString englishName() const;
00094 void setEnglishName(const QString &englishName);
00095
00096 QString iconName() const;
00097 void setIconName(const QString &iconName);
00098
00099 QStringList authenticationTypes() const;
00100 void setAuthenticationTypes(const QStringList &authenticationTypes);
00101
00102 typedef Callback2<BaseConnectionPtr, const QVariantMap &, DBusError*> CreateConnectionCallback;
00103 void setCreateConnectionCallback(const CreateConnectionCallback &cb);
00104 Tp::BaseConnectionPtr createConnection(const QVariantMap ¶meters, DBusError *error);
00105
00106 typedef Callback2<QString, const QVariantMap &, DBusError*> IdentifyAccountCallback;
00107 void setIdentifyAccountCallback(const IdentifyAccountCallback &cb);
00108 QString identifyAccount(const QVariantMap ¶meters, DBusError *error);
00109
00110 typedef Callback2<QString, const QString &, DBusError*> NormalizeContactCallback;
00111 void setNormalizeContactCallback(const NormalizeContactCallback &cb);
00112 QString normalizeContact(const QString &contactId, DBusError *error);
00113
00114 QList<AbstractProtocolInterfacePtr> interfaces() const;
00115 AbstractProtocolInterfacePtr interface(const QString & interfaceName) const;
00116 bool plugInterface(const AbstractProtocolInterfacePtr &interface);
00117
00118 protected:
00119 BaseProtocol(const QDBusConnection &dbusConnection, const QString &name);
00120
00121 virtual bool registerObject(const QString &busName, const QString &objectPath,
00122 DBusError *error);
00123
00124 private:
00125 friend class BaseConnectionManager;
00126 class Adaptee;
00127 friend class Adaptee;
00128 class Private;
00129 friend class Private;
00130 Private *mPriv;
00131 };
00132
00133 class TP_QT_EXPORT AbstractProtocolInterface : public AbstractDBusServiceInterface
00134 {
00135 Q_OBJECT
00136 Q_DISABLE_COPY(AbstractProtocolInterface)
00137
00138 public:
00139 AbstractProtocolInterface(const QString &interfaceName);
00140 virtual ~AbstractProtocolInterface();
00141
00142 private:
00143 friend class BaseProtocol;
00144
00145 class Private;
00146 friend class Private;
00147 Private *mPriv;
00148 };
00149
00150 class TP_QT_EXPORT BaseProtocolAddressingInterface : public AbstractProtocolInterface
00151 {
00152 Q_OBJECT
00153 Q_DISABLE_COPY(BaseProtocolAddressingInterface)
00154
00155 public:
00156 static BaseProtocolAddressingInterfacePtr create()
00157 {
00158 return BaseProtocolAddressingInterfacePtr(new BaseProtocolAddressingInterface());
00159 }
00160 template<typename BaseProtocolAddressingInterfaceSubclass>
00161 static SharedPtr<BaseProtocolAddressingInterfaceSubclass> create()
00162 {
00163 return SharedPtr<BaseProtocolAddressingInterfaceSubclass>(
00164 new BaseProtocolAddressingInterfaceSubclass());
00165 }
00166
00167 virtual ~BaseProtocolAddressingInterface();
00168
00169 QVariantMap immutableProperties() const;
00170
00171 QStringList addressableVCardFields() const;
00172 void setAddressableVCardFields(const QStringList &vcardFields);
00173
00174 QStringList addressableUriSchemes() const;
00175 void setAddressableUriSchemes(const QStringList &uriSchemes);
00176
00177 typedef Callback3<QString, const QString &, const QString &, DBusError*> NormalizeVCardAddressCallback;
00178 void setNormalizeVCardAddressCallback(const NormalizeVCardAddressCallback &cb);
00179 QString normalizeVCardAddress(const QString &vcardField, const QString &vcardAddress, DBusError *error);
00180
00181 typedef Callback2<QString, const QString &, DBusError*> NormalizeContactUriCallback;
00182 void setNormalizeContactUriCallback(const NormalizeContactUriCallback &cb);
00183 QString normalizeContactUri(const QString &uri, DBusError *error);
00184
00185 protected:
00186 BaseProtocolAddressingInterface();
00187
00188 private:
00189 void createAdaptor();
00190
00191 class Adaptee;
00192 friend class Adaptee;
00193 struct Private;
00194 friend struct Private;
00195 Private *mPriv;
00196 };
00197
00198 class TP_QT_EXPORT BaseProtocolAvatarsInterface : public AbstractProtocolInterface
00199 {
00200 Q_OBJECT
00201 Q_DISABLE_COPY(BaseProtocolAvatarsInterface)
00202
00203 public:
00204 static BaseProtocolAvatarsInterfacePtr create()
00205 {
00206 return BaseProtocolAvatarsInterfacePtr(new BaseProtocolAvatarsInterface());
00207 }
00208 template<typename BaseProtocolAvatarsInterfaceSubclass>
00209 static SharedPtr<BaseProtocolAvatarsInterfaceSubclass> create()
00210 {
00211 return SharedPtr<BaseProtocolAvatarsInterfaceSubclass>(
00212 new BaseProtocolAvatarsInterfaceSubclass());
00213 }
00214
00215 virtual ~BaseProtocolAvatarsInterface();
00216
00217 QVariantMap immutableProperties() const;
00218
00219 AvatarSpec avatarDetails() const;
00220 void setAvatarDetails(const AvatarSpec &spec);
00221
00222 protected:
00223 BaseProtocolAvatarsInterface();
00224
00225 private:
00226 void createAdaptor();
00227
00228 class Adaptee;
00229 friend class Adaptee;
00230 struct Private;
00231 friend struct Private;
00232 Private *mPriv;
00233 };
00234
00235 class TP_QT_EXPORT BaseProtocolPresenceInterface : public AbstractProtocolInterface
00236 {
00237 Q_OBJECT
00238 Q_DISABLE_COPY(BaseProtocolPresenceInterface)
00239
00240 public:
00241 static BaseProtocolPresenceInterfacePtr create()
00242 {
00243 return BaseProtocolPresenceInterfacePtr(new BaseProtocolPresenceInterface());
00244 }
00245 template<typename BaseProtocolPresenceInterfaceSubclass>
00246 static SharedPtr<BaseProtocolPresenceInterfaceSubclass> create()
00247 {
00248 return SharedPtr<BaseProtocolPresenceInterfaceSubclass>(
00249 new BaseProtocolPresenceInterfaceSubclass());
00250 }
00251
00252 virtual ~BaseProtocolPresenceInterface();
00253
00254 QVariantMap immutableProperties() const;
00255
00256 PresenceSpecList statuses() const;
00257 void setStatuses(const PresenceSpecList &statuses);
00258
00259 protected:
00260 BaseProtocolPresenceInterface();
00261
00262 private:
00263 void createAdaptor();
00264
00265 class Adaptee;
00266 friend class Adaptee;
00267 struct Private;
00268 friend struct Private;
00269 Private *mPriv;
00270 };
00271
00272 }
00273
00274 #endif