From 15995b7acd5a51c03298c9c671dd82718921ad4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 28 Oct 2009 16:55:18 -0500 Subject: Adding a description for the indicator service. --- libindicator/indicator-service.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 libindicator/indicator-service.xml (limited to 'libindicator') diff --git a/libindicator/indicator-service.xml b/libindicator/indicator-service.xml new file mode 100644 index 0000000..d876ea8 --- /dev/null +++ b/libindicator/indicator-service.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 606b4939df9845c82d92029abfe8403eb891a26b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 28 Oct 2009 16:58:19 -0500 Subject: Building ourselves a little dbus spec --- libindicator/Makefile.am | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libindicator') diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index db45f3c..6061ad8 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -1,3 +1,5 @@ +BUILT_SOURCES = +CLEANFILES = EXTRA_DIST = \ indicator.pc.in @@ -27,3 +29,31 @@ libindicator_la_LIBADD = \ pkgconfig_DATA = indicator.pc pkgconfigdir = $(libdir)/pkgconfig +################################## +# DBus Specs +################################## + +DBUS_SPECS = \ + indicator-service.xml + +%-client.h: %.xml + dbus-binding-tool \ + --prefix=_$(subst -,_,$(<:.xml=))_client \ + --mode=glib-client \ + --output=$@ \ + $< + +%-server.h: %.xml + dbus-binding-tool \ + --prefix=_$(subst -,_,$(<:.xml=))_server \ + --mode=glib-server \ + --output=$@ \ + $< + +BUILT_SOURCES += \ + $(DBUS_SPECS:.xml=-client.h) \ + $(DBUS_SPECS:.xml=-server.h) + +CLEANFILES += $(BUILT_SOURCES) + +EXTRA_DIST += $(DBUS_SPECS) -- cgit v1.2.3 From ba8af8211f01a5c470ac30275e907bc5a26be910 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 09:27:05 -0500 Subject: Putting in some templated objects. --- libindicator/Makefile.am | 8 +++-- libindicator/indicator-service-manager.c | 57 +++++++++++++++++++++++++++++++ libindicator/indicator-service-manager.h | 32 ++++++++++++++++++ libindicator/indicator-service.c | 58 ++++++++++++++++++++++++++++++++ libindicator/indicator-service.h | 33 ++++++++++++++++++ 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 libindicator/indicator-service-manager.c create mode 100644 libindicator/indicator-service-manager.h create mode 100644 libindicator/indicator-service.c create mode 100644 libindicator/indicator-service.h (limited to 'libindicator') diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 6061ad8..cce87ca 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -7,7 +7,9 @@ libindicatorincludedir=$(includedir)/libindicator-0.1/libindicator indicator_headers = \ indicator.h \ - indicator-object.h + indicator-object.h \ + indicator-service.h \ + indicator-service-manager.h libindicatorinclude_HEADERS = \ $(indicator_headers) @@ -17,7 +19,9 @@ lib_LTLIBRARIES = \ libindicator_la_SOURCES = \ $(indicator_headers) \ - indicator-object.c + indicator-object.c \ + indicator-service.c \ + indicator-service-manager.c libindicator_la_CFLAGS = \ $(LIBINDICATOR_CFLAGS) \ diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c new file mode 100644 index 0000000..6fd9a5b --- /dev/null +++ b/libindicator/indicator-service-manager.c @@ -0,0 +1,57 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "indicator-service-manager.h" + +typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; +struct _IndicatorServiceManagerPrivate { + int dummy; +}; + +#define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerPrivate)) + +static void indicator_service_manager_class_init (IndicatorServiceManagerClass *klass); +static void indicator_service_manager_init (IndicatorServiceManager *self); +static void indicator_service_manager_dispose (GObject *object); +static void indicator_service_manager_finalize (GObject *object); + +G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT); + +static void +indicator_service_manager_class_init (IndicatorServiceManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (IndicatorServiceManagerPrivate)); + + object_class->dispose = indicator_service_manager_dispose; + object_class->finalize = indicator_service_manager_finalize; + + + return; +} + +static void +indicator_service_manager_init (IndicatorServiceManager *self) +{ + + return; +} + +static void +indicator_service_manager_dispose (GObject *object) +{ + + G_OBJECT_CLASS (indicator_service_manager_parent_class)->dispose (object); + return; +} + +static void +indicator_service_manager_finalize (GObject *object) +{ + + G_OBJECT_CLASS (indicator_service_manager_parent_class)->finalize (object); + return; +} diff --git a/libindicator/indicator-service-manager.h b/libindicator/indicator-service-manager.h new file mode 100644 index 0000000..61c6e64 --- /dev/null +++ b/libindicator/indicator-service-manager.h @@ -0,0 +1,32 @@ +#ifndef __INDICATOR_SERVICE_MANAGER_H__ +#define __INDICATOR_SERVICE_MANAGER_H__ + +#include +#include + +G_BEGIN_DECLS + +#define INDICATOR_SERVICE_MANAGER_TYPE (indicator_service_manager_get_type ()) +#define INDICATOR_SERVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManager)) +#define INDICATOR_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerClass)) +#define IS_INDICATOR_SERVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_MANAGER_TYPE)) +#define IS_INDICATOR_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_MANAGER_TYPE)) +#define INDICATOR_SERVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerClass)) + +typedef struct _IndicatorServiceManager IndicatorServiceManager; +typedef struct _IndicatorServiceManagerClass IndicatorServiceManagerClass; + +struct _IndicatorServiceManagerClass { + GObjectClass parent_class; + +}; + +struct _IndicatorServiceManager { + GObject parent; +}; + +GType indicator_service_manager_get_type (void); + +G_END_DECLS + +#endif diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c new file mode 100644 index 0000000..089c9ad --- /dev/null +++ b/libindicator/indicator-service.c @@ -0,0 +1,58 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "indicator-service.h" + +typedef struct _IndicatorServicePrivate IndicatorServicePrivate; + +struct _IndicatorServicePrivate { + int dummy; +}; + +#define INDICATOR_SERVICE_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SERVICE_TYPE, IndicatorServicePrivate)) + +static void indicator_service_class_init (IndicatorServiceClass *klass); +static void indicator_service_init (IndicatorService *self); +static void indicator_service_dispose (GObject *object); +static void indicator_service_finalize (GObject *object); + +G_DEFINE_TYPE (IndicatorService, indicator_service, G_TYPE_OBJECT); + +static void +indicator_service_class_init (IndicatorServiceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (IndicatorServicePrivate)); + + object_class->dispose = indicator_service_dispose; + object_class->finalize = indicator_service_finalize; + + + return; +} + +static void +indicator_service_init (IndicatorService *self) +{ + + return; +} + +static void +indicator_service_dispose (GObject *object) +{ + + G_OBJECT_CLASS (indicator_service_parent_class)->dispose (object); + return; +} + +static void +indicator_service_finalize (GObject *object) +{ + + G_OBJECT_CLASS (indicator_service_parent_class)->finalize (object); + return; +} diff --git a/libindicator/indicator-service.h b/libindicator/indicator-service.h new file mode 100644 index 0000000..0cec28c --- /dev/null +++ b/libindicator/indicator-service.h @@ -0,0 +1,33 @@ +#ifndef __INDICATOR_SERVICE_H__ +#define __INDICATOR_SERVICE_H__ + +#include +#include + +G_BEGIN_DECLS + +#define INDICATOR_SERVICE_TYPE (indicator_service_get_type ()) +#define INDICATOR_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SERVICE_TYPE, IndicatorService)) +#define INDICATOR_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_SERVICE_TYPE, IndicatorServiceClass)) +#define IS_INDICATOR_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_TYPE)) +#define IS_INDICATOR_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_TYPE)) +#define INDICATOR_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_TYPE, IndicatorServiceClass)) + +typedef struct _IndicatorService IndicatorService; +typedef struct _IndicatorServiceClass IndicatorServiceClass; + +struct _IndicatorServiceClass { + GObjectClass parent_class; + +}; + +struct _IndicatorService { + GObject parent; + +}; + +GType indicator_service_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From b8db81899bc6903c7c1a21b434caaa862c29ea32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 09:33:21 -0500 Subject: Making 'INDICATOR' the prefix for the objects. --- libindicator/indicator-object.c | 6 +++--- libindicator/indicator-object.h | 4 ++-- libindicator/indicator-service-manager.h | 4 ++-- libindicator/indicator-service.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 5921ce5..ed9214c 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -246,7 +246,7 @@ unrefandout: GtkLabel * indicator_object_get_label (IndicatorObject * io) { - g_return_val_if_fail(IS_INDICATOR_OBJECT(io), NULL); + g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL); IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(io); return priv->label; } @@ -264,7 +264,7 @@ indicator_object_get_label (IndicatorObject * io) GtkImage * indicator_object_get_icon (IndicatorObject * io) { - g_return_val_if_fail(IS_INDICATOR_OBJECT(io), NULL); + g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL); IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(io); return priv->icon; } @@ -282,7 +282,7 @@ indicator_object_get_icon (IndicatorObject * io) GtkMenu * indicator_object_get_menu (IndicatorObject * io) { - g_return_val_if_fail(IS_INDICATOR_OBJECT(io), NULL); + g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL); IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(io); return priv->menu; } diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index cb01b85..ea3f52e 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -31,8 +31,8 @@ G_BEGIN_DECLS #define INDICATOR_OBJECT_TYPE (indicator_object_get_type ()) #define INDICATOR_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_OBJECT_TYPE, IndicatorObject)) #define INDICATOR_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_OBJECT_TYPE, IndicatorObjectClass)) -#define IS_INDICATOR_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_OBJECT_TYPE)) -#define IS_INDICATOR_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_OBJECT_TYPE)) +#define INDICATOR_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_OBJECT_TYPE)) +#define INDICATOR_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_OBJECT_TYPE)) #define INDICATOR_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_OBJECT_TYPE, IndicatorObjectClass)) typedef struct _IndicatorObject IndicatorObject; diff --git a/libindicator/indicator-service-manager.h b/libindicator/indicator-service-manager.h index 61c6e64..f2e4d75 100644 --- a/libindicator/indicator-service-manager.h +++ b/libindicator/indicator-service-manager.h @@ -9,8 +9,8 @@ G_BEGIN_DECLS #define INDICATOR_SERVICE_MANAGER_TYPE (indicator_service_manager_get_type ()) #define INDICATOR_SERVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManager)) #define INDICATOR_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerClass)) -#define IS_INDICATOR_SERVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_MANAGER_TYPE)) -#define IS_INDICATOR_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_MANAGER_TYPE)) +#define INDICATOR_IS_SERVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_MANAGER_TYPE)) +#define INDICATOR_IS_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_MANAGER_TYPE)) #define INDICATOR_SERVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerClass)) typedef struct _IndicatorServiceManager IndicatorServiceManager; diff --git a/libindicator/indicator-service.h b/libindicator/indicator-service.h index 0cec28c..48f1d81 100644 --- a/libindicator/indicator-service.h +++ b/libindicator/indicator-service.h @@ -9,8 +9,8 @@ G_BEGIN_DECLS #define INDICATOR_SERVICE_TYPE (indicator_service_get_type ()) #define INDICATOR_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SERVICE_TYPE, IndicatorService)) #define INDICATOR_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_SERVICE_TYPE, IndicatorServiceClass)) -#define IS_INDICATOR_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_TYPE)) -#define IS_INDICATOR_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_TYPE)) +#define INDICATOR_IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SERVICE_TYPE)) +#define INDICATOR_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_TYPE)) #define INDICATOR_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_TYPE, IndicatorServiceClass)) typedef struct _IndicatorService IndicatorService; -- cgit v1.2.3 From 0af9206bc55a78a2e39ba86b07450a15ed399eee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 09:56:39 -0500 Subject: Defining some API and boot strapping documentation. --- libindicator/indicator-service-manager.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.h b/libindicator/indicator-service-manager.h index f2e4d75..127d56b 100644 --- a/libindicator/indicator-service-manager.h +++ b/libindicator/indicator-service-manager.h @@ -13,20 +13,51 @@ G_BEGIN_DECLS #define INDICATOR_IS_SERVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_MANAGER_TYPE)) #define INDICATOR_SERVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerClass)) +#define INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE "connection-change" + typedef struct _IndicatorServiceManager IndicatorServiceManager; typedef struct _IndicatorServiceManagerClass IndicatorServiceManagerClass; +/** + IndicatorServiceManagerClass: + @parent: #GObjectClass + @connection_changed: Slot for #IndicatorServiceManager::connection-changed. + @indicator_service_manager_reserved1: Reserved for future use. + @indicator_service_manager_reserved2: Reserved for future use. + @indicator_service_manager_reserved3: Reserved for future use. + @indicator_service_manager_reserved4: Reserved for future use. + +*/ struct _IndicatorServiceManagerClass { GObjectClass parent_class; + /* Signals */ + void (*connection_change) (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); + + /* Buffer */ + void (*indicator_service_manager_reserved1) (void); + void (*indicator_service_manager_reserved2) (void); + void (*indicator_service_manager_reserved3) (void); + void (*indicator_service_manager_reserved4) (void); }; +/** + IndicatorServiceManager: + @parent: #GObject + +*/ struct _IndicatorServiceManager { GObject parent; + }; GType indicator_service_manager_get_type (void); +IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name); +gboolean indicator_service_manager_connected (IndicatorServiceManager * sm); +void indicator_service_manager_set_refresh (IndicatorServiceManager * sm, + guint time_in_ms); + G_END_DECLS #endif -- cgit v1.2.3 From b60a7f11342b8711e4bea8a51cc558d30ebbb293 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 10:49:12 -0500 Subject: Adding basic interfaces and docs to IndicatorService --- libindicator/indicator-service.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.h b/libindicator/indicator-service.h index 48f1d81..63c3f4b 100644 --- a/libindicator/indicator-service.h +++ b/libindicator/indicator-service.h @@ -13,14 +13,39 @@ G_BEGIN_DECLS #define INDICATOR_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SERVICE_TYPE)) #define INDICATOR_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SERVICE_TYPE, IndicatorServiceClass)) +#define INDICATOR_SERVICE_SIGNAL_SHUTDOWN "shutdown" + typedef struct _IndicatorService IndicatorService; typedef struct _IndicatorServiceClass IndicatorServiceClass; +/** + IndicatorServiceClass: + @parent_class: #GObjectClass + @shutdown: Slot for IndicatorServiceClass::shutdown + @indicator_service_reserved1: Reserved for future use + @indicator_service_reserved2: Reserved for future use + @indicator_service_reserved3: Reserved for future use + @indicator_service_reserved4: Reserved for future use + +*/ struct _IndicatorServiceClass { GObjectClass parent_class; - + + /* Signals */ + void (*shutdown) (IndicatorService * service, gpointer user_data); + + /* Reserved */ + void (*indicator_service_reserved1) (void); + void (*indicator_service_reserved2) (void); + void (*indicator_service_reserved3) (void); + void (*indicator_service_reserved4) (void); }; +/** + IndicatorService: + @parent: #GObject + +*/ struct _IndicatorService { GObject parent; @@ -28,6 +53,8 @@ struct _IndicatorService { GType indicator_service_get_type (void); +IndicatorService * inidcator_service_new (gchar * name); + G_END_DECLS #endif -- cgit v1.2.3 From ec0809ed60a94f582ad7111a992fa0f60e493016 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 11:33:37 -0500 Subject: Putting a dummy implementation in for _new for linking --- libindicator/indicator-service.c | 8 ++++++++ libindicator/indicator-service.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 089c9ad..7a1fa8a 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -56,3 +56,11 @@ indicator_service_finalize (GObject *object) G_OBJECT_CLASS (indicator_service_parent_class)->finalize (object); return; } + +IndicatorService * +indicator_service_new (gchar * name) +{ + GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE, NULL); + + return INDICATOR_SERVICE(obj); +} diff --git a/libindicator/indicator-service.h b/libindicator/indicator-service.h index 63c3f4b..b47a91a 100644 --- a/libindicator/indicator-service.h +++ b/libindicator/indicator-service.h @@ -53,7 +53,7 @@ struct _IndicatorService { GType indicator_service_get_type (void); -IndicatorService * inidcator_service_new (gchar * name); +IndicatorService * indicator_service_new (gchar * name); G_END_DECLS -- cgit v1.2.3 From 621a7ba6b53826e95011940b90d9bf8a684534b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 13:13:07 -0500 Subject: Adding the shutdown signal --- libindicator/indicator-service.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 7a1fa8a..5a252f8 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -4,12 +4,21 @@ #include "indicator-service.h" +/* Private Stuff */ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; struct _IndicatorServicePrivate { int dummy; }; +/* Signals Stuff */ +enum { + SHUTDOWN, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + #define INDICATOR_SERVICE_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SERVICE_TYPE, IndicatorServicePrivate)) @@ -30,6 +39,22 @@ indicator_service_class_init (IndicatorServiceClass *klass) object_class->dispose = indicator_service_dispose; object_class->finalize = indicator_service_finalize; + /* Signals */ + + /** + IndicatorService::shutdown: + @arg0: The #IndicatorService object + + Signaled when the service should shutdown as no one + is listening anymore. + */ + signals[SHUTDOWN] = g_signal_new (INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicatorServiceClass, shutdown), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); return; } -- cgit v1.2.3 From fbb2bc9cf94cb7a89856a8820f26f9311985fcc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 13:45:37 -0500 Subject: Adding in the 'name' property --- libindicator/indicator-service.c | 88 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 5a252f8..64aa986 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -19,6 +19,18 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +/* Properties */ +/* Enum for the properties so that they can be quickly + found and looked up. */ +enum { + PROP_0, + PROP_NAME, +}; + +/* The strings so that they can be slowly looked up. */ +#define PROP_NAME_S "name" + +/* GObject Stuff */ #define INDICATOR_SERVICE_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SERVICE_TYPE, IndicatorServicePrivate)) @@ -27,6 +39,10 @@ static void indicator_service_init (IndicatorService *self); static void indicator_service_dispose (GObject *object); static void indicator_service_finalize (GObject *object); +/* Other prototypes */ +static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); +static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); + G_DEFINE_TYPE (IndicatorService, indicator_service, G_TYPE_OBJECT); static void @@ -39,6 +55,18 @@ indicator_service_class_init (IndicatorServiceClass *klass) object_class->dispose = indicator_service_dispose; object_class->finalize = indicator_service_finalize; + /* Property funcs */ + object_class->set_property = set_property; + object_class->get_property = get_property; + + /* Properties */ + g_object_class_install_property(object_class, PROP_NAME, + g_param_spec_string(PROP_NAME_S, + "The DBus name for this service", + "This is the name that should be used on DBus for this service.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /* Signals */ /** @@ -82,10 +110,68 @@ indicator_service_finalize (GObject *object) return; } +static void +set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +{ + IndicatorService * self = INDICATOR_SERVICE(object); + g_return_if_fail(self != NULL); + + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + switch (prop_id) { + /* *********************** */ + case PROP_NAME: + break; + /* *********************** */ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + return; +} + +static void +get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +{ + IndicatorService * self = INDICATOR_SERVICE(object); + g_return_if_fail(self != NULL); + + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + switch (prop_id) { + /* *********************** */ + case PROP_NAME: + break; + /* *********************** */ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + return; +} + +/** + indicator_service_new: + @name: The name for the service on dbus + + This function creates the service on DBus and tries to + get a well-known name specified in @name. If the name + can't be estabilished then the #IndicatorService::shutdown + signal will be sent. + + Return value: A brand new #IndicatorService object or #NULL + if there is an error. +*/ IndicatorService * indicator_service_new (gchar * name) { - GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE, NULL); + GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE, + PROP_NAME_S, name, + NULL); return INDICATOR_SERVICE(obj); } -- cgit v1.2.3 From 145b214353d592e234387d03fbcabab28b14b34b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 14:55:25 -0500 Subject: Filling in more of the name property. --- libindicator/indicator-service.c | 54 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 64aa986..ecbb238 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -1,6 +1,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include #include "indicator-service.h" @@ -8,7 +9,7 @@ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; struct _IndicatorServicePrivate { - int dummy; + gchar * name; }; /* Signals Stuff */ @@ -42,6 +43,7 @@ static void indicator_service_finalize (GObject *object); /* Other prototypes */ static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static void try_and_get_name (IndicatorService * service); G_DEFINE_TYPE (IndicatorService, indicator_service, G_TYPE_OBJECT); @@ -90,6 +92,9 @@ indicator_service_class_init (IndicatorServiceClass *klass) static void indicator_service_init (IndicatorService *self) { + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(self); + + priv->name = NULL; return; } @@ -105,6 +110,11 @@ indicator_service_dispose (GObject *object) static void indicator_service_finalize (GObject *object) { + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object); + + if (priv->name) { + g_free(priv->name); + } G_OBJECT_CLASS (indicator_service_parent_class)->finalize (object); return; @@ -122,6 +132,16 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec switch (prop_id) { /* *********************** */ case PROP_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + if (priv->name != NULL) { + g_error("Name can not be set twice!"); + return; + } + priv->name = g_value_dup_string(value); + try_and_get_name(self); + } else { + g_warning("Name is a string bud."); + } break; /* *********************** */ default: @@ -144,6 +164,11 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe switch (prop_id) { /* *********************** */ case PROP_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_string(value, priv->name); + } else { + g_warning("Name is a string bud."); + } break; /* *********************** */ default: @@ -154,6 +179,33 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe return; } +static void +try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data) +{ + IndicatorService * service = INDICATOR_SERVICE(data); + g_return_if_fail(service != NULL); + + +} + +static void +try_and_get_name (IndicatorService * service) +{ + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service); + /* g_return_if_fail(priv->dbus_proxy != NULL); */ + g_return_if_fail(priv->name != NULL); + + org_freedesktop_DBus_request_name_async(/* priv->dbus_proxy, */ NULL, + priv->name, + 0, + try_and_get_name_cb, + service); + + return; +} + +/* API */ + /** indicator_service_new: @name: The name for the service on dbus -- cgit v1.2.3 From f99a9f269a702b2db3f96e1b6740e9eceb6b9ca8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 15:24:49 -0500 Subject: Building ourselves a DBus proxy. --- libindicator/indicator-service.c | 43 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index ecbb238..9b7e885 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -10,6 +10,7 @@ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; struct _IndicatorServicePrivate { gchar * name; + DBusGProxy * dbus_proxy; }; /* Signals Stuff */ @@ -94,7 +95,29 @@ indicator_service_init (IndicatorService *self) { IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(self); + /* Get the private variables in a decent state */ priv->name = NULL; + priv->dbus_proxy = NULL; + + /* Start talkin' dbus */ + GError * error = NULL; + DBusGConnection * 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->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_error("Unable to get the proxy to DBus: %s", error->message); + g_error_free(error); + return; + } return; } @@ -102,6 +125,12 @@ indicator_service_init (IndicatorService *self) static void indicator_service_dispose (GObject *object) { + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object); + + if (priv->dbus_proxy != NULL) { + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } G_OBJECT_CLASS (indicator_service_parent_class)->dispose (object); return; @@ -185,19 +214,27 @@ try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer IndicatorService * service = INDICATOR_SERVICE(data); g_return_if_fail(service != NULL); + if (status != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && status != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) { + /* The already owner seems like it shouldn't ever + happen, but I have a hard time throwing an error + on it as we did achieve our goals. */ + g_signal_emit(G_OBJECT(data), signals[SHUTDOWN], 0, TRUE); + return; + } + return; } static void try_and_get_name (IndicatorService * service) { IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service); - /* g_return_if_fail(priv->dbus_proxy != NULL); */ + g_return_if_fail(priv->dbus_proxy != NULL); g_return_if_fail(priv->name != NULL); - org_freedesktop_DBus_request_name_async(/* priv->dbus_proxy, */ NULL, + org_freedesktop_DBus_request_name_async(priv->dbus_proxy, priv->name, - 0, + DBUS_NAME_FLAG_DO_NOT_QUEUE, try_and_get_name_cb, service); -- cgit v1.2.3 From 2e39b18fd87c298eeb9e104d3e80f76b1d937c21 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 16:11:02 -0500 Subject: Woot! We're a DBus service now. --- libindicator/indicator-service.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 9b7e885..125ecfc 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -5,6 +5,11 @@ #include "indicator-service.h" +/* DBus Prototypes */ +void _indicator_service_server_watch (void); + +#include "indicator-service-server.h" + /* Private Stuff */ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; @@ -87,6 +92,10 @@ indicator_service_class_init (IndicatorServiceClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); + /* Initialize the object as a DBus type */ + dbus_g_object_type_install_info(INDICATOR_SERVICE_TYPE, + &dbus_glib__indicator_service_server_object_info); + return; } @@ -119,6 +128,10 @@ indicator_service_init (IndicatorService *self) return; } + dbus_g_connection_register_g_object(session_bus, + "/need/a/path", + G_OBJECT(self)); + return; } @@ -241,6 +254,8 @@ try_and_get_name (IndicatorService * service) return; } +void _indicator_service_server_watch (void) { } + /* API */ /** -- cgit v1.2.3 From 82aaaed9788d56fa2739da70621e56f1e21ec0a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 16:29:47 -0500 Subject: Adding in some shared strings for finding intefaces and objects. --- libindicator/Makefile.am | 1 + libindicator/dbus-shared.h | 4 ++++ libindicator/indicator-service.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 libindicator/dbus-shared.h (limited to 'libindicator') diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index cce87ca..209b787 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -19,6 +19,7 @@ lib_LTLIBRARIES = \ libindicator_la_SOURCES = \ $(indicator_headers) \ + dbus-shared.h \ indicator-object.c \ indicator-service.c \ indicator-service-manager.c diff --git a/libindicator/dbus-shared.h b/libindicator/dbus-shared.h new file mode 100644 index 0000000..f64588c --- /dev/null +++ b/libindicator/dbus-shared.h @@ -0,0 +1,4 @@ + +#define INDICATOR_SERVICE_INTERFACE "org.ayatana.indicator.service" +#define INDICATOR_SERVICE_OBJECT "/org/ayatana/indicator/service" + diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 125ecfc..eef916b 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -9,6 +9,7 @@ void _indicator_service_server_watch (void); #include "indicator-service-server.h" +#include "dbus-shared.h" /* Private Stuff */ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; @@ -129,7 +130,7 @@ indicator_service_init (IndicatorService *self) } dbus_g_connection_register_g_object(session_bus, - "/need/a/path", + INDICATOR_SERVICE_OBJECT, G_OBJECT(self)); return; -- cgit v1.2.3 From fbba41584475d598deab170e12ba81b16f3601aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 17:18:51 -0500 Subject: Adding in the watchers and timeout parameter. --- libindicator/indicator-service.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index eef916b..cf02bac 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -2,11 +2,12 @@ #include "config.h" #endif #include +#include #include "indicator-service.h" /* DBus Prototypes */ -void _indicator_service_server_watch (void); +static gboolean _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method); #include "indicator-service-server.h" #include "dbus-shared.h" @@ -17,6 +18,8 @@ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; struct _IndicatorServicePrivate { gchar * name; DBusGProxy * dbus_proxy; + guint timeout; + GList * watchers; }; /* Signals Stuff */ @@ -108,6 +111,8 @@ indicator_service_init (IndicatorService *self) /* Get the private variables in a decent state */ priv->name = NULL; priv->dbus_proxy = NULL; + priv->timeout = 0; + priv->watchers = NULL; /* Start talkin' dbus */ GError * error = NULL; @@ -146,6 +151,11 @@ indicator_service_dispose (GObject *object) priv->dbus_proxy = NULL; } + if (priv->timeout != 0) { + g_source_remove(priv->timeout); + priv->timeout = 0; + } + G_OBJECT_CLASS (indicator_service_parent_class)->dispose (object); return; } @@ -155,10 +165,16 @@ indicator_service_finalize (GObject *object) { IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object); - if (priv->name) { + if (priv->name != NULL) { g_free(priv->name); } + if (priv->watchers != NULL) { + g_list_foreach(priv->watchers, (GFunc)g_free, NULL); + g_list_free(priv->watchers); + priv->watchers = NULL; + } + G_OBJECT_CLASS (indicator_service_parent_class)->finalize (object); return; } @@ -255,7 +271,23 @@ try_and_get_name (IndicatorService * service) return; } -void _indicator_service_server_watch (void) { } +static gboolean +_indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method) +{ + g_return_val_if_fail(INDICATOR_IS_SERVICE(service), FALSE); + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service); + + priv->watchers = g_list_append(priv->watchers, + g_strdup(dbus_g_method_get_sender(method))); + + if (priv->timeout != 0) { + g_source_remove(priv->timeout); + priv->timeout = 0; + } + + dbus_g_method_return(method, 1); + return TRUE; +} /* API */ -- cgit v1.2.3 From 58194766a1163b1e1df94ef391403a2a827e3e95 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 17:21:39 -0500 Subject: Sending shutdown signal 500 ms after getting a name if we have no watchers. --- libindicator/indicator-service.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index cf02bac..4cc99d2 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -238,6 +238,13 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe return; } +static gboolean +timeout_no_watchers (gpointer data) +{ + g_signal_emit(G_OBJECT(data), signals[SHUTDOWN], 0, TRUE); + return FALSE; +} + static void try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data) { @@ -252,6 +259,9 @@ try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer return; } + IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service); + priv->timeout = g_timeout_add(500, timeout_no_watchers, service); + return; } -- cgit v1.2.3 From c099b0332adb448caa987370d95fbbc808f00935 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 17:34:00 -0500 Subject: Adding the API functions. --- libindicator/indicator-service-manager.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 6fd9a5b..cd16cf6 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -55,3 +55,28 @@ indicator_service_manager_finalize (GObject *object) G_OBJECT_CLASS (indicator_service_manager_parent_class)->finalize (object); return; } + +/* API */ +IndicatorServiceManager * +indicator_service_manager_new (gchar * dbus_name) +{ + GObject * obj = g_object_new(INDICATOR_SERVICE_MANAGER_TYPE, + "name", dbus_name, + NULL); + + return INDICATOR_SERVICE_MANAGER(obj); +} + +gboolean +indicator_service_manager_connected (IndicatorServiceManager * sm) +{ + + return FALSE; +} + +void +indicator_service_manager_set_refresh (IndicatorServiceManager * sm, guint time_in_ms) +{ + + return; +} -- cgit v1.2.3 From 9af4097a1f0df273ca8891e3ef6ec579e5032060 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 20:02:46 -0500 Subject: Signals and properties, oh my! --- libindicator/indicator-service-manager.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index cd16cf6..dbf96b1 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -4,11 +4,33 @@ #include "indicator-service-manager.h" +/* Private Stuff */ typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; struct _IndicatorServiceManagerPrivate { - int dummy; + gchar * name; }; +/* Signals Stuff */ +enum { + CONNECTION_CHANGE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + + +/* Properties */ +/* Enum for the properties so that they can be quickly + found and looked up. */ +enum { + PROP_0, + PROP_NAME, +}; + +/* The strings so that they can be slowly looked up. */ +#define PROP_NAME_S "name" + +/* GObject Stuff */ #define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SERVICE_MANAGER_TYPE, IndicatorServiceManagerPrivate)) @@ -29,6 +51,29 @@ indicator_service_manager_class_init (IndicatorServiceManagerClass *klass) object_class->dispose = indicator_service_manager_dispose; object_class->finalize = indicator_service_manager_finalize; + /** + IndicatorServiceManager::connecton-change: + @arg0: The #IndicatorServiceManager object + @arg1: The state of the connection, TRUE is connected. + + Signaled when the service is connected or disconnected + depending on it's previous state. + */ + signals[CONNECTION_CHANGE] = g_signal_new (INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IndicatorServiceManagerClass, connection_change), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); + + /* Properties */ + g_object_class_install_property(object_class, PROP_NAME, + g_param_spec_string(PROP_NAME_S, + "The DBus name for the service to monitor", + "This is the name that should be used to start a service.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); return; } @@ -61,7 +106,7 @@ IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name) { GObject * obj = g_object_new(INDICATOR_SERVICE_MANAGER_TYPE, - "name", dbus_name, + PROP_NAME_S, dbus_name, NULL); return INDICATOR_SERVICE_MANAGER(obj); -- cgit v1.2.3 From 12fbcd5566d35303777958048c069d0e8e775b3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 20:12:44 -0500 Subject: Properties functions. --- libindicator/indicator-service-manager.c | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index dbf96b1..1b169cd 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -39,6 +39,11 @@ static void indicator_service_manager_init (IndicatorServiceManager *self) static void indicator_service_manager_dispose (GObject *object); static void indicator_service_manager_finalize (GObject *object); +/* Prototypes */ +static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); +static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static void start_service (IndicatorServiceManager * service); + G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT); static void @@ -51,6 +56,10 @@ indicator_service_manager_class_init (IndicatorServiceManagerClass *klass) object_class->dispose = indicator_service_manager_dispose; object_class->finalize = indicator_service_manager_finalize; + /* Property funcs */ + object_class->set_property = set_property; + object_class->get_property = get_property; + /** IndicatorServiceManager::connecton-change: @arg0: The #IndicatorServiceManager object @@ -101,6 +110,73 @@ indicator_service_manager_finalize (GObject *object) return; } +static void +set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +{ + IndicatorServiceManager * self = INDICATOR_SERVICE_MANAGER(object); + g_return_if_fail(self != NULL); + + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + switch (prop_id) { + /* *********************** */ + case PROP_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + if (priv->name != NULL) { + g_error("Name can not be set twice!"); + return; + } + priv->name = g_value_dup_string(value); + start_service(self); + } else { + g_warning("Name is a string bud."); + } + break; + /* *********************** */ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + return; +} + +static void +get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +{ + IndicatorServiceManager * self = INDICATOR_SERVICE_MANAGER(object); + g_return_if_fail(self != NULL); + + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + switch (prop_id) { + /* *********************** */ + case PROP_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_string(value, priv->name); + } else { + g_warning("Name is a string bud."); + } + break; + /* *********************** */ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + return; +} + +static void +start_service (IndicatorServiceManager * service) +{ + + + return; +} + /* API */ IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name) -- cgit v1.2.3 From c87569c1ac75b5a97318587df4d913e4841a913c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 20:23:54 -0500 Subject: Ah, forgot to free name --- libindicator/indicator-service-manager.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 1b169cd..b15aaa8 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -105,6 +105,12 @@ indicator_service_manager_dispose (GObject *object) static void indicator_service_manager_finalize (GObject *object) { + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object); + + if (priv->name != NULL) { + g_free(priv->name); + priv->name = NULL; + } G_OBJECT_CLASS (indicator_service_manager_parent_class)->finalize (object); return; -- cgit v1.2.3 From 02ce4f5c45f255c4058f1f2c8d5545569b498e64 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 21:28:48 -0500 Subject: Building the dbus proxy and using it a little bit. --- libindicator/indicator-service-manager.c | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index b15aaa8..011f9c6 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -2,12 +2,16 @@ #include "config.h" #endif +#include +#include + #include "indicator-service-manager.h" /* Private Stuff */ typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; struct _IndicatorServiceManagerPrivate { gchar * name; + DBusGProxy * dbus_proxy; }; /* Signals Stuff */ @@ -90,6 +94,31 @@ indicator_service_manager_class_init (IndicatorServiceManagerClass *klass) static void indicator_service_manager_init (IndicatorServiceManager *self) { + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(self); + + /* Get the private variables in a decent state */ + priv->name = NULL; + priv->dbus_proxy = NULL; + + /* Start talkin' dbus */ + GError * error = NULL; + DBusGConnection * 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->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_error("Unable to get the proxy to DBus: %s", error->message); + g_error_free(error); + return; + } return; } @@ -97,6 +126,12 @@ indicator_service_manager_init (IndicatorServiceManager *self) static void indicator_service_manager_dispose (GObject *object) { + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object); + + if (priv->dbus_proxy != NULL) { + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } G_OBJECT_CLASS (indicator_service_manager_parent_class)->dispose (object); return; @@ -175,10 +210,37 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe return; } +static void +start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer user_data) +{ + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); + + if (error != NULL) { + g_error("Unable to start service '%s': %s", priv->name, error->message); + return; + } + + if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) { + g_error("Status of starting the process '%s' was an error: %d", priv->name, status); + return; + } + + return; +} + static void start_service (IndicatorServiceManager * service) { + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(service); + + g_return_if_fail(priv->dbus_proxy != NULL); + g_return_if_fail(priv->name != NULL); + org_freedesktop_DBus_start_service_by_name_async (priv->dbus_proxy, + priv->name, + 0, + start_service_cb, + service); return; } -- cgit v1.2.3 From a9e61b6f6196c06f79791de768e426b3e6539cec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 29 Oct 2009 21:58:48 -0500 Subject: A service proxy, and then calling watch. --- libindicator/indicator-service-manager.c | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 011f9c6..321b026 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -6,12 +6,15 @@ #include #include "indicator-service-manager.h" +#include "indicator-service-client.h" +#include "dbus-shared.h" /* Private Stuff */ typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; struct _IndicatorServiceManagerPrivate { gchar * name; DBusGProxy * dbus_proxy; + DBusGProxy * service_proxy; }; /* Signals Stuff */ @@ -99,6 +102,7 @@ indicator_service_manager_init (IndicatorServiceManager *self) /* Get the private variables in a decent state */ priv->name = NULL; priv->dbus_proxy = NULL; + priv->service_proxy = NULL; /* Start talkin' dbus */ GError * error = NULL; @@ -133,6 +137,11 @@ indicator_service_manager_dispose (GObject *object) priv->dbus_proxy = NULL; } + if (priv->service_proxy != NULL) { + g_object_unref(G_OBJECT(priv->service_proxy)); + priv->service_proxy = NULL; + } + G_OBJECT_CLASS (indicator_service_manager_parent_class)->dispose (object); return; } @@ -210,6 +219,20 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe return; } +static void +watch_cb (DBusGProxy * proxy, gint version, GError * error, gpointer user_data) +{ + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); + + if (error != NULL) { + g_error("Unable to set watch on '%s': '%s'", priv->name, error->message); + g_error_free(error); + return; + } + + return; +} + static void start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer user_data) { @@ -225,6 +248,24 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use return; } + /* Woot! it's running. Let's do it some more. */ + DBusGConnection * 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->service_proxy = dbus_g_proxy_new_for_name_owner(session_bus, + priv->name, + INDICATOR_SERVICE_OBJECT, + INDICATOR_SERVICE_INTERFACE, + &error); + + org_ayatana_indicator_service_watch_async(priv->service_proxy, + watch_cb, + user_data); + return; } -- cgit v1.2.3 From aa1549d81d1d0eb1f92d4fb5b0339ba4ceab72cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 30 Oct 2009 15:58:57 -0500 Subject: Adding in the connected property and signalling when we're all hooked up. --- libindicator/dbus-shared.h | 2 ++ libindicator/indicator-service-manager.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'libindicator') diff --git a/libindicator/dbus-shared.h b/libindicator/dbus-shared.h index f64588c..f3dbd83 100644 --- a/libindicator/dbus-shared.h +++ b/libindicator/dbus-shared.h @@ -2,3 +2,5 @@ #define INDICATOR_SERVICE_INTERFACE "org.ayatana.indicator.service" #define INDICATOR_SERVICE_OBJECT "/org/ayatana/indicator/service" +#define INDICATOR_SERVICE_VERSION 1 + diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 321b026..2d668ff 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -15,6 +15,7 @@ struct _IndicatorServiceManagerPrivate { gchar * name; DBusGProxy * dbus_proxy; DBusGProxy * service_proxy; + gboolean connected; }; /* Signals Stuff */ @@ -103,6 +104,7 @@ indicator_service_manager_init (IndicatorServiceManager *self) priv->name = NULL; priv->dbus_proxy = NULL; priv->service_proxy = NULL; + priv->connected = FALSE; /* Start talkin' dbus */ GError * error = NULL; @@ -132,16 +134,26 @@ indicator_service_manager_dispose (GObject *object) { IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object); + /* If we were connected we need to make sure to + tell people that it's no longer the case. */ + if (priv->connected) { + priv->connected = FALSE; + g_signal_emit(object, signals[CONNECTION_CHANGE], 0, FALSE, TRUE); + } + + /* Destory our DBus proxy, we won't need it. */ if (priv->dbus_proxy != NULL) { g_object_unref(G_OBJECT(priv->dbus_proxy)); priv->dbus_proxy = NULL; } + /* Destory our service proxy, we won't need it. */ if (priv->service_proxy != NULL) { g_object_unref(G_OBJECT(priv->service_proxy)); priv->service_proxy = NULL; } + /* Let's see if our parents want to do anything. */ G_OBJECT_CLASS (indicator_service_manager_parent_class)->dispose (object); return; } @@ -230,6 +242,16 @@ watch_cb (DBusGProxy * proxy, gint version, GError * error, gpointer user_data) return; } + if (version != INDICATOR_SERVICE_VERSION) { + g_error("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, version); + return; + } + + if (!priv->connected) { + priv->connected = TRUE; + g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, TRUE, TRUE); + } + return; } -- cgit v1.2.3 From c99ef2256a94f1ce7c4b54f8c7d5321e29faffa9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Nov 2009 09:35:48 -0600 Subject: Some things are errors that should really be warnings. --- libindicator/indicator-service-manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 2d668ff..656472d 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -237,13 +237,13 @@ watch_cb (DBusGProxy * proxy, gint version, GError * error, gpointer user_data) IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); if (error != NULL) { - g_error("Unable to set watch on '%s': '%s'", priv->name, error->message); + g_warning("Unable to set watch on '%s': '%s'", priv->name, error->message); g_error_free(error); return; } if (version != INDICATOR_SERVICE_VERSION) { - g_error("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, version); + g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, version); return; } @@ -261,12 +261,12 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); if (error != NULL) { - g_error("Unable to start service '%s': %s", priv->name, error->message); + g_warning("Unable to start service '%s': %s", priv->name, error->message); return; } if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) { - g_error("Status of starting the process '%s' was an error: %d", priv->name, status); + g_warning("Status of starting the process '%s' was an error: %d", priv->name, status); return; } -- cgit v1.2.3 From 90446e0f46aec726341a8e178bfa65ddcb057deb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Nov 2009 10:48:18 -0600 Subject: Fixing up the build rules so that they're directory independent. --- libindicator/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 209b787..5c512cd 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -43,14 +43,14 @@ DBUS_SPECS = \ %-client.h: %.xml dbus-binding-tool \ - --prefix=_$(subst -,_,$(<:.xml=))_client \ + --prefix=_$(subst -,_,$(basename $(notdir $<)))_client \ --mode=glib-client \ --output=$@ \ $< %-server.h: %.xml dbus-binding-tool \ - --prefix=_$(subst -,_,$(<:.xml=))_server \ + --prefix=_$(subst -,_,$(basename $(notdir $<)))_server \ --mode=glib-server \ --output=$@ \ $< -- cgit v1.2.3 From ddb2ab7cba0d8b2c7ea5171595e06c04520f4b81 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Nov 2009 16:08:04 -0600 Subject: Adding a fallback to the session bus after trying the starter bus. --- libindicator/indicator-service.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 4cc99d2..ff0bd03 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -116,14 +116,24 @@ indicator_service_init (IndicatorService *self) /* Start talkin' dbus */ GError * error = NULL; - DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); if (error != NULL) { - g_error("Unable to get session bus: %s", error->message); + g_error("Unable to get starter bus: %s", error->message); g_error_free(error); - return; + + /* Okay, fine let's try the session bus then. */ + /* I think this should automatically, but I can't find confirmation + of that, so we're putting the extra little code in here. */ + error = NULL; + 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->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus, + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner(bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, @@ -134,7 +144,7 @@ indicator_service_init (IndicatorService *self) return; } - dbus_g_connection_register_g_object(session_bus, + dbus_g_connection_register_g_object(bus, INDICATOR_SERVICE_OBJECT, G_OBJECT(self)); -- cgit v1.2.3 From 0aa210608dda6d29c178126e0ad1d613e30e3cd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Nov 2009 17:12:06 -0600 Subject: Oops, we need to tell package config that we're a big library now. --- libindicator/indicator.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in index 2835115..9a8169e 100644 --- a/libindicator/indicator.pc.in +++ b/libindicator/indicator.pc.in @@ -9,7 +9,7 @@ iconsdir=@datarootdir@/@PACKAGE@/icons/ Cflags: -I${includedir}/libindicator-0.1 Requires: gtk+-2.0 -Libs: +Libs: -lindicator Name: libindicator Description: libindicator. -- cgit v1.2.3 From cfa83c08d769ba10eb90718e3c856b18e49c691b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Nov 2009 22:40:05 -0600 Subject: Changing version to service_version --- libindicator/indicator-service-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 656472d..4eaed23 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -232,7 +232,7 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe } static void -watch_cb (DBusGProxy * proxy, gint version, GError * error, gpointer user_data) +watch_cb (DBusGProxy * proxy, gint service_version, GError * error, gpointer user_data) { IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); @@ -242,8 +242,8 @@ watch_cb (DBusGProxy * proxy, gint version, GError * error, gpointer user_data) return; } - if (version != INDICATOR_SERVICE_VERSION) { - g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, version); + if (service_version != INDICATOR_SERVICE_VERSION) { + g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_version); return; } -- cgit v1.2.3 From cb0c099a07068f374e7ce27b873d2773131e4a48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Nov 2009 22:42:39 -0600 Subject: Making a warning not use a colloquialism. --- libindicator/indicator-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index ff0bd03..69422c5 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -209,7 +209,7 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec priv->name = g_value_dup_string(value); try_and_get_name(self); } else { - g_warning("Name is a string bud."); + g_warning("Name property requires a string value."); } break; /* *********************** */ @@ -236,7 +236,7 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe if (G_VALUE_HOLDS_STRING(value)) { g_value_set_string(value, priv->name); } else { - g_warning("Name is a string bud."); + g_warning("Name property requires a string value."); } break; /* *********************** */ -- cgit v1.2.3