From: Artem Garmash Date: Sun, 17 Jan 2010 20:12:54 +0000 (+0200) Subject: Support group chats with persistent id X-Git-Url: http://git.maemo.org/git/?p=conv-inbox;a=commitdiff_plain;h=4864f31536ae759376a3c7e6285fc4f2431cca0c Support group chats with persistent id --- diff --git a/configure.ac b/configure.ac index bda4647..7e1182c 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,8 @@ PKG_CHECK_MODULES([LIBHILDONDESKTOP], PKG_CHECK_MODULES([LIBOSSO_ABOOK], [libosso-abook-1.0]) PKG_CHECK_MODULES([LIBTP_GLIB], - [telepathy-glib]) + [telepathy-glib + rtcom-telepathy-glib]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [enable debugging])], diff --git a/debian/control b/debian/control index 24de726..95c19f9 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,8 @@ Priority: extra Section: user/desktop Maintainer: Artem Garmash Build-Depends: debhelper (>= 4.0.0), cdbs, autotools-dev, librtcom-eventlogger-dev, - libhildondesktop1-dev (>= 2.1.7), libtelepathy-glib-dev + libhildondesktop1-dev (>= 2.1.7), libtelepathy-glib-dev, librtcom-telepathy-glib-dev, + libosso-abook-dev Standards-Version: 3.6.2 Package: conversations-inbox-widget diff --git a/src/el-home-applet.c b/src/el-home-applet.c index 3e6c0e3..236c783 100644 --- a/src/el-home-applet.c +++ b/src/el-home-applet.c @@ -37,6 +37,8 @@ #include #include +#include +#include #define EL_HOME_APPLET_GET_PRIVATE(obj) ( \ G_TYPE_INSTANCE_GET_PRIVATE (obj, \ @@ -117,6 +119,7 @@ struct _ELHomeAppletPrivate gchar *contact_id; gchar *remote_id; gchar *local_id; + gchar *group_uid; OssoABookContact *contact; }; @@ -511,6 +514,10 @@ clean_state (ELHomeApplet *self) g_free (priv->remote_id); priv->remote_id = NULL; } + if (priv->group_uid) { + g_free (priv->group_uid); + priv->group_uid = NULL; + } if (priv->contact) { g_object_unref (priv->contact); @@ -722,6 +729,7 @@ show_event (ELHomeApplet *self, RTComElIter *it) priv->remote_id = NULL; } } + rtcom_el_iter_dup_string (it, "group-uid", &priv->group_uid); #if 0 service = rtcom_el_iter_get_service (it); if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_SMS")) @@ -966,9 +974,9 @@ open_conversation (ELHomeApplet *self) { ELHomeAppletPrivate *priv = self->priv; McAccount *account; - McAccountChannelrequestData request; + const gchar *persistent_id = NULL; - if (!(priv->remote_id && priv->local_id)) + if (!((priv->remote_id || priv->group_uid) && priv->local_id)) return; account = osso_abook_account_manager_lookup_by_name (NULL, @@ -976,18 +984,47 @@ open_conversation (ELHomeApplet *self) if (!account) return; - MC_ACCOUNT_CRD_INIT (&request); - MC_ACCOUNT_CRD_SET (&request, channel_type, TP_IFACE_QUARK_CHANNEL_TYPE_TEXT); - MC_ACCOUNT_CRD_SET (&request, target_handle_type, TP_HANDLE_TYPE_CONTACT); - MC_ACCOUNT_CRD_SET (&request, target_id, priv->remote_id); - - mc_account_channelrequest ( - account, - &request, - time (NULL), - NULL, /* handler */ - MC_ACCOUNT_CR_FLAG_USE_EXISTING, - NULL, NULL, NULL, NULL); + if (priv->group_uid && + g_str_has_prefix (priv->group_uid, "group:")) { + persistent_id = strchr (priv->group_uid, '-'); + if (persistent_id) + persistent_id++; + } + + if (persistent_id && persistent_id[0] != '\0') { + GHashTable *properties = tp_asv_new + (TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_TEXT, + TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_UINT, + TP_HANDLE_TYPE_NONE, + RTCOM_TP_IFACE_CHANNEL_INTERFACE_PERSISTENT ".PersistentID", + G_TYPE_STRING, persistent_id, + NULL); + + mc_account_channelrequest_ht (account, + properties, + time (NULL), + NULL, + MC_ACCOUNT_CR_FLAG_USE_EXISTING, + NULL, NULL, NULL, NULL); + + g_hash_table_unref (properties); + } + else if (priv->remote_id) { + McAccountChannelrequestData request; + + MC_ACCOUNT_CRD_INIT (&request); + MC_ACCOUNT_CRD_SET (&request, channel_type, TP_IFACE_QUARK_CHANNEL_TYPE_TEXT); + MC_ACCOUNT_CRD_SET (&request, target_handle_type, TP_HANDLE_TYPE_CONTACT); + MC_ACCOUNT_CRD_SET (&request, target_id, priv->remote_id); + + mc_account_channelrequest (account, + &request, + time (NULL), + NULL, + MC_ACCOUNT_CR_FLAG_USE_EXISTING, + NULL, NULL, NULL, NULL); + } } static gboolean