2007-07-14 02:44:01 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2003-04-14 03:25:19 +00:00
|
|
|
/* dbus-monitor.c Utility program to monitor messages on the bus
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2009-07-10 19:32:38 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-14 03:25:19 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2006-12-31 11:31:12 +00:00
|
|
|
#include <config.h>
|
2003-04-14 03:25:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2006-12-31 12:20:54 +00:00
|
|
|
#ifdef DBUS_WIN
|
|
|
|
|
#include <winsock2.h>
|
|
|
|
|
#undef interface
|
|
|
|
|
#else
|
2006-11-08 15:49:30 +00:00
|
|
|
#include <sys/time.h>
|
2006-12-31 12:20:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-11-08 15:49:30 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
2006-11-08 23:10:48 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
2003-05-16 20:09:25 +00:00
|
|
|
#include "dbus-print-message.h"
|
2003-04-14 03:25:19 +00:00
|
|
|
|
2006-12-31 12:20:54 +00:00
|
|
|
#ifdef DBUS_WIN
|
|
|
|
|
|
|
|
|
|
/* gettimeofday is not defined on windows */
|
|
|
|
|
#define DBUS_SECONDS_SINCE_1601 11644473600LL
|
|
|
|
|
#define DBUS_USEC_IN_SEC 1000000LL
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
gettimeofday (struct timeval *__p,
|
|
|
|
|
void *__t)
|
|
|
|
|
{
|
|
|
|
|
union {
|
|
|
|
|
unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
|
|
|
|
|
FILETIME ft;
|
|
|
|
|
} now;
|
|
|
|
|
|
|
|
|
|
GetSystemTimeAsFileTime (&now.ft);
|
|
|
|
|
__p->tv_usec = (long) ((now.ns100 / 10LL) % DBUS_USEC_IN_SEC);
|
|
|
|
|
__p->tv_sec = (long)(((now.ns100 / 10LL) / DBUS_SECONDS_SINCE_1601) - DBUS_SECONDS_SINCE_1601);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
static DBusHandlerResult
|
2006-11-08 15:49:30 +00:00
|
|
|
monitor_filter_func (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
2003-04-14 03:25:19 +00:00
|
|
|
{
|
2005-07-06 Colin Walters <walters@verbum.org>
* dbus/dbus-glib.h (DBusGPendingCall, DBusGPendingCallNotify)
(DBUS_TYPE_G_PENDING_CALL, dbus_g_pending_call_get_g_type)
(dbus_g_pending_call_ref, dbus_g_pending_call_unref): Delete.
(dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel):
Delete in favor of dbus_g_proxy_begin_call and
dbus_g_proxy_cancel_call.
(DBusGProxyCall, DBusGProxyCallNotify): New.
(dbus_g_proxy_begin_call): Change prototype to take callback, user
data, and destroy function. This replaces
dbus_g_pending_call_set_notify.
(dbus_g_proxy_cancel_call): Prototype.
(DBusGAsyncData): Delete, shouldn't be needed anymore.
* glib/dbus-gproxy.c (struct _DBusGProxy): Add call_id_counter and
pending_calls map.
(struct _DBusGProxyManager): Add bus_proxy member, which is an
internal proxy for calls to the bus. Remove
pending_nameowner_calls, now the internal proxy keeps track.
(dbus_g_proxy_manager_unref): Unref bus proxy, remove reference to
pending_nameowner_calls.
(got_name_owner_cb): Update prototype, and use
dbus_g_proxy_end_call.
(got_name_owner_cb): Remove reference to pending_nameowner_calls.
(dbus_g_proxy_manager_register): Delete directly libdbus code in
favor of using internal proxy.
(dbus_g_proxy_manager_unregister): Update to use
dbus_g_proxy_cancel_call for any pending GetNameOwner call.
(dbus_g_proxy_init): Initialize pending calls map.
(dbus_g_proxy_constructor): New.
(dbus_g_proxy_class_init): Add get/set property functions,
constructor, and add NAME, PATH, and INTERFACE properties.
(cancel_pending_call): New function.
(dbus_g_proxy_dispose): Iterate over any outstanding calls and
cancel them.
(dbus_g_proxy_set_property, dbus_g_proxy_get_property): New.
(GPendingNotifyClosure): New structure.
(d_pending_call_notify, d_pending_call_free): Moved here from
dbus-glib.c.
(DBUS_G_VALUE_ARRAY_COLLECT_ALL): Moved around to satisfy function
ordering.
(manager_begin_bus_call): New internal function for talking to
internal bus proxy.
(dbus_g_proxy_new): Construct object using GObjet properties.
(dbus_g_proxy_begin_call_internal): Update to take user data, etc.
Create closure of same, and insert call into map of pending calls.
(dbus_g_proxy_end_call_internal): Take call id instead of pending
call. Look up pending call in current set. Remove it when we've
completed.
(dbus_g_pending_call_end, dbus_g_proxy_end_call_internal): Delete.
(dbus_g_proxy_begin_call): Change API to take callback, user data,
and destroy function directly.
(dbus_g_proxy_end_call): Update to take DBusGProxyCall.
(dbus_g_proxy_call): Invoke with NULL callback.
(dbus_g_proxy_cancel_call): New function, replaces
dbus_g_pending_call_cancel.
* glib/dbus-gparser.c (validate_signature): Fix call to
dbus_set_g_error.
* glib/dbus-gobject.c (dbus_g_object_type_dbus_metadata_quark):
New quark for attaching metadata to GType.
(info_hash): Delete.
(lookup_object_info): Look up using quark.
(dbus_g_object_type_install_info): Check that a type is classed,
not that it's an object. Also just install type data using quark
instead of using global hash.
* glib/dbus-glib.c (dbus_g_pending_call_ref)
(dbus_g_pending_call_unref, dbus_pending_call_get_g_type)
(GPendingNotifyClosure): Delete.
(d_pending_call_notify, d_pending_call_free): Move to dbus-gproxy.c.
(dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete.
* glib/dbus-binding-tool-glib.c (generate_client_glue): Disable async
client method generation until we can fix it...
* tools/dbus-viewer.c (load_child_nodes): Use dbus_g_proxy_call.
(load_from_service_thread_func): Ditto.
* tools/dbus-names-model.c (struct NamesModel): Hold
DBusGProxyCall.
(have_names_notify): Update prototype, use
dbus_g_proxy_cancel_call.
(names_model_reload): Update for new dbus_g_proxy_begin_call API.
* tools/dbus-monitor.c (filter_func): Update for print_message
API change.
* test/glib/test-dbus-glib.c: Add more tests for async
invocations. Update many begin_call/end_call pairs to just use
dbus_g_proxy_call.
* tools/dbus-send.c (main): Add --print-reply=literal mode. This
allows us to dump print-introspect.c.
* tools/dbus-print-message.h (print_message): Add literal argument
to print_message which is intended to allow printing arguments without
metadata like "string=".
* tools/dbus-print-message.c (print_iter): Add literal argument.
(print_message): Allow printing string messages literally.
2005-07-06 21:27:53 +00:00
|
|
|
print_message (message, FALSE);
|
2003-05-16 20:09:25 +00:00
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_LOCAL,
|
2003-08-18 22:43:30 +00:00
|
|
|
"Disconnected"))
|
2003-05-16 20:09:25 +00:00
|
|
|
exit (0);
|
|
|
|
|
|
2004-10-29 18:52:30 +00:00
|
|
|
/* Conceptually we want this to be
|
|
|
|
|
* DBUS_HANDLER_RESULT_NOT_YET_HANDLED, but this raises
|
|
|
|
|
* some problems. See bug 1719.
|
|
|
|
|
*/
|
2004-10-29 18:50:29 +00:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
2003-04-14 03:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-08 15:49:30 +00:00
|
|
|
#define PROFILE_TIMED_FORMAT "%s\t%lu\t%lu"
|
|
|
|
|
#define TRAP_NULL_STRING(str) ((str) ? (str) : "<none>")
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SERIAL = 1,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL = 2,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SENDER = 4,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_DESTINATION = 8,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_PATH = 16,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_INTERFACE = 32,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_MEMBER = 64,
|
2008-04-16 10:49:25 -04:00
|
|
|
PROFILE_ATTRIBUTE_FLAG_ERROR_NAME = 128
|
2006-11-08 15:49:30 +00:00
|
|
|
} ProfileAttributeFlags;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
profile_print_with_attrs (const char *type, DBusMessage *message,
|
|
|
|
|
struct timeval *t, ProfileAttributeFlags attrs)
|
|
|
|
|
{
|
|
|
|
|
printf (PROFILE_TIMED_FORMAT, type, t->tv_sec, t->tv_usec);
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_SERIAL)
|
|
|
|
|
printf ("\t%u", dbus_message_get_serial (message));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL)
|
|
|
|
|
printf ("\t%u", dbus_message_get_reply_serial (message));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_SENDER)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_sender (message)));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_DESTINATION)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_destination (message)));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_PATH)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_path (message)));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_INTERFACE)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_interface (message)));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_MEMBER)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_member (message)));
|
|
|
|
|
|
|
|
|
|
if (attrs & PROFILE_ATTRIBUTE_FLAG_ERROR_NAME)
|
|
|
|
|
printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_error_name (message)));
|
|
|
|
|
|
|
|
|
|
printf ("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_message_profile (DBusMessage *message)
|
|
|
|
|
{
|
|
|
|
|
struct timeval t;
|
|
|
|
|
|
|
|
|
|
if (gettimeofday (&t, NULL) < 0)
|
|
|
|
|
{
|
|
|
|
|
printf ("un\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (dbus_message_get_type (message))
|
|
|
|
|
{
|
|
|
|
|
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
|
|
|
|
profile_print_with_attrs ("mc", message, &t,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SERIAL |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SENDER |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_PATH |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_INTERFACE |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_MEMBER);
|
|
|
|
|
break;
|
|
|
|
|
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
|
|
|
|
|
profile_print_with_attrs ("mr", message, &t,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SERIAL |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_DESTINATION |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL);
|
|
|
|
|
break;
|
|
|
|
|
case DBUS_MESSAGE_TYPE_ERROR:
|
|
|
|
|
profile_print_with_attrs ("err", message, &t,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SERIAL |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_DESTINATION |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL);
|
|
|
|
|
break;
|
|
|
|
|
case DBUS_MESSAGE_TYPE_SIGNAL:
|
|
|
|
|
profile_print_with_attrs ("sig", message, &t,
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_SERIAL |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_PATH |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_INTERFACE |
|
|
|
|
|
PROFILE_ATTRIBUTE_FLAG_MEMBER);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf (PROFILE_TIMED_FORMAT "\n", "tun", t.tv_sec, t.tv_usec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
|
|
|
|
profile_filter_func (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
print_message_profile (message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_signal (message,
|
|
|
|
|
DBUS_INTERFACE_LOCAL,
|
|
|
|
|
"Disconnected"))
|
|
|
|
|
exit (0);
|
|
|
|
|
|
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-16 16:01:56 +00:00
|
|
|
static void
|
|
|
|
|
usage (char *name, int ecode)
|
|
|
|
|
{
|
2009-07-13 14:06:26 -04:00
|
|
|
fprintf (stderr, "Usage: %s [--system | --session | --address ADDRESS] [--monitor | --profile ] [watch expressions]\n", name);
|
2003-05-16 16:01:56 +00:00
|
|
|
exit (ecode);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-21 12:52:22 -04:00
|
|
|
static dbus_bool_t sigint_received = FALSE;
|
2006-11-08 23:10:48 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sigint_handler (int signum)
|
|
|
|
|
{
|
|
|
|
|
sigint_received = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
DBusError error;
|
2003-05-18 02:39:47 +00:00
|
|
|
DBusBusType type = DBUS_BUS_SESSION;
|
2006-11-08 15:49:30 +00:00
|
|
|
DBusHandleMessageFunction filter_func = monitor_filter_func;
|
2009-07-13 14:06:26 -04:00
|
|
|
char *address = NULL;
|
|
|
|
|
|
2005-10-29 17:02:58 +00:00
|
|
|
int i = 0, j = 0, numFilters = 0;
|
|
|
|
|
char **filters = NULL;
|
2003-05-16 16:01:56 +00:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
|
{
|
|
|
|
|
char *arg = argv[i];
|
|
|
|
|
|
2003-05-28 21:26:03 +00:00
|
|
|
if (!strcmp (arg, "--system"))
|
2003-05-18 02:39:47 +00:00
|
|
|
type = DBUS_BUS_SYSTEM;
|
2003-06-19 22:22:37 +00:00
|
|
|
else if (!strcmp (arg, "--session"))
|
|
|
|
|
type = DBUS_BUS_SESSION;
|
2009-07-13 14:06:26 -04:00
|
|
|
else if (!strcmp (arg, "--address"))
|
|
|
|
|
{
|
|
|
|
|
if (i+1 < argc)
|
|
|
|
|
{
|
|
|
|
|
address = argv[i+1];
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
usage (argv[0], 1);
|
|
|
|
|
}
|
2003-05-16 16:01:56 +00:00
|
|
|
else if (!strcmp (arg, "--help"))
|
|
|
|
|
usage (argv[0], 0);
|
2006-11-08 15:49:30 +00:00
|
|
|
else if (!strcmp (arg, "--monitor"))
|
|
|
|
|
filter_func = monitor_filter_func;
|
|
|
|
|
else if (!strcmp (arg, "--profile"))
|
|
|
|
|
filter_func = profile_filter_func;
|
2003-05-16 16:01:56 +00:00
|
|
|
else if (!strcmp (arg, "--"))
|
2005-10-29 17:02:58 +00:00
|
|
|
continue;
|
2003-05-16 16:01:56 +00:00
|
|
|
else if (arg[0] == '-')
|
|
|
|
|
usage (argv[0], 1);
|
2005-10-29 17:02:58 +00:00
|
|
|
else {
|
|
|
|
|
numFilters++;
|
|
|
|
|
filters = (char **)realloc(filters, numFilters * sizeof(char *));
|
|
|
|
|
filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *));
|
|
|
|
|
snprintf(filters[j], strlen(arg) + 1, "%s", arg);
|
|
|
|
|
j++;
|
|
|
|
|
}
|
2003-05-16 16:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-14 03:25:19 +00:00
|
|
|
dbus_error_init (&error);
|
2009-07-13 14:06:26 -04:00
|
|
|
|
|
|
|
|
if (address != NULL)
|
|
|
|
|
{
|
|
|
|
|
connection = dbus_connection_open (address, &error);
|
|
|
|
|
if (connection)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_bus_register (connection, &error))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Failed to register connection to bus at %s: %s\n",
|
|
|
|
|
address, error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
connection = dbus_bus_get (type, &error);
|
2003-04-14 03:25:19 +00:00
|
|
|
if (connection == NULL)
|
|
|
|
|
{
|
2009-07-13 14:06:26 -04:00
|
|
|
const char *where;
|
|
|
|
|
if (address != NULL)
|
|
|
|
|
where = address;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case DBUS_BUS_SYSTEM:
|
|
|
|
|
where = "system bus";
|
|
|
|
|
break;
|
|
|
|
|
case DBUS_BUS_SESSION:
|
|
|
|
|
where = "session bus";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
where = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fprintf (stderr, "Failed to open connection to %s: %s\n",
|
|
|
|
|
where,
|
2003-04-14 03:25:19 +00:00
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-29 17:02:58 +00:00
|
|
|
if (numFilters)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < j; i++)
|
|
|
|
|
{
|
|
|
|
|
dbus_bus_add_match (connection, filters[i], &error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Failed to setup match \"%s\": %s\n",
|
|
|
|
|
filters[i], error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
free(filters[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_bus_add_match (connection,
|
|
|
|
|
"type='signal'",
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
goto lose;
|
|
|
|
|
dbus_bus_add_match (connection,
|
|
|
|
|
"type='method_call'",
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
goto lose;
|
|
|
|
|
dbus_bus_add_match (connection,
|
|
|
|
|
"type='method_return'",
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
goto lose;
|
|
|
|
|
dbus_bus_add_match (connection,
|
|
|
|
|
"type='error'",
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
goto lose;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-25 18:02:17 +00:00
|
|
|
if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) {
|
|
|
|
|
fprintf (stderr, "Couldn't add filter!\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2006-11-08 23:10:48 +00:00
|
|
|
|
|
|
|
|
/* we handle SIGINT so exit() is reached and flushes stdout */
|
|
|
|
|
signal (SIGINT, sigint_handler);
|
|
|
|
|
while (dbus_connection_read_write_dispatch(connection, -1)
|
|
|
|
|
&& !sigint_received)
|
2006-06-14 14:39:51 +00:00
|
|
|
;
|
2003-04-14 03:25:19 +00:00
|
|
|
exit (0);
|
2004-05-25 18:02:17 +00:00
|
|
|
lose:
|
|
|
|
|
fprintf (stderr, "Error: %s\n", error.message);
|
|
|
|
|
exit (1);
|
2003-04-14 03:25:19 +00:00
|
|
|
}
|
2006-11-08 15:49:30 +00:00
|
|
|
|