Merge lp:~3v1n0/bamf/bamfdaemon-gdbus into lp:bamf/0.4

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 450
Merged at revision: 426
Proposed branch: lp:~3v1n0/bamf/bamfdaemon-gdbus
Merge into: lp:bamf/0.4
Diff against target: 7188 lines (+2713/-1892)
43 files modified
configure.in (+7/-2)
src/Makefile.am (+66/-63)
src/bamf-application-glue.xml (+0/-45)
src/bamf-application.c (+164/-88)
src/bamf-application.h (+24/-25)
src/bamf-control-glue.xml (+0/-35)
src/bamf-control.c (+126/-81)
src/bamf-control.h (+20/-24)
src/bamf-daemon.c (+215/-0)
src/bamf-daemon.h (+61/-0)
src/bamf-indicator-glue.xml (+0/-23)
src/bamf-indicator-source-glue.xml (+0/-28)
src/bamf-indicator-source.c (+225/-167)
src/bamf-indicator-source.h (+21/-24)
src/bamf-indicator.c (+133/-67)
src/bamf-indicator.h (+30/-32)
src/bamf-marshal.list (+2/-5)
src/bamf-matcher-glue.xml (+0/-108)
src/bamf-matcher.c (+283/-158)
src/bamf-matcher.h (+28/-31)
src/bamf-tab-glue.xml (+0/-39)
src/bamf-tab-source.c (+159/-140)
src/bamf-tab-source.h (+3/-2)
src/bamf-tab.c (+132/-31)
src/bamf-tab.h (+4/-3)
src/bamf-view-glue.xml (+0/-109)
src/bamf-view.c (+386/-225)
src/bamf-view.h (+50/-60)
src/bamf-window-glue.xml (+0/-30)
src/bamf-window.c (+102/-37)
src/bamf-window.h (+4/-4)
src/bamf.h (+7/-1)
src/com.canonical.StatusNotifierApprover.xml (+19/-0)
src/main.c (+9/-49)
src/main.h (+4/-9)
src/org.ayatana.bamf.browser.xml (+35/-0)
src/org.ayatana.bamf.view.xml (+120/-0)
src/org.ayatana.bamf.xml (+77/-0)
tests/bamfdaemon/Makefile.am (+23/-25)
tests/bamfdaemon/run-xvfb.sh (+16/-0)
tests/bamfdaemon/test-application.c (+46/-24)
tests/bamfdaemon/test-bamf.c (+63/-59)
tests/bamfdaemon/test-view.c (+49/-39)
To merge this branch: bzr merge lp:~3v1n0/bamf/bamfdaemon-gdbus
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Mikkel Kamstrup Erlandsen Pending
Review via email: mp+86843@code.launchpad.net

Description of the change

Ported the BAMF daemon to GDBus, using gdbus-codegen to generate most of the low-level code.

The BamfMatcher and BamfControl are directly extending the generated skeleton class, while the Views are now extending the generated BamfDBusItemObjectSkeleton class, so it has been easily possible to transform each subclass into a kind of proxy to the generated skeleton interface. To reduce code redundancy for initializing signals, some view classes are also implementing the related skeleton interface, but this has been done only for convenience.

Then, I've added a BamfDaemon class to handle the daemon initialization and termination, and I've updated the tests against the new internal APIs.

Finally, I've also ported all the code for indicators and tabs, while I guess that this is now quite obsolete (the indicator part shouldn't totally, but the tabs really are), so maybe it could safely be removed.

I also want to make clear that the public DBus API interface has not been touched by this porting, so the new bamfdaemon can safely replace the old one (in fact I'm using it on my PC for some days with no crashes or unexpected behavior).

The port of libbamf will begin soon as well, and doing that maybe we should refine also the DBus interface.

PS: of course I've also included some random code fixes and cleanup.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

A few things from a quick look: (in merge request line numbers)

1) please enable silent rules

339 + const GList *children, *l;

Please get rid of the const, this isn't C++ and afaict it's wrong in this case. (same for 405, 439, 449, 490, ...)

Same applies to methods returning const GList* - in that case the qualifier is correct, but all GList methods require non-const list anyway, so you're forcing the consumer to cast away the const-ness.

1335 + g_error_free (error);
1336 + error = NULL;

There are also multiple instances of this and it can be simplified using g_clear_error().

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for your review. I've made the changes you suggested to me.

Also, I've disabled the indicator approver, since it is currently deprecated (after a chat with Ted).

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/14/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Jason Smith (jassmith) wrote :

Works for me, please fix jenkins issues :)

review: Approve
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Marking branch approved again. I have no idea why jenkins silently fails...

Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:bamf failed due to conflicts:

text conflict in configure.in

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/24/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/25/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/26/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/27/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/28/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/29/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/30/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

lp:~3v1n0/bamf/bamfdaemon-gdbus updated
450. By Marco Trevisan (Treviño)

tests, BamfDaemon: removed typo.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.in'
2--- configure.in 2012-01-12 15:08:42 +0000
3+++ configure.in 2012-01-19 19:16:25 +0000
4@@ -2,7 +2,7 @@
5 # Process this file with autoconf to produce a configure script.
6
7 AC_PREREQ([2.63])
8-AC_INIT(bamf, 0.2.106, dx-team@canonical.com)
9+AC_INIT(bamf, 0.2.107, dx-team@canonical.com)
10 AC_PREREQ(2.62)
11
12 AC_CONFIG_SRCDIR(src/main.c)
13@@ -56,7 +56,12 @@
14 #
15 # glib
16 #
17-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 gio-unix-2.0)
18+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 >= 2.30.0 gio-unix-2.0)
19+
20+#
21+# gdbus-codegen
22+#
23+AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], AC_MSG_ERROR([gdbus-codegen is required but was not found]))
24
25 #
26 # dbus
27
28=== modified file 'src/Makefile.am'
29--- src/Makefile.am 2010-07-09 08:05:06 +0000
30+++ src/Makefile.am 2012-01-19 19:16:25 +0000
31@@ -5,10 +5,10 @@
32
33 include $(top_srcdir)/Makefile.am.marshal
34
35-INCLUDE = \
36- -I. \
37- -I$(srcdir) \
38- $(NULL)
39+INCLUDE = \
40+ -I. \
41+ -I$(srcdir) \
42+ $(NULL)
43
44 bamfdaemondir = $(libexecdir)
45
46@@ -16,39 +16,36 @@
47 bamfdaemon \
48 $(NULL)
49
50-bamfdaemon_glue_files = \
51- bamf-application-glue.h \
52- bamf-control-glue.h \
53- bamf-matcher-glue.h \
54- bamf-window-glue.h \
55- bamf-view-glue.h \
56- bamf-tab-glue.h \
57- bamf-indicator-source-glue.h \
58- bamf-indicator-glue.h \
59+bamfdaemon_gdbus_files = \
60+ bamf-gdbus-generated.c \
61+ bamf-gdbus-generated.h \
62+ bamf-gdbus-view-generated.c \
63+ bamf-gdbus-view-generated.h \
64+ bamf-gdbus-browser-generated.c \
65+ bamf-gdbus-browser-generated.h \
66+ bamf-gdbus-indicator-source-generated.c \
67+ bamf-gdbus-indicator-source-generated.h \
68 $(NULL)
69-
70-bamfdaemon_xml_glue_files = \
71- bamf-application-glue.xml \
72- bamf-control-glue.xml \
73- bamf-matcher-glue.xml \
74- bamf-window-glue.xml \
75- bamf-view-glue.xml \
76- bamf-tab-glue.xml \
77- bamf-indicator-source-glue.xml \
78- bamf-indicator-glue.xml \
79+
80+bamfdaemon_xml_gdbus_files = \
81+ org.ayatana.bamf.xml \
82+ org.ayatana.bamf.view.xml \
83+ org.ayatana.bamf.browser.xml \
84+ com.canonical.StatusNotifierApprover.xml \
85 $(NULL)
86
87 bamfdaemon_built_sources = \
88 bamf-marshal.c \
89 bamf-marshal.h \
90- $(bamfdaemon_glue_files) \
91+ $(bamfdaemon_gdbus_files) \
92 $(NULL)
93
94 bamfdaemon_sources = \
95 main.c \
96+ bamf-daemon.c \
97 bamf-legacy-window.c \
98 bamf-legacy-window-test.c \
99- bamf-legacy-screen.c \
100+ bamf-legacy-screen.c \
101 bamf-view.c \
102 bamf-control.c \
103 bamf-matcher.c \
104@@ -63,9 +60,10 @@
105 bamfdaemon_headers = \
106 main.h \
107 bamf.h \
108+ bamf-daemon.h \
109 bamf-legacy-window.h \
110 bamf-legacy-window-test.h \
111- bamf-legacy-screen.h \
112+ bamf-legacy-screen.h \
113 bamf-view.h \
114 bamf-control.h \
115 bamf-matcher.h \
116@@ -78,27 +76,22 @@
117 $(NULL)
118
119 bamfdaemon_SOURCES = \
120- $(bamfdaemon_built_sources) \
121+ $(bamfdaemon_built_sources) \
122 $(bamfdaemon_sources) \
123 $(bamfdaemon_headers) \
124 $(NULL)
125
126 nodist_EXTRA_bamfdaemon_SOURCES = \
127- $(bamfdaemon_glue_files) \
128+ $(bamfdaemon_gdbus_files) \
129 $(NULL)
130
131 glib_marshal_list = bamf-marshal.list
132 glib_marshal_prefix = bamf_marshal
133
134-DISTCLEANFILES += \
135- $(bamfdaemon_glue_files) \
136- $(NULL)
137-
138 bamfdaemon_LDADD = \
139 $(X_LIBS) \
140 $(GLIB_LIBS) \
141 $(GTK_LIBS) \
142- $(DBUS_LIBS) \
143 $(WNCK_LIBS) \
144 $(GTOP_LIBS) \
145 $(NULL)
146@@ -109,7 +102,6 @@
147 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \
148 $(GLIB_CFLAGS) \
149 $(GTK_CFLAGS) \
150- $(DBUS_CFLAGS) \
151 $(WNCK_CFLAGS) \
152 $(GTOP_CFLAGS) \
153 $(NULL)
154@@ -118,36 +110,47 @@
155 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \
156 $(NULL)
157
158-bamf-application-glue.h: bamf-application-glue.xml Makefile
159- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_application --mode=glib-server --output=$@ $<
160-
161-bamf-control-glue.h: bamf-control-glue.xml Makefile
162- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_control --mode=glib-server --output=$@ $<
163-
164-bamf-matcher-glue.h: bamf-matcher-glue.xml Makefile
165- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_matcher --mode=glib-server --output=$@ $<
166-
167-bamf-window-glue.h: bamf-window-glue.xml Makefile
168- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_window --mode=glib-server --output=$@ $<
169-
170-bamf-view-glue.h: bamf-view-glue.xml Makefile
171- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_view --mode=glib-server --output=$@ $<
172-
173-bamf-tab-glue.h: bamf-tab-glue.xml Makefile
174- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_tab --mode=glib-server --output=$@ $<
175-
176-bamf-indicator-source-glue.h: bamf-indicator-source-glue.xml Makefile
177- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator_source --mode=glib-server --output=$@ $<
178-
179-bamf-indicator-glue.h: bamf-indicator-glue.xml Makefile
180- $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator --mode=glib-server --output=$@ $<
181+bamf-gdbus-generated.c bamf-gdbus-generated.h: org.ayatana.bamf.xml
182+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
183+ --generate-c-code bamf-gdbus-generated \
184+ --c-namespace BamfDBus \
185+ --interface-prefix org.ayatana.bamf \
186+ $<
187+
188+bamf-gdbus-view-generated.c bamf-gdbus-view-generated.h: org.ayatana.bamf.view.xml
189+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
190+ --c-generate-object-manager \
191+ --generate-c-code bamf-gdbus-view-generated \
192+ --c-namespace BamfDBusItem \
193+ --interface-prefix org.ayatana.bamf \
194+ $<
195+
196+bamf-gdbus-browser-generated.c bamf-gdbus-browser-generated.h: org.ayatana.bamf.browser.xml
197+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
198+ --generate-c-code bamf-gdbus-browser-generated \
199+ --c-namespace BamfDBusBrowser \
200+ --interface-prefix org.ayatana.bamf.browser \
201+ $<
202+
203+bamf-gdbus-indicator-source-generated.c bamf-gdbus-indicator-source-generated.h: com.canonical.StatusNotifierApprover.xml
204+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
205+ --generate-c-code bamf-gdbus-indicator-source-generated \
206+ --c-namespace StatusNotifierApprover \
207+ --interface-prefix com.canonical.StatusNotifierApprover \
208+ $<
209
210 BUILT_SOURCES += \
211- $(bamfdaemon_glue_files) \
212- $(NULL)
213+ $(bamfdaemon_gdbus_files) \
214+ $(NULL)
215
216 EXTRA_DIST += \
217- $(bamfdaemon_xml_glue_files) \
218- $(NULL)
219-
220-
221+ $(bamfdaemon_xml_gdbus_files) \
222+ $(NULL)
223+
224+DISTCLEANFILES += \
225+ $(bamfdaemon_built_sources) \
226+ $(NULL)
227+
228+CLEANFILES += \
229+ $(bamfdaemon_built_sources) \
230+ $(NULL)
231
232=== removed file 'src/bamf-application-glue.xml'
233--- src/bamf-application-glue.xml 2010-09-10 16:41:41 +0000
234+++ src/bamf-application-glue.xml 1970-01-01 00:00:00 +0000
235@@ -1,45 +0,0 @@
236-<?xml version="1.0" encoding="UTF-8" ?>
237-
238-<node name="/org/ayatana/bamf">
239-
240- <interface name="org.ayatana.bamf.application">
241-
242- <signal name="WindowAdded">
243- <arg type="s" name="path" direction="out" />
244- </signal>
245-
246- <signal name="WindowRemoved">
247- <arg type="s" name="path" direction="out" />
248- </signal>
249-
250- <method name="ApplicationType">
251- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_application_type" />
252- <arg type="s" name="type" direction="out">
253- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
254- </arg>
255- </method>
256-
257- <method name="DesktopFile">
258- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_desktop_file" />
259- <arg type="s" name="desktop_file" direction="out">
260- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
261- </arg>
262- </method>
263-
264- <method name="Xids">
265- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_xids" />
266- <arg type="au" name="xids" direction="out">
267- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
268- </arg>
269- </method>
270-
271- <method name="ShowStubs">
272- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_show_stubs" />
273- <arg type="b" name="show_stubs" direction="out">
274- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
275- </arg>
276- </method>
277-
278- </interface>
279-
280-</node>
281
282=== modified file 'src/bamf-application.c'
283--- src/bamf-application.c 2011-12-14 03:17:37 +0000
284+++ src/bamf-application.c 2012-01-19 19:16:25 +0000
285@@ -1,5 +1,5 @@
286 /*
287- * Copyright (C) 2010 Canonical Ltd
288+ * Copyright (C) 2010-2011 Canonical Ltd
289 *
290 * This program is free software: you can redistribute it and/or modify
291 * it under the terms of the GNU General Public License version 3 as
292@@ -14,12 +14,11 @@
293 * along with this program. If not, see <http://www.gnu.org/licenses/>.
294 *
295 * Authored by: Jason Smith <jason.smith@canonical.com>
296+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
297 *
298 */
299
300-
301 #include "bamf-application.h"
302-#include "bamf-application-glue.h"
303 #include "bamf-window.h"
304 #include "bamf-matcher.h"
305 #include "bamf-indicator.h"
306@@ -28,22 +27,17 @@
307 #include <string.h>
308 #include <gio/gdesktopappinfo.h>
309
310-G_DEFINE_TYPE (BamfApplication, bamf_application, BAMF_TYPE_VIEW);
311 #define BAMF_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
312 BAMF_TYPE_APPLICATION, BamfApplicationPrivate))
313
314-enum
315-{
316- WINDOW_ADDED,
317- WINDOW_REMOVED,
318-
319- LAST_SIGNAL,
320-};
321-
322-static guint application_signals[LAST_SIGNAL] = { 0 };
323+static void bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface);
324+G_DEFINE_TYPE_WITH_CODE (BamfApplication, bamf_application, BAMF_TYPE_VIEW,
325+ G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_APPLICATION,
326+ bamf_application_dbus_application_iface_init));
327
328 struct _BamfApplicationPrivate
329 {
330+ BamfDBusItemApplication *dbus_iface;
331 char * desktop_file;
332 GList * desktop_file_list;
333 char * app_type;
334@@ -153,27 +147,32 @@
335 /* This will error to return false, which is okay as it seems
336 unlikely anyone will want to set this flag except to turn
337 off the stub menus. */
338- self->priv->show_stubs = g_key_file_get_boolean(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL);
339+ self->priv->show_stubs = g_key_file_get_boolean (keyfile,
340+ G_KEY_FILE_DESKTOP_GROUP,
341+ STUB_KEY, NULL);
342 }
343
344- if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))
345- {
346- /* Grab the better name if its available */
347- gchar *fullname = NULL;
348- error = NULL;
349- fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL, &error);
350- if (error != NULL)
351- {
352- g_error_free (error);
353- if (fullname)
354- g_free (fullname);
355- }
356- else
357- {
358- g_free (name);
359- name = fullname;
360- }
361- }
362+ if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))
363+ {
364+ /* Grab the better name if its available */
365+ gchar *fullname = NULL;
366+ error = NULL;
367+ fullname = g_key_file_get_locale_string (keyfile,
368+ G_KEY_FILE_DESKTOP_GROUP,
369+ "X-GNOME-FullName", NULL,
370+ &error);
371+ if (error != NULL)
372+ {
373+ g_error_free (error);
374+ if (fullname)
375+ g_free (fullname);
376+ }
377+ else
378+ {
379+ g_free (name);
380+ name = fullname;
381+ }
382+ }
383
384 g_object_unref (desktop);
385 g_key_file_free(keyfile);
386@@ -274,17 +273,18 @@
387 application->priv->wmclass = NULL;
388 }
389
390-GArray *
391+GVariant *
392 bamf_application_get_xids (BamfApplication *application)
393 {
394 GList *l;
395- GArray *xids;
396+ GVariantBuilder b;
397 BamfView *view;
398 guint32 xid;
399
400 g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL);
401
402- xids = g_array_new (FALSE, TRUE, sizeof (guint32));
403+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)"));
404+ g_variant_builder_open (&b, G_VARIANT_TYPE ("au"));
405
406 for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next)
407 {
408@@ -294,11 +294,12 @@
409 continue;
410
411 xid = bamf_window_get_xid (BAMF_WINDOW (view));
412-
413- g_array_append_val (xids, xid);
414+ g_variant_builder_add (&b, "u", xid);
415 }
416
417- return xids;
418+ g_variant_builder_close (&b);
419+
420+ return g_variant_builder_end (&b);
421 }
422
423 gboolean
424@@ -339,32 +340,32 @@
425 bamf_application_manages_xid (BamfApplication *application,
426 guint32 xid)
427 {
428- GArray *xids;
429- int i;
430+ GList *l;
431 gboolean result = FALSE;
432
433 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
434
435- xids = bamf_application_get_xids (application);
436-
437- for (i = 0; i < xids->len; i++)
438+ for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next)
439 {
440- if (g_array_index (xids, guint32, i) == xid)
441+ BamfView *view = l->data;
442+
443+ if (!BAMF_IS_WINDOW (view))
444+ continue;
445+
446+ if (bamf_window_get_xid (BAMF_WINDOW (view)) == xid)
447 {
448 result = TRUE;
449 break;
450 }
451 }
452
453- g_array_free (xids, TRUE);
454-
455 return result;
456 }
457
458-static char *
459+static const char *
460 bamf_application_get_view_type (BamfView *view)
461 {
462- return g_strdup ("application");
463+ return "application";
464 }
465
466 static char *
467@@ -455,7 +456,7 @@
468 static void
469 view_exported (BamfView *view, BamfApplication *self)
470 {
471- g_signal_emit (self, application_signals[WINDOW_ADDED], 0, bamf_view_get_path (view));
472+ g_signal_emit_by_name (self, "window-added", bamf_view_get_path (view));
473 }
474
475 static void
476@@ -468,7 +469,7 @@
477 if (BAMF_IS_WINDOW (child))
478 {
479 if (bamf_view_is_on_bus (child))
480- g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_ADDED], 0, bamf_view_get_path (child));
481+ g_signal_emit_by_name (BAMF_APPLICATION (view), "window-added", bamf_view_get_path (child));
482 else
483 g_signal_connect (G_OBJECT (child), "exported",
484 (GCallback) view_exported, view);
485@@ -486,15 +487,6 @@
486 bamf_application_setup_icon_and_name (application);
487 }
488
489-static gboolean
490-on_empty (GObject *object)
491-{
492- g_return_val_if_fail (BAMF_IS_VIEW (object), FALSE);
493-
494- bamf_view_close (BAMF_VIEW (object));
495- return FALSE;
496-}
497-
498 static char *
499 bamf_application_favorite_from_list (BamfApplication *self, GList *list)
500 {
501@@ -518,7 +510,7 @@
502 }
503 }
504 }
505-
506+
507 return result;
508 }
509
510@@ -560,7 +552,8 @@
511 if (BAMF_IS_WINDOW (child))
512 {
513 if (bamf_view_is_on_bus (child))
514- g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_REMOVED],0, bamf_view_get_path (child));
515+ g_signal_emit_by_name (BAMF_APPLICATION (view), "window-removed",
516+ bamf_view_get_path (child));
517 }
518
519 g_signal_handlers_disconnect_by_func (G_OBJECT (child), view_active_changed, view);
520@@ -569,9 +562,9 @@
521
522 bamf_application_ensure_flags (BAMF_APPLICATION (view));
523
524- if (g_list_length (bamf_view_get_children (view)) == 0)
525+ if (bamf_view_get_children (view) == NULL)
526 {
527- g_idle_add ((GSourceFunc) on_empty, view);
528+ bamf_view_close (view);
529 }
530 }
531
532@@ -584,7 +577,7 @@
533 g_return_if_fail (BAMF_IS_MATCHER (matcher));
534
535 new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list);
536-
537+
538 if (new_desktop_file)
539 {
540 bamf_application_set_desktop_file (self, new_desktop_file);
541@@ -592,6 +585,67 @@
542 }
543
544 static void
545+on_window_added (BamfApplication *self, const gchar *win_path, gpointer _not_used)
546+{
547+ g_return_if_fail (BAMF_IS_APPLICATION (self));
548+ g_signal_emit_by_name (self->priv->dbus_iface, "window-added", win_path);
549+}
550+
551+static void
552+on_window_removed (BamfApplication *self, const gchar *win_path, gpointer _not_used)
553+{
554+ g_return_if_fail (BAMF_IS_APPLICATION (self));
555+ g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", win_path);
556+}
557+
558+static gboolean
559+on_dbus_handle_show_stubs (BamfDBusItemApplication *interface,
560+ GDBusMethodInvocation *invocation,
561+ BamfApplication *self)
562+{
563+ gboolean show_stubs = bamf_application_get_show_stubs (self);
564+ g_dbus_method_invocation_return_value (invocation,
565+ g_variant_new ("(b)", show_stubs));
566+
567+ return TRUE;
568+}
569+
570+static gboolean
571+on_dbus_handle_xids (BamfDBusItemApplication *interface,
572+ GDBusMethodInvocation *invocation,
573+ BamfApplication *self)
574+{
575+ GVariant *xids = bamf_application_get_xids (self);
576+ g_dbus_method_invocation_return_value (invocation, xids);
577+
578+ return TRUE;
579+}
580+
581+static gboolean
582+on_dbus_handle_desktop_file (BamfDBusItemApplication *interface,
583+ GDBusMethodInvocation *invocation,
584+ BamfApplication *self)
585+{
586+ const char *desktop_file = self->priv->desktop_file ? self->priv->desktop_file : "";
587+ g_dbus_method_invocation_return_value (invocation,
588+ g_variant_new ("(s)", desktop_file));
589+
590+ return TRUE;
591+}
592+
593+static gboolean
594+on_dbus_handle_application_type (BamfDBusItemApplication *interface,
595+ GDBusMethodInvocation *invocation,
596+ BamfApplication *self)
597+{
598+ const char *type = self->priv->app_type ? self->priv->app_type : "";
599+ g_dbus_method_invocation_return_value (invocation,
600+ g_variant_new ("(s)", type));
601+
602+ return TRUE;
603+}
604+
605+static void
606 bamf_application_dispose (GObject *object)
607 {
608 BamfApplication *app;
609@@ -629,13 +683,25 @@
610 g_free (priv->wmclass);
611 priv->wmclass = NULL;
612 }
613-
614- g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()), matcher_favorites_changed, object);
615+
616+ g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()),
617+ matcher_favorites_changed, object);
618
619 G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object);
620 }
621
622 static void
623+bamf_application_finalize (GObject *object)
624+{
625+ BamfApplication *self;
626+ self = BAMF_APPLICATION (object);
627+
628+ g_object_unref (self->priv->dbus_iface);
629+
630+ G_OBJECT_CLASS (bamf_application_parent_class)->finalize (object);
631+}
632+
633+static void
634 bamf_application_init (BamfApplication * self)
635 {
636 BamfApplicationPrivate *priv;
637@@ -645,18 +711,49 @@
638 priv->app_type = g_strdup ("system");
639 priv->show_stubs = TRUE;
640 priv->wmclass = NULL;
641-
642+
643+ /* Initializing the dbus interface */
644+ priv->dbus_iface = bamf_dbus_item_application_skeleton_new ();
645+
646+ /* We need to connect to the object own signals to redirect them to the dbus
647+ * interface */
648+ g_signal_connect (self, "window-added", G_CALLBACK (on_window_added), NULL);
649+ g_signal_connect (self, "window-removed", G_CALLBACK (on_window_removed), NULL);
650+
651+ /* Registering signal callbacks to reply to dbus method calls */
652+ g_signal_connect (priv->dbus_iface, "handle-show-stubs",
653+ G_CALLBACK (on_dbus_handle_show_stubs), self);
654+
655+ g_signal_connect (priv->dbus_iface, "handle-xids",
656+ G_CALLBACK (on_dbus_handle_xids), self);
657+
658+ g_signal_connect (priv->dbus_iface, "handle-desktop-file",
659+ G_CALLBACK (on_dbus_handle_desktop_file), self);
660+
661+ g_signal_connect (priv->dbus_iface, "handle-application-type",
662+ G_CALLBACK (on_dbus_handle_application_type), self);
663+
664+ /* Setting the interface for the dbus object */
665+ bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
666+ priv->dbus_iface);
667+
668 g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed",
669 (GCallback) matcher_favorites_changed, self);
670 }
671
672 static void
673+bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface)
674+{
675+}
676+
677+static void
678 bamf_application_class_init (BamfApplicationClass * klass)
679 {
680 GObjectClass *object_class = G_OBJECT_CLASS (klass);
681 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
682
683 object_class->dispose = bamf_application_dispose;
684+ object_class->finalize = bamf_application_finalize;
685
686 view_class->view_type = bamf_application_get_view_type;
687 view_class->child_added = bamf_application_child_added;
688@@ -665,27 +762,6 @@
689 view_class->stable_bus_name = bamf_application_get_stable_bus_name;
690
691 g_type_class_add_private (klass, sizeof (BamfApplicationPrivate));
692-
693- dbus_g_object_type_install_info (BAMF_TYPE_APPLICATION,
694- &dbus_glib_bamf_application_object_info);
695-
696- application_signals [WINDOW_ADDED] =
697- g_signal_new ("window-added",
698- G_OBJECT_CLASS_TYPE (klass),
699- 0,
700- 0, NULL, NULL,
701- g_cclosure_marshal_VOID__STRING,
702- G_TYPE_NONE, 1,
703- G_TYPE_STRING);
704-
705- application_signals [WINDOW_REMOVED] =
706- g_signal_new ("window-removed",
707- G_OBJECT_CLASS_TYPE (klass),
708- 0,
709- 0, NULL, NULL,
710- g_cclosure_marshal_VOID__STRING,
711- G_TYPE_NONE, 1,
712- G_TYPE_STRING);
713 }
714
715 BamfApplication *
716
717=== modified file 'src/bamf-application.h'
718--- src/bamf-application.h 2011-06-21 23:45:49 +0000
719+++ src/bamf-application.h 2012-01-19 19:16:25 +0000
720@@ -1,5 +1,5 @@
721 /*
722- * Copyright (C) 2010 Canonical Ltd
723+ * Copyright (C) 2010-2011 Canonical Ltd
724 *
725 * This program is free software: you can redistribute it and/or modify
726 * it under the terms of the GNU General Public License version 3 as
727@@ -14,6 +14,7 @@
728 * along with this program. If not, see <http://www.gnu.org/licenses/>.
729 *
730 * Authored by: Jason Smith <jason.smith@canonical.com>
731+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
732 *
733 */
734
735@@ -50,33 +51,31 @@
736 BamfApplicationPrivate *priv;
737 };
738
739-GType bamf_application_get_type (void) G_GNUC_CONST;
740-
741-char * bamf_application_get_application_type (BamfApplication *application);
742-
743-char * bamf_application_get_desktop_file (BamfApplication *application);
744-void bamf_application_set_desktop_file (BamfApplication *application,
745- const char * desktop_file);
746-
747-GArray * bamf_application_get_xids (BamfApplication *application);
748-
749-gboolean bamf_application_manages_xid (BamfApplication *application,
750- guint32 xid);
751+GType bamf_application_get_type (void) G_GNUC_CONST;
752+
753+char * bamf_application_get_desktop_file (BamfApplication *application);
754+void bamf_application_set_desktop_file (BamfApplication *application,
755+ const char * desktop_file);
756+
757+GVariant * bamf_application_get_xids (BamfApplication *application);
758+
759+gboolean bamf_application_manages_xid (BamfApplication *application,
760+ guint32 xid);
761
762 gboolean bamf_application_contains_similar_to_window (BamfApplication *app,
763 BamfWindow *window);
764
765-char * bamf_application_get_wmclass (BamfApplication *application);
766-void bamf_application_set_wmclass (BamfApplication *application,
767- const char *wmclass);
768-
769-BamfApplication * bamf_application_new (void);
770-
771-BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file);
772-gboolean bamf_application_get_show_stubs (BamfApplication *application);
773-
774-BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files);
775-
776-BamfApplication * bamf_application_new_with_wmclass (const char *wmclass);
777+char * bamf_application_get_wmclass (BamfApplication *application);
778+void bamf_application_set_wmclass (BamfApplication *application,
779+ const char *wmclass);
780+
781+BamfApplication * bamf_application_new (void);
782+
783+BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file);
784+gboolean bamf_application_get_show_stubs (BamfApplication *application);
785+
786+BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files);
787+
788+BamfApplication * bamf_application_new_with_wmclass (const char *wmclass);
789
790 #endif
791
792=== removed file 'src/bamf-control-glue.xml'
793--- src/bamf-control-glue.xml 2010-08-18 23:22:58 +0000
794+++ src/bamf-control-glue.xml 1970-01-01 00:00:00 +0000
795@@ -1,35 +0,0 @@
796-<?xml version="1.0" encoding="UTF-8" ?>
797-
798-<node name="/org/ayatana/bamf">
799-
800- <interface name="org.ayatana.bamf.control">
801-
802- <method name="RegisterApplicationForPid">
803- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_application_for_pid" />
804- <arg type="s" name="application" direction="in" />
805- <arg type="i" name="pid" direction="in" />
806- </method>
807-
808- <method name="RegisterTabProvider">
809- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_tab_provider" />
810- <annotation name="org.freedesktop.DBus.GLib.Async" value="" />
811- <arg type="s" name="tab_path" direction="in" />
812- </method>
813-
814- <method name="OmNomNomDesktopFile">
815- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_insert_desktop_file" />
816- <arg type="s" name="tab_path" direction="in" />
817- </method>
818-
819- <method name="SetApproverBehavior">
820- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_set_approver_behavior" />
821- <arg type="i" name="behavior" direction="in" />
822- </method>
823-
824- <method name="Quit">
825- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_quit" />
826- </method>
827-
828- </interface>
829-
830-</node>
831
832=== modified file 'src/bamf-control.c'
833--- src/bamf-control.c 2011-08-01 23:25:01 +0000
834+++ src/bamf-control.c 2012-01-19 19:16:25 +0000
835@@ -1,5 +1,5 @@
836 /*
837- * Copyright (C) 2010 Canonical Ltd
838+ * Copyright (C) 2010-2011 Canonical Ltd
839 *
840 * This program is free software: you can redistribute it and/or modify
841 * it under the terms of the GNU General Public License version 3 as
842@@ -14,6 +14,7 @@
843 * along with this program. If not, see <http://www.gnu.org/licenses/>.
844 *
845 * Authored by: Jason Smith <jason.smith@canonical.com>
846+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
847 *
848 */
849
850@@ -21,11 +22,10 @@
851 #include "bamf-tab-source.h"
852 #include "bamf-matcher.h"
853 #include "bamf-control.h"
854-#include "bamf-control-glue.h"
855 #include "bamf-indicator-source.h"
856-#include <gtk/gtk.h>
857+#include "bamf-daemon.h"
858
859-G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT);
860+G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON);
861 #define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
862 BAMF_TYPE_CONTROL, BamfControlPrivate))
863
864@@ -56,26 +56,12 @@
865 static void
866 bamf_control_constructed (GObject *object)
867 {
868- BamfControl *control;
869- DBusGConnection *bus;
870- GError *error = NULL;
871+ GDBusConnection *gbus;
872
873 if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed)
874 G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object);
875
876- control = BAMF_CONTROL (object);
877-
878- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
879-
880- g_return_if_fail (bus);
881-
882- dbus_g_connection_register_g_object (bus, BAMF_CONTROL_PATH,
883- G_OBJECT (control));
884-
885-
886- GDBusConnection *gbus;
887 gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
888-
889 g_dbus_connection_signal_subscribe (gbus,
890 NULL,
891 "org.gtk.gio.DesktopAppInfo",
892@@ -84,14 +70,100 @@
893 NULL,
894 0,
895 bamf_control_on_launched_callback,
896- control,
897+ BAMF_CONTROL (object),
898 NULL);
899 }
900
901+static gboolean
902+on_dbus_handle_quit (BamfDBusControl *interface,
903+ GDBusMethodInvocation *invocation,
904+ BamfControl *self)
905+{
906+ bamf_control_quit (self);
907+ g_dbus_method_invocation_return_value (invocation, NULL);
908+
909+ return TRUE;
910+}
911+
912+static gboolean
913+on_dbus_handle_set_approver_behavior (BamfDBusControl *interface,
914+ GDBusMethodInvocation *invocation,
915+ gint behavior,
916+ BamfControl *self)
917+{
918+ bamf_control_set_approver_behavior (self, behavior);
919+ g_dbus_method_invocation_return_value (invocation, NULL);
920+
921+ return TRUE;
922+}
923+
924+static gboolean
925+on_dbus_handle_om_nom_nom_desktop_file (BamfDBusControl *interface,
926+ GDBusMethodInvocation *invocation,
927+ const gchar *desktop_file,
928+ BamfControl *self)
929+{
930+ bamf_control_insert_desktop_file (self, desktop_file);
931+ g_dbus_method_invocation_return_value (invocation, NULL);
932+
933+ return TRUE;
934+}
935+
936+static gboolean
937+on_dbus_handle_register_tab_provider (BamfDBusControl *interface,
938+ GDBusMethodInvocation *invocation,
939+ const gchar *tab_path,
940+ BamfControl *self)
941+{
942+ const gchar *sender = g_dbus_method_invocation_get_sender (invocation);
943+ bamf_control_register_tab_provider (self, sender, tab_path);
944+ g_dbus_method_invocation_return_value (invocation, NULL);
945+
946+ return TRUE;
947+}
948+
949+static gboolean
950+on_dbus_handle_register_application_for_pid (BamfDBusControl *interface,
951+ GDBusMethodInvocation *invocation,
952+ const gchar *application,
953+ guint pid,
954+ BamfControl *self)
955+{
956+ bamf_control_register_application_for_pid (self, application, pid);
957+ g_dbus_method_invocation_return_value (invocation, NULL);
958+
959+ return TRUE;
960+}
961+
962 static void
963 bamf_control_init (BamfControl * self)
964 {
965 self->priv = BAMF_CONTROL_GET_PRIVATE (self);
966+ self->priv->sources = NULL;
967+
968+ /* Registering signal callbacks to reply to dbus method calls */
969+ g_signal_connect (self, "handle-quit",
970+ G_CALLBACK (on_dbus_handle_quit), self);
971+
972+ g_signal_connect (self, "handle-set-approver-behavior",
973+ G_CALLBACK (on_dbus_handle_set_approver_behavior), self);
974+
975+ g_signal_connect (self, "handle-om-nom-nom-desktop-file",
976+ G_CALLBACK (on_dbus_handle_om_nom_nom_desktop_file), self);
977+
978+ g_signal_connect (self, "handle-register-tab-provider",
979+ G_CALLBACK (on_dbus_handle_register_tab_provider), self);
980+
981+ g_signal_connect (self, "handle-register-application-for-pid",
982+ G_CALLBACK (on_dbus_handle_register_application_for_pid), self);
983+}
984+
985+static void
986+bamf_control_finalize (GObject *object)
987+{
988+ BamfControl *self = BAMF_CONTROL (object);
989+ g_list_free_full (self->priv->sources, g_object_unref);
990+ self->priv->sources = NULL;
991 }
992
993 static void
994@@ -100,94 +172,68 @@
995 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
996
997 obj_class->constructed = bamf_control_constructed;
998-
999- dbus_g_object_type_install_info (BAMF_TYPE_CONTROL,
1000- &dbus_glib_bamf_control_object_info);
1001+ obj_class->finalize = bamf_control_finalize;
1002
1003 g_type_class_add_private (klass, sizeof (BamfControlPrivate));
1004 }
1005
1006-gboolean
1007+void
1008 bamf_control_set_approver_behavior (BamfControl *control,
1009- gint32 behavior,
1010- GError **error)
1011+ gint32 behavior)
1012 {
1013- bamf_indicator_source_set_behavior (bamf_indicator_source_get_default (), behavior);
1014-
1015- return TRUE;
1016+ BamfIndicatorSource *indicator_source = bamf_indicator_source_get_default ();
1017+ bamf_indicator_source_set_behavior (indicator_source, behavior);
1018 }
1019
1020-gboolean
1021+void
1022 bamf_control_register_application_for_pid (BamfControl *control,
1023- char *application,
1024- gint32 pid,
1025- GError **error)
1026+ const char *application,
1027+ gint32 pid)
1028 {
1029- bamf_matcher_register_desktop_file_for_pid (bamf_matcher_get_default (),
1030- application, pid);
1031-
1032- return TRUE;
1033+ BamfMatcher *matcher = bamf_matcher_get_default ();
1034+ bamf_matcher_register_desktop_file_for_pid (matcher, application, pid);
1035 }
1036
1037-gboolean
1038+void
1039 bamf_control_insert_desktop_file (BamfControl *control,
1040- char *path,
1041- GError **error)
1042+ const char *path)
1043 {
1044- bamf_matcher_load_desktop_file (bamf_matcher_get_default (), path);
1045-
1046- return TRUE;
1047+ BamfMatcher *matcher = bamf_matcher_get_default ();
1048+ bamf_matcher_load_desktop_file (matcher, path);
1049 }
1050
1051-gboolean
1052+void
1053 bamf_control_register_tab_provider (BamfControl *control,
1054- char *path,
1055- DBusGMethodInvocation *context)
1056+ const char *sender,
1057+ const char *path)
1058 {
1059 BamfTabSource *source;
1060- char *bus;
1061-
1062- if (!path)
1063- {
1064- dbus_g_method_return (context);
1065- return TRUE;
1066- }
1067-
1068- bus = dbus_g_method_get_sender (context);
1069-
1070- if (!bus)
1071- {
1072- dbus_g_method_return (context);
1073- return TRUE;
1074- }
1075-
1076- source = bamf_tab_source_new (bus, path);
1077-
1078- if (!BAMF_IS_TAB_SOURCE (source))
1079- {
1080- dbus_g_method_return (context);
1081- return TRUE;
1082- }
1083-
1084- control->priv->sources = g_list_prepend (control->priv->sources, source);
1085-
1086- dbus_g_method_return (context);
1087- return TRUE;
1088+
1089+ if (!path || !sender)
1090+ {
1091+ return;
1092+ }
1093+
1094+ source = bamf_tab_source_new (g_strdup (sender), g_strdup (path));
1095+
1096+ if (BAMF_IS_TAB_SOURCE (source))
1097+ {
1098+ control->priv->sources = g_list_prepend (control->priv->sources, source);
1099+ }
1100 }
1101
1102 static gboolean
1103 bamf_control_on_quit (BamfControl *control)
1104 {
1105- gtk_main_quit ();
1106+ BamfDaemon *daemon = bamf_daemon_get_default ();
1107+ bamf_daemon_stop (daemon);
1108 return FALSE;
1109 }
1110
1111-gboolean
1112-bamf_control_quit (BamfControl *control,
1113- GError **error)
1114+void
1115+bamf_control_quit (BamfControl *control)
1116 {
1117 g_idle_add ((GSourceFunc) bamf_control_on_quit, control);
1118- return TRUE;
1119 }
1120
1121 BamfControl *
1122@@ -198,8 +244,7 @@
1123 if (!BAMF_IS_CONTROL (control))
1124 {
1125 control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL);
1126- return control;
1127 }
1128
1129- return g_object_ref (G_OBJECT (control));
1130+ return control;
1131 }
1132
1133=== modified file 'src/bamf-control.h'
1134--- src/bamf-control.h 2010-08-18 23:22:58 +0000
1135+++ src/bamf-control.h 2012-01-19 19:16:25 +0000
1136@@ -1,5 +1,5 @@
1137 /*
1138- * Copyright (C) 2010 Canonical Ltd
1139+ * Copyright (C) 2010-2011 Canonical Ltd
1140 *
1141 * This program is free software: you can redistribute it and/or modify
1142 * it under the terms of the GNU General Public License version 3 as
1143@@ -14,6 +14,7 @@
1144 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1145 *
1146 * Authored by: Jason Smith <jason.smith@canonical.com>
1147+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1148 *
1149 */
1150
1151@@ -24,8 +25,7 @@
1152 #include "bamf.h"
1153 #include <glib.h>
1154 #include <glib-object.h>
1155-#include <dbus/dbus-glib.h>
1156-#include <dbus/dbus-glib-lowlevel.h>
1157+#include <gio/gio.h>
1158
1159 #define BAMF_TYPE_CONTROL (bamf_control_get_type ())
1160 #define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl))
1161@@ -40,12 +40,12 @@
1162
1163 struct _BamfControlClass
1164 {
1165- GObjectClass parent;
1166+ BamfDBusControlSkeletonClass parent;
1167 };
1168
1169 struct _BamfControl
1170 {
1171- GObject parent;
1172+ BamfDBusControlSkeleton parent;
1173
1174 /* private */
1175 BamfControlPrivate *priv;
1176@@ -53,25 +53,21 @@
1177
1178 GType bamf_control_get_type (void) G_GNUC_CONST;
1179
1180-gboolean bamf_control_register_application_for_pid (BamfControl *control,
1181- char *application,
1182- gint32 pid,
1183- GError **error);
1184-
1185-gboolean bamf_control_register_tab_provider (BamfControl *control,
1186- char *path,
1187- DBusGMethodInvocation *context);
1188-
1189-gboolean bamf_control_insert_desktop_file (BamfControl *control,
1190- char *path,
1191- GError **error);
1192-
1193-gboolean bamf_control_set_approver_behavior (BamfControl *control,
1194- gint32 behavior,
1195- GError **error);
1196-
1197-gboolean bamf_control_quit (BamfControl *control,
1198- GError **error);
1199+void bamf_control_register_application_for_pid (BamfControl *control,
1200+ const char *application,
1201+ gint32 pid);
1202+
1203+void bamf_control_register_tab_provider (BamfControl *control,
1204+ const char *sender,
1205+ const char *path);
1206+
1207+void bamf_control_insert_desktop_file (BamfControl *control,
1208+ const char *path);
1209+
1210+void bamf_control_set_approver_behavior (BamfControl *control,
1211+ gint32 behavior);
1212+
1213+void bamf_control_quit (BamfControl *control);
1214
1215 BamfControl * bamf_control_get_default (void);
1216
1217
1218=== added file 'src/bamf-daemon.c'
1219--- src/bamf-daemon.c 1970-01-01 00:00:00 +0000
1220+++ src/bamf-daemon.c 2012-01-19 19:16:25 +0000
1221@@ -0,0 +1,215 @@
1222+/*
1223+ * Copyright (C) 2011 Canonical Ltd
1224+ *
1225+ * This program is free software: you can redistribute it and/or modify
1226+ * it under the terms of the GNU General Public License version 3 as
1227+ * published by the Free Software Foundation.
1228+ *
1229+ * This program is distributed in the hope that it will be useful,
1230+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1231+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1232+ * GNU General Public License for more details.
1233+ *
1234+ * You should have received a copy of the GNU General Public License
1235+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1236+ *
1237+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1238+ *
1239+ */
1240+
1241+#include "bamf.h"
1242+
1243+#include "bamf-daemon.h"
1244+#include "bamf-matcher.h"
1245+#include "bamf-control.h"
1246+#include "bamf-indicator-source.h"
1247+
1248+G_DEFINE_TYPE (BamfDaemon, bamf_daemon, G_TYPE_OBJECT);
1249+#define BAMF_DAEMON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
1250+ BAMF_TYPE_DAEMON, BamfDaemonPrivate))
1251+
1252+static BamfDaemon *instance = NULL;
1253+
1254+struct _BamfDaemonPrivate
1255+{
1256+ BamfMatcher *matcher;
1257+ BamfControl *control;
1258+ BamfIndicatorSource *approver;
1259+ GMainLoop *loop;
1260+};
1261+
1262+gboolean
1263+bamf_daemon_is_running (BamfDaemon *self)
1264+{
1265+ g_return_val_if_fail (self, FALSE);
1266+
1267+ if (self->priv->loop && g_main_loop_is_running (self->priv->loop))
1268+ {
1269+ return TRUE;
1270+ }
1271+
1272+ return FALSE;
1273+}
1274+
1275+static void
1276+bamf_on_bus_acquired (GDBusConnection *connection, const gchar *name,
1277+ BamfDaemon *self)
1278+{
1279+ GError *error = NULL;
1280+ g_return_if_fail (BAMF_IS_DAEMON (self));
1281+
1282+ g_debug ("Acquired a message bus connection");
1283+
1284+ g_dbus_connection_set_exit_on_close (connection, TRUE);
1285+
1286+ self->priv->matcher = bamf_matcher_get_default ();
1287+ self->priv->control = bamf_control_get_default ();
1288+ //self->priv->approver = bamf_indicator_source_get_default ();
1289+
1290+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->matcher),
1291+ connection,
1292+ BAMF_MATCHER_PATH,
1293+ &error);
1294+
1295+ if (error)
1296+ {
1297+ g_critical ("Can't register BAMF matcher at path %s: %s", BAMF_MATCHER_PATH,
1298+ error->message);
1299+ g_clear_error (&error);
1300+ }
1301+
1302+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->control),
1303+ connection,
1304+ BAMF_CONTROL_PATH,
1305+ &error);
1306+
1307+ if (error)
1308+ {
1309+ g_critical ("Can't register BAMF control at path %s: %s", BAMF_CONTROL_PATH,
1310+ error->message);
1311+ g_clear_error (&error);
1312+ }
1313+/*
1314+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->approver),
1315+ connection,
1316+ BAMF_INDICATOR_SOURCE_PATH,
1317+ &error);
1318+
1319+ if (error)
1320+ {
1321+ g_critical ("Can't register BAMF approver at path %s: %s",
1322+ BAMF_INDICATOR_SOURCE_PATH, error->message);
1323+ g_clear_error (&error);
1324+ }
1325+*/
1326+}
1327+
1328+static void
1329+bamf_on_name_acquired (GDBusConnection *connection, const gchar *name,
1330+ BamfDaemon *self)
1331+{
1332+ g_debug ("Acquired the name %s", name);
1333+}
1334+
1335+static void
1336+bamf_on_name_lost (GDBusConnection *connection, const gchar *name, BamfDaemon *self)
1337+{
1338+ g_critical ("Lost the name %s, another BAMF daemon is currently running", name);
1339+
1340+ bamf_daemon_stop (self);
1341+}
1342+
1343+void
1344+bamf_daemon_start (BamfDaemon *self)
1345+{
1346+ g_return_if_fail (BAMF_IS_DAEMON (self));
1347+
1348+ if (bamf_daemon_is_running (self))
1349+ return;
1350+
1351+ g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE,
1352+ G_BUS_NAME_OWNER_FLAGS_NONE,
1353+ (GBusAcquiredCallback) bamf_on_bus_acquired,
1354+ (GBusNameAcquiredCallback) bamf_on_name_acquired,
1355+ (GBusNameLostCallback) bamf_on_name_lost,
1356+ self, NULL);
1357+
1358+ g_main_loop_run (self->priv->loop);
1359+}
1360+
1361+void
1362+bamf_daemon_stop (BamfDaemon *self)
1363+{
1364+ g_return_if_fail (BAMF_IS_DAEMON (self));
1365+
1366+ if (self->priv->matcher)
1367+ {
1368+ g_object_unref (self->priv->matcher);
1369+ self->priv->matcher = NULL;
1370+ }
1371+
1372+ if (self->priv->control)
1373+ {
1374+ g_object_unref (self->priv->control);
1375+ self->priv->control = NULL;
1376+ }
1377+
1378+ if (self->priv->approver)
1379+ {
1380+ g_object_unref (self->priv->approver);
1381+ self->priv->approver = NULL;
1382+ }
1383+
1384+ g_main_loop_quit (self->priv->loop);
1385+}
1386+
1387+static void
1388+bamf_daemon_dispose (GObject *object)
1389+{
1390+ BamfDaemon *self = BAMF_DAEMON (object);
1391+
1392+ bamf_daemon_stop (self);
1393+
1394+ if (self->priv->loop)
1395+ {
1396+ g_main_loop_unref (self->priv->loop);
1397+ self->priv->loop = NULL;
1398+ }
1399+
1400+ G_OBJECT_CLASS (bamf_daemon_parent_class)->dispose (object);
1401+}
1402+
1403+static void
1404+bamf_daemon_finalize (GObject *object)
1405+{
1406+ instance = NULL;
1407+}
1408+
1409+static void
1410+bamf_daemon_init (BamfDaemon *self)
1411+{
1412+ BamfDaemonPrivate *priv;
1413+ priv = self->priv = BAMF_DAEMON_GET_PRIVATE (self);
1414+
1415+ priv->loop = g_main_loop_new (NULL, FALSE);
1416+}
1417+
1418+static void
1419+bamf_daemon_class_init (BamfDaemonClass * klass)
1420+{
1421+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
1422+
1423+ object_class->dispose = bamf_daemon_dispose;
1424+ object_class->finalize = bamf_daemon_finalize;
1425+
1426+ g_type_class_add_private (klass, sizeof (BamfDaemonPrivate));
1427+}
1428+
1429+BamfDaemon *
1430+bamf_daemon_get_default (void)
1431+{
1432+ if (!BAMF_IS_DAEMON (instance))
1433+ instance = (BamfDaemon *) g_object_new (BAMF_TYPE_DAEMON, NULL);
1434+
1435+ return instance;
1436+}
1437
1438=== added file 'src/bamf-daemon.h'
1439--- src/bamf-daemon.h 1970-01-01 00:00:00 +0000
1440+++ src/bamf-daemon.h 2012-01-19 19:16:25 +0000
1441@@ -0,0 +1,61 @@
1442+/*
1443+ * Copyright (C) 2011 Canonical Ltd
1444+ *
1445+ * This program is free software: you can redistribute it and/or modify
1446+ * it under the terms of the GNU General Public License version 3 as
1447+ * published by the Free Software Foundation.
1448+ *
1449+ * This program is distributed in the hope that it will be useful,
1450+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1451+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1452+ * GNU General Public License for more details.
1453+ *
1454+ * You should have received a copy of the GNU General Public License
1455+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1456+ *
1457+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1458+ *
1459+ */
1460+
1461+#ifndef __BAMFDAEMON_H__
1462+#define __BAMFDAEMON_H__
1463+
1464+#include "bamf.h"
1465+#include <glib.h>
1466+#include <glib-object.h>
1467+
1468+#define BAMF_TYPE_DAEMON (bamf_daemon_get_type ())
1469+#define BAMF_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_DAEMON, BamfDaemon))
1470+#define BAMF_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_DAEMON))
1471+#define BAMF_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_DAEMON, BamfDaemonClass))
1472+#define BAMF_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_DAEMON))
1473+#define BAMF_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_DAEMON, BamfDaemonClass))
1474+
1475+typedef struct _BamfDaemon BamfDaemon;
1476+typedef struct _BamfDaemonClass BamfDaemonClass;
1477+typedef struct _BamfDaemonPrivate BamfDaemonPrivate;
1478+
1479+struct _BamfDaemonClass
1480+{
1481+ GObjectClass parent;
1482+};
1483+
1484+struct _BamfDaemon
1485+{
1486+ GObject parent;
1487+
1488+ /* private */
1489+ BamfDaemonPrivate *priv;
1490+};
1491+
1492+GType bamf_daemon_get_type (void) G_GNUC_CONST;
1493+
1494+void bamf_daemon_start (BamfDaemon *self);
1495+
1496+void bamf_daemon_stop (BamfDaemon *self);
1497+
1498+gboolean bamf_daemon_is_running (BamfDaemon *self);
1499+
1500+BamfDaemon * bamf_daemon_get_default (void);
1501+
1502+#endif //__BAMFDAEMON_H__
1503
1504=== removed file 'src/bamf-indicator-glue.xml'
1505--- src/bamf-indicator-glue.xml 2010-07-09 08:05:06 +0000
1506+++ src/bamf-indicator-glue.xml 1970-01-01 00:00:00 +0000
1507@@ -1,23 +0,0 @@
1508-<?xml version="1.0" encoding="UTF-8" ?>
1509-
1510-<node name="/org/ayatana/bamf">
1511-
1512- <interface name="org.ayatana.bamf.indicator">
1513-
1514- <method name="Path">
1515- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_path" />
1516- <arg type="s" name="path" direction="out">
1517- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
1518- </arg>
1519- </method>
1520-
1521- <method name="Address">
1522- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_address" />
1523- <arg type="s" name="address" direction="out">
1524- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
1525- </arg>
1526- </method>
1527-
1528- </interface>
1529-
1530-</node>
1531
1532=== removed file 'src/bamf-indicator-source-glue.xml'
1533--- src/bamf-indicator-source-glue.xml 2011-01-14 06:35:14 +0000
1534+++ src/bamf-indicator-source-glue.xml 1970-01-01 00:00:00 +0000
1535@@ -1,28 +0,0 @@
1536-<?xml version="1.0" encoding="UTF-8"?>
1537-<node name="/org/ayatana/bamf">
1538- <interface name="com.canonical.StatusNotifierApprover">
1539- <signal name="ReviseJudgement">
1540- <arg type="b" name="approved" direction="out" />
1541- <arg type="s" name="address" direction="out" />
1542- <arg type="o" name="path" direction="out" />
1543- </signal>
1544-
1545- <!-- Methods -->
1546- <method name="ApproveItem">
1547- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_source_approve_item" />
1548- <!-- KSNI ID -->
1549- <arg type="s" name="id" direction="in" />
1550- <!-- KSNI Category -->
1551- <arg type="s" name="category" direction="in" />
1552- <!-- Application PID -->
1553- <arg type="u" name="pid" direction="in" />
1554- <!-- Application DBus Address -->
1555- <arg type="s" name="address" direction="in" />
1556- <!-- Application DBus Path for KSNI interface -->
1557- <arg type="o" name="path" direction="in" />
1558- <!-- So, what do you think? -->
1559- <arg type="b" name="approved" direction="out" />
1560- </method>
1561-
1562- </interface>
1563-</node>
1564
1565=== modified file 'src/bamf-indicator-source.c'
1566--- src/bamf-indicator-source.c 2011-02-09 18:45:53 +0000
1567+++ src/bamf-indicator-source.c 2012-01-19 19:16:25 +0000
1568@@ -1,39 +1,32 @@
1569 /*
1570- * bamf-notification-approver.c
1571- * This file is part of BAMF
1572- *
1573- * Copyright (C) 2010 - Jason Smith
1574- *
1575- * BAMF is free software; you can redistribute it and/or modify
1576- * it under the terms of the GNU General Public License as published by
1577- * the Free Software Foundation; either version 2 of the License, or
1578- * (at your option) any later version.
1579- *
1580- * BAMF is distributed in the hope that it will be useful,
1581+ * Copyright (C) 2010-2011 Canonical Ltd
1582+ *
1583+ * This program is free software: you can redistribute it and/or modify
1584+ * it under the terms of the GNU General Public License version 3 as
1585+ * published by the Free Software Foundation.
1586+ *
1587+ * This program is distributed in the hope that it will be useful,
1588 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1589 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1590 * GNU General Public License for more details.
1591 *
1592 * You should have received a copy of the GNU General Public License
1593- * along with BAMF; if not, write to the Free Software
1594- * Foundation, Inc., 51 Franklin St, Fifth Floor,
1595- * Boston, MA 02110-1301 USA
1596+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1597+ *
1598+ * Authored by: Jason Smith <jason.smith@canonical.com>
1599+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1600+ *
1601 */
1602
1603-
1604-#include "bamf-marshal.h"
1605 #include "bamf-indicator-source.h"
1606-#include "bamf-indicator-source-glue.h"
1607-#include <dbus/dbus-glib-bindings.h>
1608
1609-#define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate))
1610-#define BAMF_INDICATOR_SOURCE_PATH "/org/ayatana/bamf/IndicatorSource"
1611+#define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
1612+ BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate))
1613
1614 enum
1615 {
1616 INDICATOR_OPENED,
1617 INDICATOR_CLOSED,
1618- REVISE_JUDGEMENT,
1619
1620 LAST_SIGNAL,
1621 };
1622@@ -43,17 +36,17 @@
1623 struct _BamfIndicatorSourcePrivate
1624 {
1625 GList *indicators;
1626- DBusGProxy *proxy;
1627+ GDBusProxy *proxy;
1628 int behavior;
1629 };
1630
1631-G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, G_TYPE_OBJECT)
1632+G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, STATUS_NOTIFIER_APPROVER_TYPE__SKELETON)
1633
1634 GList *
1635 bamf_indicator_source_get_indicators (BamfIndicatorSource *self)
1636 {
1637 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL);
1638-
1639+
1640 return self->priv->indicators;
1641 }
1642
1643@@ -61,15 +54,15 @@
1644 on_indicator_closed (BamfView *view, BamfIndicatorSource *self)
1645 {
1646 BamfIndicator *indicator;
1647-
1648+
1649 g_return_if_fail (BAMF_IS_INDICATOR (view));
1650 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
1651-
1652+
1653 indicator = BAMF_INDICATOR (view);
1654-
1655+
1656 self->priv->indicators = g_list_remove (self->priv->indicators, indicator);
1657 g_signal_emit (self, indicator_source_signals[INDICATOR_CLOSED], 0, indicator);
1658-
1659+
1660 g_object_unref (G_OBJECT (indicator));
1661 }
1662
1663@@ -78,9 +71,10 @@
1664 {
1665 g_return_if_fail (BAMF_IS_INDICATOR (indicator));
1666 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
1667-
1668- char *address = bamf_indicator_get_address (indicator);
1669- char *path = bamf_indicator_get_path (indicator);
1670+
1671+ const char *address = bamf_indicator_get_address (indicator);
1672+ const char *path = bamf_indicator_get_path (indicator);
1673+ GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator));
1674 gboolean approve = TRUE;
1675
1676 switch (self->priv->behavior)
1677@@ -89,17 +83,14 @@
1678 approve = FALSE;
1679 break;
1680 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:
1681- approve = g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) == 0;
1682+ approve = (parents == NULL);
1683 break;
1684 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:
1685 approve = TRUE;
1686 break;
1687 }
1688-
1689- g_signal_emit (self, indicator_source_signals[REVISE_JUDGEMENT], 0, approve, address, path);
1690-
1691- g_free (address);
1692- g_free (path);
1693+
1694+ g_signal_emit_by_name (self, "revise-judgement", approve, address, path);
1695 }
1696
1697 void
1698@@ -114,9 +105,9 @@
1699
1700 if (priv->behavior == behavior)
1701 return;
1702-
1703+
1704 priv->behavior = behavior;
1705-
1706+
1707 g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self);
1708 }
1709
1710@@ -126,61 +117,80 @@
1711 const char *category,
1712 guint32 pid,
1713 const char *address,
1714- const char *path,
1715- gboolean *approve,
1716- GError **remote_error)
1717+ const char *path)
1718 {
1719- DBusGConnection *bus;
1720- DBusGProxy *dbus_proxy;
1721 GList *l;
1722 GError *error = NULL;
1723 BamfIndicator *indicator = NULL;
1724- *approve = TRUE;
1725- guint remote_pid;
1726-
1727+
1728 g_return_val_if_fail (category, TRUE);
1729 g_return_val_if_fail (path, TRUE);
1730 g_return_val_if_fail (address, TRUE);
1731 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE);
1732-
1733+
1734 if (g_strcmp0 (category, "ApplicationStatus") != 0 ||
1735 g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0)
1736 return TRUE;
1737-
1738+
1739 if (pid == 0)
1740 {
1741- g_warning ("Remote service passed indicator with pid of 0, manually fetching pid\n");
1742-
1743- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1744- g_return_val_if_fail (bus, TRUE);
1745-
1746- dbus_proxy = dbus_g_proxy_new_for_name (bus,
1747- DBUS_SERVICE_DBUS,
1748- DBUS_PATH_DBUS,
1749- DBUS_INTERFACE_DBUS);
1750- g_return_val_if_fail (dbus_proxy, TRUE);
1751-
1752- error = NULL;
1753- if (!org_freedesktop_DBus_get_connection_unix_process_id (dbus_proxy, address, &remote_pid, &error))
1754- {
1755- g_warning ("Could not get indicator process id: %s\n", error->message);
1756- g_error_free (error);
1757- }
1758-
1759- g_object_unref (G_OBJECT (dbus_proxy));
1760- pid = (guint32) remote_pid;
1761+ GDBusProxy *gproxy;
1762+ GVariant *remote_pid;
1763+
1764+ g_warning ("Remote service passed indicator with pid of 0, manually fetching pid");
1765+
1766+ gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1767+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
1768+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
1769+ NULL,
1770+ "org.freedesktop.DBus",
1771+ "/org/freedesktop/DBus",
1772+ "org.freedesktop.DBus",
1773+ NULL,
1774+ &error);
1775+
1776+ if (error)
1777+ {
1778+ g_warning ("Could not get indicator process id: %s", error->message);
1779+ g_clear_error (&error);
1780+ }
1781+
1782+ g_return_val_if_fail (G_IS_DBUS_PROXY (gproxy), TRUE);
1783+
1784+ remote_pid = g_dbus_proxy_call_sync (gproxy, "GetConnectionUnixProcessID",
1785+ g_variant_new ("(s)", address),
1786+ G_DBUS_CALL_FLAGS_NONE,
1787+ -1,
1788+ NULL,
1789+ &error);
1790+ if (error)
1791+ {
1792+ g_warning ("Could not get indicator process id: %s", error->message);
1793+ g_clear_error (&error);
1794+ return TRUE;
1795+ }
1796+
1797+ g_return_val_if_fail (remote_pid, TRUE);
1798+
1799+ pid = g_variant_get_uint32 (g_variant_get_child_value (remote_pid, 0));
1800+
1801+ g_object_unref (gproxy);
1802+ g_variant_unref (remote_pid);
1803+
1804+ if (pid == 0)
1805+ return TRUE;
1806 }
1807-
1808+
1809 for (l = self->priv->indicators; l; l = l->next)
1810 {
1811 if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path))
1812 {
1813- g_debug ("NotifierWatcher service passed already known indicator, ignoring\n");
1814+ g_debug ("NotifierWatcher service passed already known indicator, ignoring");
1815 indicator = BAMF_INDICATOR (l->data);
1816 break;
1817 }
1818 }
1819-
1820+
1821 if (!indicator)
1822 {
1823 indicator = bamf_indicator_new (id, path, address, pid);
1824@@ -189,101 +199,145 @@
1825 g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self);
1826 g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator);
1827 }
1828-
1829+
1830+ GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator));
1831+
1832 switch (self->priv->behavior)
1833 {
1834 case BAMF_INDICATOR_SOURCE_APPROVE_NONE:
1835- *approve = FALSE;
1836- break;
1837-
1838+ return FALSE;
1839+
1840 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:
1841- *approve = !(indicator && g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) > 0);
1842- break;
1843-
1844+ return !(indicator && parents);
1845+
1846 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:
1847- *approve = TRUE;
1848- break;
1849+ return TRUE;
1850 }
1851-
1852+
1853 return TRUE;
1854 }
1855
1856-static void on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self);
1857+static void status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec, BamfIndicatorSource *self);
1858
1859 static gboolean
1860 bamf_indicator_source_register_notification_approver (BamfIndicatorSource *self)
1861 {
1862- DBusGConnection *bus;
1863- GError *error = NULL;
1864 static int retry_count = 0;
1865-
1866- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1867- g_return_val_if_fail (bus, FALSE);
1868-
1869- self->priv->proxy = dbus_g_proxy_new_for_name_owner (bus,
1870- "com.canonical.indicator.application",
1871- "/StatusNotifierWatcher",
1872- "org.kde.StatusNotifierWatcher",
1873- &error);
1874-
1875- if (self->priv->proxy)
1876- {
1877- if (dbus_g_proxy_call (self->priv->proxy,
1878- "XAyatanaRegisterNotificationApprover",
1879- &error,
1880- DBUS_TYPE_G_OBJECT_PATH, BAMF_INDICATOR_SOURCE_PATH,
1881- G_TYPE_STRV, NULL,
1882- G_TYPE_INVALID,
1883- G_TYPE_INVALID))
1884+ GDBusProxy *gproxy;
1885+ GError *error = NULL;
1886+ gchar *owner;
1887+
1888+ gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1889+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
1890+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
1891+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
1892+ NULL,
1893+ "org.kde.StatusNotifierWatcher",//"com.canonical.indicator.application",
1894+ "/StatusNotifierWatcher",
1895+ "org.kde.StatusNotifierWatcher",
1896+ NULL,
1897+ &error);
1898+
1899+ if (error)
1900+ {
1901+ g_debug ("Failed to get notification approver proxy: %s", error->message);
1902+ g_error_free (error);
1903+ }
1904+ else
1905+ {
1906+ owner = g_dbus_proxy_get_name_owner (gproxy);
1907+
1908+ if (owner)
1909 {
1910- g_debug ("Remote notification approver registered\n");
1911- g_signal_connect (G_OBJECT (self->priv->proxy), "destroy", (GCallback) on_proxy_destroy, self);
1912- retry_count = 0;
1913- return FALSE;
1914+ g_free (owner);
1915+
1916+ GVariantBuilder tuple, array;
1917+ g_variant_builder_init (&tuple, G_VARIANT_TYPE_TUPLE);
1918+ g_variant_builder_add_value (&tuple, g_variant_new_object_path (BAMF_INDICATOR_SOURCE_PATH));
1919+ g_variant_builder_init (&array, G_VARIANT_TYPE ("as"));
1920+ g_variant_builder_add_value (&tuple, g_variant_builder_end (&array));
1921+
1922+ g_dbus_proxy_call_sync (gproxy, "XAyatanaRegisterNotificationApprover",
1923+ g_variant_builder_end (&tuple),
1924+ G_DBUS_CALL_FLAGS_NONE,
1925+ -1,
1926+ NULL,
1927+ &error);
1928+
1929+ if (!error)
1930+ {
1931+ g_debug ("Remote notification approver registered");
1932+ g_signal_connect (G_OBJECT (gproxy), "notify::g-name-owner",
1933+ (GCallback) status_notifier_proxy_owner_changed,
1934+ self);
1935+
1936+ if (self->priv->proxy)
1937+ g_object_unref (self->priv->proxy);
1938+
1939+ self->priv->proxy = gproxy;
1940+ retry_count = 0;
1941+ return FALSE;
1942+ }
1943+ else
1944+ {
1945+ g_debug ("Failed to register as approver: %s", error->message);
1946+ g_error_free (error);
1947+ }
1948 }
1949 else
1950 {
1951- g_debug ("Failed to register as approver: %s\n", error->message);
1952- g_error_free (error);
1953+ g_debug ("Failed to get notification approver proxy: no owner available");
1954 }
1955- }
1956- else
1957- {
1958- g_debug ("Failed to get notification approver proxy: %s\n", error->message);
1959- g_error_free (error);
1960- }
1961+
1962+ g_object_unref (gproxy);
1963+ }
1964+
1965 retry_count++;
1966-
1967+
1968 if (retry_count > 10)
1969 {
1970- g_debug ("Retry count expired\n");
1971+ g_debug ("Retry count expired");
1972 return FALSE;
1973 }
1974-
1975- g_debug ("Retrying registration in 2 seconds\n");
1976+
1977+ g_debug ("Retrying registration in 2 seconds");
1978 return TRUE;
1979 }
1980
1981 static void
1982-on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self)
1983+status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec,
1984+ BamfIndicatorSource *self)
1985 {
1986- g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
1987-
1988- g_debug ("Remote approver service died, re-establishing connection\n");
1989-
1990+ g_debug ("Remote approver service died, re-establishing connection");
1991+ g_object_unref (self->priv->proxy);
1992+ self->priv->proxy = NULL;
1993+
1994 if (bamf_indicator_source_register_notification_approver (self))
1995- g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
1996+ g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
1997+}
1998+
1999+static gboolean
2000+on_dbus_handle_approve_item (BamfDBusMatcher *interface,
2001+ GDBusMethodInvocation *invocation,
2002+ const gchar *id,
2003+ const gchar *category,
2004+ guint pid,
2005+ const gchar *address,
2006+ const gchar *path,
2007+ BamfIndicatorSource *self)
2008+{
2009+ gboolean approved = bamf_indicator_source_approve_item (self, id, category,
2010+ pid, address, path);
2011+ g_dbus_method_invocation_return_value (invocation,
2012+ g_variant_new ("(b)", approved));
2013+
2014+ return TRUE;
2015 }
2016
2017 static void
2018 bamf_indicator_source_constructed (GObject *object)
2019 {
2020 BamfIndicatorSource *self;
2021- DBusGConnection *bus;
2022- GError *error = NULL;
2023-
2024- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
2025- g_return_if_fail (bus);
2026
2027 self = BAMF_INDICATOR_SOURCE (object);
2028
2029@@ -292,15 +346,27 @@
2030
2031 self->priv->behavior = BAMF_INDICATOR_SOURCE_APPROVE_ALL;
2032
2033- dbus_g_connection_register_g_object (bus, BAMF_INDICATOR_SOURCE_PATH, object);
2034-
2035 if (bamf_indicator_source_register_notification_approver (self))
2036- g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
2037+ g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
2038 }
2039
2040 static void
2041 bamf_indicator_source_dispose (GObject *object)
2042 {
2043+ BamfIndicatorSource *self = BAMF_INDICATOR_SOURCE (object);
2044+
2045+ if (self->priv->indicators)
2046+ {
2047+ g_list_free_full (self->priv->indicators, g_object_unref);
2048+ self->priv->indicators = NULL;
2049+ }
2050+
2051+ if (self->priv->proxy)
2052+ {
2053+ g_object_unref (self->priv->proxy);
2054+ self->priv->proxy = NULL;
2055+ }
2056+
2057 G_OBJECT_CLASS (bamf_indicator_source_parent_class)->dispose (object);
2058 }
2059
2060@@ -308,50 +374,41 @@
2061 bamf_indicator_source_class_init (BamfIndicatorSourceClass *klass)
2062 {
2063 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2064-
2065+
2066 object_class->dispose = bamf_indicator_source_dispose;
2067 object_class->constructed = bamf_indicator_source_constructed;
2068
2069- indicator_source_signals [REVISE_JUDGEMENT] =
2070- g_signal_new ("revise-judgement",
2071- G_OBJECT_CLASS_TYPE (klass),
2072- G_SIGNAL_RUN_FIRST,
2073- G_STRUCT_OFFSET (BamfIndicatorSourceClass, revise_judgement),
2074- NULL, NULL,
2075- bamf_marshal_VOID__BOOL_STRING_STRING,
2076- G_TYPE_NONE, 3,
2077- G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
2078+ g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate));
2079
2080 indicator_source_signals [INDICATOR_OPENED] =
2081- g_signal_new ("indicator-opened",
2082- G_OBJECT_CLASS_TYPE (klass),
2083- G_SIGNAL_RUN_FIRST,
2084- G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened),
2085- NULL, NULL,
2086- g_cclosure_marshal_VOID__OBJECT,
2087- G_TYPE_NONE, 1,
2088- BAMF_TYPE_INDICATOR);
2089+ g_signal_new ("indicator-opened",
2090+ G_OBJECT_CLASS_TYPE (klass),
2091+ G_SIGNAL_RUN_FIRST,
2092+ G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened),
2093+ NULL, NULL,
2094+ g_cclosure_marshal_VOID__OBJECT,
2095+ G_TYPE_NONE, 1,
2096+ BAMF_TYPE_INDICATOR);
2097
2098 indicator_source_signals [INDICATOR_CLOSED] =
2099- g_signal_new ("indicator-closed",
2100- G_OBJECT_CLASS_TYPE (klass),
2101- G_SIGNAL_RUN_FIRST,
2102- G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed),
2103- NULL, NULL,
2104- g_cclosure_marshal_VOID__OBJECT,
2105- G_TYPE_NONE, 1,
2106- BAMF_TYPE_INDICATOR);
2107-
2108- dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR_SOURCE,
2109- &dbus_glib_bamf_indicator_source_object_info);
2110-
2111- g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate));
2112+ g_signal_new ("indicator-closed",
2113+ G_OBJECT_CLASS_TYPE (klass),
2114+ G_SIGNAL_RUN_FIRST,
2115+ G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed),
2116+ NULL, NULL,
2117+ g_cclosure_marshal_VOID__OBJECT,
2118+ G_TYPE_NONE, 1,
2119+ BAMF_TYPE_INDICATOR);
2120 }
2121
2122 static void
2123 bamf_indicator_source_init (BamfIndicatorSource *self)
2124 {
2125 self->priv = BAMF_INDICATOR_SOURCE_GET_PRIVATE (self);
2126+
2127+ /* Registering signal callbacks to reply to dbus method calls */
2128+ g_signal_connect (self, "handle-approve-item",
2129+ G_CALLBACK (on_dbus_handle_approve_item), self);
2130 }
2131
2132 static BamfIndicatorSource *approver = NULL;
2133@@ -360,6 +417,7 @@
2134 bamf_indicator_source_get_default ()
2135 {
2136 if (!approver)
2137- return approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL);
2138- return BAMF_INDICATOR_SOURCE (g_object_ref (approver));
2139+ approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL);
2140+
2141+ return approver;
2142 }
2143
2144=== modified file 'src/bamf-indicator-source.h'
2145--- src/bamf-indicator-source.h 2010-08-18 23:22:58 +0000
2146+++ src/bamf-indicator-source.h 2012-01-19 19:16:25 +0000
2147@@ -1,23 +1,21 @@
2148 /*
2149- * bamf-notification-approver.h
2150- * This file is part of BAMF
2151- *
2152- * Copyright (C) 2010 - Jason Smith
2153- *
2154- * BAMF is free software; you can redistribute it and/or modify
2155- * it under the terms of the GNU General Public License as published by
2156- * the Free Software Foundation; either version 2 of the License, or
2157- * (at your option) any later version.
2158- *
2159- * BAMF is distributed in the hope that it will be useful,
2160+ * Copyright (C) 2010-2011 Canonical Ltd
2161+ *
2162+ * This program is free software: you can redistribute it and/or modify
2163+ * it under the terms of the GNU General Public License version 3 as
2164+ * published by the Free Software Foundation.
2165+ *
2166+ * This program is distributed in the hope that it will be useful,
2167 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2168 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2169 * GNU General Public License for more details.
2170 *
2171 * You should have received a copy of the GNU General Public License
2172- * along with BAMF; if not, write to the Free Software
2173- * Foundation, Inc., 51 Franklin St, Fifth Floor,
2174- * Boston, MA 02110-1301 USA
2175+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2176+ *
2177+ * Authored by: Jason Smith <jason.smith@canonical.com>
2178+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2179+ *
2180 */
2181
2182 #ifndef __BAMF_INDICATOR_SOURCE_H__
2183@@ -25,6 +23,7 @@
2184
2185 #include <glib-object.h>
2186 #include "bamf-indicator.h"
2187+#include "bamf-gdbus-indicator-source-generated.h"
2188
2189 G_BEGIN_DECLS
2190
2191@@ -48,13 +47,13 @@
2192 };
2193
2194 struct _BamfIndicatorSource {
2195- GObject parent;
2196-
2197+ StatusNotifierApproverSkeleton parent;
2198+
2199 BamfIndicatorSourcePrivate *priv;
2200 };
2201
2202 struct _BamfIndicatorSourceClass {
2203- GObjectClass parent_class;
2204+ StatusNotifierApproverSkeletonClass parent_class;
2205
2206 /*< signals >*/
2207 void (*indicator_opened) (BamfIndicatorSource *approver, BamfIndicator *indicator);
2208@@ -73,13 +72,11 @@
2209 GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self);
2210
2211 gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self,
2212- const char *id,
2213- const char *category,
2214- guint32 pid,
2215- const char *address,
2216- const char *proxy,
2217- gboolean *approve,
2218- GError **error);
2219+ const char *id,
2220+ const char *category,
2221+ guint32 pid,
2222+ const char *address,
2223+ const char *proxy);
2224
2225 void bamf_indicator_source_set_behavior (BamfIndicatorSource *self,
2226 gint32 behavior);
2227
2228=== modified file 'src/bamf-indicator.c'
2229--- src/bamf-indicator.c 2011-01-14 15:53:35 +0000
2230+++ src/bamf-indicator.c 2012-01-19 19:16:25 +0000
2231@@ -1,30 +1,27 @@
2232 /*
2233- * bamf-indicator.c
2234- * This file is part of BAMF
2235- *
2236- * Copyright (C) 2010 - Jason Smith
2237- *
2238- * BAMF is free software; you can redistribute it and/or modify
2239- * it under the terms of the GNU General Public License as published by
2240- * the Free Software Foundation; either version 2 of the License, or
2241- * (at your option) any later version.
2242- *
2243- * BAMF is distributed in the hope that it will be useful,
2244+ * Copyright (C) 2010-2011 Canonical Ltd
2245+ *
2246+ * This program is free software: you can redistribute it and/or modify
2247+ * it under the terms of the GNU General Public License version 3 as
2248+ * published by the Free Software Foundation.
2249+ *
2250+ * This program is distributed in the hope that it will be useful,
2251 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2252- * MERCHANINDICATORILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2253+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2254 * GNU General Public License for more details.
2255 *
2256 * You should have received a copy of the GNU General Public License
2257- * along with BAMF; if not, write to the Free Software
2258- * Foundation, Inc., 51 Franklin St, Fifth Floor,
2259- * Boston, MA 02110-1301 USA
2260+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2261+ *
2262+ * Authored by: Jason Smith <jason.smith@canonical.com>
2263+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2264+ *
2265 */
2266
2267 #include "bamf-indicator.h"
2268-#include "bamf-indicator-glue.h"
2269-
2270-
2271-#define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))
2272+
2273+#define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
2274+ BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))
2275
2276 enum
2277 {
2278@@ -39,34 +36,35 @@
2279
2280 struct _BamfIndicatorPrivate
2281 {
2282+ BamfDBusItemIndicator *dbus_iface;
2283 char *id;
2284 char *path;
2285 char *address;
2286 guint32 pid;
2287- DBusGProxy *proxy;
2288+ GDBusProxy *proxy;
2289 };
2290
2291 G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW)
2292
2293-char *
2294+const char *
2295 bamf_indicator_get_path (BamfIndicator *self)
2296 {
2297 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
2298- return g_strdup (self->priv->path);
2299+ return self->priv->path;
2300 }
2301
2302-char *
2303+const char *
2304 bamf_indicator_get_address (BamfIndicator *self)
2305 {
2306 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
2307- return g_strdup (self->priv->address);
2308+ return self->priv->address;
2309 }
2310
2311-char *
2312+const char *
2313 bamf_indicator_get_id (BamfIndicator *self)
2314 {
2315 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
2316- return g_strdup (self->priv->id);
2317+ return self->priv->id;
2318 }
2319
2320 guint32
2321@@ -86,10 +84,10 @@
2322 pid == self->priv->pid;
2323 }
2324
2325-static char *
2326+static const char *
2327 bamf_indicator_get_view_type (BamfView *view)
2328 {
2329- return g_strdup ("indicator");
2330+ return "indicator";
2331 }
2332
2333 static char *
2334@@ -104,7 +102,8 @@
2335 }
2336
2337 static void
2338-bamf_indicator_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
2339+bamf_indicator_set_property (GObject *object, guint property_id,
2340+ const GValue *value, GParamSpec *pspec)
2341 {
2342 BamfIndicator *self;
2343
2344@@ -129,7 +128,7 @@
2345 break;
2346
2347 default:
2348- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
2349+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2350 }
2351 }
2352
2353@@ -159,53 +158,96 @@
2354 break;
2355
2356 default:
2357- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
2358+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2359 }
2360 }
2361
2362 static void
2363-bamf_indicator_on_destroy (DBusGProxy *proxy, BamfIndicator *self)
2364+bamf_indicator_on_destroy (GObject *object, GParamSpec *pspec, BamfIndicator *self)
2365 {
2366+ g_object_unref (self->priv->proxy);
2367+ self->priv->proxy = NULL;
2368+
2369 bamf_view_close (BAMF_VIEW (self));
2370 }
2371
2372+static gboolean
2373+on_dbus_handle_path (BamfDBusItemIndicator *interface,
2374+ GDBusMethodInvocation *invocation,
2375+ BamfIndicator *self)
2376+{
2377+ const char *path = bamf_indicator_get_path (self);
2378+ g_dbus_method_invocation_return_value (invocation,
2379+ g_variant_new ("(s)", path ? path : ""));
2380+
2381+ return TRUE;
2382+}
2383+
2384+static gboolean
2385+on_dbus_handle_address (BamfDBusItemIndicator *interface,
2386+ GDBusMethodInvocation *invocation,
2387+ BamfIndicator *self)
2388+{
2389+ const char *address = bamf_indicator_get_address (self);
2390+ g_dbus_method_invocation_return_value (invocation,
2391+ g_variant_new ("(s)", address ? address : ""));
2392+
2393+ return TRUE;
2394+}
2395+
2396 static void
2397 bamf_indicator_constructed (GObject *object)
2398 {
2399 BamfIndicator *self;
2400 BamfIndicatorPrivate *priv;
2401- DBusGProxy *proxy;
2402- DBusGConnection *bus;
2403+ GDBusProxy *proxy;
2404 GError *error = NULL;
2405
2406 if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed)
2407 G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object);
2408-
2409+
2410 self = BAMF_INDICATOR (object);
2411 priv = self->priv;
2412-
2413- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
2414-
2415- if (!bus)
2416- {
2417- g_warning ("Could not get session bus\n");
2418- return;
2419- }
2420-
2421- error = NULL;
2422- if (!(proxy = dbus_g_proxy_new_for_name_owner (bus,
2423- priv->address,
2424- priv->path,
2425- "org.ayatana.indicator.application.service",
2426- &error)))
2427- {
2428- g_warning ("Could not setup proxy: %s %s\n", priv->address, priv->path);
2429- return;
2430- }
2431-
2432- priv->proxy = proxy;
2433-
2434- g_signal_connect (G_OBJECT (proxy), "destroy", (GCallback) bamf_indicator_on_destroy, self);
2435+
2436+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
2437+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
2438+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
2439+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
2440+ NULL,
2441+ priv->address,
2442+ priv->path,
2443+ "org.ayatana.indicator.application.service",
2444+ NULL,
2445+ &error);
2446+
2447+ if (error)
2448+ {
2449+ g_debug ("Could not setup proxy: %s %s: %s", priv->address, priv->path,
2450+ error->message);
2451+ g_error_free (error);
2452+ }
2453+ else
2454+ {
2455+ gchar *owner = g_dbus_proxy_get_name_owner (proxy);
2456+
2457+ if (owner)
2458+ {
2459+ g_free (owner);
2460+
2461+ g_signal_connect (G_OBJECT (proxy), "notify::g-name-owner",
2462+ G_CALLBACK (bamf_indicator_on_destroy), self);
2463+
2464+ if (priv->proxy)
2465+ g_object_unref (priv->proxy);
2466+
2467+ priv->proxy = proxy;
2468+ }
2469+ else
2470+ {
2471+ g_debug ("Failed to get notification approver proxy: no owner available");
2472+ g_object_unref (proxy);
2473+ }
2474+ }
2475 }
2476
2477 static void
2478@@ -243,17 +285,31 @@
2479 }
2480
2481 static void
2482+bamf_indicator_finalize (GObject *object)
2483+{
2484+ BamfIndicatorPrivate *priv;
2485+
2486+ priv = BAMF_INDICATOR (object)->priv;
2487+
2488+ g_object_unref (priv->dbus_iface);
2489+
2490+ G_OBJECT_CLASS (bamf_indicator_parent_class)->finalize (object);
2491+}
2492+
2493+static void
2494 bamf_indicator_class_init (BamfIndicatorClass *klass)
2495 {
2496 GParamSpec *pspec;
2497 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2498 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
2499-
2500- object_class->constructed = bamf_indicator_constructed;
2501- object_class->get_property = bamf_indicator_get_property;
2502- object_class->set_property = bamf_indicator_set_property;
2503- object_class->dispose = bamf_indicator_dispose;
2504- view_class->view_type = bamf_indicator_get_view_type;
2505+
2506+ object_class->constructed = bamf_indicator_constructed;
2507+ object_class->get_property = bamf_indicator_get_property;
2508+ object_class->set_property = bamf_indicator_set_property;
2509+ object_class->dispose = bamf_indicator_dispose;
2510+ object_class->finalize = bamf_indicator_finalize;
2511+
2512+ view_class->view_type = bamf_indicator_get_view_type;
2513 view_class->stable_bus_name = bamf_indicator_get_stable_bus_name;
2514
2515 pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
2516@@ -268,9 +324,6 @@
2517 pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE);
2518 g_object_class_install_property (object_class, PROP_PID, pspec);
2519
2520- dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR,
2521- &dbus_glib_bamf_indicator_object_info);
2522-
2523 g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate));
2524 }
2525
2526@@ -278,6 +331,19 @@
2527 bamf_indicator_init (BamfIndicator *self)
2528 {
2529 self->priv = BAMF_INDICATOR_GET_PRIVATE (self);
2530+
2531+ self->priv->dbus_iface = bamf_dbus_item_indicator_skeleton_new ();
2532+
2533+ /* Registering signal callbacks to reply to dbus method calls */
2534+ g_signal_connect (self->priv->dbus_iface, "handle-path",
2535+ G_CALLBACK (on_dbus_handle_path), self);
2536+
2537+ g_signal_connect (self->priv->dbus_iface, "handle-address",
2538+ G_CALLBACK (on_dbus_handle_address), self);
2539+
2540+ /* Setting the interface for the dbus object */
2541+ bamf_dbus_item_object_skeleton_set_indicator (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
2542+ self->priv->dbus_iface);
2543 }
2544
2545 BamfIndicator *
2546
2547=== modified file 'src/bamf-indicator.h'
2548--- src/bamf-indicator.h 2010-07-09 23:22:44 +0000
2549+++ src/bamf-indicator.h 2012-01-19 19:16:25 +0000
2550@@ -1,23 +1,21 @@
2551 /*
2552- * bamf-indicator.h
2553- * This file is part of BAMF
2554- *
2555- * Copyright (C) 2010 - Jason Smith
2556- *
2557- * BAMF is free software; you can redistribute it and/or modify
2558- * it under the terms of the GNU General Public License as published by
2559- * the Free Software Foundation; either version 2 of the License, or
2560- * (at your option) any later version.
2561- *
2562- * BAMF is distributed in the hope that it will be useful,
2563+ * Copyright (C) 2010-2011 Canonical Ltd
2564+ *
2565+ * This program is free software: you can redistribute it and/or modify
2566+ * it under the terms of the GNU General Public License version 3 as
2567+ * published by the Free Software Foundation.
2568+ *
2569+ * This program is distributed in the hope that it will be useful,
2570 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2571 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2572 * GNU General Public License for more details.
2573 *
2574 * You should have received a copy of the GNU General Public License
2575- * along with BAMF; if not, write to the Free Software
2576- * Foundation, Inc., 51 Franklin St, Fifth Floor,
2577- * Boston, MA 02110-1301 USA
2578+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2579+ *
2580+ * Authored by: Jason Smith <jason.smith@canonical.com>
2581+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2582+ *
2583 */
2584
2585 #ifndef __BAMF_INDICATOR_H__
2586@@ -42,7 +40,7 @@
2587
2588 struct _BamfIndicator {
2589 BamfView parent;
2590-
2591+
2592 BamfIndicatorPrivate *priv;
2593 };
2594
2595@@ -52,23 +50,23 @@
2596
2597 GType bamf_indicator_get_type (void) G_GNUC_CONST;
2598
2599-char * bamf_indicator_get_id (BamfIndicator *self);
2600-
2601-char * bamf_indicator_get_path (BamfIndicator *self);
2602-
2603-char * bamf_indicator_get_address (BamfIndicator *self);
2604-
2605-guint32 bamf_indicator_get_pid (BamfIndicator *self);
2606-
2607-gboolean bamf_indicator_matches_signature (BamfIndicator *self,
2608- gint pid,
2609- const char *address,
2610- const char *path);
2611-
2612-BamfIndicator *bamf_indicator_new (const char *id,
2613- const char *proxy,
2614- const char *address,
2615- guint32 pid);
2616+const char * bamf_indicator_get_id (BamfIndicator *self);
2617+
2618+const char * bamf_indicator_get_path (BamfIndicator *self);
2619+
2620+const char * bamf_indicator_get_address (BamfIndicator *self);
2621+
2622+guint32 bamf_indicator_get_pid (BamfIndicator *self);
2623+
2624+gboolean bamf_indicator_matches_signature (BamfIndicator *self,
2625+ gint pid,
2626+ const char *address,
2627+ const char *path);
2628+
2629+BamfIndicator * bamf_indicator_new (const char *id,
2630+ const char *proxy,
2631+ const char *address,
2632+ guint32 pid);
2633
2634 G_END_DECLS
2635
2636
2637=== modified file 'src/bamf-marshal.list'
2638--- src/bamf-marshal.list 2010-08-18 23:22:58 +0000
2639+++ src/bamf-marshal.list 2012-01-19 19:16:25 +0000
2640@@ -1,9 +1,10 @@
2641 # Marshaller definitions to be generated.
2642 #
2643-# Copyright 2010 Canonical Ltd.
2644+# Copyright 2010-2011 Canonical Ltd.
2645 #
2646 # Authors:
2647 # Jason Smith <jason.smith@canonical.com>
2648+# Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2649 #
2650 # This program is free software: you can redistribute it and/or modify it
2651 # under the terms of the GNU General Public License version 3, as published
2652@@ -17,8 +18,4 @@
2653 # You should have received a copy of the GNU General Public License along
2654 # with this program. If not, see <http://www.gnu.org/licenses/>.
2655
2656-VOID: BOOL, STRING, STRING
2657-VOID: STRING, STRING
2658 VOID: STRING, STRING, STRING
2659-VOID: OBJECT, OBJECT
2660-VOID: STRING, INT, STRING, STRING, STRING
2661
2662=== removed file 'src/bamf-matcher-glue.xml'
2663--- src/bamf-matcher-glue.xml 2010-09-08 23:38:35 +0000
2664+++ src/bamf-matcher-glue.xml 1970-01-01 00:00:00 +0000
2665@@ -1,108 +0,0 @@
2666-<?xml version="1.0" encoding="UTF-8" ?>
2667-
2668-<node name="/org/ayatana/bamf">
2669-
2670- <interface name="org.ayatana.bamf.matcher">
2671-
2672- <signal name="ViewOpened">
2673- <arg type="s" name="path" direction="out" />
2674- <arg type="s" name="type" direction="out" />
2675- </signal>
2676-
2677- <signal name="ViewClosed">
2678- <arg type="s" name="path" direction="out" />
2679- <arg type="s" name="type" direction="out" />
2680- </signal>
2681-
2682- <signal name="ActiveWindowChanged">
2683- <arg type="s" name="old" direction="out" />
2684- <arg type="s" name="new" direction="out" />
2685- </signal>
2686-
2687- <signal name="ActiveApplicationChanged">
2688- <arg type="s" name="old" direction="out" />
2689- <arg type="s" name="new" direction="out" />
2690- </signal>
2691-
2692- <method name="ActiveApplication">
2693- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_application" />
2694- <arg type="s" name="application" direction="out">
2695- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2696- </arg>
2697- </method>
2698-
2699- <method name="ActiveWindow">
2700- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_window" />
2701- <arg type="s" name="window" direction="out">
2702- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2703- </arg>
2704- </method>
2705-
2706- <method name="ApplicationForXid">
2707- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_for_xid" />
2708- <arg type="u" name="xid" direction="in" />
2709- <arg type="s" name="application" direction="out">
2710- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2711- </arg>
2712- </method>
2713-
2714- <method name="ApplicationIsRunning">
2715- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_is_running" />
2716- <arg type="s" name="application" direction="in" />
2717- <arg type="b" name="running" direction="out">
2718- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2719- </arg>
2720- </method>
2721-
2722- <method name="ApplicationPaths">
2723- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_dbus_paths" />
2724- <arg type="as" name="paths" direction="out">
2725- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2726- </arg>
2727- </method>
2728-
2729- <method name="WindowPaths">
2730- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_window_dbus_paths" />
2731- <arg type="as" name="paths" direction="out">
2732- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2733- </arg>
2734- </method>
2735-
2736- <method name="PathForApplication">
2737- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_dbus_path_for_application" />
2738- <arg type="s" name="applicaiton" direction="in" />
2739- <arg type="s" name="path" direction="out">
2740- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2741- </arg>
2742- </method>
2743-
2744- <method name="RegisterFavorites">
2745- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_register_favorites" />
2746- <arg type="as" name="favorites" direction="in" />
2747- </method>
2748-
2749- <method name="RunningApplications">
2750- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_running_application_paths" />
2751- <arg type="as" name="paths" direction="out">
2752- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2753- </arg>
2754- </method>
2755-
2756- <method name="TabPaths">
2757- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_tab_dbus_paths" />
2758- <arg type="as" name="paths" direction="out">
2759- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2760- </arg>
2761- </method>
2762-
2763- <method name="XidsForApplication">
2764- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_xids_for_application" />
2765- <arg type="s" name="application" direction="in" />
2766- <arg type="au" name="xids" direction="out">
2767- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
2768- </arg>
2769- </method>
2770-
2771- </interface>
2772-
2773-</node>
2774
2775=== modified file 'src/bamf-matcher.c'
2776--- src/bamf-matcher.c 2011-12-15 11:30:52 +0000
2777+++ src/bamf-matcher.c 2012-01-19 19:16:25 +0000
2778@@ -1,5 +1,5 @@
2779 /*
2780- * Copyright (C) 2010 Canonical Ltd
2781+ * Copyright (C) 2010-2011 Canonical Ltd
2782 *
2783 * This program is free software: you can redistribute it and/or modify
2784 * it under the terms of the GNU General Public License version 3 as
2785@@ -22,9 +22,7 @@
2786
2787 #include <gdk/gdkx.h>
2788
2789-#include "bamf-marshal.h"
2790 #include "bamf-matcher.h"
2791-#include "bamf-matcher-glue.h"
2792 #include "bamf-application.h"
2793 #include "bamf-window.h"
2794 #include "bamf-legacy-window.h"
2795@@ -32,16 +30,12 @@
2796 #include "bamf-legacy-screen.h"
2797 #include "bamf-indicator-source.h"
2798
2799-G_DEFINE_TYPE (BamfMatcher, bamf_matcher, G_TYPE_OBJECT);
2800+G_DEFINE_TYPE (BamfMatcher, bamf_matcher, BAMF_DBUS_TYPE_MATCHER_SKELETON);
2801 #define BAMF_MATCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
2802-BAMF_TYPE_MATCHER, BamfMatcherPrivate))
2803+ BAMF_TYPE_MATCHER, BamfMatcherPrivate))
2804
2805 enum
2806 {
2807- VIEW_OPENED,
2808- VIEW_CLOSED,
2809- ACTIVE_APPLICATION_CHANGED,
2810- ACTIVE_WINDOW_CHANGED,
2811 FAVORITES_CHANGED,
2812
2813 LAST_SIGNAL,
2814@@ -49,16 +43,6 @@
2815
2816 static guint matcher_signals[LAST_SIGNAL] = { 0 };
2817
2818-typedef struct _OpenOfficeTimeoutArgs OpenOfficeTimeoutArgs;
2819-
2820-struct _OpenOfficeTimeoutArgs
2821-{
2822- BamfMatcher *matcher;
2823- BamfLegacyWindow *window;
2824- int count;
2825-};
2826-
2827-
2828 struct _BamfMatcherPrivate
2829 {
2830 GArray * bad_prefixes;
2831@@ -103,11 +87,9 @@
2832 else
2833 priv->active_app = NULL;
2834
2835- g_signal_emit (matcher,
2836- matcher_signals[ACTIVE_APPLICATION_CHANGED],
2837- 0,
2838- BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL,
2839- BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : NULL);
2840+ g_signal_emit_by_name (matcher, "active-application-changed",
2841+ BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "",
2842+ BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : "");
2843 }
2844 else if (BAMF_IS_WINDOW (view))
2845 {
2846@@ -127,11 +109,10 @@
2847 else
2848 priv->active_win = NULL;
2849
2850- g_signal_emit (matcher,
2851- matcher_signals[ACTIVE_WINDOW_CHANGED],
2852- 0,
2853- BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL,
2854- BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : NULL);
2855+
2856+ g_signal_emit_by_name (matcher, "active-window-changed",
2857+ BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "",
2858+ BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : "");
2859 }
2860 }
2861
2862@@ -146,9 +127,12 @@
2863 static void
2864 bamf_matcher_register_view (BamfMatcher *self, BamfView *view)
2865 {
2866- char * path, * type;
2867+ const char *path, *type;
2868+ GDBusConnection *connection;
2869+ GDBusInterfaceSkeleton *dbus_interface = G_DBUS_INTERFACE_SKELETON (self);
2870
2871- path = bamf_view_export_on_bus (view);
2872+ connection = g_dbus_interface_skeleton_get_connection (dbus_interface);
2873+ path = bamf_view_export_on_bus (view, connection);
2874 type = bamf_view_get_view_type (view);
2875
2876 g_signal_connect (G_OBJECT (view), "closed-internal",
2877@@ -159,8 +143,7 @@
2878 self->priv->views = g_list_prepend (self->priv->views, view);
2879 g_object_ref (view);
2880
2881- g_signal_emit (self, matcher_signals[VIEW_OPENED],0, path, type);
2882- g_free (type);
2883+ g_signal_emit_by_name (self, "view-opened", path, type);
2884
2885 // trigger manually since this is already active
2886 if (bamf_view_is_active (view))
2887@@ -171,12 +154,12 @@
2888 bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view, gboolean unref)
2889 {
2890 const char * path;
2891- char * type;
2892+ const char * type;
2893
2894 path = bamf_view_get_path (view);
2895 type = bamf_view_get_view_type (view);
2896
2897- g_signal_emit (self, matcher_signals[VIEW_CLOSED],0, path, type);
2898+ g_signal_emit_by_name (self, "view-closed", path, type);
2899
2900 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_closed, self);
2901 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_active_changed, self);
2902@@ -186,8 +169,6 @@
2903 self->priv->views = g_list_remove (self->priv->views, view);
2904 g_object_unref (view);
2905 }
2906-
2907- g_free (type);
2908 }
2909
2910 static char *
2911@@ -317,7 +298,8 @@
2912 gboolean regexFail;
2913 GRegex *regex;
2914
2915- g_return_val_if_fail ((execString && execString[0] != '\0'), g_strdup (execString));
2916+ if (!execString || (execString && execString[0] == '\0'))
2917+ return NULL;
2918
2919 exec = g_utf8_casefold (execString, -1);
2920 parts = g_strsplit (exec, " ", 0);
2921@@ -983,7 +965,7 @@
2922 path = g_file_get_path (file);
2923 filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL);
2924 monitored_dir = g_object_get_data (G_OBJECT (monitor), "root");
2925-
2926+
2927 if (!g_str_has_suffix (path, ".desktop") &&
2928 filetype != G_FILE_TYPE_DIRECTORY &&
2929 type != G_FILE_MONITOR_EVENT_DELETED)
2930@@ -1367,7 +1349,7 @@
2931 g_free (exec_string);
2932 }
2933
2934- if (g_list_length (result) > 0)
2935+ if (result)
2936 {
2937 result = g_list_reverse (result);
2938 return result;
2939@@ -1885,7 +1867,7 @@
2940
2941 void
2942 bamf_matcher_load_desktop_file (BamfMatcher * self,
2943- char * desktop_file)
2944+ const char * desktop_file)
2945 {
2946 g_return_if_fail (BAMF_IS_MATCHER (self));
2947
2948@@ -1937,7 +1919,7 @@
2949 return 0;
2950 }
2951
2952-char *
2953+const char *
2954 bamf_matcher_get_active_application (BamfMatcher *matcher)
2955 {
2956 GList *l;
2957@@ -1957,14 +1939,14 @@
2958
2959 if (bamf_view_is_active (view))
2960 {
2961- return g_strdup (bamf_view_get_path (view));
2962+ return bamf_view_get_path (view);
2963 }
2964 }
2965
2966- return NULL;
2967+ return "";
2968 }
2969
2970-char *
2971+const char *
2972 bamf_matcher_get_active_window (BamfMatcher *matcher)
2973 {
2974 GList *l;
2975@@ -1984,14 +1966,14 @@
2976
2977 if (bamf_view_is_active (view))
2978 {
2979- return g_strdup (bamf_view_get_path (view));
2980+ return bamf_view_get_path (view);
2981 }
2982 }
2983
2984- return NULL;
2985+ return "";
2986 }
2987
2988-char *
2989+const char *
2990 bamf_matcher_application_for_xid (BamfMatcher *matcher,
2991 guint32 xid)
2992 {
2993@@ -2012,16 +1994,16 @@
2994
2995 if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid))
2996 {
2997- return g_strdup (bamf_view_get_path (view));
2998+ return bamf_view_get_path (view);
2999 }
3000 }
3001
3002- return NULL;
3003+ return "";
3004 }
3005
3006 gboolean
3007 bamf_matcher_application_is_running (BamfMatcher *matcher,
3008- char *application)
3009+ const char *application)
3010 {
3011 char * desktop_file;
3012 GList *l;
3013@@ -2051,22 +2033,21 @@
3014 return FALSE;
3015 }
3016
3017-char **
3018+GVariant *
3019 bamf_matcher_window_dbus_paths (BamfMatcher *matcher)
3020 {
3021- char ** paths;
3022- int i;
3023 GList *l;
3024 BamfView *view;
3025 BamfMatcherPrivate *priv;
3026+ GVariantBuilder b;
3027
3028 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
3029
3030+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
3031+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
3032+
3033 priv = matcher->priv;
3034
3035- paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
3036-
3037- i = 0;
3038 for (l = priv->views; l; l = l->next)
3039 {
3040 view = l->data;
3041@@ -2074,29 +2055,29 @@
3042 if (!BAMF_IS_WINDOW (view))
3043 continue;
3044
3045- paths[i] = g_strdup (bamf_view_get_path (view));
3046- i++;
3047+ g_variant_builder_add (&b, "s", bamf_view_get_path (view));
3048 }
3049
3050- return paths;
3051+ g_variant_builder_close (&b);
3052+
3053+ return g_variant_builder_end (&b);
3054 }
3055
3056-char **
3057+GVariant *
3058 bamf_matcher_application_dbus_paths (BamfMatcher *matcher)
3059 {
3060- char ** paths;
3061- int i;
3062 GList *l;
3063 BamfView *view;
3064 BamfMatcherPrivate *priv;
3065+ GVariantBuilder b;
3066
3067 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
3068
3069+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
3070+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
3071+
3072 priv = matcher->priv;
3073
3074- paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
3075-
3076- i = 0;
3077 for (l = priv->views; l; l = l->next)
3078 {
3079 view = l->data;
3080@@ -2104,18 +2085,19 @@
3081 if (!BAMF_IS_APPLICATION (view))
3082 continue;
3083
3084- paths[i] = g_strdup (bamf_view_get_path (view));
3085- i++;
3086+ g_variant_builder_add (&b, "s", bamf_view_get_path (view));
3087 }
3088
3089- return paths;
3090+ g_variant_builder_close (&b);
3091+
3092+ return g_variant_builder_end (&b);
3093 }
3094
3095-char *
3096+const char *
3097 bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,
3098- char *application)
3099+ const char *application)
3100 {
3101- char * path = NULL;
3102+ const char * path = "";
3103 char * desktop_file;
3104 GList *l;
3105 BamfView *view;
3106@@ -2135,7 +2117,7 @@
3107 desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view));
3108 if (g_strcmp0 (desktop_file, application) == 0)
3109 {
3110- path = g_strdup (bamf_view_get_path (view));
3111+ path = bamf_view_get_path (view);
3112 }
3113 g_free (desktop_file);
3114 }
3115@@ -2151,18 +2133,16 @@
3116 return matcher->priv->favorites;
3117 }
3118
3119-gboolean
3120+void
3121 bamf_matcher_register_favorites (BamfMatcher *matcher,
3122- char **favorites,
3123- GError *error)
3124+ const char **favorites)
3125 {
3126- char *fav;
3127- char **favs;
3128+ const char *fav;
3129+ const char **favs;
3130 BamfMatcherPrivate *priv;
3131-
3132- g_return_val_if_fail (BAMF_IS_MATCHER (matcher), TRUE);
3133- g_return_val_if_fail (favorites, TRUE);
3134-
3135+
3136+ g_return_if_fail (BAMF_IS_MATCHER (matcher));
3137+ g_return_if_fail (favorites);
3138 priv = matcher->priv;
3139
3140 for (favs = favorites; *favs; favs++)
3141@@ -2171,33 +2151,29 @@
3142 /* ignore things already in the list */
3143 if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0))
3144 continue;
3145-
3146-
3147+
3148 priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav));
3149 bamf_matcher_load_desktop_file (matcher, fav);
3150 }
3151-
3152+
3153 g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0);
3154-
3155- return TRUE;
3156 }
3157
3158-char **
3159+GVariant *
3160 bamf_matcher_running_application_paths (BamfMatcher *matcher)
3161 {
3162- char ** paths;
3163- int i;
3164 GList *l;
3165 BamfView *view;
3166 BamfMatcherPrivate *priv;
3167+ GVariantBuilder b;
3168
3169 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
3170
3171+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
3172+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
3173+
3174 priv = matcher->priv;
3175
3176- paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
3177-
3178- i = 0;
3179 for (l = priv->views; l; l = l->next)
3180 {
3181 view = l->data;
3182@@ -2205,24 +2181,31 @@
3183 if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view))
3184 continue;
3185
3186- paths[i] = g_strdup (bamf_view_get_path (view));
3187- i++;
3188+ g_variant_builder_add (&b, "s", bamf_view_get_path (view));
3189 }
3190
3191- return paths;
3192+ g_variant_builder_close (&b);
3193+
3194+ return g_variant_builder_end (&b);
3195 }
3196
3197-char **
3198+GVariant *
3199 bamf_matcher_tab_dbus_paths (BamfMatcher *matcher)
3200 {
3201- return NULL;
3202+ GVariantBuilder b;
3203+
3204+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
3205+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
3206+ g_variant_builder_close (&b);
3207+ return g_variant_builder_end (&b);
3208 }
3209
3210-GArray *
3211+GVariant *
3212 bamf_matcher_xids_for_application (BamfMatcher *matcher,
3213- char *application)
3214+ const char *application)
3215 {
3216- GArray * xids = NULL;
3217+ GVariantBuilder b;
3218+ GVariant *xids;
3219 char * desktop_file;
3220 GList *l;
3221 BamfView *view;
3222@@ -2231,6 +2214,7 @@
3223 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
3224
3225 priv = matcher->priv;
3226+ xids = NULL;
3227
3228 for (l = priv->views; l; l = l->next)
3229 {
3230@@ -2249,19 +2233,159 @@
3231 g_free (desktop_file);
3232 }
3233
3234+ if (!xids)
3235+ {
3236+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)"));
3237+ g_variant_builder_open (&b, G_VARIANT_TYPE ("au"));
3238+ g_variant_builder_close (&b);
3239+ xids = g_variant_builder_end (&b);
3240+ }
3241+
3242 return xids;
3243 }
3244
3245+static gboolean
3246+on_dbus_handle_xids_for_application (BamfDBusMatcher *interface,
3247+ GDBusMethodInvocation *invocation,
3248+ const gchar *application,
3249+ BamfMatcher *self)
3250+{
3251+ GVariant *xids = bamf_matcher_xids_for_application (self, application);
3252+ g_dbus_method_invocation_return_value (invocation, xids);
3253+
3254+ return TRUE;
3255+}
3256+
3257+static gboolean
3258+on_dbus_handle_tab_paths (BamfDBusMatcher *interface,
3259+ GDBusMethodInvocation *invocation,
3260+ BamfMatcher *self)
3261+{
3262+ GVariant *tab_paths = bamf_matcher_tab_dbus_paths (self);
3263+ g_dbus_method_invocation_return_value (invocation, tab_paths);
3264+
3265+ return TRUE;
3266+}
3267+
3268+static gboolean
3269+on_dbus_handle_application_paths (BamfDBusMatcher *interface,
3270+ GDBusMethodInvocation *invocation,
3271+ BamfMatcher *self)
3272+{
3273+ GVariant *app_paths = bamf_matcher_application_dbus_paths (self);
3274+ g_dbus_method_invocation_return_value (invocation, app_paths);
3275+
3276+ return TRUE;
3277+}
3278+
3279+
3280+static gboolean
3281+on_dbus_handle_window_paths (BamfDBusMatcher *interface,
3282+ GDBusMethodInvocation *invocation,
3283+ BamfMatcher *self)
3284+{
3285+ GVariant *win_paths = bamf_matcher_window_dbus_paths (self);
3286+ g_dbus_method_invocation_return_value (invocation, win_paths);
3287+
3288+ return TRUE;
3289+}
3290+
3291+static gboolean
3292+on_dbus_handle_running_applications (BamfDBusMatcher *interface,
3293+ GDBusMethodInvocation *invocation,
3294+ BamfMatcher *self)
3295+{
3296+ GVariant *running_apps = bamf_matcher_running_application_paths (self);
3297+ g_dbus_method_invocation_return_value (invocation, running_apps);
3298+
3299+ return TRUE;
3300+}
3301+
3302+static gboolean
3303+on_dbus_handle_active_application (BamfDBusMatcher *interface,
3304+ GDBusMethodInvocation *invocation,
3305+ BamfMatcher *self)
3306+{
3307+ const gchar *active_app = bamf_matcher_get_active_application (self);
3308+
3309+ g_dbus_method_invocation_return_value (invocation,
3310+ g_variant_new ("(s)", active_app));
3311+ return TRUE;
3312+}
3313+
3314+static gboolean
3315+on_dbus_handle_active_window (BamfDBusMatcher *interface,
3316+ GDBusMethodInvocation *invocation,
3317+ BamfMatcher *self)
3318+{
3319+ const gchar *active_win = bamf_matcher_get_active_window (self);
3320+
3321+ g_dbus_method_invocation_return_value (invocation,
3322+ g_variant_new ("(s)", active_win));
3323+ return TRUE;
3324+}
3325+
3326+static gboolean
3327+on_dbus_handle_application_is_running (BamfDBusMatcher *interface,
3328+ GDBusMethodInvocation *invocation,
3329+ const gchar *application,
3330+ BamfMatcher *self)
3331+{
3332+ gboolean is_running = bamf_matcher_application_is_running (self, application);
3333+
3334+ g_dbus_method_invocation_return_value (invocation,
3335+ g_variant_new ("(b)", is_running));
3336+ return TRUE;
3337+}
3338+
3339+static gboolean
3340+on_dbus_handle_register_favorites (BamfDBusMatcher *interface,
3341+ GDBusMethodInvocation *invocation,
3342+ const char **favorites,
3343+ BamfMatcher *self)
3344+{
3345+ bamf_matcher_register_favorites (self, favorites);
3346+ g_dbus_method_invocation_return_value (invocation, NULL);
3347+
3348+ return TRUE;
3349+}
3350+
3351+static gboolean
3352+on_dbus_handle_path_for_application (BamfDBusMatcher *interface,
3353+ GDBusMethodInvocation *invocation,
3354+ const gchar *application,
3355+ BamfMatcher *self)
3356+{
3357+ const gchar *app_path = bamf_matcher_dbus_path_for_application (self, application);
3358+
3359+ g_dbus_method_invocation_return_value (invocation,
3360+ g_variant_new ("(s)", app_path));
3361+
3362+ return TRUE;
3363+}
3364+
3365+static gboolean
3366+on_dbus_handle_application_for_xid (BamfDBusMatcher *interface,
3367+ GDBusMethodInvocation *invocation,
3368+ guint xid,
3369+ BamfMatcher *self)
3370+{
3371+ const gchar *app_path = bamf_matcher_application_for_xid (self, xid);
3372+
3373+ g_dbus_method_invocation_return_value (invocation,
3374+ g_variant_new ("(s)", app_path));
3375+
3376+ return TRUE;
3377+}
3378+
3379 static void
3380 bamf_matcher_init (BamfMatcher * self)
3381 {
3382+ BamfMatcherPrivate *priv;
3383+ BamfLegacyScreen *screen;
3384+ BamfIndicatorSource *approver;
3385 GArray *prefixstrings;
3386 int i;
3387- DBusGConnection *bus;
3388- GError *error = NULL;
3389- BamfMatcherPrivate *priv;
3390- BamfLegacyScreen *screen;
3391- BamfIndicatorSource *approver;
3392
3393 priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self);
3394
3395@@ -2294,11 +2418,56 @@
3396
3397 XSetErrorHandler (x_error_handler);
3398
3399- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
3400-
3401- g_return_if_fail (bus);
3402-
3403- dbus_g_connection_register_g_object (bus, BAMF_MATCHER_PATH, G_OBJECT (self));
3404+ /* Registering signal callbacks to reply to dbus method calls */
3405+ g_signal_connect (self, "handle-xids-for-application",
3406+ G_CALLBACK (on_dbus_handle_xids_for_application), self);
3407+
3408+ g_signal_connect (self, "handle-tab-paths",
3409+ G_CALLBACK (on_dbus_handle_tab_paths), self);
3410+
3411+ g_signal_connect (self, "handle-application-paths",
3412+ G_CALLBACK (on_dbus_handle_application_paths), self);
3413+
3414+ g_signal_connect (self, "handle-window-paths",
3415+ G_CALLBACK (on_dbus_handle_window_paths), self);
3416+
3417+ g_signal_connect (self, "handle-running-applications",
3418+ G_CALLBACK (on_dbus_handle_running_applications), self);
3419+
3420+ g_signal_connect (self, "handle-active-window",
3421+ G_CALLBACK (on_dbus_handle_active_window), self);
3422+
3423+ g_signal_connect (self, "handle-active-application",
3424+ G_CALLBACK (on_dbus_handle_active_application), self);
3425+
3426+ g_signal_connect (self, "handle-application-is-running",
3427+ G_CALLBACK (on_dbus_handle_application_is_running), self);
3428+
3429+ g_signal_connect (self, "handle-register-favorites",
3430+ G_CALLBACK (on_dbus_handle_register_favorites), self);
3431+
3432+ g_signal_connect (self, "handle-path-for-application",
3433+ G_CALLBACK (on_dbus_handle_path_for_application), self);
3434+
3435+ g_signal_connect (self, "handle-application-for-xid",
3436+ G_CALLBACK (on_dbus_handle_application_for_xid), self);
3437+}
3438+
3439+static void
3440+bamf_matcher_dispose (GObject *object)
3441+{
3442+ BamfMatcher *self = (BamfMatcher *) object;
3443+ BamfMatcherPrivate *priv = self->priv;
3444+ GList *l;
3445+
3446+ for (l = priv->views; l; l = l->next)
3447+ {
3448+ bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE);
3449+ }
3450+ g_list_free_full (priv->views, g_object_unref);
3451+ priv->views = NULL;
3452+
3453+ G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object);
3454 }
3455
3456 static void
3457@@ -2322,12 +2491,7 @@
3458 g_hash_table_destroy (priv->desktop_class_table);
3459 g_hash_table_destroy (priv->registered_pids);
3460
3461- for (l = priv->views; l; l = l->next)
3462- {
3463- bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE);
3464- }
3465 g_list_free_full (priv->views, g_object_unref);
3466- priv->views = NULL;
3467
3468 for (l = priv->monitors; l; l = l->next)
3469 {
3470@@ -2350,49 +2514,11 @@
3471 bamf_matcher_class_init (BamfMatcherClass * klass)
3472 {
3473 GObjectClass *object_class = G_OBJECT_CLASS (klass);
3474+
3475 g_type_class_add_private (klass, sizeof (BamfMatcherPrivate));
3476-
3477- dbus_g_object_type_install_info (BAMF_TYPE_MATCHER,
3478- &dbus_glib_bamf_matcher_object_info);
3479-
3480+ object_class->dispose = bamf_matcher_dispose;
3481 object_class->finalize = bamf_matcher_finalize;
3482
3483- matcher_signals [VIEW_OPENED] =
3484- g_signal_new ("view-opened",
3485- G_OBJECT_CLASS_TYPE (klass),
3486- 0,
3487- 0, NULL, NULL,
3488- bamf_marshal_VOID__STRING_STRING,
3489- G_TYPE_NONE, 2,
3490- G_TYPE_STRING, G_TYPE_STRING);
3491-
3492- matcher_signals [VIEW_CLOSED] =
3493- g_signal_new ("view-closed",
3494- G_OBJECT_CLASS_TYPE (klass),
3495- 0,
3496- 0, NULL, NULL,
3497- bamf_marshal_VOID__STRING_STRING,
3498- G_TYPE_NONE, 2,
3499- G_TYPE_STRING, G_TYPE_STRING);
3500-
3501- matcher_signals [ACTIVE_APPLICATION_CHANGED] =
3502- g_signal_new ("active-application-changed",
3503- G_OBJECT_CLASS_TYPE (klass),
3504- 0,
3505- 0, NULL, NULL,
3506- bamf_marshal_VOID__STRING_STRING,
3507- G_TYPE_NONE, 2,
3508- G_TYPE_STRING, G_TYPE_STRING);
3509-
3510- matcher_signals [ACTIVE_WINDOW_CHANGED] =
3511- g_signal_new ("active-window-changed",
3512- G_OBJECT_CLASS_TYPE (klass),
3513- 0,
3514- 0, NULL, NULL,
3515- bamf_marshal_VOID__STRING_STRING,
3516- G_TYPE_NONE, 2,
3517- G_TYPE_STRING, G_TYPE_STRING);
3518-
3519 matcher_signals [FAVORITES_CHANGED] =
3520 g_signal_new ("favorites-changed",
3521 G_OBJECT_CLASS_TYPE (klass),
3522@@ -2410,8 +2536,7 @@
3523 if (!BAMF_IS_MATCHER (matcher))
3524 {
3525 matcher = (BamfMatcher *) g_object_new (BAMF_TYPE_MATCHER, NULL);
3526- return matcher;
3527 }
3528
3529- return g_object_ref (G_OBJECT (matcher));
3530+ return matcher;
3531 }
3532
3533=== modified file 'src/bamf-matcher.h'
3534--- src/bamf-matcher.h 2011-08-01 23:01:36 +0000
3535+++ src/bamf-matcher.h 2012-01-19 19:16:25 +0000
3536@@ -14,6 +14,7 @@
3537 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3538 *
3539 * Authored by: Jason Smith <jason.smith@canonical.com>
3540+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3541 *
3542 */
3543
3544@@ -26,9 +27,6 @@
3545 #include <stdlib.h>
3546 #include <unistd.h>
3547 #include <sys/types.h>
3548-#include <dbus/dbus.h>
3549-#include <dbus/dbus-glib.h>
3550-#include <dbus/dbus-glib-lowlevel.h>
3551 #include <gdk/gdk.h>
3552 #include <glib.h>
3553 #include <glib-object.h>
3554@@ -47,7 +45,7 @@
3555 #define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER))
3556 #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass))
3557
3558-#define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE"
3559+#define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE"
3560
3561 typedef struct _BamfMatcher BamfMatcher;
3562 typedef struct _BamfMatcherClass BamfMatcherClass;
3563@@ -55,12 +53,12 @@
3564
3565 struct _BamfMatcherClass
3566 {
3567- GObjectClass parent;
3568+ BamfDBusMatcherSkeletonClass parent;
3569 };
3570
3571 struct _BamfMatcher
3572 {
3573- GObject parent;
3574+ BamfDBusMatcherSkeleton parent;
3575
3576 /* private */
3577 BamfMatcherPrivate *priv;
3578@@ -69,41 +67,40 @@
3579 GType bamf_matcher_get_type (void) G_GNUC_CONST;
3580
3581 void bamf_matcher_load_desktop_file (BamfMatcher * self,
3582- char * desktop_file);
3583+ const char * desktop_file);
3584
3585 void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self,
3586- const char * desktopFile,
3587+ const char *application,
3588 gint pid);
3589
3590-char * bamf_matcher_get_active_application (BamfMatcher *matcher);
3591-
3592-char * bamf_matcher_get_active_window (BamfMatcher *matcher);
3593-
3594-char * bamf_matcher_application_for_xid (BamfMatcher *matcher,
3595+const char * bamf_matcher_get_active_application (BamfMatcher *matcher);
3596+
3597+const char * bamf_matcher_get_active_window (BamfMatcher *matcher);
3598+
3599+const char * bamf_matcher_application_for_xid (BamfMatcher *matcher,
3600 guint32 xid);
3601
3602 gboolean bamf_matcher_application_is_running (BamfMatcher *matcher,
3603- char *application);
3604-
3605-char ** bamf_matcher_application_dbus_paths (BamfMatcher *matcher);
3606-
3607-char ** bamf_matcher_window_dbus_paths (BamfMatcher *matcher);
3608-
3609-char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,
3610- char *application);
3611-
3612-gboolean bamf_matcher_register_favorites (BamfMatcher *matcher,
3613- char **favorites,
3614- GError *error);
3615+ const char *application);
3616+
3617+GVariant * bamf_matcher_application_dbus_paths (BamfMatcher *matcher);
3618+
3619+GVariant * bamf_matcher_window_dbus_paths (BamfMatcher *matcher);
3620+
3621+const char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,
3622+ const char *application);
3623+
3624+void bamf_matcher_register_favorites (BamfMatcher *matcher,
3625+ const char **favorites);
3626
3627 GList * bamf_matcher_get_favorites (BamfMatcher *matcher);
3628
3629-char ** bamf_matcher_running_application_paths (BamfMatcher *matcher);
3630-
3631-char ** bamf_matcher_tab_dbus_paths (BamfMatcher *matcher);
3632-
3633-GArray * bamf_matcher_xids_for_application (BamfMatcher *matcher,
3634- char *application);
3635+GVariant * bamf_matcher_running_application_paths (BamfMatcher *matcher);
3636+
3637+GVariant * bamf_matcher_tab_dbus_paths (BamfMatcher *matcher);
3638+
3639+GVariant * bamf_matcher_xids_for_application (BamfMatcher *matcher,
3640+ const char *application);
3641
3642 BamfMatcher * bamf_matcher_get_default (void);
3643
3644
3645=== removed file 'src/bamf-tab-glue.xml'
3646--- src/bamf-tab-glue.xml 2010-05-18 19:55:44 +0000
3647+++ src/bamf-tab-glue.xml 1970-01-01 00:00:00 +0000
3648@@ -1,39 +0,0 @@
3649-<?xml version="1.0" encoding="UTF-8" ?>
3650-
3651-<node name="/org/ayatana/bamf">
3652-
3653- <interface name="org.ayatana.bamf.tab">
3654-
3655- <signal name="UriChanged">
3656- <arg type="s" name="old" direction="out" />
3657- <arg type="s" name="new" direction="out" />
3658- </signal>
3659-
3660- <method name="ShowTab">
3661- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_show" />
3662- </method>
3663-
3664- <method name="ParentXid">
3665- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_parent_xid" />
3666- <arg type="u" name="xid" direction="out">
3667- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
3668- </arg>
3669- </method>
3670-
3671- <method name="CurrentUri">
3672- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_current_uri" />
3673- <arg type="s" name="uri" direction="out">
3674- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
3675- </arg>
3676- </method>
3677-
3678- <method name="Preview">
3679- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_get_preview" />
3680- <arg type="ay" name="data" direction="out">
3681- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
3682- </arg>
3683- </method>
3684-
3685- </interface>
3686-
3687-</node>
3688
3689=== modified file 'src/bamf-tab-source.c'
3690--- src/bamf-tab-source.c 2011-08-01 23:25:01 +0000
3691+++ src/bamf-tab-source.c 2012-01-19 19:16:25 +0000
3692@@ -1,5 +1,5 @@
3693 /*
3694- * Copyright (C) 2010 Canonical Ltd
3695+ * Copyright (C) 2010-2011 Canonical Ltd
3696 *
3697 * This program is free software: you can redistribute it and/or modify
3698 * it under the terms of the GNU General Public License version 3 as
3699@@ -14,15 +14,15 @@
3700 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3701 *
3702 * Authored by: Jason Smith <jason.smith@canonical.com>
3703+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3704 *
3705 */
3706
3707-
3708 #include "bamf-view.h"
3709 #include "bamf-tab-source.h"
3710 #include "bamf-tab.h"
3711 #include "bamf-marshal.h"
3712-#include <dbus/dbus-glib.h>
3713+#include "bamf-gdbus-browser-generated.h"
3714
3715 G_DEFINE_TYPE (BamfTabSource, bamf_tab_source, G_TYPE_OBJECT);
3716 #define BAMF_TAB_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
3717@@ -51,9 +51,9 @@
3718
3719 struct _BamfTabSourcePrivate
3720 {
3721+ BamfDBusBrowser *proxy;
3722 char *bus;
3723 char *path;
3724- DBusGProxy *proxy;
3725 GHashTable *tabs;
3726 };
3727
3728@@ -67,12 +67,7 @@
3729 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
3730 priv = self->priv;
3731
3732- if (!dbus_g_proxy_call (priv->proxy,
3733- "TabIds",
3734- &error,
3735- G_TYPE_INVALID,
3736- G_TYPE_STRV, &ids,
3737- G_TYPE_INVALID))
3738+ if (!bamf_dbus_browser__call_tab_ids_sync (priv->proxy, &ids, NULL, &error))
3739 {
3740 g_warning ("Failed to get tab ids: %s", error->message);
3741 g_error_free (error);
3742@@ -83,8 +78,7 @@
3743 }
3744
3745 void
3746-bamf_tab_source_show_tab (BamfTabSource *self,
3747- char *id)
3748+bamf_tab_source_show_tab (BamfTabSource *self, char *id)
3749 {
3750 BamfTabSourcePrivate *priv;
3751 GError *error = NULL;
3752@@ -92,36 +86,26 @@
3753 g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
3754 priv = self->priv;
3755
3756- if (!dbus_g_proxy_call (priv->proxy,
3757- "ShowTab",
3758- &error,
3759- G_TYPE_STRING, id,
3760- G_TYPE_INVALID,
3761- G_TYPE_INVALID))
3762+ if (!bamf_dbus_browser__call_show_tab_sync (priv->proxy, id, NULL, &error))
3763 {
3764 g_warning ("Failed to show tab: %s", error->message);
3765 g_error_free (error);
3766 }
3767 }
3768
3769-GArray *
3770+gchar *
3771 bamf_tab_source_get_tab_preview (BamfTabSource *self,
3772 char *id)
3773 {
3774 BamfTabSourcePrivate *priv;
3775 GError *error = NULL;
3776- GArray *preview_data = NULL;
3777+ gchar *preview_data = NULL;
3778
3779 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
3780 priv = self->priv;
3781
3782- if (!dbus_g_proxy_call (priv->proxy,
3783- "TabUri",
3784- &error,
3785- G_TYPE_STRING, id,
3786- G_TYPE_INVALID,
3787- G_TYPE_ARRAY, &preview_data,
3788- G_TYPE_INVALID))
3789+ if (!bamf_dbus_browser__call_tab_preview_sync (priv->proxy, id, &preview_data,
3790+ NULL, &error))
3791 {
3792 g_warning ("Failed to get tab preview data: %s", error->message);
3793 g_error_free (error);
3794@@ -142,13 +126,7 @@
3795 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
3796 priv = self->priv;
3797
3798- if (!dbus_g_proxy_call (priv->proxy,
3799- "TabUri",
3800- &error,
3801- G_TYPE_STRING, id,
3802- G_TYPE_INVALID,
3803- G_TYPE_STRING, &uri,
3804- G_TYPE_INVALID))
3805+ if (!bamf_dbus_browser__call_tab_uri_sync (priv->proxy, id, &uri, NULL, &error))
3806 {
3807 g_warning ("Failed to get tab URI: %s", error->message);
3808 g_error_free (error);
3809@@ -169,13 +147,7 @@
3810 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), 0);
3811 priv = self->priv;
3812
3813- if (!dbus_g_proxy_call (priv->proxy,
3814- "TabXid",
3815- &error,
3816- G_TYPE_STRING, id,
3817- G_TYPE_INVALID,
3818- G_TYPE_UINT, &xid,
3819- G_TYPE_INVALID))
3820+ if (!bamf_dbus_browser__call_tab_xid_sync (priv->proxy, id, &xid, NULL, &error))
3821 {
3822 g_warning ("Failed to get tab XID: %s", error->message);
3823 g_error_free (error);
3824@@ -186,7 +158,8 @@
3825 }
3826
3827 static void
3828-bamf_tab_source_on_tab_opened (DBusGProxy *proxy, char *id, BamfTabSource *source)
3829+bamf_tab_source_on_tab_opened (BamfDBusBrowser *proxy, const char *id,
3830+ BamfTabSource *source)
3831 {
3832 BamfTab *tab;
3833
3834@@ -201,7 +174,8 @@
3835 }
3836
3837 static void
3838-bamf_tab_source_on_tab_closed (DBusGProxy *proxy, char *id, BamfTabSource *source)
3839+bamf_tab_source_on_tab_closed (BamfDBusBrowser *proxy, const char *id,
3840+ BamfTabSource *source)
3841 {
3842 BamfTab *tab;
3843
3844@@ -221,7 +195,8 @@
3845 }
3846
3847 static void
3848-bamf_tab_source_on_uri_changed (DBusGProxy *proxy, char *id, char *old_uri, char *new_uri, BamfTabSource *source)
3849+bamf_tab_source_on_uri_changed (BamfDBusBrowser *proxy, const char *id,
3850+ const char *old_uri, char *new_uri, BamfTabSource *source)
3851 {
3852 g_signal_emit (source, REMOTE_TAB_URI_CHANGED, 0, id, old_uri, new_uri);
3853 }
3854@@ -266,13 +241,82 @@
3855 }
3856 }
3857
3858+static void bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self);
3859+
3860+static void
3861+on_proxy_ready_cb (GDBusProxy *proxy, GAsyncResult *res, BamfTabSource *self)
3862+{
3863+ BamfDBusBrowser *bproxy;
3864+ GError *error = NULL;
3865+ g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
3866+
3867+ bproxy = bamf_dbus_browser__proxy_new_for_bus_finish (res, &error);
3868+
3869+ if (error)
3870+ {
3871+ g_critical ("Unable to get org.ayatana.bamf.browser object from bus %s: %s",
3872+ self->priv->bus, error->message);
3873+ g_error_free (error);
3874+ }
3875+ else
3876+ {
3877+ gchar *owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (bproxy));
3878+
3879+ if (owner)
3880+ {
3881+ g_free (owner);
3882+
3883+ if (self->priv->proxy)
3884+ g_object_unref (self->priv->proxy);
3885+
3886+ self->priv->proxy = bproxy;
3887+
3888+ g_signal_connect (self->priv->proxy, "tab-uri-changed",
3889+ (GCallback) bamf_tab_source_on_uri_changed, self);
3890+
3891+ g_signal_connect (self->priv->proxy, "tab-opened",
3892+ (GCallback) bamf_tab_source_on_tab_opened, self);
3893+
3894+ g_signal_connect (self->priv->proxy, "tab-closed",
3895+ (GCallback) bamf_tab_source_on_tab_closed, self);
3896+
3897+ g_signal_connect (self->priv->proxy, "notify::g-name-owner",
3898+ G_CALLBACK (bamf_tab_source_reconnect), self);
3899+
3900+ }
3901+ else
3902+ {
3903+ g_debug ("Failed to get notification approver proxy: no owner available");
3904+ g_object_unref (proxy);
3905+ }
3906+ }
3907+}
3908+
3909+static void
3910+bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self)
3911+{
3912+ g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
3913+
3914+ if (self->priv->proxy)
3915+ {
3916+ g_object_unref (self->priv->proxy);
3917+ self->priv->proxy = NULL;
3918+ }
3919+
3920+ bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION,
3921+ G_DBUS_PROXY_FLAGS_NONE,
3922+ self->priv->bus,
3923+ self->priv->path,
3924+ NULL,
3925+ (GAsyncReadyCallback) on_proxy_ready_cb,
3926+ self);
3927+}
3928+
3929 static void
3930 bamf_tab_source_constructed (GObject *object)
3931 {
3932 BamfTabSource *source;
3933 BamfTabSourcePrivate *priv;
3934- DBusGConnection *connection;
3935- GError *error = NULL;
3936
3937 if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed)
3938 G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object);
3939@@ -280,65 +324,40 @@
3940 source = BAMF_TAB_SOURCE (object);
3941 priv = source->priv;
3942
3943- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
3944- if (connection == NULL)
3945- {
3946- g_critical ("Failed to open connection to bus: %s",
3947- error != NULL ? error->message : "Unknown");
3948- if (error)
3949- g_error_free (error);
3950- return;
3951- }
3952-
3953- priv->proxy = dbus_g_proxy_new_for_name (connection,
3954- priv->bus,
3955- priv->path,
3956- "org.ayatana.bamf.browser");
3957-
3958- if (priv->proxy == NULL)
3959- {
3960- g_critical ("Unable to get org.ayatana.bamf.browser object from bus");
3961- }
3962-
3963- dbus_g_proxy_add_signal (priv->proxy,
3964- "TabUriChanged",
3965- G_TYPE_STRING,
3966- G_TYPE_STRING,
3967- G_TYPE_STRING,
3968- G_TYPE_INVALID);
3969-
3970- dbus_g_proxy_add_signal (priv->proxy,
3971- "TabOpened",
3972- G_TYPE_STRING,
3973- G_TYPE_INVALID);
3974-
3975- dbus_g_proxy_add_signal (priv->proxy,
3976- "TabClosed",
3977- G_TYPE_STRING,
3978- G_TYPE_INVALID);
3979-
3980- dbus_g_proxy_connect_signal (priv->proxy,
3981- "TabUriChanged",
3982- (GCallback) bamf_tab_source_on_uri_changed,
3983- source,
3984- NULL);
3985-
3986- dbus_g_proxy_connect_signal (priv->proxy,
3987- "TabOpened",
3988- (GCallback) bamf_tab_source_on_tab_opened,
3989- source,
3990- NULL);
3991-
3992- dbus_g_proxy_connect_signal (priv->proxy,
3993- "TabClosed",
3994- (GCallback) bamf_tab_source_on_tab_closed,
3995- source,
3996- NULL);
3997+ bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION,
3998+ G_DBUS_PROXY_FLAGS_NONE,
3999+ priv->bus,
4000+ priv->path,
4001+ NULL,
4002+ (GAsyncReadyCallback) on_proxy_ready_cb,
4003+ source);
4004 }
4005
4006 static void
4007 bamf_tab_source_dispose (GObject *object)
4008 {
4009+ BamfTabSource *self;
4010+
4011+ self = BAMF_TAB_SOURCE (object);
4012+
4013+ if (self->priv->bus)
4014+ {
4015+ g_free (self->priv->bus);
4016+ self->priv->bus = NULL;
4017+ }
4018+
4019+ if (self->priv->path)
4020+ {
4021+ g_free (self->priv->path);
4022+ self->priv->path = NULL;
4023+ }
4024+
4025+ if (self->priv->proxy)
4026+ {
4027+ g_object_unref (self->priv->proxy);
4028+ self->priv->proxy = NULL;
4029+ }
4030+
4031 G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object);
4032 }
4033
4034@@ -374,54 +393,54 @@
4035 g_object_class_install_property (object_class, PROP_BUS, pspec);
4036
4037 bamf_tab_source_signals [REMOTE_TAB_URI_CHANGED] =
4038- g_signal_new ("remote-tab-uri-changed",
4039- G_OBJECT_CLASS_TYPE (klass),
4040- G_SIGNAL_RUN_FIRST,
4041- 0,
4042- NULL, NULL,
4043- bamf_marshal_VOID__STRING_STRING_STRING,
4044- G_TYPE_NONE, 3,
4045- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
4046+ g_signal_new ("remote-tab-uri-changed",
4047+ G_OBJECT_CLASS_TYPE (klass),
4048+ G_SIGNAL_RUN_FIRST,
4049+ 0,
4050+ NULL, NULL,
4051+ bamf_marshal_VOID__STRING_STRING_STRING,
4052+ G_TYPE_NONE, 3,
4053+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
4054
4055 bamf_tab_source_signals [REMOTE_TAB_OPENED] =
4056- g_signal_new ("remote-tab-opened",
4057- G_OBJECT_CLASS_TYPE (klass),
4058- G_SIGNAL_RUN_FIRST,
4059- 0,
4060- NULL, NULL,
4061- g_cclosure_marshal_VOID__STRING,
4062- G_TYPE_NONE, 1,
4063- G_TYPE_STRING);
4064+ g_signal_new ("remote-tab-opened",
4065+ G_OBJECT_CLASS_TYPE (klass),
4066+ G_SIGNAL_RUN_FIRST,
4067+ 0,
4068+ NULL, NULL,
4069+ g_cclosure_marshal_VOID__STRING,
4070+ G_TYPE_NONE, 1,
4071+ G_TYPE_STRING);
4072
4073 bamf_tab_source_signals [REMOTE_TAB_CLOSED] =
4074- g_signal_new ("remote-tab-closed",
4075- G_OBJECT_CLASS_TYPE (klass),
4076- G_SIGNAL_RUN_FIRST,
4077- 0,
4078- NULL, NULL,
4079- g_cclosure_marshal_VOID__STRING,
4080- G_TYPE_NONE, 1,
4081- G_TYPE_STRING);
4082+ g_signal_new ("remote-tab-closed",
4083+ G_OBJECT_CLASS_TYPE (klass),
4084+ G_SIGNAL_RUN_FIRST,
4085+ 0,
4086+ NULL, NULL,
4087+ g_cclosure_marshal_VOID__STRING,
4088+ G_TYPE_NONE, 1,
4089+ G_TYPE_STRING);
4090
4091 bamf_tab_source_signals [TAB_OPENED] =
4092- g_signal_new ("tab-opened",
4093- G_OBJECT_CLASS_TYPE (klass),
4094- G_SIGNAL_RUN_FIRST,
4095- 0,
4096- NULL, NULL,
4097- g_cclosure_marshal_VOID__OBJECT,
4098- G_TYPE_NONE, 1,
4099- BAMF_TYPE_TAB);
4100+ g_signal_new ("tab-opened",
4101+ G_OBJECT_CLASS_TYPE (klass),
4102+ G_SIGNAL_RUN_FIRST,
4103+ 0,
4104+ NULL, NULL,
4105+ g_cclosure_marshal_VOID__OBJECT,
4106+ G_TYPE_NONE, 1,
4107+ BAMF_TYPE_TAB);
4108
4109 bamf_tab_source_signals [TAB_CLOSED] =
4110- g_signal_new ("tab-closed",
4111- G_OBJECT_CLASS_TYPE (klass),
4112- G_SIGNAL_RUN_FIRST,
4113- 0,
4114- NULL, NULL,
4115- g_cclosure_marshal_VOID__OBJECT,
4116- G_TYPE_NONE, 1,
4117- BAMF_TYPE_TAB);
4118+ g_signal_new ("tab-closed",
4119+ G_OBJECT_CLASS_TYPE (klass),
4120+ G_SIGNAL_RUN_FIRST,
4121+ 0,
4122+ NULL, NULL,
4123+ g_cclosure_marshal_VOID__OBJECT,
4124+ G_TYPE_NONE, 1,
4125+ BAMF_TYPE_TAB);
4126 }
4127
4128 BamfTabSource *
4129
4130=== modified file 'src/bamf-tab-source.h'
4131--- src/bamf-tab-source.h 2010-05-25 13:47:38 +0000
4132+++ src/bamf-tab-source.h 2012-01-19 19:16:25 +0000
4133@@ -1,5 +1,5 @@
4134 /*
4135- * Copyright (C) 2010 Canonical Ltd
4136+ * Copyright (C) 2010-2011 Canonical Ltd
4137 *
4138 * This program is free software: you can redistribute it and/or modify
4139 * it under the terms of the GNU General Public License version 3 as
4140@@ -14,6 +14,7 @@
4141 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4142 *
4143 * Authored by: Jason Smith <jason.smith@canonical.com>
4144+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4145 *
4146 */
4147
4148@@ -59,7 +60,7 @@
4149
4150 void bamf_tab_source_show_tab (BamfTabSource *self, char *id);
4151
4152-GArray * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id);
4153+gchar * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id);
4154
4155 char * bamf_tab_source_get_tab_uri (BamfTabSource *self, char *id);
4156
4157
4158=== modified file 'src/bamf-tab.c'
4159--- src/bamf-tab.c 2011-08-01 23:25:01 +0000
4160+++ src/bamf-tab.c 2012-01-19 19:16:25 +0000
4161@@ -1,5 +1,5 @@
4162 /*
4163- * Copyright (C) 2010 Canonical Ltd
4164+ * Copyright (C) 2010-2011 Canonical Ltd
4165 *
4166 * This program is free software: you can redistribute it and/or modify
4167 * it under the terms of the GNU General Public License version 3 as
4168@@ -14,24 +14,20 @@
4169 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4170 *
4171 * Authored by: Jason Smith <jason.smith@canonical.com>
4172+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4173 *
4174 */
4175
4176 #include "bamf-tab.h"
4177-#include "bamf-tab-glue.h"
4178 #include "bamf-tab-source.h"
4179-#include "bamf-marshal.h"
4180
4181-G_DEFINE_TYPE (BamfTab, bamf_tab, BAMF_TYPE_VIEW);
4182 #define BAMF_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
4183 BAMF_TYPE_TAB, BamfTabPrivate))
4184
4185-enum
4186-{
4187- URI_CHANGED,
4188-
4189- LAST_SIGNAL,
4190-};
4191+static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface);
4192+G_DEFINE_TYPE_WITH_CODE (BamfTab, bamf_tab, BAMF_TYPE_VIEW,
4193+ G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_TAB,
4194+ bamf_tab_dbus_iface_init));
4195
4196 enum
4197 {
4198@@ -41,10 +37,9 @@
4199 PROP_SOURCE,
4200 };
4201
4202-static guint tab_signals[LAST_SIGNAL] = { 0 };
4203-
4204 struct _BamfTabPrivate
4205 {
4206+ BamfDBusItemTab *dbus_iface;
4207 char *id;
4208 char *uri;
4209 BamfTabSource *source;
4210@@ -73,20 +68,21 @@
4211 return bamf_tab_source_get_tab_xid (tab->priv->source, tab->priv->id);
4212 }
4213
4214-GArray *
4215+gchar *
4216 bamf_tab_get_preview (BamfTab *tab)
4217 {
4218 return bamf_tab_source_get_tab_preview (tab->priv->source, tab->priv->id);
4219 }
4220
4221-static char *
4222+static const char *
4223 bamf_tab_get_view_type (BamfView *view)
4224 {
4225- return g_strdup ("tab");
4226+ return "tab";
4227 }
4228
4229 static void
4230-on_tab_uri_changed (BamfTabSource *source, char *id, char *old_uri, char *new_uri, BamfTab *self)
4231+on_tab_source_uri_changed (BamfTabSource *source, char *id,
4232+ char *old_uri, char *new_uri, BamfTab *self)
4233 {
4234 if (g_strcmp0 (id, self->priv->id) != 0)
4235 return;
4236@@ -94,7 +90,70 @@
4237 g_free (self->priv->uri);
4238 self->priv->uri = g_strdup (new_uri);
4239
4240- g_signal_emit (self, URI_CHANGED, 0, old_uri, new_uri);
4241+ g_signal_emit_by_name (self, "uri-changed", old_uri, new_uri);
4242+}
4243+
4244+static void
4245+on_uri_changed (BamfTab *self, const gchar *old_uri, const gchar *new_uri, gpointer _not_used)
4246+{
4247+ g_return_if_fail (BAMF_IS_TAB (self));
4248+ g_signal_emit_by_name (self->priv->dbus_iface, "uri-changed", old_uri, new_uri);
4249+}
4250+
4251+static gboolean
4252+on_dbus_handle_show_tab (BamfDBusItemTab *interface,
4253+ GDBusMethodInvocation *invocation,
4254+ BamfTab *self)
4255+{
4256+ bamf_tab_show (self);
4257+ g_dbus_method_invocation_return_value (invocation, NULL);
4258+
4259+ return TRUE;
4260+}
4261+
4262+static gboolean
4263+on_dbus_handle_parent_xid (BamfDBusItemTab *interface,
4264+ GDBusMethodInvocation *invocation,
4265+ BamfTab *self)
4266+{
4267+ guint32 parent_xid = bamf_tab_parent_xid (self);
4268+ g_dbus_method_invocation_return_value (invocation,
4269+ g_variant_new ("(u)", parent_xid));
4270+
4271+ return TRUE;
4272+}
4273+
4274+static gboolean
4275+on_dbus_handle_current_uri (BamfDBusItemTab *interface,
4276+ GDBusMethodInvocation *invocation,
4277+ BamfTab *self)
4278+{
4279+ char *current_uri = self->priv->uri ? self->priv->uri : "";
4280+ g_dbus_method_invocation_return_value (invocation,
4281+ g_variant_new ("(s)", current_uri));
4282+
4283+ return TRUE;
4284+}
4285+
4286+static gboolean
4287+on_dbus_handle_preview (BamfDBusItemTab *interface,
4288+ GDBusMethodInvocation *invocation,
4289+ BamfTab *self)
4290+{
4291+ gchar *preview = bamf_tab_get_preview (self);
4292+
4293+ if (preview)
4294+ {
4295+ bamf_dbus_item_tab_complete_preview (interface, invocation, preview);
4296+ g_free (preview);
4297+ }
4298+ else
4299+ {
4300+ g_dbus_method_invocation_return_value (invocation,
4301+ g_variant_new ("(ay)", NULL));
4302+ }
4303+
4304+ return TRUE;
4305 }
4306
4307 static void
4308@@ -151,19 +210,72 @@
4309
4310 self = BAMF_TAB (object);
4311
4312- g_signal_connect (self->priv->source, "remote-tab-uri-changed", (GCallback) on_tab_uri_changed, self);
4313+ g_signal_connect (self->priv->source, "remote-tab-uri-changed",
4314+ G_CALLBACK (on_tab_source_uri_changed), self);
4315 }
4316
4317 static void
4318 bamf_tab_dispose (GObject *object)
4319 {
4320+ BamfTab *self = BAMF_TAB (object);
4321+
4322+ if (self->priv->id)
4323+ {
4324+ g_free (self->priv->id);
4325+ self->priv->id = NULL;
4326+ }
4327+
4328+ if (self->priv->uri)
4329+ {
4330+ g_free (self->priv->uri);
4331+ self->priv->uri = NULL;
4332+ }
4333+
4334 G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object);
4335 }
4336
4337 static void
4338+bamf_tab_finalize (GObject *object)
4339+{
4340+ BamfTab *self = BAMF_TAB (object);
4341+
4342+ g_object_unref (self->priv->dbus_iface);
4343+
4344+ G_OBJECT_CLASS (bamf_tab_parent_class)->finalize (object);
4345+}
4346+
4347+static void
4348 bamf_tab_init (BamfTab * self)
4349 {
4350 self->priv = BAMF_TAB_GET_PRIVATE (self);
4351+
4352+ /* Initializing the dbus interface */
4353+ self->priv->dbus_iface = bamf_dbus_item_tab_skeleton_new ();
4354+
4355+ /* We need to connect to the object own signals to redirect them to the dbus
4356+ * interface */
4357+ g_signal_connect (self, "uri-changed", G_CALLBACK (on_uri_changed), NULL);
4358+
4359+ /* Registering signal callbacks to reply to dbus method calls */
4360+ g_signal_connect (self->priv->dbus_iface, "handle-show-tab",
4361+ G_CALLBACK (on_dbus_handle_show_tab), self);
4362+
4363+ g_signal_connect (self->priv->dbus_iface, "handle-parent-xid",
4364+ G_CALLBACK (on_dbus_handle_parent_xid), self);
4365+
4366+ g_signal_connect (self->priv->dbus_iface, "handle-current-uri",
4367+ G_CALLBACK (on_dbus_handle_current_uri), self);
4368+
4369+ g_signal_connect (self->priv->dbus_iface, "handle-preview",
4370+ G_CALLBACK (on_dbus_handle_preview), self);
4371+
4372+ /* Setting the interface for the dbus object */
4373+ bamf_dbus_item_object_skeleton_set_tab (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
4374+ self->priv->dbus_iface);
4375+}
4376+
4377+static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface)
4378+{
4379 }
4380
4381 static void
4382@@ -177,6 +289,7 @@
4383 object_class->get_property = bamf_tab_get_property;
4384 object_class->set_property = bamf_tab_set_property;
4385 object_class->dispose = bamf_tab_dispose;
4386+ object_class->finalize = bamf_tab_finalize;
4387 view_class->view_type = bamf_tab_get_view_type;
4388
4389 pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
4390@@ -186,22 +299,10 @@
4391 g_object_class_install_property (object_class, PROP_SOURCE, pspec);
4392
4393 g_type_class_add_private (klass, sizeof (BamfTabPrivate));
4394-
4395- dbus_g_object_type_install_info (BAMF_TYPE_TAB,
4396- &dbus_glib_bamf_tab_object_info);
4397-
4398- tab_signals [URI_CHANGED] =
4399- g_signal_new ("uri-changed",
4400- G_OBJECT_CLASS_TYPE (klass),
4401- 0,
4402- 0, NULL, NULL,
4403- bamf_marshal_VOID__STRING_STRING,
4404- G_TYPE_NONE, 2,
4405- G_TYPE_STRING, G_TYPE_STRING);
4406 }
4407
4408 BamfTab *
4409-bamf_tab_new (BamfTabSource *source, char *id)
4410+bamf_tab_new (BamfTabSource *source, const char *id)
4411 {
4412 BamfTab *self;
4413 self = (BamfTab *) g_object_new (BAMF_TYPE_TAB,
4414
4415=== modified file 'src/bamf-tab.h'
4416--- src/bamf-tab.h 2010-05-25 13:47:38 +0000
4417+++ src/bamf-tab.h 2012-01-19 19:16:25 +0000
4418@@ -1,5 +1,5 @@
4419 /*
4420- * Copyright (C) 2010 Canonical Ltd
4421+ * Copyright (C) 2010-2011 Canonical Ltd
4422 *
4423 * This program is free software: you can redistribute it and/or modify
4424 * it under the terms of the GNU General Public License version 3 as
4425@@ -14,6 +14,7 @@
4426 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4427 *
4428 * Authored by: Jason Smith <jason.smith@canonical.com>
4429+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4430 *
4431 */
4432
4433@@ -58,8 +59,8 @@
4434
4435 guint32 bamf_tab_parent_xid (BamfTab *tab);
4436
4437-GArray * bamf_tab_get_preview (BamfTab *tab);
4438+gchar * bamf_tab_get_preview (BamfTab *tab);
4439
4440-BamfTab * bamf_tab_new (BamfTabSource *source, char *tab_id);
4441+BamfTab * bamf_tab_new (BamfTabSource *source, const char *tab_id);
4442
4443 #endif
4444
4445=== removed file 'src/bamf-view-glue.xml'
4446--- src/bamf-view-glue.xml 2011-01-26 09:54:11 +0000
4447+++ src/bamf-view-glue.xml 1970-01-01 00:00:00 +0000
4448@@ -1,109 +0,0 @@
4449-<?xml version="1.0" encoding="UTF-8" ?>
4450-
4451-<node name="/org/ayatana/bamf">
4452-
4453- <interface name="org.ayatana.bamf.view">
4454-
4455- <signal name="ActiveChanged">
4456- <arg type="b" name="new_state" direction="out" />
4457- </signal>
4458-
4459- <signal name="Closed">
4460- </signal>
4461-
4462- <signal name="ChildAdded">
4463- <arg type="s" name="path" direction="out" />
4464- </signal>
4465-
4466- <signal name="ChildRemoved">
4467- <arg type="s" name="path" direction="out" />
4468- </signal>
4469-
4470- <signal name="RunningChanged">
4471- <arg type="b" name="new_state" direction="out" />
4472- </signal>
4473-
4474- <signal name="UrgentChanged">
4475- <arg type="b" name="new_state" direction="out" />
4476- </signal>
4477-
4478- <signal name="UserVisibleChanged">
4479- <arg type="b" name="new_state" direction="out" />
4480- </signal>
4481-
4482- <signal name="NameChanged">
4483- <arg type="s" name="old_name" direction="out" />
4484- <arg type="s" name="new_name" direction="out" />
4485- </signal>
4486-
4487- <property name="Active" type="b" access="read" />
4488- <property name="Urgent" type="b" access="read" />
4489- <property name="Running" type="b" access="read" />
4490- <property name="UserVisible" type="b" access="read" />
4491-
4492- <method name="Children">
4493- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_children_paths" />
4494- <arg type="as" name="children" direction="out">
4495- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4496- </arg>
4497- </method>
4498-
4499- <method name="Parents">
4500- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_parent_paths" />
4501- <arg type="as" name="parents" direction="out">
4502- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4503- </arg>
4504- </method>
4505-
4506- <method name="IsActive">
4507- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_active" />
4508- <arg type="b" name="active" direction="out">
4509- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4510- </arg>
4511- </method>
4512-
4513- <method name="IsRunning">
4514- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_running" />
4515- <arg type="b" name="running" direction="out">
4516- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4517- </arg>
4518- </method>
4519-
4520- <method name="IsUrgent">
4521- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_urgent" />
4522- <arg type="b" name="urgent" direction="out">
4523- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4524- </arg>
4525- </method>
4526-
4527- <method name="Name">
4528- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_name" />
4529- <arg type="s" name="name" direction="out">
4530- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4531- </arg>
4532- </method>
4533-
4534- <method name="Icon">
4535- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_icon" />
4536- <arg type="s" name="name" direction="out">
4537- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4538- </arg>
4539- </method>
4540-
4541- <method name="UserVisible">
4542- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_user_visible" />
4543- <arg type="b" name="visible" direction="out">
4544- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4545- </arg>
4546- </method>
4547-
4548- <method name="ViewType">
4549- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_view_type" />
4550- <arg type="s" name="view_type" direction="out">
4551- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
4552- </arg>
4553- </method>
4554-
4555- </interface>
4556-
4557-</node>
4558
4559=== modified file 'src/bamf-view.c'
4560--- src/bamf-view.c 2011-12-14 03:19:47 +0000
4561+++ src/bamf-view.c 2012-01-19 19:16:25 +0000
4562@@ -1,5 +1,5 @@
4563 /*
4564- * Copyright (C) 2010 Canonical Ltd
4565+ * Copyright (C) 2010-2011 Canonical Ltd
4566 *
4567 * This program is free software: you can redistribute it and/or modify
4568 * it under the terms of the GNU General Public License version 3 as
4569@@ -14,21 +14,24 @@
4570 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4571 *
4572 * Authored by: Jason Smith <jason.smith@canonical.com>
4573+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4574 *
4575 */
4576
4577-#include "bamf-marshal.h"
4578 #include "bamf-view.h"
4579-#include "bamf-view-glue.h"
4580
4581-G_DEFINE_TYPE (BamfView, bamf_view, G_TYPE_OBJECT);
4582 #define BAMF_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
4583-BAMF_TYPE_VIEW, BamfViewPrivate))
4584+ BAMF_TYPE_VIEW, BamfViewPrivate))
4585+
4586+static void bamf_view_dbus_view_iface_init (BamfDBusItemViewIface *iface);
4587+G_DEFINE_TYPE_WITH_CODE (BamfView, bamf_view, BAMF_DBUS_ITEM_TYPE_OBJECT_SKELETON,
4588+ G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_VIEW,
4589+ bamf_view_dbus_view_iface_init));
4590
4591 enum
4592 {
4593 PROP_0,
4594-
4595+
4596 PROP_ACTIVE,
4597 PROP_RUNNING,
4598 PROP_URGENT,
4599@@ -37,16 +40,8 @@
4600
4601 enum
4602 {
4603- ACTIVE_CHANGED,
4604- CLOSED,
4605 CLOSED_INTERNAL,
4606- CHILD_ADDED,
4607- CHILD_REMOVED,
4608 EXPORTED,
4609- RUNNING_CHANGED,
4610- URGENT_CHANGED,
4611- USER_VISIBLE_CHANGED,
4612- NAME_CHANGED,
4613
4614 LAST_SIGNAL,
4615 };
4616@@ -55,20 +50,19 @@
4617
4618 struct _BamfViewPrivate
4619 {
4620+ BamfDBusItemView *dbus_iface;
4621 char * name;
4622 char * path;
4623 GList * children;
4624 GList * parents;
4625 gboolean closed;
4626- gboolean is_active;
4627- gboolean is_running;
4628- gboolean is_urgent;
4629- gboolean user_visible;
4630 };
4631
4632 static void
4633 bamf_view_active_changed (BamfView *view, gboolean active)
4634 {
4635+ g_return_if_fail (BAMF_IS_VIEW (view));
4636+
4637 gboolean emit = TRUE;
4638 if (BAMF_VIEW_GET_CLASS (view)->active_changed)
4639 {
4640@@ -76,16 +70,17 @@
4641 }
4642
4643 if (emit)
4644- g_signal_emit (view, view_signals[ACTIVE_CHANGED], 0, active);
4645-
4646+ g_signal_emit_by_name (view, "active-changed", active);
4647 }
4648
4649 static void
4650-bamf_view_name_changed (BamfView* view,
4651- const gchar* old_name,
4652- const gchar* new_name)
4653+bamf_view_name_changed (BamfView *view,
4654+ const gchar *old_name,
4655+ const gchar *new_name)
4656 {
4657- g_signal_emit (view, view_signals[NAME_CHANGED], 0, old_name, new_name);
4658+ g_return_if_fail (BAMF_IS_VIEW (view));
4659+
4660+ g_signal_emit_by_name (view, "name-changed", old_name, new_name);
4661
4662 if (view->priv->name)
4663 g_free (view->priv->name);
4664@@ -96,6 +91,8 @@
4665 static void
4666 bamf_view_user_visible_changed (BamfView *view, gboolean user_visible)
4667 {
4668+ g_return_if_fail (BAMF_IS_VIEW (view));
4669+
4670 gboolean emit = TRUE;
4671 if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed)
4672 {
4673@@ -103,12 +100,14 @@
4674 }
4675
4676 if (emit)
4677- g_signal_emit (view, view_signals[USER_VISIBLE_CHANGED], 0, user_visible);
4678+ g_signal_emit_by_name (view, "user-visible-changed", user_visible);
4679 }
4680
4681 static void
4682 bamf_view_running_changed (BamfView *view, gboolean running)
4683 {
4684+ g_return_if_fail (BAMF_IS_VIEW (view));
4685+
4686 gboolean emit = TRUE;
4687 if (BAMF_VIEW_GET_CLASS (view)->running_changed)
4688 {
4689@@ -116,12 +115,14 @@
4690 }
4691
4692 if (emit)
4693- g_signal_emit (view, view_signals[RUNNING_CHANGED], 0, running);
4694+ g_signal_emit_by_name (view, "running-changed", running);
4695 }
4696
4697 static void
4698 bamf_view_urgent_changed (BamfView *view, gboolean urgent)
4699 {
4700+ g_return_if_fail (BAMF_IS_VIEW (view));
4701+
4702 gboolean emit = TRUE;
4703 if (BAMF_VIEW_GET_CLASS (view)->urgent_changed)
4704 {
4705@@ -129,7 +130,7 @@
4706 }
4707
4708 if (emit)
4709- g_signal_emit (view, view_signals[URGENT_CHANGED], 0, urgent);
4710+ g_signal_emit_by_name (view, "urgent-changed", urgent);
4711 }
4712
4713 void
4714@@ -138,19 +139,20 @@
4715 BamfViewPrivate *priv;
4716 gboolean emit = TRUE;
4717 GList *l;
4718-
4719+
4720+ g_return_if_fail (BAMF_IS_VIEW (view));
4721 priv = view->priv;
4722
4723 if (priv->closed)
4724 return;
4725-
4726+
4727 priv->closed = TRUE;
4728
4729 if (BAMF_VIEW_GET_CLASS (view)->closed)
4730 {
4731 emit = !BAMF_VIEW_GET_CLASS (view)->closed (view);
4732 }
4733-
4734+
4735 if (priv->children)
4736 {
4737 for (l = priv->children; l; l = l->next)
4738@@ -164,10 +166,10 @@
4739
4740 if (emit)
4741 {
4742- g_object_ref (G_OBJECT (view));
4743+ g_object_ref (view);
4744 g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0);
4745- g_signal_emit (view, view_signals[CLOSED], 0);
4746- g_object_unref (G_OBJECT (view));
4747+ g_signal_emit_by_name (view, "closed");
4748+ g_object_unref (view);
4749 }
4750 }
4751
4752@@ -179,35 +181,31 @@
4753 return view->priv->path;
4754 }
4755
4756-char **
4757+GVariant *
4758 bamf_view_get_children_paths (BamfView *view)
4759 {
4760- char ** paths;
4761- const char *path;
4762- int n_items, i;
4763- GList *child;
4764- BamfView *cview;
4765+ GVariantBuilder b;
4766+ GList *l;
4767
4768 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
4769
4770- n_items = g_list_length (view->priv->children);
4771-
4772- paths = g_malloc0 (sizeof (char *) * (n_items + 1));
4773-
4774- i = 0;
4775- for (child = view->priv->children; child; child = child->next)
4776+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
4777+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
4778+
4779+ for (l = view->priv->children; l; l = l->next)
4780 {
4781- cview = child->data;
4782- path = bamf_view_get_path (cview);
4783+ BamfView *child = l->data;
4784+ const char *path = bamf_view_get_path (child);
4785
4786 if (!path)
4787 continue;
4788
4789- paths[i] = g_strdup (path);
4790- i++;
4791+ g_variant_builder_add (&b, "s", path);
4792 }
4793
4794- return paths;
4795+ g_variant_builder_close (&b);
4796+
4797+ return g_variant_builder_end (&b);
4798 }
4799
4800 GList *
4801@@ -218,35 +216,31 @@
4802 return view->priv->children;
4803 }
4804
4805-char **
4806+GVariant *
4807 bamf_view_get_parent_paths (BamfView *view)
4808 {
4809- char ** paths;
4810- const char *path;
4811- int n_items, i;
4812- GList *parent;
4813- BamfView *pview;
4814+ GVariantBuilder b;
4815+ GList *l;
4816
4817 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
4818
4819- n_items = g_list_length (view->priv->parents);
4820-
4821- paths = g_malloc0 (sizeof (char *) * (n_items + 1));
4822-
4823- i = 0;
4824- for (parent = view->priv->parents; parent; parent = parent->next)
4825+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
4826+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
4827+
4828+ for (l = view->priv->parents; l; l = l->next)
4829 {
4830- pview = parent->data;
4831- path = bamf_view_get_path (pview);
4832+ BamfView *parent = l->data;
4833+ const char *path = bamf_view_get_path (parent);
4834
4835 if (!path)
4836 continue;
4837
4838- paths[i] = g_strdup (path);
4839- i++;
4840+ g_variant_builder_add (&b, "s", path);
4841 }
4842
4843- return paths;
4844+ g_variant_builder_close (&b);
4845+
4846+ return g_variant_builder_end (&b);
4847 }
4848
4849 GList *
4850@@ -274,7 +268,7 @@
4851 g_return_if_fail (BAMF_IS_VIEW (child));
4852
4853 g_signal_connect (G_OBJECT (child), "closed-internal",
4854- (GCallback) bamf_view_handle_child_closed, view);
4855+ (GCallback) bamf_view_handle_child_closed, view);
4856
4857 /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */
4858 view->priv->children = g_list_prepend (view->priv->children, child);
4859@@ -285,7 +279,7 @@
4860 BAMF_VIEW_GET_CLASS (view)->child_added (view, child);
4861
4862 added = bamf_view_get_path (child);
4863- g_signal_emit (view, view_signals[CHILD_ADDED], 0, added);
4864+ g_signal_emit_by_name (view, "child-added", added);
4865 }
4866
4867 void
4868@@ -303,12 +297,12 @@
4869 view->priv->children = g_list_remove (view->priv->children, child);
4870 child->priv->parents = g_list_remove (child->priv->parents, view);
4871
4872+ removed = bamf_view_get_path (child);
4873+ g_signal_emit_by_name (view, "child-removed", removed);
4874+
4875 // Do this by hand so we can pass and object instead of a string
4876 if (BAMF_VIEW_GET_CLASS (view)->child_removed)
4877 BAMF_VIEW_GET_CLASS (view)->child_removed (view, child);
4878-
4879- removed = bamf_view_get_path (child);
4880- g_signal_emit (view, view_signals[CHILD_REMOVED], 0, removed);
4881 }
4882
4883 gboolean
4884@@ -316,7 +310,7 @@
4885 {
4886 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
4887
4888- return view->priv->is_active;
4889+ return bamf_dbus_item_view_get_active (view->priv->dbus_iface);
4890 }
4891
4892 void
4893@@ -325,10 +319,10 @@
4894 {
4895 g_return_if_fail (BAMF_IS_VIEW (view));
4896
4897- if (active == view->priv->is_active)
4898+ if (active == bamf_view_is_active (view))
4899 return;
4900
4901- view->priv->is_active = active;
4902+ bamf_dbus_item_view_set_active (view->priv->dbus_iface, active);
4903 bamf_view_active_changed (view, active);
4904 }
4905
4906@@ -337,7 +331,7 @@
4907 {
4908 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
4909
4910- return view->priv->is_urgent;
4911+ return bamf_dbus_item_view_get_urgent (view->priv->dbus_iface);
4912 }
4913
4914 void
4915@@ -346,10 +340,10 @@
4916 {
4917 g_return_if_fail (BAMF_IS_VIEW (view));
4918
4919- if (urgent == view->priv->is_urgent)
4920+ if (urgent == bamf_view_is_urgent (view))
4921 return;
4922
4923- view->priv->is_urgent = urgent;
4924+ bamf_dbus_item_view_set_urgent (view->priv->dbus_iface, urgent);
4925 bamf_view_urgent_changed (view, urgent);
4926 }
4927
4928@@ -358,7 +352,7 @@
4929 {
4930 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
4931
4932- return view->priv->is_running;
4933+ return bamf_dbus_item_view_get_running (view->priv->dbus_iface);
4934 }
4935
4936 void
4937@@ -367,10 +361,10 @@
4938 {
4939 g_return_if_fail (BAMF_IS_VIEW (view));
4940
4941- if (running == view->priv->is_running)
4942+ if (running == bamf_view_is_running (view))
4943 return;
4944
4945- view->priv->is_running = running;
4946+ bamf_dbus_item_view_set_running (view->priv->dbus_iface, running);
4947 bamf_view_running_changed (view, running);
4948 }
4949
4950@@ -379,7 +373,7 @@
4951 {
4952 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
4953
4954- return view->priv->user_visible;
4955+ return bamf_dbus_item_view_get_user_visible (view->priv->dbus_iface);
4956 }
4957
4958 void
4959@@ -387,10 +381,10 @@
4960 {
4961 g_return_if_fail (BAMF_IS_VIEW (view));
4962
4963- if (user_visible == view->priv->user_visible)
4964+ if (user_visible == bamf_view_user_visible (view))
4965 return;
4966
4967- view->priv->user_visible = user_visible;
4968+ bamf_dbus_item_view_set_user_visible (view->priv->dbus_iface, user_visible);
4969 bamf_view_user_visible_changed (view, user_visible);
4970 }
4971
4972@@ -422,10 +416,10 @@
4973 if (!g_strcmp0 (name, view->priv->name))
4974 return;
4975
4976- bamf_view_name_changed (view, view->priv->name, (gchar*) name);
4977+ bamf_view_name_changed (view, view->priv->name, name);
4978 }
4979
4980-char *
4981+const char *
4982 bamf_view_get_view_type (BamfView *view)
4983 {
4984 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
4985@@ -433,7 +427,7 @@
4986 if (BAMF_VIEW_GET_CLASS (view)->view_type)
4987 return BAMF_VIEW_GET_CLASS (view)->view_type (view);
4988
4989- return g_strdup ("view");
4990+ return "view";
4991 }
4992
4993 char *
4994@@ -447,14 +441,15 @@
4995 return g_strdup_printf ("view%p", view);
4996 }
4997
4998-char *
4999-bamf_view_export_on_bus (BamfView *view)
5000+const char *
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches