From aa951a3eb41ba3e4c9fcf9732992aa6e28dc83a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Dec 2009 16:34:32 -0600 Subject: Change the watch function to return both an API version and a user set version. --- libindicator/indicator-service-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 4eaed23..4cf80c6 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -232,7 +232,7 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe } static void -watch_cb (DBusGProxy * proxy, gint service_version, GError * error, gpointer user_data) +watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_version, GError * error, gpointer user_data) { IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); @@ -242,8 +242,8 @@ watch_cb (DBusGProxy * proxy, gint service_version, GError * error, gpointer use return; } - if (service_version != INDICATOR_SERVICE_VERSION) { - g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_version); + if (service_api_version != INDICATOR_SERVICE_VERSION) { + g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version); return; } -- cgit v1.2.3 From a1d20fbfb38c1e4581b86a86964d3c71c46f1ead Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Dec 2009 16:45:54 -0600 Subject: Adding a property for version. --- libindicator/indicator-service-manager.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 4cf80c6..cbe66d3 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -16,6 +16,7 @@ struct _IndicatorServiceManagerPrivate { DBusGProxy * dbus_proxy; DBusGProxy * service_proxy; gboolean connected; + guint this_service_version; }; /* Signals Stuff */ @@ -33,10 +34,12 @@ static guint signals[LAST_SIGNAL] = { 0 }; enum { PROP_0, PROP_NAME, + PROP_VERSION }; /* The strings so that they can be slowly looked up. */ #define PROP_NAME_S "name" +#define PROP_VERSION_S "version" /* GObject Stuff */ #define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \ @@ -91,6 +94,12 @@ indicator_service_manager_class_init (IndicatorServiceManagerClass *klass) "This is the name that should be used to start a service.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, PROP_VERSION, + g_param_spec_uint(PROP_VERSION_S, + "The version of the service that we're expecting.", + "A number to check and reject a service if it gives us the wrong number. This should match across the manager and the service", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); return; } @@ -105,6 +114,7 @@ indicator_service_manager_init (IndicatorServiceManager *self) priv->dbus_proxy = NULL; priv->service_proxy = NULL; priv->connected = FALSE; + priv->this_service_version = 0; /* Start talkin' dbus */ GError * error = NULL; @@ -196,6 +206,10 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec } break; /* *********************** */ + case PROP_VERSION: + priv->this_service_version = g_value_get_uint(value); + break; + /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -223,6 +237,10 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe } break; /* *********************** */ + case PROP_VERSION: + g_value_set_uint(value, priv->this_service_version); + break; + /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From a4e33bf97827e04c364210f29ccb85ed6254050f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 10:15:11 -0600 Subject: Adding _new functions that include the version number in them. --- libindicator/indicator-service-manager.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index cbe66d3..293ae03 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -337,6 +337,17 @@ indicator_service_manager_new (gchar * dbus_name) return INDICATOR_SERVICE_MANAGER(obj); } +IndicatorServiceManager * +indicator_service_manager_new_version (gchar * dbus_name, guint version) +{ + GObject * obj = g_object_new(INDICATOR_SERVICE_MANAGER_TYPE, + PROP_NAME_S, dbus_name, + PROP_VERSION_S, version, + NULL); + + return INDICATOR_SERVICE_MANAGER(obj); +} + gboolean indicator_service_manager_connected (IndicatorServiceManager * sm) { -- cgit v1.2.3 From 0c7f6132b3a13ef580f872db309b9adb061a0513 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 15:15:21 -0600 Subject: Specifying who can't get the session bus. --- libindicator/indicator-service-manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 293ae03..86aa8b3 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -120,7 +120,7 @@ indicator_service_manager_init (IndicatorServiceManager *self) GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { - g_error("Unable to get session bus: %s", error->message); + g_error("Unable to get session bus for manager: %s", error->message); g_error_free(error); return; } @@ -291,7 +291,7 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use /* Woot! it's running. Let's do it some more. */ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { - g_error("Unable to get session bus: %s", error->message); + g_error("Unable to get session bus for manager: %s", error->message); g_error_free(error); return; } -- cgit v1.2.3 From b2a0e038ff46fc4ad40377e71eed4e1fd74c69f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 15:35:26 -0600 Subject: Actually checking the version and erroring on it. --- libindicator/indicator-service-manager.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 86aa8b3..cc5c382 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -265,6 +265,11 @@ watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_vers return; } + if (this_service_version != priv->this_service_version) { + g_warning("Service is using a API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); + return; + } + if (!priv->connected) { priv->connected = TRUE; g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, TRUE, TRUE); -- cgit v1.2.3 From 8331ee5c19c33130e574a2c9785e6caad806dfe2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Dec 2009 14:39:20 -0600 Subject: Switching unwatch to being a no_reply function call. --- libindicator/indicator-service-manager.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index a3f76b2..db31aff 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -55,7 +55,6 @@ static void indicator_service_manager_finalize (GObject *object); static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void start_service (IndicatorServiceManager * service); -static void unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata); G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT); @@ -163,7 +162,7 @@ indicator_service_manager_dispose (GObject *object) /* If we have a proxy, tell it we're shutting down. Just to be polite about it. */ if (priv->service_proxy != NULL) { - org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL); + dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); } /* Destory our service proxy, we won't need it. */ @@ -258,12 +257,6 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe return; } -static void -unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata) -{ - return; -} - static void watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_version, GError * error, gpointer user_data) { @@ -277,13 +270,13 @@ watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_vers if (service_api_version != INDICATOR_SERVICE_VERSION) { g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version); - org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL); + dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); return; } if (this_service_version != priv->this_service_version) { g_warning("Service is using a API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); - org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL); + dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); return; } -- cgit v1.2.3 From ea29a8effb3c9ebcb7d2f469add8eaff462d29c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Dec 2009 15:15:34 -0600 Subject: Adding a weak pointer to the service proxy. --- libindicator/indicator-service-manager.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index db31aff..a3680c4 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -309,6 +309,7 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use INDICATOR_SERVICE_OBJECT, INDICATOR_SERVICE_INTERFACE, &error); + g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy)); org_ayatana_indicator_service_watch_async(priv->service_proxy, watch_cb, -- cgit v1.2.3 From 134704130d3d871c8ff5bda62e2e9501a447375a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 7 Dec 2009 13:07:43 -0600 Subject: Fixing a typo in the error message -- noticed by David Barth. --- libindicator/indicator-service-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicator/indicator-service-manager.c') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index a3680c4..b4d5915 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -275,7 +275,7 @@ watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_vers } if (this_service_version != priv->this_service_version) { - g_warning("Service is using a API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); + g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); return; } -- cgit v1.2.3