cpw.malu.xmpp.google_ft: a2b4d456: we shouldn't look for sessions just amon...
malu at pidgin.im
malu at pidgin.im
Fri Sep 10 17:05:56 EDT 2010
----------------------------------------------------------------------
Revision: a2b4d45631c0eea4d0d0b5e3f6eca3d953ae7f54
Parent: 3375625c3ebfb1cc25412af5390ccbc8763f2b55
Author: malu at pidgin.im
Date: 09/10/10 17:00:05
Branch: im.pidgin.cpw.malu.xmpp.google_ft
URL: http://d.pidgin.im/viewmtn/revision/info/a2b4d45631c0eea4d0d0b5e3f6eca3d953ae7f54
Changelog:
we shouldn't look for sessions just among media instances...
Changes against parent 3375625c3ebfb1cc25412af5390ccbc8763f2b55
patched libpurple/protocols/jabber/google/google_av.c
patched libpurple/protocols/jabber/google/google_session.c
patched libpurple/protocols/jabber/google/google_session.h
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google/google_session.c fb4aedbcae1eea6aa47be7c5833961fe7294a09f
+++ libpurple/protocols/jabber/google/google_session.c ed802d71c8566cfca568bf8a88f98439f5625181
@@ -26,18 +26,10 @@
#include "relay.h"
-#ifdef USE_VV
+static GList *google_sessions = NULL;
-static gboolean
-google_session_id_equal(gconstpointer a, gconstpointer b)
-{
- GoogleSessionId *c = (GoogleSessionId*)a;
- GoogleSessionId *d = (GoogleSessionId*)b;
+#ifdef USE_VV
- return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator);
-}
-
-
xmlnode *
google_session_create_xmlnode(GoogleSession *session, const char *type)
{
@@ -127,7 +119,8 @@ jabber_google_session_parse(JabberStream
xmlnode *session_node)
{
GoogleSession *session = NULL;
- GoogleSessionId id;
+ const gchar *id;
+ const gchar *initiator;
xmlnode *desc_node;
@@ -136,28 +129,15 @@ jabber_google_session_parse(JabberStream
if (type != JABBER_IQ_SET)
return;
- id.id = (gchar*)xmlnode_get_attrib(session_node, "id");
- if (!id.id)
+ id = xmlnode_get_attrib(session_node, "id");
+ if (!id)
return;
- id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator");
- if (!id.initiator)
+ initiator = xmlnode_get_attrib(session_node, "initiator");
+ if (!initiator)
return;
- iter = purple_media_manager_get_media_by_account(
- purple_media_manager_get(),
- purple_connection_get_account(js->gc));
- for (; iter; iter = g_list_delete_link(iter, iter)) {
- GoogleSession *gsession =
- purple_media_get_prpl_data(iter->data);
- if (google_session_id_equal(&(gsession->id), &id)) {
- session = gsession;
- break;
- }
- }
- if (iter != NULL) {
- g_list_free(iter);
- }
+ session = jabber_google_session_find_by_id(id);
if (session) {
google_session_parse_iq(js, session, session_node, iq_id);
@@ -171,14 +151,69 @@ jabber_google_session_parse(JabberStream
if (!desc_node)
return;
session = g_new0(GoogleSession, 1);
- session->id.id = g_strdup(id.id);
- session->id.initiator = g_strdup(id.initiator);
+ session->id.id = g_strdup(id);
+ session->id.initiator = g_strdup(initiator);
session->state = UNINIT;
session->js = js;
- session->remote_jid = g_strdup(session->id.initiator);
+ session->remote_jid = g_strdup(initiator);
+ jabber_google_session_register(session);
+
google_session_handle_initiate(js, session, session_node, iq_id);
}
#endif /* USE_VV */
+void
+jabber_google_session_register(GoogleSession *session)
+{
+ gboolean found = FALSE;
+ GList *iter;
+
+ for (iter = google_sessions ; iter ; iter = g_list_next(iter)) {
+ GoogleSession *sess = (GoogleSession *) iter->data;
+ if (purple_strequal(sess->id.id, session->id.id)) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ google_sessions = g_list_append(google_sessions, session);
+ }
+}
+
+void
+jabber_google_session_unregister(const GoogleSession *session)
+{
+ GList *iter;
+
+ for (iter = google_sessions ; iter ; iter = g_list_next(iter)) {
+ GoogleSession *sess = (GoogleSession *) iter->data;
+
+ if (purple_strequal(sess->id.id, session->id.id)) {
+ google_sessions =
+ g_list_delete_link(google_sessions, iter);
+ break;
+ }
+ }
+}
+
+GoogleSession *
+jabber_google_session_find_by_id(const gchar *id)
+{
+ GoogleSession *session = NULL;
+ GList *iter;
+
+ for (iter = google_sessions ; iter ; iter = g_list_next(iter)) {
+ GoogleSession *sess = (GoogleSession *) iter->data;
+
+ if (purple_strequal(sess->id.id, id)) {
+ session = sess;
+ break;
+ }
+ }
+
+ return session;
+}
+
============================================================
--- libpurple/protocols/jabber/google/google_session.h d110781da090d7516e5fa2503e4260e473cd7f22
+++ libpurple/protocols/jabber/google/google_session.h 5b58e654a4804006768f7cac7acdb2748892f044
@@ -66,6 +66,10 @@ void jabber_google_session_parse(JabberS
void jabber_google_session_parse(JabberStream *js, const char *from,
JabberIqType type, const char *iq, xmlnode *session);
+void jabber_google_session_register(GoogleSession *session);
+void jabber_google_session_unregister(const GoogleSession *session);
+GoogleSession *jabber_google_session_find_by_id(const gchar *id);
+
xmlnode *google_session_create_xmlnode(GoogleSession *session, const char *type);
#endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */
\ No newline at end of file
============================================================
--- libpurple/protocols/jabber/google/google_av.c f3de3f466b8da75bef00c38baef2ca294efe7182
+++ libpurple/protocols/jabber/google/google_av.c c8f6899bb6211050d3488381733e441e5abf7812
@@ -41,6 +41,9 @@ google_av_destroy(GoogleSession *session
{
GoogleAVSessionData *session_data =
(GoogleAVSessionData *) session->session_data;
+
+ jabber_google_session_unregister(session);
+
g_free(session->id.id);
g_free(session->id.initiator);
g_free(session->remote_jid);
@@ -584,6 +587,8 @@ jabber_google_av_initiate(JabberStream *
session->handle_accept_cb = google_av_handle_accept;
session->handle_reject_cb = google_av_handle_reject;
session->handle_terminate_cb = google_av_handle_terminate;
+
+ jabber_google_session_register(session);
if (type & PURPLE_MEDIA_VIDEO)
session_data->video = TRUE;
More information about the Commits
mailing list