From f7bf54acfd41be9c753ff339e7b681ad05f87ff2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 12:37:24 -0500 Subject: First pass at the pretty meag-change to make it so that we can detect people on the system vs. the session bus. Basically reworking a bunch of structures. Fun. --- libindicate/listener.c | 123 ++++++++++++++++++++++++++++++++----------------- libindicate/listener.h | 11 +++-- 2 files changed, 88 insertions(+), 46 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index b786552..e54b9b4 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -51,6 +51,15 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +struct _IndicateListenerServer { + gchar * name; + DBusGProxy * proxy; +}; + +struct _IndicateListenerIndicator { + guint id; +}; + typedef struct _IndicateListenerPrivate IndicateListenerPrivate; struct _IndicateListenerPrivate { @@ -60,8 +69,8 @@ struct _IndicateListenerPrivate DBusGProxy * dbus_proxy_session; DBusGProxy * dbus_proxy_system; - GHashTable * proxies_working; - GHashTable * proxies_possible; + GList * proxies_working; + GList * proxies_possible; GArray * proxy_todo; guint todo_idle; @@ -78,8 +87,23 @@ typedef struct { gchar * type; IndicateListener * listener; GHashTable * indicators; + + IndicateListenerServer server; } proxy_t; +static gint +proxy_t_equal (gconstpointer pa, gconstpointer pb) +{ + proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb; + + if (a->proxy == b->proxy) { + return g_strcmp0(a->name, b->name); + } else { + /* we're only using this for equal, not sorting */ + return 1; + } +} + typedef struct { DBusGConnection * bus; gchar * name; @@ -219,8 +243,8 @@ indicate_listener_init (IndicateListener * listener) G_CALLBACK(dbus_owner_change), listener, NULL); /* Initialize Data structures */ - priv->proxies_working = g_hash_table_new(g_str_hash, g_str_equal); - priv->proxies_possible = g_hash_table_new(g_str_hash, g_str_equal); + priv->proxies_working = NULL; + priv->proxies_possible = NULL; /* TODO: Look at some common scenarios and find out how to make this sized */ priv->proxy_todo = g_array_new(FALSE, TRUE, sizeof(proxy_todo_t)); @@ -292,16 +316,20 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c todo_list_add(name, proxy, listener, FALSE); } if (new != NULL && new[0] == '\0') { - proxy_t * proxyt; - proxyt = g_hash_table_lookup(priv->proxies_working, name); - if (proxyt != NULL) { - g_hash_table_remove(priv->proxies_working, name); - proxy_struct_destroy(proxyt); + proxy_t searchitem; + searchitem.proxy = proxy; + searchitem.name = (gchar *)name; /* Droping const, not that it isn't, but to remove the warning */ + + GList * proxyt_item; + proxyt_item = g_list_find_custom(priv->proxies_working, &searchitem, proxy_t_equal); + if (proxyt_item != NULL) { + proxy_struct_destroy((proxy_t *)proxyt_item->data); + priv->proxies_working = g_list_remove(priv->proxies_working, proxyt_item); } - proxyt = g_hash_table_lookup(priv->proxies_possible, name); - if (proxyt != NULL) { - g_hash_table_remove(priv->proxies_possible, name); - proxy_struct_destroy(proxyt); + proxyt_item = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal); + if (proxyt_item != NULL) { + proxy_struct_destroy((proxy_t *)proxyt_item->data); + priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item); } } @@ -319,7 +347,7 @@ proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data) GList * indicator; for (indicator = keys; indicator != NULL; indicator = indicator->next) { guint id = (guint)indicator->data; - g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, proxy_data->name, id, type, TRUE); + g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(id), type, TRUE); } g_list_free(keys); @@ -339,7 +367,7 @@ proxy_struct_destroy (gpointer data) proxy_data); g_hash_table_remove_all(proxy_data->indicators); - g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, proxy_data->name, proxy_data->type, TRUE); + g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE); proxy_data->indicators = NULL; } @@ -444,6 +472,8 @@ todo_idle (gpointer data) proxyt->listener = listener; proxyt->indicators = NULL; proxyt->connection = todo->bus; + proxyt->server.name = todo->name; + proxyt->server.proxy = proxyt->proxy; priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1); @@ -457,7 +487,7 @@ todo_idle (gpointer data) dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow", G_CALLBACK(proxy_server_added), proxyt, NULL); - g_hash_table_insert(priv->proxies_possible, proxyt->name, proxyt); + priv->proxies_possible = g_list_append(priv->proxies_possible, proxyt); /* I think that we need to have this as there is a race * condition here. If someone comes on the bus and we get @@ -465,7 +495,7 @@ todo_idle (gpointer data) * signal it gets sent, we wouldn't get it. So then we would * miss an indicator server coming on the bus. I'd like to not * generate a warning in every app with DBus though. */ - indicate_listener_server_get_type(listener, (IndicateListenerServer *)proxyt->name, get_type_cb, proxyt); + indicate_listener_server_get_type(listener, &proxyt->server, get_type_cb, proxyt); return TRUE; } @@ -538,8 +568,13 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt) g_free, proxy_indicators_free); /* Elevate to working */ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener); - g_hash_table_remove(priv->proxies_possible, proxyt->name); - g_hash_table_insert(priv->proxies_working, proxyt->name, proxyt); + + GList * proxyt_item; + proxyt_item = g_list_find_custom(priv->proxies_possible, proxyt, proxy_t_equal); + if (proxyt_item != NULL) { + priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item); + } + priv->proxies_working = g_list_append(priv->proxies_working, proxyt); dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); @@ -561,7 +596,7 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt) proxyt->type = g_strdup(type); } - g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, proxyt->name, proxyt->type, TRUE); + g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE); } return; @@ -583,7 +618,7 @@ proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t if (!g_hash_table_lookup(indicators, (gpointer)id)) { g_hash_table_insert(indicators, (gpointer)id, (gpointer)TRUE); - g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, proxyt->name, id, type, TRUE); + g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE); } return; @@ -609,7 +644,7 @@ proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy } g_hash_table_remove(indicators, (gpointer)id); - g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, proxyt->name, id, type, TRUE); + g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE); return; } @@ -642,7 +677,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, return; } - g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, proxyt->name, id, type, property, TRUE); + g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); return; } @@ -754,14 +789,6 @@ get_property_helper (IndicateListener * listener, IndicateListenerServer * serve { /* g_debug("get_property_helper: %s %d", property, prop_type); */ /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */ - IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); - - proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); - if (proxyt == NULL) { - g_error("Trying to get property '%s' on server '%s' that currently isn't set to working.", property, (gchar *)server); - return; - } - get_property_t * get_property_data = g_new(get_property_t, 1); get_property_data->cb = callback; get_property_data->data = data; @@ -771,7 +798,7 @@ get_property_helper (IndicateListener * listener, IndicateListenerServer * serve get_property_data->property = g_strdup(property); get_property_data->type = prop_type; - org_freedesktop_indicator_get_indicator_property_async (proxyt->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data); + org_freedesktop_indicator_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data); return; } @@ -812,11 +839,7 @@ listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata) void indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator) { - IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); - - proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server); - - org_freedesktop_indicator_show_indicator_to_user_async (proxyt->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), listener_display_cb, NULL); + org_freedesktop_indicator_show_indicator_to_user_async (server->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), listener_display_cb, NULL); return; } @@ -871,16 +894,22 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve /* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); - proxy_t * proxyt = g_hash_table_lookup(priv->proxies_possible, server); - if (proxyt == NULL) { - proxyt = g_hash_table_lookup(priv->proxies_working, server); + proxy_t searchitem; + searchitem.name = server->name; + searchitem.proxy = server->proxy; + + GList * proxyitem = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal); + if (proxyitem == NULL) { + proxyitem = g_list_find_custom(priv->proxies_working, &searchitem, proxy_t_equal); } - if (proxyt == NULL) { + if (proxyitem == NULL) { g_warning("Can not find a proxy for the server at all."); return; } + proxy_t * proxyt = (proxy_t *)proxyitem->data; + if (proxyt->property_proxy == NULL) { proxyt->property_proxy = dbus_g_proxy_new_for_name(proxyt->connection, proxyt->name, @@ -918,3 +947,15 @@ indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListe return get_server_property(listener, server, callback, "desktop", data); } +const gchar * +indicate_listener_server_get_dbusname (IndicateListenerServer * server) +{ + return server->name; +} + +guint +indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator) +{ + return GPOINTER_TO_UINT(indicator); +} + diff --git a/libindicate/listener.h b/libindicate/listener.h index f931b04..c4e724d 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -54,11 +54,11 @@ G_BEGIN_DECLS #define INDICATE_LISTENER_SIGNAL_SERVER_ADDED "server-added" #define INDICATE_LISTENER_SIGNAL_SERVER_REMOVED "server-removed" -#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) ((gchar *)server) -#define INDICATE_LISTENER_INDICATOR_ID(indicator) (GPOINTER_TO_UINT(indicator)) +#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) (indicate_listener_server_get_dbusname(server)) +#define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator)) -typedef gchar IndicateListenerServer; -typedef guint IndicateListenerIndicator; +typedef struct _IndicateListenerServer IndicateListenerServer; +typedef struct _IndicateListenerIndicator IndicateListenerIndicator; typedef struct _IndicateListener IndicateListener; struct _IndicateListener { @@ -118,7 +118,8 @@ void indicate_listener_server_get_desktop (IndicateListener * l IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data); - +const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server); +guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator); -- cgit v1.2.3 From 589454c1262cfe3b24423036349e762697a3df7f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 13:21:55 -0500 Subject: Switch to searching on the connection, which is really what we care about and the proxy is a poor sustitute for. --- libindicate/listener.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index e54b9b4..f8ce32e 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -54,6 +54,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; struct _IndicateListenerServer { gchar * name; DBusGProxy * proxy; + DBusGConnection * connection; }; struct _IndicateListenerIndicator { @@ -96,7 +97,7 @@ proxy_t_equal (gconstpointer pa, gconstpointer pb) { proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb; - if (a->proxy == b->proxy) { + if (a->connection == b->connection) { return g_strcmp0(a->name, b->name); } else { /* we're only using this for equal, not sorting */ @@ -317,7 +318,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c } if (new != NULL && new[0] == '\0') { proxy_t searchitem; - searchitem.proxy = proxy; + searchitem.connection = bus; searchitem.name = (gchar *)name; /* Droping const, not that it isn't, but to remove the warning */ GList * proxyt_item; @@ -474,6 +475,7 @@ todo_idle (gpointer data) proxyt->connection = todo->bus; proxyt->server.name = todo->name; proxyt->server.proxy = proxyt->proxy; + proxyt->server.connection = proxyt->connection; priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1); @@ -896,7 +898,7 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve proxy_t searchitem; searchitem.name = server->name; - searchitem.proxy = server->proxy; + searchitem.connection = server->connection; GList * proxyitem = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal); if (proxyitem == NULL) { -- cgit v1.2.3 From b76642fa768fd6fb34abc2a02a8bdf548081add7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 14:49:02 -0500 Subject: Getting some interests in the game. --- libindicate/Makefile.am | 6 ++++-- libindicate/interests-priv.h | 46 +++++++++++++++++++++++++++++++++++++++ libindicate/interests.h | 51 ++++++++++++++++++++++++++++++++++++++++++++ libindicate/listener.h | 1 + libindicate/server.c | 1 + libindicate/server.h | 10 ++++++++- 6 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 libindicate/interests-priv.h create mode 100644 libindicate/interests.h (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index 5a6f466..c31fe5b 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -25,7 +25,8 @@ indicate_headers = \ indicator.h \ indicator-message.h \ listener.h \ - server.h + server.h \ + interests.h libindicateinclude_HEADERS = \ $(indicate_headers) @@ -41,7 +42,8 @@ libindicate_la_SOURCES = \ listener-marshal.c \ listener-marshal.h \ indicator.c \ - indicator-message.c + indicator-message.c \ + interestes-priv.h libindicate_la_LDFLAGS = \ -version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \ diff --git a/libindicate/interests-priv.h b/libindicate/interests-priv.h new file mode 100644 index 0000000..eb4e791 --- /dev/null +++ b/libindicate/interests-priv.h @@ -0,0 +1,46 @@ +/* +A library to allow applictions to provide simple indications of +information to be displayed to users of the application through the +interface shell. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#ifndef INDICATE_INTERESTS_PRIV_H_INCLUDED__ +#define INDICATE_INTERESTS_PRIV_H_INCLUDED__ 1 + +#include + +G_BEGIN_DECLS + +#define INDICATE_INTEREST_STRING_SERVER_DISPLAY "server-display" +#define INDICATE_INTEREST_STRING_SERVER_SIGNAL "server-signal" +#define INDICATE_INTEREST_STRING_INDICATOR_DISPLAY "indicator-display" +#define INDICATE_INTEREST_STRING_INDICATOR_SIGNAL "indicator-signal" +#define INDICATE_INTEREST_STRING_INDICATOR_COUNT "indicator-count" + +G_END_DECLS + +#endif /* INDICATE_INTERESTS_PRIV_H_INCLUDED__ */ + diff --git a/libindicate/interests.h b/libindicate/interests.h new file mode 100644 index 0000000..1543075 --- /dev/null +++ b/libindicate/interests.h @@ -0,0 +1,51 @@ +/* +A library to allow applictions to provide simple indications of +information to be displayed to users of the application through the +interface shell. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#ifndef INDICATE_INTERESTS_H_INCLUDED__ +#define INDICATE_INTERESTS_H_INCLUDED__ 1 + +#include + +G_BEGIN_DECLS + +typedef enum _IndicateServerInterests IndicateServerInterests; +enum _IndicateServerInterests { + INDICATE_INTEREST_END, /**< Finishes a list of interests */ + INDICATE_INTEREST_SERVER_DISPLAY, /**< Displays the server's existance to the user */ + INDICATE_INTEREST_SERVER_SIGNAL, /**< Will send signals to the server to be displayed */ + INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */ + INDICATE_INTEREST_INDICATOR_SIGNAL, /**< Will return signals based on individual indicators being responded to */ + INDICATE_INTEREST_INDICATOR_COUNT, /**< Only displays a count of the indicators */ + INDICATE_INTEREST_INDICATOR_LAST /**< Makes merges and counting easier */ +}; + +G_END_DECLS + +#endif /* INDICATE_INTERESTS_H_INCLUDED__ */ + diff --git a/libindicate/listener.h b/libindicate/listener.h index c4e724d..9bd04d6 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -36,6 +36,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "indicator.h" +#include "interests-priv.h" #include "server.h" G_BEGIN_DECLS diff --git a/libindicate/server.c b/libindicate/server.c index 39753d2..ec5d957 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -28,6 +28,7 @@ License version 3 and version 2.1 along with this program. If not, see */ #include "server.h" +#include "interests-priv.h" #include "dbus-indicate-server.h" /* Errors */ diff --git a/libindicate/server.h b/libindicate/server.h index 8aa0cf1..d5ba9a6 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "indicator.h" +#include "interests.h" G_BEGIN_DECLS @@ -53,7 +54,7 @@ G_BEGIN_DECLS #define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" #define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" - +#define INDICATE_SERVER_SIGNAL_LISTENER_INTERESTED "listener-interested" typedef struct _IndicateServer IndicateServer; struct _IndicateServer { @@ -71,6 +72,7 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); + void (* listener_interested) (IndicateServer * server, IndicateServerInterests * interests); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -82,6 +84,12 @@ struct _IndicateServerClass { gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); guint (*get_next_id) (IndicateServer * server); + + /* Reserver for future use */ + void (*indicate_server_reserved1)(void); + void (*indicate_server_reserved2)(void); + void (*indicate_server_reserved3)(void); + void (*indicate_server_reserved4)(void); }; GType indicate_server_get_type (void) G_GNUC_CONST; -- cgit v1.2.3 From 7fea958d9cab987d058f5181bad426084615d8fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 14:50:13 -0500 Subject: Misspelling --- libindicate/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index c31fe5b..aff9ffc 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -43,7 +43,7 @@ libindicate_la_SOURCES = \ listener-marshal.h \ indicator.c \ indicator-message.c \ - interestes-priv.h + interests-priv.h libindicate_la_LDFLAGS = \ -version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \ -- cgit v1.2.3 From bae37d985580c258a0244a0a43bd634e2ecb5dd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 15:23:31 -0500 Subject: Change the API so it's more like we're keeping a list of what, and who are interested in. This'll make it easier for us to manage all the DBus nastyness. --- libindicate/server.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.h b/libindicate/server.h index d5ba9a6..969e280 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -54,7 +54,8 @@ G_BEGIN_DECLS #define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" #define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" -#define INDICATE_SERVER_SIGNAL_LISTENER_INTERESTED "listener-interested" +#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added" +#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed" typedef struct _IndicateServer IndicateServer; struct _IndicateServer { @@ -72,7 +73,8 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); - void (* listener_interested) (IndicateServer * server, IndicateServerInterests * interests); + void (* interest_added) (IndicateServer * server, IndicateServerInterests interest); + void (* interest_removed) (IndicateServer * server, IndicateServerInterests interest); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -119,6 +121,9 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato IndicateServer * indicate_server_ref_default (void); void indicate_server_set_default (IndicateServer * server); +/* Check to see if there is someone, out there, who likes this */ +gboolean indicate_server_check_interest (IndicateServer * server, IndicateServerInterests interest); + /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); -- cgit v1.2.3 From 966a1e53a3544b748d25a4679a8d085bcd916cbd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 15:27:42 -0500 Subject: Adding a remove and show interest --- libindicate/listener.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.h b/libindicate/listener.h index 9bd04d6..9b20070 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -119,10 +119,14 @@ void indicate_listener_server_get_desktop (IndicateListener * l IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data); -const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server); -guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator); - - +const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server); +guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator); +void indicate_listener_server_show_interest (IndicateListener * listener, + IndicateListenerServer * server, + IndicateInterests interest); +void indicate_listener_server_remove_interest (IndicateListener * listener, + IndicateListenerServer * server, + IndicateInterests interest); G_END_DECLS -- cgit v1.2.3 From 58403a8f18f9463ed95446a1ae227fdb97441900 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Apr 2009 15:54:55 -0500 Subject: Adding new functions show_interest and remove_interest into the API. Now to fill in the backend. --- libindicate/indicate-interface.xml | 6 ++++ libindicate/interests.h | 6 ++-- libindicate/server.c | 70 ++++++++++++++++++++++++++++++++++++++ libindicate/server.h | 10 ++++-- 4 files changed, 86 insertions(+), 6 deletions(-) (limited to 'libindicate') diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml index 102df12..9a58f74 100644 --- a/libindicate/indicate-interface.xml +++ b/libindicate/indicate-interface.xml @@ -66,6 +66,12 @@ License version 3 and version 2.1 along with this program. If not, see + + + + + + diff --git a/libindicate/interests.h b/libindicate/interests.h index 1543075..5733199 100644 --- a/libindicate/interests.h +++ b/libindicate/interests.h @@ -34,9 +34,9 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -typedef enum _IndicateServerInterests IndicateServerInterests; -enum _IndicateServerInterests { - INDICATE_INTEREST_END, /**< Finishes a list of interests */ +typedef enum _IndicateInterests IndicateInterests; +enum _IndicateInterests { + INDICATE_INTEREST_NONE, /**< We're of no interest */ INDICATE_INTEREST_SERVER_DISPLAY, /**< Displays the server's existance to the user */ INDICATE_INTEREST_SERVER_SIGNAL, /**< Will send signals to the server to be displayed */ INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */ diff --git a/libindicate/server.c b/libindicate/server.c index ec5d957..bd7c4dd 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -43,6 +43,8 @@ enum { NO_GET_INDICATOR_PROPERTIES, NO_SHOW_INDICATOR_TO_USER, INVALID_INDICATOR_ID, + NO_SHOW_INTEREST, + NO_REMOVE_INTEREST, LAST_ERROR }; @@ -866,6 +868,74 @@ indicate_server_get_next_id (IndicateServer * server) return 0; } +static IndicateInterests +interest_string_to_enum (gchar * interest_string) +{ + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_DISPLAY)) { + return INDICATE_INTEREST_SERVER_DISPLAY; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_SIGNAL)) { + return INDICATE_INTEREST_SERVER_SIGNAL; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_DISPLAY)) { + return INDICATE_INTEREST_INDICATOR_DISPLAY; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_SIGNAL)) { + return INDICATE_INTEREST_INDICATOR_SIGNAL; + } + + if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_COUNT)) { + return INDICATE_INTEREST_INDICATOR_COUNT; + } + + return INDICATE_INTEREST_NONE; +} + +gboolean +indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->show_interest (server, interest_string_to_enum(interest)); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_SHOW_INTEREST, + "show_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + return FALSE; + } + + return TRUE; +} + +gboolean +indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL) { + return class->remove_interest (server, interest_string_to_enum(interest)); + } + + if (error) { + g_set_error(error, + indicate_server_error_quark(), + NO_REMOVE_INTEREST, + "remove_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + return FALSE; + } + + return TRUE; +} + /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type) diff --git a/libindicate/server.h b/libindicate/server.h index 969e280..4d6bbc5 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -73,8 +73,8 @@ struct _IndicateServerClass { void (* server_show) (IndicateServer * server, gchar * type); void (* server_hide) (IndicateServer * server, gchar * type); void (* server_display) (IndicateServer * server); - void (* interest_added) (IndicateServer * server, IndicateServerInterests interest); - void (* interest_removed) (IndicateServer * server, IndicateServerInterests interest); + void (* interest_added) (IndicateServer * server, IndicateInterests interest); + void (* interest_removed) (IndicateServer * server, IndicateInterests interest); /* Virtual Functions */ gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); @@ -86,6 +86,8 @@ struct _IndicateServerClass { gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); guint (*get_next_id) (IndicateServer * server); + gboolean (*show_interest) (IndicateServer * server, IndicateInterests interest); + gboolean (*remove_interest) (IndicateServer * server, IndicateInterests interest); /* Reserver for future use */ void (*indicate_server_reserved1)(void); @@ -122,7 +124,7 @@ IndicateServer * indicate_server_ref_default (void); void indicate_server_set_default (IndicateServer * server); /* Check to see if there is someone, out there, who likes this */ -gboolean indicate_server_check_interest (IndicateServer * server, IndicateServerInterests interest); +gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); /* DBus API */ @@ -134,6 +136,8 @@ gboolean indicate_server_get_indicator_property (IndicateServer * server, guint gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error); +gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error); /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type); -- cgit v1.2.3 From 6e51efbeaceab68fdf66e53c66afe7a94c82d7cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 10:49:35 -0500 Subject: Switching around the show_interest and remove_interest functions so that they are now asyncronous. Not that being asynchronous is important but more that now they get the Method Invocation interface that we can use to find out the sender of the message. Changed various APIs as a result of this, and moved the DBus functions to be internal. --- libindicate/indicate-interface.xml | 2 + libindicate/server.c | 94 ++++++++++++++++++++++++++++---------- libindicate/server.h | 17 ++----- 3 files changed, 74 insertions(+), 39 deletions(-) (limited to 'libindicate') diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml index 9a58f74..900b336 100644 --- a/libindicate/indicate-interface.xml +++ b/libindicate/indicate-interface.xml @@ -67,9 +67,11 @@ License version 3 and version 2.1 along with this program. If not, see + + diff --git a/libindicate/server.c b/libindicate/server.c index bd7c4dd..597bf74 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -29,7 +29,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "server.h" #include "interests-priv.h" -#include "dbus-indicate-server.h" +#include +#include /* Errors */ enum { @@ -45,6 +46,8 @@ enum { INVALID_INDICATOR_ID, NO_SHOW_INTEREST, NO_REMOVE_INTEREST, + SHOW_INTEREST_FAILED, + REMOVE_INTEREST_FAILED, LAST_ERROR }; @@ -106,6 +109,23 @@ static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +/* DBus API */ +gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); +gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); +gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); +gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); +gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); +gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); +gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); + +/* Has to be after the dbus prototypes */ +#include "dbus-indicate-server.h" + + + /* Code */ static void indicate_server_class_init (IndicateServerClass * class) @@ -895,45 +915,69 @@ interest_string_to_enum (gchar * interest_string) } gboolean -indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error) +indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); if (class != NULL) { - return class->show_interest (server, interest_string_to_enum(interest)); - } - - if (error) { - g_set_error(error, - indicate_server_error_quark(), - NO_SHOW_INTEREST, - "show_interest function doesn't exist for this server class: %s", - G_OBJECT_TYPE_NAME(server)); - return FALSE; + if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ + dbus_g_method_return(method); + return TRUE; + } else { + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + SHOW_INTEREST_FAILED, + "Unable to show interest: %s", + interest); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; + } } - return TRUE; + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + NO_SHOW_INTEREST, + "show_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; } gboolean -indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error) +indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); if (class != NULL) { - return class->remove_interest (server, interest_string_to_enum(interest)); - } - - if (error) { - g_set_error(error, - indicate_server_error_quark(), - NO_REMOVE_INTEREST, - "remove_interest function doesn't exist for this server class: %s", - G_OBJECT_TYPE_NAME(server)); - return FALSE; + if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ + dbus_g_method_return(method); + return TRUE; + } else { + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + REMOVE_INTEREST_FAILED, + "Unable to remove interest: %s", + interest); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; + } } - return TRUE; + GError * error; + g_set_error(&error, + indicate_server_error_quark(), + NO_REMOVE_INTEREST, + "remove_interest function doesn't exist for this server class: %s", + G_OBJECT_TYPE_NAME(server)); + dbus_g_method_return_error(method, error); + g_error_free(error); + return FALSE; } /* Signal emission functions for sub-classes of the server */ diff --git a/libindicate/server.h b/libindicate/server.h index 4d6bbc5..0db5bef 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -86,8 +86,9 @@ struct _IndicateServerClass { gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); guint (*get_next_id) (IndicateServer * server); - gboolean (*show_interest) (IndicateServer * server, IndicateInterests interest); - gboolean (*remove_interest) (IndicateServer * server, IndicateInterests interest); + gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); + gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); + gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest); /* Reserver for future use */ void (*indicate_server_reserved1)(void); @@ -127,18 +128,6 @@ void indicate_server_set_default (IndicateServer * server); gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); -/* DBus API */ -gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); -gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); -gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); -gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); -gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); -gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); -gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); -gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, GError ** error); -gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, GError ** error); - /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type); void indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type); -- cgit v1.2.3 From b87476878dde5c5eed23e474073922b65e5f2ff5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:05:35 -0500 Subject: I can't believe I messed up this one. Luckily it doesn't seem to have caused any bugs. Man. --- libindicate/server.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 597bf74..a907dea 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -713,7 +713,7 @@ indicate_server_get_indicator_count (IndicateServer * server, guint * count, GEr { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_count != NULL) { return class->get_indicator_count (server, count, error); } @@ -734,7 +734,7 @@ indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * ty { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_count_by_type != NULL) { return class->get_indicator_count_by_type (server, type, count, error); } @@ -755,7 +755,7 @@ indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicator { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_list != NULL) { return class->get_indicator_list (server, indicators, error); } @@ -776,7 +776,7 @@ indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * typ { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_list_by_type != NULL) { return class->get_indicator_list_by_type (server, type, indicators, error); } @@ -797,7 +797,7 @@ indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_property != NULL) { return class->get_indicator_property (server, id, property, value, error); } @@ -818,7 +818,7 @@ indicate_server_get_indicator_property_group (IndicateServer * server, guint id, { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_property_group != NULL) { return class->get_indicator_property_group (server, id, properties, value, error); } @@ -839,7 +839,7 @@ indicate_server_get_indicator_properties (IndicateServer * server, guint id, gch { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_indicator_properties != NULL) { return class->get_indicator_properties (server, id, properties, error); } @@ -860,7 +860,7 @@ indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GErro { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->show_indicator_to_user != NULL) { return class->show_indicator_to_user (server, id, error); } @@ -881,7 +881,7 @@ indicate_server_get_next_id (IndicateServer * server) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->get_next_id != NULL) { return class->get_next_id (server); } @@ -919,7 +919,7 @@ indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGM { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->show_interest != NULL) { if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ dbus_g_method_return(method); return TRUE; @@ -952,7 +952,7 @@ indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBus { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); - if (class != NULL) { + if (class != NULL && class->remove_interest != NULL) { if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){ dbus_g_method_return(method); return TRUE; -- cgit v1.2.3 From 5ebb3c4f87cf9965183c055d52193e656c59193b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:11:20 -0500 Subject: Woot! Now we have some real functions to call! --- libindicate/server.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index a907dea..e11a4a3 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -108,6 +108,9 @@ static gboolean show_indicator_to_user (IndicateServer * server, guint id, GErro static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); +static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); +static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -206,6 +209,9 @@ indicate_server_class_init (IndicateServerClass * class) class->get_indicator_properties = get_indicator_properties; class->show_indicator_to_user = show_indicator_to_user; class->get_next_id = get_next_id; + class->show_interest = show_interest; + class->remove_interest = remove_interest; + class->check_interest = check_interest; return; } @@ -362,6 +368,29 @@ get_next_id (IndicateServer * server) return priv->current_id; } +static gboolean +show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) +{ + + + return FALSE; +} + +static gboolean +remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) +{ + + return FALSE; +} + +static gboolean +check_interest (IndicateServer * server, IndicateInterests intrest) +{ + + + return FALSE; +} + static void indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server) { -- cgit v1.2.3 From 1212c8e00290669f251067fb22ccf7f16f4719df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 11:34:56 -0500 Subject: Adding the interest removed and interest added signals in. --- libindicate/server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index e11a4a3..e560ba8 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -59,6 +59,8 @@ enum { SERVER_SHOW, SERVER_HIDE, SERVER_DISPLAY, + INTEREST_ADDED, + INTEREST_REMOVED, LAST_SIGNAL }; @@ -185,6 +187,20 @@ indicate_server_class_init (IndicateServerClass * class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[INTEREST_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_ADDED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicateServerClass, interest_added), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); + signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicateServerClass, interest_removed), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); g_object_class_install_property (gobj, PROP_DESKTOP, g_param_spec_string("desktop", "Desktop File", -- cgit v1.2.3 From f94b485955374f9ef6c4cb8521f610711edf54ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 13:34:40 -0500 Subject: Adding in folks support. --- libindicate/interests.h | 2 +- libindicate/server.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/interests.h b/libindicate/interests.h index 5733199..70c52d9 100644 --- a/libindicate/interests.h +++ b/libindicate/interests.h @@ -42,7 +42,7 @@ enum _IndicateInterests { INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */ INDICATE_INTEREST_INDICATOR_SIGNAL, /**< Will return signals based on individual indicators being responded to */ INDICATE_INTEREST_INDICATOR_COUNT, /**< Only displays a count of the indicators */ - INDICATE_INTEREST_INDICATOR_LAST /**< Makes merges and counting easier */ + INDICATE_INTEREST_LAST /**< Makes merges and counting easier */ }; G_END_DECLS diff --git a/libindicate/server.c b/libindicate/server.c index e560ba8..3a8907c 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -88,11 +88,20 @@ struct _IndicateServerPrivate // TODO: Should have a more robust way to track this, but this'll work for now guint num_hidden; + + gboolean interests[INDICATE_INTEREST_LAST]; + GList * interestedfolks; }; #define INDICATE_SERVER_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_SERVER, IndicateServerPrivate)) +typedef struct _IndicateServerInterestedFolk IndicateServerInterestedFolk; +struct _IndicateServerInterestedFolk { + gchar * sender; + gboolean interests[INDICATE_INTEREST_LAST]; +}; + /* Define Type */ G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT); @@ -113,6 +122,10 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); +static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b); +static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk); +static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value); +static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -247,6 +260,13 @@ indicate_server_init (IndicateServer * server) priv->type = NULL; priv->desktop = NULL; + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + priv->interestedfolks = NULL; + + return; } @@ -1060,3 +1080,45 @@ indicate_server_emit_server_display (IndicateServer *server) g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE); } + +/* *** Folks stuff *** */ + +static gint +indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b) +{ + return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender); +} + +static void +indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk) +{ + folk->sender = NULL; + + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + folk->interests[i] = FALSE; + } + + return; +} + +static void +indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value) +{ + folk->interests[interest] = value; + return; +} + +static void +indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests) +{ + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (folk->interests[i]) { + interests[i] = TRUE; + } + } + + return; +} +/* *** End Folks *** */ -- cgit v1.2.3 From 6e4299654841510621000077ebd71423db03cde3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 14:08:55 -0500 Subject: Fleshing out the interest setting and removing functions. --- libindicate/server.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 5 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 3a8907c..a121984 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -407,24 +407,75 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + IndicateServerInterestedFolk localfolk; + localfolk.sender = sender; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); - return FALSE; + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); + IndicateServerInterestedFolk * folkpointer = NULL; + if (entry == NULL) { + folkpointer = g_new(IndicateServerInterestedFolk, 1); + indicate_server_interested_folks_init(folkpointer); + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); + } else { + folkpointer = (IndicateServerInterestedFolk *)entry->data; + } + + indicate_server_interested_folk_set(folkpointer, interest, TRUE); + if (!priv->interests[interest]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_ADDED], 0, interest, TRUE); + priv->interests[interest] = TRUE; + } + + return TRUE; } static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + IndicateServerInterestedFolk localfolk; + localfolk.sender = sender; - return FALSE; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); + IndicateServerInterestedFolk * folkpointer = NULL; + if (entry == NULL) { + folkpointer = g_new(IndicateServerInterestedFolk, 1); + indicate_server_interested_folks_init(folkpointer); + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); + } else { + folkpointer = (IndicateServerInterestedFolk *)entry->data; + } + + indicate_server_interested_folk_set(folkpointer, interest, FALSE); + + if (priv->interests[interest]) { + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + + GList * listi = NULL; + for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { + folkpointer = (IndicateServerInterestedFolk *)listi->data; + inkscape_server_interested_folk_copy(folkpointer, priv->interests); + } + + if (!priv->interests[interest]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, interest, TRUE); + } + } + + return TRUE; } static gboolean check_interest (IndicateServer * server, IndicateInterests intrest) { - - - return FALSE; + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + return priv->interests[interest]; } static void -- cgit v1.2.3 From 26bfe1c6a952952d404130f783e7399cb28e496f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 15:23:10 -0500 Subject: Connecting in the DBus messaging that we need. --- libindicate/server.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index a121984..0dba9fa 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -78,6 +78,8 @@ typedef struct _IndicateServerPrivate IndicateServerPrivate; struct _IndicateServerPrivate { DBusGConnection *connection; + DBusGProxy * dbus_proxy; + gchar * path; GSList * indicators; gboolean visible; @@ -116,6 +118,7 @@ static gboolean get_indicator_property (IndicateServer * server, guint id, gchar static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server); static guint get_next_id (IndicateServer * server); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); @@ -373,6 +376,17 @@ indicate_server_show (IndicateServer * server) priv->visible = TRUE; g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE); + + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + NULL); + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_owner_change), server, NULL); return; } @@ -388,14 +402,36 @@ indicate_server_hide (IndicateServer * server) priv->visible = FALSE; + /* Delete interested parties */ + g_list_foreach(priv->interestedfolks, (GFunc)g_free, NULL); + g_list_free(priv->interestedfolks); + priv->interestedfolks = NULL; + + /* Signal the lack of interest */ + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (priv->interests[i]) { + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); + } + priv->interests[i] = FALSE; + } + g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE); + g_object_unref(G_OBJECT(priv->dbus_proxy)); dbus_g_connection_unref (priv->connection); priv->connection = NULL; return; } +static void +dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) +{ + + +} + static guint get_next_id (IndicateServer * server) { @@ -422,7 +458,7 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere folkpointer = (IndicateServerInterestedFolk *)entry->data; } - indicate_server_interested_folk_set(folkpointer, interest, TRUE); + indicate_server_interested_folks_set(folkpointer, interest, TRUE); if (!priv->interests[interest]) { g_signal_emit(G_OBJECT(server), signals[INTEREST_ADDED], 0, interest, TRUE); priv->interests[interest] = TRUE; @@ -449,7 +485,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte folkpointer = (IndicateServerInterestedFolk *)entry->data; } - indicate_server_interested_folk_set(folkpointer, interest, FALSE); + indicate_server_interested_folks_set(folkpointer, interest, FALSE); if (priv->interests[interest]) { guint i; @@ -460,7 +496,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { folkpointer = (IndicateServerInterestedFolk *)listi->data; - inkscape_server_interested_folk_copy(folkpointer, priv->interests); + indicate_server_interested_folks_copy(folkpointer, priv->interests); } if (!priv->interests[interest]) { @@ -472,7 +508,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte } static gboolean -check_interest (IndicateServer * server, IndicateInterests intrest) +check_interest (IndicateServer * server, IndicateInterests interest) { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); return priv->interests[interest]; -- cgit v1.2.3 From 682684874b40d4a18ae0ebec29e4d42c5184501e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:12:19 -0500 Subject: Filling in the dbus owner changing code. Now we should catch those. --- libindicate/server.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 0dba9fa..ca3257b 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -428,8 +428,46 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { + if (prev != NULL) { + /* We only care about people leaving the bus */ + return; + } + + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + + IndicateServerInterestedFolk searchitem; + searchitem.sender = (gchar *)name; + GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); + + if (entry == NULL) { + return; + } + IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data; + priv->interestedfolks = g_list_remove(priv->interestedfolks, entry); + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + priv->interests[i] = FALSE; + } + + GList * listi = NULL; + for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { + IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; + indicate_server_interested_folks_copy(folkpointer, priv->interests); + } + + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (folk->interests[i] != priv->interests[i]) { + /* We can only remove interest here. Think about it for a + moment and I think you'll be cool with it. */ + g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); + } + } + + g_free(folk); + + return; } static guint -- cgit v1.2.3 From 5c9e92e513666fcffea8841d5b5005953c7f7d37 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:35:38 -0500 Subject: Adding a bunch of debugging messages and fixing the lifecycle for the folk pointer. Lots'o'fun. But things seem to be working. --- libindicate/server.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index ca3257b..4346ae0 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -126,9 +126,10 @@ static gboolean show_interest (IndicateServer * server, gchar * sender, Indicate static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b); -static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk); +static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender); static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value); static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests); +static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk); /* DBus API */ gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); @@ -403,7 +404,7 @@ indicate_server_hide (IndicateServer * server) priv->visible = FALSE; /* Delete interested parties */ - g_list_foreach(priv->interestedfolks, (GFunc)g_free, NULL); + g_list_foreach(priv->interestedfolks, (GFunc)indicate_server_interested_folks_destroy, NULL); g_list_free(priv->interestedfolks); priv->interestedfolks = NULL; @@ -428,11 +429,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - if (prev != NULL) { + g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } + g_debug("\tBeing removed, interesting"); IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -440,11 +443,12 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { + g_debug("\tWe don't have it, not interesting"); return; } IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data; - priv->interestedfolks = g_list_remove(priv->interestedfolks, entry); + priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data); guint i; for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { @@ -454,13 +458,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; + g_debug("\tRebuild list from folk: %s", folkpointer->sender); indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); if (folk->interests[i] != priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ + g_debug("\tOh, and it was interested in %d. Not anymore.", i); g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } @@ -481,6 +488,7 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + g_debug("Someone is showing interest. %s in %d", sender, interest); IndicateServerInterestedFolk localfolk; localfolk.sender = sender; @@ -490,7 +498,7 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere IndicateServerInterestedFolk * folkpointer = NULL; if (entry == NULL) { folkpointer = g_new(IndicateServerInterestedFolk, 1); - indicate_server_interested_folks_init(folkpointer); + indicate_server_interested_folks_init(folkpointer, sender); priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); } else { folkpointer = (IndicateServerInterestedFolk *)entry->data; @@ -517,7 +525,7 @@ remove_interest (IndicateServer * server, gchar * sender, IndicateInterests inte IndicateServerInterestedFolk * folkpointer = NULL; if (entry == NULL) { folkpointer = g_new(IndicateServerInterestedFolk, 1); - indicate_server_interested_folks_init(folkpointer); + indicate_server_interested_folks_init(folkpointer, sender); priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); } else { folkpointer = (IndicateServerInterestedFolk *)entry->data; @@ -1215,9 +1223,9 @@ indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b) } static void -indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk) +indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender) { - folk->sender = NULL; + folk->sender = g_strdup(sender); guint i; for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { @@ -1246,4 +1254,12 @@ indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboo return; } + +static void +indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk) +{ + g_free(folk->sender); + g_free(folk); + return; +} /* *** End Folks *** */ -- cgit v1.2.3 From 2f66ceb474f6d42368873742c99100b8c4ef62d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:36:27 -0500 Subject: Hiding debug --- libindicate/server.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 4346ae0..4e47040 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -429,13 +429,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - g_debug("\tBeing removed, interesting"); + /* g_debug("\tBeing removed, interesting"); */ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -443,7 +443,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - g_debug("\tWe don't have it, not interesting"); + /* g_debug("\tWe don't have it, not interesting"); */ return; } @@ -458,16 +458,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - g_debug("\tRebuild list from folk: %s", folkpointer->sender); + /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ if (folk->interests[i] != priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - g_debug("\tOh, and it was interested in %d. Not anymore.", i); + /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } @@ -488,7 +488,7 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { - g_debug("Someone is showing interest. %s in %d", sender, interest); + /* g_debug("Someone is showing interest. %s in %d", sender, interest); */ IndicateServerInterestedFolk localfolk; localfolk.sender = sender; -- cgit v1.2.3 From 68fb067b6dc1a2153205ec8b210813a610d66d24 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Apr 2009 16:38:47 -0500 Subject: Putting in some protection from crazy values --- libindicate/server.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 4e47040..e6041de 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -488,6 +488,10 @@ get_next_id (IndicateServer * server) static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) { + return FALSE; + } + /* g_debug("Someone is showing interest. %s in %d", sender, interest); */ IndicateServerInterestedFolk localfolk; localfolk.sender = sender; @@ -516,6 +520,10 @@ show_interest (IndicateServer * server, gchar * sender, IndicateInterests intere static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) { + if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) { + return FALSE; + } + IndicateServerInterestedFolk localfolk; localfolk.sender = sender; -- cgit v1.2.3 From 96c188390cec3abfbaf078cd4bf69f18e8c2bc27 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 10:22:20 -0500 Subject: Fleshing out the functions in the listener to set interests. --- libindicate/listener.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++- libindicate/listener.h | 4 +++- 2 files changed, 60 insertions(+), 2 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index f8ce32e..858c63b 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -55,6 +55,7 @@ struct _IndicateListenerServer { gchar * name; DBusGProxy * proxy; DBusGConnection * connection; + gboolean interests[INDICATE_INTEREST_LAST]; }; struct _IndicateListenerIndicator { @@ -462,7 +463,7 @@ todo_idle (gpointer data) proxy_todo_t * todo = &g_array_index(priv->proxy_todo, proxy_todo_t, priv->proxy_todo->len - 1); - proxy_t * proxyt = g_new(proxy_t, 1); + proxy_t * proxyt = g_new0(proxy_t, 1); proxyt->name = todo->name; proxyt->type = NULL; proxyt->proxy = dbus_g_proxy_new_for_name(todo->bus, @@ -961,3 +962,58 @@ indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator) return GPOINTER_TO_UINT(indicator); } +static const gchar * +interest_to_string (IndicateInterests interest) +{ + switch (interest) { + case INDICATE_INTEREST_SERVER_DISPLAY: + return INDICATE_INTEREST_STRING_SERVER_DISPLAY; + case INDICATE_INTEREST_SERVER_SIGNAL: + return INDICATE_INTEREST_STRING_SERVER_SIGNAL; + case INDICATE_INTEREST_INDICATOR_DISPLAY: + return INDICATE_INTEREST_STRING_INDICATOR_DISPLAY; + case INDICATE_INTEREST_INDICATOR_SIGNAL: + return INDICATE_INTEREST_STRING_INDICATOR_SIGNAL; + case INDICATE_INTEREST_INDICATOR_COUNT: + return INDICATE_INTEREST_STRING_INDICATOR_COUNT; + default: + return ""; + } +} + +static void +interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to configure interest on server %s because: %s", ((IndicateListenerServer *)userdata)->name, error->message); + } + + return; +} + +void +indicate_listener_server_show_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + if (!server->interests[interest]) { + org_freedesktop_indicator_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server); + server->interests[interest] = TRUE; + } + return; +} + +void +indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + if (server->interests[interest]) { + org_freedesktop_indicator_remove_interest_async (server->proxy, interest_to_string(interest), interest_cb, server); + server->interests[interest] = FALSE; + } + return; +} + +gboolean +indicate_listener_server_check_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + return server->interests[interest]; +} + diff --git a/libindicate/listener.h b/libindicate/listener.h index 9b20070..f9bb6bb 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -127,7 +127,9 @@ void indicate_listener_server_show_interest (IndicateListen void indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest); - +gboolean indicate_listener_server_check_interest (IndicateListener * listener, + IndicateListenerServer * server, + IndicateInterests interest); G_END_DECLS -- cgit v1.2.3 From 303c52b3167cd943a2a84e55f562c39daf1e4d6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 11:28:44 -0500 Subject: Cleaning up the exported symbols, make sure that 'get_type_cb' isn't exported --- libindicate/listener.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index 858c63b..da2aa9f 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -121,7 +121,7 @@ static void proxy_struct_destroy (gpointer data); static void build_todo_list_cb (DBusGProxy * proxy, char ** names, GError * error, void * data); static void todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener, gboolean startup); static gboolean todo_idle (gpointer data); -void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); +static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt); static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); static void proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); @@ -503,7 +503,7 @@ todo_idle (gpointer data) return TRUE; } -void +static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { if (type == NULL) { -- cgit v1.2.3 From be4c00257d32c9d26407f10384ef78837b2c1fe0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 11:32:35 -0500 Subject: Hiding the marshsallers from the libraries in the symbols by adding a _ in front of them. --- libindicate/Makefile.am | 4 ++-- libindicate/listener.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index aff9ffc..f48ad1f 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -86,12 +86,12 @@ dbus-listener-client.h: indicate-listener.xml listener-marshal.h: $(srcdir)/listener-marshal.list glib-genmarshal --header \ - --prefix=indicate_listener_marshal $(srcdir)/listener-marshal.list \ + --prefix=_indicate_listener_marshal $(srcdir)/listener-marshal.list \ > listener-marshal.h listener-marshal.c: $(srcdir)/listener-marshal.list glib-genmarshal --body \ - --prefix=indicate_listener_marshal $(srcdir)/listener-marshal.list \ + --prefix=_indicate_listener_marshal $(srcdir)/listener-marshal.list \ > listener-marshal.c pkgconfig_DATA = indicate.pc diff --git a/libindicate/listener.c b/libindicate/listener.c index da2aa9f..92cb2da 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -147,38 +147,38 @@ indicate_listener_class_init (IndicateListenerClass * class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_added), NULL, NULL, - indicate_listener_marshal_VOID__POINTER_POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed), NULL, NULL, - indicate_listener_marshal_VOID__POINTER_POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified), NULL, NULL, - indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_added), NULL, NULL, - indicate_listener_marshal_VOID__POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_STRING, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); signals[SERVER_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_removed), NULL, NULL, - indicate_listener_marshal_VOID__POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_STRING, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); - dbus_g_object_register_marshaller(indicate_listener_marshal_VOID__UINT_STRING, + dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, -- cgit v1.2.3 From eb5078b8f0a60ef5d213ce84b3f1e67f615bd87e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 12:14:07 -0500 Subject: Getting rid of everything starting with 'd'. This gets rid of the dbus stuff that isn't set up to be static, which is silly. --- libindicate/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index f48ad1f..e594649 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -48,7 +48,7 @@ libindicate_la_SOURCES = \ libindicate_la_LDFLAGS = \ -version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \ -no-undefined \ - -export-symbols-regex "^[^_].*" + -export-symbols-regex "^[^_d].*" libindicate_la_CFLAGS = \ $(LIBINDICATE_CFLAGS) -- cgit v1.2.3 From d93da3d5d79786e5402a8d70a30468e95e82d55b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 12:27:31 -0500 Subject: Hiding all of the functions that part of the DBus interface in that now they're all prefixed with '_' so that they don't get exported as part of the library symbols. This should simplify everything a little bit for implementors. --- libindicate/Makefile.am | 8 ++++---- libindicate/listener.c | 9 +++++++-- libindicate/listener.h | 1 - libindicate/server.c | 42 +++++++++++++++++++++--------------------- 4 files changed, 32 insertions(+), 28 deletions(-) (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index e594649..c1900a6 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -58,28 +58,28 @@ libindicate_la_LIBADD = \ dbus-indicate-server.h: indicate-interface.xml dbus-binding-tool \ - --prefix=indicate_server \ + --prefix=_indicate_server \ --mode=glib-server \ --output=dbus-indicate-server.h \ $(srcdir)/indicate-interface.xml dbus-indicate-client.h: indicate-interface.xml dbus-binding-tool \ - --prefix=indicate_client \ + --prefix=_indicate_client \ --mode=glib-client \ --output=dbus-indicate-client.h \ $(srcdir)/indicate-interface.xml dbus-listener-server.h: indicate-listener.xml dbus-binding-tool \ - --prefix=indicate_listener \ + --prefix=_indicate_listener \ --mode=glib-server \ --output=dbus-listener-server.h \ $(srcdir)/indicate-listener.xml dbus-listener-client.h: indicate-listener.xml dbus-binding-tool \ - --prefix=indicate_listener \ + --prefix=_indicate_listener \ --mode=glib-client \ --output=dbus-listener-client.h \ $(srcdir)/indicate-listener.xml diff --git a/libindicate/listener.c b/libindicate/listener.c index 92cb2da..0796bf1 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -32,7 +32,6 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "dbus-indicate-client.h" #include "dbus-listener-client.h" -#include "dbus-listener-server.h" /* Errors */ enum { @@ -130,6 +129,12 @@ static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, G static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data); static void proxy_indicators_free (gpointer data); +/* DBus interface */ +gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); + +/* Need the above prototypes */ +#include "dbus-listener-server.h" + /* Code */ static void indicate_listener_class_init (IndicateListenerClass * class) @@ -824,7 +829,7 @@ indicate_listener_get_property_icon (IndicateListener * listener, IndicateListen } gboolean -indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers) +_indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers) { diff --git a/libindicate/listener.h b/libindicate/listener.h index f9bb6bb..3b05f86 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -110,7 +110,6 @@ void indicate_listener_get_property_icon (IndicateListener * l void indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator); -gboolean indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); void indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, diff --git a/libindicate/server.c b/libindicate/server.c index e6041de..004c386 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -132,16 +132,16 @@ static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk); /* DBus API */ -gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); -gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); -gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); -gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); -gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); -gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); -gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); -gboolean indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); -gboolean indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); +gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); +gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); +gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); +gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); +gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); +gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); +gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); /* Has to be after the dbus prototypes */ #include "dbus-indicate-server.h" @@ -231,7 +231,7 @@ indicate_server_class_init (IndicateServerClass * class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); dbus_g_object_type_install_info(INDICATE_TYPE_SERVER, - &dbus_glib_indicate_server_object_info); + &dbus_glib__indicate_server_object_info); class->get_indicator_count = get_indicator_count; class->get_indicator_count_by_type = get_indicator_count_by_type; @@ -915,7 +915,7 @@ show_indicator_to_user (IndicateServer * server, guint id, GError ** error) /* Virtual Functions */ gboolean -indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error) +_indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -936,7 +936,7 @@ indicate_server_get_indicator_count (IndicateServer * server, guint * count, GEr } gboolean -indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) +_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -957,7 +957,7 @@ indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * ty } gboolean -indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) +_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -978,7 +978,7 @@ indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicator } gboolean -indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -999,7 +999,7 @@ indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * typ } gboolean -indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) +_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1020,7 +1020,7 @@ indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar } gboolean -indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error) +_indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1041,7 +1041,7 @@ indicate_server_get_indicator_property_group (IndicateServer * server, guint id, } gboolean -indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) +_indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1062,7 +1062,7 @@ indicate_server_get_indicator_properties (IndicateServer * server, guint id, gch } gboolean -indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error) +_indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1121,7 +1121,7 @@ interest_string_to_enum (gchar * interest_string) } gboolean -indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) +_indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); @@ -1154,7 +1154,7 @@ indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGM } gboolean -indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) +_indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); -- cgit v1.2.3 From 06dd63a32f54e72796baa64a28438b5d839ccff2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Apr 2009 15:09:06 -0500 Subject: Moving private interests out of the public header file. --- libindicate/listener.c | 1 + libindicate/listener.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index 0796bf1..74cf960 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -32,6 +32,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "dbus-indicate-client.h" #include "dbus-listener-client.h" +#include "interests-priv.h" /* Errors */ enum { diff --git a/libindicate/listener.h b/libindicate/listener.h index 3b05f86..0fdaa9b 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -36,8 +36,8 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "indicator.h" -#include "interests-priv.h" #include "server.h" +#include "interests.h" G_BEGIN_DECLS -- cgit v1.2.3 From 42492db6a41dc304820d744470f86644765b0aa9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Apr 2009 21:42:16 -0500 Subject: * Some debug messages * Making the comparison of interests detect changings properly * Correctly use g_list_remove in several cases making for long lists * Using g_list_prepend instead of append because it's faster. * Checking whether we've got proxies before destroying them. --- libindicate/listener.c | 15 ++++++++------- libindicate/server.c | 26 ++++++++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index 74cf960..e4fe68f 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -332,12 +332,12 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c proxyt_item = g_list_find_custom(priv->proxies_working, &searchitem, proxy_t_equal); if (proxyt_item != NULL) { proxy_struct_destroy((proxy_t *)proxyt_item->data); - priv->proxies_working = g_list_remove(priv->proxies_working, proxyt_item); + priv->proxies_working = g_list_remove(priv->proxies_working, proxyt_item->data); } proxyt_item = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal); if (proxyt_item != NULL) { proxy_struct_destroy((proxy_t *)proxyt_item->data); - priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item); + priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item->data); } } @@ -379,11 +379,11 @@ proxy_struct_destroy (gpointer data) proxy_data->indicators = NULL; } - if (proxy_data->property_proxy) { + if (DBUS_IS_G_PROXY(proxy_data->property_proxy)) { g_object_unref(G_OBJECT(proxy_data->property_proxy)); } - if (proxy_data->proxy) { + if (DBUS_IS_G_PROXY(proxy_data->proxy)) { g_object_unref(G_OBJECT(proxy_data->proxy)); } @@ -496,7 +496,7 @@ todo_idle (gpointer data) dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow", G_CALLBACK(proxy_server_added), proxyt, NULL); - priv->proxies_possible = g_list_append(priv->proxies_possible, proxyt); + priv->proxies_possible = g_list_prepend(priv->proxies_possible, proxyt); /* I think that we need to have this as there is a race * condition here. If someone comes on the bus and we get @@ -581,9 +581,9 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt) GList * proxyt_item; proxyt_item = g_list_find_custom(priv->proxies_possible, proxyt, proxy_t_equal); if (proxyt_item != NULL) { - priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item); + priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item->data); } - priv->proxies_working = g_list_append(priv->proxies_working, proxyt); + priv->proxies_working = g_list_prepend(priv->proxies_working, proxyt); dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); @@ -959,6 +959,7 @@ indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListe const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server) { + if (server == NULL) return NULL; return server->name; } diff --git a/libindicate/server.c b/libindicate/server.c index 004c386..520d47c 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -419,9 +419,15 @@ indicate_server_hide (IndicateServer * server) g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE); - g_object_unref(G_OBJECT(priv->dbus_proxy)); - dbus_g_connection_unref (priv->connection); - priv->connection = NULL; + if (priv->dbus_proxy != NULL) { + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } + + if (priv->connection != NULL) { + dbus_g_connection_unref (priv->connection); + priv->connection = NULL; + } return; } @@ -429,13 +435,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ + g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - /* g_debug("\tBeing removed, interesting"); */ + g_debug("\tBeing removed, interesting"); IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -443,7 +449,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - /* g_debug("\tWe don't have it, not interesting"); */ + g_debug("\tWe don't have it, not interesting"); return; } @@ -458,16 +464,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ + g_debug("\tRebuild list from folk: %s", folkpointer->sender); indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ - if (folk->interests[i] != priv->interests[i]) { + g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + if (folk->interests[i] && !priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ + g_debug("\tOh, and it was interested in %d. Not anymore.", i); g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } -- cgit v1.2.3 From 9bd1519eb45e506840a633711f43090c9d833e33 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 10:14:00 -0500 Subject: Simplifying error message --- libindicate/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index e4fe68f..381a5f9 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -992,7 +992,7 @@ static void interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata) { if (error != NULL) { - g_warning("Unable to configure interest on server %s because: %s", ((IndicateListenerServer *)userdata)->name, error->message); + g_warning("Unable to configure interest."); } return; -- cgit v1.2.3 From 912a2a1a79b9c5eaa3442a7945d8f9390dd2d522 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 10:15:39 -0500 Subject: Hiding some debugging messages. --- libindicate/server.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 520d47c..ed81d54 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -435,13 +435,13 @@ indicate_server_hide (IndicateServer * server) static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) { - g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); + /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */ if (prev == NULL || prev[0] == '\0') { /* We only care about people leaving the bus */ return; } - g_debug("\tBeing removed, interesting"); + /* g_debug("\tBeing removed, interesting"); */ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); IndicateServerInterestedFolk searchitem; @@ -449,7 +449,7 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal); if (entry == NULL) { - g_debug("\tWe don't have it, not interesting"); + /* g_debug("\tWe don't have it, not interesting"); */ return; } @@ -464,16 +464,16 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c GList * listi = NULL; for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) { IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data; - g_debug("\tRebuild list from folk: %s", folkpointer->sender); + /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */ indicate_server_interested_folks_copy(folkpointer, priv->interests); } for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { - g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); + /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */ if (folk->interests[i] && !priv->interests[i]) { /* We can only remove interest here. Think about it for a moment and I think you'll be cool with it. */ - g_debug("\tOh, and it was interested in %d. Not anymore.", i); + /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE); } } -- cgit v1.2.3 From 3e1e51261167c74fa81819cebaafce944e14b310 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 17:40:25 -0500 Subject: Making it so that we don't register the object twice. This is really a work around, but it's atleast fixes the crasher. Which sucked. We need to work with the dbus folks to make this better. --- libindicate/server.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index ed81d54..1be8ee5 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -84,6 +84,7 @@ struct _IndicateServerPrivate GSList * indicators; gboolean visible; guint current_id; + gboolean registered; gchar * desktop; gchar * type; @@ -260,6 +261,7 @@ indicate_server_init (IndicateServer * server) priv->indicators = NULL; priv->num_hidden = 0; priv->visible = FALSE; + priv->registered = FALSE; priv->current_id = 0; priv->type = NULL; priv->desktop = NULL; @@ -371,9 +373,13 @@ indicate_server_show (IndicateServer * server) priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(priv->connection, - priv->path, - G_OBJECT(server)); + if (!priv->registered) { + dbus_g_connection_register_g_object(priv->connection, + priv->path, + G_OBJECT(server)); + priv->registered = TRUE; + } + priv->visible = TRUE; g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE); -- cgit v1.2.3 From eba8697a790029397d771a3871f431abc4fc0029 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 20:52:05 -0500 Subject: Patch from Eitan Isaacson to remove a ref/unref infinite loop that effectively made it so that we kept our objects forever. While we love them, at some point we need to say goodbye. --- libindicate/server.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index 1be8ee5..e5bf731 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -610,8 +610,10 @@ indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indi { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); - g_object_ref(indicator); - priv->indicators = g_slist_prepend(priv->indicators, indicator); + if (g_slist_find (priv->indicators, indicator) != NULL) + return; + + priv->indicators = g_slist_prepend(priv->indicators, indicator); if (!indicate_indicator_is_visible(indicator)) { priv->num_hidden++; @@ -631,6 +633,9 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i { IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); + if (g_slist_find (priv->indicators, indicator) == NULL) + return; + priv->indicators = g_slist_remove(priv->indicators, indicator); if (indicate_indicator_is_visible(indicator)) { g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); @@ -642,7 +647,6 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server); g_signal_handlers_disconnect_by_func(indicator, indicator_modified_cb, server); - g_object_unref(indicator); return; } -- cgit v1.2.3 From 9a7bcf39b419f9ac30eb44c14e5f7f17a34cc15b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:08:27 -0500 Subject: Patch from Eitan Isaacson to correct prototype. Had to be adjusted slightly as the prototypes had moved. --- libindicate/server.c | 8 ++++---- libindicate/server.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libindicate') diff --git a/libindicate/server.c b/libindicate/server.c index e5bf731..9e33516 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -114,7 +114,7 @@ static void indicate_server_finalize (GObject * obj); static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error); static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -136,7 +136,7 @@ static void indicate_server_interested_folks_destroy(IndicateServerInterestedFol gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); -gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); +gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); @@ -798,7 +798,7 @@ get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** err } static gboolean -get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); @@ -994,7 +994,7 @@ _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicato } gboolean -_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error) +_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) { IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); diff --git a/libindicate/server.h b/libindicate/server.h index 0db5bef..cfb4334 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -80,7 +80,7 @@ struct _IndicateServerClass { gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error); gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error); - gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, guint ** indicators, GError ** error); + gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); -- cgit v1.2.3 From 75002ffd6068873af92d3f8f2c687415f0325e1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 7 Apr 2009 21:13:07 -0500 Subject: Clearing another warning. Shame gdk doesn't do this one for us. --- libindicate/indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicate') diff --git a/libindicate/indicator.c b/libindicate/indicator.c index e4bae76..9427d03 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -249,7 +249,7 @@ indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar gchar * png_data; gsize png_data_len; - if (!gdk_pixbuf_save_to_buffer(data, &png_data, &png_data_len, "png", &error, NULL)) { + if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) { if (error == NULL) { g_warning("Unable to create pixbuf data stream: %d", png_data_len); } else { -- cgit v1.2.3