[telepathy-qt4/master] OptionalInterfaceFactory: Added public interfaces and protected setInterfaces method.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Sun Jun 21 21:14:17 PDT 2009
Moved interfaces method to OptionalInterfaceFactory so it does not need to be
duplicated around every class.
This is also a preparation for moving optionalInterface method to
OptionalInterfaceFactory.
---
TelepathyQt4/account-manager.cpp | 13 +-----
TelepathyQt4/account-manager.h | 4 +-
TelepathyQt4/account.cpp | 14 ++----
TelepathyQt4/account.h | 4 +-
TelepathyQt4/channel-dispatch-operation.cpp | 8 +---
TelepathyQt4/channel-dispatch-operation.h | 4 +-
TelepathyQt4/channel-request.cpp | 8 +---
TelepathyQt4/channel-request.h | 4 +-
TelepathyQt4/channel.cpp | 65 +++++++-------------------
TelepathyQt4/channel.h | 3 +-
TelepathyQt4/connection-manager-internal.h | 1 -
TelepathyQt4/connection-manager.cpp | 9 +---
TelepathyQt4/connection-manager.h | 4 +-
TelepathyQt4/connection.cpp | 34 +++-----------
TelepathyQt4/connection.h | 4 +-
TelepathyQt4/optional-interface-factory.cpp | 8 +++
TelepathyQt4/optional-interface-factory.h | 14 +++++-
17 files changed, 62 insertions(+), 139 deletions(-)
diff --git a/TelepathyQt4/account-manager.cpp b/TelepathyQt4/account-manager.cpp
index aaa569b..1fe927f 100644
--- a/TelepathyQt4/account-manager.cpp
+++ b/TelepathyQt4/account-manager.cpp
@@ -78,7 +78,6 @@ struct AccountManager::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
QSet<QString> validAccountPaths;
QSet<QString> invalidAccountPaths;
QMap<QString, AccountPtr> accounts;
@@ -312,16 +311,6 @@ AccountManager::~AccountManager()
}
/**
- * Return a list of interfaces supported by this account manager.
- *
- * \return List of supported interfaces.
- */
-QStringList AccountManager::interfaces() const
-{
- return mPriv->interfaces;
-}
-
-/**
* \fn DBus::PropertiesInterface *AccountManager::propertiesInterface() const
*
* Return the properties interface proxy object for this account manager. The
@@ -577,7 +566,7 @@ void AccountManager::gotMainProperties(QDBusPendingCallWatcher *watcher)
props = reply.value();
if (props.contains("Interfaces")) {
- mPriv->interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
+ setInterfaces(qdbus_cast<QStringList>(props["Interfaces"]));
}
if (props.contains("ValidAccounts")) {
mPriv->setAccountPaths(mPriv->validAccountPaths,
diff --git a/TelepathyQt4/account-manager.h b/TelepathyQt4/account-manager.h
index cf9c72a..b22da8a 100644
--- a/TelepathyQt4/account-manager.h
+++ b/TelepathyQt4/account-manager.h
@@ -50,7 +50,7 @@ class PendingAccount;
class PendingReady;
class AccountManager : public StatelessDBusProxy,
- private OptionalInterfaceFactory<AccountManager>,
+ public OptionalInterfaceFactory<AccountManager>,
public ReadyObject,
public RefCounted
{
@@ -65,8 +65,6 @@ public:
virtual ~AccountManager();
- QStringList interfaces() const;
-
inline Client::DBus::PropertiesInterface *propertiesInterface() const
{
return OptionalInterfaceFactory<AccountManager>::interface<Client::DBus::PropertiesInterface>();
diff --git a/TelepathyQt4/account.cpp b/TelepathyQt4/account.cpp
index 46c0099..5917ab2 100644
--- a/TelepathyQt4/account.cpp
+++ b/TelepathyQt4/account.cpp
@@ -79,7 +79,6 @@ struct Account::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
QVariantMap parameters;
bool valid;
bool enabled;
@@ -430,7 +429,7 @@ const Avatar &Account::avatar() const
*/
PendingOperation *Account::setAvatar(const Avatar &avatar)
{
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_ACCOUNT_INTERFACE_AVATAR)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_ACCOUNT_INTERFACE_AVATAR)) {
return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
"Account does not support Avatar");
}
@@ -913,11 +912,6 @@ PendingChannelRequest *Account::ensureChannel(
request, userActionTime, preferredHandler, false, this);
}
-QStringList Account::interfaces() const
-{
- return mPriv->interfaces;
-}
-
/**
* \fn Account::optionalInterface(InterfaceSupportedChecking check) const
*
@@ -1039,8 +1033,8 @@ void Account::Private::updateProperties(const QVariantMap &props)
debug() << "Account::updateProperties: changed:";
if (props.contains("Interfaces")) {
- interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
- debug() << " Interfaces:" << interfaces;
+ parent->setInterfaces(qdbus_cast<QStringList>(props["Interfaces"]));
+ debug() << " Interfaces:" << parent->interfaces();
}
if (props.contains("DisplayName") &&
@@ -1211,7 +1205,7 @@ void Account::gotMainProperties(QDBusPendingCallWatcher *watcher)
debug() << "Got reply to Properties.GetAll(Account)";
mPriv->updateProperties(reply.value());
- mPriv->readinessHelper->setInterfaces(mPriv->interfaces);
+ mPriv->readinessHelper->setInterfaces(interfaces());
debug() << "Account basic functionality is ready";
mPriv->readinessHelper->setIntrospectCompleted(FeatureCore, true);
diff --git a/TelepathyQt4/account.h b/TelepathyQt4/account.h
index c19b115..d20c037 100644
--- a/TelepathyQt4/account.h
+++ b/TelepathyQt4/account.h
@@ -56,7 +56,7 @@ class PendingStringList;
class ProtocolInfo;
class Account : public StatelessDBusProxy,
- private OptionalInterfaceFactory<Account>,
+ public OptionalInterfaceFactory<Account>,
public ReadyObject,
public RefCounted
@@ -169,8 +169,6 @@ public:
QDateTime userActionTime = QDateTime::currentDateTime(),
const QString &preferredHandler = QString());
- QStringList interfaces() const;
-
template <class Interface>
inline Interface *optionalInterface(
InterfaceSupportedChecking check = CheckInterfaceSupported) const
diff --git a/TelepathyQt4/channel-dispatch-operation.cpp b/TelepathyQt4/channel-dispatch-operation.cpp
index 82dbf90..9a7ed64 100644
--- a/TelepathyQt4/channel-dispatch-operation.cpp
+++ b/TelepathyQt4/channel-dispatch-operation.cpp
@@ -79,7 +79,6 @@ struct ChannelDispatchOperation::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
ConnectionPtr connection;
AccountPtr account;
QList<ChannelPtr> channels;
@@ -138,7 +137,7 @@ void ChannelDispatchOperation::Private::introspectMain(ChannelDispatchOperation:
void ChannelDispatchOperation::Private::extractMainProps(const QVariantMap &props,
bool immutableProperties)
{
- interfaces = qdbus_cast<QStringList>(props.value("Interfaces"));
+ parent->setInterfaces(qdbus_cast<QStringList>(props.value("Interfaces")));
if (!connection && props.contains("Connection")) {
QDBusObjectPath connectionObjectPath =
@@ -235,11 +234,6 @@ ChannelDispatchOperation::~ChannelDispatchOperation()
delete mPriv;
}
-QStringList ChannelDispatchOperation::interfaces() const
-{
- return mPriv->interfaces;
-}
-
ConnectionPtr ChannelDispatchOperation::connection() const
{
return mPriv->connection;
diff --git a/TelepathyQt4/channel-dispatch-operation.h b/TelepathyQt4/channel-dispatch-operation.h
index f3544ac..c2622fc 100644
--- a/TelepathyQt4/channel-dispatch-operation.h
+++ b/TelepathyQt4/channel-dispatch-operation.h
@@ -48,7 +48,7 @@ namespace Tp
class PendingOperation;
class ChannelDispatchOperation : public StatefulDBusProxy,
- private OptionalInterfaceFactory<ChannelDispatchOperation>,
+ public OptionalInterfaceFactory<ChannelDispatchOperation>,
public ReadyObject,
public RefCounted
{
@@ -65,8 +65,6 @@ public:
~ChannelDispatchOperation();
- QStringList interfaces() const;
-
ConnectionPtr connection() const;
AccountPtr account() const;
diff --git a/TelepathyQt4/channel-request.cpp b/TelepathyQt4/channel-request.cpp
index 8151d37..8e2005e 100644
--- a/TelepathyQt4/channel-request.cpp
+++ b/TelepathyQt4/channel-request.cpp
@@ -77,7 +77,6 @@ struct ChannelRequest::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
AccountPtr account;
QDateTime userActionTime;
QString preferredHandler;
@@ -145,7 +144,7 @@ void ChannelRequest::Private::introspectMain(ChannelRequest::Private *self)
void ChannelRequest::Private::extractMainProps(const QVariantMap &props)
{
- interfaces = qdbus_cast<QStringList>(props.value("Interfaces"));
+ parent->setInterfaces(qdbus_cast<QStringList>(props.value("Interfaces")));
if (!account && props.contains("Account")) {
QDBusObjectPath accountObjectPath =
@@ -209,11 +208,6 @@ ChannelRequest::~ChannelRequest()
delete mPriv;
}
-QStringList ChannelRequest::interfaces() const
-{
- return mPriv->interfaces;
-}
-
AccountPtr ChannelRequest::account() const
{
return mPriv->account;
diff --git a/TelepathyQt4/channel-request.h b/TelepathyQt4/channel-request.h
index 774c4a5..57941f8 100644
--- a/TelepathyQt4/channel-request.h
+++ b/TelepathyQt4/channel-request.h
@@ -48,7 +48,7 @@ namespace Tp
class PendingOperation;
class ChannelRequest : public StatefulDBusProxy,
- private OptionalInterfaceFactory<ChannelRequest>,
+ public OptionalInterfaceFactory<ChannelRequest>,
public ReadyObject,
public RefCounted
{
@@ -65,8 +65,6 @@ public:
~ChannelRequest();
- QStringList interfaces() const;
-
AccountPtr account() const;
QDateTime userActionTime() const;
diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp
index d45c0fb..a85ab70 100644
--- a/TelepathyQt4/channel.cpp
+++ b/TelepathyQt4/channel.cpp
@@ -115,7 +115,6 @@ struct Channel::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
QQueue<void (Private::*)()> introspectQueue;
// Introspected properties
@@ -442,15 +441,15 @@ void Channel::Private::extract0177MainProps(const QVariantMap &props)
else {
debug() << " Found properties specified in 0.17.7";
+ parent->setInterfaces(qdbus_cast<QStringList>(props["Interfaces"]));
channelType = qdbus_cast<QString>(props["ChannelType"]);
- interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
targetHandle = qdbus_cast<uint>(props["TargetHandle"]);
targetHandleType = qdbus_cast<uint>(props["TargetHandleType"]);
requested = qdbus_cast<uint>(props["Requested"]);
initiatorHandle = qdbus_cast<uint>(props["InitiatorHandle"]);
if (!fakeGroupInterfaceIfNeeded() &&
- !interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP) &&
+ !parent->interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP) &&
initiatorHandle) {
// No group interface, so nobody will build the poor fellow for us. Will do it ourselves
// out of pity for him.
@@ -506,10 +505,10 @@ void Channel::Private::extract0176GroupProps(const QVariantMap &props)
void Channel::Private::nowHaveInterfaces()
{
- debug() << "Channel has" << interfaces.size() <<
- "optional interfaces:" << interfaces;
+ debug() << "Channel has" << parent->interfaces().size() <<
+ "optional interfaces:" << parent->interfaces();
- if (interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (parent->interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
introspectQueue.enqueue(&Private::introspectGroup);
}
}
@@ -573,7 +572,7 @@ bool Channel::Private::setGroupFlags(uint newGroupFlags)
groupFlags = newGroupFlags;
// this shouldn't happen but let's make sure
- if (!interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (!parent->interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
return false;
}
@@ -875,7 +874,7 @@ void Channel::Private::updateContacts(const QList<ContactPtr> &contacts)
bool Channel::Private::fakeGroupInterfaceIfNeeded()
{
- if (interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (parent->interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
return false;
} else if (targetHandleType != HandleTypeContact) {
return false;
@@ -909,7 +908,7 @@ void Channel::Private::setReady()
debug() << " Target handle" << targetHandle;
debug() << " Target handle type" << targetHandleType;
- if (interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (parent->interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
debug() << " Group: flags" << groupFlags;
if (groupAreHandleOwnersAvailable) {
debug() << " Group: Number of handle owner mappings" <<
@@ -1063,27 +1062,6 @@ QVariantMap Channel::immutableProperties() const
}
/**
- * Return a list of optional interfaces implemented by the remote object.
- *
- * \return D-Bus names of the implemented optional interfaces.
- */
-QStringList Channel::interfaces() const
-{
- // Different check than the others, because the optional interface getters
- // may be used internally with the knowledge about getting the interfaces
- // list, so we don't want this to cause warnings.
- if (!isReady() && mPriv->interfaces.empty()) {
- warning() << "Channel::interfaces() used possibly before the list of "
- "interfaces has been received";
- }
- else if (!isValid()) {
- warning() << "Channel::interfaces() used with channel closed";
- }
-
- return mPriv->interfaces;
-}
-
-/**
* Return the type of this channel.
*
* \return D-Bus interface name for the type of the channel.
@@ -1326,7 +1304,7 @@ PendingOperation *Channel::groupAddContacts(const QList<ContactPtr> &contacts,
}
}
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupAddContacts() used with no group interface";
return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
"Channel does not support group interface");
@@ -1500,7 +1478,7 @@ PendingOperation *Channel::groupRemoveContacts(const QList<ContactPtr> &contacts
}
}
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupRemoveContacts() used with no group interface";
return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
"Channel does not support group interface");
@@ -1538,8 +1516,7 @@ Contacts Channel::groupLocalPendingContacts() const
{
if (!isReady()) {
warning() << "Channel::groupLocalPending() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupLocalPending() used with no group interface";
}
@@ -1556,8 +1533,7 @@ Contacts Channel::groupRemotePendingContacts() const
{
if (!isReady()) {
warning() << "Channel::groupRemotePending() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupRemotePending() used with no "
"group interface";
}
@@ -1578,8 +1554,7 @@ Channel::GroupMemberChangeDetails Channel::groupLocalPendingContactChangeInfo(
{
if (!isReady()) {
warning() << "Channel::groupLocalPending() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupLocalPending() used with no group interface";
}
else if (!contact) {
@@ -1611,8 +1586,7 @@ Channel::GroupMemberChangeDetails Channel::groupSelfContactRemoveInfo() const
{
if (!isReady()) {
warning() << "Channel::groupSelfContactRemoveInfo() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupSelfContactRemoveInfo() used with "
"no group interface";
}
@@ -1646,8 +1620,7 @@ bool Channel::groupAreHandleOwnersAvailable() const
{
if (!isReady()) {
warning() << "Channel::groupAreHandleOwnersAvailable() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupAreHandleOwnersAvailable() used with "
"no group interface";
}
@@ -1671,8 +1644,7 @@ HandleOwnerMap Channel::groupHandleOwners() const
{
if (!isReady()) {
warning() << "Channel::groupHandleOwners() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupAreHandleOwnersAvailable() used with no "
"group interface";
}
@@ -1697,8 +1669,7 @@ bool Channel::groupIsSelfContactTracked() const
{
if (!isReady()) {
warning() << "Channel::groupIsSelfHandleTracked() used channel not ready";
- }
- else if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
+ } else if (!interfaces().contains(TELEPATHY_INTERFACE_CHANNEL_INTERFACE_GROUP)) {
warning() << "Channel::groupIsSelfHandleTracked() used with "
"no group interface";
}
@@ -2082,7 +2053,7 @@ void Channel::gotInterfaces(QDBusPendingCallWatcher *watcher)
}
debug() << "Got reply to fallback Channel::GetInterfaces()";
- mPriv->interfaces = reply.value();
+ setInterfaces(reply.value());
mPriv->nowHaveInterfaces();
mPriv->fakeGroupInterfaceIfNeeded();
diff --git a/TelepathyQt4/channel.h b/TelepathyQt4/channel.h
index c75285b..63c5459 100644
--- a/TelepathyQt4/channel.h
+++ b/TelepathyQt4/channel.h
@@ -49,7 +49,7 @@ class PendingOperation;
class PendingReady;
class Channel : public StatefulDBusProxy,
- private OptionalInterfaceFactory<Channel>,
+ public OptionalInterfaceFactory<Channel>,
public ReadyObject,
public RefCounted
{
@@ -69,7 +69,6 @@ public:
QVariantMap immutableProperties() const;
QString channelType() const;
- QStringList interfaces() const;
uint targetHandleType() const;
uint targetHandle() const;
diff --git a/TelepathyQt4/connection-manager-internal.h b/TelepathyQt4/connection-manager-internal.h
index 18ac431..b9d77df 100644
--- a/TelepathyQt4/connection-manager-internal.h
+++ b/TelepathyQt4/connection-manager-internal.h
@@ -64,7 +64,6 @@ struct ConnectionManager::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
QQueue<QString> parametersQueue;
ProtocolInfoList protocols;
};
diff --git a/TelepathyQt4/connection-manager.cpp b/TelepathyQt4/connection-manager.cpp
index be78170..c59bc27 100644
--- a/TelepathyQt4/connection-manager.cpp
+++ b/TelepathyQt4/connection-manager.cpp
@@ -407,11 +407,6 @@ QString ConnectionManager::name() const
return mPriv->name;
}
-QStringList ConnectionManager::interfaces() const
-{
- return mPriv->interfaces;
-}
-
/**
* Get a list of strings identifying the protocols supported by this
* connection manager, as described in the Telepathy
@@ -586,8 +581,8 @@ void ConnectionManager::gotMainProperties(QDBusPendingCallWatcher *watcher)
// If Interfaces is not supported, the spec says to assume it's
// empty, so keep the empty list mPriv was initialized with
if (props.contains("Interfaces")) {
- mPriv->interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
- mPriv->readinessHelper->setInterfaces(mPriv->interfaces);
+ setInterfaces(qdbus_cast<QStringList>(props["Interfaces"]));
+ mPriv->readinessHelper->setInterfaces(interfaces());
}
} else {
warning().nospace() <<
diff --git a/TelepathyQt4/connection-manager.h b/TelepathyQt4/connection-manager.h
index e8b8f55..80d86bf 100644
--- a/TelepathyQt4/connection-manager.h
+++ b/TelepathyQt4/connection-manager.h
@@ -117,7 +117,7 @@ private:
class ConnectionManager : public StatelessDBusProxy,
- private OptionalInterfaceFactory<ConnectionManager>,
+ public OptionalInterfaceFactory<ConnectionManager>,
public ReadyObject,
public RefCounted
{
@@ -134,8 +134,6 @@ public:
QString name() const;
- QStringList interfaces() const;
-
QStringList supportedProtocols() const;
const ProtocolInfoList &protocols() const;
diff --git a/TelepathyQt4/connection.cpp b/TelepathyQt4/connection.cpp
index 2574959..5050c71 100644
--- a/TelepathyQt4/connection.cpp
+++ b/TelepathyQt4/connection.cpp
@@ -99,7 +99,6 @@ struct Connection::Private
ReadinessHelper *readinessHelper;
// Introspection
- QStringList interfaces;
// Introspected properties
// keep pendingStatus and pendingStatusReason until we emit statusChanged
@@ -536,25 +535,6 @@ uint Connection::statusReason() const
}
/**
- * Return a list of optional interfaces supported by this object. The
- * contents of the list is undefined unless the Connection has status
- * StatusConnecting or StatusConnected. The returned value stays
- * constant for the entire time the connection spends in each of these
- * states; however interfaces might have been added to the supported set by
- * the time StatusConnected is reached.
- *
- * \return Names of the supported interfaces.
- */
-QStringList Connection::interfaces() const
-{
- if (!isReady()) {
- warning() << "Connection::interfaces() used while connection is not ready";
- }
-
- return mPriv->interfaces;
-}
-
-/**
* Return the handle which represents the user on this connection, which will remain
* valid for the lifetime of this connection, or until a change in the user's
* identifier is signalled by the selfHandleChanged signal. If the connection is
@@ -612,7 +592,7 @@ SimpleStatusSpecMap Connection::allowedPresenceStatuses() const
PendingOperation *Connection::setSelfPresence(const QString &status,
const QString &statusMessage)
{
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE)) {
return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
"Connection does not support SimplePresence");
}
@@ -834,9 +814,9 @@ void Connection::gotInterfaces(QDBusPendingCallWatcher *watcher)
QDBusPendingReply<QStringList> reply = *watcher;
if (!reply.isError()) {
- mPriv->interfaces = reply.value();
- debug() << "Got reply to GetInterfaces():" << mPriv->interfaces;
- mPriv->readinessHelper->setInterfaces(mPriv->interfaces);
+ setInterfaces(reply.value());
+ debug() << "Got reply to GetInterfaces():" << interfaces();
+ mPriv->readinessHelper->setInterfaces(interfaces());
}
else {
warning().nospace() << "GetInterfaces() failed with " <<
@@ -932,7 +912,7 @@ void Connection::gotSelfHandle(QDBusPendingCallWatcher *watcher)
mPriv->selfHandle = reply.value();
debug() << "Got self handle" << mPriv->selfHandle;
- if (mPriv->interfaces.contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_CONTACTS)) {
+ if (interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_CONTACTS)) {
mPriv->introspectContacts();
} else {
mPriv->readinessHelper->setIntrospectCompleted(FeatureCore, true);
@@ -1068,7 +1048,7 @@ PendingChannel *Connection::createChannel(const QVariantMap &request)
"Connection not yet connected");
}
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_REQUESTS)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_REQUESTS)) {
warning() << "Requests interface is not support by this connection";
return new PendingChannel(ConnectionPtr(this),
TELEPATHY_ERROR_NOT_IMPLEMENTED,
@@ -1123,7 +1103,7 @@ PendingChannel *Connection::ensureChannel(const QVariantMap &request)
"Connection not yet connected");
}
- if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_REQUESTS)) {
+ if (!interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_REQUESTS)) {
warning() << "Requests interface is not support by this connection";
return new PendingChannel(ConnectionPtr(this),
TELEPATHY_ERROR_NOT_IMPLEMENTED,
diff --git a/TelepathyQt4/connection.h b/TelepathyQt4/connection.h
index a589bd3..50e5afd 100644
--- a/TelepathyQt4/connection.h
+++ b/TelepathyQt4/connection.h
@@ -57,7 +57,7 @@ class PendingOperation;
class PendingReady;
class Connection : public StatefulDBusProxy,
- private OptionalInterfaceFactory<Connection>,
+ public OptionalInterfaceFactory<Connection>,
public ReadyObject,
public RefCounted
{
@@ -88,8 +88,6 @@ public:
uint status() const;
uint statusReason() const;
- QStringList interfaces() const;
-
uint selfHandle() const;
SimpleStatusSpecMap allowedPresenceStatuses() const;
diff --git a/TelepathyQt4/optional-interface-factory.cpp b/TelepathyQt4/optional-interface-factory.cpp
index 17287d0..5614767 100644
--- a/TelepathyQt4/optional-interface-factory.cpp
+++ b/TelepathyQt4/optional-interface-factory.cpp
@@ -134,6 +134,14 @@ void OptionalInterfaceCache::cache(AbstractInterface *interface) const
* Frees all interface instances constructed by this factory.
*/
+ /**
+ * \fn OptionalInterfaceFactory::interfaces() const;
+ *
+ * Return a list of interfaces supported by this object.
+ *
+ * \return List of supported interfaces.
+ */
+
/**
* \fn template <typename Interface> inline Interface *OptionalInterfaceFactory::interface() const
*
diff --git a/TelepathyQt4/optional-interface-factory.h b/TelepathyQt4/optional-interface-factory.h
index 032f3cc..d33d048 100644
--- a/TelepathyQt4/optional-interface-factory.h
+++ b/TelepathyQt4/optional-interface-factory.h
@@ -26,8 +26,9 @@
#error IN_TELEPATHY_QT4_HEADER
#endif
-#include <QtGlobal>
#include <QObject>
+#include <QStringList>
+#include <QtGlobal>
namespace Tp
{
@@ -66,6 +67,8 @@ public:
{
}
+ inline QStringList interfaces() const { return mInterfaces; }
+
template <typename Interface>
inline Interface *interface() const
{
@@ -84,6 +87,15 @@ public:
cache(interface);
return interface;
}
+
+protected:
+ inline void setInterfaces(const QStringList &interfaces)
+ {
+ mInterfaces = interfaces;
+ }
+
+private:
+ QStringList mInterfaces;
};
} // Tp
--
1.5.6.5
More information about the telepathy-commits
mailing list