annotate libpurple/protocols/jabber/google.c @ 27937:1337d2813b2d

propagate from branch 'im.pidgin.pidgin' (head 5ab68ddb0251205f7ef97f4c280e65696cbd5ff2) to branch 'im.pidgin.pidgin.yaz' (head 7a5d48783707dd377fd754961d3b009c3e492827)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 07 Apr 2009 14:32:50 +0000
parents cd1f3a1750a1 d8e6a2d592a4
children b623c1824f29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27894
f3477b0d32f4 improved "now listening" status support.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 23399
diff changeset
1 /* -*- coding: utf-8 -*- */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 /**
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18751
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "debug.h"
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
24 #include "mediamanager.h"
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
25 #include "util.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "privacy.h"
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
27 #include "dnsquery.h"
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
28 #include "network.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "google.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "jabber.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
36 #include "jingle/jingle.h"
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
37
25654
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25650
diff changeset
38 #ifdef USE_VV
25650
4b9b265a8100 Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25647
diff changeset
39
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
40 typedef struct {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
41 char *id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
42 char *initiator;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
43 } GoogleSessionId;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
44
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
45 typedef enum {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
46 UNINIT,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
47 SENT_INITIATE,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
48 RECEIVED_INITIATE,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
49 IN_PRORESS,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
50 TERMINATED
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
51 } GoogleSessionState;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
52
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
53 typedef struct {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
54 GoogleSessionId id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
55 GoogleSessionState state;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
56 PurpleMedia *media;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
57 JabberStream *js;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
58 char *remote_jid;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
59 } GoogleSession;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
60
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
61 static gboolean
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
62 google_session_id_equal(gconstpointer a, gconstpointer b)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
63 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
64 GoogleSessionId *c = (GoogleSessionId*)a;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
65 GoogleSessionId *d = (GoogleSessionId*)b;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
66
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
67 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
68 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
69
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
70 static void
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
71 google_session_destroy(GoogleSession *session)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
72 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
73 g_free(session->id.id);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
74 g_free(session->id.initiator);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
75 g_free(session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
76 g_free(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
77 }
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
78
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
79 static xmlnode *
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
80 google_session_create_xmlnode(GoogleSession *session, const char *type)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
81 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
82 xmlnode *node = xmlnode_new("session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
83 xmlnode_set_namespace(node, "http://www.google.com/session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
84 xmlnode_set_attrib(node, "id", session->id.id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
85 xmlnode_set_attrib(node, "initiator", session->id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
86 xmlnode_set_attrib(node, "type", type);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
87 return node;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
88 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
89
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
90 static void
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
91 google_session_send_terminate(GoogleSession *session)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
92 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
93 xmlnode *sess;
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
94 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
95
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
96 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
97 sess = google_session_create_xmlnode(session, "terminate");
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
98 xmlnode_insert_child(iq->node, sess);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
99
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
100 jabber_iq_send(iq);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
101 google_session_destroy(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
102 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
103
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
104 static void
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
105 google_session_send_candidates(PurpleMedia *media, gchar *session_id,
26040
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26036
diff changeset
106 gchar *participant, GoogleSession *session)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
107 {
25671
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
108 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice",
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
109 session->remote_jid);
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
110 PurpleMediaCandidate *transport;
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
111
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
112 for (;candidates;candidates = candidates->next) {
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
113 JabberIq *iq;
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
114 gchar *ip, *port, *pref, *username, *password;
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
115 PurpleMediaCandidateType type;
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
116 xmlnode *sess;
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
117 xmlnode *candidate;
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
118 transport = (PurpleMediaCandidate*)(candidates->data);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
119
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
120 if (purple_media_candidate_get_component_id(transport)
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
121 != PURPLE_MEDIA_COMPONENT_RTP)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
122 continue;
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
123
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
124 iq = jabber_iq_new(session->js, JABBER_IQ_SET);
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
125 sess = google_session_create_xmlnode(session, "candidates");
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
126 xmlnode_insert_child(iq->node, sess);
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
127 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
128
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
129 candidate = xmlnode_new("candidate");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
130
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
131 ip = purple_media_candidate_get_ip(transport);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
132 port = g_strdup_printf("%d",
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
133 purple_media_candidate_get_port(transport));
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
134 pref = g_strdup_printf("%f",
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
135 purple_media_candidate_get_priority(transport)
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
136 /1000.0);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
137 username = purple_media_candidate_get_username(transport);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
138 password = purple_media_candidate_get_password(transport);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
139 type = purple_media_candidate_get_candidate_type(transport);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
140
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
141 xmlnode_set_attrib(candidate, "address", ip);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
142 xmlnode_set_attrib(candidate, "port", port);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
143 xmlnode_set_attrib(candidate, "name", "rtp");
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
144 xmlnode_set_attrib(candidate, "username", username);
26077
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
145 /*
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
146 * As of this writing, Farsight 2 in Google compatibility
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
147 * mode doesn't provide a password. The Gmail client
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
148 * requires this to be set.
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
149 */
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26075
diff changeset
150 xmlnode_set_attrib(candidate, "password",
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
151 password != NULL ? password : "");
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
152 xmlnode_set_attrib(candidate, "preference", pref);
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
153 xmlnode_set_attrib(candidate, "protocol",
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
154 purple_media_candidate_get_protocol(transport)
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
155 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ?
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
156 "udp" : "tcp");
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
157 xmlnode_set_attrib(candidate, "type", type ==
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
158 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" :
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
159 type ==
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
160 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" :
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
161 type ==
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
162 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" :
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
163 NULL);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
164 xmlnode_set_attrib(candidate, "generation", "0");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
165 xmlnode_set_attrib(candidate, "network", "0");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
166 xmlnode_insert_child(sess, candidate);
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
167
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
168 g_free(ip);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
169 g_free(port);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
170 g_free(pref);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
171 g_free(username);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
172 g_free(password);
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
173
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
174 jabber_iq_send(iq);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
175 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
176 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
177
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
178 static void
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
179 google_session_ready(GoogleSession *session)
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
180 {
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
181 PurpleMedia *media = session->media;
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
182 if (purple_media_codecs_ready(media, NULL) &&
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
183 purple_media_candidates_prepared(media, NULL, NULL)) {
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
184 gchar *me = g_strdup_printf("%s@%s/%s",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
185 session->js->user->node,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
186 session->js->user->domain,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
187 session->js->user->resource);
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
188 JabberIq *iq;
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
189 xmlnode *sess, *desc, *payload;
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
190 GList *codecs, *iter;
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
191 gboolean is_initiator = !strcmp(session->id.initiator, me);
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
192
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
193 if (!is_initiator &&
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
194 !purple_media_accepted(media, NULL, NULL)) {
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
195 g_free(me);
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
196 return;
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
197 }
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
198
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
199 iq = jabber_iq_new(session->js, JABBER_IQ_SET);
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
200
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
201 if (is_initiator) {
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
202 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
203 xmlnode_set_attrib(iq->node, "from", session->id.initiator);
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
204 sess = google_session_create_xmlnode(session, "initiate");
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
205 } else {
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
206 google_session_send_candidates(session->media,
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
207 "google-voice", session->remote_jid,
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
208 session);
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
209 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
210 xmlnode_set_attrib(iq->node, "from", me);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
211 sess = google_session_create_xmlnode(session, "accept");
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
212 }
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
213 xmlnode_insert_child(iq->node, sess);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
214 desc = xmlnode_new_child(sess, "description");
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
215 xmlnode_set_namespace(desc, "http://www.google.com/session/phone");
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
216
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
217 codecs = purple_media_get_codecs(media, "google-voice");
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
218
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
219 for (iter = codecs; iter; iter = g_list_next(iter)) {
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
220 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data;
26486
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
221 gchar *id = g_strdup_printf("%d",
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
222 purple_media_codec_get_id(codec));
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
223 gchar *encoding_name =
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
224 purple_media_codec_get_encoding_name(codec);
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
225 gchar *clock_rate = g_strdup_printf("%d",
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
226 purple_media_codec_get_clock_rate(codec));
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
227 payload = xmlnode_new_child(desc, "payload-type");
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
228 xmlnode_set_attrib(payload, "id", id);
26486
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
229 xmlnode_set_attrib(payload, "name", encoding_name);
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
230 xmlnode_set_attrib(payload, "clockrate", clock_rate);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
231 g_free(clock_rate);
26486
217574ec2a34 Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26466
diff changeset
232 g_free(encoding_name);
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
233 g_free(id);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
234 }
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
235 purple_media_codec_list_free(codecs);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
236
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
237 jabber_iq_send(iq);
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
238
26437
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
239 if (is_initiator)
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
240 google_session_send_candidates(session->media,
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
241 "google-voice", session->remote_jid,
29bc149cbd07 Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26436
diff changeset
242 session);
26400
007cd8dad384 Don't let initiate or accept be sent again with Google Voice.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26396
diff changeset
243
007cd8dad384 Don't let initiate or accept be sent again with Google Voice.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26396
diff changeset
244 g_signal_handlers_disconnect_by_func(G_OBJECT(session->media),
007cd8dad384 Don't let initiate or accept be sent again with Google Voice.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26396
diff changeset
245 G_CALLBACK(google_session_ready), session);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
246 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
247 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
248
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
249 static void
26411
86bc2d34f689 Rename state-changed enum and values.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26405
diff changeset
250 google_session_state_changed_cb(PurpleMedia *media, PurpleMediaState state,
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
251 gchar *sid, gchar *name, GoogleSession *session)
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
252 {
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
253 if (sid == NULL && name == NULL) {
26411
86bc2d34f689 Rename state-changed enum and values.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26405
diff changeset
254 if (state == PURPLE_MEDIA_STATE_END) {
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
255 google_session_destroy(session);
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
256 }
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
257 }
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
258 }
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
259
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
260 static void
26405
51b986bbe260 Use the right enum for the parameter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26404
diff changeset
261 google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
26448
4e1286e76f1f Create purple_media_stream_info. Add local parameter to stream-info signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26447
diff changeset
262 gchar *sid, gchar *name, gboolean local,
4e1286e76f1f Create purple_media_stream_info. Add local parameter to stream-info signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26447
diff changeset
263 GoogleSession *session)
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
264 {
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
265 if (type == PURPLE_MEDIA_INFO_HANGUP) {
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
266 xmlnode *sess;
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
267 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
268
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
269 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
270 sess = google_session_create_xmlnode(session, "terminate");
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
271 xmlnode_insert_child(iq->node, sess);
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
272
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
273 jabber_iq_send(iq);
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
274 } else if (type == PURPLE_MEDIA_INFO_REJECT) {
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
275 xmlnode *sess;
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
276 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
277
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
278 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
279 sess = google_session_create_xmlnode(session, "reject");
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
280 xmlnode_insert_child(iq->node, sess);
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
281
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
282 jabber_iq_send(iq);
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
283 }
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
284 }
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
285
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
286 static GParameter *
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
287 jabber_google_session_get_params(JabberStream *js, guint *num)
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
288 {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
289 guint num_params;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
290 GParameter *params = jingle_get_params(js, &num_params);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
291 GParameter *new_params = g_new0(GParameter, num_params + 1);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
292
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
293 memcpy(new_params, params, sizeof(GParameter) * num_params);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
294
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
295 purple_debug_info("jabber", "setting Google jingle compatibility param\n");
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
296 new_params[num_params].name = "compatibility-mode";
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
297 g_value_init(&new_params[num_params].value, G_TYPE_UINT);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
298 g_value_set_uint(&new_params[num_params].value, 1); /* NICE_COMPATIBILITY_GOOGLE */
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
299
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
300 g_free(params);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
301 *num = num_params + 1;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
302 return new_params;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
303 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
304
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
305
26447
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26437
diff changeset
306 gboolean
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
307 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 {
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
309 GoogleSession *session;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
310 JabberBuddy *jb;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
311 JabberBuddyResource *jbr;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
312 gchar *jid;
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
313 GParameter *params;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
314 guint num_params;
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
315
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
316 /* construct JID to send to */
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
317 jb = jabber_buddy_find(js, who, FALSE);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
318 if (!jb) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
319 purple_debug_error("jingle-rtp",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
320 "Could not find Jabber buddy\n");
26447
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26437
diff changeset
321 return FALSE;
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
322 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
323 jbr = jabber_buddy_find_resource(jb, NULL);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
324 if (!jbr) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
325 purple_debug_error("jingle-rtp",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
326 "Could not find buddy's resource\n");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
327 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
328
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
329 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
330 jid = g_strdup_printf("%s/%s", who, jbr->name);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
331 } else {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
332 jid = g_strdup(who);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
333 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
334
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
335 session = g_new0(GoogleSession, 1);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
336 session->id.id = jabber_get_next_id(js);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
337 session->id.initiator = g_strdup_printf("%s@%s/%s", js->user->node,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
338 js->user->domain, js->user->resource);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
339 session->state = SENT_INITIATE;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
340 session->js = js;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
341 session->remote_jid = jid;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
342
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
343 session->media = purple_media_manager_create_media(
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
344 purple_media_manager_get(), js->gc,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
345 "fsrtpconference", session->remote_jid, TRUE);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
346
26207
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
347 purple_media_set_prpl_data(session->media, session);
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
348
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
349 params = jabber_google_session_get_params(js, &num_params);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
350
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
351 if (purple_media_add_stream(session->media, "google-voice",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
352 session->remote_jid, PURPLE_MEDIA_AUDIO,
26466
bea334b214fa Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26453
diff changeset
353 TRUE, "nice", num_params, params) == FALSE) {
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
354 purple_media_error(session->media, "Error adding stream.");
26451
2862fee7acf2 Remove purple_media_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26448
diff changeset
355 purple_media_stream_info(session->media,
2862fee7acf2 Remove purple_media_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26448
diff changeset
356 PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
357 google_session_destroy(session);
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
358 g_free(params);
26447
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26437
diff changeset
359 return FALSE;
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
360 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
361
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
362 g_signal_connect_swapped(G_OBJECT(session->media),
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
363 "candidates-prepared",
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
364 G_CALLBACK(google_session_ready), session);
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
365 g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
366 G_CALLBACK(google_session_ready), session);
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
367 g_signal_connect(G_OBJECT(session->media), "state-changed",
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
368 G_CALLBACK(google_session_state_changed_cb), session);
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
369 g_signal_connect(G_OBJECT(session->media), "stream-info",
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
370 G_CALLBACK(google_session_stream_info_cb), session);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
371
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
372 g_free(params);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
373
26447
34eb898478b4 Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26437
diff changeset
374 return (session->media != NULL) ? TRUE : FALSE;
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
375 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
376
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
377 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
378 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
379 {
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
380 JabberIq *result;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
381 GList *codecs = NULL;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
382 xmlnode *desc_element, *codec_element;
26106
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
383 PurpleMediaCodec *codec;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
384 const char *id, *encoding_name, *clock_rate;
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
385 GParameter *params;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
386 guint num_params;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
387
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
388 if (session->state != UNINIT) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
389 purple_debug_error("jabber", "Received initiate for active session.\n");
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
390 return;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
391 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
392
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
393 session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc,
26063
c7d4b67b3332 Add initiator property to PurpleMedia.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26040
diff changeset
394 "fsrtpconference", session->remote_jid, FALSE);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
395
26207
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
396 purple_media_set_prpl_data(session->media, session);
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
397
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
398 params = jabber_google_session_get_params(js, &num_params);
26040
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26036
diff changeset
399
26466
bea334b214fa Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26453
diff changeset
400 if (purple_media_add_stream(session->media, "google-voice",
bea334b214fa Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26453
diff changeset
401 session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE,
bea334b214fa Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26453
diff changeset
402 "nice", num_params, params) == FALSE) {
26075
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26063
diff changeset
403 purple_media_error(session->media, "Error adding stream.");
26451
2862fee7acf2 Remove purple_media_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26448
diff changeset
404 purple_media_stream_info(session->media,
2862fee7acf2 Remove purple_media_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26448
diff changeset
405 PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
26075
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26063
diff changeset
406 google_session_send_terminate(session);
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
407 g_free(params);
26075
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26063
diff changeset
408 return;
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26063
diff changeset
409 }
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
410
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
411 g_free(params);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
412
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
413 desc_element = xmlnode_get_child(sess, "description");
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
414
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
415 for (codec_element = xmlnode_get_child(desc_element, "payload-type");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
416 codec_element;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
417 codec_element = xmlnode_get_next_twin(codec_element)) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
418 encoding_name = xmlnode_get_attrib(codec_element, "name");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
419 id = xmlnode_get_attrib(codec_element, "id");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
420 clock_rate = xmlnode_get_attrib(codec_element, "clockrate");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
421
26106
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
422 codec = purple_media_codec_new(atoi(id), encoding_name, PURPLE_MEDIA_AUDIO,
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
423 clock_rate ? atoi(clock_rate) : 0);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
424 codecs = g_list_append(codecs, codec);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
425 }
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
426
25671
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
427 purple_media_set_remote_codecs(session->media, "google-voice", session->remote_jid, codecs);
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
428
26396
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
429 g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
430 G_CALLBACK(google_session_ready), session);
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
431 g_signal_connect_swapped(G_OBJECT(session->media),
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
432 "candidates-prepared",
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
433 G_CALLBACK(google_session_ready), session);
2ad89aff8d68 Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26213
diff changeset
434 g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed",
26113
7bbac147f276 Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26112
diff changeset
435 G_CALLBACK(google_session_ready), session);
26112
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
436 g_signal_connect(G_OBJECT(session->media), "state-changed",
027ce238eb40 Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26106
diff changeset
437 G_CALLBACK(google_session_state_changed_cb), session);
26404
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
438 g_signal_connect(G_OBJECT(session->media), "stream-info",
90c7f3e477b3 Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26400
diff changeset
439 G_CALLBACK(google_session_stream_info_cb), session);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
440
26106
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
441 purple_media_codec_list_free(codecs);
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
442
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
443 result = jabber_iq_new(js, JABBER_IQ_RESULT);
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
444 jabber_iq_set_id(result, iq_id);
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
445 xmlnode_set_attrib(result->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
446 jabber_iq_send(result);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
447 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
448
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
449 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
450 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
451 {
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
452 JabberIq *result;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
453 GList *list = NULL;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
454 xmlnode *cand;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
455 static int name = 0;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
456 char n[4];
25637
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25557
diff changeset
457
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
458 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) {
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
459 PurpleMediaCandidate *info;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
460 g_snprintf(n, sizeof(n), "S%d", name++);
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
461 info = purple_media_candidate_new(n, PURPLE_MEDIA_COMPONENT_RTP,
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
462 !strcmp(xmlnode_get_attrib(cand, "type"), "local") ?
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
463 PURPLE_MEDIA_CANDIDATE_TYPE_HOST :
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
464 !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ?
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
465 PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX :
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
466 !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ?
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
467 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY :
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
468 PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
469 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ?
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
470 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP :
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
471 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
472 xmlnode_get_attrib(cand, "address"),
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
473 atoi(xmlnode_get_attrib(cand, "port")));
26488
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
474 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"),
2d332d327a0e Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26486
diff changeset
475 "password", xmlnode_get_attrib(cand, "password"), NULL);
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
476
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
477 list = g_list_append(list, info);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
478 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
479
25671
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25654
diff changeset
480 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list);
26103
f7cf50180e1d Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26093
diff changeset
481 purple_media_candidate_list_free(list);
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
482
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
483 result = jabber_iq_new(js, JABBER_IQ_RESULT);
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
484 jabber_iq_set_id(result, iq_id);
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
485 xmlnode_set_attrib(result->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
486 jabber_iq_send(result);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
487 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
488
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
489 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
490 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
491 {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
492 xmlnode *desc_element = xmlnode_get_child(sess, "description");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
493 xmlnode *codec_element = xmlnode_get_child(desc_element, "payload-type");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
494 GList *codecs = NULL;
26436
d8d6fb37c789 Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26416
diff changeset
495 JabberIq *result = NULL;
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
496
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
497 for (; codec_element; codec_element =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
498 xmlnode_get_next_twin(codec_element)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
499 const gchar *encoding_name =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
500 xmlnode_get_attrib(codec_element, "name");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
501 const gchar *id = xmlnode_get_attrib(codec_element, "id");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
502 const gchar *clock_rate =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
503 xmlnode_get_attrib(codec_element, "clockrate");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
504
26106
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
505 PurpleMediaCodec *codec = purple_media_codec_new(atoi(id),
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
506 encoding_name, PURPLE_MEDIA_AUDIO,
ac4d7695dbc7 Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26103
diff changeset
507 clock_rate ? atoi(clock_rate) : 0);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
508 codecs = g_list_append(codecs, codec);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
509 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
510
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
511 purple_media_set_remote_codecs(session->media, "google-voice",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
512 session->remote_jid, codecs);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
513
26453
12c7db418c3e Remove purple_media_accept.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26451
diff changeset
514 purple_media_stream_info(session->media, PURPLE_MEDIA_INFO_ACCEPT,
12c7db418c3e Remove purple_media_accept.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26451
diff changeset
515 NULL, NULL, FALSE);
26436
d8d6fb37c789 Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26416
diff changeset
516
d8d6fb37c789 Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26416
diff changeset
517 result = jabber_iq_new(js, JABBER_IQ_RESULT);
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
518 jabber_iq_set_id(result, iq_id);
26436
d8d6fb37c789 Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26416
diff changeset
519 xmlnode_set_attrib(result->node, "to", session->remote_jid);
d8d6fb37c789 Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26416
diff changeset
520 jabber_iq_send(result);
26081
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
521 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
522
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26077
diff changeset
523 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
524 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *sess)
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
525 {
26140
ac56e5707a72 Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26122
diff changeset
526 purple_media_end(session->media, NULL, NULL);
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
527 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
528
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
529 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
530 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess)
25548
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 25545
diff changeset
531 {
26140
ac56e5707a72 Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26122
diff changeset
532 purple_media_end(session->media, NULL, NULL);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
533 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
534
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
535 static void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
536 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
537 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
538 const char *type = xmlnode_get_attrib(sess, "type");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
539
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
540 if (!strcmp(type, "initiate")) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
541 google_session_handle_initiate(js, session, sess, iq_id);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
542 } else if (!strcmp(type, "accept")) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
543 google_session_handle_accept(js, session, sess, iq_id);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
544 } else if (!strcmp(type, "reject")) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
545 google_session_handle_reject(js, session, sess);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
546 } else if (!strcmp(type, "terminate")) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
547 google_session_handle_terminate(js, session, sess);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
548 } else if (!strcmp(type, "candidates")) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
549 google_session_handle_candidates(js, session, sess, iq_id);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
550 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
551 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
552
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
553 void
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
554 jabber_google_session_parse(JabberStream *js, const char *from,
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
555 JabberIqType type, const char *iq_id,
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
556 xmlnode *session_node)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
557 {
26207
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
558 GoogleSession *session = NULL;
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
559 GoogleSessionId id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
560
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
561 xmlnode *desc_node;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
562
26207
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
563 GList *iter = NULL;
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
564
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
565 if (type != JABBER_IQ_SET)
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
566 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
567
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
568 id.id = (gchar*)xmlnode_get_attrib(session_node, "id");
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
569 if (!id.id)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
570 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
571
25647
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25637
diff changeset
572 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator");
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
573 if (!id.initiator)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
574 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
575
26207
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
576 iter = purple_media_manager_get_media_by_connection(
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
577 purple_media_manager_get(), js->gc);
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
578 for (; iter; iter = g_list_delete_link(iter, iter)) {
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
579 GoogleSession *gsession =
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
580 purple_media_get_prpl_data(iter->data);
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
581 if (google_session_id_equal(&(gsession->id), &id)) {
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
582 session = gsession;
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
583 break;
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
584 }
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
585 }
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
586 if (iter != NULL) {
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
587 g_list_free(iter);
a773b465935e Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26162
diff changeset
588 }
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
589
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
590 if (session) {
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
591 google_session_parse_iq(js, session, session_node, iq_id);
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
592 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
593 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
594
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
595 /* If the session doesn't exist, this has to be an initiate message */
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
596 if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate"))
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
597 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
598 desc_node = xmlnode_get_child(session_node, "description");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
599 if (!desc_node)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
600 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
601 session = g_new0(GoogleSession, 1);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
602 session->id.id = g_strdup(id.id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
603 session->id.initiator = g_strdup(id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
604 session->state = UNINIT;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
605 session->js = js;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
606 session->remote_jid = g_strdup(session->id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
607
26558
cd1f3a1750a1 And google session handling
Paul Aurich <paul@darkrain42.org>
parents: 26553
diff changeset
608 google_session_parse_iq(js, session, session_node, iq_id);
26416
6f0200f1e497 Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26411
diff changeset
609 }
25654
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25650
diff changeset
610 #endif /* USE_VV */
25545
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
611
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
612 static void
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
613 jabber_gmail_parse(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
614 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
615 xmlnode *packet, gpointer nul)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 xmlnode *child;
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
618 xmlnode *message;
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
619 const char *to, *url;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 const char *in_str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 char *to_name;
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
622 char *default_tos[1];
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
623
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 int i, count = 1, returned_count;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
625
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
626 const char **tos, **froms, **urls;
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
627 char **subjects;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
628
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
629 if (type == JABBER_IQ_ERROR)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
631
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 child = xmlnode_get_child(packet, "mailbox");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 if (!child)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 in_str = xmlnode_get_attrib(child, "total-matched");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
637 if (in_str && *in_str)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 count = atoi(in_str);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
639
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
640 /* If Gmail doesn't tell us who the mail is to, let's use our JID */
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
641 to = xmlnode_get_attrib(packet, "to");
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
642 default_tos[0] = jabber_get_bare_jid(to);
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
643
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
644 message = xmlnode_get_child(child, "mail-thread-info");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
646 if (count == 0 || !message) {
20281
d41907afb521 Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents: 20218
diff changeset
647 if (count > 0)
d41907afb521 Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents: 20218
diff changeset
648 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
649 g_free(default_tos[0]);
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
650 return;
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
651 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
652
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 /* Loop once to see how many messages were returned so we can allocate arrays
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 * accordingly */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message));
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
656
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 froms = g_new0(const char* , returned_count);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 tos = g_new0(const char* , returned_count);
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
659 subjects = g_new0(char* , returned_count);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 urls = g_new0(const char* , returned_count);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
661
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 to = xmlnode_get_attrib(packet, "to");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 to_name = jabber_get_bare_jid(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 url = xmlnode_get_attrib(child, "url");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 if (!url || !*url)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 url = "http://www.gmail.com";
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
667
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 message= xmlnode_get_child(child, "mail-thread-info");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 for (i=0; message; message = xmlnode_get_next_twin(message), i++) {
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
670 xmlnode *sender_node, *subject_node;
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
671 const char *from, *tid;
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
672 char *subject;
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25983
diff changeset
673
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 subject_node = xmlnode_get_child(message, "subject");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 sender_node = xmlnode_get_child(message, "senders");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 sender_node = xmlnode_get_child(sender_node, "sender");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
678 while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") ||
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 sender_node = xmlnode_get_next_twin(sender_node);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
681
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 if (!sender_node) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 i--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
686
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 from = xmlnode_get_attrib(sender_node, "name");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 if (!from || !*from)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 from = xmlnode_get_attrib(sender_node, "address");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 subject = xmlnode_get_data(subject_node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 * url = xmlnode_get_attrib(message, "url");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 tos[i] = (to_name != NULL ? to_name : "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 froms[i] = (from != NULL ? from : "");
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
696 subjects[i] = (subject != NULL ? subject : g_strdup(""));
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20317
diff changeset
697 urls[i] = url;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
698
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 tid = xmlnode_get_attrib(message, "tid");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
700 if (tid &&
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 g_free(js->gmail_last_tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 js->gmail_last_tid = g_strdup(tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
707 if (i>0)
18492
94c23019a864 Only display the "detailed" email notifications for gtalk if we really have all the details to show. Fixes #1813.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18491
diff changeset
708 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos,
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
709 urls, NULL, NULL);
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
710 else
20211
a5d366d614f5 applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@wiktel.com>
parents: 20169
diff changeset
711 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
712
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 g_free(to_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715 g_free(tos);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
716 g_free(default_tos[0]);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 g_free(froms);
18751
0580b246b2c5 Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18492
diff changeset
718 for (; i > 0; i--)
0580b246b2c5 Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18492
diff changeset
719 g_free(subjects[i - 1]);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 g_free(subjects);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 g_free(urls);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 in_str = xmlnode_get_attrib(child, "result-time");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 if (in_str && *in_str) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 g_free(js->gmail_last_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 js->gmail_last_time = g_strdup(in_str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
730 void
25933
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25067
diff changeset
731 jabber_gmail_poke(JabberStream *js, const char *from, JabberIqType type,
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25067
diff changeset
732 const char *id, xmlnode *new_mail)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 JabberIq *iq;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
736
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 /* bail if the user isn't interested */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
738 if (!purple_account_get_check_mail(js->gc->account))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 /* Is this an initial incoming mail notification? If so, send a request for more info */
25933
050052891c55 Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents: 25067
diff changeset
742 if (type != JABBER_IQ_SET)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
745 purple_debug(PURPLE_DEBUG_MISC, "jabber",
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 "Got new mail notification. Sending request for more info\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 if (js->gmail_last_time)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 if (js->gmail_last_tid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 void jabber_gmail_init(JabberStream *js) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
764 if (!purple_account_get_check_mail(js->gc->account))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 void jabber_google_roster_init(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 query = xmlnode_get_child(iq->node, "query");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
779
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
788 PurpleAccount *account = purple_connection_get_account(js->gc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 GSList *list = account->deny;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 const char *jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 char *jid_norm = g_strdup(jabber_normalize(account, jid));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 if (!strcmp(jid_norm, (char*)list->data)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 xmlnode_set_attrib(item, "gr:t", "B");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
804 g_free(jid_norm);
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
805
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807
15467
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
808 gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
810 PurpleAccount *account = purple_connection_get_account(js->gc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 GSList *list = account->deny;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 const char *jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 gboolean on_block_list = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814
20317
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
815 char *jid_norm;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster");
17051
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
818 const char *subscription = xmlnode_get_attrib(item, "subscription");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
819
17292
a7c07b57f3e4 This should be better
Sean Egan <seanegan@gmail.com>
parents: 17281
diff changeset
820 if (!subscription || !strcmp(subscription, "none")) {
17051
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
821 /* The Google Talk servers will automatically add people from your Gmail address book
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
822 * with subscription=none. If we see someone with subscription=none, ignore them.
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
823 */
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
824 return FALSE;
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16943
diff changeset
825 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
826
20317
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
827 jid_norm = g_strdup(jabber_normalize(account, jid));
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
828
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 if (!strcmp(jid_norm, (char*)list->data)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 on_block_list = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
836
15467
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
837 if (grt && (*grt == 'H' || *grt == 'h')) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
838 PurpleBuddy *buddy = purple_find_buddy(account, jid_norm);
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
839 if (buddy)
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
840 purple_blist_remove_buddy(buddy);
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
841 g_free(jid_norm);
15467
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
842 return FALSE;
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
843 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
844
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
846 purple_debug_info("jabber", "Blocking %s\n", jid_norm);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
847 purple_privacy_deny_add(account, jid_norm, TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
849 purple_debug_info("jabber", "Unblocking %s\n", jid_norm);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
850 purple_privacy_deny_remove(account, jid_norm, TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 }
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
852
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
853 g_free(jid_norm);
15467
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
854 return TRUE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
857 void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 GSList *buddies;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 xmlnode *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 xmlnode *group;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
865 PurpleBuddy *b;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 JabberBuddy *jb;
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
867 const char *balias;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 js = (JabberStream*)(gc->proto_data);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
870
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 jb = jabber_buddy_find(js, who, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
876 buddies = purple_find_buddies(js->gc->account, who);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
879
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 b = buddies->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
883
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 while(buddies) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
888 PurpleGroup *g;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 b = buddies->data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
891 g = purple_buddy_get_group(b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 group = xmlnode_new_child(item, "group");
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23399
diff changeset
894 xmlnode_insert_data(group, purple_group_get_name(g), -1);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
895
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 buddies = buddies->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
899 balias = purple_buddy_get_local_buddy_alias(b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 xmlnode_set_attrib(item, "jid", who);
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
901 xmlnode_set_attrib(item, "name", balias ? balias : "");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 xmlnode_set_attrib(item, "gr:t", "B");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 /* Synthesize a sign-off */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 if (jb) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 JabberBuddyResource *jbr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 GList *l = jb->resources;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 while (l) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 jbr = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 if (jbr && jbr->name)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
916 purple_debug(PURPLE_DEBUG_MISC, "jabber", "Removing resource %s\n", jbr->name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 jabber_buddy_remove_resource(jb, jbr->name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 l = l->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 }
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
922 purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
925 void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 GSList *buddies;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 xmlnode *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 xmlnode *group;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
933 PurpleBuddy *b;
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
934 const char *balias;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 g_return_if_fail(gc != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 g_return_if_fail(who != NULL);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
938
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 js = (JabberStream*)(gc->proto_data);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
940
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
943
25286
ede22bc33d56 More struct hiding work
Richard Laager <rlaager@wiktel.com>
parents: 23399
diff changeset
944 buddies = purple_find_buddies(purple_connection_get_account(js->gc), who);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
947
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 b = buddies->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
951
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 while(buddies) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
956 PurpleGroup *g;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 b = buddies->data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15523
diff changeset
959 g = purple_buddy_get_group(b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 group = xmlnode_new_child(item, "group");
24120
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23399
diff changeset
962 xmlnode_insert_data(group, purple_group_get_name(g), -1);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
963
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 buddies = buddies->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
967 balias = purple_buddy_get_local_buddy_alias(b);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 xmlnode_set_attrib(item, "jid", who);
25294
8aa7d8bcbc7d Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25288
diff changeset
969 xmlnode_set_attrib(item, "name", balias ? balias : "");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 /* See if he's online */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 jabber_presence_subscription_set(js, who, "probe");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 }
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
978
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
979 /* This does two passes on the string. The first pass goes through
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
980 * and determine if all the structured text is properly balanced, and
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
981 * how many instances of each there is. The second pass goes and converts
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
982 * everything to HTML, depending on what's figured out by the first pass.
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
983 * It will short circuit once it knows it has no more replacements to make
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
984 */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
985 char *jabber_google_format_to_html(const char *text)
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
986 {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
987 const char *p;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
988
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
989 /* The start of the screen may be consdiered a space for this purpose */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
990 gboolean preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
991
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
992 gboolean in_bold = FALSE, in_italic = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
993 gboolean in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
994
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
995 gint bold_count = 0, italic_count = 0;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
996
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
997 GString *str;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
998
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
999 for (p = text; *p != '\0'; p = g_utf8_next_char(p)) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1000 gunichar c = g_utf8_get_char(p);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1001 if (c == '*' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1002 if (in_bold && (g_unichar_isspace(*(p+1)) ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1003 *(p+1) == '\0' ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1004 *(p+1) == '<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1005 bold_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1006 in_bold = FALSE;
16943
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
1007 } else if (preceding_space && !in_bold && !g_unichar_isspace(*(p+1))) {
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1008 bold_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1009 in_bold = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1010 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1011 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1012 } else if (c == '_' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1013 if (in_italic && (g_unichar_isspace(*(p+1)) ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1014 *(p+1) == '\0' ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1015 *(p+1) == '<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1016 italic_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1017 in_italic = FALSE;
16943
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
1018 } else if (preceding_space && !in_italic && !g_unichar_isspace(*(p+1))) {
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1019 italic_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1020 in_italic = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1021 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1022 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1023 } else if (c == '<' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1024 in_tag = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1025 } else if (c == '>' && in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1026 in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1027 } else if (!in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1028 if (g_unichar_isspace(c))
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1029 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1030 else
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1031 preceding_space = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1032 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1033 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1034
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1035 str = g_string_new(NULL);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1036 in_bold = in_italic = in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1037 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1038
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1039 for (p = text; *p != '\0'; p = g_utf8_next_char(p)) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1040 gunichar c = g_utf8_get_char(p);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
1041
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1042 if (bold_count < 2 && italic_count < 2 && !in_bold && !in_italic) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1043 g_string_append(str, p);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1044 return g_string_free(str, FALSE);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1045 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1046
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
1047
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1048 if (c == '*' && !in_tag) {
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
1049 if (in_bold &&
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1050 (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { /* This is safe in UTF-8 */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1051 str = g_string_append(str, "</b>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1052 in_bold = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1053 bold_count--;
16943
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
1054 } else if (preceding_space && bold_count > 1 && !g_unichar_isspace(*(p+1))) {
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1055 str = g_string_append(str, "<b>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1056 bold_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1057 in_bold = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1058 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1059 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1060 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1061 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1062 } else if (c == '_' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1063 if (in_italic &&
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1064 (g_unichar_isspace(*(p+1))||*(p+1)=='<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1065 str = g_string_append(str, "</i>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1066 italic_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1067 in_italic = FALSE;
16943
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
1068 } else if (preceding_space && italic_count > 1 && !g_unichar_isspace(*(p+1))) {
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1069 str = g_string_append(str, "<i>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1070 italic_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1071 in_italic = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1072 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1073 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1074 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1075 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1076 } else if (c == '<' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1077 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1078 in_tag = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1079 } else if (c == '>' && in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1080 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1081 in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1082 } else if (!in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1083 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1084 if (g_unichar_isspace(c))
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1085 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1086 else
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1087 preceding_space = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1088 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1089 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1090 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17292
diff changeset
1091 }
15523
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1092 return g_string_free(str, FALSE);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15467
diff changeset
1093 }
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1094
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1095 void jabber_google_presence_incoming(JabberStream *js, const char *user, JabberBuddyResource *jbr)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1096 {
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1097 if (!js->googletalk)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1098 return;
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1099 if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) {
27894
f3477b0d32f4 improved "now listening" status support.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 23399
diff changeset
1100 gchar *unescaped;
f3477b0d32f4 improved "now listening" status support.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 23399
diff changeset
1101 unescaped = purple_unescape_html(jbr->status + strlen("♫ "));
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1102 purple_prpl_got_user_status(js->gc->account, user, "tune",
27894
f3477b0d32f4 improved "now listening" status support.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 23399
diff changeset
1103 PURPLE_TUNE_TITLE, unescaped, NULL);
f3477b0d32f4 improved "now listening" status support.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 23399
diff changeset
1104 g_free(unescaped);
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1105 jbr->status = NULL;
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1106 } else {
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1107 purple_prpl_got_user_status_deactive(js->gc->account, user, "tune");
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1108 }
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1109 }
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1110
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1111 char *jabber_google_presence_outgoing(PurpleStatus *tune)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1112 {
21634
1853d9d0cc65 don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents: 21220
diff changeset
1113 const char *attr = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
1853d9d0cc65 don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents: 21220
diff changeset
1114 return attr ? g_strdup_printf("♫ %s", attr) : g_strdup("");
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1115 }
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1116
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1117 static void
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1118 jabber_google_stun_lookup_cb(GSList *hosts, gpointer data,
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1119 const char *error_message)
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1120 {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1121 JabberStream *js = (JabberStream *) data;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1122
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1123 if (error_message) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1124 purple_debug_error("jabber", "Google STUN lookup failed: %s\n",
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1125 error_message);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1126 g_slist_free(hosts);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1127 return;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1128 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1129
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1130 if (hosts && g_slist_next(hosts)) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1131 struct sockaddr *addr = g_slist_next(hosts)->data;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1132 char dst[INET6_ADDRSTRLEN];
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1133 int port;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1134
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1135 if (addr->sa_family == AF_INET6) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1136 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr,
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1137 dst, sizeof(dst));
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1138 port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1139 } else {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1140 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr,
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1141 dst, sizeof(dst));
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1142 port = ntohs(((struct sockaddr_in *) addr)->sin_port);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1143 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1144
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1145 if (js) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1146 if (js->stun_ip) {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1147 g_free(js->stun_ip);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1148 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1149 js->stun_ip = g_strdup(dst);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1150 purple_debug_info("jabber", "set Google STUN IP address: %s\n", dst);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1151 js->stun_port = port;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1152 purple_debug_info("jabber", "set Google STUN port: %d\n", port);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1153 purple_debug_info("jabber", "set Google STUN port: %d\n", port);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1154 /* unmark ongoing query */
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1155 js->stun_query = NULL;
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1156 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1157 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1158
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1159 g_slist_free(hosts);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1160 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1161
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1162 static void
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1163 jabber_google_jingle_info_common(JabberStream *js, const char *from,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1164 JabberIqType type, xmlnode *query)
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1165 {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1166 const xmlnode *stun = xmlnode_get_child(query, "stun");
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1167 gchar *my_bare_jid;
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1168
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1169 /*
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1170 * Make sure that random people aren't sending us STUN servers. Per
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1171 * http://code.google.com/apis/talk/jep_extensions/jingleinfo.html, these
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1172 * stanzas are stamped from our bare JID.
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1173 */
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1174 if (from) {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1175 my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1176 if (!purple_strequal(from, my_bare_jid)) {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1177 purple_debug_warning("jabber", "got google:jingleinfo with invalid from (%s)\n",
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1178 from);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1179 g_free(my_bare_jid);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1180 return;
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1181 }
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1182
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1183 g_free(my_bare_jid);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1184 }
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1185
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1186 if (type == JABBER_IQ_ERROR || type == JABBER_IQ_GET)
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1187 return;
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1188
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1189 purple_debug_info("jabber", "got google:jingleinfo\n");
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1190
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1191 if (stun) {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1192 xmlnode *server = xmlnode_get_child(stun, "server");
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1193
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1194 if (server) {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1195 const gchar *host = xmlnode_get_attrib(server, "host");
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1196 const gchar *udp = xmlnode_get_attrib(server, "udp");
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1197
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1198 if (host && udp) {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1199 int port = atoi(udp);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1200 /* if there, would already be an ongoing query,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1201 cancel it */
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1202 if (js->stun_query)
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1203 purple_dnsquery_destroy(js->stun_query);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1204
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1205 js->stun_query = purple_dnsquery_a(host, port,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1206 jabber_google_stun_lookup_cb, js);
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1207 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1208 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1209 }
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1210 /* should perhaps handle relays later on, or maybe wait until
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1211 Google supports a common standard... */
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1212 }
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1213
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1214 static void
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1215 jabber_google_jingle_info_cb(JabberStream *js, const char *from,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1216 JabberIqType type, const char *id,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1217 xmlnode *packet, gpointer data)
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1218 {
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1219 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1220 GOOGLE_JINGLE_INFO_NAMESPACE);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1221
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1222 if (query)
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1223 jabber_google_jingle_info_common(js, from, type, query);
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1224 else
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1225 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n");
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1226 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1227
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1228 void
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1229 jabber_google_handle_jingle_info(JabberStream *js, const char *from,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1230 JabberIqType type, const char *id,
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1231 xmlnode *child)
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1232 {
26553
91583903b478 Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents: 26552
diff changeset
1233 jabber_google_jingle_info_common(js, from, type, child);
26162
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1234 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1235
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1236 void
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1237 jabber_google_send_jingle_info(JabberStream *js)
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1238 {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1239 JabberIq *jingle_info =
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1240 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1241
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1242 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb,
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1243 NULL);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1244 purple_debug_info("jabber", "sending google:jingleinfo query\n");
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1245 jabber_iq_send(jingle_info);
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26140
diff changeset
1246 }