diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-03-14 17:10:26 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-03-14 17:10:26 +0100 |
| commit | 9abf4680ab5be63897966aa209b213dbba6da04c (patch) | |
| tree | 03d73fb872a2cbe32f3bac4e68915d098edbfbde /UnityCore | |
| parent | 839207836f166fa7098749d6de284cb4261044ec (diff) | |
DBusIndicators: sync against DBusProxy changes, add reconnection support here
Plus, when clearing the indicators, we also clear the cached entries locations. (bzr r1858.12.5)
Diffstat (limited to 'UnityCore')
| -rw-r--r-- | UnityCore/DBusIndicators.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/UnityCore/DBusIndicators.cpp b/UnityCore/DBusIndicators.cpp index 9fe2232b1..b72851c8b 100644 --- a/UnityCore/DBusIndicators.cpp +++ b/UnityCore/DBusIndicators.cpp @@ -43,6 +43,7 @@ class DBusIndicators::Impl { public: Impl(DBusIndicators* owner); + ~Impl(); void CheckLocalService(); void RequestSyncAll(); @@ -74,6 +75,7 @@ public: }; DBusIndicators* owner_; + guint reconnect_timeout_id_; glib::DBusProxy gproxy_; std::map<std::string, EntryLocationMap> cached_locations_; }; @@ -82,8 +84,9 @@ public: // Public Methods DBusIndicators::Impl::Impl(DBusIndicators* owner) : owner_(owner) + , reconnect_timeout_id_(0) , gproxy_(SERVICE_NAME, SERVICE_PATH, SERVICE_IFACE, - G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, true) + G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES) { gproxy_.Connect("ReSync", sigc::mem_fun(this, &DBusIndicators::Impl::OnReSync)); gproxy_.Connect("EntryActivated", sigc::mem_fun(this, &DBusIndicators::Impl::OnEntryActivated)); @@ -96,6 +99,14 @@ DBusIndicators::Impl::Impl(DBusIndicators* owner) CheckLocalService(); } +DBusIndicators::Impl::~Impl() +{ + if (reconnect_timeout_id_) + { + g_source_remove(reconnect_timeout_id_); + } +} + void DBusIndicators::Impl::CheckLocalService() { if (g_getenv("PANEL_USE_LOCAL_SERVICE")) @@ -134,7 +145,23 @@ void DBusIndicators::Impl::OnDisconnected() owner_->RemoveIndicator(indicator->name()); } + cached_locations_.clear(); + CheckLocalService(); + RequestSyncAll(); + + reconnect_timeout_id_ = g_timeout_add_seconds(1, [](gpointer data) -> gboolean { + auto self = static_cast<DBusIndicators::Impl*>(data); + + if (!self->gproxy_.IsConnected()) + { + self->RequestSyncAll(); + return TRUE; + } + + self->reconnect_timeout_id_ = 0; + return FALSE; + }, this); } void DBusIndicators::Impl::OnReSync(GVariant* parameters) |
