Commit graph

58 commits

Author SHA1 Message Date
Simon McVittie
eeef787418 Normalize C source files to end with exactly one newline
Some editors automatically remove trailing blank lines, or
automatically add a trailing newline to avoid having a trailing
non-blank line that is not terminated by a newline. To avoid unrelated
whitespace changes when users of such editors contribute to dbus,
let's pre-emptively normalize all files.

Unlike more intrusive whitespace normalization like removing trailing
whitespace from each line, this seems unlikely to cause significant
issues with cherry-picking changes to stable branches.

Implemented by:

    find . -name '*.[ch]' -print0 | \
    xargs -0 perl -0777 -p -i -e 's/\n+\z//g; s/\z/\n/g'

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-10 10:47:31 +00:00
Simon McVittie
67c3ad422c dbus-monitor: handle default case for binary mode header
Also comment why it's OK to not do anything for the modes that don't
have a header. We are effectively treating the default case as one
of those, on the assumption that future modes are more likely to
lack a header than to have one.

Based on part of a patch from Thomas Zimmermann.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98191
2017-04-07 12:07:21 +01:00
Simon McVittie
40560fa0c7 test, tools: assert impossible values of local enums are not reached
Based on part of a patch from Thomas Zimmermann.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98191
2017-04-07 12:07:01 +01:00
Simon McVittie
7959d90719 Add missing function attributes suggested by clang (but not by gcc)
clang is a little more enthusiastic about suggesting these.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-13 22:44:13 +01:00
Simon McVittie
d9ee040d0b dbus-monitor: disable automatic handling of o.fd.Peer messages
A normal DBusConnection will automatically reply to o.fd.Peer
messages such as Ping. We don't want this: if we are using
traditional eavesdropping with an older dbus-daemon, we'll
confuse everyone else by replying to messages that weren't
intended for us. If we are using the new Monitoring
interface (since 1.9.12), the same still applies, but in
addition, the dbus-daemon will disconnect us for not being
a well-behaved monitor.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90952
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-07-21 16:50:48 +01:00
Simon McVittie
188884dd62 dbus-monitor: use _dbus_get_real_time instead of gettimeofday
gettimeofday is implicitly declared (i.e. not in our #include'd header
files) when cross-compiling for on Windows. Now that fd.o#83115
has been fixed, using _dbus functions is not a problem.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89428
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-03-05 13:14:37 +00:00
Ralf Habacker
360a68eddd dbus-monitor: Add timestamp to --monitor mode.
Use cross platform function _dbus_get_real_time() for fetching current time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: use %ld to avoid needing casts; reinstate printing the timestamp;
libdbus-1 is sufficient now that fd.o#83115 is fixed; print timestamp for
non-literal dbus-send replies too]
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 13:29:45 +00:00
Ralf Habacker
387c1a5b91 dbus-monitor: Remove empty column in --profile mode.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-16 15:12:06 +01:00
Ralf Habacker
450c7067de dbus-monitor: Combine sec and usec columns into one timestamp column and unify platform related format string.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-16 15:12:06 +01:00
Simon McVittie
4453665b17 dbus-monitor: whitespace 2015-02-16 12:53:57 +00:00
Simon McVittie
bb950952e6 dbus-monitor: clarify column headers
- change "ref serial" to "in_reply_to" (avoiding whitespace for easy
  visual parsing)
- prefix with # to clarify that these are not part of the data

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:53:18 +00:00
Ralf Habacker
a52ef07c80 dbus-monitor.c: unify columns format in --profile mode and display column header.
[rebase onto correctly indented version -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:53:16 +00:00
Simon McVittie
1ddaffffb8 dbus-monitor: convert remaining hard tabs to 8 spaces
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:52:53 +00:00
Simon McVittie
1a28f82926 dbus-monitor: add options to log binary data with or without pcap framing
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:34 +00:00
Simon McVittie
8a621b8f77 dbus-monitor: add support for using BecomeMonitor to be a read-only monitor
Move the dbus_connection_add_filter() call further up as a precaution,
because it isn't safe for a monitor to not have a filter that
swallows all messages.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:31 +00:00
Simon McVittie
9806240b78 dbus-monitor: use common code from dbus-test-tool
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall
[also sync up the cmake build system -smcv]
2015-02-04 14:18:39 +00:00
Chengwei Yang
faaa092f20 dbus-monitor: keep backwards compatibility
eavesdropping as a match rule key introduced in DBus 1.5.6, and the
privous implementation doesn't keep backwards compatibility with older
dbus-daemon.

And the reference dbus-daemon implementation just fail if unknwon key
found in match rule, this is undefined hehavior in DBus Sepcification.

Also there is a feature request for change this hehavior to
"ignore unknown key in match rule", See
https://bugs.freedesktop.org/show_bug.cgi?id=66114

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-09 11:26:46 +01:00
Chengwei Yang
1451f946c1 dbus-monitor: remove redundant match rules
Currently, DBus Specification only consists of four message types, so to
monitor all the types of message, no need to match all of them but just
left it empty is OK.

Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 11:15:35 +01:00
Chengwei Yang
fd5271f839 Fix build on NetBSD 6.1.1 with gcc 4.5.3
There are two build failure on NetBSD 6.1.1 with gcc 4.5.3, the first
one is char to int, warning treated as error. The second one is a mismatch
between format string and arguments.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69842
[adjusted commit message -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 10:29:20 +01:00
Sviatoslav Chagaev
990fd63f4e Fix an incorrect sizeof.
Fix an incorrect sizeof which leads to allocation of more memory than
actually needed.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329
[elide redundant "* sizeof (char)" which is 1 by definition -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-16 15:31:22 +01:00
Simon McVittie
9577e33c89 Revert "Fix an incorrect sizeof." to fix attribution
This reverts commit 3c1938180b.
2013-09-16 15:31:22 +01:00
Simon McVittie
3c1938180b Fix an incorrect sizeof.
Fix an incorrect sizeof which leads to allocation of more memory than
actually needed.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329
[elide redundant "* sizeof (char)" which is 1 by definition -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-16 12:43:40 +01:00
Simon McVittie
2ccbfb82dc dbus-monitor: remove unused SIGINT handler
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39231
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-08-05 12:26:29 +01:00
Cosimo Alfarano
f997b0ac48 Fix dbus-monitor using eavesdrop=true when no filters are passed
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-07-12 18:36:40 +01:00
Cosimo Alfarano
56b9629d69 Add "eavesdrop=true" as constant match rule for dbus-monitor
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37890
Bug-NB: NB#269748
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-07-11 17:03:54 +01:00
Will Thompson
435ddb0df1 minotaur: bail if asked to monitor >1 bus
A coworker was just tripped up by `dbus-monitor --session --system` only
monitoring the system bus. This patch would have saved him reproducing a
tricky bug several times!

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=26548
Reviewed-by: Colin Walters <walters@verbum.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-04-29 15:42:18 +01:00
Mike McQuaid
2366423e97 Fix PROFILE_TIMED_FORMAT printf warning on OSX. 2010-12-04 01:42:41 +01:00
Marcus Brinkmann
1af558a620 Fix _IOLBF for Windows CE and also define _IONBF if needed. 2010-05-12 14:59:45 +02:00
Ralf Habacker
892bb42550 Fixed assert raised with msvc 2008 on windows. 2010-05-10 22:57:48 +02:00
Marcus Brinkmann
f041773df2 Port dbus tools to Windows CE. 2010-04-13 20:58:20 +02:00
Lennart Poettering
43b1f91865 dbus-monitor: use unbuffered stdout instead of handling SIGINT
The current SIGINT handling of dbus-monitor ain't making too many people
happy since it defers the exit to the next msg received -- which might
be quite some time away often enough.

This patch replaces the SIGINT handling by simply enabling line-buffered
IO for STDOUT so that even if you redirect dbus-monitor into a file no
lines get accidently lost and the effect of C-c is still immediate.

halfline came up with the great idea to use setvbuf here instead of
fflush()ing after each printf().

(Oh and the old signal handler was broken anyway, the flag should have
been of type sigatomic_t and be marked volatile)

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-31 12:27:48 -04:00
Daniel Reed
fceaa7a153 Bug 2432 - Support --address option for dbus-monitor
Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit e4b271e242)
2009-07-14 15:42:25 -04:00
Tobias Mueller
dc33f4f774 Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit 5baf2f856a)
2009-07-14 15:39:47 -04:00
Kjartan Maraas
eb3b99e7c6 Bug 19502 - Sparse warning cleanups
This patch makes various things that should be static static,
corrects some "return FALSE" where it should be NULL, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:18 -04:00
John (J5) Palmieri
eead418b24 take out trailing comma inside an enum so non gcc compilers don't error out
* tools/dbus-monitor.c: take out the trailing comma in the
  ProfileAttributeFlags enum as it isn't in our style guides and causes
  some compilers to error out
2008-04-16 10:49:25 -04:00
Havoc Pennington
d012387afe 2007-07-13 Havoc Pennington <hp@redhat.com>
* Add indent-tabs-mode: nil to all file headers.
2007-07-14 02:44:01 +00:00
Ralf Habacker
3a33c8e294 * tools/dbus-monitor.c: gettimeofday() is not available
on windows so we have to provide our own. It's taken from
lgpl'd kdewin32 package. - Patches from Christian Ehrlicher
2006-12-31 12:20:54 +00:00
Ralf Habacker
572ae0a7d4 win32 compile fix 2006-12-31 11:31:12 +00:00
John (J5) Palmieri
4ff579c92b * tools/dbus-monitor.c: Handle sigint so we flush stdout
(Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)
2006-11-08 23:10:48 +00:00
John (J5) Palmieri
88b1c4061a * tools/dbus-monitor.c: add profiling tools to dbus-monitor
(Patch from Olli Salli <olli dot salli at collabora dot co dot uk>)
2006-11-08 15:49:30 +00:00
Ross Burton
db64de230b 2006-06-14 Ross Burton <ross@openedhand.com>
* tools/Makefile.am:
	* tools/dbus-monitor.c:
	Don't use the GLib bindings in dbus-monitor (patch from Ralf
	Habacker).
2006-06-14 14:39:51 +00:00
Robert McQueen
2d74492ba2 2005-10-29 Robert McQueen <robot101@debian.org>
* glib/Makefile.am, glib/examples/Makefile.am,
        glib/examples/statemachine/Makefile.am: Merge patch from Ubuntu by
        Daniel Stone to replace explicit calls to libtool with $(LIBTOOL).

        * test/python/.cvsignore: Add run-with-tmp-session-bus.conf.

        * tools/dbus-monitor.1, tools/dbus-monitor.c: Merge dbus-monitor patch
        from Ubuntu by Daniel Silverstone to allow specifying match rules on
        the command line.
2005-10-29 17:02:58 +00:00
Colin Walters
2ca6e95764 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
Colin Walters
248895207d 2005-02-17 Colin Walters <walters@verbum.org>
* dbus/dbus-protocol.h (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS):
	Rename to DBUS_SERVICE_DBUS.
	(DBUS_PATH_ORG_FREEDESKTOP_DBUS): Rename to DBUS_PATH_DBUS.
	(DBUS_PATH_ORG_FREEDESKTOP_LOCAL): Rename to DBUS_PATH_LOCAL.
	(DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS): Rename to DBUS_INTERFACE_DBUS.
	(DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE): Rename to
	DBUS_INTERFACE_INTROSPECTABLE.
	(DBUS_INTERFACE_ORG_FREEDESKTOP_PROPERTIES): Rename to
	DBUS_INTERFACE_PROPERTIES.
	(DBUS_INTERFACE_ORG_FREEDESKTOP_PEER): Rename to
	DBUS_INTERFACE_PEER.
	(DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL):
	DBUS_INTERFACE_LOCAL.

	All other users of those constants have been changed.

	* bus/driver.c (bus_driver_handle_introspect): Use constants.

	* glib/dbus-gobject.c (handle_introspect): Use constants.

	* doc/dbus-faq.xml, doc/dbus-specification.xml: Update for rename.
2005-02-17 21:19:49 +00:00
Colin Walters
588da01c17 Add comment about workaround. 2004-10-29 18:52:30 +00:00
Colin Walters
0880b83d86 2004-10-29 Colin Walters <walters@redhat.com>
* tools/dbus-monitor.c (filter_func): Return
	DBUS_HANDLER_RESULT_HANDLED in filter function
	for now.  See:
	http://freedesktop.org/pipermail/dbus/2004-August/001433.html
2004-10-29 18:50:29 +00:00
Havoc Pennington
961e6ca41c 2004-06-20 Havoc Pennington <hp@redhat.com>
* dbus/dbus-glib-error-enum.h: autogenerate the GError enum
	codes from the dbus error names

        * glib/dbus-glib.h: move to subdir dbus/ since it's included
	as dbus/dbus-glib.h and that breakage is now visible due to
	including dbus/dbus-glib.h in dbus-glib-lowlevel.h

	* glib/dbus-glib.h: s/gproxy/g_proxy/

	* dbus/dbus-shared.h: new header to hold stuff shared with
	binding APIs

	* dbus/dbus-protocol.h (DBUS_ERROR_*): move errors here rather
	than dbus-errors.h

	* glib/dbus-glib.h (dbus_set_g_error): move to
	dbus-glib-lowlevel.h

	* glib/dbus-glib.h: remove dbus/dbus.h from here; change a bunch
	of stuff to enable this

	* dbus/dbus-glib-lowlevel.h: put dbus/dbus.h here

	* a bunch of other changes with the same basic "separate glib
	bindings from dbus.h" theme
2004-06-20 15:28:15 +00:00
Colin Walters
aa54f14c05 monitor all types of messages 2004-05-25 18:02:17 +00:00
Havoc Pennington
1dd3f1788f 2003-08-30 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c: purge DBusMessageHandler

	* dbus/dbus-message-handler.c: remove DBusMessageHandler, just
	use callbacks everywhere
2003-08-31 03:25:24 +00:00
Havoc Pennington
68a3c593b9 2003-08-18 Havoc Pennington <hp@redhat.com>
* dbus/dbus-hash.c (_dbus_hash_table_insert_two_strings): fix

	* dbus/dbus-message.c (_dbus_message_loader_queue_messages): fix
	dumb bug created earlier (wrong order of args to
	decode_header_data())

	* tools/dbus-send.c: port

	* tools/dbus-print-message.c (print_message): port

        * test/data/*messages: port all messages over

        * dbus/dbus-message-builder.c: support including
	message type

        * bus/driver.c: port over

	* bus/dispatch.c: port over to new stuff

	* dbus/dbus-connection.c (_dbus_connection_new_for_transport):
	rename disconnect signal to "Disconnected"
2003-08-18 22:43:30 +00:00