1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2008 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
26 #include <telepathy-glib/channel.h>
27 #include <telepathy-glib/dbus.h>
28 #include <telepathy-glib/util.h>
30 #include "empathy-tp-chat.h"
31 #include "empathy-contact-factory.h"
32 #include "empathy-marshal.h"
33 #include "empathy-debug.h"
34 #include "empathy-time.h"
35 #include "empathy-utils.h"
37 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
38 EMPATHY_TYPE_TP_CHAT, EmpathyTpChatPriv))
40 #define DEBUG_DOMAIN "TpChat"
42 struct _EmpathyTpChatPriv {
43 EmpathyContactFactory *factory;
51 gboolean had_pending_messages;
52 GSList *message_queue;
53 gboolean had_properties_list;
54 GPtrArray *properties;
60 TpPropertyFlags flags;
64 static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass);
65 static void empathy_tp_chat_init (EmpathyTpChat *chat);
84 static guint signals[LAST_SIGNAL];
86 G_DEFINE_TYPE (EmpathyTpChat, empathy_tp_chat, G_TYPE_OBJECT);
89 tp_chat_invalidated_cb (TpProxy *proxy,
95 EmpathyTpChatPriv *priv = GET_PRIV (chat);
97 empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message);
99 g_object_unref (priv->channel);
100 g_object_unref (priv->tp_chan);
101 priv->channel = NULL;
102 priv->tp_chan = NULL;
104 g_signal_emit (chat, signals[DESTROY], 0);
108 tp_chat_async_cb (TpChannel *proxy,
111 GObject *weak_object)
114 empathy_debug (DEBUG_DOMAIN, "Error %s: %s",
115 user_data, error->message);
119 static EmpathyMessage *
120 tp_chat_build_message (EmpathyTpChat *chat,
124 const gchar *message_body)
126 EmpathyTpChatPriv *priv;
127 EmpathyMessage *message;
128 EmpathyContact *sender;
130 priv = GET_PRIV (chat);
132 if (from_handle == 0) {
133 sender = g_object_ref (priv->user);
135 sender = empathy_contact_factory_get_from_handle (priv->factory,
140 message = empathy_message_new (message_body);
141 empathy_message_set_type (message, type);
142 empathy_message_set_sender (message, sender);
143 empathy_message_set_receiver (message, priv->user);
144 empathy_message_set_timestamp (message, timestamp);
146 g_object_unref (sender);
152 tp_chat_sender_ready_notify_cb (EmpathyContact *contact,
153 GParamSpec *param_spec,
156 EmpathyTpChatPriv *priv = GET_PRIV (chat);
157 EmpathyMessage *message;
158 EmpathyContactReady ready;
159 EmpathyContact *sender;
160 gboolean removed = FALSE;
162 /* Emit all messages queued until we find a message with not
163 * ready sender. When leaving this loop, sender is the first not ready
164 * contact queued and removed tells if at least one message got removed
166 while (priv->message_queue) {
167 message = priv->message_queue->data;
168 sender = empathy_message_get_sender (message);
169 ready = empathy_contact_get_ready (sender);
171 if (!(ready & EMPATHY_CONTACT_READY_NAME)) {
175 empathy_debug (DEBUG_DOMAIN, "Queued message ready");
176 g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
177 priv->message_queue = g_slist_remove (priv->message_queue,
179 g_object_unref (message);
184 g_signal_handlers_disconnect_by_func (contact,
185 tp_chat_sender_ready_notify_cb,
188 if (priv->message_queue) {
189 g_signal_connect (sender, "notify::ready",
190 G_CALLBACK (tp_chat_sender_ready_notify_cb),
197 tp_chat_emit_or_queue_message (EmpathyTpChat *chat,
198 EmpathyMessage *message)
200 EmpathyTpChatPriv *priv = GET_PRIV (chat);
201 EmpathyContact *sender;
202 EmpathyContactReady ready;
204 if (priv->message_queue != NULL) {
205 empathy_debug (DEBUG_DOMAIN, "Message queue not empty");
206 priv->message_queue = g_slist_append (priv->message_queue,
207 g_object_ref (message));
211 sender = empathy_message_get_sender (message);
212 ready = empathy_contact_get_ready (sender);
213 if (ready & EMPATHY_CONTACT_READY_NAME) {
214 empathy_debug (DEBUG_DOMAIN, "Message queue empty and sender ready");
215 g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
219 empathy_debug (DEBUG_DOMAIN, "Sender not ready");
220 priv->message_queue = g_slist_append (priv->message_queue,
221 g_object_ref (message));
222 g_signal_connect (sender, "notify::ready",
223 G_CALLBACK (tp_chat_sender_ready_notify_cb),
228 tp_chat_received_cb (TpChannel *channel,
234 const gchar *message_body,
238 EmpathyTpChatPriv *priv = GET_PRIV (chat);
239 EmpathyMessage *message;
241 if (!priv->had_pending_messages) {
245 empathy_debug (DEBUG_DOMAIN, "Message received: %s", message_body);
247 message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
253 tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
254 g_object_unref (message);
256 if (priv->acknowledge) {
259 message_ids = g_array_new (FALSE, FALSE, sizeof (guint));
260 g_array_append_val (message_ids, message_id);
261 tp_cli_channel_type_text_call_acknowledge_pending_messages (priv->channel,
265 "acknowledging pending messages",
268 g_array_free (message_ids, TRUE);
273 tp_chat_sent_cb (TpChannel *channel,
276 const gchar *message_body,
280 EmpathyMessage *message;
282 empathy_debug (DEBUG_DOMAIN, "Message sent: %s", message_body);
284 message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
290 tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
291 g_object_unref (message);
295 tp_chat_send_error_cb (TpChannel *channel,
299 const gchar *message_body,
303 EmpathyMessage *message;
305 empathy_debug (DEBUG_DOMAIN, "Message sent error: %s (%d)",
306 message_body, error_code);
308 message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
314 g_signal_emit (chat, signals[SEND_ERROR], 0, message, error_code);
315 g_object_unref (message);
319 tp_chat_state_changed_cb (TpChannel *channel,
325 EmpathyTpChatPriv *priv = GET_PRIV (chat);
326 EmpathyContact *contact;
328 contact = empathy_contact_factory_get_from_handle (priv->factory,
332 empathy_debug (DEBUG_DOMAIN, "Chat state changed for %s (%d): %d",
333 empathy_contact_get_name (contact),
336 g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state);
337 g_object_unref (contact);
341 tp_chat_list_pending_messages_cb (TpChannel *channel,
342 const GPtrArray *messages_list,
347 EmpathyTpChatPriv *priv = GET_PRIV (chat);
350 priv->had_pending_messages = TRUE;
353 empathy_debug (DEBUG_DOMAIN, "Error listing pending messages: %s",
358 for (i = 0; i < messages_list->len; i++) {
359 EmpathyMessage *message;
360 GValueArray *message_struct;
361 const gchar *message_body;
368 message_struct = g_ptr_array_index (messages_list, i);
370 message_id = g_value_get_uint (g_value_array_get_nth (message_struct, 0));
371 timestamp = g_value_get_uint (g_value_array_get_nth (message_struct, 1));
372 from_handle = g_value_get_uint (g_value_array_get_nth (message_struct, 2));
373 message_type = g_value_get_uint (g_value_array_get_nth (message_struct, 3));
374 message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4));
375 message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5));
377 empathy_debug (DEBUG_DOMAIN, "Message pending: %s", message_body);
379 message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
385 tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
386 g_object_unref (message);
391 tp_chat_property_flags_changed_cb (TpProxy *proxy,
392 const GPtrArray *properties,
396 EmpathyTpChatPriv *priv = GET_PRIV (chat);
399 if (!priv->had_properties_list || !properties) {
403 for (i = 0; i < properties->len; i++) {
404 GValueArray *prop_struct;
405 TpChatProperty *property;
409 prop_struct = g_ptr_array_index (properties, i);
410 id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
411 flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 1));
413 for (j = 0; j < priv->properties->len; j++) {
414 property = g_ptr_array_index (priv->properties, j);
415 if (property->id == id) {
416 property->flags = flags;
417 empathy_debug (DEBUG_DOMAIN,
418 "property %s flags changed: %d",
419 property->name, property->flags);
427 tp_chat_properties_changed_cb (TpProxy *proxy,
428 const GPtrArray *properties,
432 EmpathyTpChatPriv *priv = GET_PRIV (chat);
435 if (!priv->had_properties_list || !properties) {
439 for (i = 0; i < properties->len; i++) {
440 GValueArray *prop_struct;
441 TpChatProperty *property;
445 prop_struct = g_ptr_array_index (properties, i);
446 id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
447 src_value = g_value_get_boxed (g_value_array_get_nth (prop_struct, 1));
449 for (j = 0; j < priv->properties->len; j++) {
450 property = g_ptr_array_index (priv->properties, j);
451 if (property->id == id) {
452 if (property->value) {
453 g_value_copy (src_value, property->value);
455 property->value = tp_g_value_slice_dup (src_value);
458 empathy_debug (DEBUG_DOMAIN, "property %s changed",
460 g_signal_emit (chat, signals[PROPERTY_CHANGED], 0,
461 property->name, property->value);
469 tp_chat_get_properties_cb (TpProxy *proxy,
470 const GPtrArray *properties,
476 empathy_debug (DEBUG_DOMAIN, "Error getting properties: %s",
481 tp_chat_properties_changed_cb (proxy, properties, user_data, chat);
485 tp_chat_list_properties_cb (TpProxy *proxy,
486 const GPtrArray *properties,
491 EmpathyTpChatPriv *priv = GET_PRIV (chat);
495 priv->had_properties_list = TRUE;
498 empathy_debug (DEBUG_DOMAIN, "Error listing properties: %s",
503 ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len);
504 priv->properties = g_ptr_array_sized_new (properties->len);
505 for (i = 0; i < properties->len; i++) {
506 GValueArray *prop_struct;
507 TpChatProperty *property;
509 prop_struct = g_ptr_array_index (properties, i);
510 property = g_slice_new0 (TpChatProperty);
511 property->id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
512 property->name = g_value_dup_string (g_value_array_get_nth (prop_struct, 1));
513 property->flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 3));
515 empathy_debug (DEBUG_DOMAIN, "Adding property name=%s id=%d flags=%d",
516 property->name, property->id, property->flags);
517 g_ptr_array_add (priv->properties, property);
518 if (property->flags & TP_PROPERTY_FLAG_READ) {
519 g_array_append_val (ids, property->id);
523 tp_cli_properties_interface_call_get_properties (proxy, -1,
525 tp_chat_get_properties_cb,
529 g_array_free (ids, TRUE);
533 empathy_tp_chat_set_property (EmpathyTpChat *chat,
537 EmpathyTpChatPriv *priv = GET_PRIV (chat);
538 TpChatProperty *property;
541 for (i = 0; i < priv->properties->len; i++) {
542 property = g_ptr_array_index (priv->properties, i);
543 if (!tp_strdiff (property->name, name)) {
544 GPtrArray *properties;
547 GValue dest_value = {0, };
549 if (!(property->flags & TP_PROPERTY_FLAG_WRITE)) {
553 g_value_init (&id, G_TYPE_UINT);
554 g_value_init (&dest_value, G_TYPE_VALUE);
555 g_value_set_uint (&id, property->id);
556 g_value_set_boxed (&dest_value, value);
558 prop = g_value_array_new (2);
559 g_value_array_append (prop, &id);
560 g_value_array_append (prop, &dest_value);
562 properties = g_ptr_array_sized_new (1);
563 g_ptr_array_add (properties, prop);
565 empathy_debug (DEBUG_DOMAIN, "Set property %s", name);
566 tp_cli_properties_interface_call_set_properties (priv->channel, -1,
568 (tp_cli_properties_interface_callback_for_set_properties)
570 "Seting property", NULL,
573 g_ptr_array_free (properties, TRUE);
574 g_value_array_free (prop);
582 tp_chat_channel_ready_cb (EmpathyTpChat *chat)
584 EmpathyTpChatPriv *priv = GET_PRIV (chat);
586 empathy_debug (DEBUG_DOMAIN, "Channel ready");
588 tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
590 tp_chat_list_pending_messages_cb,
593 tp_cli_properties_interface_call_list_properties (priv->channel, -1,
594 tp_chat_list_properties_cb,
599 tp_cli_channel_type_text_connect_to_received (priv->channel,
602 G_OBJECT (chat), NULL);
603 tp_cli_channel_type_text_connect_to_sent (priv->channel,
606 G_OBJECT (chat), NULL);
607 tp_cli_channel_type_text_connect_to_send_error (priv->channel,
608 tp_chat_send_error_cb,
610 G_OBJECT (chat), NULL);
611 tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
612 tp_chat_state_changed_cb,
614 G_OBJECT (chat), NULL);
615 tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
616 tp_chat_state_changed_cb,
618 G_OBJECT (chat), NULL);
619 tp_cli_properties_interface_connect_to_properties_changed (priv->channel,
620 tp_chat_properties_changed_cb,
622 G_OBJECT (chat), NULL);
623 tp_cli_properties_interface_connect_to_property_flags_changed (priv->channel,
624 tp_chat_property_flags_changed_cb,
626 G_OBJECT (chat), NULL);
632 tp_chat_finalize (GObject *object)
634 EmpathyTpChatPriv *priv = GET_PRIV (object);
637 if (priv->acknowledge && priv->channel) {
638 empathy_debug (DEBUG_DOMAIN, "Closing channel...");
639 tp_cli_channel_call_close (priv->channel, -1,
641 "closing channel", NULL,
646 g_signal_handlers_disconnect_by_func (priv->channel,
647 tp_chat_invalidated_cb,
649 g_object_unref (priv->channel);
652 g_object_unref (priv->tp_chan);
655 if (priv->properties) {
656 for (i = 0; i < priv->properties->len; i++) {
657 TpChatProperty *property;
659 property = g_ptr_array_index (priv->properties, i);
660 g_free (property->name);
661 if (property->value) {
662 tp_g_value_slice_free (property->value);
664 g_slice_free (TpChatProperty, property);
666 g_ptr_array_free (priv->properties, TRUE);
669 g_object_unref (priv->factory);
670 g_object_unref (priv->user);
671 g_object_unref (priv->account);
672 g_object_unref (priv->mc);
675 G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object);
679 tp_chat_constructor (GType type,
681 GObjectConstructParam *props)
684 EmpathyTpChatPriv *priv;
685 gboolean channel_ready;
687 chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);
689 priv = GET_PRIV (chat);
690 priv->factory = empathy_contact_factory_new ();
691 priv->user = empathy_contact_factory_get_user (priv->factory, priv->account);
692 priv->mc = empathy_mission_control_new ();
694 g_signal_connect (priv->channel, "invalidated",
695 G_CALLBACK (tp_chat_invalidated_cb),
698 g_object_get (priv->channel, "channel-ready", &channel_ready, NULL);
700 /* FIXME: We do that in a cb to let time to set the acknowledge
701 * property, this property should be required for construct. */
702 g_idle_add ((GSourceFunc) tp_chat_channel_ready_cb, chat);
704 g_signal_connect_swapped (priv->channel, "notify::channel-ready",
705 G_CALLBACK (tp_chat_channel_ready_cb),
713 tp_chat_get_property (GObject *object,
718 EmpathyTpChatPriv *priv = GET_PRIV (object);
722 g_value_set_object (value, priv->account);
725 g_value_set_object (value, priv->tp_chan);
728 g_value_set_object (value, priv->channel);
730 case PROP_ACKNOWLEDGE:
731 g_value_set_boolean (value, priv->acknowledge);
734 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
740 tp_chat_set_property (GObject *object,
745 EmpathyTpChatPriv *priv = GET_PRIV (object);
749 priv->account = g_object_ref (g_value_get_object (value));
752 priv->tp_chan = g_object_ref (g_value_get_object (value));
755 priv->channel = g_object_ref (g_value_get_object (value));
757 case PROP_ACKNOWLEDGE:
758 empathy_tp_chat_set_acknowledge (EMPATHY_TP_CHAT (object),
759 g_value_get_boolean (value));
762 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
768 empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
770 GObjectClass *object_class = G_OBJECT_CLASS (klass);
772 object_class->finalize = tp_chat_finalize;
773 object_class->constructor = tp_chat_constructor;
774 object_class->get_property = tp_chat_get_property;
775 object_class->set_property = tp_chat_set_property;
777 /* Construct properties */
778 g_object_class_install_property (object_class,
780 g_param_spec_object ("account",
782 "The account associated with the channel",
785 G_PARAM_CONSTRUCT_ONLY));
786 g_object_class_install_property (object_class,
788 g_param_spec_object ("tp-chan",
790 "The text channel for the chat",
793 G_PARAM_CONSTRUCT_ONLY));
795 g_object_class_install_property (object_class,
797 g_param_spec_object ("channel",
799 "The text channel for the chat",
802 G_PARAM_CONSTRUCT_ONLY));
804 g_object_class_install_property (object_class,
806 g_param_spec_boolean ("acknowledge",
807 "acknowledge messages",
808 "Wheter or not received messages should be acknowledged",
814 signals[MESSAGE_RECEIVED] =
815 g_signal_new ("message-received",
816 G_TYPE_FROM_CLASS (klass),
820 g_cclosure_marshal_VOID__OBJECT,
822 1, EMPATHY_TYPE_MESSAGE);
824 signals[SEND_ERROR] =
825 g_signal_new ("send-error",
826 G_TYPE_FROM_CLASS (klass),
830 _empathy_marshal_VOID__OBJECT_UINT,
832 2, EMPATHY_TYPE_MESSAGE, G_TYPE_UINT);
834 signals[CHAT_STATE_CHANGED] =
835 g_signal_new ("chat-state-changed",
836 G_TYPE_FROM_CLASS (klass),
840 _empathy_marshal_VOID__OBJECT_UINT,
842 2, EMPATHY_TYPE_CONTACT, G_TYPE_UINT);
844 signals[PROPERTY_CHANGED] =
845 g_signal_new ("property-changed",
846 G_TYPE_FROM_CLASS (klass),
850 _empathy_marshal_VOID__STRING_BOXED,
852 2, G_TYPE_STRING, G_TYPE_VALUE);
855 g_signal_new ("destroy",
856 G_TYPE_FROM_CLASS (klass),
860 g_cclosure_marshal_VOID__VOID,
864 g_type_class_add_private (object_class, sizeof (EmpathyTpChatPriv));
868 empathy_tp_chat_init (EmpathyTpChat *chat)
873 empathy_tp_chat_new (McAccount *account,
878 TpConnection *connection;
882 mc = empathy_mission_control_new ();
883 tp_conn = mission_control_get_connection (mc, account, NULL);
884 connection = tp_conn_dup_connection (tp_conn);
885 channel = tp_chan_dup_channel (tp_chan, connection, NULL);
887 chat = g_object_new (EMPATHY_TYPE_TP_CHAT,
893 g_object_unref (channel);
894 g_object_unref (tp_conn);
895 g_object_unref (connection);
902 empathy_tp_chat_new_with_contact (EmpathyContact *contact)
909 const gchar *bus_name;
912 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
914 mc = empathy_mission_control_new ();
915 account = empathy_contact_get_account (contact);
917 if (mission_control_get_connection_status (mc, account, NULL) != 0) {
918 /* The account is not connected. */
922 tp_conn = mission_control_get_connection (mc, account, NULL);
923 g_return_val_if_fail (tp_conn != NULL, NULL);
924 bus_name = dbus_g_proxy_get_bus_name (DBUS_G_PROXY (tp_conn));
925 handle = empathy_contact_get_handle (contact);
927 text_chan = tp_conn_new_channel (tp_get_bus (),
930 TP_IFACE_CHANNEL_TYPE_TEXT,
931 TP_HANDLE_TYPE_CONTACT,
935 chat = empathy_tp_chat_new (account, text_chan);
937 g_object_unref (tp_conn);
938 g_object_unref (text_chan);
945 empathy_tp_chat_get_acknowledge (EmpathyTpChat *chat)
947 EmpathyTpChatPriv *priv;
949 g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), FALSE);
951 priv = GET_PRIV (chat);
953 return priv->acknowledge;
957 empathy_tp_chat_set_acknowledge (EmpathyTpChat *chat,
958 gboolean acknowledge)
960 EmpathyTpChatPriv *priv;
962 g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
964 priv = GET_PRIV (chat);
966 priv->acknowledge = acknowledge;
967 g_object_notify (G_OBJECT (chat), "acknowledge");
971 empathy_tp_chat_get_channel (EmpathyTpChat *chat)
973 EmpathyTpChatPriv *priv;
975 g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
977 priv = GET_PRIV (chat);
979 return priv->tp_chan;
983 empathy_tp_chat_get_account (EmpathyTpChat *chat)
985 EmpathyTpChatPriv *priv;
987 g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
989 priv = GET_PRIV (chat);
991 return priv->account;
995 empathy_tp_chat_send (EmpathyTpChat *chat,
996 EmpathyMessage *message)
998 EmpathyTpChatPriv *priv;
999 const gchar *message_body;
1000 EmpathyMessageType message_type;
1002 g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
1003 g_return_if_fail (EMPATHY_IS_MESSAGE (message));
1005 priv = GET_PRIV (chat);
1007 message_body = empathy_message_get_body (message);
1008 message_type = empathy_message_get_type (message);
1010 empathy_debug (DEBUG_DOMAIN, "Sending message: %s", message_body);
1011 tp_cli_channel_type_text_call_send (priv->channel, -1,
1015 "sending message", NULL,
1020 empathy_tp_chat_set_state (EmpathyTpChat *chat,
1021 TpChannelChatState state)
1023 EmpathyTpChatPriv *priv;
1025 g_return_if_fail (EMPATHY_IS_TP_CHAT (chat));
1027 priv = GET_PRIV (chat);
1029 empathy_debug (DEBUG_DOMAIN, "Set state: %d", state);
1030 tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1,
1033 "setting chat state",
1039 empathy_tp_chat_get_id (EmpathyTpChat *chat)
1041 EmpathyTpChatPriv *priv;
1043 g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
1045 priv = GET_PRIV (chat);
1048 priv->id = empathy_inspect_channel (priv->account, priv->tp_chan);