Merge lp:~ted/indicator-messages/lp1358340-greeter-data-filter into lp:indicator-messages/15.04
- lp1358340-greeter-data-filter
- Merge into trunk.15.04
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||
Approved revision: | 445 | ||||
Merged at revision: | 430 | ||||
Proposed branch: | lp:~ted/indicator-messages/lp1358340-greeter-data-filter | ||||
Merge into: | lp:indicator-messages/15.04 | ||||
Diff against target: |
624 lines (+373/-8) 13 files modified
configure.ac (+2/-1) data/com.canonical.indicator.messages (+4/-1) debian/control (+1/-0) src/Makefile.am (+2/-0) src/im-accounts-service.c (+223/-0) src/im-accounts-service.h (+53/-0) src/im-application-list.c (+9/-0) src/im-menu.c (+33/-0) src/im-menu.h (+2/-0) src/im-phone-menu.c (+9/-4) src/im-phone-menu.h (+2/-1) src/messages-service.c (+3/-1) tests/manual (+30/-0) |
||||
To merge this branch: | bzr merge lp:~ted/indicator-messages/lp1358340-greeter-data-filter | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+240467@code.launchpad.net |
This proposal supersedes a proposal from 2014-09-22.
Commit message
Add filtering for lock screen.
Description of the change
Provides basic support for setting of the show messages button on the phone disabling how much of the messages are shown on the greeter.
Ted Gould (ted) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:438
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal | # |
The phone-menu im*menu.[ch] changes look fine, but I had a couple of issues with the new im-accounts-service code, inline below.
Ted Gould (ted) wrote : Posted in a previous version of this proposal | # |
Fixed. Only difference is that I left the g_clear_object() in both places because we're using it as a sentinel in checking the value, so I'd like to to be clear when we're getting a new one and we think the value will be changing still, even in the rapid fire case.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:442
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:443
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal | # |
Ted, thanks for the fixes!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:445
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) : | # |
Preview Diff
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2014-02-20 05:12:07 +0000 |
3 | +++ configure.ac 2014-11-03 16:11:06 +0000 |
4 | @@ -43,7 +43,8 @@ |
5 | INTROSPECTION_REQUIRED_VERSION=1.32.0 |
6 | |
7 | PKG_CHECK_MODULES(APPLET, gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION |
8 | - glib-2.0 >= $GLIB_REQUIRED_VERSION) |
9 | + glib-2.0 >= $GLIB_REQUIRED_VERSION |
10 | + accountsservice) |
11 | |
12 | PKG_CHECK_MODULES(GIO, gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION) |
13 | |
14 | |
15 | === modified file 'data/com.canonical.indicator.messages' |
16 | --- data/com.canonical.indicator.messages 2014-10-06 16:53:34 +0000 |
17 | +++ data/com.canonical.indicator.messages 2014-11-03 16:11:06 +0000 |
18 | @@ -6,11 +6,14 @@ |
19 | [desktop] |
20 | ObjectPath=/com/canonical/indicator/messages/desktop |
21 | |
22 | +[desktop_greeter] |
23 | +ObjectPath=/com/canonical/indicator/messages/desktop_greeter |
24 | + |
25 | [phone] |
26 | ObjectPath=/com/canonical/indicator/messages/phone |
27 | Position=100 |
28 | |
29 | [phone_greeter] |
30 | -ObjectPath=/com/canonical/indicator/messages/phone |
31 | +ObjectPath=/com/canonical/indicator/messages/phone_greeter |
32 | Position=100 |
33 | |
34 | |
35 | === modified file 'debian/control' |
36 | --- debian/control 2014-09-02 11:56:00 +0000 |
37 | +++ debian/control 2014-11-03 16:11:06 +0000 |
38 | @@ -10,6 +10,7 @@ |
39 | gobject-introspection (>= 0.9.12-4~), |
40 | gtk-doc-tools, |
41 | intltool, |
42 | + libaccountsservice-dev, |
43 | libgirepository1.0-dev (>= 0.9.12), |
44 | libgtest-dev, |
45 | python3-dbusmock, |
46 | |
47 | === modified file 'src/Makefile.am' |
48 | --- src/Makefile.am 2013-09-09 14:32:02 +0000 |
49 | +++ src/Makefile.am 2014-11-03 16:11:06 +0000 |
50 | @@ -10,6 +10,8 @@ |
51 | gactionmuxer.h \ |
52 | gsettingsstrv.c \ |
53 | gsettingsstrv.h \ |
54 | + im-accounts-service.c \ |
55 | + im-accounts-service.h \ |
56 | im-menu.c \ |
57 | im-menu.h \ |
58 | im-phone-menu.c \ |
59 | |
60 | === added file 'src/im-accounts-service.c' |
61 | --- src/im-accounts-service.c 1970-01-01 00:00:00 +0000 |
62 | +++ src/im-accounts-service.c 2014-11-03 16:11:06 +0000 |
63 | @@ -0,0 +1,223 @@ |
64 | +/* |
65 | + * Copyright © 2014 Canonical Ltd. |
66 | + * |
67 | + * This program is free software: you can redistribute it and/or modify it |
68 | + * under the terms of the GNU General Public License version 3, as published |
69 | + * by the Free Software Foundation. |
70 | + * |
71 | + * This program is distributed in the hope that it will be useful, but |
72 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
73 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
74 | + * PURPOSE. See the GNU General Public License for more details. |
75 | + * |
76 | + * You should have received a copy of the GNU General Public License along |
77 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
78 | + * |
79 | + * Authors: |
80 | + * Ted Gould <ted@canonical.com> |
81 | + */ |
82 | + |
83 | +#ifdef HAVE_CONFIG_H |
84 | +#include "config.h" |
85 | +#endif |
86 | + |
87 | +#include <act/act.h> |
88 | + |
89 | +#include "im-accounts-service.h" |
90 | + |
91 | +typedef struct _ImAccountsServicePrivate ImAccountsServicePrivate; |
92 | + |
93 | +struct _ImAccountsServicePrivate { |
94 | + ActUserManager * user_manager; |
95 | + GDBusProxy * touch_settings; |
96 | + GCancellable * cancel; |
97 | +}; |
98 | + |
99 | +#define IM_ACCOUNTS_SERVICE_GET_PRIVATE(o) \ |
100 | +(G_TYPE_INSTANCE_GET_PRIVATE ((o), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServicePrivate)) |
101 | + |
102 | +static void im_accounts_service_class_init (ImAccountsServiceClass *klass); |
103 | +static void im_accounts_service_init (ImAccountsService *self); |
104 | +static void im_accounts_service_dispose (GObject *object); |
105 | +static void im_accounts_service_finalize (GObject *object); |
106 | +static void user_changed (ActUserManager * manager, ActUser * user, gpointer user_data); |
107 | +static void on_user_manager_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data); |
108 | +static void security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data); |
109 | + |
110 | +G_DEFINE_TYPE (ImAccountsService, im_accounts_service, G_TYPE_OBJECT); |
111 | + |
112 | +static void |
113 | +im_accounts_service_class_init (ImAccountsServiceClass *klass) |
114 | +{ |
115 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
116 | + |
117 | + g_type_class_add_private (klass, sizeof (ImAccountsServicePrivate)); |
118 | + |
119 | + object_class->dispose = im_accounts_service_dispose; |
120 | + object_class->finalize = im_accounts_service_finalize; |
121 | +} |
122 | + |
123 | +static void |
124 | +im_accounts_service_init (ImAccountsService *self) |
125 | +{ |
126 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(self); |
127 | + |
128 | + priv->cancel = g_cancellable_new(); |
129 | + |
130 | + priv->user_manager = act_user_manager_get_default(); |
131 | + g_signal_connect(priv->user_manager, "user-changed", G_CALLBACK(user_changed), self); |
132 | + g_signal_connect(priv->user_manager, "notify::is-loaded", G_CALLBACK(on_user_manager_loaded), self); |
133 | + |
134 | + gboolean isLoaded = FALSE; |
135 | + g_object_get(G_OBJECT(priv->user_manager), "is-loaded", &isLoaded, NULL); |
136 | + if (isLoaded) { |
137 | + on_user_manager_loaded(priv->user_manager, NULL, NULL); |
138 | + } |
139 | +} |
140 | + |
141 | +static void |
142 | +im_accounts_service_dispose (GObject *object) |
143 | +{ |
144 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(object); |
145 | + |
146 | + if (priv->cancel != NULL) { |
147 | + g_cancellable_cancel(priv->cancel); |
148 | + g_clear_object(&priv->cancel); |
149 | + } |
150 | + |
151 | + g_clear_object(&priv->user_manager); |
152 | + |
153 | + G_OBJECT_CLASS (im_accounts_service_parent_class)->dispose (object); |
154 | +} |
155 | + |
156 | +static void |
157 | +im_accounts_service_finalize (GObject *object) |
158 | +{ |
159 | + G_OBJECT_CLASS (im_accounts_service_parent_class)->finalize (object); |
160 | +} |
161 | + |
162 | +/* Handles a User getting updated */ |
163 | +static void |
164 | +user_changed (ActUserManager * manager, ActUser * user, gpointer user_data) |
165 | +{ |
166 | + if (g_strcmp0(act_user_get_user_name(user), g_get_user_name()) != 0) { |
167 | + return; |
168 | + } |
169 | + |
170 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); |
171 | + g_debug("User Updated"); |
172 | + |
173 | + /* Clear old proxies */ |
174 | + g_clear_object(&priv->touch_settings); |
175 | + |
176 | + /* Start getting a new proxy */ |
177 | + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, |
178 | + G_DBUS_PROXY_FLAGS_NONE, |
179 | + NULL, |
180 | + "org.freedesktop.Accounts", |
181 | + act_user_get_object_path(user), |
182 | + "com.ubuntu.touch.AccountsService.SecurityPrivacy", |
183 | + priv->cancel, |
184 | + security_privacy_ready, |
185 | + user_data); |
186 | +} |
187 | + |
188 | +/* Respond to the async of setting up the proxy. Mostly we get it or we error. */ |
189 | +static void |
190 | +security_privacy_ready (GObject * obj, GAsyncResult * res, gpointer user_data) |
191 | +{ |
192 | + GError * error = NULL; |
193 | + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); |
194 | + |
195 | + if (error != NULL) { |
196 | + g_warning("Unable to get a proxy on accounts service for touch settings: %s", error->message); |
197 | + g_error_free(error); |
198 | + return; |
199 | + } |
200 | + |
201 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); |
202 | + /* Ensure we didn't get a proxy while we weren't looking */ |
203 | + g_clear_object(&priv->touch_settings); |
204 | + priv->touch_settings = proxy; |
205 | +} |
206 | + |
207 | +/* When the user manager is loaded see if we have a user already loaded |
208 | + along with. */ |
209 | +static void |
210 | +on_user_manager_loaded (ActUserManager * manager, GParamSpec * pspect, gpointer user_data) |
211 | +{ |
212 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(user_data); |
213 | + ActUser * user = NULL; |
214 | + |
215 | + g_debug("Accounts Manager Loaded"); |
216 | + |
217 | + user = act_user_manager_get_user(priv->user_manager, g_get_user_name()); |
218 | + if (user != NULL) { |
219 | + user_changed(priv->user_manager, user, user_data); |
220 | + g_object_unref(user); |
221 | + } |
222 | +} |
223 | + |
224 | +/* Not the most testable way to do this but, it is a less invasive one, and we'll |
225 | + probably restructure this codebase soonish */ |
226 | +/* Gets an account service wrapper reference, so then it can be free'd */ |
227 | +ImAccountsService * |
228 | +im_accounts_service_ref_default (void) |
229 | +{ |
230 | + static ImAccountsService * as = NULL; |
231 | + if (as == NULL) { |
232 | + as = IM_ACCOUNTS_SERVICE(g_object_new(IM_ACCOUNTS_SERVICE_TYPE, NULL)); |
233 | + g_object_add_weak_pointer(G_OBJECT(as), (gpointer *)&as); |
234 | + return as; |
235 | + } |
236 | + |
237 | + return g_object_ref(as); |
238 | +} |
239 | + |
240 | +/* The draws attention setting is very legacy right now, we've patched and not changed |
241 | + things much. We're gonna do better in the future, this function abstracts out the ugly */ |
242 | +void |
243 | +im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention) |
244 | +{ |
245 | + g_return_if_fail(IM_IS_ACCOUNTS_SERVICE(service)); |
246 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(service); |
247 | + |
248 | + if (priv->touch_settings == NULL) { |
249 | + return; |
250 | + } |
251 | + |
252 | + g_dbus_connection_call(g_dbus_proxy_get_connection(priv->touch_settings), |
253 | + g_dbus_proxy_get_name(priv->touch_settings), |
254 | + g_dbus_proxy_get_object_path(priv->touch_settings), |
255 | + "org.freedesktop.Accounts.User", |
256 | + "SetXHasMessages", |
257 | + g_variant_new("(b)", draws_attention), |
258 | + NULL, /* reply */ |
259 | + G_DBUS_CALL_FLAGS_NONE, |
260 | + -1, /* timeout */ |
261 | + priv->cancel, /* cancellable */ |
262 | + NULL, NULL); /* cb */ |
263 | +} |
264 | + |
265 | +/* Looks at the property that is set by settings. We default to off in any case |
266 | + that we can or we don't know what the state is. */ |
267 | +gboolean |
268 | +im_accounts_service_get_show_on_greeter (ImAccountsService * service) |
269 | +{ |
270 | + g_return_val_if_fail(IM_IS_ACCOUNTS_SERVICE(service), FALSE); |
271 | + |
272 | + ImAccountsServicePrivate * priv = IM_ACCOUNTS_SERVICE_GET_PRIVATE(service); |
273 | + |
274 | + if (priv->touch_settings == NULL) { |
275 | + return FALSE; |
276 | + } |
277 | + |
278 | + GVariant * val = g_dbus_proxy_get_cached_property(priv->touch_settings, "MessagesWelcomeScreen"); |
279 | + if (val == NULL) { |
280 | + return FALSE; |
281 | + } |
282 | + |
283 | + gboolean retval = g_variant_get_boolean(val); |
284 | + g_variant_unref(val); |
285 | + return retval; |
286 | +} |
287 | |
288 | === added file 'src/im-accounts-service.h' |
289 | --- src/im-accounts-service.h 1970-01-01 00:00:00 +0000 |
290 | +++ src/im-accounts-service.h 2014-11-03 16:11:06 +0000 |
291 | @@ -0,0 +1,53 @@ |
292 | +/* |
293 | + * Copyright © 2014 Canonical Ltd. |
294 | + * |
295 | + * This program is free software: you can redistribute it and/or modify it |
296 | + * under the terms of the GNU General Public License version 3, as published |
297 | + * by the Free Software Foundation. |
298 | + * |
299 | + * This program is distributed in the hope that it will be useful, but |
300 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
301 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
302 | + * PURPOSE. See the GNU General Public License for more details. |
303 | + * |
304 | + * You should have received a copy of the GNU General Public License along |
305 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
306 | + * |
307 | + * Authors: |
308 | + * Ted Gould <ted@canonical.com> |
309 | + */ |
310 | + |
311 | +#ifndef __IM_ACCOUNTS_SERVICE_H__ |
312 | +#define __IM_ACCOUNTS_SERVICE_H__ |
313 | + |
314 | +#include <glib.h> |
315 | +#include <glib-object.h> |
316 | + |
317 | +G_BEGIN_DECLS |
318 | + |
319 | +#define IM_ACCOUNTS_SERVICE_TYPE (im_accounts_service_get_type ()) |
320 | +#define IM_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsService)) |
321 | +#define IM_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServiceClass)) |
322 | +#define IM_IS_ACCOUNTS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IM_ACCOUNTS_SERVICE_TYPE)) |
323 | +#define IM_IS_ACCOUNTS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IM_ACCOUNTS_SERVICE_TYPE)) |
324 | +#define IM_ACCOUNTS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IM_ACCOUNTS_SERVICE_TYPE, ImAccountsServiceClass)) |
325 | + |
326 | +typedef struct _ImAccountsService ImAccountsService; |
327 | +typedef struct _ImAccountsServiceClass ImAccountsServiceClass; |
328 | + |
329 | +struct _ImAccountsServiceClass { |
330 | + GObjectClass parent_class; |
331 | +}; |
332 | + |
333 | +struct _ImAccountsService { |
334 | + GObject parent; |
335 | +}; |
336 | + |
337 | +GType im_accounts_service_get_type (void); |
338 | +ImAccountsService * im_accounts_service_ref_default (void); |
339 | +void im_accounts_service_set_draws_attention (ImAccountsService * service, gboolean draws_attention); |
340 | +gboolean im_accounts_service_get_show_on_greeter (ImAccountsService * service); |
341 | + |
342 | +G_END_DECLS |
343 | + |
344 | +#endif |
345 | |
346 | === modified file 'src/im-application-list.c' |
347 | --- src/im-application-list.c 2014-10-03 19:53:30 +0000 |
348 | +++ src/im-application-list.c 2014-11-03 16:11:06 +0000 |
349 | @@ -22,6 +22,7 @@ |
350 | #include "indicator-messages-application.h" |
351 | #include "gactionmuxer.h" |
352 | #include "indicator-desktop-shortcuts.h" |
353 | +#include "im-accounts-service.h" |
354 | |
355 | #include <gio/gdesktopappinfo.h> |
356 | #include <string.h> |
357 | @@ -41,6 +42,8 @@ |
358 | GSimpleAction * statusaction; |
359 | |
360 | GHashTable *app_status; |
361 | + |
362 | + ImAccountsService * as; |
363 | }; |
364 | |
365 | G_DEFINE_TYPE (ImApplicationList, im_application_list, G_TYPE_OBJECT); |
366 | @@ -170,9 +173,11 @@ |
367 | if (g_hash_table_find (list->applications, application_draws_attention, NULL)) { |
368 | base_icon_name = "indicator-messages-new-%s"; |
369 | accessible_name = _("New Messages"); |
370 | + im_accounts_service_set_draws_attention(list->as, TRUE); |
371 | } else { |
372 | base_icon_name = "indicator-messages-%s"; |
373 | accessible_name = _("Messages"); |
374 | + im_accounts_service_set_draws_attention(list->as, FALSE); |
375 | } |
376 | |
377 | /* Include the IM state in the icon */ |
378 | @@ -449,6 +454,8 @@ |
379 | g_clear_pointer (&list->applications, g_hash_table_unref); |
380 | g_clear_object (&list->muxer); |
381 | |
382 | + g_clear_object (&list->as); |
383 | + |
384 | G_OBJECT_CLASS (im_application_list_parent_class)->dispose (object); |
385 | } |
386 | |
387 | @@ -600,6 +607,8 @@ |
388 | list->muxer = g_action_muxer_new (); |
389 | g_action_muxer_insert (list->muxer, NULL, G_ACTION_GROUP (list->globalactions)); |
390 | |
391 | + list->as = im_accounts_service_ref_default(); |
392 | + |
393 | im_application_list_update_root_action (list); |
394 | } |
395 | |
396 | |
397 | === modified file 'src/im-menu.c' |
398 | --- src/im-menu.c 2014-04-07 13:22:06 +0000 |
399 | +++ src/im-menu.c 2014-11-03 16:11:06 +0000 |
400 | @@ -18,12 +18,15 @@ |
401 | */ |
402 | |
403 | #include "im-menu.h" |
404 | +#include "im-accounts-service.h" |
405 | |
406 | struct _ImMenuPrivate |
407 | { |
408 | GMenu *toplevel_menu; |
409 | GMenu *menu; |
410 | ImApplicationList *applist; |
411 | + gboolean on_greeter; |
412 | + ImAccountsService *as; |
413 | }; |
414 | |
415 | G_DEFINE_TYPE_WITH_PRIVATE (ImMenu, im_menu, G_TYPE_OBJECT) |
416 | @@ -32,6 +35,7 @@ |
417 | { |
418 | PROP_0, |
419 | PROP_APPLICATION_LIST, |
420 | + PROP_ON_GREETER, |
421 | NUM_PROPERTIES |
422 | }; |
423 | |
424 | @@ -43,6 +47,7 @@ |
425 | g_object_unref (priv->toplevel_menu); |
426 | g_object_unref (priv->menu); |
427 | g_object_unref (priv->applist); |
428 | + g_object_unref (priv->as); |
429 | |
430 | G_OBJECT_CLASS (im_menu_parent_class)->finalize (object); |
431 | } |
432 | @@ -60,6 +65,9 @@ |
433 | case PROP_APPLICATION_LIST: |
434 | g_value_set_object (value, priv->applist); |
435 | break; |
436 | + case PROP_ON_GREETER: |
437 | + g_value_set_boolean (value, priv->on_greeter); |
438 | + break; |
439 | |
440 | default: |
441 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
442 | @@ -79,6 +87,9 @@ |
443 | case PROP_APPLICATION_LIST: /* construct only */ |
444 | priv->applist = g_value_dup_object (value); |
445 | break; |
446 | + case PROP_ON_GREETER: |
447 | + priv->on_greeter = g_value_get_boolean (value); |
448 | + break; |
449 | |
450 | default: |
451 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
452 | @@ -100,6 +111,12 @@ |
453 | G_PARAM_CONSTRUCT_ONLY | |
454 | G_PARAM_READWRITE | |
455 | G_PARAM_STATIC_STRINGS)); |
456 | + g_object_class_install_property (object_class, PROP_ON_GREETER, |
457 | + g_param_spec_boolean ("on-greeter", "", "", |
458 | + FALSE, |
459 | + G_PARAM_CONSTRUCT_ONLY | |
460 | + G_PARAM_READWRITE | |
461 | + G_PARAM_STATIC_STRINGS)); |
462 | } |
463 | |
464 | static void |
465 | @@ -110,6 +127,8 @@ |
466 | |
467 | priv->toplevel_menu = g_menu_new (); |
468 | priv->menu = g_menu_new (); |
469 | + priv->on_greeter = FALSE; |
470 | + priv->as = im_accounts_service_ref_default(); |
471 | |
472 | root = g_menu_item_new (NULL, "indicator.messages"); |
473 | g_menu_item_set_attribute (root, "x-canonical-type", "s", "com.canonical.indicator.root"); |
474 | @@ -225,3 +244,17 @@ |
475 | |
476 | g_menu_insert_item (priv->menu, position, item); |
477 | } |
478 | + |
479 | +/* Whether the menu should show extra data on it. Depends on the greeter |
480 | + status and user settings */ |
481 | +gboolean |
482 | +im_menu_show_data (ImMenu *menu) |
483 | +{ |
484 | + g_return_val_if_fail (IM_IS_MENU (menu), FALSE); |
485 | + ImMenuPrivate *priv = im_menu_get_instance_private (IM_MENU (menu)); |
486 | + |
487 | + if (!priv->on_greeter) |
488 | + return TRUE; |
489 | + |
490 | + return im_accounts_service_get_show_on_greeter(priv->as); |
491 | +} |
492 | |
493 | === modified file 'src/im-menu.h' |
494 | --- src/im-menu.h 2014-04-07 13:22:06 +0000 |
495 | +++ src/im-menu.h 2014-11-03 16:11:06 +0000 |
496 | @@ -64,4 +64,6 @@ |
497 | gint first, |
498 | gint last); |
499 | |
500 | +gboolean im_menu_show_data (ImMenu *menu); |
501 | + |
502 | #endif |
503 | |
504 | === modified file 'src/im-phone-menu.c' |
505 | --- src/im-phone-menu.c 2013-12-13 15:09:20 +0000 |
506 | +++ src/im-phone-menu.c 2014-11-03 16:11:06 +0000 |
507 | @@ -142,12 +142,13 @@ |
508 | } |
509 | |
510 | ImPhoneMenu * |
511 | -im_phone_menu_new (ImApplicationList *applist) |
512 | +im_phone_menu_new (ImApplicationList *applist, gboolean greeter) |
513 | { |
514 | g_return_val_if_fail (IM_IS_APPLICATION_LIST (applist), NULL); |
515 | |
516 | return g_object_new (IM_TYPE_PHONE_MENU, |
517 | "application-list", applist, |
518 | + "on-greeter", greeter, |
519 | NULL); |
520 | } |
521 | |
522 | @@ -179,10 +180,12 @@ |
523 | gint n_messages; |
524 | gint pos; |
525 | GVariant *serialized_app_icon; |
526 | + gboolean show_data; |
527 | |
528 | g_return_if_fail (IM_IS_PHONE_MENU (menu)); |
529 | g_return_if_fail (app_id); |
530 | |
531 | + show_data = im_menu_show_data(IM_MENU (menu)); |
532 | action_name = g_strconcat (app_id, ".msg.", id, NULL); |
533 | |
534 | item = g_menu_item_new (title, NULL); |
535 | @@ -190,8 +193,10 @@ |
536 | |
537 | g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.messages.messageitem"); |
538 | g_menu_item_set_attribute (item, "x-canonical-message-id", "s", id); |
539 | - g_menu_item_set_attribute (item, "x-canonical-subtitle", "s", subtitle); |
540 | - g_menu_item_set_attribute (item, "x-canonical-text", "s", body); |
541 | + if (show_data) |
542 | + g_menu_item_set_attribute (item, "x-canonical-subtitle", "s", subtitle); |
543 | + if (show_data) |
544 | + g_menu_item_set_attribute (item, "x-canonical-text", "s", body); |
545 | g_menu_item_set_attribute (item, "x-canonical-time", "x", time); |
546 | |
547 | if (serialized_icon) |
548 | @@ -203,7 +208,7 @@ |
549 | g_variant_unref (serialized_app_icon); |
550 | } |
551 | |
552 | - if (actions) |
553 | + if (actions && show_data) |
554 | g_menu_item_set_attribute (item, "x-canonical-message-actions", "v", actions); |
555 | |
556 | n_messages = g_menu_model_get_n_items (G_MENU_MODEL (menu->message_section)); |
557 | |
558 | === modified file 'src/im-phone-menu.h' |
559 | --- src/im-phone-menu.h 2013-09-06 10:06:40 +0000 |
560 | +++ src/im-phone-menu.h 2014-11-03 16:11:06 +0000 |
561 | @@ -33,7 +33,8 @@ |
562 | |
563 | GType im_phone_menu_get_type (void); |
564 | |
565 | -ImPhoneMenu * im_phone_menu_new (ImApplicationList *applist); |
566 | +ImPhoneMenu * im_phone_menu_new (ImApplicationList *applist, |
567 | + gboolean greeter); |
568 | |
569 | void im_phone_menu_add_message (ImPhoneMenu *menu, |
570 | const gchar *app_id, |
571 | |
572 | === modified file 'src/messages-service.c' |
573 | --- src/messages-service.c 2014-04-10 08:22:09 +0000 |
574 | +++ src/messages-service.c 2014-11-03 16:11:06 +0000 |
575 | @@ -273,8 +273,10 @@ |
576 | } |
577 | |
578 | menus = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); |
579 | - g_hash_table_insert (menus, "phone", im_phone_menu_new (applications)); |
580 | + g_hash_table_insert (menus, "phone", im_phone_menu_new (applications, FALSE)); |
581 | + g_hash_table_insert (menus, "phone_greeter", im_phone_menu_new (applications, TRUE)); |
582 | g_hash_table_insert (menus, "desktop", im_desktop_menu_new (applications)); |
583 | + g_hash_table_insert (menus, "desktop_greeter", im_desktop_menu_new (applications)); |
584 | |
585 | g_unix_signal_add(SIGTERM, sig_term_handler, mainloop); |
586 | |
587 | |
588 | === modified file 'tests/manual' |
589 | --- tests/manual 2014-10-09 13:29:55 +0000 |
590 | +++ tests/manual 2014-11-03 16:11:06 +0000 |
591 | @@ -31,3 +31,33 @@ |
592 | <dt>Verify the application icon in the menu item is monochromatic</dt> |
593 | <dd>On the right side of the item the application icon should have no color</dd> |
594 | </dl> |
595 | + |
596 | +Test-case indicator-messages/unity8-embedded-greeter |
597 | +<dl> |
598 | + <dt>NOTE: Only works with embedded greeter, split greeter will require modifications to this test</dt> |
599 | + <dt>NOTE: Only works on a device that can receive SMS messages</dt> |
600 | + <dt>Ensure System Settings is set to "Show Messages on Greeter"</dt> |
601 | + <dt>Send an SMS to the device</dt> |
602 | + <dd>The notification icon should change color</dd> |
603 | + <dd>There should be an entry in the messaging menu with the SMS message</dd> |
604 | + <dd>The item should include the sender and the start of the message</dd> |
605 | + <dt>Go to the greeter. This can be done by hitting the lock button twice.</dt> |
606 | + <dt>Ensure the messaging menu has the message</dt> |
607 | + <dd>The notification icon should have color</dd> |
608 | + <dd>There should be an entry in the messaging menu with the SMS message</dd> |
609 | + <dd>The item should include the sender and the start of the message</dd> |
610 | + <dt>Clear the message in the greeter</dt> |
611 | + <dd>The message should no longer be in the messaging menu</dd> |
612 | + <dt>Disable System Settings value "Show Messages on Greeter"</dt> |
613 | + <dt>Send an SMS to the device</dt> |
614 | + <dd>The notification icon should change color</dd> |
615 | + <dd>There should be an entry in the messaging menu with the SMS message</dd> |
616 | + <dd>The item should include the sender and the start of the message</dd> |
617 | + <dt>Go to the greeter. This can be done by hitting the lock button twice.</dt> |
618 | + <dt>Ensure the messaging menu has the message, but it does not include the start of the message</dt> |
619 | + <dd>The notification icon should have color</dd> |
620 | + <dd>There should be an entry in the messaging menu with the SMS message</dd> |
621 | + <dd>The item should include the sender but NOT the start of the message</dd> |
622 | + <dt>Clear the message in the greeter</dt> |
623 | + <dd>The message should no longer be in the messaging menu</dd> |
624 | +</dl> |
In silo 13 with a few other changes.