Merge lp:~robertcarr/libindicate/fix-multiserver into lp:libindicate/0.6

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/libindicate/fix-multiserver
Merge into: lp:libindicate/0.6
Diff against target: 223 lines (+76/-13)
5 files modified
libindicate/listener.c (+20/-7)
libindicate/listener.h (+1/-0)
libindicate/server.c (+34/-2)
libindicate/server.h (+5/-0)
tests/test-simple-server.c (+16/-4)
To merge this branch: bzr merge lp:~robertcarr/libindicate/fix-multiserver
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+84141@code.launchpad.net

This proposal has been superseded by a proposal from 2012-02-09.

Description of the change

A host of changes to fix multiple servers from a single DBus name. See individual commits for details.

To post a comment you must log in.

Unmerged revisions

446. By Robert Carr

Implement server test based off the path setting code

445. By Robert Carr

indicate_listener_server_get_indicators: Fix const correct warning in searchitem assignment

444. By Robert Carr

Again we need to compare by DBus path as well as name

443. By Robert Carr

listener.c: In todo_idle we have to give our search item a path. This prevents a breakdown when the same DBus name exports two indicate servers at seperate paths

442. By Robert Carr

Implement indicate_listener_server_get_dbuspath

441. By Robert Carr

When comparing two proxy_t we have to check their DBus name and DBus path

440. By Robert Carr

Implement indicate_server_get_path

439. By Robert Carr

Implement path property on server to enable exporting server objects at paths besides /com/canonical/indicate

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicate/listener.c'
2--- libindicate/listener.c 2011-09-20 03:17:39 +0000
3+++ libindicate/listener.c 2011-12-01 17:18:34 +0000
4@@ -78,12 +78,15 @@
5 {
6 proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;
7
8- if (a->connection == b->connection) {
9- return g_strcmp0(a->name, b->name);
10- } else {
11- /* we're only using this for equal, not sorting */
12- return 1;
13- }
14+ if (a->connection == b->connection) {
15+ if (g_strcmp0(a->name, b->name) == 0) {
16+ return g_strcmp0(a->path, b->path);
17+ }
18+ }
19+
20+ /* we're only using this for equal, not sorting */
21+ return 1;
22+
23 }
24
25 typedef struct {
26@@ -261,7 +264,7 @@
27 indicate_listener_dispose (GObject * obj)
28 {
29 IndicateListener * listener = INDICATE_LISTENER(obj);
30- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
31+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
32
33 if (priv->signal_subscription != 0) {
34 g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
35@@ -575,6 +578,7 @@
36 proxy_t searchitem;
37 searchitem.name = todo->name;
38 searchitem.connection = todo->bus;
39+ searchitem.path = todo->path;
40
41 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
42 if (proxyitem != NULL) {
43@@ -1406,6 +1410,7 @@
44 proxy_t searchitem;
45 searchitem.name = server->name;
46 searchitem.connection = server->connection;
47+ searchitem.path = (gchar *)indicate_listener_server_get_dbuspath (server);
48
49 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
50 if (proxyitem == NULL) {
51@@ -1430,6 +1435,14 @@
52 return server->name;
53 }
54
55+const gchar *
56+indicate_listener_server_get_dbuspath (IndicateListenerServer *server)
57+{
58+ if (server == NULL) return NULL;
59+
60+ return g_dbus_proxy_get_object_path (server->proxy);
61+}
62+
63 guint
64 indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator)
65 {
66
67=== modified file 'libindicate/listener.h'
68--- libindicate/listener.h 2011-08-15 21:21:46 +0000
69+++ libindicate/listener.h 2011-12-01 17:18:34 +0000
70@@ -196,6 +196,7 @@
71 GList * indicate_listener_server_get_indicators (IndicateListener * listener,
72 IndicateListenerServer * server);
73 const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
74+const gchar * indicate_listener_server_get_dbuspath (IndicateListenerServer *server);
75 guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
76 void indicate_listener_server_show_interest (IndicateListener * listener,
77 IndicateListenerServer * server,
78
79=== modified file 'libindicate/server.c'
80--- libindicate/server.c 2011-08-10 19:13:56 +0000
81+++ libindicate/server.c 2011-12-01 17:18:34 +0000
82@@ -79,7 +79,8 @@
83 PROP_DESKTOP,
84 PROP_TYPE,
85 PROP_COUNT,
86- PROP_MENU
87+ PROP_MENU,
88+ PROP_PATH
89 };
90
91 static guint signals[LAST_SIGNAL] = { 0 };
92@@ -408,6 +409,10 @@
93 "The DBus Object path to an object with a dbusmenu interface on it.",
94 "",
95 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
96+
97+ g_object_class_install_property (gobj, PROP_PATH,
98+ g_param_spec_string("path", "DBus Path for server", "DBus path for the server object", "/com/canonical/indicate",
99+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
100
101 class->get_indicator_count = get_indicator_count;
102 class->get_indicator_list = get_indicator_list;
103@@ -484,7 +489,7 @@
104
105 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
106
107- priv->path = g_strdup("/com/canonical/indicate");
108+ priv->path = NULL;
109 priv->indicators = NULL;
110 priv->num_hidden = 0;
111 priv->visible = FALSE;
112@@ -624,6 +629,12 @@
113 }
114 break;
115 }
116+ case PROP_PATH:
117+ if (priv->path != NULL) {
118+ g_free(priv->path);
119+ }
120+ priv->path = g_value_dup_string(value);
121+ break;
122 default:
123 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
124 break;
125@@ -671,6 +682,9 @@
126 g_value_set_boxed(value, g_strdup("/"));
127 }
128 break;
129+ case PROP_PATH:
130+ g_value_set_string(value, priv->path);
131+ break;
132 default:
133 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
134 break;
135@@ -1948,6 +1962,24 @@
136 return 0;
137 }
138
139+/**
140+ * @indicate_server_get_path:
141+ * @server: The #IndicateServer to get the path of.
142+ *
143+ * Gets DBus object path for the exported server object.
144+ *
145+ * Return value: The servers DBus path.
146+ */
147+const gchar *
148+indicate_server_get_path (IndicateServer *server)
149+{
150+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
151+
152+ g_return_val_if_fail(INDICATE_IS_SERVER(server), NULL);
153+
154+ return priv->path;
155+}
156+
157 static IndicateInterests
158 interest_string_to_enum (const gchar * interest_string)
159 {
160
161=== modified file 'libindicate/server.h'
162--- libindicate/server.h 2011-08-10 19:13:56 +0000
163+++ libindicate/server.h 2011-12-01 17:18:34 +0000
164@@ -213,6 +213,9 @@
165
166 GType indicate_server_get_type (void) G_GNUC_CONST;
167
168+/* Gets the server object path. */
169+const gchar *indicate_server_get_path (IndicateServer *server);
170+
171 /* Sets the object. By default this is /org/freedesktop/indicators */
172 void indicate_server_set_dbus_object (const gchar * obj);
173
174@@ -244,6 +247,8 @@
175 /* Setting a server to use */
176 void indicate_server_set_menu (IndicateServer * server, DbusmenuServer * menu);
177
178+
179+
180 /**
181 SECTION:server
182 @short_description: The representation of the application on DBus.
183
184=== modified file 'tests/test-simple-server.c'
185--- tests/test-simple-server.c 2009-04-20 16:25:33 +0000
186+++ tests/test-simple-server.c 2011-12-01 17:18:34 +0000
187@@ -8,8 +8,12 @@
188 static void
189 server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
190 {
191- g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
192- g_main_loop_quit(mainloop);
193+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
194+ if (!g_strcmp0(type, "test.type")) {
195+ if (!g_strcmp0(indicate_listener_server_get_dbuspath(server), "/com/tests/indicate/server")) {
196+ g_main_loop_quit(mainloop);
197+ }
198+ }
199 }
200
201 static gboolean
202@@ -25,11 +29,19 @@
203 main (int argc, char * argv)
204 {
205 g_type_init();
206-
207+ // HACK: This just works around a bug
208+ indicate_server_ref_default ();
209+
210 IndicateListener * listener = indicate_listener_ref_default();
211-
212+ IndicateServer * server = g_object_new (INDICATE_TYPE_SERVER, "path", "/com/tests/indicate/server", NULL);
213+
214+ indicate_server_set_type(server, "test.type");
215+
216 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
217
218+ indicate_server_show (server);
219+
220+
221 g_timeout_add_seconds(5, failed_cb, NULL);
222
223 mainloop = g_main_loop_new(NULL, FALSE);

Subscribers

People subscribed via source and target branches