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 +++--- libindicator/indicator-service.c | 2 +- libindicator/indicator-service.xml | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) 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; } diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 69422c5..a4cdb68 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -305,7 +305,7 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati priv->timeout = 0; } - dbus_g_method_return(method, 1); + dbus_g_method_return(method, INDICATOR_SERVICE_VERSION, 0); return TRUE; } diff --git a/libindicator/indicator-service.xml b/libindicator/indicator-service.xml index d876ea8..dc872e2 100644 --- a/libindicator/indicator-service.xml +++ b/libindicator/indicator-service.xml @@ -7,7 +7,8 @@ - + + -- 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(+) 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 d7e9d013ae0d872fe0657b79f081a2a44b42f4c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 10:06:43 -0600 Subject: Sending a version number for the local service. --- libindicator/indicator-service.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index a4cdb68..eebe3f8 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -20,6 +20,7 @@ struct _IndicatorServicePrivate { DBusGProxy * dbus_proxy; guint timeout; GList * watchers; + guint this_service_version; }; /* Signals Stuff */ @@ -36,10 +37,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_GET_PRIVATE(o) \ @@ -78,6 +81,12 @@ indicator_service_class_init (IndicatorServiceClass *klass) "This is the name that should be used on DBus for this 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 implementing.", + "A number to represent the version of the other APIs the service provides. This should match across the manager and the service", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ @@ -113,6 +122,7 @@ indicator_service_init (IndicatorService *self) priv->dbus_proxy = NULL; priv->timeout = 0; priv->watchers = NULL; + priv->this_service_version = 0; /* Start talkin' dbus */ GError * error = NULL; @@ -213,6 +223,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; @@ -240,6 +254,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; @@ -305,7 +323,7 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati priv->timeout = 0; } - dbus_g_method_return(method, INDICATOR_SERVICE_VERSION, 0); + dbus_g_method_return(method, INDICATOR_SERVICE_VERSION, priv->this_service_version); return TRUE; } -- 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 +++++++++++ libindicator/indicator-service-manager.h | 2 ++ libindicator/indicator-service.c | 25 +++++++++++++++++++++++++ libindicator/indicator-service.h | 4 +++- 4 files changed, 41 insertions(+), 1 deletion(-) 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) { diff --git a/libindicator/indicator-service-manager.h b/libindicator/indicator-service-manager.h index 127d56b..65a93ea 100644 --- a/libindicator/indicator-service-manager.h +++ b/libindicator/indicator-service-manager.h @@ -54,6 +54,8 @@ struct _IndicatorServiceManager { GType indicator_service_manager_get_type (void); IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name); +IndicatorServiceManager * indicator_service_manager_new_version (gchar * dbus_name, + guint version); gboolean indicator_service_manager_connected (IndicatorServiceManager * sm); void indicator_service_manager_set_refresh (IndicatorServiceManager * sm, guint time_in_ms); diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index eebe3f8..2ce5521 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -350,3 +350,28 @@ indicator_service_new (gchar * name) return INDICATOR_SERVICE(obj); } + +/** + indicator_service_new_version: + @name: The name for the service on dbus + @version: The version of the other interfaces provide + by the service. + + This function creates the service on DBus and tries to + get a well-known name specified in @name. If the name + can't be estabilished then the #IndicatorService::shutdown + signal will be sent. + + Return value: A brand new #IndicatorService object or #NULL + if there is an error. +*/ +IndicatorService * +indicator_service_new_version (gchar * name, guint version) +{ + GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE, + PROP_NAME_S, name, + PROP_VERSION_S, version, + NULL); + + return INDICATOR_SERVICE(obj); +} diff --git a/libindicator/indicator-service.h b/libindicator/indicator-service.h index b47a91a..59c5385 100644 --- a/libindicator/indicator-service.h +++ b/libindicator/indicator-service.h @@ -53,7 +53,9 @@ struct _IndicatorService { GType indicator_service_get_type (void); -IndicatorService * indicator_service_new (gchar * name); +IndicatorService * indicator_service_new (gchar * name); +IndicatorService * indicator_service_new_version (gchar * name, + guint version); G_END_DECLS -- cgit v1.2.3 From 36f2ede024b05019c50e06d177e0c9be5750e919 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 13:42:29 -0600 Subject: Adding a new test to look at version numbers. --- .bzrignore | 6 +++ tests/Makefile.am | 72 ++++++++++++++++++++++++++++++++++- tests/service-version-bad-service.c | 47 +++++++++++++++++++++++ tests/service-version-bad.service.in | 3 ++ tests/service-version-good-service.c | 47 +++++++++++++++++++++++ tests/service-version-good.service.in | 3 ++ tests/service-version-manager.c | 61 +++++++++++++++++++++++++++++ tests/service-version-values.h | 4 ++ 8 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 tests/service-version-bad-service.c create mode 100644 tests/service-version-bad.service.in create mode 100644 tests/service-version-good-service.c create mode 100644 tests/service-version-good.service.in create mode 100644 tests/service-version-manager.c create mode 100644 tests/service-version-values.h diff --git a/.bzrignore b/.bzrignore index f11a31f..39300cc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -135,3 +135,9 @@ tests/service-manager-connect-tester tests/session.conf tests/service-manager-connect.service tools/indicator-loader +tests/service-version-bad-service +tests/service-version-bad.service +tests/service-version-good-service +tests/service-version-good.service +tests/service-version-manager +tests/service-version-tester diff --git a/tests/Makefile.am b/tests/Makefile.am index 80c4191..ede838c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ TESTS = DISTCLEANFILES = -check_PROGRAMS = \ +check_PROGRAMS = test-loader \ service-manager-no-connect \ service-manager-connect \ @@ -20,6 +20,8 @@ DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.c # Test Loader ############################# +check_PROGRAMS += test-loader + test_loader_SOURCES = \ test-loader.c @@ -117,6 +119,8 @@ libdummy_indicator_simple_la_LDFLAGS = \ # Service Shutdown Timeout ############################# +check_PROGRAMS += service-shutdown-timeout + service_shutdown_timeout_SOURCES = \ service-shutdown-timeout.c @@ -140,6 +144,8 @@ DISTCLEANFILES += service-shutdown-timeout-tester # Service Manager No Connect ############################# +check_PROGRAMS += service-manager-no-connect + service_manager_no_connect_SOURCES = \ service-manager-no-connect.c @@ -169,6 +175,8 @@ session.conf: $(srcdir)/session.conf.in Makefile.am service-manager-connect.service: $(srcdir)/service-manager-connect.service.in Makefile.am sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@ +check_PROGRAMS += service-manager-connect + service_manager_connect_SOURCES = \ service-manager-connect.c @@ -180,6 +188,8 @@ service_manager_connect_LDADD = \ $(LIBINDICATOR_LIBS) \ $(top_builddir)/libindicator/.libs/libindicator.a +check_PROGRAMS += service-manager-connect-service + service_manager_connect_service_SOURCES = \ service-manager-connect-service.c @@ -199,6 +209,66 @@ service-manager-connect-tester: service-manager-connect service-manager-connect- TESTS += service-manager-connect-tester DISTCLEANFILES += service-manager-connect-tester session.conf service-manager-connect.service +############################# +# Service Versions +############################# + +service-version-good.service: $(srcdir)/service-version-good.service.in Makefile.am + sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@ + +service-version-bad.service: $(srcdir)/service-version-bad.service.in Makefile.am + sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@ + +check_PROGRAMS += service-version-manager + +service_version_manager_SOURCES = \ + service-version-values.h \ + service-version-manager.c + +service_version_manager_CFLAGS = \ + -Wall -Werror \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) + +service_version_manager_LDADD = \ + $(LIBINDICATOR_LIBS) \ + $(top_builddir)/libindicator/.libs/libindicator.a + +check_PROGRAMS += service-version-bad-service + +service_version_bad_service_SOURCES = \ + service-version-values.h \ + service-version-bad-service.c + +service_version_bad_service_CFLAGS = \ + -Wall -Werror \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) + +service_version_bad_service_LDADD = \ + $(LIBINDICATOR_LIBS) \ + $(top_builddir)/libindicator/.libs/libindicator.a + +check_PROGRAMS += service-version-good-service + +service_version_good_service_SOURCES = \ + service-version-values.h \ + service-version-good-service.c + +service_version_good_service_CFLAGS = \ + -Wall -Werror \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) + +service_version_good_service_LDADD = \ + $(LIBINDICATOR_LIBS) \ + $(top_builddir)/libindicator/.libs/libindicator.a + +service-version-tester: service-version-manager service-version-bad-service service-version-good-service session.conf service-version-bad.service service-version-good.service Makefile.am + @echo "#!/bin/sh" > $@ + @echo dbus-test-runner --dbus-config $(builddir)/session.conf --task ./service-version-manager >> $@ + @chmod +x $@ + +TESTS += service-version-tester +DISTCLEANFILES += service-version-tester service-version-bad.service service-version-good.service + ############################# # Test stuff ############################# diff --git a/tests/service-version-bad-service.c b/tests/service-version-bad-service.c new file mode 100644 index 0000000..aea87b1 --- /dev/null +++ b/tests/service-version-bad-service.c @@ -0,0 +1,47 @@ + +#include +#include "libindicator/indicator-service.h" +#include "service-version-values.h" + +static GMainLoop * mainloop = NULL; +static gboolean passed = FALSE; + +gboolean +timeout (gpointer data) +{ + passed = FALSE; + g_debug("Timeout with no shutdown."); + g_main_loop_quit(mainloop); + return FALSE; +} + +void +shutdown (void) +{ + g_error("Shutdown"); + passed = TRUE; + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicatorService * is = indicator_service_new_version("org.ayatana.test", SERVICE_VERSION_BAD); + g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL); + + g_timeout_add_seconds(1, timeout, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + if (passed) { + g_debug("Passed"); + return 0; + } + g_debug("Failed"); + return 1; +} diff --git a/tests/service-version-bad.service.in b/tests/service-version-bad.service.in new file mode 100644 index 0000000..1e763eb --- /dev/null +++ b/tests/service-version-bad.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.ayatana.version.bad +Exec=@builddir@/service-version-bad-service diff --git a/tests/service-version-good-service.c b/tests/service-version-good-service.c new file mode 100644 index 0000000..db9632c --- /dev/null +++ b/tests/service-version-good-service.c @@ -0,0 +1,47 @@ + +#include +#include "libindicator/indicator-service.h" +#include "service-version-values.h" + +static GMainLoop * mainloop = NULL; +static gboolean passed = FALSE; + +gboolean +timeout (gpointer data) +{ + passed = FALSE; + g_debug("Timeout with no shutdown."); + g_main_loop_quit(mainloop); + return FALSE; +} + +void +shutdown (void) +{ + g_error("Shutdown"); + passed = TRUE; + g_main_loop_quit(mainloop); + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicatorService * is = indicator_service_new_version("org.ayatana.test", SERVICE_VERSION_GOOD); + g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL); + + g_timeout_add_seconds(1, timeout, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + if (passed) { + g_debug("Passed"); + return 0; + } + g_debug("Failed"); + return 1; +} diff --git a/tests/service-version-good.service.in b/tests/service-version-good.service.in new file mode 100644 index 0000000..c57a04f --- /dev/null +++ b/tests/service-version-good.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.ayatana.version.good +Exec=@builddir@/service-version-good-service diff --git a/tests/service-version-manager.c b/tests/service-version-manager.c new file mode 100644 index 0000000..ca29ea7 --- /dev/null +++ b/tests/service-version-manager.c @@ -0,0 +1,61 @@ + +#include +#include "libindicator/indicator-service-manager.h" +#include "service-version-values.h" + +static GMainLoop * mainloop = NULL; +static gboolean con_good = FALSE; +static gboolean con_bad = FALSE; + +gboolean +timeout (gpointer data) +{ + g_error("Timeout."); + g_main_loop_quit(mainloop); + return FALSE; +} + +void +connection_bad (void) +{ + g_debug("Connection From Bad!"); + con_bad = TRUE; + return; +} + +void +connection_good (void) +{ + g_debug("Connection From Good."); + con_good = TRUE; + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); + + IndicatorServiceManager * goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD); + g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection_good, NULL); + + IndicatorServiceManager * badis = indicator_service_manager_new_version("org.ayatana.version.bad", SERVICE_VERSION_GOOD); + g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection_bad, NULL); + + g_timeout_add_seconds(1, timeout, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(goodis); + g_object_unref(badis); + + g_debug("Quiting"); + if (con_good && !con_bad) { + g_debug("Passed"); + return 0; + } + g_debug("Failed"); + return 1; +} diff --git a/tests/service-version-values.h b/tests/service-version-values.h new file mode 100644 index 0000000..e9fb087 --- /dev/null +++ b/tests/service-version-values.h @@ -0,0 +1,4 @@ + +#define SERVICE_VERSION_GOOD 1342 +#define SERVICE_VERSION_BAD 543 + -- cgit v1.2.3 From 792315d74baf0dcb2c36a85bcab2c5888b362a82 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 13:56:44 -0600 Subject: Adding a log domain for error messages --- libindicator/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 717d60f..6d5c627 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -26,6 +26,7 @@ libindicator_la_SOURCES = \ libindicator_la_CFLAGS = \ $(LIBINDICATOR_CFLAGS) \ + -DG_LOG_DOMAIN=\"libindicator\" \ -Wall -Werror libindicator_la_LIBADD = \ -- cgit v1.2.3 From 937c28b1c18f945c0bcbb5f4cd2deaa7f46927ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 13:57:00 -0600 Subject: Not erroring when we're supposed to pass. --- tests/service-version-bad-service.c | 2 +- tests/service-version-good-service.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/service-version-bad-service.c b/tests/service-version-bad-service.c index aea87b1..f3b25be 100644 --- a/tests/service-version-bad-service.c +++ b/tests/service-version-bad-service.c @@ -18,7 +18,7 @@ timeout (gpointer data) void shutdown (void) { - g_error("Shutdown"); + g_debug("Shutdown"); passed = TRUE; g_main_loop_quit(mainloop); return; diff --git a/tests/service-version-good-service.c b/tests/service-version-good-service.c index db9632c..b607137 100644 --- a/tests/service-version-good-service.c +++ b/tests/service-version-good-service.c @@ -18,7 +18,7 @@ timeout (gpointer data) void shutdown (void) { - g_error("Shutdown"); + g_debug("Shutdown"); passed = TRUE; g_main_loop_quit(mainloop); return; -- cgit v1.2.3 From 18351a81c96b2d9299cda2fdb2e13901bead7cb1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 15:11:29 -0600 Subject: Changing the names we're registering for to be correct. --- tests/service-version-bad-service.c | 2 +- tests/service-version-good-service.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/service-version-bad-service.c b/tests/service-version-bad-service.c index f3b25be..6057e74 100644 --- a/tests/service-version-bad-service.c +++ b/tests/service-version-bad-service.c @@ -29,7 +29,7 @@ main (int argc, char ** argv) { g_type_init(); - IndicatorService * is = indicator_service_new_version("org.ayatana.test", SERVICE_VERSION_BAD); + IndicatorService * is = indicator_service_new_version("org.ayatana.version.bad", SERVICE_VERSION_BAD); g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL); g_timeout_add_seconds(1, timeout, NULL); diff --git a/tests/service-version-good-service.c b/tests/service-version-good-service.c index b607137..bcfe46d 100644 --- a/tests/service-version-good-service.c +++ b/tests/service-version-good-service.c @@ -29,7 +29,7 @@ main (int argc, char ** argv) { g_type_init(); - IndicatorService * is = indicator_service_new_version("org.ayatana.test", SERVICE_VERSION_GOOD); + IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD); g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL); g_timeout_add_seconds(1, timeout, NULL); -- cgit v1.2.3 From 6bbe989007e7363daf84d6779d80312ee73daf60 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 15:15:03 -0600 Subject: Printing out the session bus address --- tests/service-version-manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/service-version-manager.c b/tests/service-version-manager.c index ca29ea7..b5bb807 100644 --- a/tests/service-version-manager.c +++ b/tests/service-version-manager.c @@ -10,7 +10,7 @@ static gboolean con_bad = FALSE; gboolean timeout (gpointer data) { - g_error("Timeout."); + g_debug("Timeout."); g_main_loop_quit(mainloop); return FALSE; } @@ -36,6 +36,7 @@ main (int argc, char ** argv) { g_type_init(); g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); + g_print("Manager: DBUS_SESSION_BUS_ADDRESS = %s\n", g_getenv("DBUS_SESSION_BUS_ADDRESS")); IndicatorServiceManager * goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD); g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection_good, NULL); -- 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(-) 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(+) 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 1696a679089c71f23557ad8c3ec4d1da2d9f6b73 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 2 Dec 2009 15:49:23 -0600 Subject: Forgot to delete the programs. --- tests/Makefile.am | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index ede838c..373367a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,11 +2,6 @@ TESTS = DISTCLEANFILES = check_PROGRAMS = - test-loader \ - service-manager-no-connect \ - service-manager-connect \ - service-manager-connect-service \ - service-shutdown-timeout lib_LTLIBRARIES = \ libdummy-indicator-blank.la \ -- cgit v1.2.3 From 436bca27a730090096c20637013a3905fe9f9055 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Dec 2009 14:31:10 -0600 Subject: Full signal handlers so that we can see everything. --- tests/service-version-manager.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/service-version-manager.c b/tests/service-version-manager.c index b5bb807..aedc0ed 100644 --- a/tests/service-version-manager.c +++ b/tests/service-version-manager.c @@ -16,16 +16,18 @@ timeout (gpointer data) } void -connection_bad (void) +connection_bad (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { + if (!connected) return; g_debug("Connection From Bad!"); con_bad = TRUE; return; } void -connection_good (void) +connection_good (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { + if (!connected) return; g_debug("Connection From Good."); con_good = TRUE; return; @@ -39,10 +41,10 @@ main (int argc, char ** argv) g_print("Manager: DBUS_SESSION_BUS_ADDRESS = %s\n", g_getenv("DBUS_SESSION_BUS_ADDRESS")); IndicatorServiceManager * goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD); - g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection_good, NULL); + g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_good), NULL); IndicatorServiceManager * badis = indicator_service_manager_new_version("org.ayatana.version.bad", SERVICE_VERSION_GOOD); - g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection_bad, NULL); + g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_bad), NULL); g_timeout_add_seconds(1, timeout, NULL); -- 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(-) 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(+) 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(-) 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