]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/dbus/dbus/dbus-monitor.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / dbus / dbus / dbus-monitor.patch
1 diff -urN dbus-0.22.orig/tools/dbus-monitor.1 dbus-0.22/tools/dbus-monitor.1
2 --- dbus-0.22.orig/tools/dbus-monitor.1 2004-10-10 20:47:19.906823680 +1000
3 +++ dbus-0.22/tools/dbus-monitor.1      2004-10-10 20:47:27.791625008 +1000
4 @@ -9,6 +9,7 @@
5  .PP
6  .B dbus-monitor
7  [\-\-system | \-\-session]
8 +[watch expressions]
9  
10  .SH DESCRIPTION
11  
12 @@ -25,6 +26,11 @@
13  monitor the system or session buses respectively.  If neither is
14  specified, \fIdbus-monitor\fP monitors the session bus.
15  
16 +.PP
17 +In order to get \fIdbus-monitor\fP to see the messages you are interested
18 +in, you should specify a set of watch expressions as you would expect to
19 +be passed to the \fIdbus_bus_add_watch\fP function.
20 +
21  .PP 
22  The message bus configuration may keep \fIdbus-monitor\fP from seeing
23  all messages, especially if you run the monitor as a non-root user.
24 @@ -37,6 +43,15 @@
25  .I "--session"
26  Monitor the session message bus.  (This is the default.)
27  
28 +.SH EXAMPLE
29 +Here is an example of using dbus-monitor to watch for the gnome typing
30 +monitor to say things
31 +.nf
32 +
33 +  dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"
34 +
35 +.fi
36 +
37  .SH AUTHOR
38  dbus-monitor was written by Philip Blundell.
39  
40 --- dbus-0.22-1ubuntu1/tools/dbus-monitor.c     2004-08-10 13:03:37.000000000 +1000
41 +++ dbus-0.22/tools/dbus-monitor.c      2004-10-10 21:38:08.532362152 +1000
42 @@ -45,7 +45,7 @@
43  static void
44  usage (char *name, int ecode)
45  {
46 -  fprintf (stderr, "Usage: %s [--system | --session]\n", name);
47 +  fprintf (stderr, "Usage: %s [--system | --session] [watch expressions]\n", name);
48    exit (ecode);
49  }
50  
51 @@ -56,8 +56,8 @@
52    DBusError error;
53    DBusBusType type = DBUS_BUS_SESSION;
54    GMainLoop *loop;
55 -  int i;
56 -
57 +  int i = 0, j = 0, numFilters = 0;
58 +  char **filters = NULL;
59    for (i = 1; i < argc; i++)
60      {
61        char *arg = argv[i];
62 @@ -69,14 +69,18 @@
63        else if (!strcmp (arg, "--help"))
64         usage (argv[0], 0);
65        else if (!strcmp (arg, "--"))
66 -       break;
67 +       continue;
68        else if (arg[0] == '-')
69         usage (argv[0], 1);
70 +      else {
71 +       numFilters++;
72 +       filters = (char **)realloc(filters, numFilters * sizeof(char *));
73 +       filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *));
74 +       snprintf(filters[j], strlen(arg) + 1, "%s", arg);
75 +       j++;
76 +      }
77      }
78  
79 -  if (argc > 2)
80 -    usage (argv[0], 1);
81 -
82    loop = g_main_loop_new (NULL, FALSE);
83  
84    dbus_error_init (&error);
85 @@ -92,26 +102,45 @@
86  
87    dbus_connection_setup_with_g_main (connection, NULL);
88  
89 -  dbus_bus_add_match (connection,
90 -                     "type='signal'",
91 -                     &error);
92 -  if (dbus_error_is_set (&error))
93 -    goto lose;
94 -  dbus_bus_add_match (connection,
95 -                     "type='method_call'",
96 -                     &error);
97 -  if (dbus_error_is_set (&error))
98 -    goto lose;
99 -  dbus_bus_add_match (connection,
100 -                     "type='method_return'",
101 -                     &error);
102 -  if (dbus_error_is_set (&error))
103 -    goto lose;
104 -  dbus_bus_add_match (connection,
105 -                     "type='error'",
106 -                     &error);
107 -  if (dbus_error_is_set (&error))
108 -    goto lose;
109 +  if (numFilters)
110 +    {
111 +      for (i = 0; i < j; i++)
112 +        {
113 +          dbus_bus_add_match (connection, filters[i], &error);
114 +          if (dbus_error_is_set (&error))
115 +            {
116 +              fprintf (stderr, "Failed to setup match \"%s\": %s\n",
117 +                       filters[i], error.message);
118 +              dbus_error_free (&error);
119 +              exit (1);
120 +            }
121 +         free(filters[i]);
122 +        }
123 +    }
124 +  else
125 +    {
126 +      dbus_bus_add_match (connection,
127 +                         "type='signal'",
128 +                         &error);
129 +      if (dbus_error_is_set (&error))
130 +        goto lose;
131 +      dbus_bus_add_match (connection,
132 +                         "type='method_call'",
133 +                         &error);
134 +      if (dbus_error_is_set (&error))
135 +        goto lose;
136 +      dbus_bus_add_match (connection,
137 +                         "type='method_return'",
138 +                         &error);
139 +      if (dbus_error_is_set (&error))
140 +        goto lose;
141 +      dbus_bus_add_match (connection,
142 +                         "type='error'",
143 +                         &error);
144 +      if (dbus_error_is_set (&error))
145 +        goto lose;
146 +    }
147 +
148    if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) {
149      fprintf (stderr, "Couldn't add filter!\n");
150      exit (1);