summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross@openedhand.com>2007-09-12 13:21:47 +0000
committerRoss Burton <ross@openedhand.com>2007-09-12 13:21:47 +0000
commit8d4fb7f79cecc898f5eb101d8d69ef2dd72a9830 (patch)
treeba462ab0868127e6a786ac67e0929a6b0d77d444 /meta
parente805cf6b66d7ed630c49f1d4b25f807e8fc1bb21 (diff)
downloadpoky-8d4fb7f79cecc898f5eb101d8d69ef2dd72a9830.tar.gz
eds-dbus: Add threading patch until I'm confident enough to commit it to svn
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2729 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta')
-rw-r--r--meta/packages/eds/eds-dbus/threads.patch319
-rw-r--r--meta/packages/eds/eds-dbus_svn.bb3
2 files changed, 321 insertions, 1 deletions
diff --git a/meta/packages/eds/eds-dbus/threads.patch b/meta/packages/eds/eds-dbus/threads.patch
new file mode 100644
index 0000000000..c1c0199845
--- /dev/null
+++ b/meta/packages/eds/eds-dbus/threads.patch
@@ -0,0 +1,319 @@
1Index: addressbook/libedata-book-dbus/e-data-book.c
2===================================================================
3--- addressbook/libedata-book-dbus/e-data-book.c (revision 622)
4+++ addressbook/libedata-book-dbus/e-data-book.c (working copy)
5@@ -55,8 +55,7 @@
6
7 static void return_status_and_list (guint32 opid, EDataBookStatus status, GList *list, gboolean free_data);
8
9-enum
10-{
11+enum {
12 WRITABLE,
13 CONNECTION,
14 AUTH_REQUIRED,
15@@ -65,6 +64,121 @@
16
17 static guint signals[LAST_SIGNAL] = { 0 };
18
19+static GThreadPool *op_pool = NULL;
20+
21+typedef enum {
22+ OP_OPEN,
23+ OP_AUTHENTICATE,
24+ OP_ADD_CONTACT,
25+ OP_GET_CONTACT,
26+ OP_GET_CONTACTS,
27+ OP_MODIFY_CONTACT,
28+ OP_MODIFY_CONTACTS,
29+ OP_REMOVE_CONTACTS,
30+ OP_GET_CHANGES,
31+} OperationID;
32+
33+typedef struct {
34+ OperationID op;
35+ guint32 id; /* operation id */
36+ EDataBook *book; /* book */
37+ union {
38+ /* OP_OPEN */
39+ gboolean only_if_exists;
40+ /* OP_AUTHENTICATE */
41+ struct {
42+ char *username;
43+ char *password;
44+ char *method;
45+ } auth;
46+ /* OP_ADD_CONTACT */
47+ /* OP_MODIFY_CONTACT */
48+ char *vcard;
49+ /* OP_GET_CONTACT */
50+ char *uid;
51+ /* OP_GET_CONTACTS */
52+ char *query;
53+ /* OP_MODIFY_CONTACT */
54+ char **vcards;
55+ /* OP_REMOVE_CONTACTS */
56+ GList *ids;
57+ /* OP_GET_CHANGES */
58+ char *change_id;
59+ };
60+} OperationData;
61+
62+
63+static void
64+operation_thread (gpointer data, gpointer user_data)
65+{
66+ OperationData *op = data;
67+ EBookBackend *backend;
68+
69+ backend = e_data_book_get_backend (op->book);
70+
71+ switch (op->op) {
72+ case OP_OPEN:
73+ e_book_backend_open (backend, op->book, op->id, op->only_if_exists);
74+ break;
75+ case OP_AUTHENTICATE:
76+ e_book_backend_authenticate_user (backend, op->book, op->id,
77+ op->auth.username,
78+ op->auth.password,
79+ op->auth.method);
80+ g_free (op->auth.username);
81+ g_free (op->auth.password);
82+ g_free (op->auth.method);
83+ break;
84+ case OP_ADD_CONTACT:
85+ e_book_backend_create_contact (backend, op->book, op->id, op->vcard);
86+ g_free (op->vcard);
87+ break;
88+ case OP_GET_CONTACT:
89+ e_book_backend_get_contact (backend, op->book, op->id, op->uid);
90+ g_free (op->uid);
91+ break;
92+ case OP_GET_CONTACTS:
93+ e_book_backend_get_contact_list (backend, op->book, op->id, op->query);
94+ g_free (op->query);
95+ break;
96+ case OP_MODIFY_CONTACT:
97+ e_book_backend_modify_contact (backend, op->book, op->id, op->vcard);
98+ g_free (op->vcard);
99+ break;
100+ case OP_MODIFY_CONTACTS:
101+ /* C is weird at times, need to cast to const char** */
102+ e_book_backend_modify_contacts (backend, op->book, op->id, (const char**)op->vcards);
103+ g_strfreev (op->vcards);
104+ break;
105+ case OP_REMOVE_CONTACTS:
106+ e_book_backend_remove_contacts (backend, op->book, op->id, op->ids);
107+ g_list_foreach (op->ids, (GFunc)g_free, NULL);
108+ g_list_free (op->ids);
109+ break;
110+ case OP_GET_CHANGES:
111+ e_book_backend_get_changes (backend, op->book, op->id, op->change_id);
112+ g_free (op->change_id);
113+ break;
114+ }
115+
116+ g_object_unref (op->book);
117+ g_slice_free (OperationData, op);
118+}
119+
120+static OperationData *
121+op_new (OperationID op, EDataBook *book, DBusGMethodInvocation *context)
122+{
123+ OperationData *data;
124+
125+ data = g_slice_new0 (OperationData);
126+ data->op = op;
127+ data->book = g_object_ref (book);
128+ data->id = opid_store (context);
129+
130+ return data;
131+}
132+
133+
134 /* Create the EDataBook error quark */
135 GQuark
136 e_data_book_error_quark (void)
137@@ -134,6 +248,10 @@
138 dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (e_data_book_class), &dbus_glib_e_data_book_object_info);
139
140 dbus_g_error_domain_register (E_DATA_BOOK_ERROR, NULL, E_TYPE_DATA_BOOK_STATUS);
141+
142+ op_pool = g_thread_pool_new (operation_thread, NULL, 10, FALSE, NULL);
143+ /* Kill threads which don't do anything for 10 seconds */
144+ g_thread_pool_set_max_idle_time (10 * 1000);
145 }
146
147 /* Instance init */
148@@ -172,7 +290,11 @@
149 static void
150 impl_AddressBook_Book_open(EDataBook *book, gboolean only_if_exists, DBusGMethodInvocation *context)
151 {
152- e_book_backend_open (book->backend, book, opid_store (context), only_if_exists);
153+ OperationData *op;
154+
155+ op = op_new (OP_OPEN, book, context);
156+ op->only_if_exists = only_if_exists;
157+ g_thread_pool_push (op_pool, op, NULL);
158 }
159
160 void
161@@ -208,12 +330,16 @@
162 static void
163 impl_AddressBook_Book_getContact (EDataBook *book, const char *IN_uid, DBusGMethodInvocation *context)
164 {
165+ OperationData *op;
166+
167 if (IN_uid == NULL) {
168 dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, ContactNotFound, _("Cannot get contact")));
169 return;
170 }
171
172- e_book_backend_get_contact (book->backend, book, opid_store (context), IN_uid);
173+ op = op_new (OP_GET_CONTACT, book, context);
174+ op->uid = g_strdup (IN_uid);
175+ g_thread_pool_push (op_pool, op, NULL);
176 }
177
178 void
179@@ -229,14 +355,18 @@
180 }
181
182 static void
183-impl_AddressBook_Book_getContactList(EDataBook *book, const char *query, DBusGMethodInvocation *context)
184+impl_AddressBook_Book_getContactList (EDataBook *book, const char *query, DBusGMethodInvocation *context)
185 {
186- if (query == NULL) {
187+ OperationData *op;
188+
189+ if (query == NULL || query[0] == '\0') {
190 dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, InvalidQuery, _("Empty query")));
191 return;
192 }
193
194- e_book_backend_get_contact_list (book->backend, book, opid_store (context), query);
195+ op = op_new (OP_GET_CONTACTS, book, context);
196+ op->query = g_strdup (query);
197+ g_thread_pool_push (op_pool, op, NULL);
198 }
199
200 void
201@@ -248,8 +378,13 @@
202 static void
203 impl_AddressBook_Book_authenticateUser(EDataBook *book, const char *IN_user, const char *IN_passwd, const char *IN_auth_method, DBusGMethodInvocation *context)
204 {
205- e_book_backend_authenticate_user (e_data_book_get_backend (book), book,
206- opid_store (context), IN_user, IN_passwd, IN_auth_method);
207+ OperationData *op;
208+
209+ op = op_new (OP_AUTHENTICATE, book, context);
210+ op->auth.username = g_strdup (IN_user);
211+ op->auth.password = g_strdup (IN_passwd);
212+ op->auth.method = g_strdup (IN_auth_method);
213+ g_thread_pool_push (op_pool, op, NULL);
214 }
215
216 void
217@@ -267,13 +402,16 @@
218 static void
219 impl_AddressBook_Book_addContact (EDataBook *book, const char *IN_vcard, DBusGMethodInvocation *context)
220 {
221- if (IN_vcard == NULL) {
222+ OperationData *op;
223+
224+ if (IN_vcard == NULL || IN_vcard[0] == '\0') {
225 dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, InvalidQuery, _("Cannot add contact")));
226 return;
227 }
228
229- e_book_backend_create_contact (e_data_book_get_backend (book), book,
230- opid_store (context), IN_vcard);
231+ op = op_new (OP_ADD_CONTACT, book, context);
232+ op->vcard = g_strdup (IN_vcard);
233+ g_thread_pool_push (op_pool, op, NULL);
234 }
235
236 void
237@@ -294,13 +432,16 @@
238 static void
239 impl_AddressBook_Book_modifyContact (EDataBook *book, const char *IN_vcard, DBusGMethodInvocation *context)
240 {
241+ OperationData *op;
242+
243 if (IN_vcard == NULL) {
244 dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, InvalidQuery, _("Cannot modify contact")));
245 return;
246 }
247
248- e_book_backend_modify_contact (e_data_book_get_backend (book), book,
249- opid_store (context), IN_vcard);
250+ op = op_new (OP_MODIFY_CONTACT, book, context);
251+ op->vcard = g_strdup (IN_vcard);
252+ g_thread_pool_push (op_pool, op, NULL);
253 }
254
255 void
256@@ -321,13 +462,16 @@
257 static void
258 impl_AddressBook_Book_modifyContacts(EDataBook *book, const char **IN_vcards, DBusGMethodInvocation *context)
259 {
260- if (IN_vcards == NULL) {
261- dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, InvalidQuery, _("Cannot modify contact")));
262+ OperationData *op;
263+
264+ if (IN_vcards == NULL || IN_vcards[0] == NULL) {
265+ dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, InvalidQuery, _("Cannot modify contacts")));
266 return;
267 }
268
269- e_book_backend_modify_contacts (e_data_book_get_backend (book), book,
270- opid_store (context), IN_vcards);
271+ op = op_new (OP_MODIFY_CONTACTS, book, context);
272+ op->vcards = g_strdupv ((char**)IN_vcards);
273+ g_thread_pool_push (op_pool, op, NULL);
274 }
275
276 void
277@@ -350,8 +494,7 @@
278 static void
279 impl_AddressBook_Book_removeContacts(EDataBook *book, const char **IN_uids, DBusGMethodInvocation *context)
280 {
281- GList *id_list = NULL;
282- int i = 0;
283+ OperationData *op;
284
285 /* Allow an empty array to be removed */
286 if (IN_uids == NULL) {
287@@ -359,14 +502,13 @@
288 return;
289 }
290
291- while (IN_uids[i] != NULL) {
292- id_list = g_list_prepend (id_list, (gpointer) IN_uids[i]);
293- i++;
294+ op = op_new (OP_REMOVE_CONTACTS, book, context);
295+
296+ for (; *IN_uids; IN_uids++) {
297+ op->ids = g_list_prepend (op->ids, g_strdup (*IN_uids));
298 }
299
300- e_book_backend_remove_contacts (e_data_book_get_backend (book), book,
301- opid_store (context), id_list);
302- g_list_free (id_list);
303+ g_thread_pool_push (op_pool, op, NULL);
304 }
305
306 void
307@@ -466,7 +608,11 @@
308 static void
309 impl_AddressBook_Book_getChanges(EDataBook *book, const char *IN_change_id, DBusGMethodInvocation *context)
310 {
311- e_book_backend_get_changes (e_data_book_get_backend (book), book, opid_store (context), IN_change_id);
312+ OperationData *op;
313+
314+ op = op_new (OP_GET_CHANGES, book, context);
315+ op->change_id = g_strdup (IN_change_id);
316+ g_thread_pool_push (op_pool, op, NULL);
317 }
318
319 void
diff --git a/meta/packages/eds/eds-dbus_svn.bb b/meta/packages/eds/eds-dbus_svn.bb
index 5e6eb85eed..f88c18ffed 100644
--- a/meta/packages/eds/eds-dbus_svn.bb
+++ b/meta/packages/eds/eds-dbus_svn.bb
@@ -4,13 +4,14 @@ LICENSE = "LGPL"
4DEPENDS = "intltool-native glib-2.0 gtk+ gconf dbus db gnome-common virtual/libiconv zlib" 4DEPENDS = "intltool-native glib-2.0 gtk+ gconf dbus db gnome-common virtual/libiconv zlib"
5 5
6PV = "1.4.0+svnr${SRCREV}" 6PV = "1.4.0+svnr${SRCREV}"
7PR = "r1" 7PR = "r2"
8 8
9SRC_URI = "svn://svn.o-hand.com/repos/${PN};module=trunk;proto=http \ 9SRC_URI = "svn://svn.o-hand.com/repos/${PN};module=trunk;proto=http \
10 file://oh-contact.patch;patch=1;pnum=0 \ 10 file://oh-contact.patch;patch=1;pnum=0 \
11 file://no_libdb.patch;patch=1 \ 11 file://no_libdb.patch;patch=1 \
12 file://no_iconv_test.patch;patch=1 \ 12 file://no_iconv_test.patch;patch=1 \
13 file://no_libedataserverui.patch;patch=1 \ 13 file://no_libedataserverui.patch;patch=1 \
14 file://threads.patch;patch=1;pnum=0 \
14 file://iconv-detect.h" 15 file://iconv-detect.h"
15 16
16S = "${WORKDIR}/trunk" 17S = "${WORKDIR}/trunk"