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