Merge lp:~mterry/indicator-network/watch-nm-dbus into lp:indicator-network/14.10

Proposed by Michael Terry
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 331
Merged at revision: 336
Proposed branch: lp:~mterry/indicator-network/watch-nm-dbus
Merge into: lp:indicator-network/14.10
Diff against target: 68 lines (+24/-4)
2 files modified
secret-agent/SecretAgent.cpp (+18/-4)
secret-agent/SecretAgent.h (+6/-0)
To merge this branch: bzr merge lp:~mterry/indicator-network/watch-nm-dbus
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+219705@code.launchpad.net

This proposal supersedes a proposal from 2014-05-15.

Commit message

Watch for NetworkManager name changes on DBus and re-register with it when they happen.

Description of the change

Watch for NetworkManager name changes on DBus and re-register with it when they happen.

Before this change, if NM starts after we do or gets restarted while we exist, we won't be registered with it as a secret agent.

This is easy to test with:
sudo restart network-manager

And then try to connect to a wifi network with a password. Without this change, you won't get a popup.

(Resubmitted to drop the deprecated notify-ftbfs branch prerequisite)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM!
Thanks!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'secret-agent/SecretAgent.cpp'
2--- secret-agent/SecretAgent.cpp 2014-03-28 15:47:23 +0000
3+++ secret-agent/SecretAgent.cpp 2014-05-15 14:41:43 +0000
4@@ -45,15 +45,20 @@
5 SecretAgent::SecretAgent(const QDBusConnection &systemConnection,
6 const QDBusConnection &sessionConnection, QObject *parent) :
7 QObject(parent), m_adaptor(new SecretAgentAdaptor(this)), m_systemConnection(
8- systemConnection), m_sessionConnection(sessionConnection), m_agentManager(
9- NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), m_notifications(
10- "org.freedesktop.Notifications",
11- "/org/freedesktop/Notifications", m_sessionConnection), m_request(nullptr) {
12+ systemConnection), m_sessionConnection(sessionConnection), m_managerWatcher(
13+ NM_DBUS_SERVICE, m_systemConnection), m_agentManager(NM_DBUS_SERVICE,
14+ NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), m_notifications(
15+ "org.freedesktop.Notifications", "/org/freedesktop/Notifications",
16+ m_sessionConnection), m_request(nullptr) {
17 if (!m_systemConnection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) {
18 throw logic_error(
19 _("Unable to register user secret agent object on DBus"));
20 }
21
22+ // Watch for NM restarting (or starting after we do)
23+ connect(&m_managerWatcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)),
24+ this, SLOT(serviceOwnerChanged(QString, QString, QString)));
25+
26 m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished();
27 }
28
29@@ -62,6 +67,15 @@
30 m_systemConnection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT);
31 }
32
33+void SecretAgent::serviceOwnerChanged(const QString &name,
34+ const QString &oldOwner, const QString &newOwner) {
35+ Q_UNUSED(name)
36+ Q_UNUSED(oldOwner)
37+ if (!newOwner.isEmpty()) {
38+ m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished();
39+ }
40+}
41+
42 /**
43 * Example call:
44 * [Argument: a{sa{sv}}
45
46=== modified file 'secret-agent/SecretAgent.h'
47--- secret-agent/SecretAgent.h 2013-10-16 14:17:50 +0000
48+++ secret-agent/SecretAgent.h 2014-05-15 14:41:43 +0000
49@@ -74,6 +74,10 @@
50
51 org::freedesktop::Notifications & notifications();
52
53+protected Q_SLOTS:
54+ void serviceOwnerChanged(const QString &name, const QString &oldOwner,
55+ const QString &newOwner);
56+
57 protected:
58 QScopedPointer<SecretAgentAdaptor> m_adaptor;
59
60@@ -81,6 +85,8 @@
61
62 QDBusConnection m_sessionConnection;
63
64+ QDBusServiceWatcher m_managerWatcher;
65+
66 org::freedesktop::NetworkManager::AgentManager m_agentManager;
67
68 org::freedesktop::Notifications m_notifications;

Subscribers

People subscribed via source and target branches