Skip to content

Commit c0aae36

Browse files
committed
offline: Make sure we allow for interactive authorization
Otherwise it might result in org.freedesktop.DBus.Error.InteractiveAuthorizationRequired which PackageKit already contemplates.
1 parent 083d495 commit c0aae36

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/offline.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ QDBusPendingReply<> Offline::trigger(Action action)
9292
};
9393
Q_ASSERT(!actionStr.isEmpty());
9494

95-
return d->iface.Trigger(actionStr);
95+
// Manually invoke dbus because the qdbusxml2cpp does not allow
96+
// setting the ALLOW_INTERACTIVE_AUTHORIZATION flag
97+
auto msg = QDBusMessage::createMethodCall(PK_NAME,
98+
PK_PATH,
99+
PK_OFFLINE_INTERFACE,
100+
QStringLiteral("Trigger"));
101+
msg << actionStr;
102+
msg.setInteractiveAuthorizationAllowed(true);
103+
return QDBusConnection::systemBus().asyncCall(msg);
96104
}
97105

98106
QDBusPendingReply<> Offline::triggerUpgrade(Action action)
@@ -112,19 +120,39 @@ QDBusPendingReply<> Offline::triggerUpgrade(Action action)
112120
};
113121
Q_ASSERT(!actionStr.isEmpty());
114122

115-
return d->iface.TriggerUpgrade(actionStr);
123+
// Manually invoke dbus because the qdbusxml2cpp does not allow
124+
// setting the ALLOW_INTERACTIVE_AUTHORIZATION flag
125+
auto msg = QDBusMessage::createMethodCall(PK_NAME,
126+
PK_PATH,
127+
PK_OFFLINE_INTERFACE,
128+
QStringLiteral("TriggerUpgrade"));
129+
msg << actionStr;
130+
msg.setInteractiveAuthorizationAllowed(true);
131+
return QDBusConnection::systemBus().asyncCall(msg, 24 * 60 * 1000 * 1000);
116132
}
117133

118134
QDBusPendingReply<> Offline::cancel()
119135
{
120-
Q_D(Offline);
121-
return d->iface.Cancel();
136+
// Manually invoke dbus because the qdbusxml2cpp does not allow
137+
// setting the ALLOW_INTERACTIVE_AUTHORIZATION flag
138+
auto msg = QDBusMessage::createMethodCall(PK_NAME,
139+
PK_PATH,
140+
PK_OFFLINE_INTERFACE,
141+
QStringLiteral("Cancel"));
142+
msg.setInteractiveAuthorizationAllowed(true);
143+
return QDBusConnection::systemBus().asyncCall(msg);
122144
}
123145

124146
QDBusPendingReply<> Offline::clearResults()
125147
{
126-
Q_D(Offline);
127-
return d->iface.ClearResults();
148+
// Manually invoke dbus because the qdbusxml2cpp does not allow
149+
// setting the ALLOW_INTERACTIVE_AUTHORIZATION flag
150+
auto msg = QDBusMessage::createMethodCall(PK_NAME,
151+
PK_PATH,
152+
PK_OFFLINE_INTERFACE,
153+
QStringLiteral("ClearResults"));
154+
msg.setInteractiveAuthorizationAllowed(true);
155+
return QDBusConnection::systemBus().asyncCall(msg);
128156
}
129157

130158
void Offline::getPrepared()

0 commit comments

Comments
 (0)