Mercurial > pidgin
annotate libpurple/protocols/jabber/google.c @ 30509:0712ce23901e
propagate from branch 'im.pidgin.pidgin' (head 37329f033a30f4f4f5048f9fdc86df4400e3ada5)
to branch 'im.pidgin.cpw.malu.xmpp.google_relay' (head 19964a278756296718ce9887b3e8b98a575f9310)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 09 Nov 2009 19:01:03 +0000 |
parents | 2702ca44d963 fa7f3426ed13 |
children | cb8b53a6f238 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
15822 | 2 * Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * 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
|
4 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * 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
|
7 * 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
|
8 * 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
|
9 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * 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
|
17 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18751
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 */ |
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 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 #include "debug.h" |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
23 #include "mediamanager.h" |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
24 #include "util.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "privacy.h" |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
26 #include "dnsquery.h" |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
27 #include "network.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "buddy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "google.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "jabber.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "presence.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "iq.h" |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
34 #include "chat.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
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:
26058
diff
changeset
|
37 |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
38 #ifdef USE_VV |
23800
4b9b265a8100
Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23797
diff
changeset
|
39 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
40 #define NS_GOOGLE_VIDEO "http://www.google.com/session/video" |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
41 #define NS_GOOGLE_PHONE "http://www.google.com/session/phone" |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
42 |
23759
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 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
|
44 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
|
45 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
|
46 } 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
|
47 |
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 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 } 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
|
55 |
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 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
|
57 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
|
58 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
|
59 PurpleMedia *media; |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
60 JabberStream *js; |
23759
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 char *remote_jid; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
62 gboolean video; |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
63 char *iq_id; |
23759
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 } 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
|
65 |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
66 static gboolean |
23759
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 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
|
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 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
|
70 GoogleSessionId *d = (GoogleSessionId*)b; |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
71 |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
72 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
|
73 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
74 |
18161 | 75 static void |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
76 google_session_destroy(GoogleSession *session) |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
77 { |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
78 g_free(session->id.id); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
79 g_free(session->id.initiator); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
80 g_free(session->remote_jid); |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
81 g_free(session->iq_id); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
82 g_free(session); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
83 } |
23759
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 |
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 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
|
86 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
|
87 { |
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 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
95 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
96 static void |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
97 google_session_send_candidates(PurpleMedia *media, gchar *session_id, |
24964
0101d6e97f12
Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24960
diff
changeset
|
98 gchar *participant, GoogleSession *session) |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
99 { |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
100 GList *candidates = purple_media_get_local_candidates( |
28360
ed88200c79ee
A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28302
diff
changeset
|
101 session->media, session_id, session->remote_jid), *iter; |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
102 PurpleMediaCandidate *transport; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
103 gboolean video = FALSE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
104 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
105 if (!strcmp(session_id, "google-video")) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
106 video = TRUE; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
107 |
28360
ed88200c79ee
A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28302
diff
changeset
|
108 for (iter = candidates; iter; iter = iter->next) { |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
109 JabberIq *iq; |
28302
67a97fca157c
Generate the "preference" attribute correctly for candidates on locales
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
110 gchar *ip, *port, *username, *password; |
67a97fca157c
Generate the "preference" attribute correctly for candidates on locales
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
111 gchar pref[16]; |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
112 PurpleMediaCandidateType type; |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
113 xmlnode *sess; |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
114 xmlnode *candidate; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
115 guint component_id; |
28360
ed88200c79ee
A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28302
diff
changeset
|
116 transport = PURPLE_MEDIA_CANDIDATE(iter->data); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
117 component_id = purple_media_candidate_get_component_id( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
118 transport); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
119 |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
120 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
121 sess = google_session_create_xmlnode(session, "candidates"); |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
122 xmlnode_insert_child(iq->node, sess); |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
123 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
124 |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
125 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
|
126 |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
127 ip = purple_media_candidate_get_ip(transport); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
128 port = g_strdup_printf("%d", |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
129 purple_media_candidate_get_port(transport)); |
28302
67a97fca157c
Generate the "preference" attribute correctly for candidates on locales
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
130 g_ascii_dtostr(pref, 16, |
67a97fca157c
Generate the "preference" attribute correctly for candidates on locales
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
131 purple_media_candidate_get_priority(transport) / 1000.0); |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
132 username = purple_media_candidate_get_username(transport); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
133 password = purple_media_candidate_get_password(transport); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
134 type = purple_media_candidate_get_candidate_type(transport); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
135 |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
136 xmlnode_set_attrib(candidate, "address", ip); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
137 xmlnode_set_attrib(candidate, "port", port); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
138 xmlnode_set_attrib(candidate, "name", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
139 component_id == PURPLE_MEDIA_COMPONENT_RTP ? |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
140 video ? "video_rtp" : "rtp" : |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
141 component_id == PURPLE_MEDIA_COMPONENT_RTCP ? |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
142 video ? "video_rtcp" : "rtcp" : "none"); |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
143 xmlnode_set_attrib(candidate, "username", username); |
25001
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
144 /* |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
145 * As of this writing, Farsight 2 in Google compatibility |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
146 * mode doesn't provide a password. The Gmail client |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
147 * requires this to be set. |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
148 */ |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
149 xmlnode_set_attrib(candidate, "password", |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
150 password != NULL ? password : ""); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
151 xmlnode_set_attrib(candidate, "preference", pref); |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
152 xmlnode_set_attrib(candidate, "protocol", |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
153 purple_media_candidate_get_protocol(transport) |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
154 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
155 "udp" : "tcp"); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
156 xmlnode_set_attrib(candidate, "type", type == |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
157 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" : |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
158 type == |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
159 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" : |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
160 type == |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
161 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
162 NULL); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
163 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
|
164 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
|
165 xmlnode_insert_child(sess, candidate); |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
166 |
26406
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
167 g_free(ip); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
168 g_free(port); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
169 g_free(username); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
170 g_free(password); |
2d332d327a0e
Hide and GObjectify PurpleMediaCandidate.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26404
diff
changeset
|
171 |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
172 jabber_iq_send(iq); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
173 } |
28360
ed88200c79ee
A leak fix in the candidate list, and some code simplification.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28302
diff
changeset
|
174 purple_media_candidate_list_free(candidates); |
23759
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 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
177 static void |
26314
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
178 google_session_ready(GoogleSession *session) |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
179 { |
26314
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
180 PurpleMedia *media = session->media; |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
181 if (purple_media_codecs_ready(media, NULL) && |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
182 purple_media_candidates_prepared(media, NULL, NULL)) { |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
183 gchar *me = g_strdup_printf("%s@%s/%s", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
184 session->js->user->node, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
185 session->js->user->domain, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
186 session->js->user->resource); |
26314
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
187 JabberIq *iq; |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
188 xmlnode *sess, *desc, *payload; |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
189 GList *codecs, *iter; |
26314
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
190 gboolean is_initiator = !strcmp(session->id.initiator, me); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
191 |
26314
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
192 if (!is_initiator && |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
193 !purple_media_accepted(media, NULL, NULL)) { |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
194 g_free(me); |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
195 return; |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
196 } |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
197 |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
198 iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
199 |
2ad89aff8d68
Remove ready-new from use.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
200 if (is_initiator) { |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
201 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:
25001
diff
changeset
|
202 xmlnode_set_attrib(iq->node, "from", session->id.initiator); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
203 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:
26030
diff
changeset
|
204 } else { |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
205 google_session_send_candidates(session->media, |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
206 "google-voice", session->remote_jid, |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
207 session); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
208 google_session_send_candidates(session->media, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
209 "google-video", session->remote_jid, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
210 session); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
211 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:
26030
diff
changeset
|
212 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:
26030
diff
changeset
|
213 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:
26030
diff
changeset
|
214 } |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
215 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:
26030
diff
changeset
|
216 desc = xmlnode_new_child(sess, "description"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
217 if (session->video) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
218 xmlnode_set_namespace(desc, NS_GOOGLE_VIDEO); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
219 else |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
220 xmlnode_set_namespace(desc, NS_GOOGLE_PHONE); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
221 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
222 codecs = purple_media_get_codecs(media, "google-video"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
223 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
224 for (iter = codecs; iter; iter = g_list_next(iter)) { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
225 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
226 gchar *id = g_strdup_printf("%d", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
227 purple_media_codec_get_id(codec)); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
228 gchar *encoding_name = |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
229 purple_media_codec_get_encoding_name(codec); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
230 payload = xmlnode_new_child(desc, "payload-type"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
231 xmlnode_set_attrib(payload, "id", id); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
232 xmlnode_set_attrib(payload, "name", encoding_name); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
233 xmlnode_set_attrib(payload, "width", "320"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
234 xmlnode_set_attrib(payload, "height", "200"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
235 xmlnode_set_attrib(payload, "framerate", "30"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
236 g_free(encoding_name); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
237 g_free(id); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
238 } |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
239 purple_media_codec_list_free(codecs); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
240 |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
241 codecs = purple_media_get_codecs(media, "google-voice"); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
242 |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
243 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:
26030
diff
changeset
|
244 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
26404
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
245 gchar *id = g_strdup_printf("%d", |
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
246 purple_media_codec_get_id(codec)); |
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
247 gchar *encoding_name = |
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
248 purple_media_codec_get_encoding_name(codec); |
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
249 gchar *clock_rate = g_strdup_printf("%d", |
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
250 purple_media_codec_get_clock_rate(codec)); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
251 payload = xmlnode_new_child(desc, "payload-type"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
252 if (session->video) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
253 xmlnode_set_namespace(payload, NS_GOOGLE_PHONE); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
254 xmlnode_set_attrib(payload, "id", id); |
26998
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
255 /* |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
256 * Hack to make Gmail accept speex as the codec. |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
257 * It shouldn't have to be case sensitive. |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
258 */ |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
259 if (purple_strequal(encoding_name, "SPEEX")) |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
260 xmlnode_set_attrib(payload, "name", "speex"); |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
261 else |
f0621e47ccf3
Make Gmail accept speex as the codec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26997
diff
changeset
|
262 xmlnode_set_attrib(payload, "name", encoding_name); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
263 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:
26030
diff
changeset
|
264 g_free(clock_rate); |
26404
217574ec2a34
Hide and gobjectify PurpleMediaCodec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26384
diff
changeset
|
265 g_free(encoding_name); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
266 g_free(id); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
267 } |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
268 purple_media_codec_list_free(codecs); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
269 |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
270 jabber_iq_send(iq); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
271 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
272 if (is_initiator) { |
26355
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
273 google_session_send_candidates(session->media, |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
274 "google-voice", session->remote_jid, |
29bc149cbd07
Send candidates more like GMail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26354
diff
changeset
|
275 session); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
276 google_session_send_candidates(session->media, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
277 "google-video", session->remote_jid, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
278 session); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
279 } |
26318
007cd8dad384
Don't let initiate or accept be sent again with Google Voice.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26314
diff
changeset
|
280 |
007cd8dad384
Don't let initiate or accept be sent again with Google Voice.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26314
diff
changeset
|
281 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:
26314
diff
changeset
|
282 G_CALLBACK(google_session_ready), session); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
283 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
284 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
285 |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
286 static void |
26329
86bc2d34f689
Rename state-changed enum and values.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26323
diff
changeset
|
287 google_session_state_changed_cb(PurpleMedia *media, PurpleMediaState state, |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
288 gchar *sid, gchar *name, GoogleSession *session) |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
289 { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
290 if (sid == NULL && name == NULL) { |
26329
86bc2d34f689
Rename state-changed enum and values.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26323
diff
changeset
|
291 if (state == PURPLE_MEDIA_STATE_END) { |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
292 google_session_destroy(session); |
26322
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
293 } |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
294 } |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
295 } |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
296 |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
297 static void |
26323
51b986bbe260
Use the right enum for the parameter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26322
diff
changeset
|
298 google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type, |
26366
4e1286e76f1f
Create purple_media_stream_info. Add local parameter to stream-info signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26365
diff
changeset
|
299 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:
26365
diff
changeset
|
300 GoogleSession *session) |
26322
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
301 { |
28089
1e529b03ec81
Handle the local accept signal with GTalk/Gmail. This was causing calls
maiku@pidgin.im
parents:
28045
diff
changeset
|
302 if (sid != NULL || name != NULL) |
1e529b03ec81
Handle the local accept signal with GTalk/Gmail. This was causing calls
maiku@pidgin.im
parents:
28045
diff
changeset
|
303 return; |
1e529b03ec81
Handle the local accept signal with GTalk/Gmail. This was causing calls
maiku@pidgin.im
parents:
28045
diff
changeset
|
304 |
26322
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
305 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:
26318
diff
changeset
|
306 xmlnode *sess; |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
307 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
308 |
26322
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
309 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:
26318
diff
changeset
|
310 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:
26318
diff
changeset
|
311 xmlnode_insert_child(iq->node, sess); |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
312 |
26322
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
313 jabber_iq_send(iq); |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
314 } 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:
26318
diff
changeset
|
315 xmlnode *sess; |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
316 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:
26318
diff
changeset
|
317 |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
318 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:
26318
diff
changeset
|
319 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:
26318
diff
changeset
|
320 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:
26318
diff
changeset
|
321 |
90c7f3e477b3
Use stream-info instead of state-changed for hangup and reject.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26318
diff
changeset
|
322 jabber_iq_send(iq); |
28089
1e529b03ec81
Handle the local accept signal with GTalk/Gmail. This was causing calls
maiku@pidgin.im
parents:
28045
diff
changeset
|
323 } else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) { |
1e529b03ec81
Handle the local accept signal with GTalk/Gmail. This was causing calls
maiku@pidgin.im
parents:
28045
diff
changeset
|
324 google_session_ready(session); |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
325 } |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
326 } |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
327 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
328 static GParameter * |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
329 jabber_google_session_get_params(JabberStream *js, const gchar *relay_ip, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
330 guint16 relay_udp, guint16 relay_tcp, guint16 relay_ssltcp, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
331 const gchar *relay_username, const gchar *relay_password, guint *num) |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
332 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
333 guint num_params; |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
334 GParameter *params = |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
335 jingle_get_params(js, relay_ip, relay_udp, relay_tcp, relay_ssltcp, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
336 relay_username, relay_password, &num_params); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
337 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:
26058
diff
changeset
|
338 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
339 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:
26058
diff
changeset
|
340 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
341 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:
26058
diff
changeset
|
342 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:
26058
diff
changeset
|
343 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:
26058
diff
changeset
|
344 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:
26058
diff
changeset
|
345 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
346 g_free(params); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
347 *num = num_params + 1; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
348 return new_params; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
349 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
350 |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
351 static void |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
352 jabber_google_relay_parse_response(const gchar *response, gchar **ip, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
353 guint *udp, guint *tcp, guint *ssltcp, gchar **username, gchar **password) |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
354 { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
355 gchar **lines = g_strsplit(response, "\n", -1); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
356 int i = 0; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
357 |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
358 for (; lines[i] ; i++) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
359 gchar *line = lines[i]; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
360 gchar **parts = g_strsplit(line, "=", 2); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
361 |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
362 if (parts[0] && parts[1]) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
363 if (purple_strequal(parts[0], "relay.ip")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
364 *ip = g_strdup(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
365 } else if (purple_strequal(parts[0], "relay.udp_port")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
366 *udp = atoi(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
367 } else if (purple_strequal(parts[0], "relay.tcp_port")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
368 *tcp = atoi(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
369 } else if (purple_strequal(parts[0], "relay.ssltcp_port")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
370 *ssltcp = atoi(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
371 } else if (purple_strequal(parts[0], "username")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
372 *username = g_strdup(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
373 } else if (purple_strequal(parts[0], "password")) { |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
374 *password = g_strdup(parts[1]); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
375 } |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
376 } |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
377 g_strfreev(parts); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
378 } |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
379 |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
380 g_strfreev(lines); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
381 } |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
382 |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
383 static void |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
384 jabber_google_relay_remove_url_data(JabberStream *js, |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
385 PurpleUtilFetchUrlData *url_data) |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
386 { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
387 GList *iter = js->google_relay_requests; |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
388 |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
389 while (iter) { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
390 if (iter->data == url_data) { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
391 js->google_relay_requests = |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
392 g_list_delete_link(js->google_relay_requests, iter); |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
393 break; |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
394 } |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
395 } |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
396 } |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
397 |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
398 static void |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
399 jabber_google_relay_response_session_initiate_cb(PurpleUtilFetchUrlData *url_data, |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
400 gpointer user_data, const gchar *url_text, gsize len, |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
401 const gchar *error_message) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 { |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
403 GoogleSession *session = (GoogleSession *) user_data; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
404 GParameter *params; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
405 guint num_params; |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
406 JabberStream *js = session->js; |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
407 gchar *relay_ip = NULL; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
408 guint relay_udp = 0; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
409 guint relay_tcp = 0; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
410 guint relay_ssltcp = 0; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
411 gchar *relay_username = NULL; |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
412 gchar *relay_password = NULL; |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
413 |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
414 if (url_data) { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
415 jabber_google_relay_remove_url_data(js, url_data); |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
416 } |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
417 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
418 purple_debug_info("jabber", "got response on HTTP request to relay server\n"); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
419 |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
420 if (url_text && len > 0) { |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
421 purple_debug_info("jabber", "got Google relay request response:\n%s\n", |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
422 url_text); |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
423 jabber_google_relay_parse_response(url_text, &relay_ip, &relay_udp, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
424 &relay_tcp, &relay_ssltcp, &relay_username, &relay_password); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
425 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
426 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
427 session->media = purple_media_manager_create_media( |
26524
df9042312063
Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26476
diff
changeset
|
428 purple_media_manager_get(), |
df9042312063
Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26476
diff
changeset
|
429 purple_connection_get_account(js->gc), |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
430 "fsrtpconference", session->remote_jid, TRUE); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
431 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
432 purple_media_set_prpl_data(session->media, session); |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
433 |
28045
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
434 g_signal_connect_swapped(G_OBJECT(session->media), |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
435 "candidates-prepared", |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
436 G_CALLBACK(google_session_ready), session); |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
437 g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed", |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
438 G_CALLBACK(google_session_ready), session); |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
439 g_signal_connect(G_OBJECT(session->media), "state-changed", |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
440 G_CALLBACK(google_session_state_changed_cb), session); |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
441 g_signal_connect(G_OBJECT(session->media), "stream-info", |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
442 G_CALLBACK(google_session_stream_info_cb), session); |
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
443 |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
444 params = |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
445 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
446 relay_ssltcp, relay_username, relay_password, &num_params); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
447 |
30499
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
448 g_free(relay_ip); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
449 g_free(relay_username); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
450 g_free(relay_password); |
f858b53dfbf0
Can now generate a relayed candidate for the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
30498
diff
changeset
|
451 |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
452 if (purple_media_add_stream(session->media, "google-voice", |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
453 session->remote_jid, PURPLE_MEDIA_AUDIO, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
454 TRUE, "nice", num_params, params) == FALSE || |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
455 (session->video && purple_media_add_stream( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
456 session->media, "google-video", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
457 session->remote_jid, PURPLE_MEDIA_VIDEO, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
458 TRUE, "nice", num_params, params) == FALSE)) { |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
459 purple_media_error(session->media, "Error adding stream."); |
28045
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
460 purple_media_end(session->media, NULL, NULL); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
461 g_free(params); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
462 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
463 |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
464 g_free(params); |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
465 } |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
466 |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
467 static void |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
468 jabber_google_do_relay_request(JabberStream *js, GoogleSession *session, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
469 PurpleUtilFetchUrlCallback cb) |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
470 { |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
471 PurpleUtilFetchUrlData *url_data = NULL; |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
472 gchar *url = g_strdup_printf("http://%s", js->google_relay_host); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
473 gchar *request = |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
474 g_strdup_printf("GET /create_session HTTP/1.0\r\n" |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
475 "Host: %s\r\n" |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
476 "X-Talk-Google-Relay-Auth: %s\r\n" |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
477 "X-Google-Relay-Auth: %s\r\n\r\n", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
478 js->google_relay_host, js->google_relay_token, js->google_relay_token); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
479 purple_debug_info("jabber", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
480 "sending Google relay request %s to %s\n", request, url); |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
481 url_data = |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
482 purple_util_fetch_url_request(url, FALSE, NULL, FALSE, request, FALSE, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
483 cb, session); |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
484 if (url_data) { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
485 js->google_relay_requests = |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
486 g_list_prepend(js->google_relay_requests, url_data); |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
487 } else { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
488 purple_debug_error("jabber", "unable to create Google relay request\n"); |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
489 cb(NULL, session, NULL, 0, NULL); |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
490 } |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
491 g_free(url); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
492 g_free(request); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
493 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
494 |
26365
34eb898478b4
Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26355
diff
changeset
|
495 gboolean |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
496 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 { |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
498 GoogleSession *session; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
499 JabberBuddy *jb; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
500 JabberBuddyResource *jbr; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
501 gchar *jid; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
502 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
503 /* construct JID to send to */ |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
504 jb = jabber_buddy_find(js, who, FALSE); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
505 if (!jb) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
506 purple_debug_error("jingle-rtp", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
507 "Could not find Jabber buddy\n"); |
26365
34eb898478b4
Don't assume a PurpleMedia instance will be created immediately.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26355
diff
changeset
|
508 return FALSE; |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
509 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
510 jbr = jabber_buddy_find_resource(jb, NULL); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
511 if (!jbr) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
512 purple_debug_error("jingle-rtp", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
513 "Could not find buddy's resource\n"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
514 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
515 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
516 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
517 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:
25001
diff
changeset
|
518 } else { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
519 jid = g_strdup(who); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
520 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
521 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
522 session = g_new0(GoogleSession, 1); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
523 session->id.id = jabber_get_next_id(js); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
524 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:
25001
diff
changeset
|
525 js->user->domain, js->user->resource); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
526 session->state = SENT_INITIATE; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
527 session->js = js; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
528 session->remote_jid = jid; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
529 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
530 if (type & PURPLE_MEDIA_VIDEO) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
531 session->video = TRUE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
532 |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
533 /* if we got a relay token and relay host in google:jingleinfo, issue an |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
534 HTTP request to get that data */ |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
535 if (js->google_relay_host && js->google_relay_token) { |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
536 jabber_google_do_relay_request(js, session, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
537 jabber_google_relay_response_session_initiate_cb); |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
538 } else { |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
539 jabber_google_relay_response_session_initiate_cb(NULL, session, NULL, 0, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
540 NULL); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
541 } |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
542 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
543 /* we don't actually know yet wether it succeeded... maybe this is very |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
544 wrong... */ |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
545 return TRUE; |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
546 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
547 |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
548 static void |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
549 jabber_google_relay_response_session_handle_initiate_cb( |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
550 PurpleUtilFetchUrlData *url_data, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
551 gpointer user_data, const gchar *url_text, gsize len, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
552 const gchar *error_message) |
23759
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 { |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
554 GoogleSession *session = (GoogleSession *) user_data; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
555 GParameter *params; |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
556 guint num_params; |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
557 JabberStream *js = session->js; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
558 gchar *relay_ip = NULL; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
559 guint relay_udp = 0; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
560 guint relay_tcp = 0; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
561 guint relay_ssltcp = 0; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
562 gchar *relay_username = NULL; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
563 gchar *relay_password = NULL; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
564 xmlnode *codec_element; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
565 xmlnode *desc_element; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
566 const gchar *xmlns; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
567 PurpleMediaCodec *codec; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
568 GList *video_codecs = NULL; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
569 GList *codecs = NULL; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
570 JabberIq *result; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
571 |
30506
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
572 if (url_data) { |
e0796db1df8a
Keep track of more than one relay request at a time (this is probably not
Marcus Lundblad <ml@update.uu.se>
parents:
30505
diff
changeset
|
573 jabber_google_relay_remove_url_data(js, url_data); |
23759
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 } |
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 |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
576 if (url_text && len > 0) { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
577 purple_debug_info("jabber", "got Google relay request response:\n%s\n", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
578 url_text); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
579 jabber_google_relay_parse_response(url_text, &relay_ip, &relay_udp, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
580 &relay_tcp, &relay_ssltcp, &relay_username, &relay_password); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
581 } |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
582 |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
583 params = |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
584 jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
585 relay_ssltcp, relay_username, relay_password, &num_params); |
24964
0101d6e97f12
Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24960
diff
changeset
|
586 |
26384
bea334b214fa
Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26371
diff
changeset
|
587 if (purple_media_add_stream(session->media, "google-voice", |
bea334b214fa
Add purple_media_is_initiator.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26371
diff
changeset
|
588 session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE, |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
589 "nice", num_params, params) == FALSE || |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
590 (session->video && purple_media_add_stream( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
591 session->media, "google-video", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
592 session->remote_jid, PURPLE_MEDIA_VIDEO, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
593 FALSE, "nice", num_params, params) == FALSE)) { |
24999
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
594 purple_media_error(session->media, "Error adding stream."); |
26369
2862fee7acf2
Remove purple_media_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26366
diff
changeset
|
595 purple_media_stream_info(session->media, |
28045
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
596 PURPLE_MEDIA_INFO_REJECT, NULL, NULL, TRUE); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
597 g_free(params); |
24999
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
598 } |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
599 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
600 g_free(params); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
601 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
602 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
603 codec_element; codec_element = codec_element->next) { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
604 const char *id, *encoding_name, *clock_rate, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
605 *width, *height, *framerate; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
606 gboolean video; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
607 if (codec_element->name && |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
608 strcmp(codec_element->name, "payload-type")) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
609 continue; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
610 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
611 xmlns = xmlnode_get_namespace(codec_element); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
612 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
|
613 id = xmlnode_get_attrib(codec_element, "id"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
614 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
615 if (!session->video || |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
616 (xmlns && !strcmp(xmlns, NS_GOOGLE_PHONE))) { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
617 clock_rate = xmlnode_get_attrib( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
618 codec_element, "clockrate"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
619 video = FALSE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
620 } else { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
621 width = xmlnode_get_attrib(codec_element, "width"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
622 height = xmlnode_get_attrib(codec_element, "height"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
623 framerate = xmlnode_get_attrib( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
624 codec_element, "framerate"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
625 clock_rate = "90000"; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
626 video = TRUE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
627 } |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
628 |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
629 if (id) { |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
630 codec = purple_media_codec_new(atoi(id), encoding_name, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
631 video ? PURPLE_MEDIA_VIDEO : |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
632 PURPLE_MEDIA_AUDIO, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
633 clock_rate ? atoi(clock_rate) : 0); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
634 if (video) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
635 video_codecs = g_list_append( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
636 video_codecs, codec); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
637 else |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
638 codecs = g_list_append(codecs, codec); |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
639 } |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
640 } |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
641 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
642 if (codecs) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
643 purple_media_set_remote_codecs(session->media, "google-voice", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
644 session->remote_jid, codecs); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
645 if (video_codecs) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
646 purple_media_set_remote_codecs(session->media, "google-video", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
647 session->remote_jid, video_codecs); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
648 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
649 purple_media_codec_list_free(codecs); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
650 purple_media_codec_list_free(video_codecs); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
651 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
652 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
653 jabber_iq_set_id(result, session->iq_id); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
654 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:
23759
diff
changeset
|
655 jabber_iq_send(result); |
30501
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
656 } |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
657 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
658 static gboolean |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
659 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
660 { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
661 xmlnode *desc_element; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
662 const gchar *xmlns; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
663 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
664 if (session->state != UNINIT) { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
665 purple_debug_error("jabber", "Received initiate for active session.\n"); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
666 return FALSE; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
667 } |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
668 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
669 desc_element = xmlnode_get_child(sess, "description"); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
670 xmlns = xmlnode_get_namespace(desc_element); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
671 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
672 if (purple_strequal(xmlns, NS_GOOGLE_PHONE)) |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
673 session->video = FALSE; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
674 else if (purple_strequal(xmlns, NS_GOOGLE_VIDEO)) |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
675 session->video = TRUE; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
676 else { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
677 purple_debug_error("jabber", "Received initiate with " |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
678 "invalid namespace %s.\n", xmlns); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
679 return FALSE; |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
680 } |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
681 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
682 session->media = purple_media_manager_create_media( |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
683 purple_media_manager_get(), |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
684 purple_connection_get_account(js->gc), |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
685 "fsrtpconference", session->remote_jid, FALSE); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
686 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
687 purple_media_set_prpl_data(session->media, session); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
688 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
689 g_signal_connect_swapped(G_OBJECT(session->media), |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
690 "candidates-prepared", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
691 G_CALLBACK(google_session_ready), session); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
692 g_signal_connect_swapped(G_OBJECT(session->media), "codecs-changed", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
693 G_CALLBACK(google_session_ready), session); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
694 g_signal_connect(G_OBJECT(session->media), "state-changed", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
695 G_CALLBACK(google_session_state_changed_cb), session); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
696 g_signal_connect(G_OBJECT(session->media), "stream-info", |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
697 G_CALLBACK(google_session_stream_info_cb), session); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
698 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
699 session->iq_id = g_strdup(iq_id); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
700 |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
701 if (js->google_relay_host && js->google_relay_token) { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
702 jabber_google_do_relay_request(js, session, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
703 jabber_google_relay_response_session_handle_initiate_cb); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
704 } else { |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
705 jabber_google_relay_response_session_handle_initiate_cb(NULL, session, |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
706 NULL, 0, NULL); |
bcf1e4fe2a89
The receiver can now generate relayed candidates
Marcus Lundblad <ml@update.uu.se>
parents:
30499
diff
changeset
|
707 } |
27799
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27685
diff
changeset
|
708 |
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27685
diff
changeset
|
709 return TRUE; |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
710 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
711 |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
712 static void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
713 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
714 { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
715 JabberIq *result; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
716 GList *list = NULL, *video_list = NULL; |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
717 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
|
718 static int name = 0; |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
719 char n[4]; |
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
720 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
721 for (cand = xmlnode_get_child(sess, "candidate"); cand; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
722 cand = xmlnode_get_next_twin(cand)) { |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
723 PurpleMediaCandidate *info; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
724 const gchar *cname = xmlnode_get_attrib(cand, "name"); |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
725 const gchar *type = xmlnode_get_attrib(cand, "type"); |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
726 const gchar *protocol = xmlnode_get_attrib(cand, "protocol"); |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
727 const gchar *address = xmlnode_get_attrib(cand, "address"); |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
728 const gchar *port = xmlnode_get_attrib(cand, "port"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
729 guint component_id; |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
730 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
731 if (cname && type && address && port) { |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
732 PurpleMediaCandidateType candidate_type; |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
733 |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
734 g_snprintf(n, sizeof(n), "S%d", name++); |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
735 |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
736 if (g_str_equal(type, "local")) |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
737 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
738 else if (g_str_equal(type, "stun")) |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
739 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX; |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
740 else if (g_str_equal(type, "relay")) |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
741 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_RELAY; |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
742 else |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
743 candidate_type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST; |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
744 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
745 if (purple_strequal(cname, "rtcp") || |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
746 purple_strequal(cname, "video_rtcp")) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
747 component_id = PURPLE_MEDIA_COMPONENT_RTCP; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
748 else |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
749 component_id = PURPLE_MEDIA_COMPONENT_RTP; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
750 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
751 info = purple_media_candidate_new(n, component_id, |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
752 candidate_type, |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
753 purple_strequal(protocol, "udp") ? |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
754 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP : |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
755 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP, |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
756 address, |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
757 atoi(port)); |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
758 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"), |
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
759 "password", xmlnode_get_attrib(cand, "password"), NULL); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
760 if (!strncmp(cname, "video_", 6)) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
761 video_list = g_list_append(video_list, info); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
762 else |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
763 list = g_list_append(list, info); |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
764 } |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
765 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
766 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
767 if (list) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
768 purple_media_add_remote_candidates( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
769 session->media, "google-voice", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
770 session->remote_jid, list); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
771 if (video_list) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
772 purple_media_add_remote_candidates( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
773 session->media, "google-video", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
774 session->remote_jid, video_list); |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
775 purple_media_candidate_list_free(list); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
776 purple_media_candidate_list_free(video_list); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
777 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
778 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
779 jabber_iq_set_id(result, iq_id); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
780 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:
23759
diff
changeset
|
781 jabber_iq_send(result); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
782 } |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
783 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
784 static void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
785 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
786 { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
787 xmlnode *desc_element = xmlnode_get_child(sess, "description"); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
788 xmlnode *codec_element = xmlnode_get_child( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
789 desc_element, "payload-type"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
790 GList *codecs = NULL, *video_codecs = NULL; |
26354
d8d6fb37c789
Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26334
diff
changeset
|
791 JabberIq *result = NULL; |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
792 const gchar *xmlns = xmlnode_get_namespace(desc_element); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
793 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_VIDEO)); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
794 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
795 for (; codec_element; codec_element = codec_element->next) { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
796 const gchar *xmlns, *encoding_name, *id, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
797 *clock_rate, *width, *height, *framerate; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
798 gboolean video_codec = FALSE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
799 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
800 if (!purple_strequal(codec_element->name, "payload-type")) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
801 continue; |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
802 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
803 xmlns = xmlnode_get_namespace(codec_element); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
804 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
805 id = xmlnode_get_attrib(codec_element, "id"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
806 |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
807 if (!video || purple_strequal(xmlns, NS_GOOGLE_PHONE)) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
808 clock_rate = xmlnode_get_attrib( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
809 codec_element, "clockrate"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
810 else { |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
811 clock_rate = "90000"; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
812 width = xmlnode_get_attrib(codec_element, "width"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
813 height = xmlnode_get_attrib(codec_element, "height"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
814 framerate = xmlnode_get_attrib( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
815 codec_element, "framerate"); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
816 video_codec = TRUE; |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
817 } |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
818 |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
819 if (id && encoding_name) { |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
820 PurpleMediaCodec *codec = purple_media_codec_new( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
821 atoi(id), encoding_name, |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
822 video_codec ? PURPLE_MEDIA_VIDEO : |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
823 PURPLE_MEDIA_AUDIO, |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
824 clock_rate ? atoi(clock_rate) : 0); |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
825 if (video_codec) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
826 video_codecs = g_list_append( |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
827 video_codecs, codec); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
828 else |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
829 codecs = g_list_append(codecs, codec); |
26757
43e1cdbc6b4b
Avoid crashing on some more atoi calls and ensure required parameters are !NULL
Paul Aurich <paul@darkrain42.org>
parents:
26551
diff
changeset
|
830 } |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
831 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
832 |
26997
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
833 if (codecs) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
834 purple_media_set_remote_codecs(session->media, "google-voice", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
835 session->remote_jid, codecs); |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
836 if (video_codecs) |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
837 purple_media_set_remote_codecs(session->media, "google-video", |
72bcdcb0629f
Add Gmail video support.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26946
diff
changeset
|
838 session->remote_jid, video_codecs); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
839 |
26371
12c7db418c3e
Remove purple_media_accept.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26369
diff
changeset
|
840 purple_media_stream_info(session->media, PURPLE_MEDIA_INFO_ACCEPT, |
12c7db418c3e
Remove purple_media_accept.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26369
diff
changeset
|
841 NULL, NULL, FALSE); |
26354
d8d6fb37c789
Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26334
diff
changeset
|
842 |
d8d6fb37c789
Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26334
diff
changeset
|
843 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
844 jabber_iq_set_id(result, iq_id); |
26354
d8d6fb37c789
Fix Gtalk bug where it would terminate the session after 15 seconds.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26334
diff
changeset
|
845 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:
26334
diff
changeset
|
846 jabber_iq_send(result); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
847 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
848 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
849 static void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
850 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *sess) |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
851 { |
26058
ac56e5707a72
Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26040
diff
changeset
|
852 purple_media_end(session->media, NULL, NULL); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
853 } |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
854 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
855 static void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
856 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess) |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
857 { |
26058
ac56e5707a72
Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26040
diff
changeset
|
858 purple_media_end(session->media, NULL, NULL); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
859 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
860 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
861 static void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
862 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
863 { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
864 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
|
865 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
866 if (!strcmp(type, "initiate")) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
867 google_session_handle_initiate(js, session, sess, iq_id); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
868 } else if (!strcmp(type, "accept")) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
869 google_session_handle_accept(js, session, sess, iq_id); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
870 } else if (!strcmp(type, "reject")) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
871 google_session_handle_reject(js, session, sess); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
872 } else if (!strcmp(type, "terminate")) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
873 google_session_handle_terminate(js, session, sess); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
874 } else if (!strcmp(type, "candidates")) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
875 google_session_handle_candidates(js, session, sess, iq_id); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
876 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
877 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
878 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
879 void |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
880 jabber_google_session_parse(JabberStream *js, const char *from, |
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
881 JabberIqType type, const char *iq_id, |
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
882 xmlnode *session_node) |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
883 { |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
884 GoogleSession *session = NULL; |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
885 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
|
886 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
887 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
|
888 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
889 GList *iter = NULL; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
890 |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
891 if (type != JABBER_IQ_SET) |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
892 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
|
893 |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
894 id.id = (gchar*)xmlnode_get_attrib(session_node, "id"); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
895 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
|
896 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
|
897 |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
898 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator"); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
899 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
|
900 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
|
901 |
26524
df9042312063
Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26476
diff
changeset
|
902 iter = purple_media_manager_get_media_by_account( |
df9042312063
Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26476
diff
changeset
|
903 purple_media_manager_get(), |
df9042312063
Switch media to store accounts rather than connections.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26476
diff
changeset
|
904 purple_connection_get_account(js->gc)); |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
905 for (; iter; iter = g_list_delete_link(iter, iter)) { |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
906 GoogleSession *gsession = |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
907 purple_media_get_prpl_data(iter->data); |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
908 if (google_session_id_equal(&(gsession->id), &id)) { |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
909 session = gsession; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
910 break; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
911 } |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
912 } |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
913 if (iter != NULL) { |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
914 g_list_free(iter); |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
915 } |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
916 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
917 if (session) { |
26476
cd1f3a1750a1
And google session handling
Paul Aurich <paul@darkrain42.org>
parents:
26471
diff
changeset
|
918 google_session_parse_iq(js, session, session_node, iq_id); |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
919 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
|
920 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
921 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
922 /* 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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 |
28045
98d8c11e4937
Gracefully handle failures to create an FsStream. This was caused by
maiku@pidgin.im
parents:
28039
diff
changeset
|
935 google_session_handle_initiate(js, session, session_node, iq_id); |
26334
6f0200f1e497
Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26329
diff
changeset
|
936 } |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
937 #endif /* USE_VV */ |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
938 |
18161 | 939 static void |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
940 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:
25979
diff
changeset
|
941 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:
25979
diff
changeset
|
942 xmlnode *packet, gpointer nul) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 xmlnode *child; |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
945 xmlnode *message; |
27328
e01ef82ba0f2
disapproval of revision '7a65a44ab2e57a47d160be267b0f41062f5c540d'
Paul Aurich <paul@darkrain42.org>
parents:
27264
diff
changeset
|
946 const char *to, *url; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 const char *in_str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 char *to_name; |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
949 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 int i, count = 1, returned_count; |
18161 | 951 |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
952 const char **tos, **froms, **urls; |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
953 char **subjects; |
18161 | 954 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
955 if (type == JABBER_IQ_ERROR) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 return; |
18161 | 957 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 child = xmlnode_get_child(packet, "mailbox"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 if (!child) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 in_str = xmlnode_get_attrib(child, "total-matched"); |
18161 | 963 if (in_str && *in_str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 count = atoi(in_str); |
18161 | 965 |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
966 /* 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:
19681
diff
changeset
|
967 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:
19681
diff
changeset
|
968 |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
969 message = xmlnode_get_child(child, "mail-thread-info"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
971 if (count == 0 || !message) { |
25606
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
972 if (count > 0) { |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
973 char *bare_jid = jabber_get_bare_jid(to); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
974 const char *default_tos[2] = { bare_jid }; |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
975 |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
976 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
977 g_free(bare_jid); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
978 } else { |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
979 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, NULL, NULL, NULL, NULL); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
980 } |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
981 |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
982 return; |
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
983 } |
18161 | 984 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 /* 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
|
986 * accordingly */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); |
18161 | 988 |
25606
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
989 froms = g_new0(const char* , returned_count + 1); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
990 tos = g_new0(const char* , returned_count + 1); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
991 subjects = g_new0(char* , returned_count + 1); |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
992 urls = g_new0(const char* , returned_count + 1); |
18161 | 993 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 to = xmlnode_get_attrib(packet, "to"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 to_name = jabber_get_bare_jid(to); |
27328
e01ef82ba0f2
disapproval of revision '7a65a44ab2e57a47d160be267b0f41062f5c540d'
Paul Aurich <paul@darkrain42.org>
parents:
27264
diff
changeset
|
996 url = xmlnode_get_attrib(child, "url"); |
e01ef82ba0f2
disapproval of revision '7a65a44ab2e57a47d160be267b0f41062f5c540d'
Paul Aurich <paul@darkrain42.org>
parents:
27264
diff
changeset
|
997 if (!url || !*url) |
e01ef82ba0f2
disapproval of revision '7a65a44ab2e57a47d160be267b0f41062f5c540d'
Paul Aurich <paul@darkrain42.org>
parents:
27264
diff
changeset
|
998 url = "http://www.gmail.com"; |
18161 | 999 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 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
|
1001 for (i=0; message; message = xmlnode_get_next_twin(message), i++) { |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1002 xmlnode *sender_node, *subject_node; |
27328
e01ef82ba0f2
disapproval of revision '7a65a44ab2e57a47d160be267b0f41062f5c540d'
Paul Aurich <paul@darkrain42.org>
parents:
27264
diff
changeset
|
1003 const char *from, *tid; |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1004 char *subject; |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1005 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 subject_node = xmlnode_get_child(message, "subject"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 sender_node = xmlnode_get_child(message, "senders"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 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
|
1009 |
18161 | 1010 while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") || |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 !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
|
1012 sender_node = xmlnode_get_next_twin(sender_node); |
18161 | 1013 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 if (!sender_node) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 i--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 } |
18161 | 1018 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 from = xmlnode_get_attrib(sender_node, "name"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 if (!from || !*from) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 from = xmlnode_get_attrib(sender_node, "address"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1022 subject = xmlnode_get_data(subject_node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1024 * url = xmlnode_get_attrib(message, "url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1026 tos[i] = (to_name != NULL ? to_name : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 froms[i] = (from != NULL ? from : ""); |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
1028 subjects[i] = (subject != NULL ? subject : g_strdup("")); |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20317
diff
changeset
|
1029 urls[i] = url; |
18161 | 1030 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1031 tid = xmlnode_get_attrib(message, "tid"); |
18161 | 1032 if (tid && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 (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
|
1034 g_free(js->gmail_last_tid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1035 js->gmail_last_tid = g_strdup(tid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1036 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1038 |
18161 | 1039 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
|
1040 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
18161 | 1041 urls, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 g_free(to_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 g_free(tos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 g_free(froms); |
25606
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
1046 for (i = 0; i < returned_count; i++) |
2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
23397
diff
changeset
|
1047 g_free(subjects[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 g_free(subjects); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1049 g_free(urls); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 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
|
1052 if (in_str && *in_str) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 g_free(js->gmail_last_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 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
|
1055 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 |
18161 | 1058 void |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1059 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:
25433
diff
changeset
|
1060 const char *id, xmlnode *new_mail) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 JabberIq *iq; |
18161 | 1064 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 /* bail if the user isn't interested */ |
15822 | 1066 if (!purple_account_get_check_mail(js->gc->account)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 /* Is this an initial incoming mail notification? If so, send a request for more info */ |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1070 if (type != JABBER_IQ_SET) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 |
26839
bb537c36d92f
Ack the mail notification IQ. Refs #8240.
Paul Aurich <paul@darkrain42.org>
parents:
26757
diff
changeset
|
1073 /* Acknowledge the notification */ |
bb537c36d92f
Ack the mail notification IQ. Refs #8240.
Paul Aurich <paul@darkrain42.org>
parents:
26757
diff
changeset
|
1074 iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
26851
edff8cc58d66
Avoid an assertion when acking the gmail poke
Paul Aurich <paul@darkrain42.org>
parents:
26839
diff
changeset
|
1075 if (from) |
edff8cc58d66
Avoid an assertion when acking the gmail poke
Paul Aurich <paul@darkrain42.org>
parents:
26839
diff
changeset
|
1076 xmlnode_set_attrib(iq->node, "to", from); |
26839
bb537c36d92f
Ack the mail notification IQ. Refs #8240.
Paul Aurich <paul@darkrain42.org>
parents:
26757
diff
changeset
|
1077 xmlnode_set_attrib(iq->node, "id", id); |
bb537c36d92f
Ack the mail notification IQ. Refs #8240.
Paul Aurich <paul@darkrain42.org>
parents:
26757
diff
changeset
|
1078 jabber_iq_send(iq); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28435
diff
changeset
|
1080 purple_debug_misc("jabber", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 "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
|
1082 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 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
|
1084 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
|
1085 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 if (js->gmail_last_time) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 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
|
1089 if (js->gmail_last_tid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 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
|
1091 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 void jabber_gmail_init(JabberStream *js) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 JabberIq *iq; |
27253
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1098 xmlnode *usersetting, *mailnotifications; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 |
27253
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1100 if (!purple_account_get_check_mail(purple_connection_get_account(js->gc))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 |
27253
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1103 /* |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1104 * Quoting http://code.google.com/apis/talk/jep_extensions/usersettings.html: |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1105 * To ensure better compatibility with other clients, rather than |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1106 * setting this value to "false" to turn off notifications, it is |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1107 * recommended that a client set this to "true" and filter incoming |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1108 * email notifications itself. |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1109 */ |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1110 iq = jabber_iq_new(js, JABBER_IQ_SET); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1111 usersetting = xmlnode_new_child(iq->node, "usersetting"); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1112 xmlnode_set_namespace(usersetting, "google:setting"); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1113 mailnotifications = xmlnode_new_child(usersetting, "mailnotifications"); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1114 xmlnode_set_attrib(mailnotifications, "value", "true"); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1115 jabber_iq_send(iq); |
beb33c984100
Fix Google Mail notifications when they inexplicably weren't working. Fixes #3300.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
1116 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 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
|
1118 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
|
1119 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 void jabber_google_roster_init(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 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
|
1128 query = xmlnode_get_child(iq->node, "query"); |
18161 | 1129 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 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
|
1131 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 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
|
1137 { |
15822 | 1138 PurpleAccount *account = purple_connection_get_account(js->gc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1139 GSList *list = account->deny; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 const char *jid = xmlnode_get_attrib(item, "jid"); |
27685 | 1141 char *jid_norm = (char *)jabber_normalize(account, jid); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 while (list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 if (!strcmp(jid_norm, (char*)list->data)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); |
27673
19d283331b9d
Fix a small leak and remove a duplicate xmlnode_set_attrib.
Paul Aurich <paul@darkrain42.org>
parents:
27527
diff
changeset
|
1146 xmlnode_set_attrib(query, "gr:ext", "2"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 xmlnode_set_attrib(item, "gr:t", "B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 list = list->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
1154 gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 { |
15822 | 1156 PurpleAccount *account = purple_connection_get_account(js->gc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 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
|
1158 gboolean on_block_list = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 |
20317
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
1160 char *jid_norm; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster"); |
17040
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:
16932
diff
changeset
|
1163 const char *subscription = xmlnode_get_attrib(item, "subscription"); |
28435
54755c2d6836
jabber: Don't ignore Google buddies with subscription="none", but ask="subscribe".
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
1164 const char *ask = xmlnode_get_attrib(item, "ask"); |
18161 | 1165 |
28435
54755c2d6836
jabber: Don't ignore Google buddies with subscription="none", but ask="subscribe".
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
1166 if ((!subscription || !strcmp(subscription, "none")) && !ask) { |
17040
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:
16932
diff
changeset
|
1167 /* 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:
16932
diff
changeset
|
1168 * 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:
16932
diff
changeset
|
1169 */ |
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:
16932
diff
changeset
|
1170 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:
16932
diff
changeset
|
1171 } |
18161 | 1172 |
20317
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
1173 jid_norm = g_strdup(jabber_normalize(account, jid)); |
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
1174 |
27494
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1175 on_block_list = NULL != g_slist_find_custom(account->deny, jid_norm, |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1176 (GCompareFunc)strcmp); |
18161 | 1177 |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
1178 if (grt && (*grt == 'H' || *grt == 'h')) { |
27494
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1179 /* Hidden; don't show this buddy. */ |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1180 GSList *buddies = purple_find_buddies(account, jid_norm); |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1181 if (buddies) |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1182 purple_debug_info("jabber", "Removing %s from local buddy list\n", |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1183 jid_norm); |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1184 |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1185 for ( ; buddies; buddies = g_slist_delete_link(buddies, buddies)) { |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1186 purple_blist_remove_buddy(buddies->data); |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1187 } |
93a41017dca9
Various roster cleanups. Refs #7008.
Paul Aurich <paul@darkrain42.org>
parents:
26998
diff
changeset
|
1188 |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
1189 g_free(jid_norm); |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
1190 return FALSE; |
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
1191 } |
18161 | 1192 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { |
15822 | 1194 purple_debug_info("jabber", "Blocking %s\n", jid_norm); |
1195 purple_privacy_deny_add(account, jid_norm, TRUE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ |
15822 | 1197 purple_debug_info("jabber", "Unblocking %s\n", jid_norm); |
1198 purple_privacy_deny_remove(account, jid_norm, TRUE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 } |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
1200 |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
1201 g_free(jid_norm); |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
1202 return TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 |
18161 | 1205 void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 GSList *buddies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 xmlnode *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 xmlnode *group; |
15822 | 1213 PurpleBuddy *b; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 JabberBuddy *jb; |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1215 const char *balias; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1217 js = (JabberStream*)(gc->proto_data); |
18161 | 1218 |
27442
739f57076303
keep the compiler happy:
Stu Tomlinson <stu@nosnilmot.com>
parents:
27420
diff
changeset
|
1219 if (!js || !(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 jb = jabber_buddy_find(js, who, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 |
15822 | 1224 buddies = purple_find_buddies(js->gc->account, who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 if(!buddies) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 return; |
18161 | 1227 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 b = buddies->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); |
18161 | 1231 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 item = xmlnode_new_child(query, "item"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1234 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 while(buddies) { |
15822 | 1236 PurpleGroup *g; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1238 b = buddies->data; |
15822 | 1239 g = purple_buddy_get_group(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1241 group = xmlnode_new_child(item, "group"); |
25130
16734635febf
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23397
diff
changeset
|
1242 xmlnode_insert_data(group, purple_group_get_name(g), -1); |
18161 | 1243 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1244 buddies = buddies->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1245 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1246 |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1247 balias = purple_buddy_get_local_buddy_alias(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1248 xmlnode_set_attrib(item, "jid", who); |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1249 xmlnode_set_attrib(item, "name", balias ? balias : ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 xmlnode_set_attrib(item, "gr:t", "B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1251 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
|
1252 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1254 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1255 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1256 /* Synthesize a sign-off */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 if (jb) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1258 JabberBuddyResource *jbr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1259 GList *l = jb->resources; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 while (l) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1261 jbr = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 if (jbr && jbr->name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1263 { |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28435
diff
changeset
|
1264 purple_debug_misc("jabber", "Removing resource %s\n", jbr->name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1265 jabber_buddy_remove_resource(jb, jbr->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1267 l = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1268 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1269 } |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28435
diff
changeset
|
1270 |
15822 | 1271 purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1272 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1273 |
15822 | 1274 void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1275 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1276 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1277 GSList *buddies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1278 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1279 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1280 xmlnode *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1281 xmlnode *group; |
15822 | 1282 PurpleBuddy *b; |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1283 const char *balias; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 g_return_if_fail(gc != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1286 g_return_if_fail(who != NULL); |
18161 | 1287 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 js = (JabberStream*)(gc->proto_data); |
18161 | 1289 |
27442
739f57076303
keep the compiler happy:
Stu Tomlinson <stu@nosnilmot.com>
parents:
27420
diff
changeset
|
1290 if (!js || !(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 return; |
18161 | 1292 |
25795
ede22bc33d56
More struct hiding work
Richard Laager <rlaager@wiktel.com>
parents:
23397
diff
changeset
|
1293 buddies = purple_find_buddies(purple_connection_get_account(js->gc), who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 if(!buddies) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 return; |
18161 | 1296 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1297 b = buddies->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1299 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); |
18161 | 1300 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1301 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1302 item = xmlnode_new_child(query, "item"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1303 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1304 while(buddies) { |
15822 | 1305 PurpleGroup *g; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 b = buddies->data; |
15822 | 1308 g = purple_buddy_get_group(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1310 group = xmlnode_new_child(item, "group"); |
25130
16734635febf
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23397
diff
changeset
|
1311 xmlnode_insert_data(group, purple_group_get_name(g), -1); |
18161 | 1312 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1313 buddies = buddies->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1314 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1315 |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1316 balias = purple_buddy_get_local_buddy_alias(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1317 xmlnode_set_attrib(item, "jid", who); |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
1318 xmlnode_set_attrib(item, "name", balias ? balias : ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1319 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
|
1320 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1321 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1322 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1324 /* See if he's online */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1325 jabber_presence_subscription_set(js, who, "probe"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1326 } |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1327 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1328 /* 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:
15466
diff
changeset
|
1329 * 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:
15466
diff
changeset
|
1330 * 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:
15466
diff
changeset
|
1331 * 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:
15466
diff
changeset
|
1332 * 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:
15466
diff
changeset
|
1333 */ |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1334 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:
15466
diff
changeset
|
1335 { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1336 const char *p; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1337 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1338 /* 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:
15466
diff
changeset
|
1339 gboolean preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1340 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1341 gboolean in_bold = FALSE, in_italic = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1342 gboolean in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1343 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1344 gint bold_count = 0, italic_count = 0; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1345 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1346 GString *str; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1347 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1348 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:
15466
diff
changeset
|
1349 gunichar c = g_utf8_get_char(p); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1350 if (c == '*' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1351 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:
15466
diff
changeset
|
1352 *(p+1) == '\0' || |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1353 *(p+1) == '<')) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1354 bold_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1355 in_bold = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
1356 } else if (preceding_space && !in_bold && !g_unichar_isspace(*(p+1))) { |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1357 bold_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1358 in_bold = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1359 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1360 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1361 } else if (c == '_' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1362 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:
15466
diff
changeset
|
1363 *(p+1) == '\0' || |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1364 *(p+1) == '<')) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1365 italic_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1366 in_italic = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
1367 } else if (preceding_space && !in_italic && !g_unichar_isspace(*(p+1))) { |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1368 italic_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1369 in_italic = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1370 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1371 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1372 } else if (c == '<' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1373 in_tag = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1374 } else if (c == '>' && in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1375 in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1376 } else if (!in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1377 if (g_unichar_isspace(c)) |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1378 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1379 else |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1380 preceding_space = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1381 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1382 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1383 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1384 str = g_string_new(NULL); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1385 in_bold = in_italic = in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1386 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1387 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1388 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:
15466
diff
changeset
|
1389 gunichar c = g_utf8_get_char(p); |
18161 | 1390 |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1391 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:
15466
diff
changeset
|
1392 g_string_append(str, p); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1393 return g_string_free(str, FALSE); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1394 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1395 |
18161 | 1396 |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1397 if (c == '*' && !in_tag) { |
18161 | 1398 if (in_bold && |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1399 (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:
15466
diff
changeset
|
1400 str = g_string_append(str, "</b>"); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1401 in_bold = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1402 bold_count--; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
1403 } else if (preceding_space && bold_count > 1 && !g_unichar_isspace(*(p+1))) { |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1404 str = g_string_append(str, "<b>"); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1405 bold_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1406 in_bold = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1407 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1408 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1409 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1410 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1411 } else if (c == '_' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1412 if (in_italic && |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1413 (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1414 str = g_string_append(str, "</i>"); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1415 italic_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1416 in_italic = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
1417 } else if (preceding_space && italic_count > 1 && !g_unichar_isspace(*(p+1))) { |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1418 str = g_string_append(str, "<i>"); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1419 italic_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1420 in_italic = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1421 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1422 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1423 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1424 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1425 } else if (c == '<' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1426 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1427 in_tag = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1428 } else if (c == '>' && in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1429 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1430 in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1431 } else if (!in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1432 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1433 if (g_unichar_isspace(c)) |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1434 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1435 else |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1436 preceding_space = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1437 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1438 str = g_string_append_unichar(str, c); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1439 } |
18161 | 1440 } |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1441 return g_string_free(str, FALSE); |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1442 } |
20571
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1443 |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1444 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
|
1445 { |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1446 if (!js->googletalk) |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1447 return; |
27486
834236111afc
We have a convenience function to do this. Also, plug a leak of the status
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27442
diff
changeset
|
1448 if (jbr->status && purple_str_has_prefix(jbr->status, "♫ ")) { |
20571
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1449 purple_prpl_got_user_status(js->gc->account, user, "tune", |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1450 PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL); |
27486
834236111afc
We have a convenience function to do this. Also, plug a leak of the status
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27442
diff
changeset
|
1451 g_free(jbr->status); |
20571
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1452 jbr->status = NULL; |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1453 } else { |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1454 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
|
1455 } |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1456 } |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1457 |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1458 char *jabber_google_presence_outgoing(PurpleStatus *tune) |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1459 { |
21634
1853d9d0cc65
don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents:
21220
diff
changeset
|
1460 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
|
1461 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
|
1462 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1463 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1464 static void |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1465 jabber_google_stun_lookup_cb(GSList *hosts, gpointer data, |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1466 const char *error_message) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1467 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1468 JabberStream *js = (JabberStream *) data; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1469 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1470 if (error_message) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1471 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:
26058
diff
changeset
|
1472 error_message); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1473 g_slist_free(hosts); |
28038
76c0969e3ea7
jabber: Unset the PurpleDnsQueryData when a query fails. Refs #9274.
Paul Aurich <paul@darkrain42.org>
parents:
27799
diff
changeset
|
1474 js->stun_query = NULL; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1475 return; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1476 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1477 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1478 if (hosts && g_slist_next(hosts)) { |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1479 struct sockaddr *addr = g_slist_next(hosts)->data; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1480 char dst[INET6_ADDRSTRLEN]; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1481 int port; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1482 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1483 if (addr->sa_family == AF_INET6) { |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1484 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1485 dst, sizeof(dst)); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1486 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:
26058
diff
changeset
|
1487 } else { |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1488 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1489 dst, sizeof(dst)); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1490 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:
26058
diff
changeset
|
1491 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1492 |
28039
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1493 if (js->stun_ip) |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1494 g_free(js->stun_ip); |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1495 js->stun_ip = g_strdup(dst); |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1496 js->stun_port = port; |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1497 |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1498 purple_debug_info("jabber", "set Google STUN IP/port address: " |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1499 "%s:%d\n", dst, port); |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1500 |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1501 /* unmark ongoing query */ |
ed30bc20442c
jabber: Simplify; js is the callback data and can't be NULL.
Paul Aurich <paul@darkrain42.org>
parents:
28038
diff
changeset
|
1502 js->stun_query = NULL; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1503 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1504 |
26551
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1505 while (hosts != NULL) { |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1506 hosts = g_slist_delete_link(hosts, hosts); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1507 /* Free the address */ |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1508 g_free(hosts->data); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1509 hosts = g_slist_delete_link(hosts, hosts); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26524
diff
changeset
|
1510 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1511 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1512 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1513 static void |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1514 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:
26470
diff
changeset
|
1515 JabberIqType type, xmlnode *query) |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1516 { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1517 const xmlnode *stun = xmlnode_get_child(query, "stun"); |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1518 const xmlnode *relay = xmlnode_get_child(query, "relay"); |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1519 gchar *my_bare_jid; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1520 |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1521 /* |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1522 * 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:
26470
diff
changeset
|
1523 * 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:
26470
diff
changeset
|
1524 * stanzas are stamped from our bare JID. |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1525 */ |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1526 if (from) { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1527 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:
26470
diff
changeset
|
1528 if (!purple_strequal(from, my_bare_jid)) { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1529 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:
26470
diff
changeset
|
1530 from); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1531 g_free(my_bare_jid); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1532 return; |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1533 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1534 |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1535 g_free(my_bare_jid); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1536 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1537 |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1538 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:
26470
diff
changeset
|
1539 return; |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1540 |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1541 purple_debug_info("jabber", "got google:jingleinfo\n"); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1542 |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1543 if (stun) { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1544 xmlnode *server = xmlnode_get_child(stun, "server"); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1545 |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1546 if (server) { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1547 const gchar *host = xmlnode_get_attrib(server, "host"); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1548 const gchar *udp = xmlnode_get_attrib(server, "udp"); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1549 |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1550 if (host && udp) { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1551 int port = atoi(udp); |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1552 /* if there, would already be an ongoing query, |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1553 cancel it */ |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1554 if (js->stun_query) |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1555 purple_dnsquery_destroy(js->stun_query); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1556 |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1557 js->stun_query = purple_dnsquery_a(host, port, |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1558 jabber_google_stun_lookup_cb, js); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1559 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1560 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1561 } |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1562 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1563 if (relay) { |
30498
794001c22306
Can now sucessfully request relay info through HTTP
Marcus Lundblad <ml@update.uu.se>
parents:
30493
diff
changeset
|
1564 xmlnode *token = xmlnode_get_child(relay, "token"); |
794001c22306
Can now sucessfully request relay info through HTTP
Marcus Lundblad <ml@update.uu.se>
parents:
30493
diff
changeset
|
1565 xmlnode *server = xmlnode_get_child(relay, "server"); |
30493
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1566 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1567 if (token) { |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1568 gchar *relay_token = xmlnode_get_data(token); |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1569 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1570 /* we let js own the string returned from xmlnode_get_data */ |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1571 js->google_relay_token = relay_token; |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1572 } |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1573 |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1574 if (server) { |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1575 js->google_relay_host = |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1576 g_strdup(xmlnode_get_attrib(server, "host")); |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1577 } |
196e4c5b2043
Some unfinished code to take advantage of Google's relays
Marcus Lundblad <ml@update.uu.se>
parents:
28089
diff
changeset
|
1578 } |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1579 } |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1580 |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1581 static void |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1582 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:
26470
diff
changeset
|
1583 JabberIqType type, const char *id, |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1584 xmlnode *packet, gpointer data) |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1585 { |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1586 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:
26470
diff
changeset
|
1587 GOOGLE_JINGLE_INFO_NAMESPACE); |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1588 |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1589 if (query) |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1590 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:
26470
diff
changeset
|
1591 else |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1592 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1593 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1594 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1595 void |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1596 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:
26470
diff
changeset
|
1597 JabberIqType type, const char *id, |
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1598 xmlnode *child) |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1599 { |
26471
91583903b478
Migrate googleinfo:jabber handlers and add some safety checks.
Paul Aurich <paul@darkrain42.org>
parents:
26470
diff
changeset
|
1600 jabber_google_jingle_info_common(js, from, type, child); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1601 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1602 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1603 void |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1604 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:
26058
diff
changeset
|
1605 { |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26860
diff
changeset
|
1606 JabberIq *jingle_info = |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1607 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:
26058
diff
changeset
|
1608 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1609 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:
26058
diff
changeset
|
1610 NULL); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1611 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:
26058
diff
changeset
|
1612 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:
26058
diff
changeset
|
1613 } |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1614 |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1615 void google_buddy_node_chat(PurpleBlistNode *node, gpointer data) |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1616 { |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1617 PurpleBuddy *buddy; |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1618 PurpleConnection *gc; |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1619 JabberStream *js; |
28373
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1620 JabberChat *chat; |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1621 gchar *room; |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1622 guint32 tmp, a, b; |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1623 |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1624 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1625 |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1626 buddy = PURPLE_BUDDY(node); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1627 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
28373
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1628 g_return_if_fail(gc != NULL); |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1629 js = purple_connection_get_protocol_data(gc); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1630 |
28373
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1631 /* Generate a version 4 UUID */ |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1632 tmp = g_random_int(); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1633 a = 0x4000 | (tmp & 0xFFF); /* 0x4000 to 0x4FFF */ |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1634 tmp >>= 12; |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1635 b = ((1 << 3) << 12) | (tmp & 0x3FFF); /* 0x8000 to 0xBFFF */ |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1636 |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1637 tmp = g_random_int(); |
28373
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1638 room = g_strdup_printf("private-chat-%08x-%04x-%04x-%04x-%04x%08x", |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1639 g_random_int(), |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1640 tmp & 0xFFFF, |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1641 a, |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1642 b, |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1643 (tmp >> 16) & 0xFFFF, g_random_int()); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1644 |
28373
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1645 chat = jabber_join_chat(js, room, GOOGLE_GROUPCHAT_SERVER, js->user->node, |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1646 NULL, NULL); |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1647 if (chat) { |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1648 chat->muc = TRUE; |
63dc67b32577
jabber: Use the newly refactored code to simplify "Initiate Chat".
Paul Aurich <paul@darkrain42.org>
parents:
28371
diff
changeset
|
1649 jabber_chat_invite(gc, chat->id, "", buddy->name); |
28371
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1650 } |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1651 |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1652 g_free(room); |
51d507e6c8f3
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
eion@robbmob.com
parents:
28360
diff
changeset
|
1653 } |