Mercurial > pidgin
annotate libpurple/protocols/jabber/google.c @ 26131:ff4212a5268f
propagate from branch 'im.pidgin.pidgin' (head 431618de0f30a6938f7e14d2d61ee5d7738acd59)
to branch 'im.pidgin.pidgin.vv' (head 8df00cb1a28baa69d0a68e0e96af201ec7d87c09)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 02 Mar 2009 18:47:27 +0000 |
parents | 8aa7d8bcbc7d a773b465935e |
children | 2ad89aff8d68 |
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" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
35 #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
|
36 |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
37 #ifdef USE_VV |
23800
4b9b265a8100
Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23797
diff
changeset
|
38 |
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
|
39 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
|
40 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
|
41 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
|
42 } 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
|
43 |
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 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 } 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
|
51 |
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 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
|
53 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
|
54 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
|
55 PurpleMedia *media; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
56 JabberStream *js; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
57 char *remote_jid; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
58 } 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
|
59 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
60 static gboolean |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
61 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
|
62 { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
63 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
|
64 GoogleSessionId *d = (GoogleSessionId*)b; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
65 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
66 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
|
67 } |
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 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
69 static void |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
70 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
|
71 { |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
72 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
|
73 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
|
74 g_free(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
|
75 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
|
76 } |
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
|
77 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
78 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
|
79 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
|
80 { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
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 |
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 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
|
90 google_session_send_terminate(GoogleSession *session) |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
91 { |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
92 xmlnode *sess; |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
93 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
94 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
95 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
96 sess = google_session_create_xmlnode(session, "terminate"); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
97 xmlnode_insert_child(iq->node, sess); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
98 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
99 jabber_iq_send(iq); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
100 google_session_destroy(session); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
101 } |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
102 |
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
|
103 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
|
104 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
|
105 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
|
106 { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
107 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
23821
12a16471f94e
Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23804
diff
changeset
|
108 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice", |
12a16471f94e
Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23804
diff
changeset
|
109 session->remote_jid); |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
110 PurpleMediaCandidate *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
|
111 xmlnode *sess; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
112 xmlnode *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
|
113 sess = google_session_create_xmlnode(session, "candidates"); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
114 xmlnode_insert_child(iq->node, sess); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
115 xmlnode_set_attrib(iq->node, "to", session->remote_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
|
116 |
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
|
117 for (;candidates;candidates = candidates->next) { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
118 char port[8]; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
119 char pref[8]; |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
120 transport = (PurpleMediaCandidate*)(candidates->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
|
121 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
122 if (!strcmp(transport->ip, "127.0.0.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
|
123 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
|
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 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
127 g_snprintf(port, sizeof(port), "%d", transport->port); |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
128 g_snprintf(pref, sizeof(pref), "%d", transport->priority); |
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
|
129 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
130 xmlnode_set_attrib(candidate, "address", transport->ip); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
131 xmlnode_set_attrib(candidate, "port", port); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
132 xmlnode_set_attrib(candidate, "name", "rtp"); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
133 xmlnode_set_attrib(candidate, "username", transport->username); |
25001
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
134 /* |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
135 * 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
|
136 * 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
|
137 * requires this to be set. |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
138 */ |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
139 xmlnode_set_attrib(candidate, "password", |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
140 transport->password != NULL ? |
2a1873a30474
Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24999
diff
changeset
|
141 transport->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
|
142 xmlnode_set_attrib(candidate, "preference", pref); |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
143 xmlnode_set_attrib(candidate, "protocol", transport->proto == |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
144 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? "udp" : "tcp"); |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
145 xmlnode_set_attrib(candidate, "type", transport->type == |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
146 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" : |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
147 transport->type == |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
148 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" : |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
149 transport->type == |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
150 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : 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
|
151 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
|
152 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
|
153 xmlnode_insert_child(sess, 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
|
154 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
155 jabber_iq_send(iq); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
156 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
157 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
158 static void |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
159 google_session_ready(PurpleMedia *media, gchar *id, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
160 gchar *participant, GoogleSession *session) |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
161 { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
162 if (id == NULL && participant == NULL) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
163 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
|
164 session->js->user->node, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
165 session->js->user->domain, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
166 session->js->user->resource); |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
167 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
168 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
|
169 GList *codecs, *iter; |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
170 |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
171 if (!strcmp(session->id.initiator, me)) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 } else { |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
176 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
|
177 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
|
178 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
|
179 } |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
180 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
|
181 desc = xmlnode_new_child(sess, "description"); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
182 xmlnode_set_namespace(desc, "http://www.google.com/session/phone"); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
183 |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
184 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
|
185 |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
186 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
|
187 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
188 gchar *id = g_strdup_printf("%d", codec->id); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
189 gchar *clock_rate = g_strdup_printf("%d", codec->clock_rate); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
190 payload = xmlnode_new_child(desc, "payload-type"); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
191 xmlnode_set_attrib(payload, "id", id); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
192 xmlnode_set_attrib(payload, "name", codec->encoding_name); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
193 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
|
194 g_free(clock_rate); |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
195 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
|
196 } |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
197 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
|
198 |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
199 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
|
200 |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
201 google_session_send_candidates(session->media, |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
202 "google-voice", session->remote_jid, session); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
203 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
204 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
205 |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
206 static void |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
207 google_session_state_changed_cb(PurpleMedia *media, |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
208 PurpleMediaStateChangedType type, |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
209 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
|
210 { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
211 if (sid == NULL && name == NULL) { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
212 if (type == PURPLE_MEDIA_STATE_CHANGED_END) { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
213 google_session_destroy(session); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
214 } else if (type == PURPLE_MEDIA_STATE_CHANGED_HANGUP) { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
215 xmlnode *sess; |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
216 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
217 |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
218 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
219 sess = google_session_create_xmlnode(session, "terminate"); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
220 xmlnode_insert_child(iq->node, sess); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
221 |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
222 jabber_iq_send(iq); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
223 } else if (type == PURPLE_MEDIA_STATE_CHANGED_REJECTED) { |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
224 xmlnode *sess; |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
225 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
226 |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
227 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
228 sess = google_session_create_xmlnode(session, "reject"); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
229 xmlnode_insert_child(iq->node, sess); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
230 |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
231 jabber_iq_send(iq); |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
232 } |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
233 |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
234 } |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
235 } |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
236 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
237 static GParameter * |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
238 jabber_google_session_get_params(JabberStream *js, guint *num) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
239 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
240 guint 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
|
241 GParameter *params = jingle_get_params(js, &num_params); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
242 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
|
243 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
244 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
|
245 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 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
|
250 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
251 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
|
252 *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
|
253 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
|
254 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
255 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
256 |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
257 PurpleMedia* |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
258 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type) |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
259 { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
260 GoogleSession *session; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
261 JabberBuddy *jb; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
262 JabberBuddyResource *jbr; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
263 gchar *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
|
264 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
|
265 guint num_params; |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
266 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
267 /* construct JID to send to */ |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
268 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
|
269 if (!jb) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
270 purple_debug_error("jingle-rtp", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
271 "Could not find Jabber buddy\n"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
272 return NULL; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
273 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
274 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
|
275 if (!jbr) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
276 purple_debug_error("jingle-rtp", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
277 "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
|
278 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
279 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
280 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
|
281 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
|
282 } else { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
283 jid = g_strdup(who); |
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 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
286 session = g_new0(GoogleSession, 1); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
287 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
|
288 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
|
289 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
|
290 session->state = SENT_INITIATE; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
291 session->js = js; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
292 session->remote_jid = jid; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
293 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
294 session->media = purple_media_manager_create_media( |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
295 purple_media_manager_get(), js->gc, |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
296 "fsrtpconference", session->remote_jid, TRUE); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
297 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
298 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
|
299 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
300 params = jabber_google_session_get_params(js, &num_params); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
301 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
302 if (purple_media_add_stream(session->media, "google-voice", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
303 session->remote_jid, PURPLE_MEDIA_AUDIO, |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
304 "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
|
305 purple_media_error(session->media, "Error adding stream."); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
306 purple_media_hangup(session->media); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
307 google_session_destroy(session); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
308 g_free(params); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
309 return NULL; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
310 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
311 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
312 g_signal_connect(G_OBJECT(session->media), "ready-new", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
313 G_CALLBACK(google_session_ready), session); |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
314 g_signal_connect(G_OBJECT(session->media), "state-changed", |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
315 G_CALLBACK(google_session_state_changed_cb), session); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
316 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
317 g_free(params); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
318 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
319 return session->media; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
320 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
321 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
322 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
|
323 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *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
|
324 { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
325 JabberIq *result; |
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
|
326 GList *codecs = NULL; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
327 xmlnode *desc_element, *codec_element; |
26024
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
328 PurpleMediaCodec *codec; |
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
|
329 const char *id, *encoding_name, *clock_rate; |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
330 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
|
331 guint 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
|
332 |
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
|
333 if (session->state != UNINIT) { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
334 purple_debug_error("jabber", "Received initiate for active session.\n"); |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
335 return; |
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
|
336 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
337 |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
338 session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc, |
24987
c7d4b67b3332
Add initiator property to PurpleMedia.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24964
diff
changeset
|
339 "fsrtpconference", session->remote_jid, FALSE); |
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
|
340 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
341 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
|
342 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
343 params = jabber_google_session_get_params(js, &num_params); |
24964
0101d6e97f12
Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24960
diff
changeset
|
344 |
24999
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
345 if (purple_media_add_stream(session->media, "google-voice", session->remote_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
|
346 PURPLE_MEDIA_AUDIO, "nice", num_params, params) == FALSE) { |
24999
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
347 purple_media_error(session->media, "Error adding stream."); |
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
348 purple_media_hangup(session->media); |
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
349 google_session_send_terminate(session); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
350 g_free(params); |
24999
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
351 return; |
f45301cc2c84
End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24987
diff
changeset
|
352 } |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
353 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
354 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
|
355 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
356 desc_element = xmlnode_get_child(sess, "description"); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
357 |
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
|
358 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
359 codec_element; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
360 codec_element = xmlnode_get_next_twin(codec_element)) { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
361 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
|
362 id = xmlnode_get_attrib(codec_element, "id"); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
363 clock_rate = xmlnode_get_attrib(codec_element, "clockrate"); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
364 |
26024
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
365 codec = purple_media_codec_new(atoi(id), encoding_name, PURPLE_MEDIA_AUDIO, |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
366 clock_rate ? atoi(clock_rate) : 0); |
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
|
367 codecs = g_list_append(codecs, codec); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
368 } |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
369 |
23821
12a16471f94e
Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23804
diff
changeset
|
370 purple_media_set_remote_codecs(session->media, "google-voice", session->remote_jid, codecs); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
371 |
26031
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
372 g_signal_connect(G_OBJECT(session->media), "ready-new", |
7bbac147f276
Convert the GTalk code to completely use the new ready signal.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26030
diff
changeset
|
373 G_CALLBACK(google_session_ready), session); |
26030
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
374 g_signal_connect(G_OBJECT(session->media), "state-changed", |
027ce238eb40
Use the state-changed signal in GTalk code.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26024
diff
changeset
|
375 G_CALLBACK(google_session_state_changed_cb), 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
|
376 |
26024
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
377 purple_media_codec_list_free(codecs); |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
378 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
379 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
380 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
381 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
|
382 jabber_iq_send(result); |
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
|
383 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
384 |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
385 static void |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
386 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *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
|
387 { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
388 JabberIq *result; |
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
|
389 GList *list = NULL; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
390 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
|
391 static int name = 0; |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
392 char n[4]; |
23787
92e71f6e10d4
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23769
diff
changeset
|
393 |
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
|
394 for (cand = xmlnode_get_child(sess, "candidate"); cand; 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
|
395 PurpleMediaCandidate *info; |
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
|
396 g_snprintf(n, sizeof(n), "S%d", name++); |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
397 info = purple_media_candidate_new(n, PURPLE_MEDIA_COMPONENT_RTP, |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
398 !strcmp(xmlnode_get_attrib(cand, "type"), "local") ? |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
399 PURPLE_MEDIA_CANDIDATE_TYPE_HOST : |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
400 !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ? |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
401 PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX : |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
402 !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ? |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
403 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY : |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
404 PURPLE_MEDIA_CANDIDATE_TYPE_HOST, |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
405 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ? |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
406 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
|
407 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP, |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
408 xmlnode_get_attrib(cand, "address"), |
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
409 atoi(xmlnode_get_attrib(cand, "port"))); |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
410 |
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
411 info->username = g_strdup(xmlnode_get_attrib(cand, "username")); |
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
412 info->password = g_strdup(xmlnode_get_attrib(cand, "password")); |
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
413 |
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
|
414 list = g_list_append(list, info); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
415 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
416 |
23821
12a16471f94e
Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23804
diff
changeset
|
417 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list); |
26021
f7cf50180e1d
Duplicate FsCandidate to remove it from the public interface.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26011
diff
changeset
|
418 purple_media_candidate_list_free(list); |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
419 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
420 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
421 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
422 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
|
423 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
|
424 } |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
425 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
426 static void |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
427 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess) |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
428 { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
429 xmlnode *desc_element = xmlnode_get_child(sess, "description"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
430 xmlnode *codec_element = xmlnode_get_child(desc_element, "payload-type"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
431 GList *codecs = NULL; |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
432 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
433 for (; codec_element; codec_element = |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
434 xmlnode_get_next_twin(codec_element)) { |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
435 const gchar *encoding_name = |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
436 xmlnode_get_attrib(codec_element, "name"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
437 const gchar *id = xmlnode_get_attrib(codec_element, "id"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
438 const gchar *clock_rate = |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
439 xmlnode_get_attrib(codec_element, "clockrate"); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
440 |
26024
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
441 PurpleMediaCodec *codec = purple_media_codec_new(atoi(id), |
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
442 encoding_name, PURPLE_MEDIA_AUDIO, |
ac4d7695dbc7
Wrap FsCodec and remove the Farsight2 include from media.h.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26021
diff
changeset
|
443 clock_rate ? atoi(clock_rate) : 0); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
444 codecs = g_list_append(codecs, codec); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
445 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
446 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
447 purple_media_set_remote_codecs(session->media, "google-voice", |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
448 session->remote_jid, codecs); |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
449 |
26040
5d9a97a23d6e
Remove some of the deprecated API.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26031
diff
changeset
|
450 purple_media_accept(session->media); |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
451 } |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
452 |
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
453 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
|
454 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess) |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
455 { |
26058
ac56e5707a72
Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26040
diff
changeset
|
456 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
|
457 } |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
458 |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
459 static void |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
460 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess) |
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
461 { |
26058
ac56e5707a72
Added purple_media_end and removed the purple_media_got_hangup.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26040
diff
changeset
|
462 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
|
463 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
464 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
465 static void |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
466 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *packet) |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
467 { |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
468 xmlnode *sess = xmlnode_get_child(packet, "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
|
469 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
|
470 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
471 if (!strcmp(type, "initiate")) { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
472 google_session_handle_initiate(js, session, packet, 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
|
473 } else if (!strcmp(type, "accept")) { |
25005
44a528094cbf
Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
25001
diff
changeset
|
474 google_session_handle_accept(js, session, packet, 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
|
475 } else if (!strcmp(type, "reject")) { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
476 google_session_handle_reject(js, session, packet, 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
|
477 } else if (!strcmp(type, "terminate")) { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
478 google_session_handle_terminate(js, session, packet, 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
|
479 } else if (!strcmp(type, "candidates")) { |
23762
70cdff43ec76
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents:
23759
diff
changeset
|
480 google_session_handle_candidates(js, session, packet, 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
|
481 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
482 } |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
483 #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
|
484 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
485 void |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
486 jabber_google_session_parse(JabberStream *js, xmlnode *packet) |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
487 { |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
488 #ifdef USE_VV |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
489 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
|
490 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
|
491 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
492 xmlnode *session_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
|
493 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
|
494 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
495 GList *iter = NULL; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
496 |
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
|
497 if (strcmp(xmlnode_get_attrib(packet, "type"), "set")) |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
498 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
|
499 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
500 session_node = xmlnode_get_child(packet, "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
|
501 if (!session_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
|
502 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
|
503 |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 |
23797
e1c8ec1259de
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23787
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 |
26125
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
512 iter = purple_media_manager_get_media_by_connection( |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
513 purple_media_manager_get(), js->gc); |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
514 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
|
515 GoogleSession *gsession = |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
516 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
|
517 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
|
518 session = gsession; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
519 break; |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
520 } |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
521 } |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
522 if (iter != NULL) { |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
523 g_list_free(iter); |
a773b465935e
Remove static sessions variable from google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
524 } |
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
|
525 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
526 if (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
|
527 google_session_parse_iq(js, session, packet); |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
528 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
|
529 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
530 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
531 /* 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
544 google_session_parse_iq(js, session, packet); |
23800
4b9b265a8100
Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23797
diff
changeset
|
545 #else |
4b9b265a8100
Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23797
diff
changeset
|
546 /* TODO: send proper error response */ |
23804
cbe97caec684
Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23800
diff
changeset
|
547 #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
|
548 } |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18751
diff
changeset
|
549 |
18161 | 550 static void |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 const char *type = xmlnode_get_attrib(packet, "type"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 xmlnode *child; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 xmlnode *message, *sender_node, *subject_node; |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
556 const char *from, *to, *url, *tid; |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
557 char *subject; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 const char *in_str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 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
|
560 char *default_tos[1]; |
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
561 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 int i, count = 1, returned_count; |
18161 | 563 |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
564 const char **tos, **froms, **urls; |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
565 char **subjects; |
18161 | 566 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 if (strcmp(type, "result")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 return; |
18161 | 569 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 child = xmlnode_get_child(packet, "mailbox"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 if (!child) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 in_str = xmlnode_get_attrib(child, "total-matched"); |
18161 | 575 if (in_str && *in_str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 count = atoi(in_str); |
18161 | 577 |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
578 /* 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
|
579 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
|
580 default_tos[0] = jabber_get_bare_jid(to); |
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
581 |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
582 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
|
583 |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
584 if (count == 0 || !message) { |
20281
d41907afb521
Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents:
20218
diff
changeset
|
585 if (count > 0) |
d41907afb521
Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents:
20218
diff
changeset
|
586 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
587 g_free(default_tos[0]); |
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
588 return; |
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
589 } |
18161 | 590 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 /* 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
|
592 * accordingly */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); |
18161 | 594 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 froms = g_new0(const char* , returned_count); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 tos = g_new0(const char* , returned_count); |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
597 subjects = g_new0(char* , returned_count); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 urls = g_new0(const char* , returned_count); |
18161 | 599 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 to = xmlnode_get_attrib(packet, "to"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 to_name = jabber_get_bare_jid(to); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 url = xmlnode_get_attrib(child, "url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 if (!url || !*url) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 url = "http://www.gmail.com"; |
18161 | 605 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 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
|
607 for (i=0; message; message = xmlnode_get_next_twin(message), i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 subject_node = xmlnode_get_child(message, "subject"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 sender_node = xmlnode_get_child(message, "senders"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 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
|
611 |
18161 | 612 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
|
613 !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
|
614 sender_node = xmlnode_get_next_twin(sender_node); |
18161 | 615 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 if (!sender_node) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 i--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 } |
18161 | 620 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 from = xmlnode_get_attrib(sender_node, "name"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 if (!from || !*from) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 from = xmlnode_get_attrib(sender_node, "address"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 subject = xmlnode_get_data(subject_node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 * url = xmlnode_get_attrib(message, "url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 tos[i] = (to_name != NULL ? to_name : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 froms[i] = (from != NULL ? from : ""); |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
630 subjects[i] = (subject != NULL ? subject : g_strdup("")); |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20317
diff
changeset
|
631 urls[i] = url; |
18161 | 632 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 tid = xmlnode_get_attrib(message, "tid"); |
18161 | 634 if (tid && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 (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
|
636 g_free(js->gmail_last_tid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 js->gmail_last_tid = g_strdup(tid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 |
18161 | 641 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
|
642 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
18161 | 643 urls, NULL, NULL); |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
644 else |
20211
a5d366d614f5
applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@wiktel.com>
parents:
20169
diff
changeset
|
645 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
646 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 g_free(to_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 g_free(tos); |
20169
575d8c84ccba
Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
650 g_free(default_tos[0]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 g_free(froms); |
18751
0580b246b2c5
Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18492
diff
changeset
|
652 for (; i > 0; i--) |
0580b246b2c5
Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18492
diff
changeset
|
653 g_free(subjects[i - 1]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 g_free(subjects); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 g_free(urls); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 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
|
658 if (in_str && *in_str) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 g_free(js->gmail_last_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 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
|
661 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 |
18161 | 664 void |
665 jabber_gmail_poke(JabberStream *js, xmlnode *packet) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 const char *type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 JabberIq *iq; |
18161 | 670 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 /* bail if the user isn't interested */ |
15822 | 672 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
|
673 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 type = xmlnode_get_attrib(packet, "type"); |
18161 | 676 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 /* Is this an initial incoming mail notification? If so, send a request for more info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 |
15822 | 682 purple_debug(PURPLE_DEBUG_MISC, "jabber", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 "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
|
684 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 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
|
686 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
|
687 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 if (js->gmail_last_time) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 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
|
691 if (js->gmail_last_tid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 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
|
693 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 void jabber_gmail_init(JabberStream *js) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 |
18161 | 701 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
|
702 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 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
|
705 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
|
706 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 void jabber_google_roster_init(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 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
|
715 query = xmlnode_get_child(iq->node, "query"); |
18161 | 716 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 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
|
718 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 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
|
724 { |
15822 | 725 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
|
726 GSList *list = account->deny; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 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
|
728 char *jid_norm = g_strdup(jabber_normalize(account, jid)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 while (list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 if (!strcmp(jid_norm, (char*)list->data)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 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
|
733 xmlnode_set_attrib(item, "gr:t", "B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 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
|
735 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
736 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 list = list->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
741 g_free(jid_norm); |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
742 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
745 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
|
746 { |
15822 | 747 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
|
748 GSList *list = account->deny; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 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
|
750 gboolean on_block_list = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 |
20317
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
752 char *jid_norm; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 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
|
755 const char *subscription = xmlnode_get_attrib(item, "subscription"); |
18161 | 756 |
17235 | 757 if (!subscription || !strcmp(subscription, "none")) { |
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
|
758 /* 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
|
759 * 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
|
760 */ |
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
|
761 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
|
762 } |
18161 | 763 |
20317
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
764 jid_norm = g_strdup(jabber_normalize(account, jid)); |
ac46ffeb5b2b
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20281
diff
changeset
|
765 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 while (list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 if (!strcmp(jid_norm, (char*)list->data)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 on_block_list = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 list = list->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 } |
18161 | 773 |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
774 if (grt && (*grt == 'H' || *grt == 'h')) { |
15822 | 775 PurpleBuddy *buddy = purple_find_buddy(account, jid_norm); |
20218
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
776 if (buddy) |
99ceb1329a5b
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents:
20211
diff
changeset
|
777 purple_blist_remove_buddy(buddy); |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
778 g_free(jid_norm); |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
779 return FALSE; |
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
780 } |
18161 | 781 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { |
15822 | 783 purple_debug_info("jabber", "Blocking %s\n", jid_norm); |
784 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
|
785 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ |
15822 | 786 purple_debug_info("jabber", "Unblocking %s\n", jid_norm); |
787 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
|
788 } |
18491
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
789 |
8f172a8b8cce
Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18161
diff
changeset
|
790 g_free(jid_norm); |
15466
2c81b0a81790
Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
791 return TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 |
18161 | 794 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
|
795 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 GSList *buddies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 xmlnode *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 xmlnode *group; |
15822 | 802 PurpleBuddy *b; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 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
|
804 const char *balias; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 js = (JabberStream*)(gc->proto_data); |
18161 | 807 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 jb = jabber_buddy_find(js, who, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 |
15822 | 813 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
|
814 if(!buddies) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 return; |
18161 | 816 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 b = buddies->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); |
18161 | 820 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 item = xmlnode_new_child(query, "item"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 while(buddies) { |
15822 | 825 PurpleGroup *g; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 b = buddies->data; |
15822 | 828 g = purple_buddy_get_group(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 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
|
831 xmlnode_insert_data(group, purple_group_get_name(g), -1); |
18161 | 832 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 buddies = buddies->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
836 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
|
837 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
|
838 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
|
839 xmlnode_set_attrib(item, "gr:t", "B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 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
|
841 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 /* Synthesize a sign-off */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 if (jb) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 JabberBuddyResource *jbr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 GList *l = jb->resources; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 while (l) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 jbr = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 if (jbr && jbr->name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 { |
15822 | 853 purple_debug(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
|
854 jabber_buddy_remove_resource(jb, jbr->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 l = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 } |
15822 | 859 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
|
860 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 |
15822 | 862 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
|
863 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
865 GSList *buddies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
866 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
868 xmlnode *item; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 xmlnode *group; |
15822 | 870 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
|
871 const char *balias; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
872 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
873 g_return_if_fail(gc != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
874 g_return_if_fail(who != NULL); |
18161 | 875 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
876 js = (JabberStream*)(gc->proto_data); |
18161 | 877 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 return; |
18161 | 880 |
25795
ede22bc33d56
More struct hiding work
Richard Laager <rlaager@wiktel.com>
parents:
23397
diff
changeset
|
881 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
|
882 if(!buddies) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
883 return; |
18161 | 884 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
885 b = buddies->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
886 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
887 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); |
18161 | 888 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
889 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 item = xmlnode_new_child(query, "item"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
891 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 while(buddies) { |
15822 | 893 PurpleGroup *g; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 b = buddies->data; |
15822 | 896 g = purple_buddy_get_group(b); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 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
|
899 xmlnode_insert_data(group, purple_group_get_name(g), -1); |
18161 | 900 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 buddies = buddies->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 |
25803
8aa7d8bcbc7d
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25797
diff
changeset
|
904 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
|
905 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
|
906 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
|
907 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
|
908 xmlnode_set_attrib(query, "gr:ext", "2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 /* See if he's online */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 jabber_presence_subscription_set(js, who, "probe"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 } |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
915 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
916 /* 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
|
917 * 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
|
918 * 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
|
919 * 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
|
920 * 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
|
921 */ |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
922 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
|
923 { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
924 const char *p; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
925 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
926 /* 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
|
927 gboolean preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
928 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
929 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
|
930 gboolean in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
931 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
932 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
|
933 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
934 GString *str; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
935 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
936 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
|
937 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
|
938 if (c == '*' && !in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
939 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
|
940 *(p+1) == '\0' || |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
941 *(p+1) == '<')) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
942 bold_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
943 in_bold = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
944 } 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
|
945 bold_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
946 in_bold = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
947 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
948 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
949 } 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
|
950 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
|
951 *(p+1) == '\0' || |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
952 *(p+1) == '<')) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
953 italic_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
954 in_italic = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
955 } 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
|
956 italic_count++; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
957 in_italic = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
958 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
959 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
960 } 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
|
961 in_tag = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
962 } 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
|
963 in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
964 } else if (!in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
965 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
|
966 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
967 else |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
968 preceding_space = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
969 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
970 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
971 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
972 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
|
973 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
|
974 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
975 |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
976 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
|
977 gunichar c = g_utf8_get_char(p); |
18161 | 978 |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
979 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
|
980 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
|
981 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
|
982 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
983 |
18161 | 984 |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
985 if (c == '*' && !in_tag) { |
18161 | 986 if (in_bold && |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
987 (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
|
988 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
|
989 in_bold = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
990 bold_count--; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
991 } 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
|
992 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
|
993 bold_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
994 in_bold = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
995 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
996 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
|
997 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
998 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
999 } 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
|
1000 if (in_italic && |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1001 (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
|
1002 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
|
1003 italic_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1004 in_italic = FALSE; |
16932
3d0aec991e5d
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
1005 } 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
|
1006 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
|
1007 italic_count--; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1008 in_italic = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1009 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1010 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
|
1011 } |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1012 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1013 } 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
|
1014 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
|
1015 in_tag = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1016 } 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
|
1017 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
|
1018 in_tag = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1019 } else if (!in_tag) { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1020 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
|
1021 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
|
1022 preceding_space = TRUE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1023 else |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1024 preceding_space = FALSE; |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1025 } else { |
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1026 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
|
1027 } |
18161 | 1028 } |
15522
ccbdf500f13a
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents:
15466
diff
changeset
|
1029 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
|
1030 } |
20571
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1031 |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1032 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
|
1033 { |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1034 if (!js->googletalk) |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1035 return; |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1036 if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) { |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1037 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
|
1038 PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL); |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1039 jbr->status = NULL; |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1040 } else { |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1041 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
|
1042 } |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1043 } |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1044 |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1045 char *jabber_google_presence_outgoing(PurpleStatus *tune) |
c97e3ab9ef11
Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents:
20211
diff
changeset
|
1046 { |
21634
1853d9d0cc65
don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents:
21220
diff
changeset
|
1047 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
|
1048 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
|
1049 } |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1050 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1051 static void |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1052 jabber_google_stun_lookup_cb(GSList *hosts, gpointer data, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1053 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
|
1054 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1055 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
|
1056 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1057 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
|
1058 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
|
1059 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
|
1060 g_slist_free(hosts); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1061 return; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1062 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1063 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1064 if (hosts && g_slist_next(hosts)) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1065 struct sockaddr *addr = g_slist_next(hosts)->data; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1066 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
|
1067 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
|
1068 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1069 if (addr->sa_family == AF_INET6) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1070 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1071 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
|
1072 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
|
1073 } else { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1074 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1075 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
|
1076 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
|
1077 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1078 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1079 if (js) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1080 if (js->stun_ip) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1081 g_free(js->stun_ip); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1082 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1083 js->stun_ip = g_strdup(dst); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1084 purple_debug_info("jabber", "set Google STUN IP address: %s\n", dst); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1085 js->stun_port = port; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1086 purple_debug_info("jabber", "set Google STUN port: %d\n", port); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1087 purple_debug_info("jabber", "set Google STUN port: %d\n", port); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1088 /* unmark ongoing query */ |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1089 js->stun_query = NULL; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1090 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1091 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1092 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1093 g_slist_free(hosts); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1094 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1095 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1096 static void |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1097 jabber_google_jingle_info_cb(JabberStream *js, xmlnode *result, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1098 gpointer nullus) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1099 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1100 if (result) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1101 const xmlnode *query = |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1102 xmlnode_get_child_with_namespace(result, "query", |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1103 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
|
1104 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1105 if (query) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1106 const xmlnode *stun = xmlnode_get_child(query, "stun"); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1107 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1108 purple_debug_info("jabber", "got google:jingleinfo\n"); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1109 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1110 if (stun) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1111 xmlnode *server = xmlnode_get_child(stun, "server"); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1112 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1113 if (server) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1114 const gchar *host = xmlnode_get_attrib(server, "host"); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1115 const gchar *udp = xmlnode_get_attrib(server, "udp"); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1116 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1117 if (host && udp) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1118 int port = atoi(udp); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1119 /* if there, would already be an ongoing query, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1120 cancel it */ |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1121 if (js->stun_query) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1122 purple_dnsquery_destroy(js->stun_query); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1123 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1124 js->stun_query = purple_dnsquery_a(host, port, |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1125 jabber_google_stun_lookup_cb, js); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1126 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1127 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1128 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1129 /* should perhaps handle relays later on, or maybe wait until |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1130 Google supports a common standard... */ |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1131 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1132 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1133 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1134 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1135 void |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1136 jabber_google_handle_jingle_info(JabberStream *js, xmlnode *packet) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1137 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1138 jabber_google_jingle_info_cb(js, packet, NULL); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1139 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1140 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1141 void |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1142 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
|
1143 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1144 JabberIq *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
|
1145 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
|
1146 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1147 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
|
1148 NULL); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26058
diff
changeset
|
1149 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
|
1150 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
|
1151 } |