Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/google/google_session.c @ 30965:e126e263be18
propagate from branch 'im.pidgin.pidgin' (head 1fe5329935f43a65155a01681228bdab48f3b48b)
to branch 'im.pidgin.cpw.malu.xmpp.google_relay' (head 1a4d83bf629ef1561c5587cdd4487d9db012979b)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sat, 04 Sep 2010 15:48:23 +0000 |
parents | c423dd4fb003 e97788414900 |
children | 75045bed7704 |
rev | line source |
---|---|
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
1 /** |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
2 * Purple is the legal property of its developers, whose names are too numerous |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
3 * to list here. Please refer to the COPYRIGHT file distributed with this |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
4 * source distribution. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
5 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
9 * (at your option) any later version. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
10 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
15 * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
19 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
20 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
21 #include "internal.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 #include "debug.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
23 #include "google_session.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
24 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
25 #include "jingle/jingle.h" |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
26 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
27 #ifdef USE_VV |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
28 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
29 typedef struct { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
30 PurpleMedia *media; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
31 gboolean video; |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
32 GList *remote_audio_candidates; /* list of PurpleMediaCandidate */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
33 GList *remote_video_candidates; /* list of PurpleMediaCandidate */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
34 gboolean added_streams; /* this indicates if the streams have been |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
35 to media (ie. after getting relay credentials */ |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
36 } GoogleAVSessionData; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
37 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
38 static gboolean |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 google_session_id_equal(gconstpointer a, gconstpointer b) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
40 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
41 GoogleSessionId *c = (GoogleSessionId*)a; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
42 GoogleSessionId *d = (GoogleSessionId*)b; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
44 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
45 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
46 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
47 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
48 google_session_destroy(GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
49 { |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
50 GoogleAVSessionData *session_data = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
51 (GoogleAVSessionData *) session->session_data; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
52 g_free(session->id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
53 g_free(session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
54 g_free(session->remote_jid); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
55 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
56 if (session_data->remote_audio_candidates) |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
57 purple_media_candidate_list_free(session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
58 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
59 if (session_data->remote_video_candidates) |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
60 purple_media_candidate_list_free(session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
61 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
62 g_free(session->session_data); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
63 g_free(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
64 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
65 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 static xmlnode * |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
67 google_session_create_xmlnode(GoogleSession *session, const char *type) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
68 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
69 xmlnode *node = xmlnode_new("session"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
70 xmlnode_set_namespace(node, NS_GOOGLE_SESSION); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
71 xmlnode_set_attrib(node, "id", session->id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
72 xmlnode_set_attrib(node, "initiator", session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
73 xmlnode_set_attrib(node, "type", type); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
74 return node; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
75 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
76 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
77 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
78 google_session_send_candidates(PurpleMedia *media, gchar *session_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
79 gchar *participant, GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
81 PurpleMedia *session_media = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
82 ((GoogleAVSessionData *) session->session_data)->media; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
83 GList *candidates = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
84 purple_media_get_local_candidates(session_media, session_id, |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
85 session->remote_jid); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
86 GList *iter; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
87 PurpleMediaCandidate *transport; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
88 gboolean video = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
89 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
90 if (!strcmp(session_id, "google-video")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
91 video = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
93 for (iter = candidates; iter; iter = iter->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
94 JabberIq *iq; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
95 gchar *ip, *port, *username, *password; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
96 gchar pref[16]; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
97 PurpleMediaCandidateType type; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
98 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
99 xmlnode *candidate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 guint component_id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
101 transport = PURPLE_MEDIA_CANDIDATE(iter->data); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
102 component_id = purple_media_candidate_get_component_id( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
104 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
105 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
106 sess = google_session_create_xmlnode(session, "candidates"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
107 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
108 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
109 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
110 candidate = xmlnode_new("candidate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
111 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
112 ip = purple_media_candidate_get_ip(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
113 port = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
114 purple_media_candidate_get_port(transport)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
115 g_ascii_dtostr(pref, 16, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
116 purple_media_candidate_get_priority(transport) / 1000.0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
117 username = purple_media_candidate_get_username(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
118 password = purple_media_candidate_get_password(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
119 type = purple_media_candidate_get_candidate_type(transport); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
120 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
121 xmlnode_set_attrib(candidate, "address", ip); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
122 xmlnode_set_attrib(candidate, "port", port); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
123 xmlnode_set_attrib(candidate, "name", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
124 component_id == PURPLE_MEDIA_COMPONENT_RTP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
125 video ? "video_rtp" : "rtp" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
126 component_id == PURPLE_MEDIA_COMPONENT_RTCP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
127 video ? "video_rtcp" : "rtcp" : "none"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
128 xmlnode_set_attrib(candidate, "username", username); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
129 /* |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
130 * As of this writing, Farsight 2 in Google compatibility |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
131 * mode doesn't provide a password. The Gmail client |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
132 * requires this to be set. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
133 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
134 xmlnode_set_attrib(candidate, "password", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
135 password != NULL ? password : ""); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
136 xmlnode_set_attrib(candidate, "preference", pref); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
137 xmlnode_set_attrib(candidate, "protocol", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
138 purple_media_candidate_get_protocol(transport) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
139 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 "udp" : "tcp"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
141 xmlnode_set_attrib(candidate, "type", type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
142 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
143 type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
144 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
145 type == |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
147 NULL); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
148 xmlnode_set_attrib(candidate, "generation", "0"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 xmlnode_set_attrib(candidate, "network", "0"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 xmlnode_insert_child(sess, candidate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
151 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 g_free(ip); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
153 g_free(port); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 g_free(username); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
155 g_free(password); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
156 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
157 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
158 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
159 purple_media_candidate_list_free(candidates); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
160 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
161 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
162 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
163 google_session_ready(GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
164 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
165 PurpleMedia *media = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
166 ((GoogleAVSessionData *)session->session_data)->media; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
167 gboolean video = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
168 ((GoogleAVSessionData *)session->session_data)->video; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
169 if (purple_media_codecs_ready(media, NULL) && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
170 purple_media_candidates_prepared(media, NULL, NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
171 gchar *me = g_strdup_printf("%s@%s/%s", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
172 session->js->user->node, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
173 session->js->user->domain, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
174 session->js->user->resource); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
175 JabberIq *iq; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
176 xmlnode *sess, *desc, *payload; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
177 GList *codecs, *iter; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
178 gboolean is_initiator = !strcmp(session->id.initiator, me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
179 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
180 if (!is_initiator && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 !purple_media_accepted(media, NULL, NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
182 g_free(me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
183 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
184 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
185 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
186 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
187 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
188 if (is_initiator) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
189 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
190 xmlnode_set_attrib(iq->node, "from", session->id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
191 sess = google_session_create_xmlnode(session, "initiate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
192 } else { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
193 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
194 "google-voice", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
195 session); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
196 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
197 "google-video", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
198 session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
199 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
200 xmlnode_set_attrib(iq->node, "from", me); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
201 sess = google_session_create_xmlnode(session, "accept"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
202 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
203 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
204 desc = xmlnode_new_child(sess, "description"); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
205 if (video) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
206 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
208 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
209 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
210 codecs = purple_media_get_codecs(media, "google-video"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
211 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
212 for (iter = codecs; iter; iter = g_list_next(iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
213 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
214 gchar *id = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 purple_media_codec_get_id(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 gchar *encoding_name = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
217 purple_media_codec_get_encoding_name(codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
218 payload = xmlnode_new_child(desc, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 xmlnode_set_attrib(payload, "id", id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
220 xmlnode_set_attrib(payload, "name", encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
221 xmlnode_set_attrib(payload, "width", "320"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
222 xmlnode_set_attrib(payload, "height", "200"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
223 xmlnode_set_attrib(payload, "framerate", "30"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
224 g_free(encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
225 g_free(id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
226 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
227 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
228 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
229 codecs = purple_media_get_codecs(media, "google-voice"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
230 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
231 for (iter = codecs; iter; iter = g_list_next(iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
232 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
233 gchar *id = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
234 purple_media_codec_get_id(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
235 gchar *encoding_name = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
236 purple_media_codec_get_encoding_name(codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
237 gchar *clock_rate = g_strdup_printf("%d", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
238 purple_media_codec_get_clock_rate(codec)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
239 payload = xmlnode_new_child(desc, "payload-type"); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
240 if (video) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
241 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
242 xmlnode_set_attrib(payload, "id", id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
243 /* |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
244 * Hack to make Gmail accept speex as the codec. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
245 * It shouldn't have to be case sensitive. |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
246 */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
247 if (purple_strequal(encoding_name, "SPEEX")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
248 xmlnode_set_attrib(payload, "name", "speex"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
249 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
250 xmlnode_set_attrib(payload, "name", encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
251 xmlnode_set_attrib(payload, "clockrate", clock_rate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
252 g_free(clock_rate); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
253 g_free(encoding_name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
254 g_free(id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
255 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
256 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
257 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
258 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
259 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
260 if (is_initiator) { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
261 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
262 "google-voice", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
263 session); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
264 google_session_send_candidates(media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
265 "google-video", session->remote_jid, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
266 session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
267 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
268 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
269 g_signal_handlers_disconnect_by_func(G_OBJECT(media), |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
270 G_CALLBACK(google_session_ready), session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
271 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
272 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
273 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
274 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
275 google_session_state_changed_cb(PurpleMedia *media, PurpleMediaState state, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
276 gchar *sid, gchar *name, GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
277 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
278 if (sid == NULL && name == NULL) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
279 if (state == PURPLE_MEDIA_STATE_END) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
280 google_session_destroy(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
281 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
282 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
283 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
284 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
285 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
286 google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
287 gchar *sid, gchar *name, gboolean local, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
288 GoogleSession *session) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
289 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
290 if (sid != NULL || name != NULL) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
291 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
292 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
293 if (type == PURPLE_MEDIA_INFO_HANGUP) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
294 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
295 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
296 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
297 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
298 sess = google_session_create_xmlnode(session, "terminate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
299 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
300 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
301 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
302 } else if (type == PURPLE_MEDIA_INFO_REJECT) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
303 xmlnode *sess; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
304 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
305 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
306 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
307 sess = google_session_create_xmlnode(session, "reject"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
308 xmlnode_insert_child(iq->node, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
309 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
310 jabber_iq_send(iq); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
311 } else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
312 google_session_ready(session); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
313 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
314 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
315 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
316 static GParameter * |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
317 jabber_google_session_get_params(JabberStream *js, const gchar *relay_ip, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
318 guint16 relay_udp, guint16 relay_tcp, guint16 relay_ssltcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
319 const gchar *relay_username, const gchar *relay_password, guint *num) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
320 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
321 guint num_params; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
322 GParameter *params = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
323 jingle_get_params(js, relay_ip, relay_udp, relay_tcp, relay_ssltcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
324 relay_username, relay_password, &num_params); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
325 GParameter *new_params = g_new0(GParameter, num_params + 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
326 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
327 memcpy(new_params, params, sizeof(GParameter) * num_params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
328 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
329 purple_debug_info("jabber", "setting Google jingle compatibility param\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
330 new_params[num_params].name = "compatibility-mode"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
331 g_value_init(&new_params[num_params].value, G_TYPE_UINT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
332 g_value_set_uint(&new_params[num_params].value, 1); /* NICE_COMPATIBILITY_GOOGLE */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
333 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
334 g_free(params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
335 *num = num_params + 1; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
336 return new_params; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
337 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
338 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
339 static void |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
340 jabber_google_relay_parse_response(const gchar *response, gchar **ip, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
341 guint *udp, guint *tcp, guint *ssltcp, gchar **username, gchar **password) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
342 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
343 gchar **lines = g_strsplit(response, "\n", -1); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
344 int i = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
345 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
346 for (; lines[i] ; i++) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
347 gchar *line = lines[i]; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
348 gchar **parts = g_strsplit(line, "=", 2); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
349 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
350 if (parts[0] && parts[1]) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
351 if (purple_strequal(parts[0], "relay.ip")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
352 *ip = g_strdup(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
353 } else if (purple_strequal(parts[0], "relay.udp_port")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
354 *udp = atoi(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
355 } else if (purple_strequal(parts[0], "relay.tcp_port")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
356 *tcp = atoi(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
357 } else if (purple_strequal(parts[0], "relay.ssltcp_port")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
358 *ssltcp = atoi(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
359 } else if (purple_strequal(parts[0], "username")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
360 *username = g_strdup(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
361 } else if (purple_strequal(parts[0], "password")) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
362 *password = g_strdup(parts[1]); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
363 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
364 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
365 g_strfreev(parts); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
366 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
367 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
368 g_strfreev(lines); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
369 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
370 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
371 static void |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
372 jabber_google_relay_remove_url_data(JabberStream *js, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
373 PurpleUtilFetchUrlData *url_data) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
374 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
375 GList *iter = js->google_relay_requests; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
376 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
377 while (iter) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
378 if (iter->data == url_data) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
379 js->google_relay_requests = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
380 g_list_delete_link(js->google_relay_requests, iter); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
381 break; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
382 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
383 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
384 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
385 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
386 static void |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
387 jabber_google_relay_response_session_initiate_cb(PurpleUtilFetchUrlData *url_data, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
388 gpointer user_data, const gchar *url_text, gsize len, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
389 const gchar *error_message) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
390 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
391 GoogleSession *session = (GoogleSession *) user_data; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
392 GParameter *params; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
393 guint num_params; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
394 JabberStream *js = session->js; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
395 gchar *relay_ip = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
396 guint relay_udp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
397 guint relay_tcp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
398 guint relay_ssltcp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
399 gchar *relay_username = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
400 gchar *relay_password = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
401 GoogleAVSessionData *session_data = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
402 (GoogleAVSessionData *) session->session_data; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
403 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
404 if (url_data) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
405 jabber_google_relay_remove_url_data(js, url_data); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
406 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
407 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
408 purple_debug_info("jabber", "got response on HTTP request to relay server\n"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
409 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
410 if (url_text && len > 0) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
411 purple_debug_info("jabber", "got Google relay request response:\n%s\n", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
412 url_text); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
413 jabber_google_relay_parse_response(url_text, &relay_ip, &relay_udp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
414 &relay_tcp, &relay_ssltcp, &relay_username, &relay_password); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
415 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
416 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
417 session_data->media = purple_media_manager_create_media( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
418 purple_media_manager_get(), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
419 purple_connection_get_account(js->gc), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
420 "fsrtpconference", session->remote_jid, TRUE); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
421 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
422 purple_media_set_prpl_data(session_data->media, session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
423 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
424 g_signal_connect_swapped(G_OBJECT(session_data->media), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
425 "candidates-prepared", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
426 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
427 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
428 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
429 g_signal_connect(G_OBJECT(session_data->media), "state-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
430 G_CALLBACK(google_session_state_changed_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
431 g_signal_connect(G_OBJECT(session_data->media), "stream-info", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
432 G_CALLBACK(google_session_stream_info_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
433 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
434 params = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
435 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
436 relay_ssltcp, relay_username, relay_password, &num_params); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
437 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
438 g_free(relay_ip); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
439 g_free(relay_username); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
440 g_free(relay_password); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
441 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
442 if (purple_media_add_stream(session_data->media, "google-voice", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
443 session->remote_jid, PURPLE_MEDIA_AUDIO, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
444 TRUE, "nice", num_params, params) == FALSE || |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
445 (session_data->video && purple_media_add_stream( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
446 session_data->media, "google-video", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
447 session->remote_jid, PURPLE_MEDIA_VIDEO, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
448 TRUE, "nice", num_params, params) == FALSE)) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
449 purple_media_error(session_data->media, "Error adding stream."); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
450 purple_media_end(session_data->media, NULL, NULL); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
451 g_free(params); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
452 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
453 session_data->added_streams = TRUE; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
454 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
455 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
456 g_free(params); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
457 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
458 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
459 static void |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
460 jabber_google_do_relay_request(JabberStream *js, GoogleSession *session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
461 PurpleUtilFetchUrlCallback cb) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
462 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
463 PurpleUtilFetchUrlData *url_data = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
464 gchar *url = g_strdup_printf("http://%s", js->google_relay_host); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
465 gchar *request = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
466 g_strdup_printf("GET /create_session HTTP/1.0\r\n" |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
467 "Host: %s\r\n" |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
468 "X-Talk-Google-Relay-Auth: %s\r\n" |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
469 "X-Google-Relay-Auth: %s\r\n\r\n", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
470 js->google_relay_host, js->google_relay_token, js->google_relay_token); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
471 purple_debug_info("jabber", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
472 "sending Google relay request %s to %s\n", request, url); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
473 url_data = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
474 purple_util_fetch_url_request(url, FALSE, NULL, FALSE, request, FALSE, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
475 cb, session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
476 if (url_data) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
477 js->google_relay_requests = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
478 g_list_prepend(js->google_relay_requests, url_data); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
479 } else { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
480 purple_debug_error("jabber", "unable to create Google relay request\n"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
481 cb(NULL, session, NULL, 0, NULL); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
482 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
483 g_free(url); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
484 g_free(request); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
485 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
486 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
487 gboolean |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
488 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
489 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
490 GoogleSession *session; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
491 JabberBuddy *jb; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
492 JabberBuddyResource *jbr; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
493 gchar *jid; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
494 GoogleAVSessionData *session_data = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
495 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
496 /* construct JID to send to */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
497 jb = jabber_buddy_find(js, who, FALSE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
498 if (!jb) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
499 purple_debug_error("jingle-rtp", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
500 "Could not find Jabber buddy\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
501 return FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
502 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
503 jbr = jabber_buddy_find_resource(jb, NULL); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
504 if (!jbr) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
505 purple_debug_error("jingle-rtp", |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
506 "Could not find buddy's resource\n"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
507 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
508 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
509 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
510 jid = g_strdup_printf("%s/%s", who, jbr->name); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
511 } else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
512 jid = g_strdup(who); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
513 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
514 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
515 session = g_new0(GoogleSession, 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
516 session->id.id = jabber_get_next_id(js); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
517 session->id.initiator = g_strdup_printf("%s@%s/%s", js->user->node, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
518 js->user->domain, js->user->resource); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
519 session->state = SENT_INITIATE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
520 session->js = js; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
521 session->remote_jid = jid; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
522 session_data = g_new0(GoogleAVSessionData, 1); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
523 session->session_data = session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
524 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
525 if (type & PURPLE_MEDIA_VIDEO) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
526 session_data->video = TRUE; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
527 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
528 /* if we got a relay token and relay host in google:jingleinfo, issue an |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
529 HTTP request to get that data */ |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
530 if (js->google_relay_host && js->google_relay_token) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
531 jabber_google_do_relay_request(js, session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
532 jabber_google_relay_response_session_initiate_cb); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
533 } else { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
534 jabber_google_relay_response_session_initiate_cb(NULL, session, NULL, 0, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
535 NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
536 } |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
537 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
538 /* we don't actually know yet wether it succeeded... maybe this is very |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
539 wrong... */ |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
540 return TRUE; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
541 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
542 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
543 static void |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
544 jabber_google_relay_response_session_handle_initiate_cb( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
545 PurpleUtilFetchUrlData *url_data, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
546 gpointer user_data, const gchar *url_text, gsize len, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
547 const gchar *error_message) |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
548 { |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
549 GoogleSession *session = (GoogleSession *) user_data; |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
550 GParameter *params; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
551 guint num_params; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
552 JabberStream *js = session->js; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
553 gchar *relay_ip = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
554 guint relay_udp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
555 guint relay_tcp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
556 guint relay_ssltcp = 0; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
557 gchar *relay_username = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
558 gchar *relay_password = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
559 xmlnode *codec_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
560 xmlnode *desc_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
561 const gchar *xmlns; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
562 PurpleMediaCodec *codec; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
563 GList *video_codecs = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
564 GList *codecs = NULL; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
565 JabberIq *result; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
566 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
567 (GoogleAVSessionData *) session->session_data; |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
568 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
569 if (url_data) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
570 jabber_google_relay_remove_url_data(js, url_data); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
571 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
572 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
573 if (url_text && len > 0) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
574 purple_debug_info("jabber", "got Google relay request response:\n%s\n", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
575 url_text); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
576 jabber_google_relay_parse_response(url_text, &relay_ip, &relay_udp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
577 &relay_tcp, &relay_ssltcp, &relay_username, &relay_password); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
578 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
579 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
580 params = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
581 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
582 relay_ssltcp, relay_username, relay_password, &num_params); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
583 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
584 if (purple_media_add_stream(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
585 session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
586 "nice", num_params, params) == FALSE || |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
587 (session_data->video && purple_media_add_stream( |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
588 session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
589 session->remote_jid, PURPLE_MEDIA_VIDEO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
590 FALSE, "nice", num_params, params) == FALSE)) { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
591 purple_media_error(session_data->media, "Error adding stream."); |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
592 purple_media_stream_info(session_data->media, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
593 PURPLE_MEDIA_INFO_REJECT, NULL, NULL, TRUE); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
594 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
595 /* successfully added stream(s) */ |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
596 session_data->added_streams = TRUE; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
597 |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
598 if (session_data->remote_audio_candidates) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
599 purple_media_add_remote_candidates(session_data->media, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
600 "google-voice", session->remote_jid, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
601 session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
602 purple_media_candidate_list_free(session_data->remote_audio_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
603 session_data->remote_audio_candidates = NULL; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
604 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
605 if (session_data->remote_video_candidates) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
606 purple_media_add_remote_candidates(session_data->media, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
607 "google-video", session->remote_jid, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
608 session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
609 purple_media_candidate_list_free(session_data->remote_video_candidates); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
610 session_data->remote_video_candidates = NULL; |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
611 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
612 } |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
613 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
614 g_free(params); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
615 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
616 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
617 codec_element; codec_element = codec_element->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
618 const char *id, *encoding_name, *clock_rate, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
619 *width, *height, *framerate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
620 gboolean video; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
621 if (codec_element->name && |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
622 strcmp(codec_element->name, "payload-type")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
623 continue; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
624 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
625 xmlns = xmlnode_get_namespace(codec_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
626 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
627 id = xmlnode_get_attrib(codec_element, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
628 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
629 if (!session_data->video || |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
630 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
631 clock_rate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
632 codec_element, "clockrate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
633 video = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
634 } else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
635 width = xmlnode_get_attrib(codec_element, "width"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
636 height = xmlnode_get_attrib(codec_element, "height"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
637 framerate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
638 codec_element, "framerate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
639 clock_rate = "90000"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
640 video = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
641 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
642 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
643 if (id) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
644 codec = purple_media_codec_new(atoi(id), encoding_name, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
645 video ? PURPLE_MEDIA_VIDEO : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
646 PURPLE_MEDIA_AUDIO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
647 clock_rate ? atoi(clock_rate) : 0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
648 if (video) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
649 video_codecs = g_list_append( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
650 video_codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
651 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
652 codecs = g_list_append(codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
653 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
654 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
655 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
656 if (codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
657 purple_media_set_remote_codecs(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
658 session->remote_jid, codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
659 if (video_codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
660 purple_media_set_remote_codecs(session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
661 session->remote_jid, video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
662 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
663 purple_media_codec_list_free(codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
664 purple_media_codec_list_free(video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
665 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
666 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
667 jabber_iq_set_id(result, session->iq_id); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
668 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
669 jabber_iq_send(result); |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
670 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
671 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
672 static gboolean |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
673 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
674 { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
675 xmlnode *desc_element; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
676 const gchar *xmlns; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
677 GoogleAVSessionData *session_data = |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
678 (GoogleAVSessionData *) session->session_data; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
679 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
680 if (session->state != UNINIT) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
681 purple_debug_error("jabber", "Received initiate for active session.\n"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
682 return FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
683 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
684 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
685 desc_element = xmlnode_get_child(sess, "description"); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
686 xmlns = xmlnode_get_namespace(desc_element); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
687 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
688 if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
689 session_data->video = FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
690 else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
691 session_data->video = TRUE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
692 else { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
693 purple_debug_error("jabber", "Received initiate with " |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
694 "invalid namespace %s.\n", xmlns); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
695 return FALSE; |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
696 } |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
697 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
698 session_data->media = purple_media_manager_create_media( |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
699 purple_media_manager_get(), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
700 purple_connection_get_account(js->gc), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
701 "fsrtpconference", session->remote_jid, FALSE); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
702 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
703 purple_media_set_prpl_data(session_data->media, session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
704 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
705 g_signal_connect_swapped(G_OBJECT(session_data->media), |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
706 "candidates-prepared", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
707 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
708 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
709 G_CALLBACK(google_session_ready), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
710 g_signal_connect(G_OBJECT(session_data->media), "state-changed", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
711 G_CALLBACK(google_session_state_changed_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
712 g_signal_connect(G_OBJECT(session_data->media), "stream-info", |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
713 G_CALLBACK(google_session_stream_info_cb), session); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
714 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
715 session->iq_id = g_strdup(iq_id); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
716 |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
717 if (js->google_relay_host && js->google_relay_token) { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
718 jabber_google_do_relay_request(js, session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
719 jabber_google_relay_response_session_handle_initiate_cb); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
720 } else { |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
721 jabber_google_relay_response_session_handle_initiate_cb(NULL, session, |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
722 NULL, 0, NULL); |
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
723 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
724 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
725 return TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
726 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
727 |
30963
2e26b90a28dd
Now it compiles again...
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
728 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
729 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
730 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
731 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
732 JabberIq *result; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
733 GList *list = NULL, *video_list = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
734 xmlnode *cand; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
735 static int name = 0; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
736 char n[4]; |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
737 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
738 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
739 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
740 for (cand = xmlnode_get_child(sess, "candidate"); cand; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
741 cand = xmlnode_get_next_twin(cand)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
742 PurpleMediaCandidate *info; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
743 const gchar *cname = xmlnode_get_attrib(cand, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
744 const gchar *type = xmlnode_get_attrib(cand, "type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
745 const gchar *protocol = xmlnode_get_attrib(cand, "protocol"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
746 const gchar *address = xmlnode_get_attrib(cand, "address"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
747 const gchar *port = xmlnode_get_attrib(cand, "port"); |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
748 const gchar *priority = xmlnode_get_attrib(cand, "priority"); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
749 guint component_id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
750 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
751 if (cname && type && address && port) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
752 PurpleMediaCandidateType candidate_type; |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
753 guint prio = priority ? atof(priority) * 1000 : 0; |
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
754 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
755 g_snprintf(n, sizeof(n), "S%d", name++); |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
756 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
757 if (g_str_equal(type, "local")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
758 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
759 else if (g_str_equal(type, "stun")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
760 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
761 else if (g_str_equal(type, "relay")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
762 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_RELAY; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
763 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
764 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
765 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
766 if (purple_strequal(cname, "rtcp") || |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
767 purple_strequal(cname, "video_rtcp")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
768 component_id = PURPLE_MEDIA_COMPONENT_RTCP; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
769 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
770 component_id = PURPLE_MEDIA_COMPONENT_RTP; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
771 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
772 info = purple_media_candidate_new(n, component_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
773 candidate_type, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
774 purple_strequal(protocol, "udp") ? |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
775 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
776 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
777 address, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
778 atoi(port)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
779 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"), |
30918
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
780 "password", xmlnode_get_attrib(cand, "password"), |
e97788414900
jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <ml@update.uu.se>
parents:
30912
diff
changeset
|
781 "priority", prio, NULL); |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
782 if (!strncmp(cname, "video_", 6)) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
783 if (session_data->added_streams) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
784 video_list = g_list_append(video_list, info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
785 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
786 session_data->remote_video_candidates = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
787 g_list_append(session_data->remote_video_candidates, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
788 info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
789 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
790 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
791 if (session_data->added_streams) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
792 list = g_list_append(list, info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
793 } else { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
794 session_data->remote_audio_candidates = |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
795 g_list_append(session_data->remote_audio_candidates, |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
796 info); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
797 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
798 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
799 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
800 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
801 |
30964
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
802 if (list) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
803 purple_media_add_remote_candidates(session_data->media, "google-voice", |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
804 session->remote_jid, list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
805 purple_media_candidate_list_free(list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
806 } |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
807 if (video_list) { |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
808 purple_media_add_remote_candidates(session_data->media, "google-video", |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
809 session->remote_jid, video_list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
810 purple_media_candidate_list_free(video_list); |
c423dd4fb003
Actually handle candidates we receive from the initiator before setting up our own streams (after getting a relay response from the HTTP server). This seems to somewhat work now, though for some reason it seems to use relays also locally...
Marcus Lundblad <ml@update.uu.se>
parents:
30963
diff
changeset
|
811 } |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
812 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
813 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
814 jabber_iq_set_id(result, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
815 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
816 jabber_iq_send(result); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
817 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
818 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
819 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
820 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
821 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
822 xmlnode *desc_element = xmlnode_get_child(sess, "description"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
823 xmlnode *codec_element = xmlnode_get_child( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
824 desc_element, "payload-type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
825 GList *codecs = NULL, *video_codecs = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
826 JabberIq *result = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
827 const gchar *xmlns = xmlnode_get_namespace(desc_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
828 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO)); |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
829 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
830 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
831 |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
832 for (; codec_element; codec_element = codec_element->next) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
833 const gchar *xmlns, *encoding_name, *id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
834 *clock_rate, *width, *height, *framerate; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
835 gboolean video_codec = FALSE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
836 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
837 if (!purple_strequal(codec_element->name, "payload-type")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
838 continue; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
839 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
840 xmlns = xmlnode_get_namespace(codec_element); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
841 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
842 id = xmlnode_get_attrib(codec_element, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
843 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
844 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
845 clock_rate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
846 codec_element, "clockrate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
847 else { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
848 clock_rate = "90000"; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
849 width = xmlnode_get_attrib(codec_element, "width"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
850 height = xmlnode_get_attrib(codec_element, "height"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
851 framerate = xmlnode_get_attrib( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
852 codec_element, "framerate"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
853 video_codec = TRUE; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
854 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
855 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
856 if (id && encoding_name) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
857 PurpleMediaCodec *codec = purple_media_codec_new( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
858 atoi(id), encoding_name, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
859 video_codec ? PURPLE_MEDIA_VIDEO : |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
860 PURPLE_MEDIA_AUDIO, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
861 clock_rate ? atoi(clock_rate) : 0); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
862 if (video_codec) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
863 video_codecs = g_list_append( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
864 video_codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
865 else |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
866 codecs = g_list_append(codecs, codec); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
867 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
868 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
869 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
870 if (codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
871 purple_media_set_remote_codecs(session_data->media, "google-voice", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
872 session->remote_jid, codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
873 if (video_codecs) |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
874 purple_media_set_remote_codecs(session_data->media, "google-video", |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
875 session->remote_jid, video_codecs); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
876 |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
877 purple_media_stream_info(session_data->media, PURPLE_MEDIA_INFO_ACCEPT, |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
878 NULL, NULL, FALSE); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
879 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
880 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
881 jabber_iq_set_id(result, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
882 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
883 jabber_iq_send(result); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
884 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
885 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
886 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
887 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *sess) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
888 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
889 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
890 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
891 purple_media_end(session_data->media, NULL, NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
892 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
893 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
894 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
895 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
896 { |
30907
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
897 GoogleAVSessionData *session_data = |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
898 (GoogleAVSessionData *) session->session_data; |
721b257bcd8c
Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <ml@update.uu.se>
parents:
30906
diff
changeset
|
899 purple_media_end(session_data->media, NULL, NULL); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
900 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
901 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
902 static void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
903 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
904 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
905 const char *type = xmlnode_get_attrib(sess, "type"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
906 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
907 if (!strcmp(type, "initiate")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
908 google_session_handle_initiate(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
909 } else if (!strcmp(type, "accept")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
910 google_session_handle_accept(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
911 } else if (!strcmp(type, "reject")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
912 google_session_handle_reject(js, session, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
913 } else if (!strcmp(type, "terminate")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
914 google_session_handle_terminate(js, session, sess); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
915 } else if (!strcmp(type, "candidates")) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
916 google_session_handle_candidates(js, session, sess, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
917 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
918 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
919 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
920 void |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
921 jabber_google_session_parse(JabberStream *js, const char *from, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
922 JabberIqType type, const char *iq_id, |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
923 xmlnode *session_node) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
924 { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
925 GoogleSession *session = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
926 GoogleSessionId id; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
927 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
928 xmlnode *desc_node; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
929 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
930 GList *iter = NULL; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
931 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
932 if (type != JABBER_IQ_SET) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
933 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
934 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
935 id.id = (gchar*)xmlnode_get_attrib(session_node, "id"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
936 if (!id.id) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
937 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
938 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
939 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
940 if (!id.initiator) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
941 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
942 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
943 iter = purple_media_manager_get_media_by_account( |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
944 purple_media_manager_get(), |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
945 purple_connection_get_account(js->gc)); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
946 for (; iter; iter = g_list_delete_link(iter, iter)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
947 GoogleSession *gsession = |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
948 purple_media_get_prpl_data(iter->data); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
949 if (google_session_id_equal(&(gsession->id), &id)) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
950 session = gsession; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
951 break; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
952 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
953 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
954 if (iter != NULL) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
955 g_list_free(iter); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
956 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
957 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
958 if (session) { |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
959 google_session_parse_iq(js, session, session_node, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
960 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
961 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
962 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
963 /* If the session doesn't exist, this has to be an initiate message */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
964 if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate")) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
965 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
966 desc_node = xmlnode_get_child(session_node, "description"); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
967 if (!desc_node) |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
968 return; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
969 session = g_new0(GoogleSession, 1); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
970 session->id.id = g_strdup(id.id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
971 session->id.initiator = g_strdup(id.initiator); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
972 session->state = UNINIT; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
973 session->js = js; |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
974 session->remote_jid = g_strdup(session->id.initiator); |
30912
f3bc8afc0944
jabber: Missed intialising session_data here.
Marcus Lundblad <ml@update.uu.se>
parents:
30907
diff
changeset
|
975 session->session_data = g_new0(GoogleAVSessionData, 1); |
30906
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
976 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
977 google_session_handle_initiate(js, session, session_node, iq_id); |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
978 } |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
979 #endif /* USE_VV */ |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
980 |
34f586bffe4e
Added new files in sub directory google
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
981 |