From 5819aef6c2d18cc328d7de4d80123223320a0202 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Tue, 28 Sep 2010 23:13:19 +0300 Subject: [PATCH] chat: add type field to sipe_chat_session Prepare to bring Multiparty chat & conference back... --- src/core/sipe-chat.c | 46 ++++++++++++++++++++++++++++++++++++---------- src/core/sipe-chat.h | 12 ++++++++++-- src/core/sipe-groupchat.c | 4 ++-- src/core/sipe-incoming.c | 3 ++- src/core/sipe.c | 3 ++- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/core/sipe-chat.c b/src/core/sipe-chat.c index 74756cb9..876273ea 100644 --- a/src/core/sipe-chat.c +++ b/src/core/sipe-chat.c @@ -49,12 +49,14 @@ static GList *chat_sessions = NULL; -struct sipe_chat_session *sipe_chat_create_session(const gchar *id, +struct sipe_chat_session *sipe_chat_create_session(enum sipe_chat_type type, + const gchar *id, const gchar *title) { struct sipe_chat_session *session = g_new0(struct sipe_chat_session, 1); session->id = g_strdup(id); session->title = g_strdup(title); + session->type = type; chat_sessions = g_list_prepend(chat_sessions, session); return(session); } @@ -98,10 +100,18 @@ void sipe_core_chat_rejoin(struct sipe_core_public *sipe_public, SIPE_DEBUG_INFO("sipe_core_chat_rejoin: '%s'", chat_session->title); - if (chat_session->is_groupchat) { - sipe_groupchat_rejoin(sipe_private, chat_session); - } else { + switch (chat_session->type) { + case SIPE_CHAT_TYPE_MULTIPARTY: + /* @TODO */ + break; + case SIPE_CHAT_TYPE_CONFERENCE: /* @TODO */ + break; + case SIPE_CHAT_TYPE_GROUPCHAT: + sipe_groupchat_rejoin(sipe_private, chat_session); + break; + default: + break; } } @@ -112,10 +122,18 @@ void sipe_core_chat_leave(struct sipe_core_public *sipe_public, SIPE_DEBUG_INFO("sipe_core_chat_leave: '%s'", chat_session->title); - if (chat_session->is_groupchat) { - sipe_groupchat_leave(sipe_private, chat_session); - } else { + switch (chat_session->type) { + case SIPE_CHAT_TYPE_MULTIPARTY: /* @TODO */ + break; + case SIPE_CHAT_TYPE_CONFERENCE: + /* @TODO */ + break; + case SIPE_CHAT_TYPE_GROUPCHAT: + sipe_groupchat_leave(sipe_private, chat_session); + break; + default: + break; } #if 0 @@ -138,10 +156,18 @@ void sipe_core_chat_send(struct sipe_core_public *sipe_public, SIPE_DEBUG_INFO("sipe_core_chat_send: '%s' to '%s'", what, chat_session->title); - if (chat_session->is_groupchat) { - sipe_groupchat_send(sipe_private, chat_session, what); - } else { + switch (chat_session->type) { + case SIPE_CHAT_TYPE_MULTIPARTY: + /* @TODO */ + break; + case SIPE_CHAT_TYPE_CONFERENCE: /* @TODO */ + break; + case SIPE_CHAT_TYPE_GROUPCHAT: + sipe_groupchat_send(sipe_private, chat_session, what); + break; + default: + break; } #if 0 diff --git a/src/core/sipe-chat.h b/src/core/sipe-chat.h index 2e92c0a7..9d892763 100644 --- a/src/core/sipe-chat.h +++ b/src/core/sipe-chat.h @@ -25,6 +25,13 @@ struct sipe_core_private; struct sip_session; struct sipe_backend_chat_session; +enum sipe_chat_type { + SIPE_CHAT_TYPE_UNKNOWN = 0, + SIPE_CHAT_TYPE_MULTIPARTY, + SIPE_CHAT_TYPE_CONFERENCE, + SIPE_CHAT_TYPE_GROUPCHAT +}; + struct sipe_chat_session { struct sipe_backend_chat_session *backend; struct sip_session *session; @@ -41,7 +48,7 @@ struct sipe_chat_session { /* Human readable chat identifier (can have duplicates) */ gchar *title; - gboolean is_groupchat; + enum sipe_chat_type type; }; /** @@ -50,7 +57,8 @@ struct sipe_chat_session { * @param session */ struct sipe_chat_session * -sipe_chat_create_session(const gchar *id, const gchar *title); +sipe_chat_create_session(enum sipe_chat_type type, + const gchar *id, const gchar *title); /** * Remove a chat session diff --git a/src/core/sipe-groupchat.c b/src/core/sipe-groupchat.c index 90a38f9e..f95390ed 100644 --- a/src/core/sipe-groupchat.c +++ b/src/core/sipe-groupchat.c @@ -641,10 +641,10 @@ static void chatserver_response_join(struct sipe_core_private *sipe_private, const sipe_xml *aib; if (new) { - chat_session = sipe_chat_create_session(sipe_xml_attribute(node, + chat_session = sipe_chat_create_session(SIPE_CHAT_TYPE_GROUPCHAT, + sipe_xml_attribute(node, "uri"), attr ? attr : ""); - chat_session->is_groupchat = TRUE; g_hash_table_insert(groupchat->uri_to_chat_session, chat_session->id, chat_session); diff --git a/src/core/sipe-incoming.c b/src/core/sipe-incoming.c index 7b89aea9..e2831496 100644 --- a/src/core/sipe-incoming.c +++ b/src/core/sipe-incoming.c @@ -427,7 +427,8 @@ void process_incoming_invite(struct sipe_core_private *sipe_private, gchar *self = sip_uri_self(sipe_private); gchar *chat_title = sipe_chat_get_name(); - session->chat_session = sipe_chat_create_session(callid, + session->chat_session = sipe_chat_create_session(SIPE_CHAT_TYPE_MULTIPARTY, + callid, chat_title); g_free(chat_title); diff --git a/src/core/sipe.c b/src/core/sipe.c index e83d03a7..d20dccc9 100644 --- a/src/core/sipe.c +++ b/src/core/sipe.c @@ -6262,7 +6262,8 @@ sipe_buddy_menu_chat_new_cb(PurpleBuddy *buddy) session = sipe_session_add_chat(sipe_private); session->roster_manager = g_strdup(self); - session->chat_session = sipe_chat_create_session(session->callid, + session->chat_session = sipe_chat_create_session(SIPE_CHAT_TYPE_MULTIPARTY, + session->callid, chat_title); g_free(chat_title); -- 2.11.4.GIT