summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-05-04 15:44:59 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-05-04 15:44:59 +0100
commit6f816d3be6658b36fd9743baf4c0f81afb457983 (patch)
tree20f753edc5cccfee2c5d6a3ec983ffc847452375
parenta375e043d82e974666b7a9f9f1fea6e22efda42e (diff)
status: add ::service-added, ::service-removed and ::status-changed
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-ytstenut-glib/status.c96
-rw-r--r--telepathy-ytstenut-glib/tests/nosey-status.c9
2 files changed, 105 insertions, 0 deletions
diff --git a/telepathy-ytstenut-glib/status.c b/telepathy-ytstenut-glib/status.c
index 1f591f1..ca0d8aa 100644
--- a/telepathy-ytstenut-glib/status.c
+++ b/telepathy-ytstenut-glib/status.c
@@ -82,6 +82,15 @@
*/
enum {
+ SERVICE_ADDED,
+ SERVICE_REMOVED,
+ STATUS_CHANGED,
+ LAST_SIGNAL
+};
+
+static gint signals[LAST_SIGNAL] = { 0, };
+
+enum {
PROP_0,
PROP_DISCOVERED_SERVICES,
PROP_DISCOVERED_STATUSES,
@@ -161,6 +170,9 @@ on_status_changed (TpYtsStatus *self,
}
g_object_notify (G_OBJECT (self), "discovered-statuses");
+
+ g_signal_emit (self, signals[STATUS_CHANGED], 0,
+ contact_id, capability, service_name, status);
}
static void
@@ -189,6 +201,9 @@ on_service_added (TpYtsStatus *self,
g_value_array_copy (service));
g_object_notify (G_OBJECT (self), "discovered-services");
+
+ g_signal_emit (self, signals[SERVICE_ADDED], 0,
+ contact_id, service_name, service);
}
static void
@@ -212,6 +227,9 @@ on_service_removed (TpYtsStatus *self,
g_hash_table_remove (self->priv->discovered_services, contact_id);
g_object_notify (G_OBJECT (self), "discovered-services");
+
+ g_signal_emit (self, signals[SERVICE_REMOVED], 0,
+ contact_id, service_name);
}
static void
@@ -388,6 +406,84 @@ tp_yts_status_class_init (TpYtsStatusClass *klass)
TP_YTS_HASH_TYPE_CONTACT_CAPABILITY_MAP,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * TpYtsStatus::service-added:
+ * @status: the #TpYtsStatus
+ * @contact_id: The contact for the device on which a service was added.
+ * @service_name: The name of the service which was added.
+ * @service: Details of the service added.
+ *
+ * This signal is emitted when we discover that a Ytstenut service
+ * has been advertised by a contact. The
+ * #TpYtsStatus:discovered-services property will have been updated
+ * before this signal is emitted.
+ *
+ * @service is a #GValueArray like this:
+ *
+ *
+ * <code><literallayout>
+ * GValueArray (
+ * gchar *service_type,
+ * GHashTable (
+ * gchar *language,
+ * gchar *localized_name
+ * )
+ * gchar **capabilities
+ * )
+ * </literallayout></code>
+ */
+ signals[SERVICE_ADDED] =
+ g_signal_new ("service-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0,
+ NULL, NULL,
+ _tp_yts_marshal_VOID__STRING_STRING_BOXED,
+ G_TYPE_NONE,
+ 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_VALUE_ARRAY);
+
+ /**
+ * TpYtsStatus::service-removed:
+ * @status: a #TpYtsStatus
+ * @contact_id: The contact for the device on which a service was removed.
+ * @service_name: The name of the service which was removed.
+ *
+ * This signal is emitted when we discover that a Ytstenut service
+ * has been removed by a Contact. The
+ * #TpYtsStatus:discovered-services property will have been updated
+ * before this signal is emitted.
+ */
+ signals[SERVICE_REMOVED] =
+ g_signal_new ("service_removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0,
+ NULL, NULL,
+ _tp_yts_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE,
+ 2, G_TYPE_STRING, G_TYPE_STRING);
+
+ /**
+ * TpYtsStatus::status-changed:
+ * @status: a #TpYtsStatus
+ * @contact_id: The contact for the device on which the status changed.
+ * @capability: The capability for which the status changed.
+ * @service_name: The name of the service whose status changed.
+ * @status: The UTF-8 encoded XML Ytstetus status, or a empty string
+ * if the status was cleared.
+ *
+ * This signal is emitted when we discover that a Ytstenut service
+ * has changed or cleared its status on one one of the devices on
+ * the local network. The #TpYtsStatus:discovered-statuses property
+ * will have been updated before this signal is emitted.
+ */
+ signals[STATUS_CHANGED] =
+ g_signal_new ("status-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0,
+ NULL, NULL,
+ _tp_yts_marshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE,
+ 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+
tp_proxy_init_known_interfaces ();
tp_proxy_or_subclass_hook_on_interface_add (tp_type,
tp_yts_status_add_signals);
diff --git a/telepathy-ytstenut-glib/tests/nosey-status.c b/telepathy-ytstenut-glib/tests/nosey-status.c
index e5b3264..c037277 100644
--- a/telepathy-ytstenut-glib/tests/nosey-status.c
+++ b/telepathy-ytstenut-glib/tests/nosey-status.c
@@ -225,6 +225,15 @@ status_ensured_cb (GObject *source_object,
NULL, NULL, NULL, NULL);
tp_yts_status_connect_to_service_removed (status, service_removed_cb,
NULL, NULL, NULL, NULL);
+
+ /* or you could use the GObject signals:
+ g_signal_connect (status, "status-changed",
+ G_CALLBACK (status_changed_cb), NULL);
+ g_signal_connect (status, "service-added",
+ G_CALLBACK (service_added_cb), NULL);
+ g_signal_connect (status, "service-removed",
+ G_CALLBACK (service_removed_cb), NULL);
+ */
}
g_clear_error (&error);