summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Staudinger <robsta@linux.intel.com>2011-10-28 15:31:54 +0200
committerRob Staudinger <robsta@linux.intel.com>2011-10-28 15:31:54 +0200
commitc0174d6dcf750c721f4394c4f8a24fafe24fa4f4 (patch)
tree0b34bc129b572708b21ee29b0edfb3a572b2e00e
parente20c47605db3308ee67fb60a2968980be7657dbd (diff)
(Proxy)Service: split away internal interface
The "send-message" signal to pass on a message to the ytstenut internals has been moved to an interface that is not exposed through the API. Service and ProxyService classes are abstract now, with -Impl subclasses which implement the new internal ServiceEmitter interface. Tags: refactoring
-rw-r--r--docs/reference/ytstenut/Makefile.am3
-rw-r--r--ytstenut/Makefile.am6
-rw-r--r--ytstenut/yts-proxy-service-impl.c79
-rw-r--r--ytstenut/yts-proxy-service-impl.h69
-rw-r--r--ytstenut/yts-proxy-service-internal.h7
-rw-r--r--ytstenut/yts-proxy-service.c32
-rw-r--r--ytstenut/yts-service-emitter.c68
-rw-r--r--ytstenut/yts-service-emitter.h59
-rw-r--r--ytstenut/yts-service-factory.c16
-rw-r--r--ytstenut/yts-service-impl.c79
-rw-r--r--ytstenut/yts-service-impl.h69
-rw-r--r--ytstenut/yts-service-internal.h8
-rw-r--r--ytstenut/yts-service.c67
-rw-r--r--ytstenut/ytstenut.sym1
14 files changed, 472 insertions, 91 deletions
diff --git a/docs/reference/ytstenut/Makefile.am b/docs/reference/ytstenut/Makefile.am
index 0df6245..cdf0f5f 100644
--- a/docs/reference/ytstenut/Makefile.am
+++ b/docs/reference/ytstenut/Makefile.am
@@ -72,11 +72,14 @@ IGNORE_HFILES = \
yts-profile-proxy.h \
yts-proxy-factory.h \
yts-proxy-internal.h \
+ yts-proxy-service-impl.h \
yts-proxy-service-internal.h \
yts-response-message.h \
yts-roster-internal.h \
yts-service-adapter.h \
+ yts-service-emitter.h \
yts-service-factory.h \
+ yts-service-impl.h \
yts-service-internal.h \
yts-status.h \
yts-vp-playable-proxy.h \
diff --git a/ytstenut/Makefile.am b/ytstenut/Makefile.am
index 5e8a034..780f007 100644
--- a/ytstenut/Makefile.am
+++ b/ytstenut/Makefile.am
@@ -46,6 +46,7 @@ source_c = \
$(srcdir)/yts-metadata.c \
$(srcdir)/yts-roster.c \
$(srcdir)/yts-service.c \
+ $(srcdir)/yts-service-impl.c \
$(srcdir)/yts-status.c \
\
$(srcdir)/yts-adapter-factory.c \
@@ -54,9 +55,11 @@ source_c = \
$(srcdir)/yts-event-message.c \
$(srcdir)/yts-factory.c \
$(srcdir)/yts-invocation-message.c \
+ $(srcdir)/yts-service-emitter.c \
$(srcdir)/yts-proxy.c \
$(srcdir)/yts-proxy-factory.c \
$(srcdir)/yts-proxy-service.c \
+ $(srcdir)/yts-proxy-service-impl.c \
$(srcdir)/yts-response-message.c \
$(srcdir)/yts-service-adapter.c \
$(srcdir)/yts-service-factory.c \
@@ -93,10 +96,13 @@ private_h = \
$(srcdir)/yts-metadata-internal.h \
$(srcdir)/yts-proxy-factory.h \
$(srcdir)/yts-proxy-internal.h \
+ $(srcdir)/yts-proxy-service-impl.h \
$(srcdir)/yts-proxy-service-internal.h \
$(srcdir)/yts-roster-internal.h \
$(srcdir)/yts-service-adapter.h \
+ $(srcdir)/yts-service-emitter.h \
$(srcdir)/yts-service-factory.h \
+ $(srcdir)/yts-service-impl.h \
$(srcdir)/yts-service-internal.h \
\
$(srcdir)/yts-capability-status.h \
diff --git a/ytstenut/yts-proxy-service-impl.c b/ytstenut/yts-proxy-service-impl.c
new file mode 100644
index 0000000..136cb73
--- /dev/null
+++ b/ytstenut/yts-proxy-service-impl.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#include "yts-service-emitter.h"
+#include "yts-proxy-service-impl.h"
+#include "config.h"
+
+static void
+_service_emitter_interface_init (YtsServiceEmitter *interface);
+
+G_DEFINE_TYPE_WITH_CODE (YtsProxyServiceImpl,
+ yts_proxy_service_impl,
+ YTS_TYPE_PROXY_SERVICE,
+ G_IMPLEMENT_INTERFACE (YTS_TYPE_SERVICE_EMITTER,
+ _service_emitter_interface_init))
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN PACKAGE"\0proxy-service-impl\0"G_STRLOC
+
+/*
+ * YtsProxyServiceEmitter
+ */
+
+static void
+_service_emitter_interface_init (YtsServiceEmitter *interface)
+{
+ /* Nothing to do, it's just about using the "send-message" signal. */
+}
+
+/*
+ * YtsProxyServiceImpl
+ */
+
+static void
+yts_proxy_service_impl_class_init (YtsProxyServiceImplClass *klass)
+{
+}
+
+static void
+yts_proxy_service_impl_init (YtsProxyServiceImpl *self)
+{
+}
+
+YtsService *
+yts_proxy_service_impl_new (char const *service_id,
+ char const *type,
+ char const *const *fqc_ids,
+ GHashTable *names,
+ GHashTable *statuses)
+{
+ g_return_val_if_fail (service_id, NULL);
+ g_return_val_if_fail (*service_id, NULL);
+
+ return g_object_new (YTS_TYPE_PROXY_SERVICE_IMPL,
+ "fqc-ids", fqc_ids,
+ "service-id", service_id,
+ "type", type,
+ "names", names,
+ "statuses", statuses,
+ NULL);
+}
+
diff --git a/ytstenut/yts-proxy-service-impl.h b/ytstenut/yts-proxy-service-impl.h
new file mode 100644
index 0000000..ed30d6e
--- /dev/null
+++ b/ytstenut/yts-proxy-service-impl.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#ifndef YTS_PROXY_SERVICE_IMPL_H
+#define YTS_PROXY_SERVICE_IMPL_H
+
+#include <glib-object.h>
+#include <ytstenut/yts-proxy-service.h>
+
+G_BEGIN_DECLS
+
+#define YTS_TYPE_PROXY_SERVICE_IMPL (yts_proxy_service_impl_get_type ())
+
+#define YTS_PROXY_SERVICE_IMPL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), YTS_TYPE_PROXY_SERVICE_IMPL, YtsProxyServiceImpl))
+
+#define YTS_PROXY_SERVICE_IMPL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), YTS_TYPE_PROXY_SERVICE_IMPL, YtsProxyServiceImplClass))
+
+#define YTS_IS_PROXY_SERVICE_IMPL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YTS_TYPE_PROXY_SERVICE_IMPL))
+
+#define YTS_IS_PROXY_SERVICE_IMPL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), YTS_TYPE_PROXY_SERVICE_IMPL))
+
+#define YTS_PROXY_SERVICE_IMPL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), YTS_TYPE_PROXY_SERVICE_IMPL, YtsProxyServiceImplClass))
+
+typedef struct {
+ /*< private >*/
+ YtsProxyService parent;
+} YtsProxyServiceImpl;
+
+typedef struct {
+ /*< private >*/
+ YtsProxyServiceClass parent;
+} YtsProxyServiceImplClass;
+
+GType
+yts_proxy_service_impl_get_type (void) G_GNUC_CONST;
+
+YtsService *
+yts_proxy_service_impl_new (char const *service_id,
+ char const *type,
+ char const *const *fqc_ids,
+ GHashTable *names,
+ GHashTable *statuses);
+
+G_END_DECLS
+
+#endif /* YTS_PROXY_SERVICE_IMPL_H */
+
diff --git a/ytstenut/yts-proxy-service-internal.h b/ytstenut/yts-proxy-service-internal.h
index c28189f..526b2bb 100644
--- a/ytstenut/yts-proxy-service-internal.h
+++ b/ytstenut/yts-proxy-service-internal.h
@@ -23,13 +23,6 @@
#include <ytstenut/yts-proxy-service.h>
-YtsService *
-yts_proxy_service_new (char const *service_id,
- char const *type,
- char const *const *fqc_ids,
- GHashTable *names,
- GHashTable *statuses);
-
bool
yts_proxy_service_dispatch_event (YtsProxyService *self,
char const *capability,
diff --git a/ytstenut/yts-proxy-service.c b/ytstenut/yts-proxy-service.c
index 0c745a8..17275d4 100644
--- a/ytstenut/yts-proxy-service.c
+++ b/ytstenut/yts-proxy-service.c
@@ -26,13 +26,14 @@
#include "yts-proxy-factory.h"
#include "yts-proxy-internal.h"
#include "yts-proxy-service-internal.h"
+#include "yts-service-emitter.h"
#include "yts-service-internal.h"
#include "profile/yts-profile.h"
#include "profile/yts-profile-proxy.h"
#include "config.h"
-G_DEFINE_TYPE (YtsProxyService, yts_proxy_service, YTS_TYPE_SERVICE)
+G_DEFINE_ABSTRACT_TYPE (YtsProxyService, yts_proxy_service, YTS_TYPE_SERVICE)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), YTS_TYPE_PROXY_SERVICE, YtsProxyServicePrivate))
@@ -60,6 +61,14 @@ typedef struct {
static unsigned _signals[N_SIGNALS] = { 0, };
static void
+_constructed (GObject *object)
+{
+ /* This is a bit of a hack, we require the non-abstract subclass to
+ * implement this interface. */
+ g_assert (YTS_IS_SERVICE_EMITTER (object));
+}
+
+static void
_get_property (GObject *object,
unsigned int property_id,
GValue *value,
@@ -134,6 +143,7 @@ yts_proxy_service_class_init (YtsProxyServiceClass *klass)
g_type_class_add_private (klass, sizeof (YtsProxyServicePrivate));
+ object_class->dispose = _constructed;
object_class->get_property = _get_property;
object_class->set_property = _set_property;
object_class->dispose = _dispose;
@@ -176,22 +186,6 @@ yts_proxy_service_init (YtsProxyService *self)
g_free);
}
-YtsService *
-yts_proxy_service_new (char const *service_id,
- char const *type,
- char const *const *fqc_ids,
- GHashTable *names,
- GHashTable *statuses)
-{
- return g_object_new (YTS_TYPE_PROXY_SERVICE,
- "fqc-ids", fqc_ids,
- "service-id", service_id,
- "type", type,
- "names", names,
- "statuses", statuses,
- NULL);
-}
-
static void
_profile_invoke_service (YtsProfile *profile,
char const *invocation_id,
@@ -208,7 +202,7 @@ _profile_invoke_service (YtsProfile *profile,
aspect,
arguments);
- yts_service_send_message (YTS_SERVICE (self), message);
+ yts_service_emitter_send_message (YTS_SERVICE_EMITTER (self), message);
g_object_unref (message);
g_free (fqc_id);
@@ -230,7 +224,7 @@ _proxy_invoke_service (YtsProxy *proxy,
aspect,
arguments);
- yts_service_send_message (YTS_SERVICE (self), message);
+ yts_service_emitter_send_message (YTS_SERVICE_EMITTER (self), message);
g_object_unref (message);
g_free (fqc_id);
diff --git a/ytstenut/yts-service-emitter.c b/ytstenut/yts-service-emitter.c
new file mode 100644
index 0000000..cc72d41
--- /dev/null
+++ b/ytstenut/yts-service-emitter.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#include <stdbool.h>
+
+#include "yts-marshal.h"
+#include "yts-service.h"
+#include "yts-service-emitter.h"
+#include "config.h"
+
+G_DEFINE_INTERFACE (YtsServiceEmitter, yts_service_emitter, YTS_TYPE_SERVICE)
+
+enum {
+ SIG_SEND_MESSAGE,
+ N_SIGNALS
+};
+
+static unsigned _signals[N_SIGNALS] = { 0, };
+
+static void
+yts_service_emitter_default_init (YtsServiceEmitterInterface *interface)
+{
+ static bool _initialized = false;
+
+ if (!_initialized) {
+
+ /**
+ * YtsServiceImpl::send-message:
+ *
+ * Internal signal, should not be considered by language bindings at this
+ * time. Maybe in the future when we allow for custom service subclasses.
+ */
+ _signals[SIG_SEND_MESSAGE] = g_signal_new ("send-message",
+ G_TYPE_FROM_INTERFACE (interface),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ yts_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ YTS_TYPE_METADATA);
+
+ _initialized = true;
+ }
+}
+
+void
+yts_service_emitter_send_message (YtsServiceEmitter *self,
+ YtsMetadata *message)
+{
+ g_signal_emit (self, _signals[SIG_SEND_MESSAGE], 0, message);
+}
+
diff --git a/ytstenut/yts-service-emitter.h b/ytstenut/yts-service-emitter.h
new file mode 100644
index 0000000..cb6e33d
--- /dev/null
+++ b/ytstenut/yts-service-emitter.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#ifndef YTS_SERVICE_EMITTER_H
+#define YTS_SERVICE_EMITTER_H
+
+#include <glib-object.h>
+#include <ytstenut/yts-metadata.h>
+
+G_BEGIN_DECLS
+
+#define YTS_TYPE_SERVICE_EMITTER (yts_service_emitter_get_type ())
+
+#define YTS_SERVICE_EMITTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), YTS_TYPE_SERVICE_EMITTER, YtsServiceEmitter))
+
+#define YTS_IS_SERVICE_EMITTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YTS_TYPE_SERVICE_EMITTER))
+
+#define YTS_SERVICE_EMITTER_GET_INTERFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), YTS_TYPE_SERVICE_EMITTER, YtsServiceEmitterInterface))
+
+typedef struct YtsServiceEmitter YtsServiceEmitter;
+
+typedef struct {
+
+ /*< private >*/
+ GTypeInterface parent;
+
+} YtsServiceEmitterInterface;
+
+GType
+yts_service_emitter_get_type (void) G_GNUC_CONST;
+
+void
+yts_service_emitter_send_message (YtsServiceEmitter *self,
+ YtsMetadata *message);
+
+G_END_DECLS
+
+#endif /* YTS_SERVICE_EMITTER_H */
+
diff --git a/ytstenut/yts-service-factory.c b/ytstenut/yts-service-factory.c
index b42aa5f..02cf55c 100644
--- a/ytstenut/yts-service-factory.c
+++ b/ytstenut/yts-service-factory.c
@@ -18,9 +18,9 @@
* Authored by: Rob Staudinger <robsta@linux.intel.com>
*/
-#include "yts-service-internal.h"
-#include "yts-proxy-service-internal.h"
+#include "yts-proxy-service-impl.h"
#include "yts-service-factory.h"
+#include "yts-service-impl.h"
#include "config.h"
G_DEFINE_TYPE (YtsServiceFactory, yts_service_factory, YTS_TYPE_FACTORY)
@@ -89,14 +89,14 @@ yts_service_factory_create_service (YtsServiceFactory *self,
YTS_FACTORY (self),
fqc_ids[i]);
if (proxy_gtype != G_TYPE_INVALID) {
- return yts_proxy_service_new (service_id,
- type,
- fqc_ids,
- names,
- statuses);
+ return yts_proxy_service_impl_new (service_id,
+ type,
+ fqc_ids,
+ names,
+ statuses);
}
}
- return yts_service_new (service_id, type, fqc_ids, names, statuses);
+ return yts_service_impl_new (service_id, type, fqc_ids, names, statuses);
}
diff --git a/ytstenut/yts-service-impl.c b/ytstenut/yts-service-impl.c
new file mode 100644
index 0000000..23dd584
--- /dev/null
+++ b/ytstenut/yts-service-impl.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#include "yts-service-emitter.h"
+#include "yts-service-impl.h"
+#include "config.h"
+
+static void
+_service_emitter_interface_init (YtsServiceEmitter *interface);
+
+G_DEFINE_TYPE_WITH_CODE (YtsServiceImpl,
+ yts_service_impl,
+ YTS_TYPE_SERVICE,
+ G_IMPLEMENT_INTERFACE (YTS_TYPE_SERVICE_EMITTER,
+ _service_emitter_interface_init))
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN PACKAGE"\0service-impl\0"G_STRLOC
+
+/*
+ * YtsServiceEmitter
+ */
+
+static void
+_service_emitter_interface_init (YtsServiceEmitter *interface)
+{
+ /* Nothing to do, it's just about using the "send-message" signal. */
+}
+
+/*
+ * YtsServiceImpl
+ */
+
+static void
+yts_service_impl_class_init (YtsServiceImplClass *klass)
+{
+}
+
+static void
+yts_service_impl_init (YtsServiceImpl *self)
+{
+}
+
+YtsService *
+yts_service_impl_new (char const *service_id,
+ char const *type,
+ char const *const *fqc_ids,
+ GHashTable *names,
+ GHashTable *statuses)
+{
+ g_return_val_if_fail (service_id, NULL);
+ g_return_val_if_fail (*service_id, NULL);
+
+ return g_object_new (YTS_TYPE_SERVICE_IMPL,
+ "fqc-ids", fqc_ids,
+ "service-id", service_id,
+ "type", type,
+ "names", names,
+ "statuses", statuses,
+ NULL);
+}
+
diff --git a/ytstenut/yts-service-impl.h b/ytstenut/yts-service-impl.h
new file mode 100644
index 0000000..965a8bc
--- /dev/null
+++ b/ytstenut/yts-service-impl.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Rob Staudinger <robsta@linux.intel.com>
+ */
+
+#ifndef YTS_SERVICE_IMPL_H
+#define YTS_SERVICE_IMPL_H
+
+#include <glib-object.h>
+#include <ytstenut/yts-service.h>
+
+G_BEGIN_DECLS
+
+#define YTS_TYPE_SERVICE_IMPL (yts_service_impl_get_type ())
+
+#define YTS_SERVICE_IMPL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), YTS_TYPE_SERVICE_IMPL, YtsServiceImpl))
+
+#define YTS_SERVICE_IMPL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), YTS_TYPE_SERVICE_IMPL, YtsServiceImplClass))
+
+#define YTS_IS_SERVICE_IMPL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YTS_TYPE_SERVICE_IMPL))
+
+#define YTS_IS_SERVICE_IMPL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), YTS_TYPE_SERVICE_IMPL))
+
+#define YTS_SERVICE_IMPL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), YTS_TYPE_SERVICE_IMPL, YtsServiceImplClass))
+
+typedef struct {
+ /*< private >*/
+ YtsService parent;
+} YtsServiceImpl;
+
+typedef struct {
+ /*< private >*/
+ YtsServiceClass parent;
+} YtsServiceImplClass;
+
+GType
+yts_service_impl_get_type (void) G_GNUC_CONST;
+
+YtsService *
+yts_service_impl_new (char const *service_id,
+ char const *type,
+ char const *const *fqc_ids,
+ GHashTable *names,
+ GHashTable *statuses);
+
+G_END_DECLS
+
+#endif /* YTS_SERVICE_IMPL_H */
+
diff --git a/ytstenut/yts-service-internal.h b/ytstenut/yts-service-internal.h
index c806f26..884b086 100644
--- a/ytstenut/yts-service-internal.h
+++ b/ytstenut/yts-service-internal.h
@@ -21,17 +21,9 @@
#ifndef YTS_SERVICE_INTERNAL_H
#define YTS_SERVICE_INTERNAL_H
-#include <ytstenut/yts-contact.h>
#include <ytstenut/yts-metadata.h>
#include <ytstenut/yts-service.h>
-YtsService *
-yts_service_new (char const *service_id,
- char const *type,
- char const *const *fqc_ids,
- GHashTable *names,
- GHashTable *statuses);
-
void
yts_service_send_message (YtsService *self,
YtsMetadata *message);
diff --git a/ytstenut/yts-service.c b/ytstenut/yts-service.c
index 8ef84ea..9a20e07 100644
--- a/ytstenut/yts-service.c
+++ b/ytstenut/yts-service.c
@@ -23,17 +23,19 @@
#include "yts-invocation-message.h"
#include "yts-marshal.h"
#include "yts-message.h"
+#include "yts-service-emitter.h"
#include "yts-service-internal.h"
#include "config.h"
static void
_capability_interface_init (YtsCapability *interface);
-G_DEFINE_TYPE_WITH_CODE (YtsService,
- yts_service,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (YTS_TYPE_CAPABILITY,
- _capability_interface_init))
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
+ YtsService,
+ yts_service,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (YTS_TYPE_CAPABILITY,
+ _capability_interface_init))
/**
* SECTION:yts-service
@@ -63,7 +65,6 @@ enum {
};
enum {
- SIG_SEND_MESSAGE,
SIG_STATUS_CHANGED,
N_SIGNALS
};
@@ -99,6 +100,14 @@ _capability_interface_init (YtsCapability *interface)
*/
static void
+_constructed (GObject *object)
+{
+ /* This is a bit of a hack, we require the non-abstract subclass to
+ * implement this interface. */
+ g_assert (YTS_IS_SERVICE_EMITTER (object));
+}
+
+static void
_get_property (GObject *object,
unsigned property_id,
GValue *value,
@@ -203,6 +212,7 @@ yts_service_class_init (YtsServiceClass *klass)
g_type_class_add_private (klass, sizeof (YtsServicePrivate));
+ object_class->dispose = _constructed;
object_class->dispose = _dispose;
object_class->get_property = _get_property;
object_class->set_property = _set_property;
@@ -265,20 +275,6 @@ yts_service_class_init (YtsServiceClass *klass)
g_object_class_install_property (object_class, PROP_STATUSES, pspec);
/**
- * YtsService::send-message:
- *
- * Internal signal, should not be considered by language bindings at this
- * time. Maybe in the future when we allow for custom service subclasses.
- */
- _signals[SIG_SEND_MESSAGE] = g_signal_new ("send-message",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- yts_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- YTS_TYPE_METADATA);
-
- /**
* YtsService::status-changed:
* @self: object which emitted the signal.
* @fqc_id: fully qualified capability ID of the changed status.
@@ -448,7 +444,7 @@ yts_service_send_text (YtsService *self,
g_return_if_fail (YTS_IS_SERVICE (self));
message = create_message ("text", g_variant_new_string (text));
- yts_service_send_message (self, message);
+ yts_service_emitter_send_message (YTS_SERVICE_EMITTER (self), message);
g_object_unref (message);
}
@@ -472,7 +468,7 @@ yts_service_send_list (YtsService *self,
g_return_if_fail (YTS_IS_SERVICE (self));
message = create_message ("list", g_variant_new_strv (texts, length));
- yts_service_send_message (self, message);
+ yts_service_emitter_send_message (YTS_SERVICE_EMITTER (self), message);
g_object_unref (message);
}
@@ -511,32 +507,7 @@ yts_service_send_dictionary (YtsService *self,
}
message = create_message ("dictionary", g_variant_builder_end (&builder));
- yts_service_send_message (self, message);
+ yts_service_emitter_send_message (YTS_SERVICE_EMITTER (self), message);
g_object_unref (message);
}
-void
-yts_service_send_message (YtsService *self,
- YtsMetadata *message)
-{
- g_signal_emit (self, _signals[SIG_SEND_MESSAGE], 0, message);
-}
-
-YtsService *
-yts_service_new (char const *service_id,
- char const *type,
- char const *const *fqc_ids,
- GHashTable *names,
- GHashTable *statuses)
-{
- g_return_val_if_fail (service_id && *service_id, NULL);
-
- return g_object_new (YTS_TYPE_SERVICE,
- "fqc-ids", fqc_ids,
- "service-id", service_id,
- "type", type,
- "names", names,
- "statuses", statuses,
- NULL);
-}
-
diff --git a/ytstenut/ytstenut.sym b/ytstenut/ytstenut.sym
index 3adc0b3..a0300d1 100644
--- a/ytstenut/ytstenut.sym
+++ b/ytstenut/ytstenut.sym
@@ -39,7 +39,6 @@ yts_proxy_get_type
yts_proxy_invoke
yts_proxy_service_create_proxy
yts_proxy_service_get_type
-yts_proxy_service_new
yts_roster_find_contact_by_id
yts_roster_foreach_contact
yts_roster_get_type