aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/Makefile.am187
-rw-r--r--libindicate/indicate-interface.xml103
-rw-r--r--libindicate/indicate-listener.xml41
-rw-r--r--libindicate/indicate.pc.in14
-rw-r--r--libindicate/indicator-message.c105
-rw-r--r--libindicate/indicator-message.h92
-rw-r--r--libindicate/indicator.c528
-rw-r--r--libindicate/indicator.h173
-rw-r--r--libindicate/interests-priv.h46
-rw-r--r--libindicate/interests.h50
-rw-r--r--libindicate/listener-marshal.list35
-rw-r--r--libindicate/listener-private.h63
-rw-r--r--libindicate/listener.c1084
-rw-r--r--libindicate/listener.h132
-rw-r--r--libindicate/server-marshal.list29
-rw-r--r--libindicate/server.c1516
-rw-r--r--libindicate/server.h219
17 files changed, 0 insertions, 4417 deletions
diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am
deleted file mode 100644
index d4746fb..0000000
--- a/libindicate/Makefile.am
+++ /dev/null
@@ -1,187 +0,0 @@
-MARSHAL_PREFIX = indicate_marshal
-MARSHAL_FILE = indicate-marshal
-ENUM_FILE = indicate-enum-types
-
-INCLUDES= \
- -DG_LOG_DOMAIN=\"libindicate\"
-
-EXTRA_DIST = \
- indicate-interface.xml \
- indicate-listener.xml \
- listener-marshal.list \
- server-marshal.list \
- indicate.pc.in
-
-BUILT_SOURCES = \
- dbus-indicate-server.h \
- dbus-indicate-client.h \
- dbus-listener-server.h \
- dbus-listener-client.h \
- listener-marshal.c \
- listener-marshal.h \
- server-marshal.c \
- server-marshal.h \
- $(ENUM_FILE).h \
- $(ENUM_FILE).c
-
-lib_LTLIBRARIES = \
- libindicate.la
-
-libindicateincludedir=$(includedir)/libindicate-0.1/libindicate
-
-indicate_headers = \
- indicator.h \
- indicator-message.h \
- listener.h \
- server.h \
- interests.h \
- $(ENUM_FILE).h
-
-libindicateinclude_HEADERS = \
- $(indicate_headers)
-
-libindicate_la_SOURCES = \
- $(indicate_headers) \
- dbus-indicate-server.h \
- dbus-indicate-client.h \
- dbus-listener-server.h \
- dbus-listener-client.h \
- indicate-enum-types.c \
- server.c \
- server-marshal.c \
- server-marshal.h \
- listener.c \
- listener-marshal.c \
- listener-marshal.h \
- listener-private.h \
- indicator.c \
- indicator-message.c \
- interests-priv.h
-
-libindicate_la_LDFLAGS = \
- -version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \
- -no-undefined \
- -export-symbols-regex "^[^_d].*"
-
-libindicate_la_CFLAGS = \
- $(LIBINDICATE_CFLAGS)
-
-libindicate_la_LIBADD = \
- $(LIBINDICATE_LIBS)
-
-dbus-indicate-server.h: indicate-interface.xml
- dbus-binding-tool \
- --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 \
- --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 \
- --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 \
- --mode=glib-client \
- --output=dbus-listener-client.h \
- $(srcdir)/indicate-listener.xml
-
-listener-marshal.h: $(srcdir)/listener-marshal.list
- glib-genmarshal --header \
- --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 \
- > listener-marshal.c
-
-server-marshal.h: $(srcdir)/server-marshal.list
- glib-genmarshal --header \
- --prefix=_indicate_server_marshal $(srcdir)/server-marshal.list \
- > server-marshal.h
-
-server-marshal.c: $(srcdir)/server-marshal.list
- glib-genmarshal --body \
- --prefix=_indicate_server_marshal $(srcdir)/server-marshal.list \
- > server-marshal.c
-
-pkgconfig_DATA = indicate.pc
-pkgconfigdir = $(libdir)/pkgconfig
-
-$(ENUM_FILE).h: s-enum-types-h
- @true
-s-enum-types-h: $(indicate_headers) Makefile
- ( cd $(srcdir) && glib-mkenums \
- --fhead "#ifndef _INDICATE_ENUM_TYPES_H_\n#define _INDICATE_ENUM_TYPES_H_\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
- --fprod "/* enumerations from \"@filename@\" */\n" \
- --vhead "GType @enum_name@_get_type(void);\n#define INDICATE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
- --ftail "G_END_DECLS\n\n#endif /* _INDICATE_ENUM_TYPES_H_ */" \
- interests.h ) > tmp-$(ENUM_FILE).h \
- && (cmp -s tmp-$(ENUM_FILE).h $(ENUM_FILE).h || cp tmp-$(ENUM_FILE).h $(ENUM_FILE).h ) \
- && rm -f tmp-$(ENUM_FILE).h \
- && echo timestamp > $(@F)
-
-$(ENUM_FILE).c: s-enum-types-c
- @true
-s-enum-types-c: $(indicate_headers) Makefile
- ( cd $(srcdir) && glib-mkenums \
- --fhead "#include \"interests.h\"\n#include <glib-object.h>" \
- --fprod "\n/* enumerations from \"@filename@\" */" \
- --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
- --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
- --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
- interests.h ) > tmp-$(ENUM_FILE).c \
- && (cmp -s tmp-$(ENUM_FILE).c $(ENUM_FILE).c || cp tmp-$(ENUM_FILE).c $(ENUM_FILE).c ) \
- && rm -f tmp-$(ENUM_FILE).c \
- && echo timestamp > $(@F)
-
-CLEANFILES = \
- $(ENUM_FILE).c \
- $(ENUM_FILE).h \
- s-enum-types-c \
- s-enum-types-h
-
-if USE_GIR
-
-gobjectintrospection_gir_DATA = \
- Indicate-0.1.gir
-gobjectintrospection_girdir = $(datadir)/gir
-
-gobjectintrospection_type_DATA = \
- Indicate-0.1.typelib
-gobjectintrospection_typedir = $(libdir)/girepository
-
-irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers))
-Indicate-0.1.gir: $(irscanner_headers)
- $(G_IR_SCANNER) \
- -v --namespace Indicate \
- --nsversion=0.1 \
- --add-include-path=$(srcdir) \
- --include=GObject-2.0 \
- --include=GLib-2.0 \
- --include=GdkPixbuf-2.0 \
- --library=indicate --pkg indicate \
- --output Indicate-0.1.gir $(irscanner_headers)
-
-Indicate-0.1.typelib: Indicate-0.1.gir
- $(G_IR_COMPILER) \
- --includedir=$(srcdir) Indicate-0.1.gir \
- -o Indicate-0.1.typelib
-
-DISTCLEANFILES = \
- Indicate-0.1.gir \
- Indicate-0.1.typelib
-
-endif
diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml
deleted file mode 100644
index 900b336..0000000
--- a/libindicate/indicate-interface.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
--->
-<node name="/">
- <interface name="org.freedesktop.indicator">
-
-<!-- Properties -->
- <property name="desktop" type="s" access="read"/>
- <property name="type" type="s" access="read"/>
-
-<!-- Functions -->
- <method name="GetIndicatorCount">
- <arg type="u" name="indicator_count" direction="out" />
- </method>
- <method name="GetIndicatorCountByType">
- <arg type="s" name="type" direction="in" />
- <arg type="u" name="indicator_count" direction="out" />
- </method>
- <method name="GetIndicatorList">
- <arg type="ai" name="indicators" direction="out" />
- </method>
- <method name="GetIndicatorListByType">
- <arg type="s" name="type" direction="in" />
- <arg type="ai" name="indicators" direction="out" />
- </method>
- <method name="GetIndicatorProperty">
- <arg type="u" name="id" direction="in" />
- <arg type="s" name="property" direction="in" />
- <arg type="s" name="value" direction="out" />
- </method>
- <method name="GetIndicatorPropertyGroup">
- <arg type="u" name="id" direction="in" />
- <arg type="as" name="properties" direction="in" />
- <arg type="as" name="values" direction="out" />
- </method>
- <method name="GetIndicatorProperties">
- <arg type="u" name="id" direction="in" />
- <arg type="as" name="properties" direction="out" />
- </method>
- <method name="ShowIndicatorToUser">
- <arg type="u" name="id" direction="in" />
- </method>
- <method name="ShowInterest">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
- <arg type="s" name="interest" direction="in" />
- </method>
- <method name="RemoveInterest">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
- <arg type="s" name="interest" direction="in" />
- </method>
-
-
-<!-- Signals -->
- <signal name="IndicatorAdded">
- <arg type="u" name="id" direction="out" />
- <arg type="s" name="type" direction="out" />
- </signal>
- <signal name="IndicatorRemoved">
- <arg type="u" name="id" direction="out" />
- <arg type="s" name="type" direction="out" />
- </signal>
- <signal name="IndicatorModified">
- <arg type="u" name="id" direction="out" />
- <arg type="s" name="property" direction="out" />
- </signal>
- <signal name="ServerShow">
- <arg type="s" name="type" direction="out" />
- </signal>
- <signal name="ServerHide">
- <arg type="s" name="type" direction="out" />
- </signal>
-
-
-<!-- End of interesting stuff -->
-
- </interface>
-</node>
diff --git a/libindicate/indicate-listener.xml b/libindicate/indicate-listener.xml
deleted file mode 100644
index c834489..0000000
--- a/libindicate/indicate-listener.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
--->
-<node name="/">
- <interface name="org.freedesktop.indicator.listener">
-
-<!-- Functions -->
- <method name="GetIndicatorServers">
- <arg type="as" name="server_ids" direction="out" />
- </method>
-
-<!-- End of interesting stuff -->
-
- </interface>
-</node>
diff --git a/libindicate/indicate.pc.in b/libindicate/indicate.pc.in
deleted file mode 100644
index ff17ecb..0000000
--- a/libindicate/indicate.pc.in
+++ /dev/null
@@ -1,14 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-bindir=@bindir@
-includedir=@includedir@
-
-Cflags: -I${includedir}/libindicate-0.1
-Requires: gobject-2.0 glib-2.0 dbus-glib-1
-Libs: -L${libdir} -lindicate
-
-Name: libindicate
-Description: libindicate.
-Version: @VERSION@
-
diff --git a/libindicate/indicator-message.c b/libindicate/indicator-message.c
deleted file mode 100644
index 9cd735a..0000000
--- a/libindicate/indicator-message.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "indicator-message.h"
-
-typedef struct _IndicateIndicatorMessagePrivate IndicateIndicatorMessagePrivate;
-
-struct _IndicateIndicatorMessagePrivate
-{
- gchar * subtype;
-};
-
-#define INDICATE_INDICATOR_MESSAGE_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_INDICATOR_MESSAGE_TYPE, IndicateIndicatorMessagePrivate))
-
-static void indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass);
-static void indicate_indicator_message_init (IndicateIndicatorMessage *self);
-static void indicate_indicator_message_dispose (GObject *object);
-static void indicate_indicator_message_finalize (GObject *object);
-static const gchar * get_indicator_type (IndicateIndicator * indicator);
-
-G_DEFINE_TYPE (IndicateIndicatorMessage, indicate_indicator_message, INDICATE_TYPE_INDICATOR);
-
-static void
-indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (IndicateIndicatorMessagePrivate));
-
- object_class->dispose = indicate_indicator_message_dispose;
- object_class->finalize = indicate_indicator_message_finalize;
-
- IndicateIndicatorClass * indicator_class = INDICATE_INDICATOR_CLASS(klass);
-
- indicator_class->get_type = get_indicator_type;
-
- return;
-}
-
-static void
-indicate_indicator_message_init (IndicateIndicatorMessage *self)
-{
-}
-
-static void
-indicate_indicator_message_dispose (GObject *object)
-{
-G_OBJECT_CLASS (indicate_indicator_message_parent_class)->dispose (object);
-}
-
-static void
-indicate_indicator_message_finalize (GObject *object)
-{
-G_OBJECT_CLASS (indicate_indicator_message_parent_class)->finalize (object);
-}
-
-/**
- indicate_indicator_message_new:
-
- Builds a new indicator message object using #g_object_new.
-
- Return value: A pointer to a new #IndicateIndicatorMessage object.
-*/
-static const gchar *
-get_indicator_type (IndicateIndicator * indicator)
-{
- return "message";
-}
-
-IndicateIndicatorMessage *
-indicate_indicator_message_new (void)
-{
- return g_object_new(INDICATE_TYPE_INDICATOR_MESSAGE, NULL);
-}
diff --git a/libindicate/indicator-message.h b/libindicate/indicator-message.h
deleted file mode 100644
index 76273c6..0000000
--- a/libindicate/indicator-message.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef __INDICATE_INDICATOR_MESSAGE_H__
-#define __INDICATE_INDICATOR_MESSAGE_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "indicator.h"
-
-G_BEGIN_DECLS
-
-#define INDICATE_TYPE_INDICATOR_MESSAGE (indicate_indicator_message_get_type ())
-#define INDICATE_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessage))
-#define INDICATE_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass))
-#define INDICATE_IS_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATE_TYPE_INDICATOR_MESSAGE))
-#define INDICATE_IS_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATE_TYPE_INDICATOR_MESSAGE))
-#define INDICATE_INDICATOR_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass))
-
-typedef struct _IndicateIndicatorMessage IndicateIndicatorMessage;
-typedef struct _IndicateIndicatorMessageClass IndicateIndicatorMessageClass;
-
-/**
- IndicateIndicatorMessageClass:
- @parent_class: Parent Class
-
- Subclass of #IndicateIndicator with no new functions or signals.
-*/
-struct _IndicateIndicatorMessageClass {
- IndicateIndicatorClass parent_class;
-};
-
-/**
- IndicateIndicatorMessage:
-
- A class to represent indicators who's 'type' is "message". These
- are basically indicators that represent messages from humans to
- humans via computers. Things like instance messages, micro blogging
- entries or e-mails. All of these qualify as messages.
-
- TODO: This should include a list of properties that are supported.
-*/
-struct _IndicateIndicatorMessage {
- IndicateIndicator parent;
-};
-
-GType indicate_indicator_message_get_type (void);
-IndicateIndicatorMessage * indicate_indicator_message_new (void);
-
-/**
- SECTION:indicator-message
- @short_description: A representation of human generated messages
- @stability: Unstable
- @include: libindicate/indicator-message.h
-
- The message indicators represent messages that come from humans
- to humans using computers. They come in all different forms with
- various different interaction protocols, but they all want the human
- at the computer to interact back with the human that sent the
- message.
-*/
-
-G_END_DECLS
-
-#endif
diff --git a/libindicate/indicator.c b/libindicate/indicator.c
deleted file mode 100644
index 18cdc4a..0000000
--- a/libindicate/indicator.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#include "glib.h"
-#include "glib/gmessages.h"
-#include "indicator.h"
-#include "server.h"
-
-/* Signals */
-enum {
- HIDE,
- SHOW,
- USER_DISPLAY,
- MODIFIED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-typedef struct _IndicateIndicatorPrivate IndicateIndicatorPrivate;
-struct _IndicateIndicatorPrivate
-{
- guint id;
- gboolean is_visible;
- IndicateServer * server;
- GHashTable * properties;
-};
-
-#define INDICATE_INDICATOR_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_INDICATOR, IndicateIndicatorPrivate))
-
-G_DEFINE_TYPE (IndicateIndicator, indicate_indicator, G_TYPE_OBJECT);
-
-static void indicate_indicator_finalize (GObject * object);
-static void set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data);
-static const gchar * get_property (IndicateIndicator * indicator, const gchar * key);
-static GPtrArray * list_properties (IndicateIndicator * indicator);
-
-
-/* Functions */
-static void
-indicate_indicator_class_init (IndicateIndicatorClass * class)
-{
- /* g_debug("Indicator Class Initialized."); */
-
- GObjectClass * gobj;
- gobj = G_OBJECT_CLASS(class);
-
- g_type_class_add_private (class, sizeof (IndicateIndicatorPrivate));
-
- gobj->finalize = indicate_indicator_finalize;
-
- /**
- IndicateIndicator::display:
- @arg0: The #IndicateIndicator object
-
- Emitted when the user has clicked on this indicator. In the
- messaging indicator this would be when someone clicks on the
- menu item for the indicator.
- */
- signals[USER_DISPLAY] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAY,
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(IndicateIndicatorClass, user_display),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- /**
- IndicateIndicator::hide:
- @arg0: The #IndicateIndicator object
-
- Emitted every time this indicator is hidden. This
- is mostly used by #IndicateServer.
-
- Typically this results in an emition of #IndicateServer::indicator-removed.
- */
- signals[HIDE] = g_signal_new(INDICATE_INDICATOR_SIGNAL_HIDE,
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(IndicateIndicatorClass, hide),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- /**
- IndicateIndicator::show:
- @arg0: The #IndicateIndicator object
-
- Emitted every time this indicator is shown. This
- is mostly used by #IndicateServer.
-
- Typically this results in an emition of #IndicateServer::indicator-added.
- */
- signals[SHOW] = g_signal_new(INDICATE_INDICATOR_SIGNAL_SHOW,
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(IndicateIndicatorClass, show),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- /**
- IndicateIndicator::modified:
- @arg0: The #IndicateIndicator object
- @arg1: The name of the property that changed.
-
- Emitted every time an indicator property is changed.
- This is mostly used by #IndicateServer.
-
- Typically this results in an emition of #IndicateServer::indicator-modified.
- */
- signals[MODIFIED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_MODIFIED,
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(IndicateIndicatorClass, modified),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- class->get_type = NULL;
- class->set_property = set_property;
- class->get_property = get_property;
- class->list_properties = list_properties;
-
- return;
-}
-
-static void
-indicate_indicator_init (IndicateIndicator * indicator)
-{
- /* g_debug("Indicator Object Initialized."); */
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- priv->is_visible = FALSE;
-
- priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-
- priv->server = indicate_server_ref_default();
- priv->id = indicate_server_get_next_id(priv->server);
-
- indicate_server_add_indicator(priv->server, indicator);
-
- return;
-}
-
-static void
-indicate_indicator_finalize (GObject * obj)
-{
- IndicateIndicator * indicator = INDICATE_INDICATOR(obj);
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- indicate_server_remove_indicator(priv->server, indicator);
- g_object_unref(priv->server);
- priv->server = NULL;
-
- G_OBJECT_CLASS (indicate_indicator_parent_class)->finalize (obj);
- return;
-}
-
-/**
- indicate_indicator_get_type:
-
- Gets a unique #GType for the #IndicateIndicator objects.
-
- Return value: A unique #GType value.
-*/
-
-/**
- indicate_indicator_new:
-
- Builds a new indicator object using g_object_new().
-
- Return value: A pointer to a new #IndicateIndicator object.
-*/
-IndicateIndicator *
-indicate_indicator_new (void)
-{
- IndicateIndicator * indicator = g_object_new(INDICATE_TYPE_INDICATOR, NULL);
- return indicator;
-}
-
-/**
- indicate_indicator_new_with_server:
- @server: The server that should be associated with this indicator.
-
- Builds a new indicator object using g_object_new() and sets
- the server to the specified server. Also, adds a reference
- to the server.
-
- Return value: A pointer to a new #IndicateIndicator object.
-*/
-IndicateIndicator *
-indicate_indicator_new_with_server (IndicateServer * server)
-{
- g_return_val_if_fail(server != NULL, NULL);
-
- IndicateIndicator * indicator = g_object_new(INDICATE_TYPE_INDICATOR, NULL);
-
- indicate_indicator_set_server (indicator, server);
-
- return indicator;
-}
-
-/**
- indicate_indicator_set_server:
- @indicator: a #IndicateIndicator to act on
- @server: the #IndicateServer which should be associated with @indicator
-
- Defines which server this indicator must be associated to. Also, adds a
- reference to the server.
-*/
-void
-indicate_indicator_set_server (IndicateIndicator * indicator, IndicateServer * server)
-{
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- if (server != NULL) {
- g_object_ref(server);
- }
-
- if (priv->server != NULL) {
- indicate_server_remove_indicator (priv->server, indicator);
- g_object_unref(priv->server);
- }
-
- priv->server = server;
- if (server != NULL) {
- indicate_server_add_indicator (server, indicator);
- }
-
- return;
-}
-
-
-/**
- indicate_indicator_show:
- @indicator: a #IndicateIndicator to act on
-
- Shows this indicator on the bus. If the #IndicateServer that it's
- connected to is not shown itself this function will show the server
- as well using #indicate_server_show.
-*/
-void
-indicate_indicator_show (IndicateIndicator * indicator)
-{
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- if (priv->is_visible) {
- return;
- }
-
- if (priv->server) {
- indicate_server_show(priv->server);
- }
-
- priv->is_visible = TRUE;
- g_signal_emit(indicator, signals[SHOW], 0, TRUE);
-
- return;
-}
-
-/**
- indicate_indicator_hide:
- @indicator: a #IndicateIndicator to act on
-
- Hides the indicator from the bus. Does not effect the
- indicator's #IndicateServer in any way.
-*/
-void
-indicate_indicator_hide (IndicateIndicator * indicator)
-{
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- if (!priv->is_visible) {
- return;
- }
-
- priv->is_visible = FALSE;
- g_signal_emit(indicator, signals[HIDE], 0, TRUE);
-
- return;
-}
-
-/**
- indicate_indicator_is_visible:
- @indicator: a #IndicateIndicator to act on
-
- Checkes the visibility status of @indicator.
-
- Return value: %TRUE if the indicator is visible else %FALSE.
-*/
-gboolean
-indicate_indicator_is_visible (IndicateIndicator * indicator)
-{
- g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), FALSE);
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
- return priv->is_visible;
-}
-
-/**
- indicate_indicator_get_id:
- @indicator: a #IndicateIndicator to act on
-
- Gets the ID value of the @indicator.
-
- Return value: The ID of the indicator. Can not be zero.
- Zero represents an error.
-*/
-guint
-indicate_indicator_get_id (IndicateIndicator * indicator)
-{
- g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), 0);
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
- return priv->id;
-}
-
-/**
- indicate_indicator_get_indicator_type:
- @indicator: a #IndicateIndicator to act on
-
- Returns the type of @indicator. This is largely set by the subclass
- that the indicator was built with and should not be free'd.
-
- Return value: A string defining the type or NULL for no type.
-*/
-const gchar *
-indicate_indicator_get_indicator_type (IndicateIndicator * indicator)
-{
- g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
- IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
-
- if (class->get_type != NULL) {
- return INDICATE_INDICATOR_GET_CLASS(indicator)->get_type(indicator);
- }
-
- return NULL;
-}
-
-/**
- indicate_indicator_user_display:
- @indicator: a #IndicateIndicator to act on
-
- Emits the #IndicateIndicator::user-display signal simliar to a user
- clicking on @indicator over the bus. Signal will not be sent if the
- @indicator is not visible.
-*/
-void
-indicate_indicator_user_display (IndicateIndicator * indicator)
-{
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
- if (!priv->is_visible) {
- return;
- }
-
- g_signal_emit(indicator, signals[USER_DISPLAY], 0, TRUE);
- return;
-}
-
-/**
- indicate_indicator_set_property:
- @indicator: a #IndicateIndicator to act on
- @key: name of the property
- @data: value of the property
-
- Sets a simple string property on @indicator. If the property
- had previously been set it will replace it with the new value,
- otherwise it will create the property. This will include an
- emition of #IndicateIndicator::modified if the property value
- was changed.
-*/
-void
-indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data)
-{
- IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
- if (class->set_property == NULL) {
- return;
- }
-
- return class->set_property(indicator, key, data);
-}
-
-/**
- indicate_indicator_set_property_time:
- @indicator: a #IndicateIndicator to act on
- @key: name of the property
- @time: time to set property with
-
- This is a helper function that wraps around #indicate_indicator_set_property
- but takes an #GTimeVal parameter. It then takes the @data
- parameter converts it to an ISO 8601 time string and
- uses that data to call #indicate_indicator_set_property.
-*/
-void
-indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time)
-{
- gchar * timestr = g_time_val_to_iso8601(time);
- if (timestr != NULL) {
- indicate_indicator_set_property(indicator, key, timestr);
- g_free(timestr);
- }
- return;
-}
-
-/**
- indicate_indicator_get_property:
- @indicator: a #IndicateIndicator to act on
- @key: name of the property
-
- Returns the value that is set for a property or %NULL if that
- property is not set.
-
- Return value: A constant string or NULL.
-*/
-const gchar *
-indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key)
-{
- IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
- if (class->get_property == NULL) {
- return NULL;
- }
-
- return class->get_property(indicator, key);
-}
-
-/**
- indicate_indicator_list_properties:
- @indicator: a #IndicateIndicator to act on
-
- This function gets a list of all the properties that exist
- on a @indicator. The array may have zero entries but almost
- always at least has 'type' in it.
-
- Return value: An array of strings that is the keys of all
- the properties on this indicator.
-*/
-GPtrArray *
-indicate_indicator_list_properties (IndicateIndicator * indicator)
-{
- IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
- if (class->list_properties == NULL) {
- return g_ptr_array_new();
- }
-
- return class->list_properties(indicator);
-}
-
-static void
-set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data)
-{
- g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
-
- if (key != NULL && !g_strcmp0(key, "type")) {
- g_warning("Trying to set the 'type' of an indicator which should be done through subclassing.");
- return;
- }
-
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- gchar * current = g_hash_table_lookup(priv->properties, key);
- if (current == NULL || g_strcmp0(current, data)) {
- /* If the value has changed or there is no value */
- gchar * newkey = g_strdup(key);
- /* g_debug("What is newkey? %s", newkey); */
- g_hash_table_insert(priv->properties, newkey, g_strdup(data));
- if (indicate_indicator_is_visible(indicator)) {
- /* g_debug("Indicator property modified: %s %s", key, data); */
- g_signal_emit(indicator, signals[MODIFIED], 0, key, TRUE);
- }
- }
-
- return;
-}
-
-static const gchar *
-get_property (IndicateIndicator * indicator, const gchar * key)
-{
- g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
-
- if (key != NULL && !g_strcmp0(key, "type")) {
- return indicate_indicator_get_indicator_type(indicator);
- }
-
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- // TODO: Think about whether we should be strdup'ing this. Seems like overkill, but might not be.
- return (const gchar *)g_hash_table_lookup(priv->properties, key);
-}
-
-static GPtrArray *
-list_properties (IndicateIndicator * indicator)
-{
- g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), g_ptr_array_new());
- IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
-
- GList * keys = g_hash_table_get_keys(priv->properties);
- GPtrArray * properties = g_ptr_array_sized_new(g_list_length(keys) + 1);
-
- g_ptr_array_add(properties, g_strdup("type"));
- for (; keys != NULL; keys = keys->next) {
- g_ptr_array_add(properties, g_strdup(keys->data));
- }
-
- return properties;
-}
diff --git a/libindicate/indicator.h b/libindicate/indicator.h
deleted file mode 100644
index b2e33c0..0000000
--- a/libindicate/indicator.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_INDICATOR_H_INCLUDED__
-#define INDICATE_INDICATOR_H_INCLUDED__ 1
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* Boilerplate */
-#define INDICATE_TYPE_INDICATOR (indicate_indicator_get_type ())
-#define INDICATE_INDICATOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), INDICATE_TYPE_INDICATOR, IndicateIndicator))
-#define INDICATE_IS_INDICATOR(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), INDICATE_TYPE_INDICATOR))
-#define INDICATE_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), INDICATE_TYPE_INDICATOR, IndicateIndicatorClass))
-#define INDICATE_IS_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), INDICATE_TYPE_INDICATOR))
-#define INDICATE_INDICATOR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), INDICATE_TYPE_INDICATOR, IndicateIndicatorClass))
-
-/* This is a signal that signals to the indicator that the user
- * has done an action where they'd like this indicator to be
- * displayed. */
-#define INDICATE_INDICATOR_SIGNAL_HIDE "hide"
-#define INDICATE_INDICATOR_SIGNAL_SHOW "show"
-#define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display"
-#define INDICATE_INDICATOR_SIGNAL_MODIFIED "modified"
-
-typedef struct _IndicateIndicator IndicateIndicator;
-typedef struct _IndicateIndicatorClass IndicateIndicatorClass;
-
-/**
- IndicateIndicator:
-
- The indicator object represents a single item that is shared over the
- indicator bus. This could be something like one IM, one e-mail or
- a single system update. It should be accessed only through its
- accessors.
-*/
-struct _IndicateIndicator {
- GObject parent;
-};
-
-#include "server.h"
-
-/**
- IndicateIndicatorClass:
- @parent_class: Parent class #GObjectClass.
- @hide: Slot for #IndicateIndicator::hide.
- @show: Slot for #IndicateIndicator::show.
- @user_display: Slot for #IndicateIndicator::user-display.
- @modified: Slot for #IndicateIndicator::modified.
- @get_type: Returns a constant string for the type of this indicator.
- Typically gets overridden by subclasses and defines the type of
- the indicator. Is called by indicate_indicator_get_indicator_type().
- @set_property: Called when indicate_indicator_set_property() is called
- and should set the value. While typically it is overridden by
- subclasses they usually handle special properties themselves and
- then call the superclass for storage.
- @get_property: Called when indicate_indicator_get_property() is called
- and should return the value requested. Many times this is left alone.
- @list_properties: Called when indicate_indicator_list_properties() is called
- and returns a list of the properties available. Again this can be
- overridden by subclasses to handle special properties.
-
- All of the functions that are used to modify or change data that is
- in the indicator. Typically gets subclassed by other types of
- indicators, for example #IndicateIndicatorMessages.
-
-*/
-struct _IndicateIndicatorClass {
- GObjectClass parent_class;
-
- void (*hide) (IndicateIndicator * indicator, gpointer data);
- void (*show) (IndicateIndicator * indicator, gpointer data);
- void (*user_display) (IndicateIndicator * indicator, gpointer data);
- void (*modified) (IndicateIndicator * indicator, gchar * property, gpointer data);
-
- const gchar * (*get_type) (IndicateIndicator * indicator);
- void (*set_property) (IndicateIndicator * indicator, const gchar * key, const gchar * data);
- const gchar * (*get_property) (IndicateIndicator * indicator, const gchar * key);
- GPtrArray * (*list_properties) (IndicateIndicator * indicator);
-};
-
-GType indicate_indicator_get_type(void) G_GNUC_CONST;
-
-/* New Indicator Functions */
-IndicateIndicator * indicate_indicator_new (void);
-IndicateIndicator * indicate_indicator_new_with_server (IndicateServer * server);
-
-/* Show and hide this indicator */
-void indicate_indicator_show (IndicateIndicator * indicator);
-void indicate_indicator_hide (IndicateIndicator * indicator);
-
-gboolean indicate_indicator_is_visible (IndicateIndicator * indicator);
-
-/* Define this indicator server */
-void indicate_indicator_set_server (IndicateIndicator * indicator, IndicateServer * server);
-
-/* Every entry has an ID, here's how to get it */
-guint indicate_indicator_get_id (IndicateIndicator * indicator);
-
-/* Every entry has a type. This should be created by the
- * subclass and exported through this pretty function */
-const gchar * indicate_indicator_get_indicator_type (IndicateIndicator * indicator);
-
-void indicate_indicator_user_display (IndicateIndicator * indicator);
-
-/* Properties handling */
-void indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data);
-void indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time);
-const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key);
-GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator);
-
-/**
- SECTION:indicator
- @short_description: A representation of state for applications
- @stability: Unstable
- @include: libindicate/indicator.h
-
- An indicator is designed to represent a single instance of something
- in your application. So this might be an IM or Email using #IndicateIndicatorMessage
- or any other thing that is a small unit of information to pass on
- to the user.
-
- Indicators make no promises about how they are preceived by the
- user, it's up to the listener to represent them in an intutive and
- visually appealling way. But, what we can do is provide information
- on the indicator to provide enough information for the listener
- to do that.
-
- Mostly this is done through properties. The only property that is
- defined for the base indicator is the 'type' property. And this
- is only available to set by creating a subclass of the
- #IndicateIndicator object. It is assumed that you can look at the
- definitions of the various subtypes to determine which properties
- they support.
-
- It may be that some users don't want to create objects for every
- indicator as it could be a lot of overhead if there are large numbers
- and there is already a data structure representing them all. In that
- case it is recommended that you ignore the #IndicateIndicator object
- tree in general and move to subclassing #IndicateServer directly.
-*/
-
-G_END_DECLS
-
-#endif /* INDICATE_INDICATOR_H_INCLUDED__ */
diff --git a/libindicate/interests-priv.h b/libindicate/interests-priv.h
deleted file mode 100644
index eb4e791..0000000
--- a/libindicate/interests-priv.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_INTERESTS_PRIV_H_INCLUDED__
-#define INDICATE_INTERESTS_PRIV_H_INCLUDED__ 1
-
-#include <glib.h>
-
-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
deleted file mode 100644
index 1c6215a..0000000
--- a/libindicate/interests.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_INTERESTS_H_INCLUDED__
-#define INDICATE_INTERESTS_H_INCLUDED__ 1
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- 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 */
- 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_LAST /**< Makes merges and counting easier */
-} IndicateInterests;
-
-G_END_DECLS
-
-#endif /* INDICATE_INTERESTS_H_INCLUDED__ */
-
diff --git a/libindicate/listener-marshal.list b/libindicate/listener-marshal.list
deleted file mode 100644
index a3d20a9..0000000
--- a/libindicate/listener-marshal.list
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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 <ted@canonical.com>
-#
-# 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
-# <http://www.gnu.org/licenses/>
-#
-# IndicatorAdded, IndicatorRemoved, IndicatorModified
-VOID:UINT,STRING
-# Local indicator_added, indicator_removed
-VOID:POINTER,POINTER,STRING
-# Local indicator_modified
-VOID:POINTER,POINTER,STRING,STRING
-# Local server_added and server_removed
-VOID:POINTER,STRING
diff --git a/libindicate/listener-private.h b/libindicate/listener-private.h
deleted file mode 100644
index ea1b108..0000000
--- a/libindicate/listener-private.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_LISTENER_PRIVATE_H__
-#define INDICATE_LISTENER_PRIVATE_H__ 1
-
-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))
-
-#endif /* INDICATE_LISTENER_PRIVATE_H__ */
diff --git a/libindicate/listener.c b/libindicate/listener.c
deleted file mode 100644
index 48ad616..0000000
--- a/libindicate/listener.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "listener.h"
-#include "listener-marshal.h"
-#include <dbus/dbus-glib-bindings.h>
-#include "dbus-indicate-client.h"
-#include "dbus-listener-client.h"
-#include "interests-priv.h"
-
-/* Errors */
-enum {
- LAST_ERROR
-};
-
-/* Signals */
-enum {
- INDICATOR_ADDED,
- INDICATOR_REMOVED,
- INDICATOR_MODIFIED,
- SERVER_ADDED,
- SERVER_REMOVED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-#include "listener-private.h"
-
-typedef struct {
- DBusGProxy * proxy;
- DBusGProxy * property_proxy;
- DBusGConnection * connection;
- gchar * name;
- gchar * type;
- IndicateListener * listener;
- GHashTable * indicators;
- guint introspect_level;
-
- 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->connection == b->connection) {
- 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;
- gboolean startup;
-} proxy_todo_t;
-
-G_DEFINE_TYPE (IndicateListener, indicate_listener, G_TYPE_OBJECT);
-
-/* Prototypes */
-static void indicate_listener_finalize (GObject * obj);
-static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener);
-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);
-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);
-static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);
-static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
-static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data);
-static void proxy_indicators_free (gpointer data);
-static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, 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)
-{
- /* g_debug("Listener Class Initialized"); */
- GObjectClass * gobj;
- gobj = G_OBJECT_CLASS(class);
-
- g_type_class_add_private (class, sizeof (IndicateListenerPrivate));
-
- gobj->finalize = indicate_listener_finalize;
-
- signals[INDICATOR_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
- NULL, NULL,
- _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
- G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, 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,
- G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);
-
- dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING,
- G_TYPE_NONE,
- G_TYPE_UINT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- return;
-}
-
-static void
-indicate_listener_init (IndicateListener * listener)
-{
- /* g_debug("Listener Object Initialized"); */
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
- GError *error = NULL;
-
- /* Get the buses */
- priv->session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_error("Unable to get session bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- priv->system_bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (error != NULL) {
- g_error("Unable to get system bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- /* Set up the DBUS service proxies */
- priv->dbus_proxy_session = dbus_g_proxy_new_for_name_owner (priv->session_bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- &error);
- if (error != NULL) {
- g_error("Unable to get dbus proxy on session bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- priv->dbus_proxy_system = dbus_g_proxy_new_for_name_owner (priv->system_bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- &error);
- if (error != NULL) {
- g_error("Unable to get dbus proxy on system bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- /* Set up name change signals */
- dbus_g_proxy_add_signal(priv->dbus_proxy_session, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(priv->dbus_proxy_session, "NameOwnerChanged",
- G_CALLBACK(dbus_owner_change), listener, NULL);
- dbus_g_proxy_add_signal(priv->dbus_proxy_system, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(priv->dbus_proxy_system, "NameOwnerChanged",
- G_CALLBACK(dbus_owner_change), listener, NULL);
-
- /* Initialize Data structures */
- 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));
- priv->todo_idle = 0;
-
- /* WARNING */
- /* Starting massive asynchronisity */
- /* */
-
- /* Build todo list */
- org_freedesktop_DBus_list_names_async (priv->dbus_proxy_session, build_todo_list_cb, listener);
- org_freedesktop_DBus_list_names_async (priv->dbus_proxy_system, build_todo_list_cb, listener);
-
- return;
-}
-
-static void
-indicate_listener_finalize (GObject * 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;
-}
-
-IndicateListener *
-indicate_listener_new (void)
-{
- IndicateListener * listener;
- listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
- return listener;
-}
-
-static IndicateListener * default_indicate_listener = NULL;
-
-IndicateListener *
-indicate_listener_ref_default (void)
-{
- if (default_indicate_listener != NULL) {
- g_object_ref(default_indicate_listener);
- } else {
- default_indicate_listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
- g_object_add_weak_pointer(G_OBJECT(default_indicate_listener),
- (gpointer *)&default_indicate_listener);
- }
-
- return default_indicate_listener;
-}
-
-static void
-dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener)
-{
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- DBusGConnection * bus;
- gchar * bus_name;
- if (proxy == priv->dbus_proxy_system) {
- bus = priv->system_bus;
- bus_name = "system";
- } else {
- bus = priv->session_bus;
- bus_name = "session";
- }
-
- /* g_debug("Name change on %s bus: '%s' from '%s' to '%s'", bus_name, name, prev, new); */
-
- if (prev != NULL && prev[0] == '\0') {
- todo_list_add(name, proxy, listener, FALSE);
- }
- if (new != NULL && new[0] == '\0') {
- proxy_t searchitem;
- searchitem.connection = bus;
- 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->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->data);
- }
- }
-
- return;
-}
-
-static void
-proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data)
-{
- gchar * type = (gchar *)key;
- GHashTable * indicators = (GHashTable *)value;
- proxy_t * proxy_data = data;
-
- GList * keys = g_hash_table_get_keys(indicators);
- 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->server, GUINT_TO_POINTER(id), type, TRUE);
- }
- g_list_free(keys);
-
- g_hash_table_remove_all(indicators);
- return;
-}
-
-static void
-proxy_struct_destroy (gpointer data)
-{
- proxy_t * proxy_data = data;
-
- /* TODO: Clear the indicators by signaling */
- if (proxy_data->indicators != NULL) {
- g_hash_table_foreach(proxy_data->indicators,
- proxy_struct_destroy_indicators,
- proxy_data);
- g_hash_table_remove_all(proxy_data->indicators);
-
- g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE);
- proxy_data->indicators = NULL;
- }
-
- if (DBUS_IS_G_PROXY(proxy_data->property_proxy)) {
- g_object_unref(G_OBJECT(proxy_data->property_proxy));
- }
-
- if (DBUS_IS_G_PROXY(proxy_data->proxy)) {
- g_object_unref(G_OBJECT(proxy_data->proxy));
- }
-
- g_free(proxy_data->name);
- if (proxy_data->type != NULL) {
- g_free(proxy_data->type);
- }
- g_free(proxy_data);
-
- return;
-}
-
-static void
-build_todo_list_cb (DBusGProxy * proxy, char ** names, GError * error, void * data)
-{
- IndicateListener * listener = INDICATE_LISTENER(data);
-
- if (error != NULL) {
- g_warning("Unable to get names: %s", error->message);
- return;
- }
-
- guint i = 0;
- for (i = 0; names[i] != NULL; i++) {
- todo_list_add(names[i], proxy, listener, TRUE);
- }
-
- return;
-}
-
-static void
-todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener, gboolean startup)
-{
- if (name == NULL || name[0] != ':') {
- return;
- }
-
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- DBusGConnection * bus;
- gchar * bus_name;
- if (proxy == priv->dbus_proxy_system) {
- bus = priv->system_bus;
- bus_name = "system";
- } else {
- bus = priv->session_bus;
- bus_name = "session";
- }
- /* g_debug ("Adding on %s bus: %s", bus_name, name); */
-
- proxy_todo_t todo;
- todo.name = g_strdup(name);
- todo.bus = bus;
- todo.startup = startup;
-
- g_array_append_val(priv->proxy_todo, todo);
-
- if (priv->todo_idle == 0) {
- priv->todo_idle = g_idle_add(todo_idle, listener);
- }
-
- return;
-}
-
-gboolean
-todo_idle (gpointer data)
-{
- IndicateListener * listener = INDICATE_LISTENER(data);
- if (listener == NULL) {
- g_error("Listener got lost in todo_idle");
- return FALSE;
- }
-
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- if (priv->proxy_todo->len == 0) {
- /* Basically if we have no todo, we need to stop running. This
- * is done this way to make the function error handling simpler
- * and results in an extra run */
- priv->todo_idle = 0;
- return FALSE;
- }
-
- proxy_todo_t * todo = &g_array_index(priv->proxy_todo, proxy_todo_t, priv->proxy_todo->len - 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,
- proxyt->name,
- "/org/freedesktop/indicate",
- "org.freedesktop.indicator");
- proxyt->property_proxy = NULL;
- proxyt->listener = listener;
- proxyt->indicators = NULL;
- 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);
-
- if (proxyt->proxy == NULL) {
- g_warning("Unable to create proxy for %s", proxyt->name);
- return TRUE;
- }
-
- dbus_g_proxy_add_signal(proxyt->proxy, "ServerShow",
- G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow",
- G_CALLBACK(proxy_server_added), proxyt, NULL);
-
- priv->proxies_possible = g_list_prepend(priv->proxies_possible, proxyt);
-
- /* Look through the introspection data to see if this
- is already a server */
- introspect_this (NULL, NULL, NULL, proxyt);
-
- return TRUE;
-}
-
-static void
-get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
-{
- if (type == NULL) {
- /* This is usually caused by an error getting the type,
- * which would mean that this isn't an indicator server */
- return;
- }
-
- proxy_t * proxyt = (proxy_t *)data;
-
- proxy_server_added (proxyt->proxy, type, proxyt);
- org_freedesktop_indicator_get_indicator_list_async(proxyt->proxy, proxy_get_indicator_list, proxyt);
-
- return;
-}
-
-typedef struct {
- guint id;
- proxy_t * proxyt;
-} indicator_type_t;
-
-static void
-proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data)
-{
- if (error != NULL) {
- return;
- }
-
- proxy_t * proxyt = (proxy_t *)data;
-
- int i;
- for (i = 0; i < indicators->len; i++) {
- indicator_type_t * itt = g_new(indicator_type_t, 1);
- itt->id = g_array_index(indicators, guint, i);
- itt->proxyt = proxyt;
-
- org_freedesktop_indicator_get_indicator_property_async(proxyt->proxy, itt->id, "type", proxy_get_indicator_type, itt);
- }
-
- return;
-}
-
-static void
-proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data)
-{
- if (error != NULL) {
- g_warning("Get Indicator Type returned error: %s", error->message);
- return;
- }
-
- indicator_type_t * itt = (indicator_type_t *)data;
- guint id = itt->id;
- proxy_t * proxyt = itt->proxyt;
-
- g_free(itt);
-
- return proxy_indicator_added(proxy, id, type, proxyt);
-}
-
-static void
-proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt)
-{
- if (proxyt->indicators == NULL) {
- proxyt->indicators = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, proxy_indicators_free);
- /* Elevate to working */
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
-
- 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->data);
- }
- 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);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded",
- G_CALLBACK(proxy_indicator_added), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved",
- G_CALLBACK(proxy_indicator_removed), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",
- G_CALLBACK(proxy_indicator_modified), proxyt, NULL);
-
- if (type != NULL) {
- if (proxyt->type != NULL) {
- g_free(proxyt->type);
- }
- proxyt->type = g_strdup(type);
- }
-
- g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE);
- }
-
- return;
-}
-
-static void
-proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt)
-{
- if (proxyt->indicators == NULL) {
- proxy_server_added (proxy, NULL, proxyt);
- }
-
- GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
-
- if (indicators == NULL) {
- indicators = g_hash_table_new(g_direct_hash, g_direct_equal);
- g_hash_table_insert(proxyt->indicators, g_strdup(type), indicators);
- }
-
- 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->server, GUINT_TO_POINTER(id), type, TRUE);
- }
-
- return;
-}
-
-static void
-proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt)
-{
- if (proxyt->indicators == NULL) {
- g_warning("Oddly we had an indicator removed from an interface that we didn't think had indicators.");
- return;
- }
-
- GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
- if (indicators == NULL) {
- g_warning("Can not remove indicator %d of type '%s' as there are no indicators of that type on %s.", id, type, proxyt->name);
- return;
- }
-
- if (!g_hash_table_lookup(indicators, (gpointer)id)) {
- g_warning("No indicator %d of type '%s' on '%s'.", id, type, proxyt->name);
- return;
- }
-
- g_hash_table_remove(indicators, (gpointer)id);
- g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE);
-
- return;
-}
-
-static void
-proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt)
-{
- if (proxyt->indicators == NULL) {
- g_warning("Oddly we had an indicator modified from an interface that we didn't think had indicators.");
- return;
- }
-
- GList * keys = g_hash_table_get_keys(proxyt->indicators);
- GList * inc = NULL;
- gchar * type;
-
- for (inc = g_list_first(keys); inc != NULL; inc = g_list_next(inc)) {
- type = (gchar *)inc->data;
-
- GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
- if (indicators == NULL) continue; /* no indicators for this type? Odd, but not an error */
-
- if (g_hash_table_lookup(indicators, (gpointer)id)) {
- break;
- }
- }
-
- if (inc == NULL) {
- g_warning("Can not modify indicator %d with property '%s' as there are no indicators with that id on %s.", id, property, proxyt->name);
- return;
- }
-
- g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE);
-
- return;
-}
-
-static void
-proxy_indicators_free (gpointer data)
-{
- GHashTable * table = (GHashTable *)data;
-
- if (g_hash_table_size(table) != 0) {
- g_warning("Clearning a set of indicators that wasn't signaled!");
- }
-
- g_hash_table_unref(table);
- return;
-}
-
-typedef enum _get_property_type get_property_type;
-enum _get_property_type {
- PROPERTY_TYPE_STRING,
- PROPERTY_TYPE_TIME
-};
-
-typedef struct _get_property_t get_property_t;
-struct _get_property_t {
- GCallback cb;
- gpointer data;
- IndicateListener * listener;
- IndicateListenerServer * server;
- IndicateListenerIndicator * indicator;
- gchar * property;
- get_property_type type;
-};
-
-static void
-get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer userdata)
-{
- get_property_t * get_property_data = (get_property_t *)userdata;
-
- if (error != NULL) {
- g_warning("Unable to get property data: %s", error->message);
- g_error_free(error);
- return;
- }
-
- switch (get_property_data->type) {
- case PROPERTY_TYPE_STRING: {
- indicate_listener_get_property_cb cb = (indicate_listener_get_property_cb)get_property_data->cb;
- 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_TIME: {
- indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb;
- GTimeVal time;
- if (g_time_val_from_iso8601(OUT_value, &time)) {
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data);
- }
- break;
- }
- }
-
- g_free(get_property_data->property);
- g_free(get_property_data);
-
- return;
-};
-
-static void
-get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type)
-{
- /* 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? */
- get_property_t * get_property_data = g_new(get_property_t, 1);
- get_property_data->cb = callback;
- get_property_data->data = data;
- get_property_data->listener = listener;
- get_property_data->server = server;
- get_property_data->indicator = indicator;
- get_property_data->property = g_strdup(property);
- get_property_data->type = prop_type;
-
- org_freedesktop_indicator_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
- return;
-}
-
-void
-indicate_listener_get_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_cb callback, gpointer data)
-{
- return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_STRING);
-}
-
-void
-indicate_listener_get_property_time (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_time_cb callback, gpointer data)
-{
- return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_TIME);
-}
-
-gboolean
-_indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers)
-{
-
- return TRUE;
-}
-
-static void
-listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
-{
- if (error != NULL) {
- g_warning("Listener display caused an error: %s", error->message);
- }
- return;
-}
-
-void
-indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator)
-{
- org_freedesktop_indicator_show_indicator_to_user_async (server->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), listener_display_cb, NULL);
-
- 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)
-{
- /* g_debug("Callback for property %s %s %s", dbus_g_proxy_get_bus_name(proxy), dbus_g_proxy_get_path(proxy), dbus_g_proxy_get_interface(proxy)); */
- property_cb_t * propertyt = data;
- GError * error = NULL;
-
- GValue property = {0};
-
- 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);
-
- /* g_debug("\tProperty value: %s", propstr); */
-
- 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)
-{
- /* 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 searchitem;
- searchitem.name = server->name;
- searchitem.connection = server->connection;
-
- 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 (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,
- "/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,
- NULL,
- G_TYPE_STRING, "org.freedesktop.indicator",
- G_TYPE_STRING, property_name,
- G_TYPE_INVALID, G_TYPE_VALUE, 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);
-}
-
-const gchar *
-indicate_listener_server_get_dbusname (IndicateListenerServer * server)
-{
- if (server == NULL) return NULL;
- return server->name;
-}
-
-guint
-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.");
- }
-
- return;
-}
-
-void
-indicate_listener_server_show_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
-{
- if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
- return;
- }
-
- 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];
-}
-
-GType
-indicate_listener_server_get_gtype (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_pointer_type_register_static ("IndicateListenerServer");
-
- return our_type;
-}
-
-GType
-indicate_listener_indicator_get_gtype (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_pointer_type_register_static ("IndicateListenerIndicator");
-
- return our_type;
-}
-
-static const gchar * _introspector_path[] = {"", "org", "freedesktop", "indicate", NULL};
-static const gchar * _introspector_fullpath[] = {"/", "/org", "/org/freedesktop", "/org/freedesktop/indicate", NULL};
-static const gchar * _introspector_interface = "org.freedesktop.indicator";
-
-static void
-introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data)
-{
- /* g_debug("Introspect this:\n%s", OUT_data); */
- proxy_t * server = (proxy_t *)data;
- if (proxy != NULL) {
- g_object_unref(proxy);
- }
- if (error != NULL) {
- /* We probably couldn't introspect that far up. That's
- life, it happens. Or there's a timeout, that happens
- too, I guess some apps are too busy for us. */
- /* g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); */
- return;
- }
-
- if (OUT_data != NULL) {
- xmlDocPtr xmldoc;
- /* Parse the XML */
- xmldoc = xmlReadMemory(OUT_data, g_utf8_strlen(OUT_data, 16*1024), "introspection.xml", NULL, 0);
-
- /* Check for root being "node" */
- xmlNodePtr root = xmlDocGetRootElement(xmldoc);
- if (g_strcmp0(root->name, "node") != 0) {
- xmlFreeDoc(xmldoc);
- g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data);
- return;
- }
-
- server->introspect_level += 1;
- const gchar * nodename = NULL;
- const gchar * nameval = NULL;
- if (_introspector_path[server->introspect_level] == NULL) {
- /* We're looking for our interface */
- nodename = "interface";
- nameval = _introspector_interface;
- } else {
- /* We're looking for our next node */
- nodename = "node";
- nameval = _introspector_path[server->introspect_level];
- }
-
- gboolean found = FALSE;
- xmlNodePtr children;
- for (children = root->children; children != NULL; children = children->next) {
- gchar * xmlnameval = NULL;
- if (g_strcmp0(children->name, nodename) == 0) {
- xmlAttrPtr attrib;
- for (attrib = children->properties; attrib != NULL; attrib = attrib->next) {
- if (g_strcmp0(attrib->name, "name") == 0) {
- if (attrib->children != NULL) {
- xmlnameval = attrib->children->content;
- }
- break;
- }
- }
-
- if (!g_strcmp0(nameval, xmlnameval)) {
- found = TRUE;
- break;
- }
- }
- }
-
- xmlFreeDoc(xmldoc);
-
- if (!found) {
- /* Ah, nothing we're interested in */
- return;
- }
-
- if (_introspector_path[server->introspect_level] == NULL) {
- /* If we've found the interface at the end of the tree, whoo! hoo! */
- /* Now we know it's safe to get the type on it */
- indicate_listener_server_get_type(server->listener, &server->server, get_type_cb, server);
- return;
- }
- } else {
- server->introspect_level = 0;
- }
-
- DBusGProxy * newproxy = dbus_g_proxy_new_for_name(server->connection,
- server->name,
- _introspector_fullpath[server->introspect_level],
- DBUS_INTERFACE_INTROSPECTABLE);
-
- org_freedesktop_DBus_Introspectable_introspect_async(newproxy, introspect_this, server);
-
- return;
-}
diff --git a/libindicate/listener.h b/libindicate/listener.h
deleted file mode 100644
index 37cda03..0000000
--- a/libindicate/listener.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_LISTENER_H_INCLUDED__
-#define INDICATE_LISTENER_H_INCLUDED__ 1
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "indicator.h"
-#include "server.h"
-#include "interests.h"
-
-G_BEGIN_DECLS
-
-/* Boilerplate */
-#define INDICATE_TYPE_LISTENER (indicate_listener_get_type ())
-#define INDICATE_LISTENER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), INDICATE_TYPE_LISTENER, IndicateListener))
-#define INDICATE_IS_LISTENER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), INDICATE_TYPE_LISTENER))
-#define INDICATE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), INDICATE_TYPE_LISTENER, IndicateListenerClass))
-#define INDICATE_IS_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), INDICATE_TYPE_LISTENER))
-#define INDICATE_LISTENER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), INDICATE_TYPE_LISTENER, IndicateListenerClass))
-
-#define INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED "indicator-added"
-#define INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED "indicator-removed"
-#define INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"
-#define INDICATE_LISTENER_SIGNAL_SERVER_ADDED "server-added"
-#define INDICATE_LISTENER_SIGNAL_SERVER_REMOVED "server-removed"
-
-#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 struct _IndicateListenerServer IndicateListenerServer;
-#define INDICATE_TYPE_LISTENER_SERVER (indicate_listener_server_get_gtype ())
-GType indicate_listener_server_get_gtype (void) G_GNUC_CONST;
-
-typedef struct _IndicateListenerIndicator IndicateListenerIndicator;
-#define INDICATE_TYPE_LISTENER_INDICATOR (indicate_listener_indicator_get_gtype ())
-GType indicate_listener_indicator_get_gtype (void) G_GNUC_CONST;
-
-typedef struct _IndicateListener IndicateListener;
-struct _IndicateListener {
- GObject parent;
-};
-
-typedef struct _IndicateListenerClass IndicateListenerClass;
-struct _IndicateListenerClass {
- GObjectClass parent;
-
- /* Signals */
- void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);
- void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);
- void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property);
-
- void (* server_added) (IndicateListenerServer * server, gchar * type);
- void (* server_removed) (IndicateListenerServer * server, gchar * type);
-};
-
-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_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * 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);
-IndicateListener * indicate_listener_ref_default (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_get_property_time (IndicateListener * listener,
- IndicateListenerServer * server,
- IndicateListenerIndicator * indicator,
- gchar * property,
- indicate_listener_get_property_time_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);
-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);
-gboolean indicate_listener_server_check_interest (IndicateListener * listener,
- IndicateListenerServer * server,
- IndicateInterests interest);
-
-G_END_DECLS
-
-#endif /* INDICATE_LISTENER_H_INCLUDED__ */
-
diff --git a/libindicate/server-marshal.list b/libindicate/server-marshal.list
deleted file mode 100644
index 540f0fe..0000000
--- a/libindicate/server-marshal.list
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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 <ted@canonical.com>
-#
-# 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
-# <http://www.gnu.org/licenses/>
-#
-# IndicatorAdded
-VOID:UINT,STRING
diff --git a/libindicate/server.c b/libindicate/server.c
deleted file mode 100644
index e1e3479..0000000
--- a/libindicate/server.c
+++ /dev/null
@@ -1,1516 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#include "server.h"
-#include "interests-priv.h"
-#include "server-marshal.h"
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-/* Errors */
-enum {
- NO_GET_DESKTOP,
- NO_GET_INDICATOR_COUNT,
- NO_GET_INDICATOR_COUNT_BY_TYPE,
- NO_GET_INDICATOR_LIST,
- NO_GET_INDICATOR_LIST_BY_TYPE,
- NO_GET_INDICATOR_PROPERTY,
- NO_GET_INDICATOR_PROPERTY_GROUP,
- NO_GET_INDICATOR_PROPERTIES,
- NO_SHOW_INDICATOR_TO_USER,
- INVALID_INDICATOR_ID,
- NO_SHOW_INTEREST,
- NO_REMOVE_INTEREST,
- SHOW_INTEREST_FAILED,
- REMOVE_INTEREST_FAILED,
- LAST_ERROR
-};
-
-/* Signals */
-enum {
- INDICATOR_ADDED,
- INDICATOR_REMOVED,
- INDICATOR_MODIFIED,
- SERVER_SHOW,
- SERVER_HIDE,
- SERVER_DISPLAY,
- INTEREST_ADDED,
- INTEREST_REMOVED,
- LAST_SIGNAL
-};
-
-/* Properties */
-enum {
- PROP_0,
- PROP_DESKTOP,
- PROP_TYPE
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/* Private area */
-typedef struct _IndicateServerPrivate IndicateServerPrivate;
-struct _IndicateServerPrivate
-{
- DBusGConnection *connection;
- DBusGProxy * dbus_proxy;
-
- gchar * path;
- GSList * indicators;
- gboolean visible;
- guint current_id;
- gboolean registered;
-
- gchar * desktop;
- gchar * type;
-
- // 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);
-
-/* Prototypes */
-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, 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);
-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);
-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, 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);
-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, 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);
-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)
-{
- /* g_debug("Server Class Initialized"); */
- GObjectClass * gobj;
- gobj = G_OBJECT_CLASS(class);
-
- g_type_class_add_private (class, sizeof (IndicateServerPrivate));
-
- gobj->finalize = indicate_server_finalize;
- gobj->set_property = set_property;
- gobj->get_property = get_property;
-
- /**
- IndicateServer::indicator-added:
- @arg0: The #IndicateServer object
- @arg1: The #IndicateIndicator ID number
- @arg2: The type of the indicator
-
- Emitted every time that a new indicator is made visible to
- the world. This results in a signal on DBus.
-
- Can be emitted by subclasses using indicate_server_emit_indicator_added()
- */
- signals[INDICATOR_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, indicator_added),
- NULL, NULL,
- _indicate_server_marshal_VOID__UINT_STRING,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
- /**
- IndicateServer::indicator-removed:
- @arg0: The #IndicateServer object
- @arg1: The #IndicateIndicator ID number
- @arg2: The type of the indicator
-
- Emitted every time that a new indicator is made invisible to
- the world. This results in a signal on DBus.
-
- Can be emitted by subclasses using indicate_server_emit_indicator_removed()
- */
- signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, indicator_removed),
- NULL, NULL,
- _indicate_server_marshal_VOID__UINT_STRING,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
- /**
- IndicateServer::indicator-modified:
- @arg0: The #IndicateServer object
- @arg1: The #IndicateIndicator ID number
- @arg2: The name of the property modified
-
- Emitted every time that a property on an indicator changes
- and it is visible to the world. This results in a signal on DBus.
-
- Can be emitted by subclasses using indicate_server_emit_indicator_modified()
- */
- signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, indicator_modified),
- NULL, NULL,
- _indicate_server_marshal_VOID__UINT_STRING,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
- /**
- IndicateServer::server-show:
- @arg0: The #IndicateServer object
- @arg1: The type of the server
-
- Emitted when a server comes onto DBus by being shown. This
- is typically when listeners start reacting to the application's
- indicators. This results in a signal on DBus.
- */
- signals[SERVER_SHOW] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_SHOW,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, server_show),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
- /**
- IndicateServer::server-hide:
- @arg0: The #IndicateServer object
- @arg1: The type of the server
-
- Emitted when a server removes itself from DBus. This results
- in a signal on DBus.
- */
- signals[SERVER_HIDE] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_HIDE,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, server_hide),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
- /**
- IndicateServer::server-display:
- @arg0: The #IndicateServer object
-
- Emitted when a listener signals that the server itself should be
- displayed. This signal is caused by a user clicking on the application
- item in the Messaging Menu. This signal is emitted by DBus.
-
- Can be emitted by subclasses using indicate_server_emit_server_display()
- */
- signals[SERVER_DISPLAY] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, server_display),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- /**
- IndicateServer::interest-added:
- @arg0: The #IndicateServer object
- @arg1: The interest that was added from #IndicateInterests
-
- Emitted when a listener signals that they are interested in
- this server for a particular reason. This signal is emitted by DBus.
- */
- 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);
- /**
- IndicateServer::interest-removed:
- @arg0: The #IndicateServer object
- @arg1: The interest that was removed from #IndicateInterests
-
- Emitted when a listener signals that they are no longer interested in
- this server for a particular reason. This signal is emitted by DBus.
- */
- 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",
- "The desktop file representing this server",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobj, PROP_TYPE,
- g_param_spec_string("type", "Server Type",
- "The type of indicators that this server will provide",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
- &dbus_glib__indicate_server_object_info);
-
- class->get_indicator_count = get_indicator_count;
- class->get_indicator_count_by_type = get_indicator_count_by_type;
- class->get_indicator_list = get_indicator_list;
- class->get_indicator_list_by_type = get_indicator_list_by_type;
- class->get_indicator_property = get_indicator_property;
- class->get_indicator_property_group = get_indicator_property_group;
- 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;
-}
-
-static void
-indicate_server_init (IndicateServer * server)
-{
- /* g_debug("Server Object Initialized"); */
-
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- priv->path = g_strdup("/org/freedesktop/indicate");
- priv->indicators = NULL;
- priv->num_hidden = 0;
- priv->visible = FALSE;
- priv->registered = FALSE;
- priv->current_id = 0;
- 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;
-}
-
-static void
-indicate_server_finalize (GObject * obj)
-{
- IndicateServer * server = INDICATE_SERVER(obj);
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- /* TODO: This probably shouldn't be as far down as finalize, but it's fine here. */
- if (priv->visible) {
- g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
- }
-
- if (priv->path) {
- g_free(priv->path);
- }
- if (priv->desktop) {
- g_free(priv->desktop);
- }
- if (priv->type) {
- g_free(priv->type);
- }
-
- G_OBJECT_CLASS (indicate_server_parent_class)->finalize (obj);
-
- return;
-}
-
-static void
-set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
-{
- g_return_if_fail(G_VALUE_HOLDS_STRING(value));
- g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
-
- gchar ** outstr;
- gchar * tempstr = NULL;
- outstr = &tempstr;
-
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
- switch (id) {
- case PROP_DESKTOP:
- outstr = &(priv->desktop);
- break;
- case PROP_TYPE:
- outstr = &(priv->type);
- break;
- }
-
- if (*outstr != NULL) {
- g_free(*outstr);
- }
-
- *outstr = g_strdup(g_value_get_string(value));
-
- return;
-}
-
-static void
-get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
-{
- g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
-
- gchar * outstr = NULL;
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
- switch (id) {
- case PROP_DESKTOP:
- outstr = priv->desktop;
- break;
- case PROP_TYPE:
- outstr = priv->type;
- break;
- }
-
- if (outstr != NULL) {
- g_value_set_string(value, outstr);
- } else {
- g_value_set_static_string(value, "");
- }
-
- return;
-}
-
-static GQuark
-indicate_server_error_quark (void)
-{
- static GQuark quark = 0;
- if (quark == 0) {
- quark = g_quark_from_static_string (G_LOG_DOMAIN);
- }
- return quark;
-}
-
-/**
- indicate_server_show:
- @server: The #IndicateServer to be shown
-
- This function exports the object onto DBus and shows it
- to the world. This will be the start of it receiving external
- signals from DBus. It is likely that, if there are listeners
- running, there will several #IndicateServer::interest-added
- signals coming shortly after this function. This function
- emits the #IndicateServer::server-added signal across the bus.
-*/
-void
-indicate_server_show (IndicateServer * server)
-{
- g_return_if_fail(INDICATE_IS_SERVER(server));
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- if (priv->visible)
- return;
-
- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-
- 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);
-
- 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;
-}
-
-/**
- indicate_server_hide:
- @server: The #IndicateServer to hide.
-
- This function hides the server from DBus so that it does
- not get signals anymore. This causes the signal #IndicateServer::server-hide
- to be sent across the bus for all listeners. Also internally
- it will signal #IndicateServer::interest-removed for all the
- interests that were currently set for this server.
-*/
-void
-indicate_server_hide (IndicateServer * server)
-{
- g_return_if_fail(INDICATE_IS_SERVER(server));
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- if (!priv->visible)
- return;
-
- priv->visible = FALSE;
-
- /* Delete interested parties */
- g_list_foreach(priv->interestedfolks, (GFunc)indicate_server_interested_folks_destroy, 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);
-
- 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;
-}
-
-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); */
- 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;
- searchitem.sender = (gchar *)name;
- 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->data);
-
- 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;
- /* 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);
- }
- }
-
- g_free(folk);
-
- return;
-}
-
-static guint
-get_next_id (IndicateServer * server)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- priv->current_id++;
- return priv->current_id;
-}
-
-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;
-
- 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, sender);
- priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
- } else {
- folkpointer = (IndicateServerInterestedFolk *)entry->data;
- }
-
- 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;
- }
-
- return TRUE;
-}
-
-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;
-
- 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, sender);
- priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
- } else {
- folkpointer = (IndicateServerInterestedFolk *)entry->data;
- }
-
- indicate_server_interested_folks_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;
- indicate_server_interested_folks_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 interest)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- return priv->interests[interest];
-}
-
-static void
-indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- priv->num_hidden--;
- g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
- return;
-}
-
-static void
-indicator_hide_cb (IndicateIndicator * indicator, IndicateServer * server)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- priv->num_hidden++;
- g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
- return;
-}
-
-static void
-indicator_modified_cb (IndicateIndicator * indicator, gchar * property, IndicateServer * server)
-{
- /* g_debug("Indicator Modified: %d %s", indicate_indicator_get_id(indicator), property); */
- g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, indicate_indicator_get_id(indicator), property, TRUE);
-}
-
-/**
- indicate_server_add_indicator:
- @server: The #IndicateServer to add the #IndicateIndictor to.
- @indicator: The #IndicateIndicator to add.
-
- This function adds an indicator @indicator to the list that are
- watched by the server @server. This means that signals that are
- emitted by the indicator will be picked up and passed via DBus onto
- listeners of the application.
-*/
-void
-indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- 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++;
- } else {
- g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
- }
-
- g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_SHOW, G_CALLBACK(indicator_show_cb), server);
- g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_HIDE, G_CALLBACK(indicator_hide_cb), server);
- g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_MODIFIED, G_CALLBACK(indicator_modified_cb), server);
-
- return;
-}
-
-/**
- indicate_server_remove_indicator:
- @server: The #IndicateServer to remove the #IndicateIndictor from.
- @indicator: The #IndicateIndicator to remove.
-
- Removes an indicator @indicator from being watched by the server @server
- so it's signals are no longer watched and set over DBus.
-*/
-void
-indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator)
-{
- 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);
- } else {
- priv->num_hidden--;
- }
-
- g_signal_handlers_disconnect_by_func(indicator, indicator_show_cb, server);
- g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server);
- g_signal_handlers_disconnect_by_func(indicator, indicator_modified_cb, server);
-
- return;
-}
-
-void
-indicate_server_set_dbus_object (const gchar * obj)
-{
- /* TODO */
-
- return;
-}
-
-/**
- indicate_server_set_desktop_file:
- @server: The #IndicateServer to set the type of
- @path: The new desktop file representing the server
-
- This is a convience function to set the #IndicateServer:desktop
- property of the @server object. The property can also be set
- via traditional means, but this one is easier to read.
-*/
-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;
-}
-
-/**
- indicate_server_set_type:
- @server: The #IndicateServer to set the type of
- @type: The new type of the server
-
- This is a convience function to set the #IndicateServer:type
- property of the @server object. The property can also be set
- via traditional means, but this one is easier to read.
-*/
-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;
-
-/**
- indicate_server_ref_default:
-
- This function will return a reference to the default #IndicateServer
- reference if there is one, or it will create one if one had not
- previously been created. It is recommended that all applications
- use this function to create a #IndicateServer as it ensure that there
- is only one per application.
-
- Return value: A reference to the default #IndicateServer instance.
-*/
-IndicateServer *
-indicate_server_ref_default (void)
-{
- if (default_indicate_server != NULL) {
- g_object_ref(default_indicate_server);
- } else {
- default_indicate_server = g_object_new(INDICATE_TYPE_SERVER, NULL);
- g_object_add_weak_pointer(G_OBJECT(default_indicate_server),
- (gpointer *)&default_indicate_server);
- }
-
- return default_indicate_server;
-}
-
-/**
- indicate_server_set_default:
- @server: The #IndicateServer that should be used
-
- This function is used to set the default #IndicateServer that will
- be used when creating #IndicateIndicators or for anyone else that
- calls indicate_server_ref_default(). Typically this is just an
- instance of #IndicateServer but applications that create a subclass
- of #IndicateServer should set this as well.
-*/
-void
-indicate_server_set_default (IndicateServer * server)
-{
- if (default_indicate_server != NULL) {
- g_warning("Setting a default Indicator Server when one has already been created. I'm not going to destroy that one, but let it live. This may create some odd results if you don't know what you're doing.");
- }
-
- if (server != NULL) {
- default_indicate_server = server;
- g_object_add_weak_pointer(G_OBJECT(default_indicate_server),
- (gpointer *)&default_indicate_server);
- }
-
- return;
-}
-
-static gboolean
-get_indicator_count (IndicateServer * server, guint * count, GError **error)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- guint lstcnt = g_slist_length(priv->indicators);
-
- g_return_val_if_fail(priv->num_hidden < lstcnt, TRUE);
-
- *count = lstcnt - priv->num_hidden;
-
- return TRUE;
-}
-
-typedef struct {
- gchar * type;
- guint count;
-} count_by_t;
-
-static void
-count_by_type (IndicateIndicator * indicator, count_by_t * cbt)
-{
- g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
- if (!indicate_indicator_is_visible(indicator)) {
- return;
- }
-
- const gchar * type = indicate_indicator_get_indicator_type(indicator);
- /* g_debug("Looking for indicator of type '%s' and have type '%s'", cbt->type, type); */
-
- if (type == NULL && cbt->type == NULL) {
- cbt->count++;
- } else if (type == NULL || cbt->type == NULL) {
- } else if (!g_strcmp0(type, cbt->type)) {
- cbt->count++;
- }
-
- return;
-}
-
-static gboolean
-get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
-{
- /* g_debug("get_indicator_count_by_type: '%s'", type); */
- count_by_t cbt;
- cbt.type = type;
- cbt.count = 0;
-
- /* Handle the NULL string case as NULL itself, we're a big
- boy language; we have pointers. */
- if (cbt.type != NULL && cbt.type[0] == '\0') {
- cbt.type = NULL;
- }
-
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- g_slist_foreach(priv->indicators, (GFunc)count_by_type, &cbt);
- *count = cbt.count;
-
- return TRUE;
-}
-
-static gboolean
-get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
-{
- g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
-
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- g_return_val_if_fail(class->get_indicator_count != NULL, TRUE);
-
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- *indicators = g_array_sized_new(FALSE, FALSE, sizeof(guint), g_slist_length(priv->indicators) - priv->num_hidden);
-
- GSList * iter;
- int i;
- for (iter = priv->indicators, i = 0; iter != NULL; iter = iter->next) {
- IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
- if (indicate_indicator_is_visible(indicator)) {
- guint id = indicate_indicator_get_id(indicator);
- g_array_insert_val(*indicators, i++, id);
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
-{
- g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
-
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- g_return_val_if_fail(class->get_indicator_count != NULL, TRUE);
-
- if (type != NULL && type[0] == '\0') {
- type = NULL;
- }
-
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- /* Can't be larger than this and it's not worth the reallocation
- for the small number we have. The memory isn't worth the time. */
- *indicators = g_array_sized_new(FALSE, FALSE, sizeof(guint), g_slist_length(priv->indicators) - priv->num_hidden);
-
- GSList * iter;
- int i;
- for (iter = priv->indicators, i = 0; iter != NULL; iter = iter->next) {
- IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
- if (indicate_indicator_is_visible(indicator)) {
- const gchar * itype = indicate_indicator_get_indicator_type(indicator);
- guint id = indicate_indicator_get_id(indicator);
-
- if (type == NULL && itype == NULL) {
- g_array_insert_val(*indicators, i++, id);
- } else if (type == NULL || itype == NULL) {
- } else if (!g_strcmp0(type, itype)) {
- g_array_insert_val(*indicators, i++, id);
- }
- }
- }
-
- return TRUE;
-}
-
-static IndicateIndicator *
-get_indicator (IndicateServer * server, guint id, GError **error)
-{
- g_return_val_if_fail(INDICATE_IS_SERVER(server), NULL);
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- GSList * iter;
- for (iter = priv->indicators; iter != NULL; iter = iter->next) {
- IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
- if (indicate_indicator_get_id(indicator) == id) {
- return indicator;
- }
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- INVALID_INDICATOR_ID,
- "Invalid Indicator ID: %d",
- id);
- }
- return NULL;
-}
-
-static gboolean
-get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
-{
- IndicateIndicator * indicator = get_indicator(server, id, error);
- if (indicator == NULL) {
- return FALSE;
- }
-
- *value = g_strdup(indicate_indicator_get_property(indicator, property));
- return TRUE;
-}
-
-static gboolean
-get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
-{
- IndicateIndicator * indicator = get_indicator(server, id, error);
- if (indicator == NULL) {
- return FALSE;
- }
-
- GPtrArray * array = g_ptr_array_new();
- int i;
- for (i = 0; i < properties->len; i++) {
- const gchar * val = indicate_indicator_get_property(indicator, g_ptr_array_index(properties, i));
- if (val != NULL) {
- g_ptr_array_add(array, g_strdup(val));
- } else {
- g_ptr_array_add(array, g_strdup(""));
- }
- }
- g_ptr_array_add(array, NULL);
- *value = (gchar **)g_ptr_array_free(array, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
-{
- IndicateIndicator * indicator = get_indicator(server, id, error);
- if (indicator == NULL) {
- return FALSE;
- }
-
- GPtrArray * array = indicate_indicator_list_properties(indicator);
- g_ptr_array_add(array, NULL);
-
- *properties = (gchar **)g_ptr_array_free(array, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
-{
- if (id == INDICATE_SERVER_INDICATOR_NULL) {
- g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE);
- return TRUE;
- }
-
- IndicateIndicator * indicator = get_indicator(server, id, error);
- if (indicator == NULL) {
- return FALSE;
- }
-
- indicate_indicator_user_display(indicator);
- return TRUE;
-}
-
-
-/* Virtual Functions */
-gboolean
-_indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_count != NULL) {
- return class->get_indicator_count (server, count, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_COUNT,
- "get_indicator_count function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_count_by_type != NULL) {
- return class->get_indicator_count_by_type (server, type, count, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_COUNT_BY_TYPE,
- "get_indicator_count_by_type function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_list != NULL) {
- return class->get_indicator_list (server, indicators, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_LIST,
- "get_indicator_list function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_list_by_type != NULL) {
- return class->get_indicator_list_by_type (server, type, indicators, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_LIST_BY_TYPE,
- "get_indicator_list_by_type function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_property != NULL) {
- return class->get_indicator_property (server, id, property, value, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_PROPERTY,
- "get_indicator_property function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_property_group != NULL) {
- return class->get_indicator_property_group (server, id, properties, value, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_PROPERTY_GROUP,
- "get_indicator_property_group function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_indicator_properties != NULL) {
- return class->get_indicator_properties (server, id, properties, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_INDICATOR_PROPERTIES,
- "get_indicator_properties function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-_indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->show_indicator_to_user != NULL) {
- return class->show_indicator_to_user (server, id, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_SHOW_INDICATOR_TO_USER,
- "show_indicator_to_user function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- indicate_server_get_next_id:
- @server: The #IndicateServer the ID will be on
-
- Returns the next available unused ID that an indicator
- can have.
-
- Return value: A valid indicator ID.
-*/
-guint
-indicate_server_get_next_id (IndicateServer * server)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->get_next_id != NULL) {
- return class->get_next_id (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, DBusGMethodInvocation * method)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- 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;
- } 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;
- }
- }
-
- 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, DBusGMethodInvocation * method)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- 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;
- } 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;
- }
- }
-
- 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;
-}
-
-/**
- indicate_server_check_interest:
- @server: The #IndicateServer being checked
- @interest: Which interest type we're checking for
-
- This function looks at all the interest that various listeners
- have specified that they have for this server and returns whether
- there is a listener that has the interest specified in @interest.
-
- Return value: %TRUE if a listener as the interest otherwise %FALSE
-*/
-gboolean
-indicate_server_check_interest (IndicateServer * server, IndicateInterests interest)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL && class->check_interest != NULL) {
- return class->check_interest (server, interest);
- }
-
- g_warning("check_interest function not implemented in this server class: %s", G_OBJECT_TYPE_NAME(server));
- return FALSE;
-}
-
-/* Signal emission functions for sub-classes of the server */
-
-/**
- indicate_server_emit_indicator_added:
- @server: The #IndicateServer being represented
- @id: The ID of the indicator being added
- @type: The type of the indicator
-
- This function emits the #IndicateServer::indicator-added signal and is
- used by subclasses.
-*/
-void
-indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type)
-{
- g_return_if_fail (INDICATE_IS_SERVER (server));
- g_return_if_fail (type);
-
- g_signal_emit(server, signals[INDICATOR_ADDED], 0, id, type);
-}
-
-/**
- indicate_server_emit_indicator_removed:
- @server: The #IndicateServer being represented
- @id: The ID of the indicator being removed
- @type: The type of the indicator
-
- This function emits the #IndicateServer::indicator-removed signal and is
- used by subclasses.
-*/
-void
-indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type)
-{
- g_return_if_fail (INDICATE_IS_SERVER (server));
- g_return_if_fail (type);
-
- g_signal_emit(server, signals[INDICATOR_REMOVED], 0, id, type);
-}
-
-/**
- indicate_server_emit_indicator_modified:
- @server: The #IndicateServer being represented
- @id: The ID of the indicator with the modified property
- @property: The name of the property being modified
-
- This function emits the #IndicateServer::indicator-modified signal and is
- used by subclasses.
-*/
-void
-indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property)
-{
- g_return_if_fail (INDICATE_IS_SERVER (server));
- g_return_if_fail (property);
-
- g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, id, property);
-}
-
-/**
- indicate_server_emit_server_display:
- @server: The #IndicateServer being displayed
-
- This function emits the #IndicateServer::server-display signal and is
- used by subclasses.
-*/
-void
-indicate_server_emit_server_display (IndicateServer *server)
-{
- g_return_if_fail (INDICATE_IS_SERVER (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, gchar * sender)
-{
- folk->sender = g_strdup(sender);
-
- 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;
-}
-
-static void
-indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk)
-{
- g_free(folk->sender);
- g_free(folk);
- return;
-}
-/* *** End Folks *** */
diff --git a/libindicate/server.h b/libindicate/server.h
deleted file mode 100644
index cff76c4..0000000
--- a/libindicate/server.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
-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 <ted@canonical.com>
-
-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
-<http://www.gnu.org/licenses/>
-*/
-
-#ifndef INDICATE_SERVER_H_INCLUDED__
-#define INDICATE_SERVER_H_INCLUDED__ 1
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "interests.h"
-
-G_BEGIN_DECLS
-
-/* Boilerplate */
-#define INDICATE_TYPE_SERVER (indicate_server_get_type ())
-#define INDICATE_SERVER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), INDICATE_TYPE_SERVER, IndicateServer))
-#define INDICATE_IS_SERVER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), INDICATE_TYPE_SERVER))
-#define INDICATE_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), INDICATE_TYPE_SERVER, IndicateServerClass))
-#define INDICATE_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), INDICATE_TYPE_SERVER))
-#define INDICATE_SERVER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), INDICATE_TYPE_SERVER, IndicateServerClass))
-
-#define INDICATE_SERVER_INDICATOR_NULL (0)
-
-#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED "indicator-added"
-#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED "indicator-removed"
-#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"
-#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_INTEREST_ADDED "interest-added"
-#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed"
-
-/**
- IndicateServer:
-
- This is the object that represents the overall connection
- between this application and DBus. It acts as the proxy for
- incomming DBus calls and also sends the appropriate signals
- on DBus for events happening on other objects locally. It
- provides some settings that effection how the application as
- a whole is perceived by listeners of the indicator protocol.
-*/
-typedef struct _IndicateServer IndicateServer;
-struct _IndicateServer {
- GObject parent;
-};
-
-#include "indicator.h"
-
-/**
- IndicateServerClass:
- @parent: Parent Class
- @indicator_added: Slot for #IndicateServer::indicator-added.
- @indicator_removed: Slot for #IndicateServer::indicator-removed.
- @indicator_modified: Slot for #IndicateServer::indicator-modified.
- @server_show: Slot for #IndicateServer::server-show.
- @server_hide: Slot for #IndicateServer::server-hide.
- @server_display: Slot for #IndicateServer::server-display.
- @interest_added: Slot for #IndicateServer::interest-added.
- @interest_removed: Slot for #IndicateServer::interest-removed.
- @get_indicator_count: Returns the number of indicators that are visible
- on the bus. Hidden indicators should not be counted.
- @get_indicator_count_by_type: Returns the number of indicators that are
- of a given type and visible on the bus.
- @get_indicator_list: List all of the indicators that are visible.
- @get_indicator_list_by_type: List all of the indicators of a given
- type that are visible.
- @get_indicator_property: Get a property from a particular indicator.
- @get_indicator_property_group: Get the values for a set of properties
- as an array of entries, returning an array as well.
- @get_indicator_properties: Get a list of all the properties that are
- on a particular indicator.
- @show_indicator_to_user: Respond to someone on the bus asking to show
- a particular indicator to the user.
- @get_next_id: Get the next unused indicator ID.
- @show_interest: React to someone signifying that they are interested
- in this server.
- @remove_interest: Someone on the bus is no longer interest in this
- server, remove it's interest.
- @check_interest: Check to see if anyone on the bus is interested in this
- server for a particular feature.
- @indicate_server_reserved1: Reserved for future use
- @indicate_server_reserved2: Reserved for future use
- @indicate_server_reserved3: Reserved for future use
- @indicate_server_reserved4: Reserved for future use
-
- All of the functions and signals that make up the server class
- including those that are public API to the application and those
- that are public API to all of DBus. Subclasses may need to
- implement a large portion of these.
-*/
-typedef struct _IndicateServerClass IndicateServerClass;
-struct _IndicateServerClass {
- GObjectClass parent;
-
- /* Signals */
- void (* indicator_added) (IndicateServer * server, guint id, gchar * type);
- void (* indicator_removed) (IndicateServer * server, guint id, gchar * type);
- void (* indicator_modified) (IndicateServer * server, guint id, gchar * property);
- void (* server_show) (IndicateServer * server, gchar * type);
- void (* server_hide) (IndicateServer * server, gchar * type);
- void (* server_display) (IndicateServer * server);
- 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);
- 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, 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);
- gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error);
- guint (*get_next_id) (IndicateServer * server);
- 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);
- void (*indicate_server_reserved2)(void);
- void (*indicate_server_reserved3)(void);
- void (*indicate_server_reserved4)(void);
-};
-
-GType indicate_server_get_type (void) G_GNUC_CONST;
-
-/* Sets the object. By default this is /org/freedesktop/indicators */
-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 (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
- * reason the app wanted to hide all it's indicators, this is a
- * sure fire way to do so. No idea why, but I'm sure I'll learn. */
-void indicate_server_show (IndicateServer * server);
-void indicate_server_hide (IndicateServer * server);
-
-guint indicate_server_get_next_id (IndicateServer * server);
-void indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator);
-void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator);
-
-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, IndicateInterests interest);
-
-
-/* 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);
-void indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property);
-void indicate_server_emit_server_display (IndicateServer *server);
-
-/**
- SECTION:server
- @short_description: The representation of the application on DBus.
- @stability: Unstable
- @include: libindicate/server.h
-
- The server object is the object that provides the functions on
- to DBus for other applications to call. It does this by implementing
- the DBus indicator spec, but it also allows for subclassing so that
- subclasses don't have to worry about the DBus-isms as much as
- the functionality that they're trying to express.
-
- For simple applications there is limited need to set anything
- more than the desktop file and the type of the server using
- indicate_server_set_desktop_file() and indicate_server_set_type().
- Each of these function sets the respective value and expresses
- it in a way that other applications on the bus can read it.
-
- More advanced applications might find the need to subclass the
- #IndicateServer object and make their own. This is likely the
- case where applications have complex data stores that they don't
- want to turn into a large set of #GObjects that can take up a
- significant amount of memory in the program.
-
- In general, it is recommended that application authors go with
- the high memory path first, and then optimize by implementing
- their server on a second pass.
-*/
-
-G_END_DECLS
-
-#endif /* INDICATE_SERVER_H_INCLUDED__ */
-