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
=== modified file 'libindicate/listener.c'
--- libindicate/listener.c 2011-09-20 03:17:39 +0000
+++ libindicate/listener.c 2011-12-01 17:18:34 +0000
@@ -78,12 +78,15 @@
78{78{
79 proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;79 proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;
8080
81 if (a->connection == b->connection) {81 if (a->connection == b->connection) {
82 return g_strcmp0(a->name, b->name);82 if (g_strcmp0(a->name, b->name) == 0) {
83 } else {83 return g_strcmp0(a->path, b->path);
84 /* we're only using this for equal, not sorting */84 }
85 return 1;85 }
86 }86
87 /* we're only using this for equal, not sorting */
88 return 1;
89
87}90}
8891
89typedef struct {92typedef struct {
@@ -261,7 +264,7 @@
261indicate_listener_dispose (GObject * obj)264indicate_listener_dispose (GObject * obj)
262{265{
263 IndicateListener * listener = INDICATE_LISTENER(obj);266 IndicateListener * listener = INDICATE_LISTENER(obj);
264 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);267 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
265268
266 if (priv->signal_subscription != 0) {269 if (priv->signal_subscription != 0) {
267 g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);270 g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
@@ -575,6 +578,7 @@
575 proxy_t searchitem;578 proxy_t searchitem;
576 searchitem.name = todo->name;579 searchitem.name = todo->name;
577 searchitem.connection = todo->bus;580 searchitem.connection = todo->bus;
581 searchitem.path = todo->path;
578582
579 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);583 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
580 if (proxyitem != NULL) {584 if (proxyitem != NULL) {
@@ -1406,6 +1410,7 @@
1406 proxy_t searchitem;1410 proxy_t searchitem;
1407 searchitem.name = server->name;1411 searchitem.name = server->name;
1408 searchitem.connection = server->connection;1412 searchitem.connection = server->connection;
1413 searchitem.path = (gchar *)indicate_listener_server_get_dbuspath (server);
14091414
1410 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);1415 GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
1411 if (proxyitem == NULL) {1416 if (proxyitem == NULL) {
@@ -1430,6 +1435,14 @@
1430 return server->name;1435 return server->name;
1431}1436}
14321437
1438const gchar *
1439indicate_listener_server_get_dbuspath (IndicateListenerServer *server)
1440{
1441 if (server == NULL) return NULL;
1442
1443 return g_dbus_proxy_get_object_path (server->proxy);
1444}
1445
1433guint1446guint
1434indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator)1447indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator)
1435{1448{
14361449
=== modified file 'libindicate/listener.h'
--- libindicate/listener.h 2011-08-15 21:21:46 +0000
+++ libindicate/listener.h 2011-12-01 17:18:34 +0000
@@ -196,6 +196,7 @@
196GList * indicate_listener_server_get_indicators (IndicateListener * listener,196GList * indicate_listener_server_get_indicators (IndicateListener * listener,
197 IndicateListenerServer * server);197 IndicateListenerServer * server);
198const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);198const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
199const gchar * indicate_listener_server_get_dbuspath (IndicateListenerServer *server);
199guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);200guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
200void indicate_listener_server_show_interest (IndicateListener * listener,201void indicate_listener_server_show_interest (IndicateListener * listener,
201 IndicateListenerServer * server,202 IndicateListenerServer * server,
202203
=== modified file 'libindicate/server.c'
--- libindicate/server.c 2011-08-10 19:13:56 +0000
+++ libindicate/server.c 2011-12-01 17:18:34 +0000
@@ -79,7 +79,8 @@
79 PROP_DESKTOP,79 PROP_DESKTOP,
80 PROP_TYPE,80 PROP_TYPE,
81 PROP_COUNT,81 PROP_COUNT,
82 PROP_MENU82 PROP_MENU,
83 PROP_PATH
83};84};
8485
85static guint signals[LAST_SIGNAL] = { 0 };86static guint signals[LAST_SIGNAL] = { 0 };
@@ -408,6 +409,10 @@
408 "The DBus Object path to an object with a dbusmenu interface on it.",409 "The DBus Object path to an object with a dbusmenu interface on it.",
409 "",410 "",
410 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));411 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
412
413 g_object_class_install_property (gobj, PROP_PATH,
414 g_param_spec_string("path", "DBus Path for server", "DBus path for the server object", "/com/canonical/indicate",
415 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
411416
412 class->get_indicator_count = get_indicator_count;417 class->get_indicator_count = get_indicator_count;
413 class->get_indicator_list = get_indicator_list;418 class->get_indicator_list = get_indicator_list;
@@ -484,7 +489,7 @@
484489
485 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);490 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
486491
487 priv->path = g_strdup("/com/canonical/indicate");492 priv->path = NULL;
488 priv->indicators = NULL;493 priv->indicators = NULL;
489 priv->num_hidden = 0;494 priv->num_hidden = 0;
490 priv->visible = FALSE;495 priv->visible = FALSE;
@@ -624,6 +629,12 @@
624 }629 }
625 break;630 break;
626 }631 }
632 case PROP_PATH:
633 if (priv->path != NULL) {
634 g_free(priv->path);
635 }
636 priv->path = g_value_dup_string(value);
637 break;
627 default:638 default:
628 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);639 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
629 break;640 break;
@@ -671,6 +682,9 @@
671 g_value_set_boxed(value, g_strdup("/"));682 g_value_set_boxed(value, g_strdup("/"));
672 }683 }
673 break;684 break;
685 case PROP_PATH:
686 g_value_set_string(value, priv->path);
687 break;
674 default:688 default:
675 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);689 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
676 break;690 break;
@@ -1948,6 +1962,24 @@
1948 return 0;1962 return 0;
1949}1963}
19501964
1965/**
1966 * @indicate_server_get_path:
1967 * @server: The #IndicateServer to get the path of.
1968 *
1969 * Gets DBus object path for the exported server object.
1970 *
1971 * Return value: The servers DBus path.
1972 */
1973const gchar *
1974indicate_server_get_path (IndicateServer *server)
1975{
1976 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
1977
1978 g_return_val_if_fail(INDICATE_IS_SERVER(server), NULL);
1979
1980 return priv->path;
1981}
1982
1951static IndicateInterests1983static IndicateInterests
1952interest_string_to_enum (const gchar * interest_string)1984interest_string_to_enum (const gchar * interest_string)
1953{1985{
19541986
=== modified file 'libindicate/server.h'
--- libindicate/server.h 2011-08-10 19:13:56 +0000
+++ libindicate/server.h 2011-12-01 17:18:34 +0000
@@ -213,6 +213,9 @@
213213
214GType indicate_server_get_type (void) G_GNUC_CONST;214GType indicate_server_get_type (void) G_GNUC_CONST;
215215
216/* Gets the server object path. */
217const gchar *indicate_server_get_path (IndicateServer *server);
218
216/* Sets the object. By default this is /org/freedesktop/indicators */219/* Sets the object. By default this is /org/freedesktop/indicators */
217void indicate_server_set_dbus_object (const gchar * obj);220void indicate_server_set_dbus_object (const gchar * obj);
218221
@@ -244,6 +247,8 @@
244/* Setting a server to use */247/* Setting a server to use */
245void indicate_server_set_menu (IndicateServer * server, DbusmenuServer * menu);248void indicate_server_set_menu (IndicateServer * server, DbusmenuServer * menu);
246249
250
251
247/**252/**
248 SECTION:server253 SECTION:server
249 @short_description: The representation of the application on DBus.254 @short_description: The representation of the application on DBus.
250255
=== modified file 'tests/test-simple-server.c'
--- tests/test-simple-server.c 2009-04-20 16:25:33 +0000
+++ tests/test-simple-server.c 2011-12-01 17:18:34 +0000
@@ -8,8 +8,12 @@
8static void8static void
9server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)9server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
10{10{
11 g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);11 g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
12 g_main_loop_quit(mainloop);12 if (!g_strcmp0(type, "test.type")) {
13 if (!g_strcmp0(indicate_listener_server_get_dbuspath(server), "/com/tests/indicate/server")) {
14 g_main_loop_quit(mainloop);
15 }
16 }
13}17}
1418
15static gboolean19static gboolean
@@ -25,11 +29,19 @@
25main (int argc, char * argv)29main (int argc, char * argv)
26{30{
27 g_type_init();31 g_type_init();
2832 // HACK: This just works around a bug
33 indicate_server_ref_default ();
34
29 IndicateListener * listener = indicate_listener_ref_default();35 IndicateListener * listener = indicate_listener_ref_default();
3036 IndicateServer * server = g_object_new (INDICATE_TYPE_SERVER, "path", "/com/tests/indicate/server", NULL);
37
38 indicate_server_set_type(server, "test.type");
39
31 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);40 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
3241
42 indicate_server_show (server);
43
44
33 g_timeout_add_seconds(5, failed_cb, NULL);45 g_timeout_add_seconds(5, failed_cb, NULL);
3446
35 mainloop = g_main_loop_new(NULL, FALSE);47 mainloop = g_main_loop_new(NULL, FALSE);

Subscribers

People subscribed via source and target branches