2007-06-03 Christian Kellner <ckellner@openismus.com>
[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
12         osso_context = osso_initialize ("test_search",
13                                         "0.0.1",
14                                         TRUE,
15                                         NULL);
16
17
18         /* Check that initialization was ok */
19         if (osso_context == NULL) {
20                 g_printerr ("osso_initialize() failed.\n");
21                 return OSSO_ERROR;
22         }
23
24         hits = NULL;
25         flags = MODEST_DBUS_SEARCH_SUBJECT | MODEST_DBUS_SEARCH_BODY;
26
27         g_print ("Starting search ...\n");
28
29         res = libmodest_dbus_client_search (osso_context,
30                                             "no",
31                                             "",
32                                             0,
33                                             0,
34                                             0,
35                                             flags,
36                                             &hits);
37
38         g_print ("Search done. (success: %s)\n", res ? "yes" : "no");
39
40         for (iter = hits; iter; iter = iter->next) {
41                 ModestSearchHit *hit = (ModestSearchHit *) iter->data;
42
43                 g_print ("Hit: id: %s\n", hit->msgid);
44
45         }
46
47         return res ? 0 : -1;
48 }