From e66af3b073fbbf77236a186bdd8caa6d14e71737 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 Aug 2014 10:47:48 -0500 Subject: Adding desktop_greeter and phone_greeter profiles --- src/messages-service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/messages-service.c b/src/messages-service.c index d1ccbbc..3035d84 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -274,7 +274,9 @@ main (int argc, char ** argv) menus = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); g_hash_table_insert (menus, "phone", im_phone_menu_new (applications)); + g_hash_table_insert (menus, "phone_greeter", im_phone_menu_new (applications)); g_hash_table_insert (menus, "desktop", im_desktop_menu_new (applications)); + g_hash_table_insert (menus, "desktop_greeter", im_desktop_menu_new (applications)); g_unix_signal_add(SIGTERM, sig_term_handler, mainloop); -- cgit v1.2.3 From 36ab9b369b8e4e2ea80c597a854db907367e5a39 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:17:59 -0500 Subject: Adding a specifier for whether it's in the greeter or not --- src/im-phone-menu.c | 3 ++- src/im-phone-menu.h | 3 ++- src/messages-service.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c index 754fc2b..6e74954 100644 --- a/src/im-phone-menu.c +++ b/src/im-phone-menu.c @@ -142,12 +142,13 @@ im_phone_menu_init (ImPhoneMenu *menu) } ImPhoneMenu * -im_phone_menu_new (ImApplicationList *applist) +im_phone_menu_new (ImApplicationList *applist, gboolean greeter) { g_return_val_if_fail (IM_IS_APPLICATION_LIST (applist), NULL); return g_object_new (IM_TYPE_PHONE_MENU, "application-list", applist, + "on-greeter", greeter, NULL); } diff --git a/src/im-phone-menu.h b/src/im-phone-menu.h index 4f96c8c..813634d 100644 --- a/src/im-phone-menu.h +++ b/src/im-phone-menu.h @@ -33,7 +33,8 @@ typedef struct _ImPhoneMenu ImPhoneMenu; GType im_phone_menu_get_type (void); -ImPhoneMenu * im_phone_menu_new (ImApplicationList *applist); +ImPhoneMenu * im_phone_menu_new (ImApplicationList *applist, + gboolean greeter); void im_phone_menu_add_message (ImPhoneMenu *menu, const gchar *app_id, diff --git a/src/messages-service.c b/src/messages-service.c index 3035d84..d2c7e92 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -273,8 +273,8 @@ main (int argc, char ** argv) } menus = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); - g_hash_table_insert (menus, "phone", im_phone_menu_new (applications)); - g_hash_table_insert (menus, "phone_greeter", im_phone_menu_new (applications)); + g_hash_table_insert (menus, "phone", im_phone_menu_new (applications, FALSE)); + g_hash_table_insert (menus, "phone_greeter", im_phone_menu_new (applications, TRUE)); g_hash_table_insert (menus, "desktop", im_desktop_menu_new (applications)); g_hash_table_insert (menus, "desktop_greeter", im_desktop_menu_new (applications)); -- cgit v1.2.3 From b3f2f2c8c75f853fe16f6d677daae66d7e931e98 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:22:25 -0500 Subject: Setup a basic greeter property --- src/im-menu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/im-menu.c b/src/im-menu.c index 55d4685..a56dacb 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -24,6 +24,7 @@ struct _ImMenuPrivate GMenu *toplevel_menu; GMenu *menu; ImApplicationList *applist; + gboolean on_greeter; }; G_DEFINE_TYPE_WITH_PRIVATE (ImMenu, im_menu, G_TYPE_OBJECT) @@ -32,6 +33,7 @@ enum { PROP_0, PROP_APPLICATION_LIST, + PROP_ON_GREETER, NUM_PROPERTIES }; @@ -60,6 +62,9 @@ im_menu_get_property (GObject *object, case PROP_APPLICATION_LIST: g_value_set_object (value, priv->applist); break; + case PROP_ON_GREETER: + g_value_set_boolean (value, priv->on_greeter); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -79,6 +84,9 @@ im_menu_set_property (GObject *object, case PROP_APPLICATION_LIST: /* construct only */ priv->applist = g_value_dup_object (value); break; + case PROP_ON_GREETER: + priv->on_greeter = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -100,6 +108,12 @@ im_menu_class_init (ImMenuClass *class) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_ON_GREETER, + g_param_spec_boolean ("on-greeter", "", "", + FALSE, + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } static void @@ -110,6 +124,7 @@ im_menu_init (ImMenu *menu) priv->toplevel_menu = g_menu_new (); priv->menu = g_menu_new (); + priv->on_greeter = FALSE; root = g_menu_item_new (NULL, "indicator.messages"); g_menu_item_set_attribute (root, "x-canonical-type", "s", "com.canonical.indicator.root"); -- cgit v1.2.3 From 8513894ecfa89da5e919b8c4cc2174fcae49c599 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:50:09 -0500 Subject: A class wrapper for all the accounts service brewhaha --- src/Makefile.am | 2 ++ src/accounts-service.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/accounts-service.h | 32 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 src/accounts-service.c create mode 100644 src/accounts-service.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index bc674c2..184e9b2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,8 @@ pkglibexec_PROGRAMS = indicator-messages-service indicator_messages_service_SOURCES = \ messages-service.c \ + accounts-service.c \ + accounts-service.h \ dbus-data.h \ gactionmuxer.c \ gactionmuxer.h \ diff --git a/src/accounts-service.c b/src/accounts-service.c new file mode 100644 index 0000000..15cc208 --- /dev/null +++ b/src/accounts-service.c @@ -0,0 +1,56 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "accounts-service.h" + +typedef struct _AccountsServicePrivate AccountsServicePrivate; + +struct _AccountsServicePrivate { + int dummy; +}; + +#define ACCOUNTS_SERVICE_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), ACCOUNTS_SERVICE_TYPE, AccountsServicePrivate)) + +static void accounts_service_class_init (AccountsServiceClass *klass); +static void accounts_service_init (AccountsService *self); +static void accounts_service_dispose (GObject *object); +static void accounts_service_finalize (GObject *object); + +G_DEFINE_TYPE (AccountsService, accounts_service, G_TYPE_OBJECT); + +static void +accounts_service_class_init (AccountsServiceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (AccountsServicePrivate)); + + object_class->dispose = accounts_service_dispose; + object_class->finalize = accounts_service_finalize; +} + +static void +accounts_service_init (AccountsService *self) +{ +} + +static void +accounts_service_dispose (GObject *object) +{ + G_OBJECT_CLASS (accounts_service_parent_class)->dispose (object); +} + +static void +accounts_service_finalize (GObject *object) +{ + G_OBJECT_CLASS (accounts_service_parent_class)->finalize (object); +} + +AccountsService * +accounts_service_ref_default (void) +{ + + return NULL; +} diff --git a/src/accounts-service.h b/src/accounts-service.h new file mode 100644 index 0000000..03c91fe --- /dev/null +++ b/src/accounts-service.h @@ -0,0 +1,32 @@ +#ifndef __ACCOUNTS_SERVICE_H__ +#define __ACCOUNTS_SERVICE_H__ + +#include +#include + +G_BEGIN_DECLS + +#define ACCOUNTS_SERVICE_TYPE (accounts_service_get_type ()) +#define ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ACCOUNTS_SERVICE_TYPE, AccountsService)) +#define ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ACCOUNTS_SERVICE_TYPE, AccountsServiceClass)) +#define IS_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ACCOUNTS_SERVICE_TYPE)) +#define IS_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ACCOUNTS_SERVICE_TYPE)) +#define ACCOUNTS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ACCOUNTS_SERVICE_TYPE, AccountsServiceClass)) + +typedef struct _AccountsService AccountsService; +typedef struct _AccountsServiceClass AccountsServiceClass; + +struct _AccountsServiceClass { + GObjectClass parent_class; +}; + +struct _AccountsService { + GObject parent; +}; + +GType accounts_service_get_type (void); +AccountsService * accounts_service_ref_default (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From 1e43bda7ecea6a658052ae3537acf50df2df60ab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:51:53 -0500 Subject: Copyright headers --- src/accounts-service.c | 19 +++++++++++++++++++ src/accounts-service.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'src') diff --git a/src/accounts-service.c b/src/accounts-service.c index 15cc208..34af4f8 100644 --- a/src/accounts-service.c +++ b/src/accounts-service.c @@ -1,3 +1,22 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Ted Gould + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/accounts-service.h b/src/accounts-service.h index 03c91fe..6298d9c 100644 --- a/src/accounts-service.h +++ b/src/accounts-service.h @@ -1,3 +1,22 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Ted Gould + */ + #ifndef __ACCOUNTS_SERVICE_H__ #define __ACCOUNTS_SERVICE_H__ -- cgit v1.2.3 From 3132098cf6e98cb6904d6e25df0267e5a524f22a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:54:32 -0500 Subject: Add API for showing data to users --- src/im-menu.c | 8 ++++++++ src/im-menu.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/im-menu.c b/src/im-menu.c index a56dacb..0f1e7ca 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -240,3 +240,11 @@ im_menu_insert_item_sorted (ImMenu *menu, g_menu_insert_item (priv->menu, position, item); } + +/* Whether the menu should show extra data on it. Depends on the greeter + status and user settings */ +gboolean +im_menu_show_data (ImMenu *menu) +{ + return TRUE; +} diff --git a/src/im-menu.h b/src/im-menu.h index f67abc8..b76d616 100644 --- a/src/im-menu.h +++ b/src/im-menu.h @@ -64,4 +64,6 @@ void im_menu_insert_item_sorted (ImMenu gint first, gint last); +gboolean im_menu_show_data (ImMenu *menu); + #endif -- cgit v1.2.3 From 20dc96cc27115c6b20740ee1044baf4521bb11b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 10:58:20 -0500 Subject: Check show data to whether we should put in the body, subtitle and actions --- src/im-phone-menu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c index 6e74954..58a23ff 100644 --- a/src/im-phone-menu.c +++ b/src/im-phone-menu.c @@ -180,10 +180,12 @@ im_phone_menu_add_message (ImPhoneMenu *menu, gint n_messages; gint pos; GVariant *serialized_app_icon; + gboolean show_data; g_return_if_fail (IM_IS_PHONE_MENU (menu)); g_return_if_fail (app_id); + show_data = im_menu_show_data(IM_MENU (menu)); action_name = g_strconcat (app_id, ".msg.", id, NULL); item = g_menu_item_new (title, NULL); @@ -191,8 +193,10 @@ im_phone_menu_add_message (ImPhoneMenu *menu, g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.messages.messageitem"); g_menu_item_set_attribute (item, "x-canonical-message-id", "s", id); - g_menu_item_set_attribute (item, "x-canonical-subtitle", "s", subtitle); - g_menu_item_set_attribute (item, "x-canonical-text", "s", body); + if (show_data) + g_menu_item_set_attribute (item, "x-canonical-subtitle", "s", subtitle); + if (show_data) + g_menu_item_set_attribute (item, "x-canonical-text", "s", body); g_menu_item_set_attribute (item, "x-canonical-time", "x", time); if (serialized_icon) @@ -204,7 +208,7 @@ im_phone_menu_add_message (ImPhoneMenu *menu, g_variant_unref (serialized_app_icon); } - if (actions) + if (actions && show_data) g_menu_item_set_attribute (item, "x-canonical-message-actions", "v", actions); n_messages = g_menu_model_get_n_items (G_MENU_MODEL (menu->message_section)); -- cgit v1.2.3 From 3b3e0d14f583c89f42ae69f372d8ac5be0691e96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 11:00:21 -0500 Subject: Simple, if we're on the greeter show it. If not, we don't --- src/im-menu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-menu.c b/src/im-menu.c index 0f1e7ca..36773c9 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -246,5 +246,11 @@ im_menu_insert_item_sorted (ImMenu *menu, gboolean im_menu_show_data (ImMenu *menu) { - return TRUE; + g_return_val_if_fail (IM_IS_MENU (menu), FALSE); + ImMenuPrivate *priv = im_menu_get_instance_private (IM_MENU (menu)); + + if (!priv->on_greeter) + return TRUE; + + return FALSE; } -- cgit v1.2.3 From 638d0ad9575f02e8101e864e8d2c8bfa2c85a84f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 11:13:26 -0500 Subject: Grab an AS reference --- src/im-menu.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/im-menu.c b/src/im-menu.c index 36773c9..e35f7c2 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -18,6 +18,7 @@ */ #include "im-menu.h" +#include "accounts-service.h" struct _ImMenuPrivate { @@ -25,6 +26,7 @@ struct _ImMenuPrivate GMenu *menu; ImApplicationList *applist; gboolean on_greeter; + AccountsService *as; }; G_DEFINE_TYPE_WITH_PRIVATE (ImMenu, im_menu, G_TYPE_OBJECT) @@ -45,6 +47,7 @@ im_menu_finalize (GObject *object) g_object_unref (priv->toplevel_menu); g_object_unref (priv->menu); g_object_unref (priv->applist); + g_object_unref (priv->as); G_OBJECT_CLASS (im_menu_parent_class)->finalize (object); } @@ -125,6 +128,7 @@ im_menu_init (ImMenu *menu) priv->toplevel_menu = g_menu_new (); priv->menu = g_menu_new (); priv->on_greeter = FALSE; + priv->as = accounts_service_ref_default(); root = g_menu_item_new (NULL, "indicator.messages"); g_menu_item_set_attribute (root, "x-canonical-type", "s", "com.canonical.indicator.root"); -- cgit v1.2.3 From 074949340958b1adccd4fd61fc5bfb338fc57781 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 11:18:57 -0500 Subject: Put into our namespace --- src/Makefile.am | 4 +-- src/accounts-service.c | 75 ----------------------------------------------- src/accounts-service.h | 51 -------------------------------- src/im-accounts-service.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++ src/im-accounts-service.h | 51 ++++++++++++++++++++++++++++++++ src/im-menu.c | 6 ++-- 6 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 src/accounts-service.c delete mode 100644 src/accounts-service.h create mode 100644 src/im-accounts-service.c create mode 100644 src/im-accounts-service.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 184e9b2..36e6a93 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,13 +5,13 @@ pkglibexec_PROGRAMS = indicator-messages-service indicator_messages_service_SOURCES = \ messages-service.c \ - accounts-service.c \ - accounts-service.h \ dbus-data.h \ gactionmuxer.c \ gactionmuxer.h \ gsettingsstrv.c \ gsettingsstrv.h \ + im-accounts-service.c \ + im-accounts-service.h \ im-menu.c \ im-menu.h \ im-phone-menu.c \ diff --git a/src/accounts-service.c b/src/accounts-service.c deleted file mode 100644 index 34af4f8..0000000 --- a/src/accounts-service.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2014 Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - * Authors: - * Ted Gould - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "accounts-service.h" - -typedef struct _AccountsServicePrivate AccountsServicePrivate; - -struct _AccountsServicePrivate { - int dummy; -}; - -#define ACCOUNTS_SERVICE_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), ACCOUNTS_SERVICE_TYPE, AccountsServicePrivate)) - -static void accounts_service_class_init (AccountsServiceClass *klass); -static void accounts_service_init (AccountsService *self); -static void accounts_service_dispose (GObject *object); -static void accounts_service_finalize (GObject *object); - -G_DEFINE_TYPE (AccountsService, accounts_service, G_TYPE_OBJECT); - -static void -accounts_service_class_init (AccountsServiceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (AccountsServicePrivate)); - - object_class->dispose = accounts_service_dispose; - object_class->finalize = accounts_service_finalize; -} - -static void -accounts_service_init (AccountsService *self) -{ -} - -static void -accounts_service_dispose (GObject *object) -{ - G_OBJECT_CLASS (accounts_service_parent_class)->dispose (object); -} - -static void -accounts_service_finalize (GObject *object) -{ - G_OBJECT_CLASS (accounts_service_parent_class)->finalize (object); -} - -AccountsService * -accounts_service_ref_default (void) -{ - - return NULL; -} diff --git a/src/accounts-service.h b/src/accounts-service.h deleted file mode 100644 index 6298d9c..0000000 --- a/src/accounts-service.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2014 Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - * Authors: - * Ted Gould - */ - -#ifndef __ACCOUNTS_SERVICE_H__ -#define __ACCOUNTS_SERVICE_H__ - -#include -#include - -G_BEGIN_DECLS - -#define ACCOUNTS_SERVICE_TYPE (accounts_service_get_type ()) -#define ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ACCOUNTS_SERVICE_TYPE, AccountsService)) -#define ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ACCOUNTS_SERVICE_TYPE, AccountsServiceClass)) -#define IS_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ACCOUNTS_SERVICE_TYPE)) -#define IS_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ACCOUNTS_SERVICE_TYPE)) -#define ACCOUNTS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ACCOUNTS_SERVICE_TYPE, AccountsServiceClass)) - -typedef struct _AccountsService AccountsService; -typedef struct _AccountsServiceClass AccountsServiceClass; - -struct _AccountsServiceClass { - GObjectClass parent_class; -}; - -struct _AccountsService { - GObject parent; -}; - -GType accounts_service_get_type (void); -AccountsService * accounts_service_ref_default (void); - -G_END_DECLS - -#endif diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c new file mode 100644 index 0000000..f618524 --- /dev/null +++ b/src/im-accounts-service.c @@ -0,0 +1,75 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Ted Gould + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "im-accounts-service.h" + +typedef struct _ImAccountsServicePrivate ImAccountsServicePrivate; + +struct _ImAccountsServicePrivate { + int dummy; +}; + +#define IM_ACCOUNTS_SERVICE_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServicePrivate)) + +static void im_accounts_service_class_init (ImAccountsServiceClass *klass); +static void im_accounts_service_init (ImAccountsService *self); +static void im_accounts_service_dispose (GObject *object); +static void im_accounts_service_finalize (GObject *object); + +G_DEFINE_TYPE (ImAccountsService, im_accounts_service, G_TYPE_OBJECT); + +static void +im_accounts_service_class_init (ImAccountsServiceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (ImAccountsServicePrivate)); + + object_class->dispose = im_accounts_service_dispose; + object_class->finalize = im_accounts_service_finalize; +} + +static void +im_accounts_service_init (ImAccountsService *self) +{ +} + +static void +im_accounts_service_dispose (GObject *object) +{ + G_OBJECT_CLASS (im_accounts_service_parent_class)->dispose (object); +} + +static void +im_accounts_service_finalize (GObject *object) +{ + G_OBJECT_CLASS (im_accounts_service_parent_class)->finalize (object); +} + +ImAccountsService * +im_accounts_service_ref_default (void) +{ + + return NULL; +} diff --git a/src/im-accounts-service.h b/src/im-accounts-service.h new file mode 100644 index 0000000..4e7da59 --- /dev/null +++ b/src/im-accounts-service.h @@ -0,0 +1,51 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Ted Gould + */ + +#ifndef __IM_ACCOUNTS_SERVICE_H__ +#define __IM_ACCOUNTS_SERVICE_H__ + +#include +#include + +G_BEGIN_DECLS + +#define IM_ACCOUNTS_SERVICE_TYPE (im_accounts_service_get_type ()) +#define IM_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsService)) +#define IM_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServiceClass)) +#define IM_IS_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IM_ACCOUNTS_SERVICE_TYPE)) +#define IM_IS_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IM_ACCOUNTS_SERVICE_TYPE)) +#define IM_ACCOUNTS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServiceClass)) + +typedef struct _ImAccountsService ImAccountsService; +typedef struct _ImAccountsServiceClass ImAccountsServiceClass; + +struct _ImAccountsServiceClass { + GObjectClass parent_class; +}; + +struct _ImAccountsService { + GObject parent; +}; + +GType im_accounts_service_get_type (void); +ImAccountsService * im_accounts_service_ref_default (void); + +G_END_DECLS + +#endif diff --git a/src/im-menu.c b/src/im-menu.c index e35f7c2..bd45098 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -18,7 +18,7 @@ */ #include "im-menu.h" -#include "accounts-service.h" +#include "im-accounts-service.h" struct _ImMenuPrivate { @@ -26,7 +26,7 @@ struct _ImMenuPrivate GMenu *menu; ImApplicationList *applist; gboolean on_greeter; - AccountsService *as; + ImAccountsService *as; }; G_DEFINE_TYPE_WITH_PRIVATE (ImMenu, im_menu, G_TYPE_OBJECT) @@ -128,7 +128,7 @@ im_menu_init (ImMenu *menu) priv->toplevel_menu = g_menu_new (); priv->menu = g_menu_new (); priv->on_greeter = FALSE; - priv->as = accounts_service_ref_default(); + priv->as = im_accounts_service_ref_default(); root = g_menu_item_new (NULL, "indicator.messages"); g_menu_item_set_attribute (root, "x-canonical-type", "s", "com.canonical.indicator.root"); -- cgit v1.2.3 From 22fcf3da4c9549daa3ba109373805bfdd960d0df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 15:13:13 -0500 Subject: Connecting into accounts service --- src/im-accounts-service.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index f618524..6fc2922 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -21,12 +21,14 @@ #include "config.h" #endif +#include + #include "im-accounts-service.h" typedef struct _ImAccountsServicePrivate ImAccountsServicePrivate; struct _ImAccountsServicePrivate { - int dummy; + ActUserManager * user_manager; }; #define IM_ACCOUNTS_SERVICE_GET_PRIVATE(o) \ @@ -53,11 +55,18 @@ im_accounts_service_class_init (ImAccountsServiceClass *klass) static void im_accounts_service_init (ImAccountsService *self) { + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(self); + + priv->user_manager = act_user_manager_get_default(); } static void im_accounts_service_dispose (GObject *object) { + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(object); + + g_clear_object(&priv->user_manager); + G_OBJECT_CLASS (im_accounts_service_parent_class)->dispose (object); } -- cgit v1.2.3 From 2f9058621c5dfa8e3f7780731072e593898c3db8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 15:56:38 -0500 Subject: Setting up default referencing --- src/im-accounts-service.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 6fc2922..dc18d1b 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -76,9 +76,18 @@ im_accounts_service_finalize (GObject *object) G_OBJECT_CLASS (im_accounts_service_parent_class)->finalize (object); } +/* Not the most testable way to do this but, it is a less invasive one, and we'll + probably restructure this codebase soonish */ +/* Gets an account service wrapper reference, so then it can be free'd */ ImAccountsService * im_accounts_service_ref_default (void) { - - return NULL; + static ImAccountsService * as = NULL; + if (as == NULL) { + as = IM_ACCOUNTS_SERVICE(g_object_new(IM_ACCOUNTS_SERVICE_TYPE, NULL)); + g_object_add_weak_pointer(G_OBJECT(as), (gpointer *)&as); + return as; + } + + return g_object_ref(as); } -- cgit v1.2.3 From 25ab64f42a9ef31b65db8c7ff9f5780d8b2824e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 16:05:46 -0500 Subject: Get an accounts service instance in the application list --- src/im-application-list.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index b926e77..d3da85b 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -22,6 +22,7 @@ #include "indicator-messages-application.h" #include "gactionmuxer.h" #include "indicator-desktop-shortcuts.h" +#include "im-accounts-service.h" #include #include @@ -41,6 +42,8 @@ struct _ImApplicationList GSimpleAction * statusaction; GHashTable *app_status; + + ImAccountsService * as; }; G_DEFINE_TYPE (ImApplicationList, im_application_list, G_TYPE_OBJECT); @@ -449,6 +452,8 @@ im_application_list_dispose (GObject *object) g_clear_pointer (&list->applications, g_hash_table_unref); g_clear_object (&list->muxer); + g_clear_object (&list->as); + G_OBJECT_CLASS (im_application_list_parent_class)->dispose (object); } @@ -600,6 +605,8 @@ im_application_list_init (ImApplicationList *list) list->muxer = g_action_muxer_new (); g_action_muxer_insert (list->muxer, NULL, G_ACTION_GROUP (list->globalactions)); + list->as = im_accounts_service_ref_default(); + im_application_list_update_root_action (list); } -- cgit v1.2.3 From c50d1189d4df8e7d23a0a226d9bc09e1b2306204 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 16:26:28 -0500 Subject: Put in a function to handle setting the draw attention value --- src/im-accounts-service.c | 7 +++++++ src/im-accounts-service.h | 1 + src/im-application-list.c | 2 ++ 3 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index dc18d1b..f3b641f 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -91,3 +91,10 @@ im_accounts_service_ref_default (void) return g_object_ref(as); } + +void +im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention) +{ + + +} diff --git a/src/im-accounts-service.h b/src/im-accounts-service.h index 4e7da59..263103b 100644 --- a/src/im-accounts-service.h +++ b/src/im-accounts-service.h @@ -45,6 +45,7 @@ struct _ImAccountsService { GType im_accounts_service_get_type (void); ImAccountsService * im_accounts_service_ref_default (void); +void im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention); G_END_DECLS diff --git a/src/im-application-list.c b/src/im-application-list.c index d3da85b..001266e 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -173,9 +173,11 @@ im_application_list_update_root_action (ImApplicationList *list) if (g_hash_table_find (list->applications, application_draws_attention, NULL)) { base_icon_name = "indicator-messages-new-%s"; accessible_name = _("New Messages"); + im_accounts_service_set_draws_attention(list->as, TRUE); } else { base_icon_name = "indicator-messages-%s"; accessible_name = _("Messages"); + im_accounts_service_set_draws_attention(list->as, FALSE); } /* Include the IM state in the icon */ -- cgit v1.2.3 From 86aab4376be3791e1170118805ed44103a5fc2fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 16:29:08 -0500 Subject: A function to handle the showing on greeter part of this. --- src/im-accounts-service.c | 7 +++++++ src/im-accounts-service.h | 1 + src/im-menu.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index f3b641f..1926d9b 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -98,3 +98,10 @@ im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean d } + +gboolean +im_accounts_service_get_show_on_greeter (ImAccountsService * service) +{ + + return FALSE; +} diff --git a/src/im-accounts-service.h b/src/im-accounts-service.h index 263103b..d7611d8 100644 --- a/src/im-accounts-service.h +++ b/src/im-accounts-service.h @@ -46,6 +46,7 @@ struct _ImAccountsService { GType im_accounts_service_get_type (void); ImAccountsService * im_accounts_service_ref_default (void); void im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention); +gboolean im_accounts_service_get_show_on_greeter (ImAccountsService * service); G_END_DECLS diff --git a/src/im-menu.c b/src/im-menu.c index bd45098..0c39b97 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -256,5 +256,5 @@ im_menu_show_data (ImMenu *menu) if (!priv->on_greeter) return TRUE; - return FALSE; + return im_accounts_service_get_show_on_greeter(priv->as); } -- cgit v1.2.3 From b255d5ab480f889d96d9b4fc42ba3e0977975660 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Sep 2014 16:31:04 -0500 Subject: Setup the user manager signals --- src/im-accounts-service.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 1926d9b..1dcce7f 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -38,6 +38,8 @@ static void im_accounts_service_class_init (ImAccountsServiceClass *klass); static void im_accounts_service_init (ImAccountsService *self); static void im_accounts_service_dispose (GObject *object); static void im_accounts_service_finalize (GObject *object); +static void user_changed (ActUserManager * manager, ActUser * user, gpointer user_data); +static void is_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data); G_DEFINE_TYPE (ImAccountsService, im_accounts_service, G_TYPE_OBJECT); @@ -58,6 +60,8 @@ im_accounts_service_init (ImAccountsService *self) ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(self); priv->user_manager = act_user_manager_get_default(); + g_signal_connect(priv->user_manager, "user-changed", G_CALLBACK(user_changed), self); + g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(is_loaded), self); } static void @@ -76,6 +80,32 @@ im_accounts_service_finalize (GObject *object) G_OBJECT_CLASS (im_accounts_service_parent_class)->finalize (object); } +/* Handles a User getting updated */ +static void +user_changed (ActUserManager * manager, ActUser * user, gpointer user_data) +{ + if (g_strcmp0(act_user_get_user_name(user), g_get_user_name()) != 0) { + return; + } + + g_debug("User Updated"); +} + +static void +is_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data) +{ + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); + ActUser * user = NULL; + + g_debug("Accounts Manager Loaded"); + + user = act_user_manager_get_user(priv->user_manager, g_get_user_name()); + if (user != NULL) { + user_changed(priv->user_manager, user, user_data); + g_object_unref(user); + } +} + /* Not the most testable way to do this but, it is a less invasive one, and we'll probably restructure this codebase soonish */ /* Gets an account service wrapper reference, so then it can be free'd */ -- cgit v1.2.3 From e44aeafe24ab18e07a23e8fc7f3cf53a7b1431f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Sep 2014 13:51:16 -0500 Subject: Setup and get our proxy --- src/im-accounts-service.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 1dcce7f..cea5866 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -29,6 +29,7 @@ typedef struct _ImAccountsServicePrivate ImAccountsServicePrivate; struct _ImAccountsServicePrivate { ActUserManager * user_manager; + GDBusProxy * touch_settings; }; #define IM_ACCOUNTS_SERVICE_GET_PRIVATE(o) \ @@ -40,6 +41,7 @@ static void im_accounts_service_dispose (GObject *object); static void im_accounts_service_finalize (GObject *object); static void user_changed (ActUserManager * manager, ActUser * user, gpointer user_data); static void is_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data); +static void security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data); G_DEFINE_TYPE (ImAccountsService, im_accounts_service, G_TYPE_OBJECT); @@ -88,7 +90,38 @@ user_changed (ActUserManager * manager, ActUser * user, gpointer user_data) return; } + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); g_debug("User Updated"); + + /* Clear old proxies */ + g_clear_object(&priv->touch_settings); + + /* Start getting a new proxy */ + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.freedesktop.Accounts", + act_user_get_object_path(user), + "com.ubuntu.touch.AccountsService.SecurityPrivacy", + NULL, + security_privacy_ready, + user_data); +} + +/* Respond to the async of setting up the proxy. Mostly we get it or we error. */ +static void +security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data) +{ + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); + GError * error = NULL; + + priv->touch_settings = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (error != NULL) { + g_warning("Unable to get a proxy on accounts service for touch settings"); + g_error_free(error); + return; + } } static void -- cgit v1.2.3 From 47f188360bd406d084935be0de209d69a7cec9e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Sep 2014 14:35:51 -0500 Subject: Get the value on whether we should show on the welcome screen --- src/im-accounts-service.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index cea5866..c7d3083 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -165,6 +165,20 @@ im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean d gboolean im_accounts_service_get_show_on_greeter (ImAccountsService * service) { + g_return_val_if_fail(IM_IS_ACCOUNTS_SERVICE(service), FALSE); - return FALSE; + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(service); + + if (priv->touch_settings == NULL) { + return FALSE; + } + + GVariant * val = g_dbus_proxy_get_cached_property(priv->touch_settings, "MessagesWelcomeScreen"); + if (val == NULL) { + return FALSE; + } + + gboolean retval = g_variant_get_boolean(val); + g_variant_unref(val); + return retval; } -- cgit v1.2.3 From 29fd0490ab7f2a03b87b34247743fa03e3278faf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Sep 2014 14:45:14 -0500 Subject: Fleshing out drawing attention --- src/im-accounts-service.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index c7d3083..a993e6e 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -155,13 +155,33 @@ im_accounts_service_ref_default (void) return g_object_ref(as); } +/* The draws attention setting is very legacy right now, we've patched and not changed + things much. We're gonna do better in the future, this function abstracts out the ugly */ void im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention) { + g_return_if_fail(IM_IS_ACCOUNTS_SERVICE(service)); + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(service); + if (priv->touch_settings == NULL) { + return; + } + g_dbus_connection_call(g_dbus_proxy_get_connection(priv->touch_settings), + g_dbus_proxy_get_name(priv->touch_settings), + g_dbus_proxy_get_object_path(priv->touch_settings), + "org.freedesktop.Accounts.User", + "SetXHasMessages", + g_variant_new("(b)", draws_attention), + NULL, /* reply */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancellable */ + NULL, NULL); /* cb */ } +/* Looks at the property that is set by settings. We default to off in any case + that we can or we don't know what the state is. */ gboolean im_accounts_service_get_show_on_greeter (ImAccountsService * service) { -- cgit v1.2.3 From 6fd3e934029a47e7ec8818dc21b7f127863eda56 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Oct 2014 21:09:43 -0500 Subject: Check for loading of a cached instance --- src/im-accounts-service.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index a993e6e..40c269c 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -64,6 +64,12 @@ im_accounts_service_init (ImAccountsService *self) priv->user_manager = act_user_manager_get_default(); g_signal_connect(priv->user_manager, "user-changed", G_CALLBACK(user_changed), self); g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(is_loaded), self); + + gboolean isLoaded = FALSE; + g_object_get(G_OBJECT(priv->user_manager), "is-loaded", &isLoaded, NULL); + if (isLoaded) { + is_loaded(priv->user_manager, NULL, NULL); + } } static void -- cgit v1.2.3 From 76bf922cf4a630cdad5dc0b3948337bb1ea4efeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Oct 2014 21:20:44 -0500 Subject: Ensure we can cancel getting the proxy and that if we do we can handle it without getting the private section --- src/im-accounts-service.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 40c269c..dc80826 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -30,6 +30,7 @@ typedef struct _ImAccountsServicePrivate ImAccountsServicePrivate; struct _ImAccountsServicePrivate { ActUserManager * user_manager; GDBusProxy * touch_settings; + GCancellable * cancel; }; #define IM_ACCOUNTS_SERVICE_GET_PRIVATE(o) \ @@ -61,6 +62,8 @@ im_accounts_service_init (ImAccountsService *self) { ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(self); + priv->cancel = g_cancellable_new(); + priv->user_manager = act_user_manager_get_default(); g_signal_connect(priv->user_manager, "user-changed", G_CALLBACK(user_changed), self); g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(is_loaded), self); @@ -77,6 +80,11 @@ im_accounts_service_dispose (GObject *object) { ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(object); + if (priv->cancel != NULL) { + g_cancellable_cancel(priv->cancel); + g_clear_object(&priv->cancel); + } + g_clear_object(&priv->user_manager); G_OBJECT_CLASS (im_accounts_service_parent_class)->dispose (object); @@ -109,7 +117,7 @@ user_changed (ActUserManager * manager, ActUser * user, gpointer user_data) "org.freedesktop.Accounts", act_user_get_object_path(user), "com.ubuntu.touch.AccountsService.SecurityPrivacy", - NULL, + priv->cancel, security_privacy_ready, user_data); } @@ -118,16 +126,17 @@ user_changed (ActUserManager * manager, ActUser * user, gpointer user_data) static void security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data) { - ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); GError * error = NULL; - - priv->touch_settings = g_dbus_proxy_new_for_bus_finish(res, &error); + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); if (error != NULL) { - g_warning("Unable to get a proxy on accounts service for touch settings"); + g_warning("Unable to get a proxy on accounts service for touch settings: %s", error->message); g_error_free(error); return; } + + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); + priv->touch_settings = proxy; } static void @@ -182,7 +191,7 @@ im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean d NULL, /* reply */ G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ - NULL, /* cancellable */ + priv->cancel, /* cancellable */ NULL, NULL); /* cb */ } -- cgit v1.2.3 From b0c1cc8b72ceaf9ddfca8481f2c72a11dfa3c26a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Oct 2014 21:22:33 -0500 Subject: Ensure the proxy is still cleared so we don't leak them --- src/im-accounts-service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index dc80826..3f9e5f8 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -136,6 +136,8 @@ security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data) } ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); + /* Ensure we didn't get a proxy while we weren't looking */ + g_clear_object(&priv->touch_settings); priv->touch_settings = proxy; } -- cgit v1.2.3 From 5c7e4c72ea133d8c2aefc4edadf0601ab097f4a9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Oct 2014 21:23:31 -0500 Subject: Name change --- src/im-accounts-service.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 3f9e5f8..b7ab15d 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -41,7 +41,7 @@ static void im_accounts_service_init (ImAccountsService *self); static void im_accounts_service_dispose (GObject *object); static void im_accounts_service_finalize (GObject *object); static void user_changed (ActUserManager * manager, ActUser * user, gpointer user_data); -static void is_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data); +static void on_user_manager_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data); static void security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data); G_DEFINE_TYPE (ImAccountsService, im_accounts_service, G_TYPE_OBJECT); @@ -66,12 +66,12 @@ im_accounts_service_init (ImAccountsService *self) priv->user_manager = act_user_manager_get_default(); g_signal_connect(priv->user_manager, "user-changed", G_CALLBACK(user_changed), self); - g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(is_loaded), self); + g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(on_user_manager_loaded), self); gboolean isLoaded = FALSE; g_object_get(G_OBJECT(priv->user_manager), "is-loaded", &isLoaded, NULL); if (isLoaded) { - is_loaded(priv->user_manager, NULL, NULL); + on_user_manager_loaded(priv->user_manager, NULL, NULL); } } @@ -141,8 +141,10 @@ security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data) priv->touch_settings = proxy; } +/* When the user manager is loaded see if we have a user already loaded + along with. */ static void -is_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data) +on_user_manager_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data) { ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); ActUser * user = NULL; -- cgit v1.2.3