2
* Copyright (C) 2016 Canonical, Ltd.
5
* Roberto Mier Escandon <roberto.escandon@canonical.com>
7
* This file is part of telephony-service.
9
* telephony-service is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; version 3.
13
* history-service is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef CHANNELINTERFACEROLESINTERFACE_H
23
#define CHANNELINTERFACEROLESINTERFACE_H
27
#include <TelepathyQt/AbstractInterface>
28
#include <TelepathyQt/ChannelInterface>
31
* \struct HandleRolesMap
33
* \headerfile TelepathyQt/types.h <TelepathyQt/Types>
36
* QMap<uint, uint>, but needed to have a discrete type in the Qt type system.
38
* A map from channel-specific handles to their owners.
40
struct HandleRolesMap : public QMap<uint, uint>
42
inline HandleRolesMap() : QMap<uint, uint>() {}
43
inline HandleRolesMap(const QMap<uint, uint>& a) : QMap<uint, uint>(a) {}
45
inline HandleRolesMap& operator=(const QMap<uint, uint>& a)
47
*(static_cast<QMap<uint, uint>*>(this)) = a;
52
Q_DECLARE_METATYPE(HandleRolesMap)
54
class ChannelInterfaceRolesInterface : public Tp::AbstractInterface
60
* Returns the name of the interface "org.freedesktop.Telepathy.Channel.Interface.Roles", which this class
63
* \return The D-Bus interface name.
65
static inline QLatin1String staticInterfaceName()
67
return QLatin1String("org.freedesktop.Telepathy.Channel.Interface.Roles");
71
* Creates a ChannelInterfaceRolesInterface associated with the given object on the session bus.
73
* \param busName Name of the service the object is on.
74
* \param objectPath Path to the object on the service.
75
* \param parent Passed to the parent class constructor.
77
ChannelInterfaceRolesInterface(
78
const QString& busName,
79
const QString& objectPath,
84
* Creates a ChannelInterfaceRolesInterface associated with the given object on the given bus.
86
* \param connection The bus via which the object can be reached.
87
* \param busName Name of the service the object is on.
88
* \param objectPath Path to the object on the service.
89
* \param parent Passed to the parent class constructor.
91
ChannelInterfaceRolesInterface(
92
const QDBusConnection& connection,
93
const QString& busName,
94
const QString& objectPath,
99
* Creates a ChannelInterfaceRolesInterface associated with the same object as the given proxy.
101
* \param proxy The proxy to use. It will also be the QObject::parent()
104
ChannelInterfaceRolesInterface(Tp::DBusProxy *proxy);
107
* Creates a ChannelInterfaceRolesInterface associated with the same object as the given proxy.
108
* Additionally, the created proxy will have the same parent as the given
111
* \param mainInterface The proxy to use.
113
explicit ChannelInterfaceRolesInterface(const Tp::Client::ChannelInterface& mainInterface);
116
* Creates a ChannelInterfaceRolesInterface associated with the same object as the given proxy.
117
* However, a different parent object can be specified.
119
* \param mainInterface The proxy to use.
120
* \param parent Passed to the parent class constructor.
122
ChannelInterfaceRolesInterface(const Tp::Client::ChannelInterface& mainInterface, QObject* parent);
125
* Asynchronous getter for the remote object property \c Roles of type \c HandleRolesMap.
127
* \return A pending variant which will emit finished when the property has been
130
inline Tp::PendingVariant *requestPropertyRoles() const
132
return internalRequestProperty(QLatin1String("Roles"));
136
* Asynchronous getter for the remote object property \c CanUpdateRoles of type \c bool.
138
* \return A pending variant which will emit finished when the property has been
141
inline Tp::PendingVariant *requestPropertyCanUpdateRoles() const
143
return internalRequestProperty(QLatin1String("CanUpdateRoles"));
147
* Request all of the DBus properties on the interface.
149
* \return A pending variant map which will emit finished when the properties have
152
Tp::PendingVariantMap *requestAllProperties() const
154
return internalRequestAllProperties();
158
* Synchronous version to get Roles property
160
HandleRolesMap getRoles() const;
163
* Synchronous version to get CanUpdateRoles property
165
bool getCanUpdateRoles() const;
169
* Begins a call to the D-Bus method \c UpdateRoles on the remote object.
171
* Update the roles in the server
174
inline QDBusPendingReply<> UpdateRoles(const HandleRolesMap &contactRoles, int timeout = -1)
176
if (!invalidationReason().isEmpty()) {
177
return QDBusPendingReply<>(QDBusMessage::createError(
178
invalidationReason(),
179
invalidationMessage()
183
QDBusMessage callMessage = QDBusMessage::createMethodCall(this->service(), this->path(),
184
this->staticInterfaceName(), QLatin1String("UpdateRoles"));
185
callMessage << QVariant::fromValue(contactRoles);
186
return this->connection().asyncCall(callMessage, timeout);
191
* Represents the signal \c RolesChanged on the remote object.
193
* Emitted when the state the roles of the channel has changed.
197
* map of handles and related roles added
201
* map of handles and related roles removed
203
void RolesChanged(const HandleRolesMap &added, const HandleRolesMap& removed);
206
virtual void invalidate(Tp::DBusProxy *, const QString &, const QString &);
210
#endif // CHANNELINTERFACEROLESINTERFACE_H