Merge lp:~cyphermox/indicator-datetime/revert277 into lp:~indicator-applet-developers/indicator-datetime/trunk.13.10
- revert277
- Merge into trunk.13.10
Proposed by
Mathieu Trudel-Lapierre
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 279 |
Merged at revision: | 279 |
Proposed branch: | lp:~cyphermox/indicator-datetime/revert277 |
Merge into: | lp:~indicator-applet-developers/indicator-datetime/trunk.13.10 |
Diff against target: |
1390 lines (+107/-861) 13 files modified
README (+1/-7) configure.ac (+0/-2) debian/control (+0/-1) src/Makefile.am (+0/-2) src/main.c (+4/-45) src/planner-eds.c (+70/-179) src/planner-eds.h (+2/-0) src/planner-mock.c (+0/-178) src/planner-mock.h (+0/-58) src/planner.c (+0/-20) src/planner.h (+2/-4) src/service.c (+27/-359) src/service.h (+1/-6) |
To merge this branch: | bzr merge lp:~cyphermox/indicator-datetime/revert277 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Ted Gould (community) | Approve | ||
Review via email: mp+192258@code.launchpad.net |
This proposal supersedes a proposal from 2013-10-22.
Commit message
Description of the change
Revert revision 277 which appears to be more feature than bugfix applicable for SRU.
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal | # |
review:
Disapprove
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' | |||
2 | --- README 2013-10-09 16:39:36 +0000 | |||
3 | +++ README 2013-10-22 22:10:20 +0000 | |||
4 | @@ -7,17 +7,11 @@ | |||
5 | 7 | Parameter: None | 7 | Parameter: None |
6 | 8 | 8 | ||
7 | 9 | * "activate-planner" | 9 | * "activate-planner" |
9 | 10 | Description: opens an appointment editor. | 10 | Description: opens up a calendar appointment editor. |
10 | 11 | State: None | 11 | State: None |
11 | 12 | Parameter: int64, a time_t hinting which day/time to show in the planner, | 12 | Parameter: int64, a time_t hinting which day/time to show in the planner, |
12 | 13 | or 0 for the current day | 13 | or 0 for the current day |
13 | 14 | 14 | ||
14 | 15 | * "activate-appointment" | ||
15 | 16 | Description: opens an appointment editor to the specified appointment. | ||
16 | 17 | State: None | ||
17 | 18 | Parameter: string, an opaque uid to specify which appointment to use. | ||
18 | 19 | This uid comes from the menuitems' target values. | ||
19 | 20 | |||
20 | 21 | * "set-location" | 15 | * "set-location" |
21 | 22 | Description: Set the current location. This will try to set the current | 16 | Description: Set the current location. This will try to set the current |
22 | 23 | timezone to the new location's timezone. | 17 | timezone to the new location's timezone. |
23 | 24 | 18 | ||
24 | === modified file 'configure.ac' | |||
25 | --- configure.ac 2013-10-16 22:14:11 +0000 | |||
26 | +++ configure.ac 2013-10-22 22:10:20 +0000 | |||
27 | @@ -51,7 +51,6 @@ | |||
28 | 51 | ICAL_REQUIRED_VERSION=0.48 | 51 | ICAL_REQUIRED_VERSION=0.48 |
29 | 52 | ECAL_REQUIRED_VERSION=3.5 | 52 | ECAL_REQUIRED_VERSION=3.5 |
30 | 53 | EDS_REQUIRED_VERSION=3.5 | 53 | EDS_REQUIRED_VERSION=3.5 |
31 | 54 | LIBNOTIFY_REQUIRED_VERSION=0.7.6 | ||
32 | 55 | URL_DISPATCHER_1_REQUIRED_VERSION=1 | 54 | URL_DISPATCHER_1_REQUIRED_VERSION=1 |
33 | 56 | JSON_GLIB_REQUIRED_VERSION=0.16.2 | 55 | JSON_GLIB_REQUIRED_VERSION=0.16.2 |
34 | 57 | 56 | ||
35 | @@ -63,7 +62,6 @@ | |||
36 | 63 | libical >= $ICAL_REQUIRED_VERSION | 62 | libical >= $ICAL_REQUIRED_VERSION |
37 | 64 | libecal-1.2 >= $ECAL_REQUIRED_VERSION | 63 | libecal-1.2 >= $ECAL_REQUIRED_VERSION |
38 | 65 | libedataserver-1.2 >= $EDS_REQUIRED_VERSION | 64 | libedataserver-1.2 >= $EDS_REQUIRED_VERSION |
39 | 66 | libnotify >= $LIBNOTIFY_REQUIRED_VERSION | ||
40 | 67 | url-dispatcher-1 >= $URL_DISPATCHER_1_REQUIRED_VERSION | 65 | url-dispatcher-1 >= $URL_DISPATCHER_1_REQUIRED_VERSION |
41 | 68 | json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION]) | 66 | json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION]) |
42 | 69 | 67 | ||
43 | 70 | 68 | ||
44 | === modified file 'debian/control' | |||
45 | --- debian/control 2013-10-16 22:14:11 +0000 | |||
46 | +++ debian/control 2013-10-22 22:10:20 +0000 | |||
47 | @@ -10,7 +10,6 @@ | |||
48 | 10 | libxorg-gtest-dev, | 10 | libxorg-gtest-dev, |
49 | 11 | libgtest-dev, | 11 | libgtest-dev, |
50 | 12 | libglib2.0-dev (>= 2.35.4), | 12 | libglib2.0-dev (>= 2.35.4), |
51 | 13 | libnotify-dev (>= 0.7.6), | ||
52 | 14 | libido3-0.1-dev (>= 0.2.90), | 13 | libido3-0.1-dev (>= 0.2.90), |
53 | 15 | libgeoclue-dev (>= 0.12.0), | 14 | libgeoclue-dev (>= 0.12.0), |
54 | 16 | libecal1.2-dev (>= 3.5), | 15 | libecal1.2-dev (>= 3.5), |
55 | 17 | 16 | ||
56 | === modified file 'src/Makefile.am' | |||
57 | --- src/Makefile.am 2013-10-10 02:31:13 +0000 | |||
58 | +++ src/Makefile.am 2013-10-22 22:10:20 +0000 | |||
59 | @@ -20,8 +20,6 @@ | |||
60 | 20 | libindicator_datetime_service_a_SOURCES = \ | 20 | libindicator_datetime_service_a_SOURCES = \ |
61 | 21 | planner.c \ | 21 | planner.c \ |
62 | 22 | planner.h \ | 22 | planner.h \ |
63 | 23 | planner-mock.c \ | ||
64 | 24 | planner-mock.h \ | ||
65 | 25 | planner-eds.c \ | 23 | planner-eds.c \ |
66 | 26 | planner-eds.h \ | 24 | planner-eds.h \ |
67 | 27 | service.c \ | 25 | service.c \ |
68 | 28 | 26 | ||
69 | === modified file 'src/main.c' | |||
70 | --- src/main.c 2013-10-17 12:23:13 +0000 | |||
71 | +++ src/main.c 2013-10-22 22:10:20 +0000 | |||
72 | @@ -24,41 +24,25 @@ | |||
73 | 24 | 24 | ||
74 | 25 | #include <glib/gi18n.h> | 25 | #include <glib/gi18n.h> |
75 | 26 | #include <gio/gio.h> | 26 | #include <gio/gio.h> |
76 | 27 | #include <libnotify/notify.h> | ||
77 | 28 | 27 | ||
78 | 29 | #include "planner-eds.h" | ||
79 | 30 | #include "planner-mock.h" | ||
80 | 31 | #include "service.h" | 28 | #include "service.h" |
81 | 32 | 29 | ||
82 | 33 | /*** | 30 | /*** |
83 | 34 | **** | 31 | **** |
84 | 35 | ***/ | 32 | ***/ |
85 | 36 | 33 | ||
86 | 37 | /* When enabled, new alarms will show up every minute to test snap decisions */ | ||
87 | 38 | static gboolean test_alarms = FALSE; | ||
88 | 39 | |||
89 | 40 | static GOptionEntry entries[] = { | ||
90 | 41 | { "test-alarms", '\0', 0, G_OPTION_ARG_NONE, &test_alarms, "Test Alarms", NULL }, | ||
91 | 42 | { NULL } | ||
92 | 43 | }; | ||
93 | 44 | |||
94 | 45 | static void | 34 | static void |
95 | 46 | on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop) | 35 | on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop) |
96 | 47 | { | 36 | { |
97 | 48 | g_message ("exiting: service couldn't acquire or lost ownership of busname"); | 37 | g_message ("exiting: service couldn't acquire or lost ownership of busname"); |
101 | 49 | 38 | g_main_loop_quit ((GMainLoop*)loop); | |
99 | 50 | if (!test_alarms) | ||
100 | 51 | g_main_loop_quit ((GMainLoop*)loop); | ||
102 | 52 | } | 39 | } |
103 | 53 | 40 | ||
104 | 54 | int | 41 | int |
105 | 55 | main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) | 42 | main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) |
106 | 56 | { | 43 | { |
110 | 57 | GOptionContext * context; | 44 | GMainLoop * loop; |
108 | 58 | GError * error; | ||
109 | 59 | IndicatorDatetimePlanner * planner; | ||
111 | 60 | IndicatorDatetimeService * service; | 45 | IndicatorDatetimeService * service; |
112 | 61 | GMainLoop * loop; | ||
113 | 62 | 46 | ||
114 | 63 | /* Work around a deadlock in glib's type initialization. It can be | 47 | /* Work around a deadlock in glib's type initialization. It can be |
115 | 64 | * removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is | 48 | * removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is |
116 | @@ -71,40 +55,15 @@ | |||
117 | 71 | bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); | 55 | bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); |
118 | 72 | textdomain (GETTEXT_PACKAGE); | 56 | textdomain (GETTEXT_PACKAGE); |
119 | 73 | 57 | ||
120 | 74 | /* init libnotify */ | ||
121 | 75 | if (!notify_init ("indicator-datetime-service")) | ||
122 | 76 | g_critical ("libnotify initialization failed"); | ||
123 | 77 | |||
124 | 78 | /* parse command-line options */ | ||
125 | 79 | context = g_option_context_new (NULL); | ||
126 | 80 | g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); | ||
127 | 81 | if (!g_option_context_parse (context, &argc, &argv, &error)) | ||
128 | 82 | { | ||
129 | 83 | g_print("option parsing failed: %s\n", error->message); | ||
130 | 84 | return EXIT_FAILURE; | ||
131 | 85 | } | ||
132 | 86 | |||
133 | 87 | /* set up the planner */ | ||
134 | 88 | if (test_alarms) | ||
135 | 89 | { | ||
136 | 90 | g_message ("Using fake appointment book for testing alarms."); | ||
137 | 91 | planner = indicator_datetime_planner_mock_new (); | ||
138 | 92 | } | ||
139 | 93 | else | ||
140 | 94 | { | ||
141 | 95 | planner = indicator_datetime_planner_eds_new (); | ||
142 | 96 | } | ||
143 | 97 | |||
144 | 98 | /* run */ | 58 | /* run */ |
146 | 99 | service = indicator_datetime_service_new (planner); | 59 | service = indicator_datetime_service_new (); |
147 | 100 | loop = g_main_loop_new (NULL, FALSE); | 60 | loop = g_main_loop_new (NULL, FALSE); |
148 | 101 | g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST, | 61 | g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST, |
149 | 102 | G_CALLBACK(on_name_lost), loop); | 62 | G_CALLBACK(on_name_lost), loop); |
150 | 103 | g_main_loop_run (loop); | 63 | g_main_loop_run (loop); |
151 | 104 | 64 | ||
152 | 105 | /* cleanup */ | 65 | /* cleanup */ |
153 | 66 | g_clear_object (&service); | ||
154 | 106 | g_main_loop_unref (loop); | 67 | g_main_loop_unref (loop); |
155 | 107 | g_object_unref (service); | ||
156 | 108 | g_object_unref (planner); | ||
157 | 109 | return 0; | 68 | return 0; |
158 | 110 | } | 69 | } |
159 | 111 | 70 | ||
160 | === modified file 'src/planner-eds.c' | |||
161 | --- src/planner-eds.c 2013-10-10 02:24:43 +0000 | |||
162 | +++ src/planner-eds.c 2013-10-22 22:10:20 +0000 | |||
163 | @@ -43,180 +43,78 @@ | |||
164 | 43 | 43 | ||
165 | 44 | /*** | 44 | /*** |
166 | 45 | **** | 45 | **** |
177 | 46 | **** my_get_appointments() helpers | 46 | ***/ |
178 | 47 | **** | 47 | |
179 | 48 | ***/ | 48 | void |
180 | 49 | 49 | indicator_datetime_appt_free (struct IndicatorDatetimeAppt * appt) | |
181 | 50 | /* whole-task data that all the subtasks can see */ | 50 | { |
182 | 51 | struct appointment_task_data | 51 | if (appt != NULL) |
183 | 52 | { | 52 | { |
184 | 53 | /* a ref to the planner's cancellable */ | 53 | g_date_time_unref (appt->end); |
185 | 54 | GCancellable * cancellable; | 54 | g_date_time_unref (appt->begin); |
186 | 55 | 55 | g_free (appt->color); | |
187 | 56 | g_free (appt->summary); | ||
188 | 57 | g_slice_free (struct IndicatorDatetimeAppt, appt); | ||
189 | 58 | } | ||
190 | 59 | } | ||
191 | 60 | |||
192 | 61 | /*** | ||
193 | 62 | **** my_get_appointments() helpers | ||
194 | 63 | ***/ | ||
195 | 64 | |||
196 | 65 | struct get_appointments_task_data | ||
197 | 66 | { | ||
198 | 56 | /* how many subtasks are still running on */ | 67 | /* how many subtasks are still running on */ |
199 | 57 | int subtask_count; | 68 | int subtask_count; |
200 | 58 | 69 | ||
201 | 59 | /* the list of appointments to be returned */ | 70 | /* the list of appointments to be returned */ |
202 | 60 | GSList * appointments; | 71 | GSList * appointments; |
203 | 72 | |||
204 | 73 | /* ensure that recurring events don't get multiple IndicatorDatetimeAppts */ | ||
205 | 74 | GHashTable * added; | ||
206 | 61 | }; | 75 | }; |
207 | 62 | 76 | ||
233 | 63 | static struct appointment_task_data * | 77 | static void |
234 | 64 | appointment_task_data_new (GCancellable * cancellable) | 78 | get_appointments_task_data_free (gpointer gdata) |
235 | 65 | { | 79 | { |
236 | 66 | struct appointment_task_data * data; | 80 | struct get_appointments_task_data * data = gdata; |
237 | 67 | 81 | g_hash_table_unref (data->added); | |
238 | 68 | data = g_slice_new0 (struct appointment_task_data); | 82 | g_slice_free (struct get_appointments_task_data, data); |
239 | 69 | data->cancellable = g_object_ref (cancellable); | 83 | } |
240 | 70 | return data; | 84 | |
241 | 71 | } | 85 | static void |
242 | 72 | 86 | on_all_subtasks_done (GTask * task) | |
243 | 73 | static void | 87 | { |
244 | 74 | appointment_task_data_free (gpointer gdata) | 88 | struct get_appointments_task_data * data = g_task_get_task_data (task); |
220 | 75 | { | ||
221 | 76 | struct appointment_task_data * data = gdata; | ||
222 | 77 | |||
223 | 78 | g_object_unref (data->cancellable); | ||
224 | 79 | |||
225 | 80 | g_slice_free (struct appointment_task_data, data); | ||
226 | 81 | } | ||
227 | 82 | |||
228 | 83 | static void | ||
229 | 84 | appointment_task_done (GTask * task) | ||
230 | 85 | { | ||
231 | 86 | struct appointment_task_data * data = g_task_get_task_data (task); | ||
232 | 87 | |||
245 | 88 | g_task_return_pointer (task, data->appointments, NULL); | 89 | g_task_return_pointer (task, data->appointments, NULL); |
246 | 89 | g_object_unref (task); | 90 | g_object_unref (task); |
247 | 90 | } | 91 | } |
248 | 91 | 92 | ||
348 | 92 | static void | 93 | struct get_appointments_subtask_data |
349 | 93 | appointment_task_decrement_subtasks (GTask * task) | 94 | { |
350 | 94 | { | 95 | GTask * task; |
351 | 95 | struct appointment_task_data * data = g_task_get_task_data (task); | 96 | |
253 | 96 | |||
254 | 97 | if (g_atomic_int_dec_and_test (&data->subtask_count)) | ||
255 | 98 | appointment_task_done (task); | ||
256 | 99 | } | ||
257 | 100 | |||
258 | 101 | static void | ||
259 | 102 | appointment_task_increment_subtasks (GTask * task) | ||
260 | 103 | { | ||
261 | 104 | struct appointment_task_data * data = g_task_get_task_data (task); | ||
262 | 105 | |||
263 | 106 | g_atomic_int_inc (&data->subtask_count); | ||
264 | 107 | } | ||
265 | 108 | |||
266 | 109 | /** | ||
267 | 110 | *** get-the-appointment's-uri subtasks | ||
268 | 111 | **/ | ||
269 | 112 | |||
270 | 113 | struct appointment_uri_subtask_data | ||
271 | 114 | { | ||
272 | 115 | /* The parent task */ | ||
273 | 116 | GTask * task; | ||
274 | 117 | |||
275 | 118 | /* The appointment whose uri we're looking for. | ||
276 | 119 | This pointer is owned by the Task and isn't reffed/unreffed by the subtask */ | ||
277 | 120 | struct IndicatorDatetimeAppt * appt; | ||
278 | 121 | }; | ||
279 | 122 | |||
280 | 123 | static void | ||
281 | 124 | appointment_uri_subtask_done (struct appointment_uri_subtask_data * subdata) | ||
282 | 125 | { | ||
283 | 126 | GTask * task = subdata->task; | ||
284 | 127 | |||
285 | 128 | /* free the subtask data */ | ||
286 | 129 | g_slice_free (struct appointment_uri_subtask_data, subdata); | ||
287 | 130 | |||
288 | 131 | appointment_task_decrement_subtasks (task); | ||
289 | 132 | } | ||
290 | 133 | |||
291 | 134 | static struct appointment_uri_subtask_data * | ||
292 | 135 | appointment_uri_subtask_data_new (GTask * task, struct IndicatorDatetimeAppt * appt) | ||
293 | 136 | { | ||
294 | 137 | struct appointment_uri_subtask_data * subdata; | ||
295 | 138 | |||
296 | 139 | appointment_task_increment_subtasks (task); | ||
297 | 140 | |||
298 | 141 | subdata = g_slice_new0 (struct appointment_uri_subtask_data); | ||
299 | 142 | subdata->task = task; | ||
300 | 143 | subdata->appt = appt; | ||
301 | 144 | return subdata; | ||
302 | 145 | } | ||
303 | 146 | |||
304 | 147 | static void | ||
305 | 148 | on_appointment_uris_ready (GObject * client, | ||
306 | 149 | GAsyncResult * res, | ||
307 | 150 | gpointer gsubdata) | ||
308 | 151 | { | ||
309 | 152 | GSList * uris; | ||
310 | 153 | GError * error; | ||
311 | 154 | struct appointment_uri_subtask_data * subdata = gsubdata; | ||
312 | 155 | |||
313 | 156 | uris = NULL; | ||
314 | 157 | error = NULL; | ||
315 | 158 | e_cal_client_get_attachment_uris_finish (E_CAL_CLIENT(client), res, &uris, &error); | ||
316 | 159 | if (error != NULL) | ||
317 | 160 | { | ||
318 | 161 | if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) | ||
319 | 162 | g_warning ("Error getting appointment uris: %s", error->message); | ||
320 | 163 | |||
321 | 164 | g_error_free (error); | ||
322 | 165 | } | ||
323 | 166 | else if (uris != NULL) | ||
324 | 167 | { | ||
325 | 168 | struct IndicatorDatetimeAppt * appt = subdata->appt; | ||
326 | 169 | appt->url = g_strdup (uris->data); /* copy the first URL */ | ||
327 | 170 | g_debug ("found url '%s' for appointment '%s'", appt->url, appt->summary); | ||
328 | 171 | e_client_util_free_string_slist (uris); | ||
329 | 172 | } | ||
330 | 173 | |||
331 | 174 | appointment_uri_subtask_done (subdata); | ||
332 | 175 | } | ||
333 | 176 | |||
334 | 177 | /** | ||
335 | 178 | *** enumerate-the-components subtasks | ||
336 | 179 | **/ | ||
337 | 180 | |||
338 | 181 | /* data struct for the enumerate-components subtask */ | ||
339 | 182 | struct appointment_component_subtask_data | ||
340 | 183 | { | ||
341 | 184 | /* The parent task */ | ||
342 | 185 | GTask * task; | ||
343 | 186 | |||
344 | 187 | /* The client we're walking through. The subtask owns a ref to this */ | ||
345 | 188 | ECalClient * client; | ||
346 | 189 | |||
347 | 190 | /* The appointment's color coding. The subtask owns this string */ | ||
352 | 191 | gchar * color; | 97 | gchar * color; |
353 | 192 | }; | 98 | }; |
354 | 193 | 99 | ||
355 | 194 | static void | 100 | static void |
357 | 195 | on_appointment_component_subtask_done (gpointer gsubdata) | 101 | on_subtask_done (gpointer gsubdata) |
358 | 196 | { | 102 | { |
361 | 197 | struct appointment_component_subtask_data * subdata = gsubdata; | 103 | struct get_appointments_subtask_data * subdata; |
362 | 198 | GTask * task = subdata->task; | 104 | GTask * task; |
363 | 105 | struct get_appointments_task_data * data; | ||
364 | 106 | |||
365 | 107 | subdata = gsubdata; | ||
366 | 108 | task = subdata->task; | ||
367 | 199 | 109 | ||
368 | 200 | /* free the subtask data */ | 110 | /* free the subtask data */ |
369 | 201 | g_free (subdata->color); | 111 | g_free (subdata->color); |
388 | 202 | g_object_unref (subdata->client); | 112 | g_slice_free (struct get_appointments_subtask_data, subdata); |
389 | 203 | g_slice_free (struct appointment_component_subtask_data, subdata); | 113 | |
390 | 204 | 114 | /* poke the task */ | |
391 | 205 | appointment_task_decrement_subtasks (task); | 115 | data = g_task_get_task_data (task); |
392 | 206 | } | 116 | if (g_atomic_int_dec_and_test (&data->subtask_count)) |
393 | 207 | 117 | on_all_subtasks_done (task); | |
376 | 208 | static struct appointment_component_subtask_data * | ||
377 | 209 | appointment_component_subtask_data_new (GTask * task, ECalClient * client, const gchar * color) | ||
378 | 210 | { | ||
379 | 211 | struct appointment_component_subtask_data * subdata; | ||
380 | 212 | |||
381 | 213 | appointment_task_increment_subtasks (task); | ||
382 | 214 | |||
383 | 215 | subdata = g_slice_new0 (struct appointment_component_subtask_data); | ||
384 | 216 | subdata->task = task; | ||
385 | 217 | subdata->client = g_object_ref (client); | ||
386 | 218 | subdata->color = g_strdup (color); | ||
387 | 219 | return subdata; | ||
394 | 220 | } | 118 | } |
395 | 221 | 119 | ||
396 | 222 | static gboolean | 120 | static gboolean |
397 | @@ -226,8 +124,8 @@ | |||
398 | 226 | gpointer gsubdata) | 124 | gpointer gsubdata) |
399 | 227 | { | 125 | { |
400 | 228 | const ECalComponentVType vtype = e_cal_component_get_vtype (component); | 126 | const ECalComponentVType vtype = e_cal_component_get_vtype (component); |
403 | 229 | struct appointment_component_subtask_data * subdata = gsubdata; | 127 | struct get_appointments_subtask_data * subdata = gsubdata; |
404 | 230 | struct appointment_task_data * data = g_task_get_task_data (subdata->task); | 128 | struct get_appointments_task_data * data = g_task_get_task_data (subdata->task); |
405 | 231 | 129 | ||
406 | 232 | if ((vtype == E_CAL_COMPONENT_EVENT) || (vtype == E_CAL_COMPONENT_TODO)) | 130 | if ((vtype == E_CAL_COMPONENT_EVENT) || (vtype == E_CAL_COMPONENT_TODO)) |
407 | 233 | { | 131 | { |
408 | @@ -238,6 +136,7 @@ | |||
409 | 238 | e_cal_component_get_status (component, &status); | 136 | e_cal_component_get_status (component, &status); |
410 | 239 | 137 | ||
411 | 240 | if ((uid != NULL) && | 138 | if ((uid != NULL) && |
412 | 139 | (!g_hash_table_contains (data->added, uid)) && | ||
413 | 241 | (status != ICAL_STATUS_COMPLETED) && | 140 | (status != ICAL_STATUS_COMPLETED) && |
414 | 242 | (status != ICAL_STATUS_CANCELLED)) | 141 | (status != ICAL_STATUS_CANCELLED)) |
415 | 243 | { | 142 | { |
416 | @@ -246,7 +145,6 @@ | |||
417 | 246 | GSList * recur_list; | 145 | GSList * recur_list; |
418 | 247 | ECalComponentText text; | 146 | ECalComponentText text; |
419 | 248 | struct IndicatorDatetimeAppt * appt; | 147 | struct IndicatorDatetimeAppt * appt; |
420 | 249 | struct appointment_uri_subtask_data * uri_subdata; | ||
421 | 250 | 148 | ||
422 | 251 | appt = g_slice_new0 (struct IndicatorDatetimeAppt); | 149 | appt = g_slice_new0 (struct IndicatorDatetimeAppt); |
423 | 252 | 150 | ||
424 | @@ -271,22 +169,13 @@ | |||
425 | 271 | appt->color = g_strdup (subdata->color); | 169 | appt->color = g_strdup (subdata->color); |
426 | 272 | appt->is_event = vtype == E_CAL_COMPONENT_EVENT; | 170 | appt->is_event = vtype == E_CAL_COMPONENT_EVENT; |
427 | 273 | appt->summary = g_strdup (text.value); | 171 | appt->summary = g_strdup (text.value); |
428 | 274 | appt->uid = g_strdup (uid); | ||
429 | 275 | 172 | ||
430 | 276 | alarm_uids = e_cal_component_get_alarm_uids (component); | 173 | alarm_uids = e_cal_component_get_alarm_uids (component); |
431 | 277 | appt->has_alarms = alarm_uids != NULL; | 174 | appt->has_alarms = alarm_uids != NULL; |
432 | 278 | cal_obj_uid_list_free (alarm_uids); | 175 | cal_obj_uid_list_free (alarm_uids); |
433 | 279 | 176 | ||
434 | 280 | data->appointments = g_slist_prepend (data->appointments, appt); | 177 | data->appointments = g_slist_prepend (data->appointments, appt); |
444 | 281 | 178 | g_hash_table_add (data->added, g_strdup(uid)); | |
436 | 282 | /* start a new subtask to get the associated URIs */ | ||
437 | 283 | uri_subdata = appointment_uri_subtask_data_new (subdata->task, appt); | ||
438 | 284 | e_cal_client_get_attachment_uris (subdata->client, | ||
439 | 285 | uid, | ||
440 | 286 | NULL, | ||
441 | 287 | data->cancellable, | ||
442 | 288 | on_appointment_uris_ready, | ||
443 | 289 | uri_subdata); | ||
445 | 290 | } | 179 | } |
446 | 291 | } | 180 | } |
447 | 292 | 181 | ||
448 | @@ -308,6 +197,7 @@ | |||
449 | 308 | priv_t * p; | 197 | priv_t * p; |
450 | 309 | const char * str; | 198 | const char * str; |
451 | 310 | icaltimezone * default_timezone; | 199 | icaltimezone * default_timezone; |
452 | 200 | struct get_appointments_task_data * data; | ||
453 | 311 | const int64_t begin = g_date_time_to_unix (begin_datetime); | 201 | const int64_t begin = g_date_time_to_unix (begin_datetime); |
454 | 312 | const int64_t end = g_date_time_to_unix (end_datetime); | 202 | const int64_t end = g_date_time_to_unix (end_datetime); |
455 | 313 | GTask * task; | 203 | GTask * task; |
456 | @@ -333,18 +223,17 @@ | |||
457 | 333 | *** walk through the sources to build the appointment list | 223 | *** walk through the sources to build the appointment list |
458 | 334 | **/ | 224 | **/ |
459 | 335 | 225 | ||
460 | 226 | data = g_slice_new0 (struct get_appointments_task_data); | ||
461 | 227 | data->added = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); | ||
462 | 336 | task = g_task_new (planner, p->cancellable, callback, user_data); | 228 | task = g_task_new (planner, p->cancellable, callback, user_data); |
466 | 337 | g_task_set_task_data (task, | 229 | g_task_set_task_data (task, data, get_appointments_task_data_free); |
464 | 338 | appointment_task_data_new (p->cancellable), | ||
465 | 339 | appointment_task_data_free); | ||
467 | 340 | 230 | ||
468 | 341 | subtasks_added = FALSE; | 231 | subtasks_added = FALSE; |
469 | 342 | for (l=p->sources; l!=NULL; l=l->next) | 232 | for (l=p->sources; l!=NULL; l=l->next) |
470 | 343 | { | 233 | { |
471 | 344 | ESource * source; | 234 | ESource * source; |
472 | 345 | ECalClient * client; | 235 | ECalClient * client; |
475 | 346 | const char * color; | 236 | struct get_appointments_subtask_data * subdata; |
474 | 347 | struct appointment_component_subtask_data * subdata; | ||
476 | 348 | 237 | ||
477 | 349 | source = l->data; | 238 | source = l->data; |
478 | 350 | client = g_object_get_qdata (l->data, source_client_quark()); | 239 | client = g_object_get_qdata (l->data, source_client_quark()); |
479 | @@ -354,9 +243,11 @@ | |||
480 | 354 | if (default_timezone != NULL) | 243 | if (default_timezone != NULL) |
481 | 355 | e_cal_client_set_default_timezone (client, default_timezone); | 244 | e_cal_client_set_default_timezone (client, default_timezone); |
482 | 356 | 245 | ||
486 | 357 | /* start a new subtask to enumerate all the components in this client. */ | 246 | subdata = g_slice_new (struct get_appointments_subtask_data); |
487 | 358 | color = e_source_selectable_get_color (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR)); | 247 | subdata->task = task; |
488 | 359 | subdata = appointment_component_subtask_data_new (task, client, color); | 248 | subdata->color = e_source_selectable_dup_color (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR)); |
489 | 249 | |||
490 | 250 | g_atomic_int_inc (&data->subtask_count); | ||
491 | 360 | subtasks_added = TRUE; | 251 | subtasks_added = TRUE; |
492 | 361 | e_cal_client_generate_instances (client, | 252 | e_cal_client_generate_instances (client, |
493 | 362 | begin, | 253 | begin, |
494 | @@ -364,11 +255,11 @@ | |||
495 | 364 | p->cancellable, | 255 | p->cancellable, |
496 | 365 | my_get_appointments_foreach, | 256 | my_get_appointments_foreach, |
497 | 366 | subdata, | 257 | subdata, |
499 | 367 | on_appointment_component_subtask_done); | 258 | on_subtask_done); |
500 | 368 | } | 259 | } |
501 | 369 | 260 | ||
502 | 370 | if (!subtasks_added) | 261 | if (!subtasks_added) |
504 | 371 | appointment_task_done (task); | 262 | on_all_subtasks_done (task); |
505 | 372 | } | 263 | } |
506 | 373 | 264 | ||
507 | 374 | static GSList * | 265 | static GSList * |
508 | @@ -379,7 +270,7 @@ | |||
509 | 379 | return g_task_propagate_pointer (G_TASK(res), error); | 270 | return g_task_propagate_pointer (G_TASK(res), error); |
510 | 380 | } | 271 | } |
511 | 381 | 272 | ||
513 | 382 | static gboolean | 273 | gboolean |
514 | 383 | my_is_configured (IndicatorDatetimePlanner * planner) | 274 | my_is_configured (IndicatorDatetimePlanner * planner) |
515 | 384 | { | 275 | { |
516 | 385 | IndicatorDatetimePlannerEds * self; | 276 | IndicatorDatetimePlannerEds * self; |
517 | 386 | 277 | ||
518 | === modified file 'src/planner-eds.h' | |||
519 | --- src/planner-eds.h 2013-10-10 02:04:31 +0000 | |||
520 | +++ src/planner-eds.h 2013-10-22 22:10:20 +0000 | |||
521 | @@ -51,6 +51,8 @@ | |||
522 | 51 | IndicatorDatetimePlannerClass parent_class; | 51 | IndicatorDatetimePlannerClass parent_class; |
523 | 52 | }; | 52 | }; |
524 | 53 | 53 | ||
525 | 54 | gboolean indicator_datetime_planner_eds_is_usable (void); | ||
526 | 55 | |||
527 | 54 | IndicatorDatetimePlanner * indicator_datetime_planner_eds_new (void); | 56 | IndicatorDatetimePlanner * indicator_datetime_planner_eds_new (void); |
528 | 55 | 57 | ||
529 | 56 | G_END_DECLS | 58 | G_END_DECLS |
530 | 57 | 59 | ||
531 | === removed file 'src/planner-mock.c' | |||
532 | --- src/planner-mock.c 2013-10-10 02:31:13 +0000 | |||
533 | +++ src/planner-mock.c 1970-01-01 00:00:00 +0000 | |||
534 | @@ -1,178 +0,0 @@ | |||
535 | 1 | /* | ||
536 | 2 | * Copyright 2013 Canonical Ltd. | ||
537 | 3 | * | ||
538 | 4 | * Authors: | ||
539 | 5 | * Charles Kerr <charles.kerr@canonical.com> | ||
540 | 6 | * | ||
541 | 7 | * This program is free software: you can redistribute it and/or modify it | ||
542 | 8 | * under the terms of the GNU General Public License version 3, as published | ||
543 | 9 | * by the Free Software Foundation. | ||
544 | 10 | * | ||
545 | 11 | * This program is distributed in the hope that it will be useful, but | ||
546 | 12 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
547 | 13 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
548 | 14 | * PURPOSE. See the GNU General Public License for more details. | ||
549 | 15 | * | ||
550 | 16 | * You should have received a copy of the GNU General Public License along | ||
551 | 17 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
552 | 18 | */ | ||
553 | 19 | |||
554 | 20 | #include "config.h" | ||
555 | 21 | |||
556 | 22 | #include "planner-mock.h" | ||
557 | 23 | |||
558 | 24 | struct _IndicatorDatetimePlannerMockPriv | ||
559 | 25 | { | ||
560 | 26 | gboolean is_configured; | ||
561 | 27 | }; | ||
562 | 28 | |||
563 | 29 | typedef IndicatorDatetimePlannerMockPriv priv_t; | ||
564 | 30 | |||
565 | 31 | G_DEFINE_TYPE (IndicatorDatetimePlannerMock, | ||
566 | 32 | indicator_datetime_planner_mock, | ||
567 | 33 | INDICATOR_TYPE_DATETIME_PLANNER) | ||
568 | 34 | |||
569 | 35 | /*** | ||
570 | 36 | **** IndicatorDatetimePlanner virtual funcs | ||
571 | 37 | ***/ | ||
572 | 38 | |||
573 | 39 | static void | ||
574 | 40 | my_get_appointments (IndicatorDatetimePlanner * planner, | ||
575 | 41 | GDateTime * begin_datetime, | ||
576 | 42 | GDateTime * end_datetime G_GNUC_UNUSED, | ||
577 | 43 | GAsyncReadyCallback callback, | ||
578 | 44 | gpointer user_data) | ||
579 | 45 | { | ||
580 | 46 | GTask * task; | ||
581 | 47 | GSList * appointments; | ||
582 | 48 | struct IndicatorDatetimeAppt * appt; | ||
583 | 49 | struct IndicatorDatetimeAppt * prev; | ||
584 | 50 | |||
585 | 51 | task = g_task_new (planner, NULL, callback, user_data); | ||
586 | 52 | |||
587 | 53 | /** | ||
588 | 54 | *** Build the appointments list | ||
589 | 55 | **/ | ||
590 | 56 | |||
591 | 57 | appointments = NULL; | ||
592 | 58 | |||
593 | 59 | /* add a daily appointment that occurs at the beginning of the next minute */ | ||
594 | 60 | appt = g_slice_new0 (struct IndicatorDatetimeAppt); | ||
595 | 61 | appt->is_daily = TRUE; | ||
596 | 62 | appt->begin = g_date_time_add_seconds (begin_datetime, 60-g_date_time_get_seconds(begin_datetime)); | ||
597 | 63 | appt->end = g_date_time_add_minutes (appt->begin, 1); | ||
598 | 64 | appt->color = g_strdup ("#00FF00"); | ||
599 | 65 | appt->is_event = TRUE; | ||
600 | 66 | appt->summary = g_strdup ("Daily alarm"); | ||
601 | 67 | appt->uid = g_strdup ("this uid isn't very random."); | ||
602 | 68 | appt->has_alarms = TRUE; | ||
603 | 69 | appt->url = g_strdup ("alarm:///some-alarm-info-goes-here"); | ||
604 | 70 | appointments = g_slist_prepend (appointments, appt); | ||
605 | 71 | prev = appt; | ||
606 | 72 | |||
607 | 73 | /* and add one for a minute later that has an alarm uri */ | ||
608 | 74 | appt = g_slice_new0 (struct IndicatorDatetimeAppt); | ||
609 | 75 | appt->is_daily = TRUE; | ||
610 | 76 | appt->begin = g_date_time_add_minutes (prev->end, 1); | ||
611 | 77 | appt->end = g_date_time_add_minutes (appt->begin, 1); | ||
612 | 78 | appt->color = g_strdup ("#0000FF"); | ||
613 | 79 | appt->is_event = TRUE; | ||
614 | 80 | appt->summary = g_strdup ("Second Daily alarm"); | ||
615 | 81 | appt->uid = g_strdup ("this uid isn't very random either."); | ||
616 | 82 | appt->has_alarms = FALSE; | ||
617 | 83 | appointments = g_slist_prepend (appointments, appt); | ||
618 | 84 | |||
619 | 85 | /* done */ | ||
620 | 86 | g_task_return_pointer (task, appointments, NULL); | ||
621 | 87 | g_object_unref (task); | ||
622 | 88 | } | ||
623 | 89 | |||
624 | 90 | static GSList * | ||
625 | 91 | my_get_appointments_finish (IndicatorDatetimePlanner * self G_GNUC_UNUSED, | ||
626 | 92 | GAsyncResult * res, | ||
627 | 93 | GError ** error) | ||
628 | 94 | { | ||
629 | 95 | return g_task_propagate_pointer (G_TASK(res), error); | ||
630 | 96 | } | ||
631 | 97 | |||
632 | 98 | static gboolean | ||
633 | 99 | my_is_configured (IndicatorDatetimePlanner * planner) | ||
634 | 100 | { | ||
635 | 101 | IndicatorDatetimePlannerMock * self; | ||
636 | 102 | self = INDICATOR_DATETIME_PLANNER_MOCK (planner); | ||
637 | 103 | return self->priv->is_configured; | ||
638 | 104 | } | ||
639 | 105 | |||
640 | 106 | static void | ||
641 | 107 | my_activate (IndicatorDatetimePlanner * self G_GNUC_UNUSED) | ||
642 | 108 | { | ||
643 | 109 | g_message ("%s %s", G_STRLOC, G_STRFUNC); | ||
644 | 110 | } | ||
645 | 111 | |||
646 | 112 | static void | ||
647 | 113 | my_activate_time (IndicatorDatetimePlanner * self G_GNUC_UNUSED, | ||
648 | 114 | GDateTime * activate_time) | ||
649 | 115 | { | ||
650 | 116 | gchar * str = g_date_time_format (activate_time, "%F %T"); | ||
651 | 117 | g_message ("%s %s: %s", G_STRLOC, G_STRFUNC, str); | ||
652 | 118 | g_free (str); | ||
653 | 119 | } | ||
654 | 120 | |||
655 | 121 | /*** | ||
656 | 122 | **** GObject virtual funcs | ||
657 | 123 | ***/ | ||
658 | 124 | |||
659 | 125 | static void | ||
660 | 126 | my_dispose (GObject * o) | ||
661 | 127 | { | ||
662 | 128 | G_OBJECT_CLASS (indicator_datetime_planner_mock_parent_class)->dispose (o); | ||
663 | 129 | } | ||
664 | 130 | |||
665 | 131 | /*** | ||
666 | 132 | **** Instantiation | ||
667 | 133 | ***/ | ||
668 | 134 | |||
669 | 135 | static void | ||
670 | 136 | indicator_datetime_planner_mock_class_init (IndicatorDatetimePlannerMockClass * klass) | ||
671 | 137 | { | ||
672 | 138 | GObjectClass * object_class; | ||
673 | 139 | IndicatorDatetimePlannerClass * planner_class; | ||
674 | 140 | |||
675 | 141 | object_class = G_OBJECT_CLASS (klass); | ||
676 | 142 | object_class->dispose = my_dispose; | ||
677 | 143 | |||
678 | 144 | planner_class = INDICATOR_DATETIME_PLANNER_CLASS (klass); | ||
679 | 145 | planner_class->is_configured = my_is_configured; | ||
680 | 146 | planner_class->activate = my_activate; | ||
681 | 147 | planner_class->activate_time = my_activate_time; | ||
682 | 148 | planner_class->get_appointments = my_get_appointments; | ||
683 | 149 | planner_class->get_appointments_finish = my_get_appointments_finish; | ||
684 | 150 | |||
685 | 151 | g_type_class_add_private (klass, sizeof (IndicatorDatetimePlannerMockPriv)); | ||
686 | 152 | } | ||
687 | 153 | |||
688 | 154 | static void | ||
689 | 155 | indicator_datetime_planner_mock_init (IndicatorDatetimePlannerMock * self) | ||
690 | 156 | { | ||
691 | 157 | priv_t * p; | ||
692 | 158 | |||
693 | 159 | p = G_TYPE_INSTANCE_GET_PRIVATE (self, | ||
694 | 160 | INDICATOR_TYPE_DATETIME_PLANNER_MOCK, | ||
695 | 161 | IndicatorDatetimePlannerMockPriv); | ||
696 | 162 | |||
697 | 163 | p->is_configured = TRUE; | ||
698 | 164 | |||
699 | 165 | self->priv = p; | ||
700 | 166 | } | ||
701 | 167 | |||
702 | 168 | /*** | ||
703 | 169 | **** Public | ||
704 | 170 | ***/ | ||
705 | 171 | |||
706 | 172 | IndicatorDatetimePlanner * | ||
707 | 173 | indicator_datetime_planner_mock_new (void) | ||
708 | 174 | { | ||
709 | 175 | gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_PLANNER_MOCK, NULL); | ||
710 | 176 | |||
711 | 177 | return INDICATOR_DATETIME_PLANNER (o); | ||
712 | 178 | } | ||
713 | 179 | 0 | ||
714 | === removed file 'src/planner-mock.h' | |||
715 | --- src/planner-mock.h 2013-10-10 02:31:13 +0000 | |||
716 | +++ src/planner-mock.h 1970-01-01 00:00:00 +0000 | |||
717 | @@ -1,58 +0,0 @@ | |||
718 | 1 | /* | ||
719 | 2 | * Copyright 2013 Canonical Ltd. | ||
720 | 3 | * | ||
721 | 4 | * Authors: | ||
722 | 5 | * Charles Kerr <charles.kerr@canonical.com> | ||
723 | 6 | * | ||
724 | 7 | * This program is free software: you can redistribute it and/or modify it | ||
725 | 8 | * under the terms of the GNU General Public License version 3, as published | ||
726 | 9 | * by the Free Software Foundation. | ||
727 | 10 | * | ||
728 | 11 | * This program is distributed in the hope that it will be useful, but | ||
729 | 12 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
730 | 13 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
731 | 14 | * PURPOSE. See the GNU General Public License for more details. | ||
732 | 15 | * | ||
733 | 16 | * You should have received a copy of the GNU General Public License along | ||
734 | 17 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
735 | 18 | */ | ||
736 | 19 | |||
737 | 20 | #ifndef __INDICATOR_DATETIME_PLANNER_MOCK__H__ | ||
738 | 21 | #define __INDICATOR_DATETIME_PLANNER_MOCK__H__ | ||
739 | 22 | |||
740 | 23 | #include "planner.h" /* parent class */ | ||
741 | 24 | |||
742 | 25 | G_BEGIN_DECLS | ||
743 | 26 | |||
744 | 27 | #define INDICATOR_TYPE_DATETIME_PLANNER_MOCK (indicator_datetime_planner_mock_get_type()) | ||
745 | 28 | #define INDICATOR_DATETIME_PLANNER_MOCK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_DATETIME_PLANNER_MOCK, IndicatorDatetimePlannerMock)) | ||
746 | 29 | #define INDICATOR_DATETIME_PLANNER_MOCK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_DATETIME_PLANNER_MOCK, IndicatorDatetimePlannerMockClass)) | ||
747 | 30 | #define INDICATOR_IS_DATETIME_PLANNER_MOCK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_DATETIME_PLANNER_MOCK)) | ||
748 | 31 | |||
749 | 32 | typedef struct _IndicatorDatetimePlannerMock IndicatorDatetimePlannerMock; | ||
750 | 33 | typedef struct _IndicatorDatetimePlannerMockPriv IndicatorDatetimePlannerMockPriv; | ||
751 | 34 | typedef struct _IndicatorDatetimePlannerMockClass IndicatorDatetimePlannerMockClass; | ||
752 | 35 | |||
753 | 36 | GType indicator_datetime_planner_mock_get_type (void); | ||
754 | 37 | |||
755 | 38 | /** | ||
756 | 39 | * An IndicatorDatetimePlanner which uses Evolution Data Server | ||
757 | 40 | * to get its list of appointments. | ||
758 | 41 | */ | ||
759 | 42 | struct _IndicatorDatetimePlannerMock | ||
760 | 43 | { | ||
761 | 44 | /*< private >*/ | ||
762 | 45 | IndicatorDatetimePlanner parent; | ||
763 | 46 | IndicatorDatetimePlannerMockPriv * priv; | ||
764 | 47 | }; | ||
765 | 48 | |||
766 | 49 | struct _IndicatorDatetimePlannerMockClass | ||
767 | 50 | { | ||
768 | 51 | IndicatorDatetimePlannerClass parent_class; | ||
769 | 52 | }; | ||
770 | 53 | |||
771 | 54 | IndicatorDatetimePlanner * indicator_datetime_planner_mock_new (void); | ||
772 | 55 | |||
773 | 56 | G_END_DECLS | ||
774 | 57 | |||
775 | 58 | #endif /* __INDICATOR_DATETIME_PLANNER_MOCK__H__ */ | ||
776 | 59 | 0 | ||
777 | === modified file 'src/planner.c' | |||
778 | --- src/planner.c 2013-10-10 02:06:35 +0000 | |||
779 | +++ src/planner.c 2013-10-22 22:10:20 +0000 | |||
780 | @@ -259,23 +259,3 @@ | |||
781 | 259 | 259 | ||
782 | 260 | return self->priv->timezone; | 260 | return self->priv->timezone; |
783 | 261 | } | 261 | } |
784 | 262 | |||
785 | 263 | /*** | ||
786 | 264 | **** | ||
787 | 265 | ***/ | ||
788 | 266 | |||
789 | 267 | void | ||
790 | 268 | indicator_datetime_appt_free (struct IndicatorDatetimeAppt * appt) | ||
791 | 269 | { | ||
792 | 270 | if (appt != NULL) | ||
793 | 271 | { | ||
794 | 272 | g_date_time_unref (appt->end); | ||
795 | 273 | g_date_time_unref (appt->begin); | ||
796 | 274 | g_free (appt->color); | ||
797 | 275 | g_free (appt->summary); | ||
798 | 276 | g_free (appt->url); | ||
799 | 277 | g_free (appt->uid); | ||
800 | 278 | g_slice_free (struct IndicatorDatetimeAppt, appt); | ||
801 | 279 | } | ||
802 | 280 | } | ||
803 | 281 | |||
804 | 282 | 262 | ||
805 | === modified file 'src/planner.h' | |||
806 | --- src/planner.h 2013-10-09 13:21:16 +0000 | |||
807 | +++ src/planner.h 2013-10-22 22:10:20 +0000 | |||
808 | @@ -40,10 +40,8 @@ | |||
809 | 40 | 40 | ||
810 | 41 | struct IndicatorDatetimeAppt | 41 | struct IndicatorDatetimeAppt |
811 | 42 | { | 42 | { |
816 | 43 | gchar * color; | 43 | char * color; |
817 | 44 | gchar * summary; | 44 | char * summary; |
814 | 45 | gchar * url; | ||
815 | 46 | gchar * uid; | ||
818 | 47 | GDateTime * begin; | 45 | GDateTime * begin; |
819 | 48 | GDateTime * end; | 46 | GDateTime * end; |
820 | 49 | gboolean is_event; | 47 | gboolean is_event; |
821 | 50 | 48 | ||
822 | === modified file 'src/service.c' | |||
823 | --- src/service.c 2013-10-17 03:39:12 +0000 | |||
824 | +++ src/service.c 2013-10-22 22:10:20 +0000 | |||
825 | @@ -24,11 +24,11 @@ | |||
826 | 24 | 24 | ||
827 | 25 | #include <glib/gi18n.h> | 25 | #include <glib/gi18n.h> |
828 | 26 | #include <gio/gio.h> | 26 | #include <gio/gio.h> |
829 | 27 | #include <libnotify/notify.h> | ||
830 | 28 | #include <json-glib/json-glib.h> | 27 | #include <json-glib/json-glib.h> |
831 | 29 | #include <url-dispatcher.h> | 28 | #include <url-dispatcher.h> |
832 | 30 | 29 | ||
833 | 31 | #include "dbus-shared.h" | 30 | #include "dbus-shared.h" |
834 | 31 | #include "planner-eds.h" | ||
835 | 32 | #include "timezone-file.h" | 32 | #include "timezone-file.h" |
836 | 33 | #include "timezone-geoclue.h" | 33 | #include "timezone-geoclue.h" |
837 | 34 | #include "service.h" | 34 | #include "service.h" |
838 | @@ -53,15 +53,6 @@ | |||
839 | 53 | 53 | ||
840 | 54 | enum | 54 | enum |
841 | 55 | { | 55 | { |
842 | 56 | PROP_0, | ||
843 | 57 | PROP_PLANNER, | ||
844 | 58 | PROP_LAST | ||
845 | 59 | }; | ||
846 | 60 | |||
847 | 61 | static GParamSpec * properties[PROP_LAST] = { 0 }; | ||
848 | 62 | |||
849 | 63 | enum | ||
850 | 64 | { | ||
851 | 65 | SECTION_HEADER = (1<<0), | 56 | SECTION_HEADER = (1<<0), |
852 | 66 | SECTION_CALENDAR = (1<<1), | 57 | SECTION_CALENDAR = (1<<1), |
853 | 67 | SECTION_APPOINTMENTS = (1<<2), | 58 | SECTION_APPOINTMENTS = (1<<2), |
854 | @@ -128,7 +119,6 @@ | |||
855 | 128 | 119 | ||
856 | 129 | guint header_timer; | 120 | guint header_timer; |
857 | 130 | guint timezone_timer; | 121 | guint timezone_timer; |
858 | 131 | guint alarm_timer; | ||
859 | 132 | 122 | ||
860 | 133 | /* Which year/month to show in the calendar, | 123 | /* Which year/month to show in the calendar, |
861 | 134 | and which day should get the cursor. | 124 | and which day should get the cursor. |
862 | @@ -398,197 +388,6 @@ | |||
863 | 398 | g_date_time_unref (now); | 388 | g_date_time_unref (now); |
864 | 399 | } | 389 | } |
865 | 400 | 390 | ||
866 | 401 | /*** | ||
867 | 402 | **** ALARMS | ||
868 | 403 | ***/ | ||
869 | 404 | |||
870 | 405 | static void set_alarm_timer (IndicatorDatetimeService * self); | ||
871 | 406 | |||
872 | 407 | static gboolean | ||
873 | 408 | appointment_has_alarm_url (const struct IndicatorDatetimeAppt * appt) | ||
874 | 409 | { | ||
875 | 410 | return (appt->has_alarms) && | ||
876 | 411 | (appt->url != NULL) && | ||
877 | 412 | (g_str_has_prefix (appt->url, "alarm:///")); | ||
878 | 413 | } | ||
879 | 414 | |||
880 | 415 | static gboolean | ||
881 | 416 | datetimes_have_the_same_minute (GDateTime * a G_GNUC_UNUSED, GDateTime * b G_GNUC_UNUSED) | ||
882 | 417 | { | ||
883 | 418 | int ay, am, ad; | ||
884 | 419 | int by, bm, bd; | ||
885 | 420 | |||
886 | 421 | g_date_time_get_ymd (a, &ay, &am, &ad); | ||
887 | 422 | g_date_time_get_ymd (b, &by, &bm, &bd); | ||
888 | 423 | |||
889 | 424 | return (ay == by) && | ||
890 | 425 | (am == bm) && | ||
891 | 426 | (ad == bd) && | ||
892 | 427 | (g_date_time_get_hour (a) == g_date_time_get_hour (b)) && | ||
893 | 428 | (g_date_time_get_minute (a) == g_date_time_get_minute (b)); | ||
894 | 429 | } | ||
895 | 430 | |||
896 | 431 | static void | ||
897 | 432 | dispatch_alarm_url (const struct IndicatorDatetimeAppt * appt) | ||
898 | 433 | { | ||
899 | 434 | gchar * str; | ||
900 | 435 | |||
901 | 436 | g_return_if_fail (appt != NULL); | ||
902 | 437 | g_return_if_fail (appointment_has_alarm_url (appt)); | ||
903 | 438 | |||
904 | 439 | str = g_date_time_format (appt->begin, "%F %T"); | ||
905 | 440 | g_debug ("dispatching url \"%s\" for appointment \"%s\", which begins at %s", | ||
906 | 441 | appt->url, appt->summary, str); | ||
907 | 442 | g_free (str); | ||
908 | 443 | |||
909 | 444 | url_dispatch_send (appt->url, NULL, NULL); | ||
910 | 445 | } | ||
911 | 446 | |||
912 | 447 | static void | ||
913 | 448 | on_snap_decided (NotifyNotification * notification G_GNUC_UNUSED, | ||
914 | 449 | char * action, | ||
915 | 450 | gpointer gurl) | ||
916 | 451 | { | ||
917 | 452 | g_debug ("%s: %s", G_STRFUNC, action); | ||
918 | 453 | |||
919 | 454 | if (!g_strcmp0 (action, "show")) | ||
920 | 455 | { | ||
921 | 456 | const gchar * url = gurl; | ||
922 | 457 | g_debug ("dispatching url '%s'", url); | ||
923 | 458 | url_dispatch_send (url, NULL, NULL); | ||
924 | 459 | } | ||
925 | 460 | } | ||
926 | 461 | |||
927 | 462 | static void | ||
928 | 463 | show_snap_decision_for_alarm (const struct IndicatorDatetimeAppt * appt) | ||
929 | 464 | { | ||
930 | 465 | gchar * title; | ||
931 | 466 | const gchar * body; | ||
932 | 467 | const gchar * icon_name; | ||
933 | 468 | NotifyNotification * nn; | ||
934 | 469 | GError * error; | ||
935 | 470 | |||
936 | 471 | title = g_date_time_format (appt->begin, | ||
937 | 472 | get_terse_time_format_string (appt->begin)); | ||
938 | 473 | body = appt->summary; | ||
939 | 474 | icon_name = ALARM_CLOCK_ICON_NAME; | ||
940 | 475 | g_debug ("creating a snap decision with title '%s', body '%s', icon '%s'", | ||
941 | 476 | title, body, icon_name); | ||
942 | 477 | |||
943 | 478 | nn = notify_notification_new (title, body, icon_name); | ||
944 | 479 | notify_notification_set_hint_string (nn, | ||
945 | 480 | "x-canonical-snap-decisions", | ||
946 | 481 | "true"); | ||
947 | 482 | notify_notification_set_hint_string (nn, | ||
948 | 483 | "x-canonical-private-button-tint", | ||
949 | 484 | "true"); | ||
950 | 485 | notify_notification_add_action (nn, "show", _("Show"), | ||
951 | 486 | on_snap_decided, g_strdup(appt->url), g_free); | ||
952 | 487 | notify_notification_add_action (nn, "dismiss", _("Dismiss"), | ||
953 | 488 | on_snap_decided, NULL, NULL); | ||
954 | 489 | |||
955 | 490 | error = NULL; | ||
956 | 491 | notify_notification_show (nn, &error); | ||
957 | 492 | if (error != NULL) | ||
958 | 493 | { | ||
959 | 494 | g_warning ("Unable to show alarm '%s' popup: %s", body, error->message); | ||
960 | 495 | g_error_free (error); | ||
961 | 496 | dispatch_alarm_url (appt); | ||
962 | 497 | } | ||
963 | 498 | |||
964 | 499 | g_free (title); | ||
965 | 500 | } | ||
966 | 501 | |||
967 | 502 | static void update_appointment_lists (IndicatorDatetimeService * self); | ||
968 | 503 | |||
969 | 504 | static gboolean | ||
970 | 505 | on_alarm_timer (gpointer gself) | ||
971 | 506 | { | ||
972 | 507 | IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself); | ||
973 | 508 | GDateTime * now; | ||
974 | 509 | GSList * l; | ||
975 | 510 | |||
976 | 511 | /* If there are any alarms at the current time, show a snap decision */ | ||
977 | 512 | now = indicator_datetime_service_get_localtime (self); | ||
978 | 513 | for (l=self->priv->upcoming_appointments; l!=NULL; l=l->next) | ||
979 | 514 | { | ||
980 | 515 | const struct IndicatorDatetimeAppt * appt = l->data; | ||
981 | 516 | |||
982 | 517 | if (appointment_has_alarm_url (appt)) | ||
983 | 518 | if (datetimes_have_the_same_minute (now, appt->begin)) | ||
984 | 519 | show_snap_decision_for_alarm (appt); | ||
985 | 520 | } | ||
986 | 521 | g_date_time_unref (now); | ||
987 | 522 | |||
988 | 523 | /* rebuild the alarm list asynchronously. | ||
989 | 524 | set_upcoming_appointments() will update the alarm timer when this | ||
990 | 525 | async call is done, so no need to restart the timer here... */ | ||
991 | 526 | update_appointment_lists (self); | ||
992 | 527 | |||
993 | 528 | return G_SOURCE_REMOVE; | ||
994 | 529 | } | ||
995 | 530 | |||
996 | 531 | /* if there are upcoming alarms, set the alarm timer to the nearest one. | ||
997 | 532 | otherwise, unset the alarm timer. */ | ||
998 | 533 | static void | ||
999 | 534 | set_alarm_timer (IndicatorDatetimeService * self) | ||
1000 | 535 | { | ||
1001 | 536 | priv_t * p; | ||
1002 | 537 | GDateTime * now; | ||
1003 | 538 | GDateTime * alarm_time; | ||
1004 | 539 | GSList * l; | ||
1005 | 540 | |||
1006 | 541 | p = self->priv; | ||
1007 | 542 | indicator_clear_timer (&p->alarm_timer); | ||
1008 | 543 | |||
1009 | 544 | now = indicator_datetime_service_get_localtime (self); | ||
1010 | 545 | |||
1011 | 546 | /* find the time of the next alarm on our calendar */ | ||
1012 | 547 | alarm_time = NULL; | ||
1013 | 548 | for (l=p->upcoming_appointments; l!=NULL; l=l->next) | ||
1014 | 549 | { | ||
1015 | 550 | const struct IndicatorDatetimeAppt * appt = l->data; | ||
1016 | 551 | |||
1017 | 552 | if (appointment_has_alarm_url (appt)) | ||
1018 | 553 | if (g_date_time_compare (appt->begin, now) > 0) | ||
1019 | 554 | if (!alarm_time || g_date_time_compare (alarm_time, appt->begin) > 0) | ||
1020 | 555 | alarm_time = appt->begin; | ||
1021 | 556 | } | ||
1022 | 557 | |||
1023 | 558 | /* if there's an upcoming alarm, set a timer to wake up at that time */ | ||
1024 | 559 | if (alarm_time != NULL) | ||
1025 | 560 | { | ||
1026 | 561 | GTimeSpan interval_msec; | ||
1027 | 562 | gchar * str; | ||
1028 | 563 | GDateTime * then; | ||
1029 | 564 | |||
1030 | 565 | interval_msec = g_date_time_difference (alarm_time, now); | ||
1031 | 566 | interval_msec += G_USEC_PER_SEC; /* fire a moment after alarm_time */ | ||
1032 | 567 | interval_msec /= 1000; /* convert from usec to msec */ | ||
1033 | 568 | |||
1034 | 569 | str = g_date_time_format (alarm_time, "%F %T"); | ||
1035 | 570 | g_debug ("%s is the next alarm time", str); | ||
1036 | 571 | g_free (str); | ||
1037 | 572 | then = g_date_time_add_seconds (now, interval_msec/1000); | ||
1038 | 573 | str = g_date_time_format (then, "%F %T"); | ||
1039 | 574 | g_debug ("%s is when we'll wake up for it", str); | ||
1040 | 575 | g_free (str); | ||
1041 | 576 | g_date_time_unref (then); | ||
1042 | 577 | |||
1043 | 578 | p->alarm_timer = g_timeout_add_full (G_PRIORITY_HIGH, | ||
1044 | 579 | (guint) interval_msec, | ||
1045 | 580 | on_alarm_timer, | ||
1046 | 581 | self, | ||
1047 | 582 | NULL); | ||
1048 | 583 | } | ||
1049 | 584 | |||
1050 | 585 | g_date_time_unref (now); | ||
1051 | 586 | } | ||
1052 | 587 | |||
1053 | 588 | /*** | ||
1054 | 589 | **** | ||
1055 | 590 | ***/ | ||
1056 | 591 | |||
1057 | 592 | static void | 391 | static void |
1058 | 593 | update_internal_timezone (IndicatorDatetimeService * self) | 392 | update_internal_timezone (IndicatorDatetimeService * self) |
1059 | 594 | { | 393 | { |
1060 | @@ -944,36 +743,23 @@ | |||
1061 | 944 | } | 743 | } |
1062 | 945 | 744 | ||
1063 | 946 | static void | 745 | static void |
1065 | 947 | add_appointments (IndicatorDatetimeService * self, GMenu * menu, gboolean phone) | 746 | add_appointments (IndicatorDatetimeService * self, GMenu * menu, gboolean terse) |
1066 | 948 | { | 747 | { |
1067 | 949 | const int MAX_APPTS = 5; | 748 | const int MAX_APPTS = 5; |
1070 | 950 | GDateTime * now; | 749 | GDateTime * now = indicator_datetime_service_get_localtime (self); |
1069 | 951 | GHashTable * added; | ||
1071 | 952 | GSList * appts; | 750 | GSList * appts; |
1072 | 953 | GSList * l; | 751 | GSList * l; |
1073 | 954 | int i; | 752 | int i; |
1074 | 955 | 753 | ||
1075 | 956 | now = indicator_datetime_service_get_localtime (self); | ||
1076 | 957 | |||
1077 | 958 | added = g_hash_table_new (g_str_hash, g_str_equal); | ||
1078 | 959 | |||
1079 | 960 | /* build appointment menuitems */ | 754 | /* build appointment menuitems */ |
1080 | 961 | appts = self->priv->upcoming_appointments; | 755 | appts = self->priv->upcoming_appointments; |
1081 | 962 | for (l=appts, i=0; l!=NULL && i<MAX_APPTS; l=l->next, i++) | 756 | for (l=appts, i=0; l!=NULL && i<MAX_APPTS; l=l->next, i++) |
1082 | 963 | { | 757 | { |
1083 | 964 | struct IndicatorDatetimeAppt * appt = l->data; | 758 | struct IndicatorDatetimeAppt * appt = l->data; |
1086 | 965 | char * fmt; | 759 | char * fmt = get_appointment_time_format (appt, now, self->priv->settings, terse); |
1087 | 966 | gint64 unix_time; | 760 | const gint64 unix_time = g_date_time_to_unix (appt->begin); |
1088 | 967 | GMenuItem * menu_item; | 761 | GMenuItem * menu_item; |
1089 | 968 | 762 | ||
1090 | 969 | if (g_hash_table_contains (added, appt->uid)) | ||
1091 | 970 | continue; | ||
1092 | 971 | |||
1093 | 972 | g_hash_table_add (added, appt->uid); | ||
1094 | 973 | |||
1095 | 974 | fmt = get_appointment_time_format (appt, now, self->priv->settings, phone); | ||
1096 | 975 | unix_time = g_date_time_to_unix (appt->begin); | ||
1097 | 976 | |||
1098 | 977 | menu_item = g_menu_item_new (appt->summary, NULL); | 763 | menu_item = g_menu_item_new (appt->summary, NULL); |
1099 | 978 | 764 | ||
1100 | 979 | if (appt->has_alarms) | 765 | if (appt->has_alarms) |
1101 | @@ -990,22 +776,15 @@ | |||
1102 | 990 | g_menu_item_set_attribute (menu_item, "x-canonical-type", | 776 | g_menu_item_set_attribute (menu_item, "x-canonical-type", |
1103 | 991 | "s", appt->has_alarms ? "com.canonical.indicator.alarm" | 777 | "s", appt->has_alarms ? "com.canonical.indicator.alarm" |
1104 | 992 | : "com.canonical.indicator.appointment"); | 778 | : "com.canonical.indicator.appointment"); |
1114 | 993 | 779 | g_menu_item_set_action_and_target_value (menu_item, | |
1115 | 994 | if (phone) | 780 | "indicator.activate-planner", |
1116 | 995 | g_menu_item_set_action_and_target_value (menu_item, | 781 | g_variant_new_int64 (unix_time)); |
1108 | 996 | "indicator.activate-appointment", | ||
1109 | 997 | g_variant_new_string (appt->uid)); | ||
1110 | 998 | else | ||
1111 | 999 | g_menu_item_set_action_and_target_value (menu_item, | ||
1112 | 1000 | "indicator.activate-planner", | ||
1113 | 1001 | g_variant_new_int64 (unix_time)); | ||
1117 | 1002 | g_menu_append_item (menu, menu_item); | 782 | g_menu_append_item (menu, menu_item); |
1118 | 1003 | g_object_unref (menu_item); | 783 | g_object_unref (menu_item); |
1119 | 1004 | g_free (fmt); | 784 | g_free (fmt); |
1120 | 1005 | } | 785 | } |
1121 | 1006 | 786 | ||
1122 | 1007 | /* cleanup */ | 787 | /* cleanup */ |
1123 | 1008 | g_hash_table_unref (added); | ||
1124 | 1009 | g_date_time_unref (now); | 788 | g_date_time_unref (now); |
1125 | 1010 | } | 789 | } |
1126 | 1011 | 790 | ||
1127 | @@ -1584,34 +1363,6 @@ | |||
1128 | 1584 | } | 1363 | } |
1129 | 1585 | 1364 | ||
1130 | 1586 | static void | 1365 | static void |
1131 | 1587 | on_activate_appointment (GSimpleAction * a G_GNUC_UNUSED, | ||
1132 | 1588 | GVariant * param, | ||
1133 | 1589 | gpointer gself) | ||
1134 | 1590 | { | ||
1135 | 1591 | priv_t * p = INDICATOR_DATETIME_SERVICE(gself)->priv; | ||
1136 | 1592 | const gchar * uid = g_variant_get_string (param, NULL); | ||
1137 | 1593 | |||
1138 | 1594 | if (uid != NULL) | ||
1139 | 1595 | { | ||
1140 | 1596 | const struct IndicatorDatetimeAppt * appt; | ||
1141 | 1597 | GSList * l; | ||
1142 | 1598 | |||
1143 | 1599 | /* find the appointment that matches that uid */ | ||
1144 | 1600 | for (l=p->upcoming_appointments, appt=NULL; l && !appt; l=l->next) | ||
1145 | 1601 | { | ||
1146 | 1602 | const struct IndicatorDatetimeAppt * tmp = l->data; | ||
1147 | 1603 | if (!g_strcmp0 (uid, tmp->uid)) | ||
1148 | 1604 | appt = tmp; | ||
1149 | 1605 | } | ||
1150 | 1606 | |||
1151 | 1607 | /* if that appointment's an alarm, dispatch its url */ | ||
1152 | 1608 | g_debug ("%s: uri '%s'; matching appt is %p", G_STRFUNC, uid, appt); | ||
1153 | 1609 | if (appt && appointment_has_alarm_url (appt)) | ||
1154 | 1610 | dispatch_alarm_url (appt); | ||
1155 | 1611 | } | ||
1156 | 1612 | } | ||
1157 | 1613 | |||
1158 | 1614 | static void | ||
1159 | 1615 | on_phone_clock_activated (GSimpleAction * a G_GNUC_UNUSED, | 1366 | on_phone_clock_activated (GSimpleAction * a G_GNUC_UNUSED, |
1160 | 1616 | GVariant * param G_GNUC_UNUSED, | 1367 | GVariant * param G_GNUC_UNUSED, |
1161 | 1617 | gpointer gself G_GNUC_UNUSED) | 1368 | gpointer gself G_GNUC_UNUSED) |
1162 | @@ -1675,7 +1426,6 @@ | |||
1163 | 1675 | { "activate-phone-settings", on_phone_settings_activated }, | 1426 | { "activate-phone-settings", on_phone_settings_activated }, |
1164 | 1676 | { "activate-phone-clock-app", on_phone_clock_activated }, | 1427 | { "activate-phone-clock-app", on_phone_clock_activated }, |
1165 | 1677 | { "activate-planner", on_activate_planner, "x", NULL }, | 1428 | { "activate-planner", on_activate_planner, "x", NULL }, |
1166 | 1678 | { "activate-appointment", on_activate_appointment, "s", NULL }, | ||
1167 | 1679 | { "set-location", on_set_location, "s" } | 1429 | { "set-location", on_set_location, "s" } |
1168 | 1680 | }; | 1430 | }; |
1169 | 1681 | 1431 | ||
1170 | @@ -1906,10 +1656,6 @@ | |||
1171 | 1906 | 1656 | ||
1172 | 1907 | /* sync the menus/actions */ | 1657 | /* sync the menus/actions */ |
1173 | 1908 | rebuild_appointments_section_soon (self); | 1658 | rebuild_appointments_section_soon (self); |
1174 | 1909 | |||
1175 | 1910 | /* alarm timer is keyed off of the next alarm time, | ||
1176 | 1911 | so it needs to be rebuilt when the appointment list changes */ | ||
1177 | 1912 | set_alarm_timer (self); | ||
1178 | 1913 | } | 1659 | } |
1179 | 1914 | 1660 | ||
1180 | 1915 | static void | 1661 | static void |
1181 | @@ -2079,45 +1825,6 @@ | |||
1182 | 2079 | ***/ | 1825 | ***/ |
1183 | 2080 | 1826 | ||
1184 | 2081 | static void | 1827 | static void |
1185 | 2082 | my_get_property (GObject * o, | ||
1186 | 2083 | guint property_id, | ||
1187 | 2084 | GValue * value, | ||
1188 | 2085 | GParamSpec * pspec) | ||
1189 | 2086 | { | ||
1190 | 2087 | IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (o); | ||
1191 | 2088 | |||
1192 | 2089 | switch (property_id) | ||
1193 | 2090 | { | ||
1194 | 2091 | case PROP_PLANNER: | ||
1195 | 2092 | g_value_set_object (value, self->priv->planner); | ||
1196 | 2093 | break; | ||
1197 | 2094 | |||
1198 | 2095 | default: | ||
1199 | 2096 | G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec); | ||
1200 | 2097 | } | ||
1201 | 2098 | } | ||
1202 | 2099 | |||
1203 | 2100 | static void | ||
1204 | 2101 | my_set_property (GObject * o, | ||
1205 | 2102 | guint property_id, | ||
1206 | 2103 | const GValue * value, | ||
1207 | 2104 | GParamSpec * pspec) | ||
1208 | 2105 | { | ||
1209 | 2106 | IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (o); | ||
1210 | 2107 | |||
1211 | 2108 | switch (property_id) | ||
1212 | 2109 | { | ||
1213 | 2110 | case PROP_PLANNER: | ||
1214 | 2111 | indicator_datetime_service_set_planner (self, g_value_get_object (value)); | ||
1215 | 2112 | break; | ||
1216 | 2113 | |||
1217 | 2114 | default: | ||
1218 | 2115 | G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec); | ||
1219 | 2116 | } | ||
1220 | 2117 | } | ||
1221 | 2118 | |||
1222 | 2119 | |||
1223 | 2120 | static void | ||
1224 | 2121 | my_dispose (GObject * o) | 1828 | my_dispose (GObject * o) |
1225 | 2122 | { | 1829 | { |
1226 | 2123 | int i; | 1830 | int i; |
1227 | @@ -2140,7 +1847,13 @@ | |||
1228 | 2140 | 1847 | ||
1229 | 2141 | set_detect_location_enabled (self, FALSE); | 1848 | set_detect_location_enabled (self, FALSE); |
1230 | 2142 | 1849 | ||
1232 | 2143 | indicator_datetime_service_set_planner (self, NULL); | 1850 | if (p->planner != NULL) |
1233 | 1851 | { | ||
1234 | 1852 | g_signal_handlers_disconnect_by_data (p->planner, self); | ||
1235 | 1853 | g_clear_object (&p->planner); | ||
1236 | 1854 | } | ||
1237 | 1855 | g_clear_pointer (&p->upcoming_appointments, indicator_datetime_planner_free_appointments); | ||
1238 | 1856 | g_clear_pointer (&p->calendar_appointments, indicator_datetime_planner_free_appointments); | ||
1239 | 2144 | 1857 | ||
1240 | 2145 | if (p->login1_manager != NULL) | 1858 | if (p->login1_manager != NULL) |
1241 | 2146 | { | 1859 | { |
1242 | @@ -2152,7 +1865,6 @@ | |||
1243 | 2152 | indicator_clear_timer (&p->rebuild_id); | 1865 | indicator_clear_timer (&p->rebuild_id); |
1244 | 2153 | indicator_clear_timer (&p->timezone_timer); | 1866 | indicator_clear_timer (&p->timezone_timer); |
1245 | 2154 | indicator_clear_timer (&p->header_timer); | 1867 | indicator_clear_timer (&p->header_timer); |
1246 | 2155 | indicator_clear_timer (&p->alarm_timer); | ||
1247 | 2156 | 1868 | ||
1248 | 2157 | if (p->settings != NULL) | 1869 | if (p->settings != NULL) |
1249 | 2158 | { | 1870 | { |
1250 | @@ -2243,6 +1955,16 @@ | |||
1251 | 2243 | p->cancellable = g_cancellable_new (); | 1955 | p->cancellable = g_cancellable_new (); |
1252 | 2244 | 1956 | ||
1253 | 2245 | /*** | 1957 | /*** |
1254 | 1958 | **** Create the planner and listen for changes | ||
1255 | 1959 | ***/ | ||
1256 | 1960 | |||
1257 | 1961 | p->planner = indicator_datetime_planner_eds_new (); | ||
1258 | 1962 | |||
1259 | 1963 | g_signal_connect_swapped (p->planner, "appointments-changed", | ||
1260 | 1964 | G_CALLBACK(update_appointment_lists), self); | ||
1261 | 1965 | |||
1262 | 1966 | |||
1263 | 1967 | /*** | ||
1264 | 2246 | **** Create the settings object and listen for changes | 1968 | **** Create the settings object and listen for changes |
1265 | 2247 | ***/ | 1969 | ***/ |
1266 | 2248 | 1970 | ||
1267 | @@ -2311,8 +2033,6 @@ | |||
1268 | 2311 | 2033 | ||
1269 | 2312 | on_local_time_jumped (self); | 2034 | on_local_time_jumped (self); |
1270 | 2313 | 2035 | ||
1271 | 2314 | set_alarm_timer (self); | ||
1272 | 2315 | |||
1273 | 2316 | for (i=0; i<N_PROFILES; ++i) | 2036 | for (i=0; i<N_PROFILES; ++i) |
1274 | 2317 | create_menu (self, i); | 2037 | create_menu (self, i); |
1275 | 2318 | 2038 | ||
1276 | @@ -2323,12 +2043,9 @@ | |||
1277 | 2323 | indicator_datetime_service_class_init (IndicatorDatetimeServiceClass * klass) | 2043 | indicator_datetime_service_class_init (IndicatorDatetimeServiceClass * klass) |
1278 | 2324 | { | 2044 | { |
1279 | 2325 | GObjectClass * object_class = G_OBJECT_CLASS (klass); | 2045 | GObjectClass * object_class = G_OBJECT_CLASS (klass); |
1280 | 2326 | const GParamFlags flags = G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS; | ||
1281 | 2327 | 2046 | ||
1282 | 2328 | object_class->dispose = my_dispose; | 2047 | object_class->dispose = my_dispose; |
1283 | 2329 | object_class->finalize = my_finalize; | 2048 | object_class->finalize = my_finalize; |
1284 | 2330 | object_class->get_property = my_get_property; | ||
1285 | 2331 | object_class->set_property = my_set_property; | ||
1286 | 2332 | 2049 | ||
1287 | 2333 | g_type_class_add_private (klass, sizeof (IndicatorDatetimeServicePrivate)); | 2050 | g_type_class_add_private (klass, sizeof (IndicatorDatetimeServicePrivate)); |
1288 | 2334 | 2051 | ||
1289 | @@ -2340,18 +2057,6 @@ | |||
1290 | 2340 | NULL, NULL, | 2057 | NULL, NULL, |
1291 | 2341 | g_cclosure_marshal_VOID__VOID, | 2058 | g_cclosure_marshal_VOID__VOID, |
1292 | 2342 | G_TYPE_NONE, 0); | 2059 | G_TYPE_NONE, 0); |
1293 | 2343 | |||
1294 | 2344 | /* install properties */ | ||
1295 | 2345 | |||
1296 | 2346 | properties[PROP_0] = NULL; | ||
1297 | 2347 | |||
1298 | 2348 | properties[PROP_PLANNER] = g_param_spec_object ("planner", | ||
1299 | 2349 | "Planner", | ||
1300 | 2350 | "The appointment provider", | ||
1301 | 2351 | INDICATOR_TYPE_DATETIME_PLANNER, | ||
1302 | 2352 | flags); | ||
1303 | 2353 | |||
1304 | 2354 | g_object_class_install_properties (object_class, PROP_LAST, properties); | ||
1305 | 2355 | } | 2060 | } |
1306 | 2356 | 2061 | ||
1307 | 2357 | /*** | 2062 | /*** |
1308 | @@ -2359,11 +2064,9 @@ | |||
1309 | 2359 | ***/ | 2064 | ***/ |
1310 | 2360 | 2065 | ||
1311 | 2361 | IndicatorDatetimeService * | 2066 | IndicatorDatetimeService * |
1313 | 2362 | indicator_datetime_service_new (IndicatorDatetimePlanner * planner) | 2067 | indicator_datetime_service_new (void) |
1314 | 2363 | { | 2068 | { |
1318 | 2364 | GObject * o = g_object_new (INDICATOR_TYPE_DATETIME_SERVICE, | 2069 | GObject * o = g_object_new (INDICATOR_TYPE_DATETIME_SERVICE, NULL); |
1316 | 2365 | "planner", planner, | ||
1317 | 2366 | NULL); | ||
1319 | 2367 | 2070 | ||
1320 | 2368 | return INDICATOR_DATETIME_SERVICE (o); | 2071 | return INDICATOR_DATETIME_SERVICE (o); |
1321 | 2369 | } | 2072 | } |
1322 | @@ -2399,38 +2102,3 @@ | |||
1323 | 2399 | if (dirty) | 2102 | if (dirty) |
1324 | 2400 | update_appointment_lists (self); | 2103 | update_appointment_lists (self); |
1325 | 2401 | } | 2104 | } |
1326 | 2402 | |||
1327 | 2403 | void | ||
1328 | 2404 | indicator_datetime_service_set_planner (IndicatorDatetimeService * self, | ||
1329 | 2405 | IndicatorDatetimePlanner * planner) | ||
1330 | 2406 | { | ||
1331 | 2407 | priv_t * p; | ||
1332 | 2408 | |||
1333 | 2409 | g_return_if_fail (INDICATOR_IS_DATETIME_SERVICE (self)); | ||
1334 | 2410 | g_return_if_fail (INDICATOR_IS_DATETIME_PLANNER (planner)); | ||
1335 | 2411 | |||
1336 | 2412 | p = self->priv; | ||
1337 | 2413 | |||
1338 | 2414 | /* clear the old planner & appointments */ | ||
1339 | 2415 | |||
1340 | 2416 | if (p->planner != NULL) | ||
1341 | 2417 | { | ||
1342 | 2418 | g_signal_handlers_disconnect_by_data (p->planner, self); | ||
1343 | 2419 | g_clear_object (&p->planner); | ||
1344 | 2420 | } | ||
1345 | 2421 | |||
1346 | 2422 | g_clear_pointer (&p->upcoming_appointments, indicator_datetime_planner_free_appointments); | ||
1347 | 2423 | g_clear_pointer (&p->calendar_appointments, indicator_datetime_planner_free_appointments); | ||
1348 | 2424 | |||
1349 | 2425 | /* set the new planner & begin fetching appointments from it */ | ||
1350 | 2426 | |||
1351 | 2427 | if (planner != NULL) | ||
1352 | 2428 | { | ||
1353 | 2429 | p->planner = g_object_ref (planner); | ||
1354 | 2430 | |||
1355 | 2431 | g_signal_connect_swapped (p->planner, "appointments-changed", | ||
1356 | 2432 | G_CALLBACK(update_appointment_lists), self); | ||
1357 | 2433 | |||
1358 | 2434 | update_appointment_lists (self); | ||
1359 | 2435 | } | ||
1360 | 2436 | } | ||
1361 | 2437 | 2105 | ||
1362 | === modified file 'src/service.h' | |||
1363 | --- src/service.h 2013-10-10 02:02:17 +0000 | |||
1364 | +++ src/service.h 2013-10-22 22:10:20 +0000 | |||
1365 | @@ -22,7 +22,6 @@ | |||
1366 | 22 | 22 | ||
1367 | 23 | #include <glib.h> | 23 | #include <glib.h> |
1368 | 24 | #include <glib-object.h> | 24 | #include <glib-object.h> |
1369 | 25 | #include "planner.h" | ||
1370 | 26 | 25 | ||
1371 | 27 | G_BEGIN_DECLS | 26 | G_BEGIN_DECLS |
1372 | 28 | 27 | ||
1373 | @@ -63,17 +62,13 @@ | |||
1374 | 63 | 62 | ||
1375 | 64 | GType indicator_datetime_service_get_type (void); | 63 | GType indicator_datetime_service_get_type (void); |
1376 | 65 | 64 | ||
1378 | 66 | IndicatorDatetimeService * indicator_datetime_service_new (IndicatorDatetimePlanner * planner); | 65 | IndicatorDatetimeService * indicator_datetime_service_new (void); |
1379 | 67 | 66 | ||
1380 | 68 | GDateTime * indicator_datetime_service_get_localtime (IndicatorDatetimeService * service); | 67 | GDateTime * indicator_datetime_service_get_localtime (IndicatorDatetimeService * service); |
1381 | 69 | 68 | ||
1382 | 70 | void indicator_datetime_service_set_calendar_date (IndicatorDatetimeService * self, | 69 | void indicator_datetime_service_set_calendar_date (IndicatorDatetimeService * self, |
1383 | 71 | GDateTime * date); | 70 | GDateTime * date); |
1384 | 72 | 71 | ||
1385 | 73 | void indicator_datetime_service_set_planner (IndicatorDatetimeService * self, | ||
1386 | 74 | IndicatorDatetimePlanner * planner); | ||
1387 | 75 | |||
1388 | 76 | |||
1389 | 77 | 72 | ||
1390 | 78 | G_END_DECLS | 73 | G_END_DECLS |
1391 | 79 | 74 |
Uhm, this is the 14.04 branch. No need to revert anything here.