ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #04053
[Merge] lp:~robertcarr/libindicate/fix-multiserver into lp:libindicate
Robert Carr has proposed merging lp:~robertcarr/libindicate/fix-multiserver into lp:libindicate.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
For more details, see:
https://code.launchpad.net/~robertcarr/libindicate/fix-multiserver/+merge/84141
A host of changes to fix multiple servers from a single DBus name. See individual commits for details.
--
https://code.launchpad.net/~robertcarr/libindicate/fix-multiserver/+merge/84141
Your team ayatana-commits is subscribed to branch lp:libindicate.
=== modified file 'libindicate/listener.c'
--- libindicate/listener.c 2011-09-20 03:17:39 +0000
+++ libindicate/listener.c 2011-12-01 17:13:02 +0000
@@ -78,12 +78,15 @@
{
proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;
- if (a->connection == b->connection) {
- return g_strcmp0(a->name, b->name);
- } else {
- /* we're only using this for equal, not sorting */
- return 1;
- }
+ if (a->connection == b->connection) {
+ if (g_strcmp0(a->name, b->name) == 0) {
+ return g_strcmp0(a->path, b->path);
+ }
+ }
+
+ /* we're only using this for equal, not sorting */
+ return 1;
+
}
typedef struct {
@@ -261,7 +264,7 @@
indicate_listener_dispose (GObject * obj)
{
IndicateListener * listener = INDICATE_LISTENER(obj);
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
if (priv->signal_subscription != 0) {
g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
@@ -575,6 +578,7 @@
proxy_t searchitem;
searchitem.name = todo->name;
searchitem.connection = todo->bus;
+ searchitem.path = todo->path;
GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
if (proxyitem != NULL) {
@@ -1406,6 +1410,7 @@
proxy_t searchitem;
searchitem.name = server->name;
searchitem.connection = server->connection;
+ searchitem.path = (gchar *)indicate_listener_server_get_dbuspath (server);
GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
if (proxyitem == NULL) {
@@ -1430,6 +1435,14 @@
return server->name;
}
+const gchar *
+indicate_listener_server_get_dbuspath (IndicateListenerServer *server)
+{
+ if (server == NULL) return NULL;
+
+ return g_dbus_proxy_get_object_path (server->proxy);
+}
+
guint
indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator)
{
=== modified file 'libindicate/listener.h'
--- libindicate/listener.h 2011-08-15 21:21:46 +0000
+++ libindicate/listener.h 2011-12-01 17:13:02 +0000
@@ -196,6 +196,7 @@
GList * indicate_listener_server_get_indicators (IndicateListener * listener,
IndicateListenerServer * server);
const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
+const gchar * indicate_listener_server_get_dbuspath (IndicateListenerServer *server);
guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
void indicate_listener_server_show_interest (IndicateListener * listener,
IndicateListenerServer * server,
=== modified file 'libindicate/server.c'
--- libindicate/server.c 2011-08-10 19:13:56 +0000
+++ libindicate/server.c 2011-12-01 17:13:02 +0000
@@ -79,7 +79,8 @@
PROP_DESKTOP,
PROP_TYPE,
PROP_COUNT,
- PROP_MENU
+ PROP_MENU,
+ PROP_PATH
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -408,6 +409,10 @@
"The DBus Object path to an object with a dbusmenu interface on it.",
"",
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobj, PROP_PATH,
+ g_param_spec_string("path", "DBus Path for server", "DBus path for the server object", "/com/canonical/indicate",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
class->get_indicator_count = get_indicator_count;
class->get_indicator_list = get_indicator_list;
@@ -484,7 +489,7 @@
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- priv->path = g_strdup("/com/canonical/indicate");
+ priv->path = NULL;
priv->indicators = NULL;
priv->num_hidden = 0;
priv->visible = FALSE;
@@ -624,6 +629,12 @@
}
break;
}
+ case PROP_PATH:
+ if (priv->path != NULL) {
+ g_free(priv->path);
+ }
+ priv->path = g_value_dup_string(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
break;
@@ -671,6 +682,9 @@
g_value_set_boxed(value, g_strdup("/"));
}
break;
+ case PROP_PATH:
+ g_value_set_string(value, priv->path);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
break;
@@ -1948,6 +1962,24 @@
return 0;
}
+/**
+ * @indicate_server_get_path:
+ * @server: The #IndicateServer to get the path of.
+ *
+ * Gets DBus object path for the exported server object.
+ *
+ * Return value: The servers DBus path.
+ */
+const gchar *
+indicate_server_get_path (IndicateServer *server)
+{
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+
+ g_return_val_if_fail(INDICATE_IS_SERVER(server), NULL);
+
+ return priv->path;
+}
+
static IndicateInterests
interest_string_to_enum (const gchar * interest_string)
{
=== modified file 'libindicate/server.h'
--- libindicate/server.h 2011-08-10 19:13:56 +0000
+++ libindicate/server.h 2011-12-01 17:13:02 +0000
@@ -213,6 +213,9 @@
GType indicate_server_get_type (void) G_GNUC_CONST;
+/* Gets the server object path. */
+const gchar *indicate_server_get_path (IndicateServer *server);
+
/* Sets the object. By default this is /org/freedesktop/indicators */
void indicate_server_set_dbus_object (const gchar * obj);
@@ -244,6 +247,8 @@
/* Setting a server to use */
void indicate_server_set_menu (IndicateServer * server, DbusmenuServer * menu);
+
+
/**
SECTION:server
@short_description: The representation of the application on DBus.
=== 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:13:02 +0000
@@ -8,8 +8,12 @@
static void
server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
{
- g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
- g_main_loop_quit(mainloop);
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ if (!g_strcmp0(type, "test.type")) {
+ if (!g_strcmp0(indicate_listener_server_get_dbuspath(server), "/com/tests/indicate/server")) {
+ g_main_loop_quit(mainloop);
+ }
+ }
}
static gboolean
@@ -25,11 +29,19 @@
main (int argc, char * argv)
{
g_type_init();
-
+ // HACK: This just works around a bug
+ indicate_server_ref_default ();
+
IndicateListener * listener = indicate_listener_ref_default();
-
+ IndicateServer * server = g_object_new (INDICATE_TYPE_SERVER, "path", "/com/tests/indicate/server", NULL);
+
+ indicate_server_set_type(server, "test.type");
+
g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+ indicate_server_show (server);
+
+
g_timeout_add_seconds(5, failed_cb, NULL);
mainloop = g_main_loop_new(NULL, FALSE);