aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-03-11 20:22:57 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-03-11 20:22:57 +0800
commitc97b20c86e3cc38706366fb273814d4af7607eae (patch)
tree1dbde3a35d258d74704964c0e34ccc2fb2415bc8 /libempathy
parent9f6da133539e93d3bd1ffbc080b9d317bd5e7a27 (diff)
downloadgsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar.gz
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar.bz2
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar.lz
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar.xz
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.tar.zst
gsoc2013-empathy-c97b20c86e3cc38706366fb273814d4af7607eae.zip
Prepare a new API for chat properties
svn path=/trunk/; revision=766
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-chat.c64
-rw-r--r--libempathy/empathy-tp-chatroom.c201
-rw-r--r--libempathy/empathy-tp-chatroom.h2
3 files changed, 160 insertions, 107 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 4e6a94bb0..3a2f71df1 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -369,6 +369,53 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
}
}
+static void
+tp_chat_properties_changed_cb (TpProxy *proxy,
+ const GPtrArray *properties,
+ gpointer user_data,
+ GObject *chat)
+{
+}
+
+static void
+tp_chat_get_properties_cb (TpProxy *proxy,
+ const GPtrArray *properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *chat)
+{
+ tp_chat_properties_changed_cb (proxy, properties, user_data, chat);
+}
+
+static void
+tp_chat_list_properties_cb (TpProxy *proxy,
+ const GPtrArray *properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *chat)
+{
+ GArray *ids;
+ guint i;
+
+ ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len);
+ for (i = 0; i < properties->len; i++) {
+ GValueArray *prop_struct;
+ guint id;
+
+ prop_struct = g_ptr_array_index (properties, i);
+ id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
+ g_array_append_val (ids, id);
+ }
+
+ tp_cli_properties_interface_call_get_properties (proxy, -1,
+ ids,
+ tp_chat_get_properties_cb,
+ NULL, NULL,
+ chat);
+
+ g_array_free (ids, TRUE);
+}
+
static gboolean
tp_chat_channel_ready_cb (EmpathyTpChat *chat)
{
@@ -381,6 +428,11 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
tp_chat_list_pending_messages_cb,
NULL, NULL,
G_OBJECT (chat));
+ tp_cli_properties_interface_call_list_properties (priv->channel, -1,
+ tp_chat_list_properties_cb,
+ NULL, NULL,
+ G_OBJECT (chat));
+
tp_cli_channel_type_text_connect_to_received (priv->channel,
tp_chat_received_cb,
@@ -398,6 +450,14 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
tp_chat_state_changed_cb,
NULL, NULL,
G_OBJECT (chat), NULL);
+ tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
+ tp_chat_state_changed_cb,
+ NULL, NULL,
+ G_OBJECT (chat), NULL);
+ tp_cli_properties_interface_connect_to_properties_changed (priv->channel,
+ tp_chat_properties_changed_cb,
+ NULL, NULL,
+ G_OBJECT (chat), NULL);
return FALSE;
}
@@ -465,10 +525,6 @@ tp_chat_constructor (GType type,
chat);
}
- /* FIXME: We do that in a cb to let time to set the acknowledge
- * property, this property should be required for construct. */
- g_idle_add ((GSourceFunc) empathy_tp_chat_get_pendings, chat);
-
return chat;
}
diff --git a/libempathy/empathy-tp-chatroom.c b/libempathy/empathy-tp-chatroom.c
index ae6f65865..52d274e25 100644
--- a/libempathy/empathy-tp-chatroom.c
+++ b/libempathy/empathy-tp-chatroom.c
@@ -43,63 +43,12 @@ struct _EmpathyTpChatroomPriv {
static void empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass);
static void tp_chatroom_iface_init (EmpathyContactListIface *iface);
static void empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom);
-static void tp_chatroom_finalize (GObject *object);
-static void tp_chatroom_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
-static void tp_chatroom_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message);
-static GList * tp_chatroom_get_members (EmpathyContactList *list);
G_DEFINE_TYPE_WITH_CODE (EmpathyTpChatroom, empathy_tp_chatroom, EMPATHY_TYPE_TP_CHAT,
G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
tp_chatroom_iface_init));
static void
-empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tp_chatroom_finalize;
-
- g_type_class_add_private (object_class, sizeof (EmpathyTpChatroomPriv));
-}
-
-static void
-tp_chatroom_iface_init (EmpathyContactListIface *iface)
-{
- iface->add = tp_chatroom_add;
- iface->remove = tp_chatroom_remove;
- iface->get_members = tp_chatroom_get_members;
-}
-
-static void
-empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom)
-{
-}
-
-static void
-tp_chatroom_finalize (GObject *object)
-{
- EmpathyTpChatroomPriv *priv;
- EmpathyTpChatroom *chatroom;
-
- chatroom = EMPATHY_TP_CHATROOM (object);
- priv = GET_PRIV (chatroom);
-
- g_object_unref (priv->group);
-
- if (priv->invitor) {
- g_object_unref (priv->invitor);
- }
-
- g_free (priv->invit_message);
-
- G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
-}
-
-static void
tp_chatroom_member_added_cb (EmpathyTpGroup *group,
EmpathyContact *contact,
EmpathyContact *actor,
@@ -146,19 +95,113 @@ tp_chatroom_local_pending_cb (EmpathyTpGroup *group,
}
}
+static void
+tp_chatroom_add (EmpathyContactList *list,
+ EmpathyContact *contact,
+ const gchar *message)
+{
+ EmpathyTpChatroomPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ priv = GET_PRIV (list);
+
+ empathy_tp_group_add_member (priv->group, contact, message);
+}
+
+static void
+tp_chatroom_remove (EmpathyContactList *list,
+ EmpathyContact *contact,
+ const gchar *message)
+{
+ EmpathyTpChatroomPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ priv = GET_PRIV (list);
+
+ empathy_tp_group_remove_member (priv->group, contact, message);
+}
+
+static GList *
+tp_chatroom_get_members (EmpathyContactList *list)
+{
+ EmpathyTpChatroomPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CHATROOM (list), NULL);
+
+ priv = GET_PRIV (list);
+
+ return empathy_tp_group_get_members (priv->group);
+}
+
+static void
+tp_chatroom_finalize (GObject *object)
+{
+ EmpathyTpChatroomPriv *priv;
+ EmpathyTpChatroom *chatroom;
+
+ chatroom = EMPATHY_TP_CHATROOM (object);
+ priv = GET_PRIV (chatroom);
+
+ g_object_unref (priv->group);
+
+ if (priv->invitor) {
+ g_object_unref (priv->invitor);
+ }
+
+ g_free (priv->invit_message);
+
+ G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
+}
+
+static void
+empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = tp_chatroom_finalize;
+
+ g_type_class_add_private (object_class, sizeof (EmpathyTpChatroomPriv));
+}
+
+static void
+tp_chatroom_iface_init (EmpathyContactListIface *iface)
+{
+ iface->add = tp_chatroom_add;
+ iface->remove = tp_chatroom_remove;
+ iface->get_members = tp_chatroom_get_members;
+}
+
+static void
+empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom)
+{
+}
+
EmpathyTpChatroom *
empathy_tp_chatroom_new (McAccount *account,
TpChan *tp_chan)
{
EmpathyTpChatroomPriv *priv;
EmpathyTpChatroom *chatroom;
+ TpChannel *channel;
+ TpConnection *connection;
+ MissionControl *mc;
+ TpConn *tp_conn;
g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL);
+ mc = empathy_mission_control_new ();
+ tp_conn = mission_control_get_connection (mc, account, NULL);
+ connection = tp_conn_dup_connection (tp_conn);
+ channel = tp_chan_dup_channel (tp_chan, connection, NULL);
+
chatroom = g_object_new (EMPATHY_TYPE_TP_CHATROOM,
"account", account,
- "tp-chan", tp_chan,
+ "channel", channel,
NULL);
priv = GET_PRIV (chatroom);
@@ -175,6 +218,11 @@ empathy_tp_chatroom_new (McAccount *account,
G_CALLBACK (tp_chatroom_local_pending_cb),
chatroom);
+ g_object_unref (channel);
+ g_object_unref (tp_conn);
+ g_object_unref (connection);
+ g_object_unref (mc);
+
return chatroom;
}
@@ -228,52 +276,3 @@ empathy_tp_chatroom_accept_invitation (EmpathyTpChatroom *chatroom)
g_object_unref (user);
}
-void
-empathy_tp_chatroom_set_topic (EmpathyTpChatroom *chatroom,
- const gchar *topic)
-{
- /* FIXME: not implemented */
-}
-
-static void
-tp_chatroom_add (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (list);
-
- empathy_tp_group_add_member (priv->group, contact, message);
-}
-
-static void
-tp_chatroom_remove (EmpathyContactList *list,
- EmpathyContact *contact,
- const gchar *message)
-{
- EmpathyTpChatroomPriv *priv;
-
- g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
- g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
- priv = GET_PRIV (list);
-
- empathy_tp_group_remove_member (priv->group, contact, message);
-}
-
-static GList *
-tp_chatroom_get_members (EmpathyContactList *list)
-{
- EmpathyTpChatroomPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CHATROOM (list), NULL);
-
- priv = GET_PRIV (list);
-
- return empathy_tp_group_get_members (priv->group);
-}
-
diff --git a/libempathy/empathy-tp-chatroom.h b/libempathy/empathy-tp-chatroom.h
index 8f0a18100..85bcf6f81 100644
--- a/libempathy/empathy-tp-chatroom.h
+++ b/libempathy/empathy-tp-chatroom.h
@@ -58,8 +58,6 @@ gboolean empathy_tp_chatroom_get_invitation (EmpathyTpChatroom *ch
EmpathyContact **contact,
const gchar **message);
void empathy_tp_chatroom_accept_invitation (EmpathyTpChatroom *chatroom);
-void empathy_tp_chatroom_set_topic (EmpathyTpChatroom *chatroom,
- const gchar *topic);
G_END_DECLS
#endif /* __EMPATHY_TP_CHATROOM_H__ */