Open conversation on message click
[conv-inbox] / src / el-home-applet.c
index 82388c9..4f7858e 100644 (file)
@@ -36,6 +36,8 @@
 #include <libosso-abook/osso-abook-temporary-contact-dialog.h>
 #include <libosso-abook/osso-abook-account-manager.h>
 
+#include <telepathy-glib/interfaces.h>
+
 #define EL_HOME_APPLET_GET_PRIVATE(obj) ( \
         G_TYPE_INSTANCE_GET_PRIVATE (obj, \
                 EL_TYPE_HOME_APPLET, ELHomeAppletPrivate))
@@ -916,6 +918,35 @@ mark_as_read (ELHomeApplet *self)
         }
 }
 
+static void
+open_conversation (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+        McAccount *account;
+        McAccountChannelrequestData request;
+
+        if (!(priv->remote_id && priv->local_id))
+                return;
+
+        account = osso_abook_account_manager_lookup_by_name (NULL,
+                                                             priv->local_id);
+        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);
+}
+
 static gboolean
 read_new_event (ELHomeApplet *self)
 {
@@ -1070,7 +1101,8 @@ button_release_event_cb (GtkWidget      *widget,
                 }
                 else {
 #ifndef DEBUG_LAYOUT
-                        mark_as_read (self);
+                        /* mark_as_read (self); */
+                        open_conversation (self);
 #endif
                 }