[Telepathy] obtaining handles to contacts to establish a text channel
harini satyanarayanan
hpundis1 at binghamton.edu
Mon Feb 18 17:16:13 PST 2008
hi,
I am trying to write telepathy code to establisg a text channel
with any one in my contact list. I am not sure how to obtain the
handle for the contact that you want to communicate with.
this is a snipet of the code i am using where i am first trying to get
the handle of the conatct then use it to send messages.
It throws an error that didnt get handle for contact. If this is wrong
then how do i mention the contact to which i have to send the message.
const gchar* lists1[] = { "contact at gmail.com", NULL };
GArray *handles1 = NULL;
if (!tp_conn_request_handles (DBUS_G_PROXY(tp_connection),
TP_HANDLE_TYPE_CONTACT, lists, &handles1, &error)) {
g_warning("Didn't get a handle for the '%s' list\n", lists1[0]);
} else {
g_assert (handles1 != NULL);
handle = g_array_index (handles, guint, 0);
g_array_free (handles1, TRUE);
}
g_print("\n handle for text channel = %d \n ",handle);
g_print("Attempting to create a text channel object.\n");
TpChan* text_channel = tp_conn_new_channel(dbus_conn,
tp_connection,bus_name,TP_IFACE_CHANNEL_TYPE_TEXT,
TP_HANDLE_TYPE_CONTACT,handle, TRUE);
if (text_channel == NULL)
{
g_warning("Failed to create a channel (tp_chan) object.\n");
}
telepathy_sending_messages(text_channel);
void telepathy_sending_messages(TpChan* text_channel)
{
DBusGProxy* text_iface =NULL;
GError* error = NULL;
text_iface = tp_chan_get_interface (text_channel,
TELEPATHY_CHAN_IFACE_TEXT_QUARK);
if (text_iface == NULL)
{
g_print("Could not acquire text interface proxy for
channel for sending messages \n");
}
else
{
/* Attach a received text handler to the type interface proxy */
dbus_g_proxy_add_signal(text_iface, "Received",
G_TYPE_UINT,G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,G_TYPE_STRING,
G_TYPE_INVALID);
g_print("Text interface proxy acquired for sending messages. \n");
g_print("Send Messages\n");
if (!tp_chan_type_text_send(text_iface,TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,"trial
message", &error))
{
g_print("Error sending message list: %s.\n",error->message);
}
else
{
g_print("\n telepathy_send_message: handle: %d
handle_type: %d type: %s \n ", text_channel->handle,
text_channel->handle_type,
dbus_g_proxy_get_path(DBUS_G_PROXY(text_channel)));
}
g_object_unref(text_iface);
}
}
Can some one please help me
Thanks,
harini
More information about the Telepathy
mailing list