libpurple/protocols/jabber/google/google_session.c

Sat, 04 Sep 2010 15:47:59 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Sat, 04 Sep 2010 15:47:59 +0000
changeset 30756
4f357819d93b
parent 30749
00eda6a032b5
child 30757
ca36f52b5f77
child 30773
530a74a5b97e
permissions
-rw-r--r--

jabber: set priority on remote candidates for Google-style vv

29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
1 /**
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
2 * Purple is the legal property of its developers, whose names are too numerous
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
3 * to list here. Please refer to the COPYRIGHT file distributed with this
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
4 * source distribution.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
5 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
10 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
15 *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
19 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
20
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
23 #include "google_session.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
24
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
25 #include "jingle/jingle.h"
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
26
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
27 #ifdef USE_VV
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
28
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
29 typedef struct {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
30 PurpleMedia *media;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
31 gboolean video;
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
32 } GoogleAVSessionData;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
33
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
34 static gboolean
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
35 google_session_id_equal(gconstpointer a, gconstpointer b)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
36 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
37 GoogleSessionId *c = (GoogleSessionId*)a;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
38 GoogleSessionId *d = (GoogleSessionId*)b;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
39
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
40 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
41 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
42
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
43 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
44 google_session_destroy(GoogleSession *session)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
45 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
46 g_free(session->id.id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
47 g_free(session->id.initiator);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
48 g_free(session->remote_jid);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
49 g_free(session->session_data);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
50 g_free(session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
51 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
52
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
53 static xmlnode *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
54 google_session_create_xmlnode(GoogleSession *session, const char *type)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
55 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
56 xmlnode *node = xmlnode_new("session");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
57 xmlnode_set_namespace(node, NS_GOOGLE_SESSION);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
58 xmlnode_set_attrib(node, "id", session->id.id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
59 xmlnode_set_attrib(node, "initiator", session->id.initiator);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
60 xmlnode_set_attrib(node, "type", type);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
61 return node;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
62 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
63
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
64 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
65 google_session_send_candidates(PurpleMedia *media, gchar *session_id,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
66 gchar *participant, GoogleSession *session)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
67 {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
68 PurpleMedia *session_media =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
69 ((GoogleAVSessionData *) session->session_data)->media;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
70 GList *candidates =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
71 purple_media_get_local_candidates(session_media, session_id,
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
72 session->remote_jid);
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
73 GList *iter;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
74 PurpleMediaCandidate *transport;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
75 gboolean video = FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
76
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
77 if (!strcmp(session_id, "google-video"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
78 video = TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
79
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
80 for (iter = candidates; iter; iter = iter->next) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
81 JabberIq *iq;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
82 gchar *ip, *port, *username, *password;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
83 gchar pref[16];
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
84 PurpleMediaCandidateType type;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
85 xmlnode *sess;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
86 xmlnode *candidate;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
87 guint component_id;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
88 transport = PURPLE_MEDIA_CANDIDATE(iter->data);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
89 component_id = purple_media_candidate_get_component_id(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
90 transport);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
91
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
92 iq = jabber_iq_new(session->js, JABBER_IQ_SET);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
93 sess = google_session_create_xmlnode(session, "candidates");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
94 xmlnode_insert_child(iq->node, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
95 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
96
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
97 candidate = xmlnode_new("candidate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
98
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
99 ip = purple_media_candidate_get_ip(transport);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
100 port = g_strdup_printf("%d",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
101 purple_media_candidate_get_port(transport));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
102 g_ascii_dtostr(pref, 16,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
103 purple_media_candidate_get_priority(transport) / 1000.0);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
104 username = purple_media_candidate_get_username(transport);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
105 password = purple_media_candidate_get_password(transport);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
106 type = purple_media_candidate_get_candidate_type(transport);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
107
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
108 xmlnode_set_attrib(candidate, "address", ip);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
109 xmlnode_set_attrib(candidate, "port", port);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
110 xmlnode_set_attrib(candidate, "name",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
111 component_id == PURPLE_MEDIA_COMPONENT_RTP ?
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
112 video ? "video_rtp" : "rtp" :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
113 component_id == PURPLE_MEDIA_COMPONENT_RTCP ?
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
114 video ? "video_rtcp" : "rtcp" : "none");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
115 xmlnode_set_attrib(candidate, "username", username);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
116 /*
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
117 * As of this writing, Farsight 2 in Google compatibility
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
118 * mode doesn't provide a password. The Gmail client
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
119 * requires this to be set.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
120 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
121 xmlnode_set_attrib(candidate, "password",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
122 password != NULL ? password : "");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
123 xmlnode_set_attrib(candidate, "preference", pref);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
124 xmlnode_set_attrib(candidate, "protocol",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
125 purple_media_candidate_get_protocol(transport)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
126 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ?
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
127 "udp" : "tcp");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
128 xmlnode_set_attrib(candidate, "type", type ==
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
129 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
130 type ==
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
131 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
132 type ==
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
133 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
134 NULL);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
135 xmlnode_set_attrib(candidate, "generation", "0");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
136 xmlnode_set_attrib(candidate, "network", "0");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
137 xmlnode_insert_child(sess, candidate);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
138
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
139 g_free(ip);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
140 g_free(port);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
141 g_free(username);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
142 g_free(password);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
143
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
144 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
145 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
146 purple_media_candidate_list_free(candidates);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
147 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
148
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
149 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
150 google_session_ready(GoogleSession *session)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
151 {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
152 PurpleMedia *media =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
153 ((GoogleAVSessionData *)session->session_data)->media;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
154 gboolean video =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
155 ((GoogleAVSessionData *)session->session_data)->video;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
156 if (purple_media_codecs_ready(media, NULL) &&
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
157 purple_media_candidates_prepared(media, NULL, NULL)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
158 gchar *me = g_strdup_printf("%s@%s/%s",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
159 session->js->user->node,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
160 session->js->user->domain,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
161 session->js->user->resource);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
162 JabberIq *iq;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
163 xmlnode *sess, *desc, *payload;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
164 GList *codecs, *iter;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
165 gboolean is_initiator = !strcmp(session->id.initiator, me);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
166
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
167 if (!is_initiator &&
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
168 !purple_media_accepted(media, NULL, NULL)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
169 g_free(me);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
170 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
171 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
172
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
173 iq = jabber_iq_new(session->js, JABBER_IQ_SET);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
174
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
175 if (is_initiator) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
176 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
177 xmlnode_set_attrib(iq->node, "from", session->id.initiator);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
178 sess = google_session_create_xmlnode(session, "initiate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
179 } else {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
180 google_session_send_candidates(media,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
181 "google-voice", session->remote_jid,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
182 session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
183 google_session_send_candidates(media,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
184 "google-video", session->remote_jid,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
185 session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
186 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
187 xmlnode_set_attrib(iq->node, "from", me);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
188 sess = google_session_create_xmlnode(session, "accept");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
189 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
190 xmlnode_insert_child(iq->node, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
191 desc = xmlnode_new_child(sess, "description");
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
192 if (video)
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
193 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
194 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
195 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
196
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
197 codecs = purple_media_get_codecs(media, "google-video");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
198
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
199 for (iter = codecs; iter; iter = g_list_next(iter)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
200 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
201 gchar *id = g_strdup_printf("%d",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
202 purple_media_codec_get_id(codec));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
203 gchar *encoding_name =
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
204 purple_media_codec_get_encoding_name(codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
205 payload = xmlnode_new_child(desc, "payload-type");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
206 xmlnode_set_attrib(payload, "id", id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
207 xmlnode_set_attrib(payload, "name", encoding_name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
208 xmlnode_set_attrib(payload, "width", "320");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
209 xmlnode_set_attrib(payload, "height", "200");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
210 xmlnode_set_attrib(payload, "framerate", "30");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
211 g_free(encoding_name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
212 g_free(id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
213 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
214 purple_media_codec_list_free(codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
215
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
216 codecs = purple_media_get_codecs(media, "google-voice");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
217
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
218 for (iter = codecs; iter; iter = g_list_next(iter)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
219 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
220 gchar *id = g_strdup_printf("%d",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
221 purple_media_codec_get_id(codec));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
222 gchar *encoding_name =
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
223 purple_media_codec_get_encoding_name(codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
224 gchar *clock_rate = g_strdup_printf("%d",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
225 purple_media_codec_get_clock_rate(codec));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
226 payload = xmlnode_new_child(desc, "payload-type");
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
227 if (video)
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
228 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
229 xmlnode_set_attrib(payload, "id", id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
230 /*
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
231 * Hack to make Gmail accept speex as the codec.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
232 * It shouldn't have to be case sensitive.
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
233 */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
234 if (purple_strequal(encoding_name, "SPEEX"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
235 xmlnode_set_attrib(payload, "name", "speex");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
236 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
237 xmlnode_set_attrib(payload, "name", encoding_name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
238 xmlnode_set_attrib(payload, "clockrate", clock_rate);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
239 g_free(clock_rate);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
240 g_free(encoding_name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
241 g_free(id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
242 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
243 purple_media_codec_list_free(codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
244
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
245 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
246
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
247 if (is_initiator) {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
248 google_session_send_candidates(media,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
249 "google-voice", session->remote_jid,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
250 session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
251 google_session_send_candidates(media,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
252 "google-video", session->remote_jid,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
253 session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
254 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
255
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
256 g_signal_handlers_disconnect_by_func(G_OBJECT(media),
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
257 G_CALLBACK(google_session_ready), session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
258 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
259 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
260
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
261 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
262 google_session_state_changed_cb(PurpleMedia *media, PurpleMediaState state,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
263 gchar *sid, gchar *name, GoogleSession *session)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
264 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
265 if (sid == NULL && name == NULL) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
266 if (state == PURPLE_MEDIA_STATE_END) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
267 google_session_destroy(session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
268 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
269 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
270 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
271
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
272 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
273 google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
274 gchar *sid, gchar *name, gboolean local,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
275 GoogleSession *session)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
276 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
277 if (sid != NULL || name != NULL)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
278 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
279
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
280 if (type == PURPLE_MEDIA_INFO_HANGUP) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
281 xmlnode *sess;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
282 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
283
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
284 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
285 sess = google_session_create_xmlnode(session, "terminate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
286 xmlnode_insert_child(iq->node, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
287
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
288 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
289 } else if (type == PURPLE_MEDIA_INFO_REJECT) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
290 xmlnode *sess;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
291 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
292
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
293 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
294 sess = google_session_create_xmlnode(session, "reject");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
295 xmlnode_insert_child(iq->node, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
296
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
297 jabber_iq_send(iq);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
298 } else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
299 google_session_ready(session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
300 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
301 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
302
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
303 static GParameter *
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
304 jabber_google_session_get_params(JabberStream *js, guint *num)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
305 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
306 guint num_params;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
307 GParameter *params = jingle_get_params(js, &num_params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
308 GParameter *new_params = g_new0(GParameter, num_params + 1);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
309
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
310 memcpy(new_params, params, sizeof(GParameter) * num_params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
311
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
312 purple_debug_info("jabber", "setting Google jingle compatibility param\n");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
313 new_params[num_params].name = "compatibility-mode";
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
314 g_value_init(&new_params[num_params].value, G_TYPE_UINT);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
315 g_value_set_uint(&new_params[num_params].value, 1); /* NICE_COMPATIBILITY_GOOGLE */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
316
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
317 g_free(params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
318 *num = num_params + 1;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
319 return new_params;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
320 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
321
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
322
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
323 gboolean
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
324 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
325 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
326 GoogleSession *session;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
327 JabberBuddy *jb;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
328 JabberBuddyResource *jbr;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
329 gchar *jid;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
330 GParameter *params;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
331 guint num_params;
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
332 GoogleAVSessionData *session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
333
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
334 /* construct JID to send to */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
335 jb = jabber_buddy_find(js, who, FALSE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
336 if (!jb) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
337 purple_debug_error("jingle-rtp",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
338 "Could not find Jabber buddy\n");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
339 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
340 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
341 jbr = jabber_buddy_find_resource(jb, NULL);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
342 if (!jbr) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
343 purple_debug_error("jingle-rtp",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
344 "Could not find buddy's resource\n");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
345 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
346
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
347 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
348 jid = g_strdup_printf("%s/%s", who, jbr->name);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
349 } else {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
350 jid = g_strdup(who);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
351 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
352
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
353 session = g_new0(GoogleSession, 1);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
354 session->id.id = jabber_get_next_id(js);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
355 session->id.initiator = g_strdup_printf("%s@%s/%s", js->user->node,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
356 js->user->domain, js->user->resource);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
357 session->state = SENT_INITIATE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
358 session->js = js;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
359 session->remote_jid = jid;
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
360 session_data = g_new0(GoogleAVSessionData, 1);
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
361 session->session_data = session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
362
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
363 if (type & PURPLE_MEDIA_VIDEO)
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
364 session_data->video = TRUE;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
365
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
366 session_data->media = purple_media_manager_create_media(
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
367 purple_media_manager_get(),
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
368 purple_connection_get_account(js->gc),
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
369 "fsrtpconference", session->remote_jid, TRUE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
370
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
371 purple_media_set_prpl_data(session_data->media, session);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
372
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
373 g_signal_connect_swapped(G_OBJECT(session_data->media),
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
374 "candidates-prepared",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
375 G_CALLBACK(google_session_ready), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
376 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
377 G_CALLBACK(google_session_ready), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
378 g_signal_connect(G_OBJECT(session_data->media), "state-changed",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
379 G_CALLBACK(google_session_state_changed_cb), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
380 g_signal_connect(G_OBJECT(session_data->media), "stream-info",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
381 G_CALLBACK(google_session_stream_info_cb), session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
382
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
383 params = jabber_google_session_get_params(js, &num_params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
384
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
385 if (purple_media_add_stream(session_data->media, "google-voice",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
386 session->remote_jid, PURPLE_MEDIA_AUDIO,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
387 TRUE, "nice", num_params, params) == FALSE ||
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
388 (session_data->video && purple_media_add_stream(
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
389 session_data->media, "google-video",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
390 session->remote_jid, PURPLE_MEDIA_VIDEO,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
391 TRUE, "nice", num_params, params) == FALSE)) {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
392 purple_media_error(session_data->media, "Error adding stream.");
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
393 purple_media_end(session_data->media, NULL, NULL);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
394 g_free(params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
395 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
396 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
397
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
398 g_free(params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
399
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
400 return (session_data->media != NULL) ? TRUE : FALSE;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
401 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
402
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
403 static gboolean
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
404 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
405 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
406 JabberIq *result;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
407 GList *codecs = NULL, *video_codecs = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
408 xmlnode *desc_element, *codec_element;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
409 PurpleMediaCodec *codec;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
410 const char *xmlns;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
411 GParameter *params;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
412 guint num_params;
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
413 GoogleAVSessionData *session_data =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
414 (GoogleAVSessionData *) session->session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
415
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
416 if (session->state != UNINIT) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
417 purple_debug_error("jabber", "Received initiate for active session.\n");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
418 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
419 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
420
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
421 desc_element = xmlnode_get_child(sess, "description");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
422 xmlns = xmlnode_get_namespace(desc_element);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
423
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
424 if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE))
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
425 session_data->video = FALSE;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
426 else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO))
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
427 session_data->video = TRUE;
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
428 else {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
429 purple_debug_error("jabber", "Received initiate with "
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
430 "invalid namespace %s.\n", xmlns);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
431 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
432 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
433
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
434 session_data->media = purple_media_manager_create_media(
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
435 purple_media_manager_get(),
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
436 purple_connection_get_account(js->gc),
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
437 "fsrtpconference", session->remote_jid, FALSE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
438
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
439 purple_media_set_prpl_data(session_data->media, session);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
440
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
441 g_signal_connect_swapped(G_OBJECT(session_data->media),
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
442 "candidates-prepared",
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
443 G_CALLBACK(google_session_ready), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
444 g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
445 G_CALLBACK(google_session_ready), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
446 g_signal_connect(G_OBJECT(session_data->media), "state-changed",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
447 G_CALLBACK(google_session_state_changed_cb), session);
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
448 g_signal_connect(G_OBJECT(session_data->media), "stream-info",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
449 G_CALLBACK(google_session_stream_info_cb), session);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
450
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
451 params = jabber_google_session_get_params(js, &num_params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
452
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
453 if (purple_media_add_stream(session_data->media, "google-voice",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
454 session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
455 "nice", num_params, params) == FALSE ||
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
456 (session_data->video && purple_media_add_stream(
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
457 session_data->media, "google-video",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
458 session->remote_jid, PURPLE_MEDIA_VIDEO,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
459 FALSE, "nice", num_params, params) == FALSE)) {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
460 purple_media_error(session_data->media, "Error adding stream.");
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
461 purple_media_stream_info(session_data->media,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
462 PURPLE_MEDIA_INFO_REJECT, NULL, NULL, TRUE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
463 g_free(params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
464 return FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
465 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
466
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
467 g_free(params);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
468
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
469 for (codec_element = xmlnode_get_child(desc_element, "payload-type");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
470 codec_element; codec_element = codec_element->next) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
471 const char *id, *encoding_name, *clock_rate,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
472 *width, *height, *framerate;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
473 gboolean video;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
474 if (codec_element->name &&
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
475 strcmp(codec_element->name, "payload-type"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
476 continue;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
477
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
478 xmlns = xmlnode_get_namespace(codec_element);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
479 encoding_name = xmlnode_get_attrib(codec_element, "name");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
480 id = xmlnode_get_attrib(codec_element, "id");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
481
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
482 if (!session_data->video ||
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
483 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
484 clock_rate = xmlnode_get_attrib(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
485 codec_element, "clockrate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
486 video = FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
487 } else {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
488 width = xmlnode_get_attrib(codec_element, "width");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
489 height = xmlnode_get_attrib(codec_element, "height");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
490 framerate = xmlnode_get_attrib(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
491 codec_element, "framerate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
492 clock_rate = "90000";
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
493 video = TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
494 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
495
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
496 if (id) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
497 codec = purple_media_codec_new(atoi(id), encoding_name,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
498 video ? PURPLE_MEDIA_VIDEO :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
499 PURPLE_MEDIA_AUDIO,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
500 clock_rate ? atoi(clock_rate) : 0);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
501 if (video)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
502 video_codecs = g_list_append(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
503 video_codecs, codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
504 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
505 codecs = g_list_append(codecs, codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
506 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
507 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
508
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
509 if (codecs)
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
510 purple_media_set_remote_codecs(session_data->media, "google-voice",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
511 session->remote_jid, codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
512 if (video_codecs)
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
513 purple_media_set_remote_codecs(session_data->media, "google-video",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
514 session->remote_jid, video_codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
515
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
516 purple_media_codec_list_free(codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
517 purple_media_codec_list_free(video_codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
518
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
519 result = jabber_iq_new(js, JABBER_IQ_RESULT);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
520 jabber_iq_set_id(result, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
521 xmlnode_set_attrib(result->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
522 jabber_iq_send(result);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
523
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
524 return TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
525 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
526
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
527 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
528 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
529 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
530 JabberIq *result;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
531 GList *list = NULL, *video_list = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
532 xmlnode *cand;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
533 static int name = 0;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
534 char n[4];
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
535 GoogleAVSessionData *session_data =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
536 (GoogleAVSessionData *) session->session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
537
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
538 for (cand = xmlnode_get_child(sess, "candidate"); cand;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
539 cand = xmlnode_get_next_twin(cand)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
540 PurpleMediaCandidate *info;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
541 const gchar *cname = xmlnode_get_attrib(cand, "name");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
542 const gchar *type = xmlnode_get_attrib(cand, "type");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
543 const gchar *protocol = xmlnode_get_attrib(cand, "protocol");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
544 const gchar *address = xmlnode_get_attrib(cand, "address");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
545 const gchar *port = xmlnode_get_attrib(cand, "port");
30756
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
546 const gchar *priority = xmlnode_get_attrib(cand, "priority");
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
547 guint component_id;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
548
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
549 if (cname && type && address && port) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
550 PurpleMediaCandidateType candidate_type;
30756
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
551 guint prio = priority ? atof(priority) * 1000 : 0;
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
552
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
553 g_snprintf(n, sizeof(n), "S%d", name++);
30756
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
554
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
555 if (g_str_equal(type, "local"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
556 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
557 else if (g_str_equal(type, "stun"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
558 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
559 else if (g_str_equal(type, "relay"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
560 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_RELAY;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
561 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
562 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
563
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
564 if (purple_strequal(cname, "rtcp") ||
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
565 purple_strequal(cname, "video_rtcp"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
566 component_id = PURPLE_MEDIA_COMPONENT_RTCP;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
567 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
568 component_id = PURPLE_MEDIA_COMPONENT_RTP;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
569
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
570 info = purple_media_candidate_new(n, component_id,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
571 candidate_type,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
572 purple_strequal(protocol, "udp") ?
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
573 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
574 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
575 address,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
576 atoi(port));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
577 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"),
30756
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
578 "password", xmlnode_get_attrib(cand, "password"),
4f357819d93b jabber: set priority on remote candidates for Google-style vv
Marcus Lundblad <malu@pidgin.im>
parents: 30749
diff changeset
579 "priority", prio, NULL);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
580 if (!strncmp(cname, "video_", 6))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
581 video_list = g_list_append(video_list, info);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
582 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
583 list = g_list_append(list, info);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
584 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
585 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
586
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
587 if (list)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
588 purple_media_add_remote_candidates(
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
589 session_data->media, "google-voice",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
590 session->remote_jid, list);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
591 if (video_list)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
592 purple_media_add_remote_candidates(
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
593 session_data->media, "google-video",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
594 session->remote_jid, video_list);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
595 purple_media_candidate_list_free(list);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
596 purple_media_candidate_list_free(video_list);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
597
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
598 result = jabber_iq_new(js, JABBER_IQ_RESULT);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
599 jabber_iq_set_id(result, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
600 xmlnode_set_attrib(result->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
601 jabber_iq_send(result);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
602 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
603
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
604 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
605 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
606 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
607 xmlnode *desc_element = xmlnode_get_child(sess, "description");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
608 xmlnode *codec_element = xmlnode_get_child(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
609 desc_element, "payload-type");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
610 GList *codecs = NULL, *video_codecs = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
611 JabberIq *result = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
612 const gchar *xmlns = xmlnode_get_namespace(desc_element);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
613 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO));
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
614 GoogleAVSessionData *session_data =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
615 (GoogleAVSessionData *) session->session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
616
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
617 for (; codec_element; codec_element = codec_element->next) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
618 const gchar *xmlns, *encoding_name, *id,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
619 *clock_rate, *width, *height, *framerate;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
620 gboolean video_codec = FALSE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
621
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
622 if (!purple_strequal(codec_element->name, "payload-type"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
623 continue;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
624
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
625 xmlns = xmlnode_get_namespace(codec_element);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
626 encoding_name = xmlnode_get_attrib(codec_element, "name");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
627 id = xmlnode_get_attrib(codec_element, "id");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
628
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
629 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
630 clock_rate = xmlnode_get_attrib(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
631 codec_element, "clockrate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
632 else {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
633 clock_rate = "90000";
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
634 width = xmlnode_get_attrib(codec_element, "width");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
635 height = xmlnode_get_attrib(codec_element, "height");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
636 framerate = xmlnode_get_attrib(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
637 codec_element, "framerate");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
638 video_codec = TRUE;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
639 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
640
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
641 if (id && encoding_name) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
642 PurpleMediaCodec *codec = purple_media_codec_new(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
643 atoi(id), encoding_name,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
644 video_codec ? PURPLE_MEDIA_VIDEO :
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
645 PURPLE_MEDIA_AUDIO,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
646 clock_rate ? atoi(clock_rate) : 0);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
647 if (video_codec)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
648 video_codecs = g_list_append(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
649 video_codecs, codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
650 else
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
651 codecs = g_list_append(codecs, codec);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
652 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
653 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
654
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
655 if (codecs)
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
656 purple_media_set_remote_codecs(session_data->media, "google-voice",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
657 session->remote_jid, codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
658 if (video_codecs)
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
659 purple_media_set_remote_codecs(session_data->media, "google-video",
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
660 session->remote_jid, video_codecs);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
661
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
662 purple_media_stream_info(session_data->media, PURPLE_MEDIA_INFO_ACCEPT,
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
663 NULL, NULL, FALSE);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
664
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
665 result = jabber_iq_new(js, JABBER_IQ_RESULT);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
666 jabber_iq_set_id(result, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
667 xmlnode_set_attrib(result->node, "to", session->remote_jid);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
668 jabber_iq_send(result);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
669 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
670
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
671 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
672 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *sess)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
673 {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
674 GoogleAVSessionData *session_data =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
675 (GoogleAVSessionData *) session->session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
676 purple_media_end(session_data->media, NULL, NULL);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
677 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
678
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
679 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
680 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
681 {
29915
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
682 GoogleAVSessionData *session_data =
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
683 (GoogleAVSessionData *) session->session_data;
2ca9f271ed5a Remove direct use of PurpleMedia in the GoogleSession struct
Marcus Lundblad <malu@pidgin.im>
parents: 29914
diff changeset
684 purple_media_end(session_data->media, NULL, NULL);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
685 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
686
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
687 static void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
688 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
689 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
690 const char *type = xmlnode_get_attrib(sess, "type");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
691
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
692 if (!strcmp(type, "initiate")) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
693 google_session_handle_initiate(js, session, sess, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
694 } else if (!strcmp(type, "accept")) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
695 google_session_handle_accept(js, session, sess, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
696 } else if (!strcmp(type, "reject")) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
697 google_session_handle_reject(js, session, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
698 } else if (!strcmp(type, "terminate")) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
699 google_session_handle_terminate(js, session, sess);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
700 } else if (!strcmp(type, "candidates")) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
701 google_session_handle_candidates(js, session, sess, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
702 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
703 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
704
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
705 void
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
706 jabber_google_session_parse(JabberStream *js, const char *from,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
707 JabberIqType type, const char *iq_id,
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
708 xmlnode *session_node)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
709 {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
710 GoogleSession *session = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
711 GoogleSessionId id;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
712
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
713 xmlnode *desc_node;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
714
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
715 GList *iter = NULL;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
716
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
717 if (type != JABBER_IQ_SET)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
718 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
719
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
720 id.id = (gchar*)xmlnode_get_attrib(session_node, "id");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
721 if (!id.id)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
722 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
723
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
724 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
725 if (!id.initiator)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
726 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
727
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
728 iter = purple_media_manager_get_media_by_account(
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
729 purple_media_manager_get(),
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
730 purple_connection_get_account(js->gc));
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
731 for (; iter; iter = g_list_delete_link(iter, iter)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
732 GoogleSession *gsession =
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
733 purple_media_get_prpl_data(iter->data);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
734 if (google_session_id_equal(&(gsession->id), &id)) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
735 session = gsession;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
736 break;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
737 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
738 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
739 if (iter != NULL) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
740 g_list_free(iter);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
741 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
742
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
743 if (session) {
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
744 google_session_parse_iq(js, session, session_node, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
745 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
746 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
747
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
748 /* If the session doesn't exist, this has to be an initiate message */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
749 if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate"))
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
750 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
751 desc_node = xmlnode_get_child(session_node, "description");
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
752 if (!desc_node)
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
753 return;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
754 session = g_new0(GoogleSession, 1);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
755 session->id.id = g_strdup(id.id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
756 session->id.initiator = g_strdup(id.initiator);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
757 session->state = UNINIT;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
758 session->js = js;
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
759 session->remote_jid = g_strdup(session->id.initiator);
30749
00eda6a032b5 jabber: Missed intialising session_data here.
Marcus Lundblad <malu@pidgin.im>
parents: 29915
diff changeset
760 session->session_data = g_new0(GoogleAVSessionData, 1);
29914
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
761
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
762 google_session_handle_initiate(js, session, session_node, iq_id);
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
763 }
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
764 #endif /* USE_VV */
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
765
a4ed5999f6d0 Added new files in sub directory google
Marcus Lundblad <malu@pidgin.im>
parents:
diff changeset
766

mercurial