Passing structure from Server to Client on DBus
ravikumar.paluri
ravikumar.paluri at azingo.com
Fri Jul 3 03:12:49 PDT 2009
Hi all,
I would like to fill and send a structure from Server to Client on
DBus.
The structure I want to send from server app is:
struct download_info
{
char *URL;
char *file_name;
long int content_length;
char *mime_type;
char *encoding;
};
The inrospection XML file contents are as below:
<?xml version ="1.0" encoding ="UTF-8"?>
<node>
<interface name="org.azingo.dlmgr">
<method name="download_getdownloadinfo">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="download_daemon_getdownloadinfo"/>
<arg type="i" name="download_handle" direction="in"/>
<arg type="(ssxss)" name="dl_info" direction="out"/>
<arg type="i" name="error" direction="out">
<annotation name="org.freedesktop.DBus.GLib.ReturnVal"
value="error"/>
</arg>
</method>
</interface>
</node>
The client side binding I generated for this is as below:
gboolean
org_azingo_dlmgr_download_getdownloadinfo (DBusGProxy *proxy, const gint
IN_download_handle, GValueArray** OUT_dl_info, gint* OUT_error, GError
**error)
{
return dbus_g_proxy_call (proxy, "download_getdownloadinfo", error,
G_TYPE_INT, IN_download_handle, G_TYPE_INVALID, dbus_g_type_get_struct
("GValueArray", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT64,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID), OUT_dl_info, G_TYPE_INT,
OUT_error, G_TYPE_INVALID);
}
For this I allocated memory on the client side as shown below:
GValueArray *gvalue_dl_info_client = NULL;
gvalue_dl_info_client = g_value_array_new(6);
and called
org_azingo_dlmgr_download_getdownloadinfo (remoteDldaemon,
20, &gvalue_dl_info_client, &error, &gerror);
On the server side, I did the following:
gint download_daemon_getdownloadinfo(DownloadDaemon* DaemonObject,
DOWNLOAD_HANDLE download_handle,
GValueArray **gvalue_dl_info,
GError** error)
{
DownloadManager* download_object = (DownloadManager*)download_handle;
dl_info = (download_info *)g_malloc0(sizeof(download_info));
dl_info->URL = "www.google.com";
dl_info->file_name = "azingo";
dl_info->content_length = 12344;
dl_info->mime_type = "image/jpg";
dl_info->encoding = "utf-8";
g_value_array_append (*gvalue_dl_info, NULL);
g_value_set_string (g_value_array_get_nth(*gvalue_dl_info, 0),
dl_info->URL);
g_value_array_append (*gvalue_dl_info, NULL);
g_value_set_string (g_value_array_get_nth(*gvalue_dl_info, 1),
dl_info->file_name);
g_value_array_append (*gvalue_dl_info, NULL);
g_value_set_long (g_value_array_get_nth(*gvalue_dl_info, 2),
dl_info->content_length);
g_value_array_append (*gvalue_dl_info, NULL);
g_value_set_string (g_value_array_get_nth(*gvalue_dl_info, 3),
dl_info->mime_type);
g_value_array_append (*gvalue_dl_info, NULL);
g_value_set_string (g_value_array_get_nth(*gvalue_dl_info, 4),
dl_info->encoding);
}
so, Ideally, *gvalue_dl_info should point to a valid memory since I
have allocated memory for it in the client app but I'm getting the
following assertion:
(process:22619): GLib-GObject-CRITICAL **: g_value_array_append:
assertion `value_array != NULL' failed
(process:22619): GLib-GObject-CRITICAL **: g_value_array_get_nth:
assertion `value_array != NULL' failed
Which in turn means that (*gvalue_dl_info == NULL)
The client and Server are two different processes.
So, is it possible to send the address of memory allocated in Client app
to Server app on DBus? If not, is there any other way to send a
structure from Server to Client?
Any pointers would be appreciated.
Thanks,
Ravi.
More information about the dbus
mailing list