aboutsummaryrefslogtreecommitdiff
path: root/libindicate/listener.c
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate/listener.c')
-rw-r--r--libindicate/listener.c94
1 files changed, 15 insertions, 79 deletions
diff --git a/libindicate/listener.c b/libindicate/listener.c
index bd3639d..48ad616 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -54,35 +54,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-struct _IndicateListenerServer {
- gchar * name;
- DBusGProxy * proxy;
- DBusGConnection * connection;
- gboolean interests[INDICATE_INTEREST_LAST];
-};
-
-struct _IndicateListenerIndicator {
- guint id;
-};
-
-typedef struct _IndicateListenerPrivate IndicateListenerPrivate;
-struct _IndicateListenerPrivate
-{
- DBusGConnection * session_bus;
- DBusGConnection * system_bus;
-
- DBusGProxy * dbus_proxy_session;
- DBusGProxy * dbus_proxy_system;
-
- GList * proxies_working;
- GList * proxies_possible;
-
- GArray * proxy_todo;
- guint todo_idle;
-};
-
-#define INDICATE_LISTENER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_LISTENER, IndicateListenerPrivate))
+#include "listener-private.h"
typedef struct {
DBusGProxy * proxy;
@@ -277,8 +249,19 @@ indicate_listener_init (IndicateListener * listener)
static void
indicate_listener_finalize (GObject * obj)
{
- /* IndicateListener * listener = INDICATE_LISTENER(obj); */
-
+ IndicateListener * listener = INDICATE_LISTENER(obj);
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
+
+ if (priv->todo_idle != 0) {
+ g_idle_remove_by_data(obj);
+ }
+ /* Hack: proxy_struct_destroy() lacks a user_data parameter, but since the
+ * caller is responsible for handling params on the stack, it works
+ */
+ g_list_foreach(priv->proxies_possible, (GFunc)proxy_struct_destroy, NULL);
+ g_list_free(priv->proxies_possible);
+ g_list_foreach(priv->proxies_working, (GFunc)proxy_struct_destroy, NULL);
+ g_list_free(priv->proxies_working);
G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj);
return;
}
@@ -286,8 +269,6 @@ indicate_listener_finalize (GObject * obj)
IndicateListener *
indicate_listener_new (void)
{
- g_warning("Creating a new listener is generally discouraged, please use indicate_listener_ref_default");
-
IndicateListener * listener;
listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
return listener;
@@ -709,8 +690,7 @@ proxy_indicators_free (gpointer data)
typedef enum _get_property_type get_property_type;
enum _get_property_type {
PROPERTY_TYPE_STRING,
- PROPERTY_TYPE_TIME,
- PROPERTY_TYPE_ICON
+ PROPERTY_TYPE_TIME
};
typedef struct _get_property_t get_property_t;
@@ -741,44 +721,6 @@ get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer us
cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, OUT_value, get_property_data->data);
break;
}
- case PROPERTY_TYPE_ICON: {
- indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb;
-
- /* There is no icon */
- if (OUT_value == NULL || OUT_value[0] == '\0') {
- break;
- }
-
- gsize length = 0;
- guchar * icondata = g_base64_decode(OUT_value, &length);
-
- GInputStream * input = g_memory_input_stream_new_from_data(icondata, length, NULL);
- if (input == NULL) {
- g_warning("Cound not create input stream from icon property data");
- g_free(icondata);
- break;
- }
-
- GError * error = NULL;
- GdkPixbuf * icon = gdk_pixbuf_new_from_stream(input, NULL, &error);
- if (icon != NULL) {
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, icon, get_property_data->data);
- }
-
- if (error != NULL) {
- g_warning("Unable to build Pixbuf from icon data: %s", error->message);
- g_error_free(error);
- }
-
- error = NULL;
- g_input_stream_close(input, NULL, &error);
- if (error != NULL) {
- g_warning("Unable to close input stream: %s", error->message);
- g_error_free(error);
- }
- g_free(icondata);
- break;
- }
case PROPERTY_TYPE_TIME: {
indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb;
GTimeVal time;
@@ -825,12 +767,6 @@ indicate_listener_get_property_time (IndicateListener * listener, IndicateListen
return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_TIME);
}
-void
-indicate_listener_get_property_icon (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_icon_cb callback, gpointer data)
-{
- return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_ICON);
-}
-
gboolean
_indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers)
{