2007-06-19 Murray Cumming,,, <murrayc@murrayc-desktop>
[modest] / libmodest-dbus-client / libmodest-dbus-client.c
1 /* Copyright (c) 2007, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "libmodest-dbus-client.h"
31 #include <dbus_api/modest-dbus-api.h> /* For the API strings. */
32
33 //#define DBUS_API_SUBJECT_TO_CHANGE 1
34 #include <dbus/dbus.h>
35 #include <dbus/dbus-glib-lowlevel.h>
36 #include <string.h>
37
38
39
40 /** Get a comma-separated list of attachement URI strings, 
41  * from a list of strings.
42  */
43 static gchar* get_attachments_string (GSList *attachments)
44 {
45         if (!attachments)
46                 return NULL;
47                 
48         gchar *attachments_str = g_strdup("");
49         
50         GSList *iter = attachments;
51         while (iter)
52         {
53                 if (iter->data) {
54                         gchar *tmp = g_strconcat(attachments_str, ",", (gchar *) (iter->data), NULL);
55                         g_free(attachments_str);
56                         attachments_str = tmp;
57                 }
58                 
59                 iter = g_slist_next(iter);
60         }
61         
62         return attachments_str;
63 }
64
65 /* TODO: Is this actually used by anything?
66  * I guess that everything uses *_compose_mail() instead. murrayc.
67  */
68  
69 /**
70  * libmodest_dbus_client_send_mail:
71  * @osso_context: a valid #osso_context_t object.
72  * @to: The Recipients (From: line)
73  * @cc: Recipients for carbon copies
74  * @bcc: Recipients for blind carbon copies
75  * @subject: Subject line
76  * @body: The actual body of the mail to send
77  * @attachments: Additional list of attachments
78  * 
79  * This function will try to do a remote procedure call (rpc)
80  * into modest (or start it if necessary) and send a new 
81  * email with the supplied parameters.
82  *
83  * Return value: Whether or not the rpc call to modest
84  * was successfull
85  **/
86 gboolean
87 libmodest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc, 
88         const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments)
89 {
90         gchar *attachments_str = get_attachments_string(attachments);
91         
92         osso_rpc_t retval;
93         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
94                    MODEST_DBUS_NAME, 
95                    MODEST_DBUS_METHOD_SEND_MAIL, &retval, 
96                    DBUS_TYPE_STRING, to, 
97                    DBUS_TYPE_STRING, cc, 
98                    DBUS_TYPE_STRING, bcc, 
99                    DBUS_TYPE_STRING, subject, 
100                    DBUS_TYPE_STRING, body, 
101                    DBUS_TYPE_STRING, attachments_str,
102                    DBUS_TYPE_INVALID);
103                 
104         if (ret != OSSO_OK) {
105                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
106                 return FALSE;
107         } else {
108                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
109         }
110         
111         osso_rpc_free_val(&retval);
112         
113         g_free (attachments_str);
114         
115         return TRUE;
116 }
117         
118 gboolean 
119 libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto_uri)
120 {
121         osso_rpc_t retval;
122         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
123                    MODEST_DBUS_NAME, 
124                    MODEST_DBUS_METHOD_MAIL_TO, &retval, 
125                    DBUS_TYPE_STRING, mailto_uri, 
126                    DBUS_TYPE_INVALID);
127                 
128         if (ret != OSSO_OK) {
129                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
130                 return FALSE;
131         } else {
132                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
133         }
134         
135         osso_rpc_free_val(&retval);
136         
137         return TRUE;
138 }
139
140 /**
141  * libmodest_dbus_client_compose_mail:
142  * @osso_context: a valid #osso_context_t object.
143  * @to: The Recipients (From: line)
144  * @cc: Recipients for carbon copies
145  * @bcc: Recipients for blind carbon copies
146  * @subject: Subject line
147  * @body: The actual body of the mail to send
148  * @attachments: Additional list of attachments
149  * 
150  * This function will try to do a remote procedure call (rpc)
151  * into modest (or start it if necessary) and open a composer
152  * window with the supplied parameters prefilled.
153  *
154  * Return value: Whether or not the rpc call to modest
155  * was successfull
156  **/
157 gboolean
158 libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc, 
159         const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments)
160 {
161         osso_rpc_t retval;
162         
163         gchar *attachments_str = get_attachments_string(attachments);
164
165         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
166                    MODEST_DBUS_NAME, 
167                    MODEST_DBUS_METHOD_COMPOSE_MAIL, &retval, 
168                    DBUS_TYPE_STRING, to, 
169                    DBUS_TYPE_STRING, cc, 
170                    DBUS_TYPE_STRING, bcc, 
171                    DBUS_TYPE_STRING, subject, 
172                    DBUS_TYPE_STRING, body,
173                    DBUS_TYPE_STRING, attachments_str,
174                    DBUS_TYPE_INVALID);
175                 
176         if (ret != OSSO_OK) {
177                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
178                 return FALSE;
179         } else {
180                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
181         }
182         
183         osso_rpc_free_val(&retval);
184
185         g_free (attachments_str);
186         
187         return TRUE;
188 }
189
190 /**
191  * libmodest_dbus_client_open_message:
192  * @osso_context: a valid #osso_context_t object.
193  * @msg_uri: A valid url to a mail
194  *
195  * This method will try to find the message supplied
196  * by @msg_uri and open it for display if found. 
197  * It will use remote procedure calls (rpc) over 
198  * dbus to do so.
199  *  
200  * Return value: TRUE on successs, FALSE on error
201  **/
202 gboolean 
203 libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *mail_uri)
204 {
205         osso_rpc_t retval;
206         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
207                    MODEST_DBUS_NAME, 
208                    MODEST_DBUS_METHOD_OPEN_MESSAGE, &retval, 
209                    DBUS_TYPE_STRING, mail_uri, 
210                    DBUS_TYPE_INVALID);
211                 
212         if (ret != OSSO_OK) {
213                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
214                 return FALSE;
215         } else {
216                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
217         }
218         
219         osso_rpc_free_val(&retval);
220         
221         return TRUE;
222 }
223
224 gboolean 
225 libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
226 {
227         osso_rpc_t retval;
228         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
229                    MODEST_DBUS_NAME, 
230                    MODEST_DBUS_METHOD_SEND_RECEIVE, &retval, 
231                    DBUS_TYPE_INVALID);
232                 
233         if (ret != OSSO_OK) {
234                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
235                 return FALSE;
236         } else {
237                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
238         }
239         
240         osso_rpc_free_val(&retval);
241         
242         return TRUE;
243 }
244
245 gboolean 
246 libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context)
247 {
248         osso_rpc_t retval;
249         const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
250                    MODEST_DBUS_NAME, 
251                    MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX, &retval, 
252                    DBUS_TYPE_INVALID);
253                 
254         if (ret != OSSO_OK) {
255                 printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
256                 return FALSE;
257         } else {
258                 printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
259         }
260         
261         osso_rpc_free_val(&retval);
262         
263         return TRUE;
264 }
265
266 /**
267  * libmodest_dbus_client_delete_message:
268  * @osso_context: a valid #osso_context_t object.
269  * @msg_uri: A valid url to a mail 
270  *
271  * This method will try to find the message supplied
272  * by @msg_uri and if found delete it. It will use
273  * remote procedure calls (rpc) over dbus to do so.
274  * 
275  * Return value: TRUE on successs, FALSE on error
276  **/
277 gboolean
278 libmodest_dbus_client_delete_message (osso_context_t   *osso_ctx,
279                                       const char       *msg_uri)
280 {
281         osso_rpc_t    retval;
282         osso_return_t ret;
283        
284         ret = osso_rpc_run_with_defaults (osso_ctx, 
285                                           MODEST_DBUS_NAME, 
286                                           MODEST_DBUS_METHOD_DELETE_MESSAGE, &retval, 
287                                           DBUS_TYPE_STRING, msg_uri, 
288                                           DBUS_TYPE_INVALID);
289                 
290         if (ret != OSSO_OK) {
291                 g_debug ("debug: osso_rpc_run() failed.\n");
292         } else {
293                 g_debug ("debug: osso_rpc_run() succeeded.\n");
294         }
295         
296         osso_rpc_free_val (&retval);
297
298         return ret == OSSO_OK;
299 }
300
301 void
302 modest_search_hit_free (ModestSearchHit *hit)
303 {
304         g_free (hit->msgid);
305         g_slice_free (ModestSearchHit, hit);
306 }
307
308 void
309 modest_search_hit_list_free (GList *hits)
310 {
311         GList *iter;
312
313         if (hits == NULL) {
314                 return;
315         }
316
317         for (iter = hits; iter; iter = iter->next) {
318                 modest_search_hit_free ((ModestSearchHit *) iter->data);
319         }
320
321         g_list_free (hits);
322 }
323
324 static char *
325 _dbus_iter_get_string_or_null (DBusMessageIter *iter)
326 {
327         const char *string = NULL;
328         char       *ret = NULL;
329
330         dbus_message_iter_get_basic (iter, &string);
331         
332         if (string && strlen (string)) {
333                 ret = g_strdup (string);
334         }
335
336         return ret;
337 }
338
339 static guint64
340 _dbus_iter_get_uint64 (DBusMessageIter *iter)
341 {
342         dbus_uint64_t ui64v;
343         guint64       ret;
344
345         ui64v = 0;
346         dbus_message_iter_get_basic (iter, &ui64v);
347
348         ret = (guint64) ui64v;
349
350         return ret;
351 }
352
353
354 static gint64
355 _dbus_iter_get_int64 (DBusMessageIter *iter)
356 {
357         dbus_int64_t i64v;
358         gint64       ret;
359
360         i64v = 0;
361         dbus_message_iter_get_basic (iter, &i64v);
362
363         ret = (gint64) i64v;
364
365         return ret;
366 }
367
368 static gboolean
369 _dbus_iter_get_boolean (DBusMessageIter *iter)
370
371 {
372         dbus_bool_t  val;
373         gboolean     ret;
374
375         val = FALSE;
376         dbus_message_iter_get_basic (iter, &val);
377
378         ret = (gboolean) val;
379
380         return ret;
381 }
382
383
384 static ModestSearchHit *
385 dbus_message_iter_get_search_hit (DBusMessageIter *parent)
386 {
387         ModestSearchHit *hit;
388         DBusMessageIter  child;
389         dbus_bool_t      res;
390         int              arg_type;
391         gboolean         error;
392
393         error = FALSE;
394         hit = g_slice_new0 (ModestSearchHit);
395
396         arg_type = dbus_message_iter_get_arg_type (parent);
397
398         if (arg_type != 'r') {
399                 return NULL;
400         }
401
402         dbus_message_iter_recurse (parent, &child);
403         
404         /* msgid  */
405         arg_type = dbus_message_iter_get_arg_type (&child);
406
407         if (arg_type != DBUS_TYPE_STRING) {
408                 error = TRUE;
409                 goto out;
410         }
411
412         hit->msgid = _dbus_iter_get_string_or_null (&child);
413
414         res = dbus_message_iter_next (&child);
415         if (res == FALSE) {
416                 error = TRUE;
417                 goto out;
418         }
419
420         /* subject  */
421         arg_type = dbus_message_iter_get_arg_type (&child);
422
423         if (arg_type != DBUS_TYPE_STRING) {
424                 error = TRUE;
425                 goto out;
426         }
427
428         hit->subject = _dbus_iter_get_string_or_null (&child);
429
430         res = dbus_message_iter_next (&child);
431         if (res == FALSE) {
432                 error = TRUE;
433                 goto out;
434         }
435
436         /* folder  */
437         arg_type = dbus_message_iter_get_arg_type (&child);
438
439         if (arg_type != DBUS_TYPE_STRING) {
440                 error = TRUE;
441                 goto out;
442         }
443
444         hit->folder = _dbus_iter_get_string_or_null (&child);
445
446         res = dbus_message_iter_next (&child);
447         if (res == FALSE) {
448                 error = TRUE;
449                 goto out;
450         }
451
452         /* sender  */
453         arg_type = dbus_message_iter_get_arg_type (&child);
454
455         if (arg_type != DBUS_TYPE_STRING) {
456                 error = TRUE;
457                 goto out;
458         }
459
460         hit->sender = _dbus_iter_get_string_or_null (&child);
461
462         res = dbus_message_iter_next (&child);
463         if (res == FALSE) {
464                 error = TRUE;
465                 goto out;
466         }
467
468         /* msize  */
469         arg_type = dbus_message_iter_get_arg_type (&child);
470
471         if (arg_type != DBUS_TYPE_UINT64) {
472                 error = TRUE;
473                 goto out;
474         }
475
476         hit->msize = _dbus_iter_get_uint64 (&child);
477
478         res = dbus_message_iter_next (&child);
479         if (res == FALSE) {
480                 error = TRUE;
481                 goto out;
482         }
483
484         /* has_attachment  */
485         arg_type = dbus_message_iter_get_arg_type (&child);
486
487         if (arg_type != DBUS_TYPE_BOOLEAN) {
488                 error = TRUE;
489                 goto out;
490         }
491
492         hit->has_attachment = _dbus_iter_get_boolean (&child); 
493
494         res = dbus_message_iter_next (&child);
495         if (res == FALSE) {
496                 error = TRUE;
497                 goto out;
498         }
499
500         /* is_unread  */
501         arg_type = dbus_message_iter_get_arg_type (&child);
502
503         if (arg_type != DBUS_TYPE_BOOLEAN) {
504                 error = TRUE;
505                 goto out;
506         }
507
508         hit->is_unread = _dbus_iter_get_boolean (&child);  
509
510         res = dbus_message_iter_next (&child);
511         if (res == FALSE) {
512                 error = TRUE;
513                 goto out;
514         }
515
516         /* msize  */
517         arg_type = dbus_message_iter_get_arg_type (&child);
518
519         if (arg_type != DBUS_TYPE_INT64) {
520                 error = TRUE;
521                 goto out;
522         }
523
524         hit->timestamp = _dbus_iter_get_int64 (&child); 
525
526         res = dbus_message_iter_next (&child);
527         if (res == TRUE) {
528                 error = TRUE;
529                 goto out;
530         }       
531
532 out:
533         if (error) {
534                 g_warning ("Error during unmarshaling");
535                 modest_search_hit_free (hit);
536                 hit = NULL;
537         }
538
539         return hit;
540 }
541
542 /**
543  * libmodest_dbus_client_search:
544  * @osso_ctx: A valid #osso_context_t object.
545  * @query: The term to search for.
546  * @folder: An url to specific folder or %NULL to search everywhere.
547  * @start_date: Search hits before this date will be ignored.
548  * @end_date: Search hits after this date will be ignored.
549  * @min_size: Messagers smaller then this size will be ingored.
550  * @flags: A list of flags where to search so the documentation 
551  * of %ModestDBusSearchFlags for details.
552  * @hits: A pointer to a valid GList pointer that will contain the search
553  * hits (ModestSearchHit). The list and the items must be freed by the caller 
554  * with modest_search_hit_list_free().
555  *
556  * This method will search the folder specified by a valid url in @folder or all
557  * known accounts (local and remote) if %NULL for matches of the search term(s)
558  * specified in @query. It is legal to specify 0 in @start_date, @end_date and
559  * @min_size to ignore these parameters during the search otherwise those message
560  * that do not meet the specifed dates or size will be ignored.
561  * Where to search, be it subject, sender or the whole body can be specified by
562  * the @flags parameter.
563  *
564  * Upon success TRUE is returned and @hits will include the search hits or the list
565  * migh be empty if none of the messages matched the search criteria. The returned
566  * list must be freed with modest_search_hit_list_free (). It is save to pass
567  * %NULL to this function so you can call this function on the result list no matter
568  * if a hit was found or not (means the list is empty - i.e. %NULL)
569  * FALSE will only be return if an error during the remote procedure call (rpc) 
570  * occured or if the specified folder could not be found.
571  *
572  * NOTE: The body of a message can only be searched if it was previously downloaded by
573  * modest. This function does also not attempt do to remote searches (i.e. IMAP search).
574  *
575  * Example to search every account for message containing "no":
576  * <informalexample><programlisting>
577  * ModestDBusSearchFlags  flags;
578  * osso_context_t        *osso_context;
579  * GList                 *hits;
580  * GList                 *iter;
581  * gboolean               res;
582  * 
583  * [...] Initialize osso context [...]
584  *
585  * res = libmodest_dbus_client_search (osso_context,
586  *                                     "no",
587  *                                     NULL,
588  *                                     0,
589  *                                     0,
590  *                                     0,
591  *                                     flags,
592  *                                     &hits);
593  * 
594  * for (iter = hits; iter; iter = iter->next) {
595  *      ModestSearchHit *hit = (ModestSearchHit *) iter->data;
596  *      
597  *      [...] Do something with the hit [...]
598  *
599  *      }
600  *
601  *      modest_search_hit_list_free (hits);
602  * </programlisting></informalexample>
603  * 
604  * Return value: TRUE if the search succeded or FALSE for an error during the search
605  **/
606 gboolean
607 libmodest_dbus_client_search (osso_context_t          *osso_ctx,
608                               const gchar             *query,
609                               const gchar             *folder,
610                               time_t                   start_date,
611                               time_t                   end_date,
612                               guint32                  min_size,
613                               ModestDBusSearchFlags    flags,
614                               GList                  **hits)
615 {
616
617         DBusMessage *msg;
618         dbus_bool_t res;
619         DBusError err;
620         DBusConnection *con;
621         DBusMessageIter iter;
622         DBusMessageIter child;
623         DBusMessage *reply = NULL;
624         gint timeout;
625         int          arg_type;
626         dbus_int64_t sd_v;
627         dbus_int64_t ed_v;
628         dbus_int32_t flags_v;
629         dbus_uint32_t size_v;
630
631         if (query == NULL) {
632                 return FALSE;
633         }
634
635         con = osso_get_dbus_connection (osso_ctx);
636
637         if (con == NULL) {
638                 g_warning ("Could not get dbus connection\n");
639                 return FALSE;
640
641         }
642
643
644         msg = dbus_message_new_method_call (MODEST_DBUS_SERVICE,
645                                             MODEST_DBUS_OBJECT,
646                                             MODEST_DBUS_IFACE,
647                                             MODEST_DBUS_METHOD_SEARCH);
648
649         if (msg == NULL) {
650                 //ULOG_ERR_F("dbus_message_new_method_call failed");
651                 return OSSO_ERROR;
652         }
653
654         if (folder == NULL) {
655                 folder = "";
656         }
657
658         sd_v = start_date;
659         ed_v = end_date;
660         flags_v = (dbus_int32_t) flags;
661         size_v = (dbus_uint32_t) min_size;
662
663         res  = dbus_message_append_args (msg,
664                                          DBUS_TYPE_STRING, &query,
665                                          DBUS_TYPE_STRING, &folder,
666                                          DBUS_TYPE_INT64, &sd_v,
667                                          DBUS_TYPE_INT64, &ed_v,
668                                          DBUS_TYPE_INT32, &flags_v,
669                                          DBUS_TYPE_UINT32, &size_v,
670                                          DBUS_TYPE_INVALID);
671
672         dbus_message_set_auto_start (msg, TRUE);
673
674         dbus_error_init (&err);
675
676         timeout = 1000; //XXX
677         osso_rpc_get_timeout (osso_ctx, &timeout);
678
679         reply = dbus_connection_send_with_reply_and_block (con,
680                                                            msg, 
681                                                            timeout,
682                                                            &err);
683
684         dbus_message_unref (msg);
685
686
687         if (reply == NULL) {
688             //ULOG_ERR_F("dbus_connection_send_with_reply_and_block error: %s", err.message);
689             //XXX to GError?! 
690             return FALSE;
691         }
692
693         switch (dbus_message_get_type (reply)) {
694
695                 case DBUS_MESSAGE_TYPE_ERROR:
696                         dbus_set_error_from_message (&err, reply);
697                         //XXX to GError?!
698                         dbus_error_free (&err);
699                         dbus_message_unref (reply);
700                         return FALSE;
701
702                 case DBUS_MESSAGE_TYPE_METHOD_RETURN:
703                         /* ok we are good to go
704                          * lets drop outa here and handle that */
705                         break;
706                 default:
707                         //ULOG_WARN_F("got unknown message type as reply");
708                         //retval->type = DBUS_TYPE_STRING;
709                         //retval->value.s = g_strdup("Invalid return value");
710                         //XXX to GError?! 
711                         dbus_message_unref (reply);
712                         return FALSE;
713         }
714
715         g_debug ("message return");
716
717         dbus_message_iter_init (reply, &iter);
718         arg_type = dbus_message_iter_get_arg_type (&iter);
719         
720         dbus_message_iter_recurse (&iter, &child);
721         *hits = NULL;
722
723         do {
724                 ModestSearchHit *hit;
725
726                 hit = dbus_message_iter_get_search_hit (&child);
727
728                 if (hit) {
729                         *hits = g_list_prepend (*hits, hit);    
730                 }
731
732         } while (dbus_message_iter_next (&child));
733
734         dbus_message_unref (reply);
735
736
737         /* TODO: This is from osso source, do we need it? */
738 #if 0
739         /* Tell TaskNavigator to show "launch banner" */
740         msg = dbus_message_new_method_call (TASK_NAV_SERVICE,
741                                             APP_LAUNCH_BANNER_METHOD_PATH,
742                                             APP_LAUNCH_BANNER_METHOD_INTERFACE,
743                                             APP_LAUNCH_BANNER_METHOD);
744
745         if (msg == NULL) {
746                 g_warn ("dbus_message_new_method_call failed");
747         }
748
749
750
751         dbus_message_append_args (msg,
752                                   DBUS_TYPE_STRING,
753                                   &service,
754                                   DBUS_TYPE_INVALID);
755
756         b = dbus_connection_send (conn, msg, NULL);
757
758         if (b == NULL) {
759                 ULOG_WARN_F("dbus_connection_send failed");
760         }
761
762         dbus_message_unref (msg);
763 #endif
764
765         return TRUE;
766 }
767