diff options
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) |
