<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>dbus-gvalue.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.15 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>dbus-gvalue.c</h1><div class="fragment"><pre>00001 <font class="preprocessor">#include <dbus-gvalue.h></font> 00002 00003 gboolean 00004 dbus_gvalue_demarshal (<a class="code" href="structDBusMessageIter.html">DBusMessageIter</a> *iter, GValue *value) 00005 { 00006 gboolean can_convert = TRUE; 00007 00008 <font class="keywordflow">switch</font> (dbus_message_iter_get_arg_type (iter)) 00009 { 00010 <font class="preprocessor">#define MAP(d_t, d_get, g_t, g_set) \</font> 00011 <font class="preprocessor"> case DBUS_##d_t: \</font> 00012 <font class="preprocessor"> g_value_init (value, G_##g_t); \</font> 00013 <font class="preprocessor"> g_value_##g_set (value, dbus_message_iter_##d_get (iter)); \</font> 00014 <font class="preprocessor"> break</font> 00015 <font class="preprocessor"></font> 00016 MAP(TYPE_BYTE, get_byte, TYPE_UCHAR, set_uchar); 00017 MAP(TYPE_BOOLEAN, get_boolean, TYPE_BOOLEAN , set_boolean); 00018 MAP(TYPE_INT32, get_int32, TYPE_INT , set_int); 00019 MAP(TYPE_UINT32, get_uint32, TYPE_UINT , set_uint); 00020 <font class="preprocessor">#ifdef DBUS_HAVE_INT64</font> 00021 <font class="preprocessor"></font> MAP(TYPE_INT64, get_int64, TYPE_INT64 , set_int64); 00022 MAP(TYPE_UINT64, get_uint64, TYPE_UINT64 , set_uint64); 00023 <font class="preprocessor">#endif</font> 00024 <font class="preprocessor"></font> MAP(TYPE_DOUBLE, get_double, TYPE_DOUBLE , set_double); 00025 <font class="keywordflow">case</font> DBUS_TYPE_STRING: 00026 { 00027 <font class="keywordtype">char</font> *s; <font class="comment">/* FIXME use a const string accessor */</font> 00028 00029 g_value_init (value, G_TYPE_STRING); 00030 00031 s = dbus_message_iter_get_string (iter); 00032 g_value_set_string (value, s); 00033 g_free (s); 00034 } 00035 <font class="keywordflow">break</font>; 00036 <font class="keywordflow">default</font>: 00037 <font class="comment">/* FIXME: we need to define custom boxed types for arrays</font> 00038 <font class="comment"> etc. so we can map them transparently / pleasantly */</font> 00039 can_convert = FALSE; 00040 <font class="keywordflow">break</font>; 00041 } 00042 <font class="preprocessor">#undef MAP</font> 00043 <font class="preprocessor"></font> <font class="keywordflow">return</font> can_convert; 00044 } 00045 00046 gboolean 00047 dbus_gvalue_marshal (<a class="code" href="structDBusMessageIter.html">DBusMessageIter</a> *iter, GValue *value) 00048 { 00049 gboolean can_convert = TRUE; 00050 GType value_type = G_VALUE_TYPE (value); 00051 00052 value_type = G_VALUE_TYPE (value); 00053 00054 <font class="keywordflow">switch</font> (value_type) 00055 { 00056 <font class="keywordflow">case</font> G_TYPE_CHAR: 00057 dbus_message_iter_append_byte (iter, 00058 g_value_get_char (value)); 00059 <font class="keywordflow">break</font>; 00060 <font class="keywordflow">case</font> G_TYPE_UCHAR: 00061 dbus_message_iter_append_byte (iter, 00062 g_value_get_uchar (value)); 00063 <font class="keywordflow">break</font>; 00064 <font class="keywordflow">case</font> G_TYPE_BOOLEAN: 00065 dbus_message_iter_append_boolean (iter, 00066 g_value_get_boolean (value)); 00067 <font class="keywordflow">break</font>; 00068 <font class="keywordflow">case</font> G_TYPE_INT: 00069 dbus_message_iter_append_int32 (iter, 00070 g_value_get_int (value)); 00071 <font class="keywordflow">break</font>; 00072 <font class="keywordflow">case</font> G_TYPE_UINT: 00073 dbus_message_iter_append_uint32 (iter, 00074 g_value_get_uint (value)); 00075 <font class="keywordflow">break</font>; 00076 <font class="comment">/* long gets cut to 32 bits so the remote API is consistent</font> 00077 <font class="comment"> * on all architectures</font> 00078 <font class="comment"> */</font> 00079 <font class="keywordflow">case</font> G_TYPE_LONG: 00080 dbus_message_iter_append_int32 (iter, 00081 g_value_get_long (value)); 00082 <font class="keywordflow">break</font>; 00083 <font class="keywordflow">case</font> G_TYPE_ULONG: 00084 dbus_message_iter_append_uint32 (iter, 00085 g_value_get_ulong (value)); 00086 <font class="keywordflow">break</font>; 00087 <font class="preprocessor">#ifdef DBUS_HAVE_INT64</font> 00088 <font class="preprocessor"></font> <font class="keywordflow">case</font> G_TYPE_INT64: 00089 dbus_message_iter_append_int64 (iter, 00090 g_value_get_int64 (value)); 00091 <font class="keywordflow">break</font>; 00092 <font class="keywordflow">case</font> G_TYPE_UINT64: 00093 dbus_message_iter_append_uint64 (iter, 00094 g_value_get_uint64 (value)); 00095 <font class="keywordflow">break</font>; 00096 <font class="preprocessor">#endif</font> 00097 <font class="preprocessor"></font> <font class="keywordflow">case</font> G_TYPE_FLOAT: 00098 dbus_message_iter_append_double (iter, 00099 g_value_get_float (value)); 00100 <font class="keywordflow">break</font>; 00101 <font class="keywordflow">case</font> G_TYPE_DOUBLE: 00102 dbus_message_iter_append_double (iter, 00103 g_value_get_double (value)); 00104 <font class="keywordflow">break</font>; 00105 <font class="keywordflow">case</font> G_TYPE_STRING: 00106 <font class="comment">/* FIXME, the GValue string may not be valid UTF-8 */</font> 00107 dbus_message_iter_append_string (iter, 00108 g_value_get_string (value)); 00109 <font class="keywordflow">break</font>; 00110 <font class="keywordflow">default</font>: 00111 <font class="comment">/* FIXME: we need to define custom boxed types for arrays</font> 00112 <font class="comment"> etc. so we can map them transparently / pleasantly */</font> 00113 can_convert = FALSE; 00114 <font class="keywordflow">break</font>; 00115 } 00116 00117 <font class="keywordflow">return</font> can_convert; 00118 } 00119 </pre></div><hr><address align="right"><small>Generated on Wed Jun 9 05:01:25 2004 for D-BUS by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.15 </small></address> </body> </html>