qwerty12 |
2010-07-12 15:46 |
Re: [Announce] scout - search contacts, conversations and calendars
Hi,
Quote:
Originally Posted by nicolai
(Post 748980)
I wished I could open the conversation app for the conversation
search result, but I couldn't find a way to do so.
|
Code:
--- scout-0.0.1.orig/src/scout-window.cpp
+++ scout-0.0.1/src/scout-window.cpp
@@ -4,6 +4,10 @@
#include <libosso.h>
#include "scout-window.h"
#include <rtcom-eventlogger/event.h>
+#include <rtcom-eventlogger-plugins/chat.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/dbus.h>
+#include <rtcom-telepathy-glib/extensions.h>
#include <string.h>
#include <libintl.h>
#include <locale.h>
@@ -899,37 +903,82 @@
const gchar* user_id,
int event_id)
{
- GtkWidget* window;
- window = hildon_stackable_window_new();
RTComElQuery *query = rtcom_el_query_new (self->priv->rt_el);
rtcom_el_query_prepare (query, "id", event_id, RTCOM_EL_OP_EQUAL, NULL);
RTComElIter* iter = rtcom_el_get_events(self->priv->rt_el, query);
g_object_unref(query);
- GtkWidget* text_view = hildon_text_view_new();
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_CHAR);
- gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
gboolean it = rtcom_el_iter_first(iter);
- if(it)
- {
- gchar* text = NULL;
- rtcom_el_iter_get_values(iter, "free-text", &text, NULL);
+ if (!it)
+ return;
+
+ gchar* remote_uid = NULL;
+ gchar* channel = NULL;
+ gint flags = 0;
+ gchar* local_uid = NULL;
+ rtcom_el_iter_get_values(iter, "remote-uid", &remote_uid, "channel", &channel, "flags", &flags, "local-uid", &local_uid, NULL);
- hildon_text_view_set_placeholder (HILDON_TEXT_VIEW (text_view),
- text);
- GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
- gtk_text_buffer_insert_at_cursor(buffer,
- text,
- strlen(text));
+ if (!((remote_uid || channel) && local_uid))
+ return;
+
+ McAccount *account = osso_abook_account_manager_lookup_by_name (NULL, local_uid);
+ if (!account)
+ goto finally;
+
+ if ((flags & RTCOM_EL_FLAG_CHAT_GROUP) && (flags & RTCOM_EL_FLAG_CHAT_OPAQUE))
+ {
+ if (!channel)
+ goto finally;
+
+ 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, channel,
+ 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
{
- hildon_text_view_set_placeholder (HILDON_TEXT_VIEW (text_view),
- "no text");
+ McAccountChannelrequestData request;
+
+ MC_ACCOUNT_CRD_INIT (&request);
+ MC_ACCOUNT_CRD_SET (&request, channel_type, TP_IFACE_QUARK_CHANNEL_TYPE_TEXT);
+
+ if ((flags & RTCOM_EL_FLAG_CHAT_ROOM) && channel)
+ {
+ MC_ACCOUNT_CRD_SET (&request, target_handle_type, TP_HANDLE_TYPE_ROOM);
+ MC_ACCOUNT_CRD_SET (&request, target_id, channel);
+ }
+ else if (remote_uid)
+ {
+ MC_ACCOUNT_CRD_SET (&request, target_handle_type, TP_HANDLE_TYPE_CONTACT);
+ MC_ACCOUNT_CRD_SET (&request, target_id, remote_uid);
+ }
+ else
+ goto finally;
+
+ mc_account_channelrequest (account,
+ &request,
+ time (NULL),
+ NULL,
+ MC_ACCOUNT_CR_FLAG_USE_EXISTING,
+ NULL, NULL, NULL, NULL);
}
- gtk_container_add(GTK_CONTAINER(window), text_view);
- gtk_window_set_title(GTK_WINDOW(window), user_id);
- gtk_widget_show_all(window);
+
+finally:
+ g_free (remote_uid);
+ g_free (channel);
+ g_free (local_uid);
}
static void
Note: I do not take credit for this method; code was taken from the Conversations Inbox Desktop Widget.
|