Sync the flags using a mail operation. This way you'll get progress
[modest] / tests / dbus_api / test_search.c
1 #include <libmodest-dbus-client/libmodest-dbus-client.h>
2 #include <stdio.h>
3 #include <glib.h>
4
5 int main (int argc, char *argv[])
6 {
7         osso_context_t *osso_context;
8         gboolean res;
9         ModestDBusSearchFlags flags;
10         GList *hits, *iter;
11         const char *query;
12
13         osso_context = osso_initialize ("test_search",
14                                         "0.0.1",
15                                         TRUE,
16                                         NULL);
17
18
19         /* Check that initialization was ok */
20         if (osso_context == NULL) {
21                 g_printerr ("osso_initialize() failed.\n");
22                 return OSSO_ERROR;
23         }
24
25         hits = NULL;
26         flags = MODEST_DBUS_SEARCH_SUBJECT | MODEST_DBUS_SEARCH_BODY;
27
28         if (argc == 2) {
29                 query = argv[1];
30         } else {
31                 query = "no";
32         }
33
34         g_print ("Starting search (%s)...\n", query);
35
36         res = libmodest_dbus_client_search (osso_context,
37                                             query,
38                                             "",
39                                             0,
40                                             0,
41                                             0,
42                                             flags,
43                                             &hits);
44
45         g_print ("Search done. (success: %s)\n", res ? "yes" : "no");
46
47         for (iter = hits; iter; iter = iter->next) {
48                 ModestSearchHit *hit = (ModestSearchHit *) iter->data;
49
50                 g_print ("Hit: id: %s\n", hit->msgid);
51
52         }
53
54         modest_search_hit_list_free (hits);
55
56         return res ? 0 : -1;
57 }