Wed, 07 Jan 2009 02:46:41 +0000
Fix receiving voice calls from Gmail.
| 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" |
| 26 | ||
| 27 | #include "buddy.h" | |
| 15225 | 28 | #include "google.h" |
| 29 | #include "jabber.h" | |
| 15265 | 30 | #include "presence.h" |
| 15225 | 31 | #include "iq.h" |
| 32 | ||
|
23704
9b88c9b23aed
Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents:
23700
diff
changeset
|
33 | #ifdef USE_VV |
|
23700
e47be56bdd2b
Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents:
23697
diff
changeset
|
34 | #include <gst/farsight/fs-conference-iface.h> |
|
e47be56bdd2b
Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents:
23697
diff
changeset
|
35 | |
|
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
|
36 | 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
|
37 | 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
|
38 | 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
|
39 | } 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
|
40 | |
|
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 | 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
|
42 | 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
|
43 | 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
|
44 | 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
|
45 | 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
|
46 | 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
|
47 | } 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
|
48 | |
|
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 | 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
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | 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
|
55 | } 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
|
56 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
57 | GHashTable *sessions = 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
|
58 | |
|
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 | static guint |
|
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 | google_session_id_hash(gconstpointer key) |
|
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 | { |
|
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 | GoogleSessionId *id = (GoogleSessionId*)key; |
|
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 | |
|
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 | guint id_hash = g_str_hash(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
|
65 | guint init_hash = g_str_hash(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
|
66 | |
|
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 | return 23 * id_hash + init_hash; |
|
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 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
69 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
70 | 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
|
71 | 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
|
72 | { |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
73 | 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
|
74 | 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
|
75 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
76 | 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
|
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 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
79 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
80 | 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
|
81 | { |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
82 | g_hash_table_remove(sessions, &(session->id)); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | g_object_unref(session->media); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
87 | 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
|
88 | } |
|
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
|
89 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
90 | 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
|
91 | 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
|
92 | { |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
100 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
101 | static void |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
102 | google_session_send_accept(GoogleSession *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
|
103 | { |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
104 | xmlnode *sess, *desc, *payload; |
|
26160
46bc5e18d59c
Combine get_*_codecs functions to mirror Farsight 2.
Michael Ruprecht <maiku@pidgin.im>
parents:
26133
diff
changeset
|
105 | GList *codecs = purple_media_get_codecs(session->media, "google-voice"); |
|
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 | JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
107 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
108 | xmlnode_set_attrib(iq->node, "to", session->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
|
109 | sess = google_session_create_xmlnode(session, "accept"); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
110 | xmlnode_insert_child(iq->node, sess); |
|
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 | desc = xmlnode_new_child(sess, "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
|
112 | xmlnode_set_namespace(desc, "http://www.google.com/session/phone"); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
113 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
114 | for (;codecs; codecs = codecs->next) { |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
115 | FsCodec *codec = (FsCodec*)codecs->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
|
116 | char id[8], clockrate[10]; |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
117 | payload = xmlnode_new_child(desc, "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
|
118 | g_snprintf(id, sizeof(id), "%d", codec->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
|
119 | g_snprintf(clockrate, sizeof(clockrate), "%d", codec->clock_rate); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
120 | xmlnode_set_attrib(payload, "name", codec->encoding_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
|
121 | xmlnode_set_attrib(payload, "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
|
122 | xmlnode_set_attrib(payload, "clockrate", 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
|
123 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
124 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
125 | fs_codec_list_destroy(codecs); |
|
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
|
126 | jabber_iq_send(iq); |
|
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
|
127 | gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_PLAYING); |
|
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 | } |
|
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 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
130 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
131 | 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
|
132 | { |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
133 | xmlnode *sess; |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
134 | 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
|
135 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
140 | 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
|
141 | 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
|
142 | } |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
143 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
144 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
145 | google_session_send_reject(GoogleSession *session) |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
146 | { |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
147 | xmlnode *sess; |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
148 | 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
|
149 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
150 | 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
|
151 | sess = google_session_create_xmlnode(session, "reject"); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
152 | 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
|
153 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
154 | 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
|
155 | 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
|
156 | } |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
157 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
158 | |
|
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
|
159 | static void |
|
26164
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
160 | google_session_candidates_prepared (PurpleMedia *media, gchar *session_id, |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
161 | 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
|
162 | { |
|
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 | JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
|
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
|
164 | 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
|
165 | session->remote_jid); |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
166 | FsCandidate *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
|
167 | xmlnode *sess; |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
168 | xmlnode *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
|
169 | sess = google_session_create_xmlnode(session, "candidates"); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
170 | xmlnode_insert_child(iq->node, sess); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
171 | xmlnode_set_attrib(iq->node, "to", session->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
|
172 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
173 | for (;candidates;candidates = candidates->next) { |
|
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 | char port[8]; |
|
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 | char pref[8]; |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
176 | transport = (FsCandidate*)(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
|
177 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
178 | if (!strcmp(transport->ip, "127.0.0.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
|
179 | continue; |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
180 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
181 | 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
|
182 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
183 | g_snprintf(port, sizeof(port), "%d", transport->port); |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
184 | g_snprintf(pref, sizeof(pref), "%d", transport->priority); |
|
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
|
185 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
186 | xmlnode_set_attrib(candidate, "address", transport->ip); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
187 | 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
|
188 | xmlnode_set_attrib(candidate, "name", "rtp"); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
189 | xmlnode_set_attrib(candidate, "username", transport->username); |
|
26201
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
190 | /* |
|
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
191 | * 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
|
192 | * 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
|
193 | * requires this to be set. |
|
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
194 | */ |
|
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
195 | xmlnode_set_attrib(candidate, "password", |
|
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
196 | transport->password != NULL ? |
|
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
197 | transport->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
|
198 | xmlnode_set_attrib(candidate, "preference", pref); |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
199 | xmlnode_set_attrib(candidate, "protocol", transport->proto == FS_NETWORK_PROTOCOL_UDP ? "udp" : "tcp"); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
200 | xmlnode_set_attrib(candidate, "type", transport->type == FS_CANDIDATE_TYPE_HOST ? "local" : |
|
26201
32baf68eeedd
Fix receiving voice calls from Gmail.
Michael Ruprecht <maiku@pidgin.im>
parents:
26199
diff
changeset
|
201 | transport->type == FS_CANDIDATE_TYPE_SRFLX ? "stun" : |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
202 | transport->type == FS_CANDIDATE_TYPE_RELAY ? "relay" : 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
|
203 | 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
|
204 | 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
|
205 | xmlnode_insert_child(sess, 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
|
206 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
207 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
208 | jabber_iq_send(iq); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
209 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
210 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
211 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
212 | google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *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
|
213 | { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
214 | 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
|
215 | 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
|
216 | xmlnode *desc_element, *codec_element; |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
217 | FsCodec *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
|
218 | const char *id, *encoding_name, *clock_rate; |
|
26164
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
219 | GParameter param; |
|
22648
e286d795c5f9
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
220 | |
|
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
|
221 | 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
|
222 | 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
|
223 | 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
|
224 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
225 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
226 | session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc, |
|
26187
3b3059a7c091
Add initiator property to PurpleMedia.
Michael Ruprecht <maiku@pidgin.im>
parents:
26164
diff
changeset
|
227 | "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
|
228 | |
|
26164
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
229 | /* GTalk requires the NICE_COMPATIBILITY_GOOGLE param */ |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
230 | param.name = "compatibility-mode"; |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
231 | memset(¶m.value, 0, sizeof(GValue)); |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
232 | g_value_init(¶m.value, G_TYPE_UINT); |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
233 | g_value_set_uint(¶m.value, 1); /* NICE_COMPATIBILITY_GOOGLE */ |
|
20f15fbe9b21
Very basic receive only GTalk audio sessions.
Michael Ruprecht <maiku@pidgin.im>
parents:
26160
diff
changeset
|
234 | |
|
26199
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
235 | if (purple_media_add_stream(session->media, "google-voice", session->remote_jid, |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
236 | PURPLE_MEDIA_AUDIO, "nice", 1, ¶m) == FALSE) { |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
237 | purple_media_error(session->media, "Error adding stream."); |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
238 | purple_media_hangup(session->media); |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
239 | google_session_send_terminate(session); |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
240 | return; |
|
a5530443b54d
End google call if stream creation fails.
Michael Ruprecht <maiku@pidgin.im>
parents:
26187
diff
changeset
|
241 | } |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
242 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
243 | desc_element = xmlnode_get_child(sess, "description"); |
|
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
|
244 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
252 | codec = fs_codec_new(atoi(id), encoding_name, FS_MEDIA_TYPE_AUDIO, |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
253 | 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
|
254 | 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
|
255 | } |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
256 | |
|
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
|
257 | 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
|
258 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
259 | g_signal_connect_swapped(G_OBJECT(session->media), "accepted", |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
260 | G_CALLBACK(google_session_send_accept), session); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
261 | g_signal_connect_swapped(G_OBJECT(session->media), "reject", |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
262 | G_CALLBACK(google_session_send_reject), session); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
263 | g_signal_connect_swapped(G_OBJECT(session->media), "hangup", |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
264 | G_CALLBACK(google_session_send_terminate), session); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
265 | g_signal_connect(G_OBJECT(session->media), "candidates-prepared", |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
266 | G_CALLBACK(google_session_candidates_prepared), session); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
267 | purple_media_ready(session->media); |
|
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
|
268 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
269 | fs_codec_list_destroy(codecs); |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
270 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
271 | result = jabber_iq_new(js, JABBER_IQ_RESULT); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
272 | jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
273 | 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
|
274 | 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
|
275 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
276 | |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
277 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
278 | google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *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
|
279 | { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
280 | 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
|
281 | 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | |
|
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
|
286 | for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) { |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
287 | FsCandidate *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
|
288 | g_snprintf(n, sizeof(n), "S%d", name++); |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
289 | info = fs_candidate_new(n, FS_COMPONENT_RTP, !strcmp(xmlnode_get_attrib(cand, "type"), "local") ? |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
290 | FS_CANDIDATE_TYPE_HOST : |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
291 | !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ? |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
292 | FS_CANDIDATE_TYPE_PRFLX : |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
293 | !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ? |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
294 | FS_CANDIDATE_TYPE_RELAY : FS_CANDIDATE_TYPE_HOST, |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
295 | !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ? |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
296 | FS_NETWORK_PROTOCOL_UDP : FS_NETWORK_PROTOCOL_TCP, |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
297 | xmlnode_get_attrib(cand, "address"), atoi(xmlnode_get_attrib(cand, "port"))); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
298 | |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
299 | info->username = g_strdup(xmlnode_get_attrib(cand, "username")); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
300 | info->password = g_strdup(xmlnode_get_attrib(cand, "password")); |
|
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
301 | |
|
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
|
302 | 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
|
303 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
304 | |
|
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
|
305 | purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list); |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
306 | fs_candidate_list_destroy(list); |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
307 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
308 | result = jabber_iq_new(js, JABBER_IQ_RESULT); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
309 | jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
310 | 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
|
311 | 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
|
312 | } |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
313 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
314 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
315 | google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess) |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
316 | { |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
317 | purple_media_got_hangup(session->media); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
318 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
319 | 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
|
320 | } |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
321 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
322 | static void |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
323 | google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess) |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
324 | { |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
325 | purple_media_got_hangup(session->media); |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
326 | |
|
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
327 | google_session_destroy(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
|
328 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
329 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
330 | static void |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
331 | google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *packet) |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
332 | { |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
333 | xmlnode *sess = xmlnode_get_child(packet, "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
|
334 | 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
|
335 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
336 | if (!strcmp(type, "initiate")) { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
337 | google_session_handle_initiate(js, session, packet, 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
|
338 | } else if (!strcmp(type, "accept")) { |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
339 | } else if (!strcmp(type, "reject")) { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
340 | google_session_handle_reject(js, session, packet, 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
|
341 | } else if (!strcmp(type, "terminate")) { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
342 | google_session_handle_terminate(js, session, packet, 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
|
343 | } else if (!strcmp(type, "candidates")) { |
|
19885
593613a22e57
You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents:
19882
diff
changeset
|
344 | google_session_handle_candidates(js, session, packet, 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
|
345 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
346 | } |
|
23704
9b88c9b23aed
Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents:
23700
diff
changeset
|
347 | #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
|
348 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
349 | void |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
350 | jabber_google_session_parse(JabberStream *js, xmlnode *packet) |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
351 | { |
|
23704
9b88c9b23aed
Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents:
23700
diff
changeset
|
352 | #ifdef 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
|
353 | GoogleSession *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
|
354 | 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
|
355 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
356 | xmlnode *session_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
|
357 | 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
|
358 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
359 | if (strcmp(xmlnode_get_attrib(packet, "type"), "set")) |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
360 | 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
|
361 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
362 | session_node = xmlnode_get_child(packet, "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
|
363 | if (!session_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
|
364 | 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
|
365 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | |
|
23697
299bafcd8eb8
Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents:
22648
diff
changeset
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
374 | if (sessions == 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
|
375 | sessions = g_hash_table_new(google_session_id_hash, google_session_id_equal); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
376 | session = (GoogleSession*)g_hash_table_lookup(sessions, &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
|
377 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
378 | if (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
|
379 | google_session_parse_iq(js, session, packet); |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
380 | 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
|
381 | } |
|
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 | |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
383 | /* 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
|
384 | 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
|
385 | 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
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | 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
|
395 | g_hash_table_insert(sessions, &(session->id), 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
|
396 | |
|
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 | google_session_parse_iq(js, session, packet); |
|
23700
e47be56bdd2b
Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents:
23697
diff
changeset
|
398 | #else |
|
e47be56bdd2b
Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents:
23697
diff
changeset
|
399 | /* TODO: send proper error response */ |
|
23704
9b88c9b23aed
Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents:
23700
diff
changeset
|
400 | #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
|
401 | } |
|
d8c2a2fc1fbf
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents:
19046
diff
changeset
|
402 | |
| 18233 | 403 | static void |
| 15225 | 404 | jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul) |
| 405 | { | |
| 406 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 407 | xmlnode *child; | |
| 408 | xmlnode *message, *sender_node, *subject_node; | |
| 18739 | 409 | const char *from, *to, *url, *tid; |
| 410 | char *subject; | |
| 15225 | 411 | const char *in_str; |
| 412 | char *to_name; | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
413 | char *default_tos[1]; |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
414 | |
| 15225 | 415 | int i, count = 1, returned_count; |
| 18233 | 416 | |
| 18739 | 417 | const char **tos, **froms, **urls; |
| 418 | char **subjects; | |
| 18233 | 419 | |
| 15225 | 420 | if (strcmp(type, "result")) |
| 421 | return; | |
| 18233 | 422 | |
| 15225 | 423 | child = xmlnode_get_child(packet, "mailbox"); |
| 424 | if (!child) | |
| 425 | return; | |
| 426 | ||
| 427 | in_str = xmlnode_get_attrib(child, "total-matched"); | |
| 18233 | 428 | if (in_str && *in_str) |
| 15225 | 429 | count = atoi(in_str); |
| 18233 | 430 | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
431 | /* 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
|
432 | to = xmlnode_get_attrib(packet, "to"); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
433 | default_tos[0] = jabber_get_bare_jid(to); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
434 | |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
435 | message = xmlnode_get_child(child, "mail-thread-info"); |
| 15225 | 436 | |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
437 | 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
|
438 | 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
|
439 | 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
|
440 | g_free(default_tos[0]); |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
441 | return; |
|
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
442 | } |
| 18233 | 443 | |
| 15225 | 444 | /* Loop once to see how many messages were returned so we can allocate arrays |
| 445 | * accordingly */ | |
| 446 | for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); | |
| 18233 | 447 | |
| 15225 | 448 | froms = g_new0(const char* , returned_count); |
| 449 | tos = g_new0(const char* , returned_count); | |
| 18739 | 450 | subjects = g_new0(char* , returned_count); |
| 15225 | 451 | urls = g_new0(const char* , returned_count); |
| 18233 | 452 | |
| 15225 | 453 | to = xmlnode_get_attrib(packet, "to"); |
| 454 | to_name = jabber_get_bare_jid(to); | |
| 455 | url = xmlnode_get_attrib(child, "url"); | |
| 456 | if (!url || !*url) | |
| 457 | url = "http://www.gmail.com"; | |
| 18233 | 458 | |
| 15225 | 459 | message= xmlnode_get_child(child, "mail-thread-info"); |
| 460 | for (i=0; message; message = xmlnode_get_next_twin(message), i++) { | |
| 461 | subject_node = xmlnode_get_child(message, "subject"); | |
| 462 | sender_node = xmlnode_get_child(message, "senders"); | |
| 463 | sender_node = xmlnode_get_child(sender_node, "sender"); | |
| 464 | ||
| 18233 | 465 | while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") || |
| 15225 | 466 | !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0"))) |
| 467 | sender_node = xmlnode_get_next_twin(sender_node); | |
| 18233 | 468 | |
| 15225 | 469 | if (!sender_node) { |
| 470 | i--; | |
| 471 | continue; | |
| 472 | } | |
| 18233 | 473 | |
| 15225 | 474 | from = xmlnode_get_attrib(sender_node, "name"); |
| 475 | if (!from || !*from) | |
| 476 | from = xmlnode_get_attrib(sender_node, "address"); | |
| 477 | subject = xmlnode_get_data(subject_node); | |
| 478 | /* | |
| 479 | * url = xmlnode_get_attrib(message, "url"); | |
| 480 | */ | |
| 481 | tos[i] = (to_name != NULL ? to_name : ""); | |
| 482 | froms[i] = (from != NULL ? from : ""); | |
| 18739 | 483 | subjects[i] = (subject != NULL ? subject : g_strdup("")); |
|
20225
684334efdc19
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20209
diff
changeset
|
484 | urls[i] = url; |
| 18233 | 485 | |
| 15225 | 486 | tid = xmlnode_get_attrib(message, "tid"); |
| 18233 | 487 | if (tid && |
| 15225 | 488 | (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) { |
| 489 | g_free(js->gmail_last_tid); | |
| 490 | js->gmail_last_tid = g_strdup(tid); | |
| 491 | } | |
| 492 | } | |
| 493 | ||
| 18233 | 494 | 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
|
495 | purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, |
| 18233 | 496 | urls, NULL, NULL); |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
497 | else |
|
20107
c2fafb2681d1
applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@pidgin.im>
parents:
20097
diff
changeset
|
498 | 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
|
499 | |
| 15261 | 500 | |
| 15225 | 501 | g_free(to_name); |
| 502 | g_free(tos); | |
|
20097
f5bef80db09e
applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
503 | g_free(default_tos[0]); |
| 15225 | 504 | 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
|
505 | 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
|
506 | g_free(subjects[i - 1]); |
| 15225 | 507 | g_free(subjects); |
| 508 | g_free(urls); | |
| 509 | ||
| 510 | in_str = xmlnode_get_attrib(child, "result-time"); | |
| 511 | if (in_str && *in_str) { | |
| 512 | g_free(js->gmail_last_time); | |
| 513 | js->gmail_last_time = g_strdup(in_str); | |
| 514 | } | |
| 515 | } | |
| 516 | ||
| 18233 | 517 | void |
| 518 | jabber_gmail_poke(JabberStream *js, xmlnode *packet) | |
| 15225 | 519 | { |
| 520 | const char *type; | |
| 521 | xmlnode *query; | |
| 522 | JabberIq *iq; | |
| 18233 | 523 | |
| 15225 | 524 | /* bail if the user isn't interested */ |
| 15884 | 525 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 526 | return; |
| 527 | ||
| 528 | type = xmlnode_get_attrib(packet, "type"); | |
| 18233 | 529 | |
| 15225 | 530 | |
| 531 | /* Is this an initial incoming mail notification? If so, send a request for more info */ | |
| 532 | if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail")) | |
| 533 | return; | |
| 534 | ||
| 15884 | 535 | purple_debug(PURPLE_DEBUG_MISC, "jabber", |
| 15225 | 536 | "Got new mail notification. Sending request for more info\n"); |
| 537 | ||
| 538 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 539 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 540 | query = xmlnode_get_child(iq->node, "query"); | |
| 541 | ||
| 542 | if (js->gmail_last_time) | |
| 543 | xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); | |
| 544 | if (js->gmail_last_tid) | |
| 545 | xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid); | |
| 546 | ||
| 547 | jabber_iq_send(iq); | |
| 548 | return; | |
| 549 | } | |
| 550 | ||
| 551 | void jabber_gmail_init(JabberStream *js) { | |
| 552 | JabberIq *iq; | |
| 553 | ||
| 18233 | 554 | if (!purple_account_get_check_mail(js->gc->account)) |
| 15225 | 555 | return; |
| 556 | ||
| 557 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | |
| 558 | jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | |
| 559 | jabber_iq_send(iq); | |
| 560 | } | |
| 15265 | 561 | |
| 562 | void jabber_google_roster_init(JabberStream *js) | |
| 563 | { | |
| 564 | JabberIq *iq; | |
| 565 | xmlnode *query; | |
| 566 | ||
| 567 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); | |
| 568 | query = xmlnode_get_child(iq->node, "query"); | |
| 18233 | 569 | |
| 15265 | 570 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); |
| 571 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 572 | ||
| 573 | jabber_iq_send(iq); | |
| 574 | } | |
| 575 | ||
| 576 | void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item) | |
| 577 | { | |
| 15884 | 578 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 579 | GSList *list = account->deny; |
| 580 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 581 | char *jid_norm = g_strdup(jabber_normalize(account, jid)); | |
| 582 | ||
| 583 | while (list) { | |
| 584 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 585 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 586 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 587 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 588 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 589 | return; | |
| 590 | } | |
| 591 | list = list->next; | |
| 592 | } | |
| 593 | ||
| 18739 | 594 | g_free(jid_norm); |
| 595 | ||
| 15265 | 596 | } |
| 597 | ||
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
598 | gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item) |
| 15265 | 599 | { |
| 15884 | 600 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 15265 | 601 | GSList *list = account->deny; |
| 602 | const char *jid = xmlnode_get_attrib(item, "jid"); | |
| 603 | gboolean on_block_list = FALSE; | |
| 604 | ||
|
20209
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
605 | char *jid_norm; |
| 15265 | 606 | |
| 607 | 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
|
608 | const char *subscription = xmlnode_get_attrib(item, "subscription"); |
| 18233 | 609 | |
| 17327 | 610 | 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
|
611 | /* 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
|
612 | * 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
|
613 | */ |
|
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
|
614 | 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
|
615 | } |
| 18233 | 616 | |
|
20209
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
617 | jid_norm = g_strdup(jabber_normalize(account, jid)); |
|
c1bbdde1f373
applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents:
20186
diff
changeset
|
618 | |
| 15265 | 619 | while (list) { |
| 620 | if (!strcmp(jid_norm, (char*)list->data)) { | |
| 621 | on_block_list = TRUE; | |
| 622 | break; | |
| 623 | } | |
| 624 | list = list->next; | |
| 625 | } | |
| 18233 | 626 | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
627 | if (grt && (*grt == 'H' || *grt == 'h')) { |
| 15884 | 628 | PurpleBuddy *buddy = purple_find_buddy(account, jid_norm); |
|
20114
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
629 | if (buddy) |
|
96e715e155e0
applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents:
20107
diff
changeset
|
630 | purple_blist_remove_buddy(buddy); |
| 18739 | 631 | g_free(jid_norm); |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
632 | return FALSE; |
|
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
633 | } |
| 18233 | 634 | |
| 15265 | 635 | if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) { |
| 15884 | 636 | purple_debug_info("jabber", "Blocking %s\n", jid_norm); |
| 637 | purple_privacy_deny_add(account, jid_norm, TRUE); | |
| 15265 | 638 | } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){ |
| 15884 | 639 | purple_debug_info("jabber", "Unblocking %s\n", jid_norm); |
| 640 | purple_privacy_deny_remove(account, jid_norm, TRUE); | |
| 15265 | 641 | } |
| 18739 | 642 | |
| 643 | g_free(jid_norm); | |
|
15530
9355a1be068e
Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
644 | return TRUE; |
| 15265 | 645 | } |
| 646 | ||
| 18233 | 647 | void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who) |
| 15265 | 648 | { |
| 649 | JabberStream *js; | |
| 650 | GSList *buddies; | |
| 651 | JabberIq *iq; | |
| 652 | xmlnode *query; | |
| 653 | xmlnode *item; | |
| 654 | xmlnode *group; | |
| 15884 | 655 | PurpleBuddy *b; |
| 15265 | 656 | JabberBuddy *jb; |
| 657 | ||
| 658 | js = (JabberStream*)(gc->proto_data); | |
| 18233 | 659 | |
| 15265 | 660 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 661 | return; | |
| 662 | ||
| 663 | jb = jabber_buddy_find(js, who, TRUE); | |
| 664 | ||
| 15884 | 665 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 666 | if(!buddies) |
| 667 | return; | |
| 18233 | 668 | |
| 15265 | 669 | b = buddies->data; |
| 670 | ||
| 671 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 672 | |
| 15265 | 673 | query = xmlnode_get_child(iq->node, "query"); |
| 674 | item = xmlnode_new_child(query, "item"); | |
| 675 | ||
| 676 | while(buddies) { | |
| 15884 | 677 | PurpleGroup *g; |
| 15265 | 678 | |
| 679 | b = buddies->data; | |
| 15884 | 680 | g = purple_buddy_get_group(b); |
| 15265 | 681 | |
| 682 | group = xmlnode_new_child(item, "group"); | |
| 683 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 684 | |
| 15265 | 685 | buddies = buddies->next; |
| 686 | } | |
| 687 | ||
| 688 | xmlnode_set_attrib(item, "jid", who); | |
| 689 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 690 | xmlnode_set_attrib(item, "gr:t", "B"); | |
| 691 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 692 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 693 | ||
| 694 | jabber_iq_send(iq); | |
| 695 | ||
| 696 | /* Synthesize a sign-off */ | |
| 697 | if (jb) { | |
| 698 | JabberBuddyResource *jbr; | |
| 699 | GList *l = jb->resources; | |
| 700 | while (l) { | |
| 701 | jbr = l->data; | |
|
15346
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
702 | if (jbr && jbr->name) |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
703 | { |
| 15884 | 704 | 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
|
705 | jabber_buddy_remove_resource(jb, jbr->name); |
|
ef48613b5b9b
[gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents:
15265
diff
changeset
|
706 | } |
| 15265 | 707 | l = l->next; |
| 708 | } | |
| 709 | } | |
| 15884 | 710 | purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); |
| 15265 | 711 | } |
| 712 | ||
| 15884 | 713 | void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who) |
| 15265 | 714 | { |
| 715 | JabberStream *js; | |
| 716 | GSList *buddies; | |
| 717 | JabberIq *iq; | |
| 718 | xmlnode *query; | |
| 719 | xmlnode *item; | |
| 720 | xmlnode *group; | |
| 15884 | 721 | PurpleBuddy *b; |
| 15265 | 722 | |
| 723 | g_return_if_fail(gc != NULL); | |
| 724 | g_return_if_fail(who != NULL); | |
| 18233 | 725 | |
| 15265 | 726 | js = (JabberStream*)(gc->proto_data); |
| 18233 | 727 | |
| 15265 | 728 | if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER) |
| 729 | return; | |
| 18233 | 730 | |
| 15884 | 731 | buddies = purple_find_buddies(js->gc->account, who); |
| 15265 | 732 | if(!buddies) |
| 733 | return; | |
| 18233 | 734 | |
| 15265 | 735 | b = buddies->data; |
| 736 | ||
| 737 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster"); | |
| 18233 | 738 | |
| 15265 | 739 | query = xmlnode_get_child(iq->node, "query"); |
| 740 | item = xmlnode_new_child(query, "item"); | |
| 741 | ||
| 742 | while(buddies) { | |
| 15884 | 743 | PurpleGroup *g; |
| 15265 | 744 | |
| 745 | b = buddies->data; | |
| 15884 | 746 | g = purple_buddy_get_group(b); |
| 15265 | 747 | |
| 748 | group = xmlnode_new_child(item, "group"); | |
| 749 | xmlnode_insert_data(group, g->name, -1); | |
| 18233 | 750 | |
| 15265 | 751 | buddies = buddies->next; |
| 752 | } | |
| 753 | ||
| 754 | xmlnode_set_attrib(item, "jid", who); | |
| 755 | xmlnode_set_attrib(item, "name", b->alias ? b->alias : ""); | |
| 756 | xmlnode_set_attrib(query, "xmlns:gr", "google:roster"); | |
| 757 | xmlnode_set_attrib(query, "gr:ext", "2"); | |
| 758 | ||
| 759 | jabber_iq_send(iq); | |
| 760 | ||
| 761 | /* See if he's online */ | |
| 762 | jabber_presence_subscription_set(js, who, "probe"); | |
| 763 | } | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
764 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
765 | /* 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
|
766 | * 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
|
767 | * 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
|
768 | * 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
|
769 | * 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
|
770 | */ |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
771 | 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
|
772 | { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
773 | const char *p; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
774 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
775 | /* 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
|
776 | gboolean preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
777 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
778 | 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
|
779 | gboolean in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
780 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
781 | 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
|
782 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
783 | GString *str; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
784 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
785 | 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
|
786 | 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
|
787 | if (c == '*' && !in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
788 | 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
|
789 | *(p+1) == '\0' || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
790 | *(p+1) == '<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
791 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
792 | in_bold = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
793 | } 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
|
794 | bold_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
795 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
796 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
797 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
798 | } 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
|
799 | 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
|
800 | *(p+1) == '\0' || |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
801 | *(p+1) == '<')) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
802 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
803 | in_italic = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
804 | } 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
|
805 | italic_count++; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
806 | in_italic = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
807 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
808 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
809 | } 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
|
810 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
811 | } 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
|
812 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
813 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
814 | 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
|
815 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
816 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
817 | preceding_space = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
818 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
819 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
820 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
821 | 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
|
822 | 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
|
823 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
824 | |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
825 | 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
|
826 | gunichar c = g_utf8_get_char(p); |
| 18233 | 827 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
828 | 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
|
829 | 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
|
830 | 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
|
831 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
832 | |
| 18233 | 833 | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
834 | if (c == '*' && !in_tag) { |
| 18233 | 835 | if (in_bold && |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
836 | (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
|
837 | 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
|
838 | in_bold = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
839 | bold_count--; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
840 | } 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
|
841 | 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
|
842 | bold_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
843 | in_bold = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
844 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
845 | 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
|
846 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
847 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
848 | } 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
|
849 | if (in_italic && |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
850 | (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
|
851 | 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
|
852 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
853 | in_italic = FALSE; |
|
16988
1aaf51bf0f23
Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
854 | } 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
|
855 | 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
|
856 | italic_count--; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
857 | in_italic = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
858 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
859 | 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
|
860 | } |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
861 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
862 | } 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
|
863 | 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
|
864 | in_tag = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
865 | } 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
|
866 | 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
|
867 | in_tag = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
868 | } else if (!in_tag) { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
869 | 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
|
870 | 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
|
871 | preceding_space = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
872 | else |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
873 | preceding_space = FALSE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
874 | } else { |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
875 | 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
|
876 | } |
| 18233 | 877 | } |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15530
diff
changeset
|
878 | 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
|
879 | } |
|
21195
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
880 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
881 | 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
|
882 | { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
883 | if (!js->googletalk) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
884 | return; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
885 | if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
886 | 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
|
887 | PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL); |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
888 | jbr->status = NULL; |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
889 | } else { |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
890 | 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
|
891 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
892 | } |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
893 | |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
894 | char *jabber_google_presence_outgoing(PurpleStatus *tune) |
|
fd63ef5027d7
Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents:
20107
diff
changeset
|
895 | { |
|
21714
5956ea2cb4af
don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@pidgin.im>
parents:
21204
diff
changeset
|
896 | 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
|
897 | 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
|
898 | } |