aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/port-eds-3.5.patch
blob: 805855f7033a9e5d2e115c3512cdc2c94e4ab987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Subject: Update to evolution-data-server 3.5 API.

---
 src/datetime-service.c |  176 +++++++++++++++++++++++--------------------------
 1 file changed, 84 insertions(+), 92 deletions(-)

Index: b/src/datetime-service.c
===================================================================
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -40,11 +40,9 @@ with this program.  If not, see <http://
 #include <geoclue/geoclue-master-client.h>
 
 #include <time.h>
-#include <libecal/e-cal.h>
+#include <libecal/libecal.h>
 #include <libical/ical.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-source.h>
-#include <libedataserverui/e-passwords.h>
+#include <libedataserver/libedataserver.h>
 // Other users of ecal seem to also include these, not sure why they should be included by the above
 #include <libical/icaltime.h>
 #include <cairo/cairo.h>
@@ -594,27 +592,6 @@ check_for_calendar (gpointer user_data)
 	return FALSE;
 }
 
-// Authentication function
-static gchar *
-auth_func (ECal *ecal, 
-           const gchar *prompt, 
-           const gchar *key, 
-           gpointer user_data)
-{
-	ESource *source = e_cal_get_source (ecal);
-	gchar *auth_domain = e_source_get_duped_property (source, "auth-domain");
-
-	const gchar *component_name;
-	if (auth_domain) component_name = auth_domain;
-	else component_name = "Calendar";
-	
-	gchar *password = e_passwords_get_password (component_name, key);
-	
-	g_free (auth_domain);
-
-	return password;
-}
-
 static gint
 compare_comp_instances (gconstpointer ga, gconstpointer gb)
 {
@@ -649,23 +626,53 @@ comp_instance_free (struct comp_instance
 }
 
 static gboolean
-populate_appointment_instances (ECalComponent * comp,
+populate_appointment_instances (ECalClient * client,
                                 time_t          start,
                                 time_t          end,
                                 gpointer        data)
 {
-	g_debug("Appending item %p", comp);
-	
-	ECalComponentVType vtype = e_cal_component_get_vtype (comp);
-	if (vtype != E_CAL_COMPONENT_EVENT && vtype != E_CAL_COMPONENT_TODO) return FALSE;
-	
-	icalproperty_status status;
-	e_cal_component_get_status (comp, &status);
-	if (status == ICAL_STATUS_COMPLETED || status == ICAL_STATUS_CANCELLED) return FALSE;
+       GSList *ecalcomps, *comp_item;
 
-	struct comp_instance *ci = comp_instance_new (comp, start, end, E_SOURCE(data));
-	comp_instances = g_list_append (comp_instances, ci);
-	return TRUE;
+       if (e_cal_client_get_object_list_as_comps_sync (client,
+                                                       NULL,
+                                                       &ecalcomps,
+                                                       NULL, NULL)) {
+
+               for (comp_item = ecalcomps; comp_item; comp_item = g_slist_next(comp_item)) {
+                       ECalComponent *comp = comp_item->data;
+
+                       g_debug("Appending item %p", e_cal_component_get_as_string(comp));
+
+                       ECalComponentVType vtype = e_cal_component_get_vtype (comp);
+                       if (vtype != E_CAL_COMPONENT_EVENT && vtype != E_CAL_COMPONENT_TODO) return FALSE;
+
+                       icalproperty_status status;
+                       e_cal_component_get_status (comp, &status);
+                       if (status == ICAL_STATUS_COMPLETED || status == ICAL_STATUS_CANCELLED) return FALSE;
+
+                       g_object_ref(comp);
+
+                       ECalComponentDateTime datetime;
+                       icaltimezone *appointment_zone = NULL;
+                       icaltimezone *current_zone = NULL;
+
+                       if (vtype == E_CAL_COMPONENT_EVENT)
+                               e_cal_component_get_dtstart (comp, &datetime);
+                       else
+                               e_cal_component_get_due (comp, &datetime);
+
+                       appointment_zone = icaltimezone_get_builtin_timezone_from_tzid(datetime.tzid);
+                       current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone);
+                       if (!appointment_zone || datetime.value->is_date) { // If it's today put in the current timezone?
+                               appointment_zone = current_zone;
+                       }
+
+                       struct comp_instance *ci = comp_instance_new (comp, start, end, E_SOURCE(data));
+                       comp_instances = g_list_append (comp_instances, ci);
+               }
+               return TRUE;
+       }
+       return FALSE;
 }
 
 /* Populate the menu with todays, next 5 appointments. 
@@ -685,12 +692,12 @@ update_appointment_menu_items (gpointer
 	updating_appointments = TRUE;
 	
 	time_t curtime = 0, t1 = 0, t2 = 0;
-	GList *l;
-	GSList *g;
+	GList *l, *s;
 	GError *gerror = NULL;
 	gint i;
 	gint width = 0, height = 0;
-	ESourceList * sources = NULL;
+	ESourceRegistry * src_registry = NULL;
+	GList * sources = NULL;
 
 	// Get today & work out query times
 	time(&curtime);
@@ -730,67 +737,52 @@ update_appointment_menu_items (gpointer
 	highlightdays = highlightdays + 7; // Minimum of 7 days ahead 
 	t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60);
 	
-	if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) {
-		g_debug("Failed to get ecal sources\n");
-		g_clear_error (&gerror);
-		return FALSE;
-	}
-	
 	// clear any previous comp_instances
 	g_list_free_full (comp_instances, (GDestroyNotify)comp_instance_free);
 	comp_instances = NULL;
 
-	GSList *cal_list = gconf_client_get_list(gconf, "/apps/evolution/calendar/display/selected_calendars", GCONF_VALUE_STRING, &gerror);
-	if (gerror) {
-	  g_debug("Failed to get evolution preference for enabled calendars");
-	  g_clear_error (&gerror);
-	  cal_list = NULL;
-	}
-	
+       src_registry = e_source_registry_new_sync (NULL, &gerror);
+       if (!src_registry) {
+               g_debug("Failed to get access to source registry: %s\n", gerror->message);
+               return FALSE;
+       }
+
+       sources = e_source_registry_list_sources(src_registry, E_SOURCE_EXTENSION_CALENDAR);
+
 	// Generate instances for all sources
-	for (g = e_source_list_peek_groups (sources); g; g = g->next) {
-		ESourceGroup *group = E_SOURCE_GROUP (g->data);
-		GSList *s;
-		
-		for (s = e_source_group_peek_sources (group); s; s = s->next) {
-			ESource *source = E_SOURCE (s->data);
-			g_signal_connect (G_OBJECT(source), "changed", G_CALLBACK (update_appointment_menu_items), NULL);
-			ECal *ecal = e_cal_new(source, E_CAL_SOURCE_TYPE_EVENT);
-			e_cal_set_auth_func (ecal, (ECalAuthFunc) auth_func, NULL);
-			
-			icaltimezone* current_zone = icaltimezone_get_builtin_timezone(current_timezone);
-			if (!current_zone) {
-				// current_timezone may be a TZID?
-				current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone);
-			}
-			if (current_zone && !e_cal_set_default_timezone(ecal, current_zone, &gerror)) {
-				g_debug("Failed to set ecal default timezone %s", gerror->message);
-				g_clear_error (&gerror);
-				g_object_unref(ecal);
-				continue;
-			}
-			
-			if (!e_cal_open(ecal, FALSE, &gerror)) {
-				g_debug("Failed to get ecal sources %s", gerror->message);
-				g_clear_error (&gerror);
-				g_object_unref(ecal);
-				continue;
-			}
+       for (s = g_list_first (sources); s; s = g_list_next (s)) {
 
-			const gchar *ecal_uid = e_source_peek_uid(source);
-			g_debug("Checking ecal_uid is enabled: %s", ecal_uid);
-			const gboolean in_list = g_slist_find_custom (cal_list, ecal_uid, (GCompareFunc)g_strcmp0) != NULL;
-			if (!in_list) {
+               ESource *source = E_SOURCE (s->data);
+               g_signal_connect (G_OBJECT(source), "changed", G_CALLBACK (update_appointment_menu_items), NULL);
+               ECalClient *ecal = e_cal_client_new(source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &gerror);
+
+               icaltimezone* current_zone = icaltimezone_get_builtin_timezone(current_timezone);
+               if (!current_zone) {
+                       // current_timezone may be a TZID?
+                       current_zone = icaltimezone_get_builtin_timezone_from_tzid(current_timezone);
+               }
+
+               e_cal_client_set_default_timezone (ecal, current_zone);
+
+               g_debug("Checking if source %s is enabled", e_source_get_uid(source));
+               if (e_source_get_enabled (source)) {
+                       g_debug("source is enabled, generating instances");
+
+                       if (!e_client_open_sync (E_CLIENT (ecal), TRUE, NULL, &gerror)) {
+                               g_debug("Failed to open source: %s", gerror->message);
+				g_clear_error (&gerror);
 				g_object_unref(ecal);
 				continue;
 			}
 
-			g_debug("ecal_uid is enabled, generating instances");
-			e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, source);
-			g_object_unref(ecal);
-		}
-	}
-	g_slist_free_full (cal_list, g_free);
+                       e_cal_client_generate_instances (ecal, t1, t2, NULL,
+                                                        (ECalRecurInstanceFn) populate_appointment_instances,
+                                                        (gpointer) source,
+                                                        NULL);
+               }
+               g_object_unref(ecal);
+       }
+       g_list_free_full (sources, g_object_unref);
 
 	g_debug("Number of ECalComponents returned: %d", g_list_length(comp_instances));
 	GList *sorted_comp_instances = g_list_sort(comp_instances, compare_comp_instances);
@@ -942,7 +934,7 @@ update_appointment_menu_items (gpointer
 		                       G_CALLBACK(activate_cb), cmd, (GClosureNotify)g_free, 0);
 		g_free (ad);
 
-        const gchar *color_spec = e_source_peek_color_spec(ci->source);
+	const gchar *color_spec = e_source_selectable_get_color (e_source_get_extension (ci->source, E_SOURCE_EXTENSION_CALENDAR));
         g_debug("Colour to use: %s", color_spec);
 			
 		// Draw the correct icon for the appointment type and then tint it using mask fill.