Don't return DBUS_HANDLER_RESULT_HANDLED for NameOwnerChanged signals
[platform/core/uifw/at-spi2-atk.git] / droute / droute-variant.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2008 Novell, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include "glib.h"
26
27 #include "droute-variant.h"
28
29 /*---------------------------------------------------------------------------*/
30
31 dbus_bool_t
32 droute_return_v_int32 (DBusMessageIter *iter, dbus_int32_t val)
33 {
34     DBusMessageIter sub;
35
36     if (!dbus_message_iter_open_container
37         (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &sub))
38       {
39         return FALSE;
40       }
41     dbus_message_iter_append_basic (&sub, DBUS_TYPE_INT32, &val);
42     dbus_message_iter_close_container (iter, &sub);
43     return TRUE;
44 }
45
46 dbus_bool_t
47 droute_return_v_double (DBusMessageIter *iter, double val)
48 {
49     DBusMessageIter sub;
50
51     if (!dbus_message_iter_open_container
52         (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_DOUBLE_AS_STRING, &sub))
53       {
54         return FALSE;
55       }
56     dbus_message_iter_append_basic (&sub, DBUS_TYPE_DOUBLE, &val);
57     dbus_message_iter_close_container (iter, &sub);
58     return TRUE;
59 }
60
61 dbus_bool_t
62 droute_return_v_string (DBusMessageIter *iter, const char *val)
63 {
64     DBusMessageIter sub;
65
66     if (!val)
67       val = "";
68     if (!g_utf8_validate (val, -1, NULL))
69       {
70         g_warning ("droute: Received bad UTF-8 string");
71         val = "";
72       }
73
74     if (!dbus_message_iter_open_container
75         (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &sub))
76       {
77         return FALSE;
78       }
79     dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING, &val);
80     dbus_message_iter_close_container (iter, &sub);
81     return TRUE;
82 }
83
84 dbus_bool_t
85 droute_return_v_object (DBusMessageIter *iter, const char *path)
86 {
87     DBusMessageIter sub;
88
89     if (!dbus_message_iter_open_container
90         (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &sub))
91       {
92         return FALSE;
93       }
94     dbus_message_iter_append_basic (&sub, DBUS_TYPE_OBJECT_PATH, &path);
95     dbus_message_iter_close_container (iter, &sub);
96     return TRUE;
97 }
98
99 /*---------------------------------------------------------------------------*/
100
101 dbus_int32_t
102 droute_get_v_int32 (DBusMessageIter *iter)
103 {
104     DBusMessageIter sub;
105     dbus_int32_t rv;
106
107     // TODO- ensure we have the correct type
108     dbus_message_iter_recurse (iter, &sub);
109     dbus_message_iter_get_basic (&sub, &rv);
110     return rv;
111 }
112
113 const char *
114 droute_get_v_string (DBusMessageIter *iter)
115 {
116     DBusMessageIter sub;
117     char *rv;
118
119     // TODO- ensure we have the correct type
120     dbus_message_iter_recurse (iter, &sub);
121     dbus_message_iter_get_basic (&sub, &rv);
122     return rv;
123 }
124
125 /*END------------------------------------------------------------------------*/