2003-04-14 03:25:19 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu" -*- */
|
|
|
|
|
/* dbus-send.c Utility program to send messages from the command line
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Philip Blundell <philb@gnu.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
|
2003-05-16 20:09:25 +00:00
|
|
|
#include "dbus-print-message.h"
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
static void
|
2003-05-18 02:39:47 +00:00
|
|
|
usage (char *name, int ecode)
|
2003-04-14 03:25:19 +00:00
|
|
|
{
|
2004-08-11 14:59:34 +00:00
|
|
|
fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--type=TYPE] [--print-reply] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", name);
|
2003-05-18 02:39:47 +00:00
|
|
|
exit (ecode);
|
2003-04-14 03:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
DBusError error;
|
|
|
|
|
DBusMessage *message;
|
2003-05-16 20:09:25 +00:00
|
|
|
int print_reply;
|
2004-08-11 14:59:34 +00:00
|
|
|
int reply_timeout;
|
2003-04-14 03:25:19 +00:00
|
|
|
DBusMessageIter iter;
|
|
|
|
|
int i;
|
2003-05-18 02:39:47 +00:00
|
|
|
DBusBusType type = DBUS_BUS_SESSION;
|
2003-09-21 19:53:56 +00:00
|
|
|
const char *dest = NULL;
|
2003-08-31 01:51:44 +00:00
|
|
|
const char *name = NULL;
|
|
|
|
|
const char *path = NULL;
|
2003-08-11 02:11:58 +00:00
|
|
|
int message_type = DBUS_MESSAGE_TYPE_SIGNAL;
|
|
|
|
|
const char *type_str = NULL;
|
|
|
|
|
|
2003-08-31 01:51:44 +00:00
|
|
|
if (argc < 3)
|
2003-05-18 02:39:47 +00:00
|
|
|
usage (argv[0], 1);
|
2003-04-14 03:25:19 +00:00
|
|
|
|
2003-05-16 20:09:25 +00:00
|
|
|
print_reply = FALSE;
|
2004-08-11 14:59:34 +00:00
|
|
|
reply_timeout = -1;
|
2003-05-16 20:09:25 +00:00
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
for (i = 1; i < argc && name == NULL; i++)
|
|
|
|
|
{
|
|
|
|
|
char *arg = argv[i];
|
|
|
|
|
|
2003-05-18 02:39:47 +00:00
|
|
|
if (strcmp (arg, "--system") == 0)
|
|
|
|
|
type = DBUS_BUS_SYSTEM;
|
2003-06-19 22:22:37 +00:00
|
|
|
else if (strcmp (arg, "--session") == 0)
|
|
|
|
|
type = DBUS_BUS_SESSION;
|
2003-05-16 20:09:25 +00:00
|
|
|
else if (strcmp (arg, "--print-reply") == 0)
|
2004-03-27 05:29:31 +00:00
|
|
|
{
|
|
|
|
|
print_reply = TRUE;
|
|
|
|
|
message_type = DBUS_MESSAGE_TYPE_METHOD_CALL;
|
|
|
|
|
}
|
2004-08-11 14:59:34 +00:00
|
|
|
else if (strstr (arg, "--reply-timeout=") == arg)
|
|
|
|
|
{
|
|
|
|
|
reply_timeout = strtol (strchr (arg, '=') + 1,
|
|
|
|
|
NULL, 10);
|
|
|
|
|
}
|
2003-04-14 03:25:19 +00:00
|
|
|
else if (strstr (arg, "--dest=") == arg)
|
|
|
|
|
dest = strchr (arg, '=') + 1;
|
2003-08-11 02:11:58 +00:00
|
|
|
else if (strstr (arg, "--type=") == arg)
|
|
|
|
|
type_str = strchr (arg, '=') + 1;
|
2003-05-18 02:39:47 +00:00
|
|
|
else if (!strcmp(arg, "--help"))
|
|
|
|
|
usage (argv[0], 0);
|
2003-04-14 03:25:19 +00:00
|
|
|
else if (arg[0] == '-')
|
2003-05-18 02:39:47 +00:00
|
|
|
usage (argv[0], 1);
|
2003-08-31 01:51:44 +00:00
|
|
|
else if (path == NULL)
|
|
|
|
|
path = arg;
|
|
|
|
|
else if (name == NULL)
|
|
|
|
|
name = arg;
|
2003-04-14 03:25:19 +00:00
|
|
|
else
|
2003-08-31 01:51:44 +00:00
|
|
|
usage (argv[0], 1);
|
2003-04-14 03:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
2003-05-18 02:39:47 +00:00
|
|
|
usage (argv[0], 1);
|
2003-04-14 03:25:19 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (type_str != NULL)
|
|
|
|
|
{
|
2003-10-10 02:42:21 +00:00
|
|
|
message_type = dbus_message_type_from_string (type_str);
|
|
|
|
|
if (!(message_type == DBUS_MESSAGE_TYPE_METHOD_CALL ||
|
|
|
|
|
message_type == DBUS_MESSAGE_TYPE_SIGNAL))
|
2003-08-11 02:11:58 +00:00
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Message type \"%s\" is not supported\n",
|
|
|
|
|
type_str);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
dbus_error_init (&error);
|
|
|
|
|
connection = dbus_bus_get (type, &error);
|
|
|
|
|
if (connection == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Failed to open connection to %s message bus: %s\n",
|
|
|
|
|
(type == DBUS_BUS_SYSTEM) ? "system" : "session",
|
|
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL)
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
char *last_dot;
|
|
|
|
|
|
|
|
|
|
last_dot = strrchr (name, '.');
|
|
|
|
|
if (last_dot == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Must use org.mydomain.Interface.Method notation, no dot in \"%s\"\n",
|
|
|
|
|
name);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
*last_dot = '\0';
|
|
|
|
|
|
2003-08-31 01:51:44 +00:00
|
|
|
message = dbus_message_new_method_call (NULL,
|
|
|
|
|
path,
|
|
|
|
|
name,
|
|
|
|
|
last_dot + 1);
|
2003-08-11 02:11:58 +00:00
|
|
|
}
|
|
|
|
|
else if (message_type == DBUS_MESSAGE_TYPE_SIGNAL)
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
char *last_dot;
|
|
|
|
|
|
|
|
|
|
last_dot = strrchr (name, '.');
|
|
|
|
|
if (last_dot == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Must use org.mydomain.Interface.Signal notation, no dot in \"%s\"\n",
|
|
|
|
|
name);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
*last_dot = '\0';
|
|
|
|
|
|
2003-08-31 01:51:44 +00:00
|
|
|
message = dbus_message_new_signal (path, name, last_dot + 1);
|
2003-08-11 02:11:58 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Internal error, unknown message type\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Couldn't allocate D-BUS message\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dest && !dbus_message_set_destination (message, dest))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Not enough memory\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
dbus_message_append_iter_init (message, &iter);
|
|
|
|
|
|
|
|
|
|
while (i < argc)
|
|
|
|
|
{
|
|
|
|
|
char *arg;
|
|
|
|
|
char *c;
|
|
|
|
|
int type;
|
|
|
|
|
dbus_uint32_t uint32;
|
|
|
|
|
dbus_int32_t int32;
|
|
|
|
|
double d;
|
|
|
|
|
unsigned char byte;
|
|
|
|
|
|
|
|
|
|
type = DBUS_TYPE_INVALID;
|
|
|
|
|
arg = argv[i++];
|
|
|
|
|
c = strchr (arg, ':');
|
|
|
|
|
|
|
|
|
|
if (c == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "%s: Data item \"%s\" is badly formed\n", argv[0], arg);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*(c++) = 0;
|
|
|
|
|
|
|
|
|
|
if (arg[0] == 0 || !strcmp (arg, "string"))
|
|
|
|
|
type = DBUS_TYPE_STRING;
|
|
|
|
|
else if (!strcmp (arg, "int32"))
|
|
|
|
|
type = DBUS_TYPE_INT32;
|
|
|
|
|
else if (!strcmp (arg, "uint32"))
|
|
|
|
|
type = DBUS_TYPE_UINT32;
|
|
|
|
|
else if (!strcmp (arg, "double"))
|
|
|
|
|
type = DBUS_TYPE_DOUBLE;
|
|
|
|
|
else if (!strcmp (arg, "byte"))
|
|
|
|
|
type = DBUS_TYPE_BYTE;
|
|
|
|
|
else if (!strcmp (arg, "boolean"))
|
|
|
|
|
type = DBUS_TYPE_BOOLEAN;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "%s: Unknown type \"%s\"\n", argv[0], arg);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
/* FIXME - we are ignoring OOM returns on all these functions */
|
2003-04-14 03:25:19 +00:00
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case DBUS_TYPE_BYTE:
|
|
|
|
|
byte = strtoul (c, NULL, 0);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_BYTE, &byte);
|
2003-04-14 03:25:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DBUS_TYPE_DOUBLE:
|
|
|
|
|
d = strtod (c, NULL);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_DOUBLE, &d);
|
2003-04-14 03:25:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DBUS_TYPE_INT32:
|
|
|
|
|
int32 = strtol (c, NULL, 0);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &int32);
|
2003-04-14 03:25:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DBUS_TYPE_UINT32:
|
|
|
|
|
uint32 = strtoul (c, NULL, 0);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &uint32);
|
2003-04-14 03:25:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DBUS_TYPE_STRING:
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &c);
|
2003-04-14 03:25:19 +00:00
|
|
|
break;
|
|
|
|
|
|
2004-03-27 05:29:31 +00:00
|
|
|
case DBUS_TYPE_BOOLEAN:
|
|
|
|
|
if (strcmp(c, "true") == 0)
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
{
|
|
|
|
|
byte = TRUE;
|
|
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &c);
|
|
|
|
|
}
|
2004-03-27 05:29:31 +00:00
|
|
|
else if (strcmp(c, "false") == 0)
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
{
|
|
|
|
|
byte = FALSE;
|
|
|
|
|
dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &c);
|
|
|
|
|
}
|
2004-03-27 05:29:31 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "%s: Expected \"true\" or \"false\" instead of \"%s\"\n", argv[0], c);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
default:
|
|
|
|
|
fprintf (stderr, "%s: Unsupported data type\n", argv[0]);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-16 20:09:25 +00:00
|
|
|
if (print_reply)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
reply = dbus_connection_send_with_reply_and_block (connection,
|
2004-08-11 14:59:34 +00:00
|
|
|
message, reply_timeout,
|
2003-05-16 20:09:25 +00:00
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Error: %s\n",
|
|
|
|
|
error.message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reply)
|
|
|
|
|
{
|
|
|
|
|
print_message (reply);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_connection_send (connection, message, NULL);
|
|
|
|
|
dbus_connection_flush (connection);
|
|
|
|
|
}
|
2003-04-14 03:25:19 +00:00
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
dbus_connection_disconnect (connection);
|
|
|
|
|
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|