aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-04-06 21:42:16 -0500
committerTed Gould <ted@canonical.com>2009-04-06 21:42:16 -0500
commit42492db6a41dc304820d744470f86644765b0aa9 (patch)
tree2c2f211673aef2f17b72457a364088427eaf3919 /libindicate
parent06dd63a32f54e72796baa64a28438b5d839ccff2 (diff)
downloadlibayatana-indicator-42492db6a41dc304820d744470f86644765b0aa9.tar.gz
libayatana-indicator-42492db6a41dc304820d744470f86644765b0aa9.tar.bz2
libayatana-indicator-42492db6a41dc304820d744470f86644765b0aa9.zip
* 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.
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/listener.c15
-rw-r--r--libindicate/server.c26
2 files changed, 24 insertions, 17 deletions
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);
}
}