aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/listener.c110
-rw-r--r--libindicate/listener.h29
-rw-r--r--libindicate/server.c28
-rw-r--r--libindicate/server.h4
4 files changed, 160 insertions, 11 deletions
diff --git a/libindicate/listener.c b/libindicate/listener.c
index 01986ad..efd69fc 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -70,6 +70,7 @@ struct _IndicateListenerPrivate
typedef struct {
DBusGProxy * proxy;
+ DBusGProxy * property_proxy;
gchar * name;
gchar * type;
IndicateListener * listener;
@@ -319,6 +320,14 @@ proxy_struct_destroy (gpointer data)
proxy_data->indicators = NULL;
}
+ if (proxy_data->property_proxy) {
+ g_object_unref(G_OBJECT(proxy_data->proxy));
+ }
+
+ if (proxy_data->property_proxy) {
+ g_object_unref(G_OBJECT(proxy_data->proxy));
+ }
+
g_free(proxy_data->name);
if (proxy_data->type != NULL) {
g_free(proxy_data->type);
@@ -407,6 +416,7 @@ todo_idle (gpointer data)
proxyt->name,
"/org/freedesktop/indicate",
"org.freedesktop.indicator");
+ proxyt->property_proxy = NULL;
proxyt->listener = listener;
proxyt->indicators = NULL;
@@ -673,3 +683,103 @@ indicate_listener_display (IndicateListener * listener, IndicateListenerServer *
return;
}
+
+typedef struct {
+ IndicateListener * listener;
+ IndicateListenerServer * server;
+ indicate_listener_get_server_property_cb cb;
+ gpointer data;
+} property_cb_t;
+
+static void
+property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data)
+{
+ property_cb_t * propertyt = data;
+ GError * error = NULL;
+
+ GValue property;
+
+ dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &property, G_TYPE_INVALID);
+ if (error != NULL) {
+ g_warning("Unable to get property: %s", error->message);
+ g_error_free(error);
+ g_free(propertyt);
+ return;
+ }
+
+ if (!G_VALUE_HOLDS_STRING(&property)) {
+ g_warning("Property returned is not a string!");
+ g_free(propertyt);
+ return;
+ }
+
+ IndicateListener * listener = propertyt->listener;
+ IndicateListenerServer * server = propertyt->server;
+ indicate_listener_get_server_property_cb cb = propertyt->cb;
+ gpointer cb_data = propertyt->data;
+
+ g_free(propertyt);
+
+ gchar * propstr = g_value_dup_string(&property);
+
+ return cb(listener, server, propstr, cb_data);
+}
+
+static void
+get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, const gchar * property_name, gpointer data)
+{
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
+
+ proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server);
+
+ if (proxyt == NULL) {
+ g_warning("Looking for a property on an interface that hasn't be setup for indicators.");
+ // Send NULL to the callback
+ return;
+ }
+
+ if (proxyt->property_proxy == NULL) {
+ DBusGConnection * bus;
+ gchar * bus_name;
+ if (proxyt->proxy == priv->dbus_proxy_system) {
+ bus = priv->system_bus;
+ bus_name = "system";
+ } else {
+ bus = priv->session_bus;
+ bus_name = "session";
+ }
+
+ proxyt->property_proxy = dbus_g_proxy_new_for_name(bus,
+ proxyt->name,
+ "/org/freedesktop/indicate",
+ DBUS_INTERFACE_PROPERTIES);
+ }
+
+ property_cb_t * localdata = g_new(property_cb_t, 1);
+ localdata->listener = listener;
+ localdata->server = server;
+ localdata->cb = callback;
+ localdata->data = data;
+
+ dbus_g_proxy_begin_call (proxyt->property_proxy,
+ "Get",
+ property_cb,
+ localdata,
+ G_TYPE_STRING, "org.freedesktop.indicator",
+ G_TYPE_STRING, property_name,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
+ return;
+}
+
+void
+indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
+{
+ return get_server_property(listener, server, callback, "type", data);
+}
+
+void
+indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
+{
+ return get_server_property(listener, server, callback, "desktop", data);
+}
diff --git a/libindicate/listener.h b/libindicate/listener.h
index 70b7e51..9ecdfc6 100644
--- a/libindicate/listener.h
+++ b/libindicate/listener.h
@@ -79,18 +79,27 @@ struct _IndicateListenerClass {
GType indicate_listener_get_type (void) G_GNUC_CONST;
typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data);
+typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);
/* Create a new listener */
-IndicateListener * indicate_listener_new (void);
-void indicate_listener_get_property (IndicateListener * listener,
- IndicateListenerServer * server,
- IndicateListenerIndicator * indicator,
- gchar * property,
- indicate_listener_get_property_cb callback,
- gpointer data);
-void indicate_listener_display (IndicateListener * listener,
- IndicateListenerServer * server,
- IndicateListenerIndicator * indicator);
+IndicateListener * indicate_listener_new (void);
+void indicate_listener_get_property (IndicateListener * listener,
+ IndicateListenerServer * server,
+ IndicateListenerIndicator * indicator,
+ gchar * property,
+ indicate_listener_get_property_cb callback,
+ gpointer data);
+void indicate_listener_display (IndicateListener * listener,
+ IndicateListenerServer * server,
+ IndicateListenerIndicator * indicator);
+void indicate_listener_server_get_type (IndicateListener * listener,
+ IndicateListenerServer * server,
+ indicate_listener_get_server_property_cb callback,
+ gpointer data);
+void indicate_listener_server_get_desktop (IndicateListener * listener,
+ IndicateListenerServer * server,
+ indicate_listener_get_server_property_cb callback,
+ gpointer data);
diff --git a/libindicate/server.c b/libindicate/server.c
index 766e312..a9849fe 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -396,6 +396,34 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i
return;
}
+void
+indicate_server_set_dbus_object (const gchar * obj)
+{
+ /* TODO */
+
+ return;
+}
+
+void
+indicate_server_set_desktop_file (IndicateServer * server, const gchar * path)
+{
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, path);
+ g_object_set_property(G_OBJECT(server), "desktop", &value);
+ return;
+}
+
+void
+indicate_server_set_type (IndicateServer * server, const gchar * type)
+{
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, type);
+ g_object_set_property(G_OBJECT(server), "type", &value);
+ return;
+}
+
static IndicateServer * default_indicate_server = NULL;
IndicateServer *
diff --git a/libindicate/server.h b/libindicate/server.h
index 9347f16..4e3c931 100644
--- a/libindicate/server.h
+++ b/libindicate/server.h
@@ -83,7 +83,8 @@ void indicate_server_set_dbus_object (const gchar * obj);
/* Sets the desktop file to get data like name and description
* out of */
-void indicate_server_set_desktop_file (const gchar * path);
+void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path);
+void indicate_server_set_type (IndicateServer * server, const gchar * type);
/* Show and hide the server on DBus, this allows for the server to
* be created, change the object, and then shown. If for some
@@ -99,6 +100,7 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato
IndicateServer * indicate_server_ref_default (void);
void indicate_server_set_default (IndicateServer * server);
+
/* 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);