frameworkd-glib-dbus: don't call deprecated g_type_init for glib-2.35* and newer
[libframeworkd-glib.git] / src / opimd / frameworkd-glib-opimd-messages.c
blob8ba2762e34af152a68559234f61b152b7ab52d67
1 /*
2 * Copyright (C) 2009
3 * Authors (alphabetical) :
4 * mrmoku (Klaus Kurzmann, mok@fluxnetz.de)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Public License as published by
8 * the Free Software Foundation; version 2 of the license.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser Public License for more details.
17 #include <stdlib.h>
18 #include <unistd.h>
20 #include <dbus/dbus-glib.h>
21 #include <dbus/dbus-glib-bindings.h>
22 #include "frameworkd-glib-opimd-messages.h"
23 #include "frameworkd-glib-opimd-dbus.h"
24 #include "dbus/messages.h"
27 DBusGProxy *opimdMessagesBus = NULL;
29 /* === PIM.Messages Interface ====================================================== */
31 /* --- Add ------------------------------------------------------------------------- */
33 typedef struct {
34 void (*callback) (GError *, char *, gpointer);
35 gpointer userdata;
36 } opimd_messages_add_data_t;
38 void
39 opimd_messages_add_callback(DBusGProxy * proxy, char *message_path,
40 GError * dbus_error, gpointer userdata)
42 (void)proxy;
43 opimd_messages_add_data_t *data = userdata;
44 GError *error = NULL;
46 if (data->callback != NULL) {
47 if (dbus_error != NULL)
48 error = dbus_handle_errors(dbus_error);
49 data->callback(error, message_path, data->userdata);
50 if (error != NULL)
51 g_error_free(error);
53 if (dbus_error != NULL)
54 g_error_free(dbus_error);
56 g_free(data);
59 void
60 opimd_messages_add(const GHashTable * message_data,
61 void (*callback) (GError *, char *, gpointer),
62 gpointer userdata)
64 dbus_connect_to_opimd_messages();
65 opimd_messages_add_data_t *data =
66 g_malloc(sizeof(opimd_messages_add_data_t));
67 data->callback = callback;
68 data->userdata = userdata;
69 org_freesmartphone_PIM_Messages_add_async(opimdMessagesBus,
70 message_data,
71 opimd_messages_add_callback,
72 data);
76 /* --- GetSingleEntrySingleField ------------------------------------------------- */
78 typedef struct {
79 void (*callback) (GError *, char *, gpointer);
80 gpointer userdata;
81 } opimd_messages_get_single_entry_single_field_data_t;
83 void
84 opimd_messages_get_single_entry_single_field_callback(DBusGProxy * bus,
85 char *value,
86 GError * dbus_error,
87 gpointer userdata)
89 (void)bus;
90 opimd_messages_get_single_entry_single_field_data_t *data = userdata;
91 GError *error = NULL;
93 if (data->callback != NULL) {
94 if (dbus_error != NULL)
95 error = dbus_handle_errors(dbus_error);
97 data->callback(error, value, data->userdata);
98 if (error != NULL)
99 g_error_free(error);
101 if (dbus_error != NULL)
102 g_error_free(dbus_error);
104 g_free(data);
107 void
108 opimd_messages_get_single_entry_single_field(const GHashTable * query,
109 const char *field,
110 void (*callback) (GError *, char *,
111 gpointer),
112 gpointer userdata)
114 dbus_connect_to_opimd_messages();
115 opimd_messages_get_single_entry_single_field_data_t *data =
116 g_malloc(sizeof
117 (opimd_messages_get_single_entry_single_field_data_t));
118 data->callback = callback;
119 data->userdata = userdata;
120 org_freesmartphone_PIM_Messages_get_single_entry_single_field_async
121 (opimdMessagesBus, query, field,
122 opimd_messages_get_single_entry_single_field_callback, data);
126 /* --- Query ----------------------------------------------------------------------- */
128 typedef struct {
129 void (*callback) (GError *, char *, gpointer);
130 gpointer userdata;
131 } opimd_messages_query_data_t;
133 void
134 opimd_messages_query_callback(DBusGProxy * proxy, char *query_path,
135 GError * dbus_error, gpointer userdata)
137 (void)proxy;
138 opimd_messages_query_data_t *data = userdata;
139 GError *error = NULL;
141 if (data->callback != NULL) {
142 if (dbus_error != NULL)
143 error = dbus_handle_errors(dbus_error);
144 data->callback(error, query_path, data->userdata);
145 if (error != NULL)
146 g_error_free(error);
148 if (dbus_error != NULL)
149 g_error_free(dbus_error);
151 g_free(data);
154 void
155 opimd_messages_query(const GHashTable * query,
156 void (*callback) (GError *, char *, gpointer),
157 gpointer userdata)
159 dbus_connect_to_opimd_messages();
160 opimd_messages_query_data_t *data =
161 g_malloc(sizeof(opimd_messages_query_data_t));
162 data->callback = callback;
163 data->userdata = userdata;
164 org_freesmartphone_PIM_Messages_query_async(opimdMessagesBus, query,
165 opimd_messages_query_callback,
166 data);
170 /* --- GetFolderNames -------------------------------------------------------------- */
172 typedef struct {
173 void (*callback) (GError *, char **, gpointer);
174 gpointer userdata;
175 } opimd_messages_get_folder_names_data_t;
177 void
178 opimd_messages_get_folder_names_callback(DBusGProxy * proxy,
179 char **folder_names,
180 GError * dbus_error, gpointer userdata)
182 (void)proxy;
183 opimd_messages_get_folder_names_data_t *data = userdata;
184 GError *error = NULL;
186 if (data->callback != NULL) {
187 if (dbus_error != NULL)
188 error = dbus_handle_errors(dbus_error);
189 data->callback(error, folder_names, data->userdata);
190 if (error != NULL)
191 g_error_free(error);
193 if (dbus_error != NULL)
194 g_error_free(dbus_error);
196 g_free(data);
199 void
200 opimd_messages_get_folder_names(void (*callback) (GError *, char **, gpointer),
201 gpointer userdata)
203 dbus_connect_to_opimd_messages();
204 opimd_messages_get_folder_names_data_t *data =
205 g_malloc(sizeof(opimd_messages_get_folder_names_data_t));
206 data->callback = callback;
207 data->userdata = userdata;
208 org_freesmartphone_PIM_Messages_get_folder_names_async(opimdMessagesBus,
209 opimd_messages_get_folder_names_callback,
210 data);
214 /* --- GetFolderURIFromName -------------------------------------------------------- */
216 typedef struct {
217 void (*callback) (GError *, char *, gpointer);
218 gpointer userdata;
219 } opimd_messages_get_folder_path_from_name_data_t;
221 void
222 opimd_messages_get_folder_path_from_name_callback(DBusGProxy * proxy,
223 char *folder_path,
224 GError * dbus_error,
225 gpointer userdata)
227 (void)proxy;
228 opimd_messages_get_folder_path_from_name_data_t *data = userdata;
229 GError *error = NULL;
231 if (data->callback != NULL) {
232 if (dbus_error != NULL)
233 error = dbus_handle_errors(dbus_error);
234 data->callback(error, folder_path, data->userdata);
235 if (error != NULL)
236 g_error_free(error);
238 if (dbus_error != NULL)
239 g_error_free(dbus_error);
241 g_free(data);
244 void
245 opimd_messages_get_folder_path_from_name(const char *folder_name,
246 void (*callback) (GError *, char *,
247 gpointer),
248 gpointer userdata)
250 dbus_connect_to_opimd_messages();
251 opimd_messages_get_folder_path_from_name_data_t *data =
252 g_malloc(sizeof
253 (opimd_messages_get_folder_path_from_name_data_t));
254 data->callback = callback;
255 data->userdata = userdata;
256 org_freesmartphone_PIM_Messages_get_folder_path_from_name_async
257 (opimdMessagesBus, folder_name,
258 opimd_messages_get_folder_path_from_name_callback, data);
262 /* --- GetUnreadMessages ----------------------------------------------------------- */
264 typedef struct {
265 void (*callback)(GError *, const int, gpointer);
266 gpointer userdata;
267 } opimd_messages_get_unread_messages_data_t;
269 void
270 opimd_messages_get_unread_messages_callback(DBusGProxy *proxy,
271 const int amount, GError *dbus_error, gpointer userdata)
273 (void)proxy;
274 opimd_messages_get_unread_messages_data_t *data = userdata;
275 GError *error = NULL;
277 if (data->callback != NULL) {
278 if (dbus_error != NULL)
279 error = dbus_handle_errors(dbus_error);
280 data->callback(error, amount, data->userdata);
281 if (error != NULL)
282 g_error_free(error);
284 if (dbus_error != NULL)
285 g_error_free(dbus_error);
287 g_free(data);
290 void
291 opimd_messages_get_unread_messages(
292 void (*callback) (GError *, const int, gpointer),
293 gpointer userdata)
295 dbus_connect_to_opimd_messages();
296 opimd_messages_get_unread_messages_data_t *data =
297 g_malloc(sizeof
298 (opimd_messages_get_unread_messages_data_t));
299 data->callback = callback;
300 data->userdata = userdata;
301 org_freesmartphone_PIM_Messages_get_unread_messages_async
302 (opimdMessagesBus,
303 opimd_messages_get_unread_messages_callback, data);
306 /* --- (signal) NewMessage --------------------------------------------------------- */
308 void
309 opimd_messages_new_message_handler(DBusGProxy * proxy, const char *message_path,
310 gpointer userdata)
312 (void)proxy;
313 void (*callback) (const char *) = NULL;
315 callback = userdata;
317 if (callback != NULL)
318 (*callback) (message_path);
322 /* --- (signal) IncomingMessage ---------------------------------------------------- */
324 void
325 opimd_messages_incoming_message_handler(DBusGProxy * proxy, const char *message_path,
326 gpointer userdata)
328 (void)proxy;
329 void (*callback) (const char *) = NULL;
331 callback = userdata;
333 if (callback != NULL)
334 (*callback) (message_path);
338 /* --- (signal) UnreadMessages -------------------------------------------------- */
340 void
341 opimd_messages_unread_messages_handler(DBusGProxy *proxy,
342 int amount, gpointer userdata)
344 (void)proxy;
345 void (*callback) (int) = NULL;
347 callback = userdata;
349 if (callback != NULL)
350 (*callback) (amount);
354 /* --- (signal) UpdatedMessage -------------------------------------------------- */
356 void
357 opimd_messages_updated_message_handler(DBusGProxy *proxy,
358 const char *message_path, GHashTable *message_data,
359 gpointer userdata)
361 (void)proxy;
362 void (*callback) (const char *, GHashTable *) = NULL;
364 callback = userdata;
366 if (callback != NULL)
367 (*callback) (message_path, message_data);
371 /* --- (signal) DeletedMessage -------------------------------------------------- */
373 void
374 opimd_messages_deleted_message_handler(DBusGProxy *proxy,
375 const char *message_path, gpointer userdata)
377 (void)proxy;
378 void (*callback) (const char *) = NULL;
380 callback = userdata;
382 if (callback != NULL)
383 (*callback) (message_path);
388 /* === PIM.Message Interface ======================================================= */
390 /* --- GetContent ------------------------------------------------------------------ */
392 typedef struct {
393 void (*callback) (GError *, GHashTable *, gpointer);
394 gpointer userdata;
395 } opimd_message_get_content_data_t;
397 void
398 opimd_message_get_content_callback(DBusGProxy * proxy, GHashTable * content,
399 GError * dbus_error, gpointer userdata)
401 (void)proxy;
402 opimd_message_get_content_data_t *data = userdata;
403 GError *error = NULL;
405 if (data->callback != NULL) {
406 if (dbus_error != NULL)
407 error = dbus_handle_errors(dbus_error);
408 data->callback(error, content, data->userdata);
409 if (error != NULL)
410 g_error_free(error);
412 if (dbus_error != NULL)
413 g_error_free(dbus_error);
415 g_free(data);
418 void
419 opimd_message_get_content(const char *message_path,
420 void (*callback) (GError *, GHashTable *, gpointer),
421 gpointer userdata)
423 DBusGProxy *proxy = dbus_connect_to_opimd_message(message_path);
424 opimd_message_get_content_data_t *data =
425 g_malloc(sizeof(opimd_message_get_content_data_t));
426 data->callback = callback;
427 data->userdata = userdata;
428 org_freesmartphone_PIM_Message_get_content_async(proxy,
429 opimd_message_get_content_callback,
430 data);
434 /* --- GetMultipleFields ----------------------------------------------------------- */
436 typedef struct {
437 void (*callback) (GError *, GHashTable *, gpointer);
438 gpointer userdata;
439 } opimd_message_get_multiple_fields_data_t;
441 void
442 opimd_message_get_multiple_fields_callback(DBusGProxy * proxy,
443 GHashTable * field_data,
444 GError * dbus_error,
445 gpointer userdata)
447 (void)proxy;
448 opimd_message_get_multiple_fields_data_t *data = userdata;
449 GError *error = NULL;
451 if (data->callback != NULL) {
452 if (dbus_error != NULL)
453 error = dbus_handle_errors(dbus_error);
454 data->callback(error, field_data, userdata);
455 if (error != NULL)
456 g_error_free(error);
458 if (dbus_error != NULL)
459 g_error_free(dbus_error);
461 g_free(data);
464 void
465 opimd_message_get_multiple_fields(const char *message_path, const char *fields,
466 void (*callback) (GError *, GHashTable *,
467 gpointer),
468 gpointer userdata)
470 DBusGProxy *proxy = dbus_connect_to_opimd_message(message_path);
471 opimd_message_get_multiple_fields_data_t *data =
472 g_malloc(sizeof(opimd_message_get_multiple_fields_data_t));
473 data->callback = callback;
474 data->userdata = userdata;
475 org_freesmartphone_PIM_Message_get_multiple_fields_async(proxy, fields,
476 opimd_message_get_multiple_fields_callback,
477 data);
481 /* --- MoveToFolder ---------------------------------------------------------------- */
483 typedef struct {
484 void (*callback) (GError *, gpointer);
485 gpointer userdata;
486 } opimd_message_move_to_folder_data_t;
488 void
489 opimd_message_move_to_folder_callback(DBusGProxy * proxy, GError * dbus_error,
490 gpointer userdata)
492 (void)proxy;
493 opimd_message_move_to_folder_data_t *data = userdata;
494 GError *error = NULL;
496 if (data->callback != NULL) {
497 if (dbus_error != NULL)
498 error = dbus_handle_errors(dbus_error);
499 data->callback(error, data->userdata);
500 if (error != NULL)
501 g_error_free(error);
503 if (dbus_error != NULL)
504 g_error_free(dbus_error);
506 g_free(data);
509 void
510 opimd_message_move_to_folder(const char *message_path, const char *folder,
511 void (*callback) (GError *, gpointer),
512 gpointer userdata)
514 DBusGProxy *proxy = dbus_connect_to_opimd_message(message_path);
515 opimd_message_move_to_folder_data_t *data =
516 g_malloc(sizeof(opimd_message_move_to_folder_data_t));
517 data->callback = callback;
518 data->userdata = userdata;
519 org_freesmartphone_PIM_Message_move_to_folder_async(proxy, folder,
520 opimd_message_move_to_folder_callback,
521 data);
525 /* --- Update ---------------------------------------------------------------------- */
527 typedef struct {
528 void (*callback) (GError *, gpointer);
529 gpointer userdata;
530 } opimd_message_update_data_t;
532 void opimd_message_update_callback(DBusGProxy *proxy, GError *dbus_error,
533 gpointer userdata)
535 (void)proxy;
536 opimd_message_update_data_t *data = userdata;
537 GError *error = NULL;
539 if (data->callback != NULL) {
540 if (dbus_error != NULL)
541 error = dbus_handle_errors(dbus_error);
542 data->callback(error, data->userdata);
543 if (error)
544 g_error_free(error);
547 if (dbus_error)
548 g_error_free(dbus_error);
550 g_free(data);
553 void
554 opimd_message_update(const char *message_path, GHashTable *field_data,
555 void (*callback)(GError *, gpointer), gpointer userdata)
557 DBusGProxy *proxy = dbus_connect_to_opimd_message(message_path);
558 opimd_message_update_data_t *data =
559 g_malloc(sizeof(opimd_message_update_data_t));
560 data->callback = callback;
561 data->userdata = userdata;
562 org_freesmartphone_PIM_Message_update_async(proxy, field_data,
563 opimd_message_update_callback,
564 data);
568 /* --- Delete ---------------------------------------------------------------------- */
570 typedef struct {
571 void (*callback) (GError *, gpointer);
572 gpointer userdata;
573 } opimd_message_delete_data_t;
576 void
577 opimd_message_delete_callback(DBusGProxy * proxy, GError * dbus_error,
578 gpointer userdata)
580 (void)proxy;
581 opimd_message_delete_data_t *data = userdata;
582 GError *error = NULL;
584 if (data->callback != NULL) {
585 if (dbus_error != NULL)
586 error = dbus_handle_errors(dbus_error);
587 data->callback(error, data->userdata);
588 if (error)
589 g_error_free(error);
592 if (dbus_error)
593 g_error_free(dbus_error);
595 g_free(data);
599 void
600 opimd_message_delete(const char *message_path,
601 void (*callback) (GError *, gpointer), gpointer userdata)
603 DBusGProxy *proxy = dbus_connect_to_opimd_message(message_path);
604 opimd_message_delete_data_t *data =
605 g_malloc(sizeof(opimd_message_delete_data_t));
606 data->callback = callback;
607 data->userdata = userdata;
608 org_freesmartphone_PIM_Message_delete_async(proxy,
609 opimd_message_delete_callback,
610 data);
615 /* === PIM.MessageQuery Interface ================================================== */
617 /* --- GetResultCount -------------------------------------------------------------- */
619 typedef struct {
620 void (*callback) (GError *, gint, gpointer);
621 gpointer userdata;
622 } opimd_message_query_get_result_count_data_t;
624 void
625 opimd_message_query_get_result_count_callback(DBusGProxy * proxy, int count,
626 GError * dbus_error,
627 gpointer userdata)
629 (void)proxy;
630 opimd_message_query_get_result_count_data_t *data = userdata;
631 GError *error = NULL;
633 if (data->callback != NULL) {
634 if (dbus_error != NULL)
635 error = dbus_handle_errors(dbus_error);
636 data->callback(error, count, data->userdata);
637 if (error != NULL)
638 g_error_free(error);
640 if (dbus_error != NULL)
641 g_error_free(dbus_error);
643 g_free(data);
646 void
647 opimd_message_query_get_result_count(DBusGProxy * query,
648 void (*callback) (GError *, gint,
649 gpointer),
650 gpointer userdata)
652 opimd_message_query_get_result_count_data_t *data =
653 g_malloc(sizeof(opimd_message_query_get_result_count_data_t));
654 data->callback = callback;
655 data->userdata = userdata;
656 org_freesmartphone_PIM_MessageQuery_get_result_count_async(query,
657 opimd_message_query_get_result_count_callback,
658 data);
662 /* --- Rewind ---------------------------------------------------------------------- */
664 typedef struct {
665 void (*callback) (GError *, gpointer);
666 gpointer userdata;
667 } opimd_message_query_rewind_data_t;
669 void
670 opimd_message_query_rewind_callback(DBusGProxy * proxy, GError * dbus_error,
671 gpointer userdata)
673 (void)proxy;
674 opimd_message_query_rewind_data_t *data = userdata;
675 GError *error = NULL;
677 if (data->callback != NULL) {
678 if (dbus_error != NULL)
679 error = dbus_handle_errors(dbus_error);
680 data->callback(error, data->userdata);
681 if (error != NULL)
682 g_error_free(error);
684 if (dbus_error != NULL)
685 g_error_free(dbus_error);
687 g_free(data);
690 void
691 opimd_message_query_rewind(DBusGProxy * query,
692 void (*callback) (GError *, gpointer),
693 gpointer userdata)
695 opimd_message_query_rewind_data_t *data =
696 g_malloc(sizeof(opimd_message_query_rewind_data_t));
697 data->callback = callback;
698 data->userdata = userdata;
699 org_freesmartphone_PIM_MessageQuery_rewind_async(query,
700 opimd_message_query_rewind_callback,
701 data);
705 /* --- Skip ------------------------------------------------------------------------ */
707 typedef struct {
708 void (*callback) (GError *, gpointer);
709 gpointer userdata;
710 } opimd_message_query_skip_data_t;
712 void
713 opimd_message_query_skip_callback(DBusGProxy * proxy, GError * dbus_error,
714 gpointer userdata)
716 (void)proxy;
717 opimd_message_query_skip_data_t *data = userdata;
718 GError *error = NULL;
720 if (data->callback != NULL) {
721 if (dbus_error != NULL)
722 error = dbus_handle_errors(dbus_error);
723 data->callback(error, data->userdata);
724 if (error != NULL)
725 g_error_free(error);
727 if (dbus_error != NULL)
728 g_error_free(dbus_error);
730 g_free(data);
733 void
734 opimd_message_query_skip(DBusGProxy * query, const gint count,
735 void (*callback) (GError *, gpointer),
736 gpointer userdata)
738 opimd_message_query_skip_data_t *data =
739 g_malloc(sizeof(opimd_message_query_skip_data_t));
740 data->callback = callback;
741 data->userdata = userdata;
742 org_freesmartphone_PIM_MessageQuery_skip_async(query, count,
743 opimd_message_query_skip_callback,
744 data);
748 /* --- GetMessagePath -------------------------------------------------------------- */
750 typedef struct {
751 void (*callback) (GError *, char *, gpointer);
752 gpointer userdata;
753 } opimd_message_query_get_message_path_data_t;
755 void
756 opimd_message_query_get_message_path_callback(DBusGProxy * proxy,
757 char *message_path,
758 GError * dbus_error,
759 gpointer userdata)
761 (void)proxy;
762 opimd_message_query_get_message_path_data_t *data = userdata;
763 GError *error = NULL;
765 if (data->callback != NULL) {
766 if (dbus_error != NULL)
767 error = dbus_handle_errors(dbus_error);
768 data->callback(error, message_path, data->userdata);
769 if (error != NULL)
770 g_error_free(error);
772 if (dbus_error != NULL)
773 g_error_free(dbus_error);
775 g_free(data);
778 void
779 opimd_message_query_get_message_path(DBusGProxy * query,
780 void (*callback) (GError *, char *,
781 gpointer),
782 gpointer userdata)
784 opimd_message_query_get_message_path_data_t *data =
785 g_malloc(sizeof(opimd_message_query_get_message_path_data_t));
786 data->callback = callback;
787 data->userdata = userdata;
788 org_freesmartphone_PIM_MessageQuery_get_message_path_async(query,
789 opimd_message_query_get_message_path_callback,
790 data);
794 /* --- GetResult ------------------------------------------------------------------- */
796 typedef struct {
797 void (*callback) (GError *, GHashTable *, gpointer);
798 gpointer userdata;
799 } opimd_message_query_get_result_data_t;
801 void
802 opimd_message_query_get_result_callback(DBusGProxy * proxy, GHashTable * result,
803 GError * dbus_error, gpointer userdata)
805 (void)proxy;
806 opimd_message_query_get_result_data_t *data = userdata;
807 GError *error = NULL;
809 if (data->callback != NULL) {
810 if (dbus_error != NULL)
811 error = dbus_handle_errors(dbus_error);
812 data->callback(error, result, data->userdata);
813 if (error != NULL)
814 g_error_free(error);
816 if (dbus_error != NULL)
817 g_error_free(dbus_error);
819 g_free(data);
822 void
823 opimd_message_query_get_result(DBusGProxy * query,
824 void (*callback) (GError *, GHashTable * result,
825 gpointer), gpointer userdata)
827 opimd_message_query_get_result_data_t *data =
828 g_malloc(sizeof(opimd_message_query_get_result_data_t));
829 data->callback = callback;
830 data->userdata = userdata;
831 org_freesmartphone_PIM_MessageQuery_get_result_async(query,
832 opimd_message_query_get_result_callback,
833 data);
837 /* --- GetMultipleResults ---------------------------------------------------------- */
839 typedef struct {
840 void (*callback) (GError *, GPtrArray *, gpointer);
841 gpointer userdata;
842 } opimd_message_query_get_multiple_results_data_t;
844 void
845 opimd_message_query_get_multiple_results_callback(DBusGProxy * proxy,
846 GPtrArray * resultset,
847 GError * dbus_error,
848 gpointer userdata)
850 (void)proxy;
851 opimd_message_query_get_multiple_results_data_t *data = userdata;
852 GError *error = NULL;
854 if (data->callback != NULL) {
855 if (dbus_error != NULL)
856 error = dbus_handle_errors(dbus_error);
857 data->callback(error, resultset, data->userdata);
858 if (error != NULL)
859 g_error_free(error);
861 if (dbus_error != NULL)
862 g_error_free(dbus_error);
864 g_free(data);
867 void
868 opimd_message_query_get_multiple_results(DBusGProxy * query, int count,
869 void (*callback) (GError *,
870 GPtrArray *,
871 gpointer),
872 gpointer userdata)
874 opimd_message_query_get_multiple_results_data_t *data =
875 g_malloc(sizeof
876 (opimd_message_query_get_multiple_results_data_t));
877 data->callback = callback;
878 data->userdata = userdata;
879 org_freesmartphone_PIM_MessageQuery_get_multiple_results_async(query,
880 count,
881 opimd_message_query_get_multiple_results_callback,
882 data);
887 /* --- Dispose --------------------------------------------------------------------- */
889 typedef struct {
890 void (*callback) (GError *, gpointer);
891 gpointer userdata;
892 } opimd_message_query_dispose_data_t;
894 void
895 opimd_message_query_dispose_callback(DBusGProxy * proxy, GError * dbus_error,
896 gpointer userdata)
898 (void)proxy;
899 opimd_message_query_dispose_data_t *data = userdata;
900 GError *error = NULL;
902 if (data->callback != NULL) {
903 if (dbus_error != NULL)
904 error = dbus_handle_errors(dbus_error);
905 data->callback(error, data->userdata);
906 if (error != NULL)
907 g_error_free(error);
909 if (dbus_error != NULL)
910 g_error_free(dbus_error);
912 g_free(data);
915 void
916 opimd_message_query_dispose(DBusGProxy * query,
917 void (*callback) (GError *, gpointer),
918 gpointer userdata)
920 opimd_message_query_dispose_data_t *data =
921 g_malloc(sizeof(opimd_message_query_dispose_data_t));
922 data->callback = callback;
923 data->userdata = userdata;
924 org_freesmartphone_PIM_MessageQuery_dispose_async(query,
925 opimd_message_query_dispose_callback,
926 data);
930 /* === PIM.MessageFolder Interface ================================================= */
932 /* --- GetMessageCount ------------------------------------------------------------- */
934 typedef struct {
935 void (*callback) (GError *, gint, gpointer);
936 gpointer userdata;
937 } opimd_message_folder_get_message_count_data_t;
939 void
940 opimd_message_folder_get_message_count_callback(DBusGProxy * proxy, gint count,
941 GError * dbus_error,
942 gpointer userdata)
944 (void)proxy;
945 opimd_message_folder_get_message_count_data_t *data = userdata;
946 GError *error = NULL;
948 if (data->callback != NULL) {
949 if (dbus_error != NULL)
950 error = dbus_handle_errors(dbus_error);
951 data->callback(error, count, data->userdata);
952 if (error != NULL)
953 g_error_free(error);
955 if (dbus_error != NULL)
956 g_error_free(dbus_error);
958 g_free(data);
961 void
962 opimd_message_folder_get_message_count(const char *folder_path,
963 void (*callback) (GError *, gint,
964 gpointer),
965 gpointer userdata)
967 DBusGProxy *proxy = dbus_connect_to_opimd_message_folder(folder_path);
968 opimd_message_folder_get_message_count_data_t *data =
969 g_malloc(sizeof(opimd_message_folder_get_message_count_data_t));
970 data->callback = callback;
971 data->userdata = userdata;
972 org_freesmartphone_PIM_MessageFolder_get_message_count_async(proxy,
973 opimd_message_folder_get_message_count_callback,
974 data);
978 /* --- GetMessagePaths ------------------------------------------------------------- */
980 typedef struct {
981 void (*callback) (GError *, char **, gpointer);
982 gpointer userdata;
983 } opimd_message_folder_get_message_paths_data_t;
985 void
986 opimd_message_folder_get_message_paths_callback(DBusGProxy * proxy,
987 char **message_paths,
988 GError * dbus_error,
989 gpointer userdata)
991 (void)proxy;
992 opimd_message_folder_get_message_paths_data_t *data = userdata;
993 GError *error = NULL;
995 if (data->callback != NULL) {
996 if (dbus_error != NULL)
997 error = dbus_handle_errors(dbus_error);
998 data->callback(error, message_paths, data->userdata);
999 if (error != NULL)
1000 g_error_free(error);
1002 if (dbus_error != NULL)
1003 g_error_free(dbus_error);
1005 g_free(data);
1008 void
1009 opimd_message_folder_get_message_paths(const char *folder_path,
1010 const gint first, const gint count,
1011 void (*callback) (GError *, char **,
1012 gpointer),
1013 gpointer userdata)
1015 DBusGProxy *proxy = dbus_connect_to_opimd_message_folder(folder_path);
1016 opimd_message_folder_get_message_paths_data_t *data =
1017 g_malloc(sizeof(opimd_message_folder_get_message_paths_data_t));
1018 data->callback = callback;
1019 data->userdata = userdata;
1020 org_freesmartphone_PIM_MessageFolder_get_message_paths_async(proxy,
1021 first,
1022 count,
1023 opimd_message_folder_get_message_paths_callback,
1024 data);
1028 /* --- (signal) MessageMoved ------------------------------------------------------- */
1030 void
1031 opimd_message_folder_message_moved_handler(DBusGProxy * proxy,
1032 char *message_path, char *new_folder,
1033 gpointer userdata)
1035 (void)proxy;
1036 void (*callback) (char *message_path, char *new_folder) = NULL;
1038 callback = userdata;
1040 if (callback != NULL)
1041 (*callback) (message_path, new_folder);