diff options
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | data/com.canonical.indicator.session | 10 | ||||
-rw-r--r-- | data/session.indicator | 4 | ||||
-rw-r--r-- | src/backend-dbus/actions.c | 13 | ||||
-rw-r--r-- | src/backend-dbus/guest.c | 30 | ||||
-rw-r--r-- | src/backend-dbus/users.c | 28 | ||||
-rw-r--r-- | src/backend-dbus/utils.c | 28 | ||||
-rw-r--r-- | src/main.c | 42 | ||||
-rw-r--r-- | src/service.c | 46 | ||||
-rw-r--r-- | src/service.h | 2 | ||||
-rw-r--r-- | tests/backend-mock-guest.c | 2 | ||||
-rw-r--r-- | tests/test-service.cc | 13 |
12 files changed, 93 insertions, 135 deletions
@@ -0,0 +1,10 @@ +code + x x-canonical-type for user/guest menuitems + x remove the --replace command-line argument + - fix deprecated/dead APIs use in backend + +cmake + - add cmake rule to install .indicator file + - add cmake rule to install dbus service file + - icon installation + - test schema installation diff --git a/data/com.canonical.indicator.session b/data/com.canonical.indicator.session new file mode 100644 index 0000000..fce3554 --- /dev/null +++ b/data/com.canonical.indicator.session @@ -0,0 +1,10 @@ +[Indicator Service] +Name=indicator-session +ObjectPath=/com/canonical/indicator/session + +[desktop] +ObjectPath=/com/canonical/indicator/session/desktop + +[greeter] +ObjectPath=/com/canonical/indicator/session/greeter + diff --git a/data/session.indicator b/data/session.indicator deleted file mode 100644 index b5f6802..0000000 --- a/data/session.indicator +++ /dev/null @@ -1,4 +0,0 @@ -[Indicator Service] -Name=indicator-session -BusName=com.canonical.indicator.session-test -ObjectPath=/com/canonical/indicator/session diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index 8994710..bc196f2 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -68,7 +68,9 @@ log_and_clear_error (GError ** err, const char * loc, const char * func) { if (*err) { - g_warning ("%s %s: %s", loc, func, (*err)->message); + if (!g_error_matches (*err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", loc, func, (*err)->message); + g_clear_error (err); } } @@ -591,14 +593,6 @@ my_dispose (GObject * o) G_OBJECT_CLASS (indicator_session_actions_dbus_parent_class)->dispose (o); } -static void -my_finalize (GObject * o) -{ - /*IndicatorSessionActionsDbus * u = INDICATOR_SESSION_ACTIONS_DBUS (o);*/ - - G_OBJECT_CLASS (indicator_session_actions_dbus_parent_class)->finalize (o); -} - /*** **** GObject Boilerplate ***/ @@ -612,7 +606,6 @@ indicator_session_actions_dbus_class_init (IndicatorSessionActionsDbusClass * kl object_class = G_OBJECT_CLASS (klass); object_class->dispose = my_dispose; - object_class->finalize = my_finalize; actions_class = INDICATOR_SESSION_ACTIONS_CLASS (klass); actions_class->can_lock = my_can_lock; diff --git a/src/backend-dbus/guest.c b/src/backend-dbus/guest.c index 1559aa8..317152d 100644 --- a/src/backend-dbus/guest.c +++ b/src/backend-dbus/guest.c @@ -95,7 +95,9 @@ on_active_uid_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gse if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else @@ -140,7 +142,10 @@ on_active_session_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gp if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + + g_error_free (err); } else { @@ -253,7 +258,9 @@ on_user_proxy_ready (GObject * o G_GNUC_UNUSED, if (err != NULL) { - g_warning ("%s: %s", G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s: %s", G_STRFUNC, err->message); + g_error_free (err); } else if (is_guest (user)) @@ -290,7 +297,9 @@ on_user_list_ready (GObject * o, GAsyncResult * res, gpointer gself) accounts_call_list_cached_users_finish (ACCOUNTS(o), &paths, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else @@ -389,7 +398,9 @@ on_switch_to_guest_done (GObject * o, GAsyncResult * res, gpointer unused G_GNUC display_manager_seat_call_switch_to_guest_finish (DISPLAY_MANAGER_SEAT(o), res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } } @@ -418,14 +429,6 @@ my_dispose (GObject * o) G_OBJECT_CLASS (indicator_session_guest_dbus_parent_class)->dispose (o); } -static void -my_finalize (GObject * o) -{ - /*IndicatorSessionGuestDbus * u = INDICATOR_SESSION_GUEST_DBUS (o);*/ - - G_OBJECT_CLASS (indicator_session_guest_dbus_parent_class)->finalize (o); -} - static gboolean my_is_allowed (IndicatorSessionGuest * self) { @@ -483,7 +486,6 @@ indicator_session_guest_dbus_class_init (IndicatorSessionGuestDbusClass * klass) object_class = G_OBJECT_CLASS (klass); object_class->dispose = my_dispose; - object_class->finalize = my_finalize; guest_class = INDICATOR_SESSION_GUEST_CLASS (klass); guest_class->is_allowed = my_is_allowed; diff --git a/src/backend-dbus/users.c b/src/backend-dbus/users.c index 34e0c97..6d9ada6 100644 --- a/src/backend-dbus/users.c +++ b/src/backend-dbus/users.c @@ -154,7 +154,9 @@ on_user_proxy_ready (GObject * o G_GNUC_UNUSED, user = accounts_user_proxy_new_for_bus_finish (res, &err); if (err != NULL) { - g_warning ("%s: %s", G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s: %s", G_STRFUNC, err->message); + g_error_free (err); } else @@ -187,7 +189,9 @@ on_user_list_ready (GObject * o, GAsyncResult * res, gpointer gself) accounts_call_list_cached_users_finish (ACCOUNTS(o), &paths, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else @@ -317,7 +321,9 @@ on_session_proxy_uid_ready (GObject * o, console_kit_session_call_get_unix_user_finish (session, &uid, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else if (uid) @@ -347,7 +353,9 @@ on_session_x11_display_ready (GObject * o, console_kit_session_call_get_x11_display_finish (session, &gui, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else @@ -378,7 +386,9 @@ on_session_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer session = console_kit_session_proxy_new_finish (res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else if (session != NULL) @@ -417,7 +427,9 @@ on_session_list_ready (GObject * o, GAsyncResult * res, gpointer gself) &sessions, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else @@ -508,7 +520,9 @@ on_seat_active_session_ready (GObject * o, GAsyncResult * res, gpointer gself) console_kit_seat_call_get_active_session_finish (seat, &ssid, res, &err); if (err != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message); + g_error_free (err); } else if (ssid != NULL) diff --git a/src/backend-dbus/utils.c b/src/backend-dbus/utils.c index 86a5e5a..c8abc2b 100644 --- a/src/backend-dbus/utils.c +++ b/src/backend-dbus/utils.c @@ -91,7 +91,8 @@ on_user_proxy_ready (GObject * o G_GNUC_UNUSED, if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else { @@ -112,7 +113,8 @@ on_user_path_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gdat if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else if (path != NULL) { @@ -141,7 +143,8 @@ on_uid_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gdata) console_kit_session_call_get_unix_user_finish (data->current_session, &uid, res, &data->error); if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else if (uid) { @@ -165,7 +168,7 @@ on_seat_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gda data->current_seat = console_kit_seat_proxy_new_for_bus_finish (res, &data->error); - if (data->error != NULL) + if (data->error && !g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); finish_callback (data); @@ -182,7 +185,8 @@ on_sid_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gdata) if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else if (sid != NULL) { @@ -210,7 +214,8 @@ on_session_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer data->current_session = console_kit_session_proxy_new_finish (res, &data->error); if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else { @@ -243,7 +248,8 @@ on_current_session_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointe &data->error); if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else if (ssid) { @@ -275,7 +281,8 @@ on_display_manager_seat_proxy_ready (GObject * o G_GNUC_UNUSED, if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else if (seat != NULL) { @@ -302,7 +309,8 @@ on_console_kit_manager_proxy_ready (GObject * o G_GNUC_UNUSED, if (data->error != NULL) { - g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); + if (!g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } else { @@ -330,7 +338,7 @@ on_accounts_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer { data->account_manager = accounts_proxy_new_for_bus_finish (res, &data->error); - if (data->error != NULL) + if (data->error && !g_error_matches (data->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, data->error->message); } @@ -29,46 +29,16 @@ **** ***/ -static gboolean replace = FALSE; - -static void -parse_command_line (int * argc, char *** argv) -{ - GError * error; - GOptionContext * option_context; - - static GOptionEntry entries[] = - { - { "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "Replace the currently-running service", NULL }, - { NULL } - }; - - error = NULL; - option_context = g_option_context_new ("- indicator-session service"); - g_option_context_add_main_entries (option_context, entries, GETTEXT_PACKAGE); - if (!g_option_context_parse (option_context, argc, argv, &error)) - { - g_print ("option parsing failed: %s\n", error->message); - g_error_free (error); - exit (EXIT_FAILURE); - } - - g_option_context_free (option_context); -} - -/*** -**** -***/ - static void on_name_lost (gpointer instance, gpointer loop) { - g_debug ("exiting: service couldn't acquire or lost ownership of busname"); - g_main_loop_quit ((GMainLoop*)loop); + g_warning ("exiting: service couldn't acquire, or lost ownership of, busname"); + + g_main_loop_quit (loop); } int -main (int argc, char ** argv) +main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) { GMainLoop * loop; IndicatorSessionService * service; @@ -78,10 +48,8 @@ main (int argc, char ** argv) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); - parse_command_line (&argc, &argv); - /* run */ - service = indicator_session_service_new (replace); + service = indicator_session_service_new (); loop = g_main_loop_new (NULL, FALSE); g_signal_connect (service, INDICATOR_SESSION_SERVICE_SIGNAL_NAME_LOST, G_CALLBACK(on_name_lost), loop); diff --git a/src/service.c b/src/service.c index 59728d1..4a62bd1 100644 --- a/src/service.c +++ b/src/service.c @@ -17,16 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <locale.h> - #include <glib/gi18n.h> #include <gio/gio.h> #include "backend.h" #include "service.h" -/* FIXME: remove -test */ -#define BUS_NAME "com.canonical.indicator.session-test" +#define BUS_NAME "com.canonical.indicator.session" #define BUS_PATH "/com/canonical/indicator/session" #define ICON_DEFAULT "system-devices-panel" @@ -49,7 +46,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; enum { PROP_0, - PROP_REPLACE, PROP_MAX_USERS, PROP_LAST }; @@ -109,8 +105,6 @@ struct _IndicatorSessionServicePrivate int rebuild_flags; GDBusConnection * conn; GCancellable * cancellable; - - gboolean replace; }; typedef IndicatorSessionServicePrivate priv_t; @@ -1025,23 +1019,10 @@ indicator_session_service_init (IndicatorSessionService * self) gp = p->keybinding_settings; g_signal_connect_swapped (gp, "changed::screensaver", G_CALLBACK(rebuild_switch_section_soon), self); -} - -static void -my_constructed (GObject * o) -{ - GBusNameOwnerFlags owner_flags; - IndicatorSessionService * self = INDICATOR_SESSION_SERVICE(o); - - /* own the name in constructed() instead of init() so that - we'll know the value of the 'replace' property */ - owner_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; - if (self->priv->replace) - owner_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE; self->priv->own_id = g_bus_own_name (G_BUS_TYPE_SESSION, BUS_NAME, - owner_flags, + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, on_bus_acquired, NULL, on_name_lost, @@ -1063,10 +1044,6 @@ my_get_property (GObject * o, switch (property_id) { - case PROP_REPLACE: - g_value_set_boolean (value, self->priv->replace); - break; - case PROP_MAX_USERS: g_value_set_uint (value, self->priv->max_users); break; @@ -1086,10 +1063,6 @@ my_set_property (GObject * o, switch (property_id) { - case PROP_REPLACE: - self->priv->replace = g_value_get_boolean (value); - break; - case PROP_MAX_USERS: self->priv->max_users = g_value_get_uint (value); rebuild_switch_section_soon (self); @@ -1157,7 +1130,6 @@ indicator_session_service_class_init (IndicatorSessionServiceClass * klass) GObjectClass * object_class = G_OBJECT_CLASS (klass); object_class->dispose = my_dispose; - object_class->constructed = my_constructed; object_class->get_property = my_get_property; object_class->set_property = my_set_property; @@ -1173,14 +1145,6 @@ indicator_session_service_class_init (IndicatorSessionServiceClass * klass) properties[PROP_0] = NULL; - properties[PROP_REPLACE] = g_param_spec_boolean ("replace", - "Replace Service", - "Replace existing service", - FALSE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - properties[PROP_MAX_USERS] = g_param_spec_uint ("max-users", "Max Users", "Max visible users", @@ -1193,11 +1157,9 @@ indicator_session_service_class_init (IndicatorSessionServiceClass * klass) } IndicatorSessionService * -indicator_session_service_new (gboolean replace) +indicator_session_service_new (void) { - GObject * o = g_object_new (INDICATOR_TYPE_SESSION_SERVICE, - "replace", replace, - NULL); + GObject * o = g_object_new (INDICATOR_TYPE_SESSION_SERVICE, NULL); return INDICATOR_SESSION_SERVICE (o); } diff --git a/src/service.h b/src/service.h index 3fad6bf..fa870e5 100644 --- a/src/service.h +++ b/src/service.h @@ -64,7 +64,7 @@ struct _IndicatorSessionServiceClass GType indicator_session_service_get_type (void); -IndicatorSessionService * indicator_session_service_new (gboolean replace); +IndicatorSessionService * indicator_session_service_new (void); G_END_DECLS diff --git a/tests/backend-mock-guest.c b/tests/backend-mock-guest.c index 0428783..b04c805 100644 --- a/tests/backend-mock-guest.c +++ b/tests/backend-mock-guest.c @@ -71,7 +71,7 @@ my_is_active (IndicatorSessionGuest * self) } static void -my_switch_to_guest (IndicatorSessionGuest * self) +my_switch_to_guest (IndicatorSessionGuest * self G_GNUC_UNUSED) { g_message ("%s %s FIXME", G_STRLOC, G_STRFUNC); } diff --git a/tests/test-service.cc b/tests/test-service.cc index 058fc3d..57b4221 100644 --- a/tests/test-service.cc +++ b/tests/test-service.cc @@ -161,16 +161,11 @@ class ServiceTest: public GTestDBusFixture // Start an IndicatorSessionService and wait for it to appear on the bus. // This way our calls to g_dbus_*_get() in the next paragraph won't activate // a second copy of the service... - service = indicator_session_service_new (true); - - // confirm that the property got set - gboolean replace = FALSE; - g_object_get (service, "replace", &replace, NULL); - ASSERT_TRUE (replace); + service = indicator_session_service_new (); // wait for the service to show up on the bus const guint watch_id = g_bus_watch_name_on_connection (conn, - "com.canonical.indicator.session-test", + "com.canonical.indicator.session", G_BUS_NAME_WATCHER_FLAGS_NONE, on_name_appeared, // quits the loop NULL, this, NULL); @@ -182,10 +177,10 @@ class ServiceTest: public GTestDBusFixture // get the actions & menus that the service exported. action_group = g_dbus_action_group_get (conn, - "com.canonical.indicator.session-test", + "com.canonical.indicator.session", "/com/canonical/indicator/session"); menu_model = g_dbus_menu_model_get (conn, - "com.canonical.indicator.session-test", + "com.canonical.indicator.session", "/com/canonical/indicator/session/desktop"); // the actions are added asynchronously, so wait for the actions if (!g_action_group_has_action (G_ACTION_GROUP(action_group), "about")) |