summaryrefslogtreecommitdiff
path: root/TelepathyQt/client-registrar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TelepathyQt/client-registrar.cpp')
-rw-r--r--TelepathyQt/client-registrar.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/TelepathyQt/client-registrar.cpp b/TelepathyQt/client-registrar.cpp
index 6ed99328..4f8ac3b1 100644
--- a/TelepathyQt/client-registrar.cpp
+++ b/TelepathyQt/client-registrar.cpp
@@ -72,7 +72,7 @@ private:
{
}
- void onFinished()
+ void onFinished() override
{
if (mFinishedCb) {
mFinishedCb(MethodInvocationContextPtr<>(this), mChannels, mFinishedCbData);
@@ -193,6 +193,12 @@ void ClientObserverAdaptor::ObserveChannels(const QDBusObjectPath &accountPath,
ObjectImmutablePropertiesMap reqPropsMap = qdbus_cast<ObjectImmutablePropertiesMap>(
observerInfo.value(QLatin1String("request-properties")));
foreach (const QDBusObjectPath &reqPath, requestsSatisfied) {
+ //don't load the channelRequest objects in requestsSatisfied if the properties are not supplied with the handler info
+ //as the channelRequest is probably invalid
+ //this works around https://bugs.freedesktop.org/show_bug.cgi?id=77986
+ if (reqPropsMap.value(reqPath).isEmpty()) {
+ continue;
+ }
ChannelRequestPtr channelRequest = ChannelRequest::create(invocation->acc,
reqPath.path(), reqPropsMap.value(reqPath));
invocation->chanReqs.append(channelRequest);
@@ -223,7 +229,7 @@ void ClientObserverAdaptor::onReadyOpFinished(Tp::PendingOperation *op)
continue;
}
- (*i)->readyOp = 0;
+ (*i)->readyOp = nullptr;
if (op->isError()) {
warning() << "Preparing proxies for ObserveChannels failed with" << op->errorName()
@@ -326,7 +332,7 @@ void ClientApproverAdaptor::onReadyOpFinished(Tp::PendingOperation *op)
continue;
}
- (*i)->readyOp = 0;
+ (*i)->readyOp = nullptr;
if (op->isError()) {
warning() << "Preparing proxies for AddDispatchOperation failed with" << op->errorName()
@@ -435,6 +441,12 @@ void ClientHandlerAdaptor::HandleChannels(const QDBusObjectPath &accountPath,
ObjectImmutablePropertiesMap reqPropsMap = qdbus_cast<ObjectImmutablePropertiesMap>(
handlerInfo.value(QLatin1String("request-properties")));
foreach (const QDBusObjectPath &reqPath, requestsSatisfied) {
+ //don't load the channelRequest objects in requestsSatisfied if the properties are not supplied with the handler info
+ //as the channelRequest is probably invalid
+ //this works around https://bugs.freedesktop.org/show_bug.cgi?id=77986
+ if (reqPropsMap.value(reqPath).isEmpty()) {
+ continue;
+ }
ChannelRequestPtr channelRequest = ChannelRequest::create(invocation->acc,
reqPath.path(), reqPropsMap.value(reqPath));
invocation->chanReqs.append(channelRequest);
@@ -443,7 +455,11 @@ void ClientHandlerAdaptor::HandleChannels(const QDBusObjectPath &accountPath,
// FIXME See http://bugs.freedesktop.org/show_bug.cgi?id=21690
if (userActionTime_t != 0) {
+#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
invocation->time = QDateTime::fromTime_t((uint) userActionTime_t);
+#else
+ invocation->time = QDateTime::fromSecsSinceEpoch((uint) userActionTime_t);
+#endif
}
invocation->ctx = HandleChannelsInvocationContext::create(mBus, message,
@@ -474,7 +490,7 @@ void ClientHandlerAdaptor::onReadyOpFinished(Tp::PendingOperation *op)
continue;
}
- (*i)->readyOp = 0;
+ (*i)->readyOp = nullptr;
if (op->isError()) {
warning() << "Preparing proxies for HandleChannels failed with" << op->errorName()
@@ -891,8 +907,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
.arg((quintptr) client.data(), 0, 16));
}
- if (mPriv->services.contains(busName) ||
- !mPriv->bus.registerService(busName)) {
+ if (mPriv->services.contains(busName)) {
warning() << "Unable to register client: busName" <<
busName << "already registered";
return false;
@@ -938,7 +953,6 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
if (interfaces.isEmpty()) {
warning() << "Client does not implement any known interface";
// cleanup
- mPriv->bus.unregisterService(busName);
return false;
}
@@ -953,10 +967,18 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
objectPath << "already registered";
// cleanup
delete object;
- mPriv->bus.unregisterService(busName);
return false;
}
+ if (!mPriv->bus.registerService(busName)) {
+ warning() << "Unable to register service: busName" <<
+ busName << "already registered";
+ mPriv->bus.unregisterObject(objectPath, QDBusConnection::UnregisterTree);
+ delete object;
+ return false;
+ }
+
+
if (handler) {
handler->setRegistered(true);
}