summaryrefslogtreecommitdiff
path: root/src/conn-olpc.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-11 14:52:35 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-18 10:11:38 +0200
commit4239c68b03958dea18b5ea2414517c0756bdc840 (patch)
treea9bcff4545bc36aa43a380cbb1f843136ba4a563 /src/conn-olpc.c
parentf7f3b2fc121764aa4460f68e51114b4383a228e3 (diff)
downloadtelepathy-gabble-4239c68b03958dea18b5ea2414517c0756bdc840.tar.gz
Add a method for retrieving an activity's room handle from its id
Diffstat (limited to 'src/conn-olpc.c')
-rw-r--r--src/conn-olpc.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 915e0450f..22fe163f3 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -3876,6 +3876,54 @@ conn_olpc_activity_properties_dispose (GabbleConnection *self)
self->olpc_activities_info = NULL;
}
+static GabbleOlpcActivity *
+find_activity_by_id (GabbleConnection *self,
+ const gchar *activity_id)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, self->olpc_activities_info);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ GabbleOlpcActivity *activity = GABBLE_OLPC_ACTIVITY (value);
+ if (strcmp (activity->id, activity_id) == 0)
+ return activity;
+ }
+
+ return NULL;
+}
+
+static void
+olpc_activity_properties_get_activity (GabbleSvcOLPCActivityProperties *iface,
+ const gchar *activity_id,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnection *self = GABBLE_CONNECTION (iface);
+ TpBaseConnection *base = (TpBaseConnection *) self;
+ GabbleOlpcActivity *activity;
+ GError *error = NULL;
+
+ TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
+
+ activity = find_activity_by_id (self, activity_id);
+ if (activity == NULL)
+ {
+ g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "Activity unknown: %s", activity_id);
+ goto error;
+ }
+
+ gabble_svc_olpc_activity_properties_return_from_get_activity (context,
+ activity->room);
+
+ return;
+
+error:
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+}
+
void
olpc_activity_properties_iface_init (gpointer g_iface,
gpointer iface_data)
@@ -3886,6 +3934,7 @@ olpc_activity_properties_iface_init (gpointer g_iface,
klass, olpc_activity_properties_##x)
IMPLEMENT(get_properties);
IMPLEMENT(set_properties);
+ IMPLEMENT(get_activity);
#undef IMPLEMENT
}