libpurple/protocols/jabber/google.c

Thu, 13 Nov 2008 03:46:28 +0000

author
Michael Ruprecht <maiku@pidgin.im>
date
Thu, 13 Nov 2008 03:46:28 +0000
branch
maiku.vv
changeset 26160
46bc5e18d59c
parent 26133
a12ffee5bd73
child 26164
20f15fbe9b21
permissions
-rw-r--r--

Combine get_*_codecs functions to mirror Farsight 2.

15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1 /**
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
2 * Purple is the legal property of its developers, whose names are too numerous
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
3 * to list here. Please refer to the COPYRIGHT file distributed with this
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
4 * source distribution.
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
5 *
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
10 *
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
15 *
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
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
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
19 */
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
20
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
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
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
25 #include "privacy.h"
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
26
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
27 #include "buddy.h"
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
28 #include "google.h"
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
29 #include "jabber.h"
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
30 #include "presence.h"
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
31 #include "iq.h"
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
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
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
160 google_session_candidates_prepared (PurpleMedia *media, 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
161 {
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 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171
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 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
173 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
174 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
175 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
176
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 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
178 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
179
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 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
181
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 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
183 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
184
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 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
186 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
187 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
188 xmlnode_set_attrib(candidate, "username", transport->username);
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, "password", transport->password);
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
190 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
191 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
192 xmlnode_set_attrib(candidate, "type", transport->type == FS_CANDIDATE_TYPE_HOST ? "local" :
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
193 transport->type == FS_CANDIDATE_TYPE_PRFLX ? "stun" :
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
194 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
195 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
196 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
197 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
198
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
199 }
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
200 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
201 }
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
202
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
203 static void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
204 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
205 {
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
206 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
207 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
208 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
209 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
210 const char *id, *encoding_name, *clock_rate;
22648
e286d795c5f9 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22069
diff changeset
211
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
212 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
213 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
214 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
215 }
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
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
217 session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc,
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
218 "fsrtpconference", session->remote_jid);
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
219
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
220 /* "rawudp" will need to be changed to "nice" when libnice is finished */
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26095
diff changeset
221 /* GTalk will require the NICE_COMPATIBILITY_GOOGLE param */
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
222 purple_media_add_stream(session->media, "google-voice", session->remote_jid,
26133
a12ffee5bd73 Add params to purple_media_add_stream to allow for different libNice
Michael Ruprecht <maiku@pidgin.im>
parents: 26095
diff changeset
223 PURPLE_MEDIA_AUDIO, "rawudp", 0, NULL);
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
224
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
225 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
226
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
227 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
228 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
229 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
230 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
231 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
232 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
233
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
234 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
235 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
236 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
237 }
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
238
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
239 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
240
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
251 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
252
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
253 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
254 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
255 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
256 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
257 }
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
258
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
259 static void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
260 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
261 {
19885
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
262 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
263 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
264 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
265 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
266 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
267
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 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
269 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
270 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
271 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
272 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
273 !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
274 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
275 !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
276 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
277 !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
278 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
279 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
280
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
281 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
282 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
283
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
284 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
285 }
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
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
287 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
288 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
289
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
290 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
291 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
292 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
293 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
294 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
295
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
296 static void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
297 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
298 {
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
299 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
300
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
301 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
302 }
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
303
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
304 static void
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
305 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
306 {
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
307 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
308
593613a22e57 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@pidgin.im>
parents: 19882
diff changeset
309 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
310 }
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
311
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
312 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
313 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
314 {
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
315 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
316 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
317
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
318 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
319 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
320 } 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
321 } 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
322 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
323 } 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
324 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
325 } 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
326 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
327 }
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 }
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
329 #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
330
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 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
332 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
333 {
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
334 #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
335 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
336 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
337
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 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
339 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
340
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 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
342 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
343
d8c2a2fc1fbf Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@pidgin.im>
parents: 19046
diff changeset
344 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
345 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
346 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
347
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
348 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
349 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
350 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
351
23697
299bafcd8eb8 Updates voice and video to use Farsight 2, gets XMPP voice conferences
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
352 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
353 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
354 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
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 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
357 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
358 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
359
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 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
361 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
362 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
363 }
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
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 /* 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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378
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);
23700
e47be56bdd2b Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
380 #else
e47be56bdd2b Fix compiling with the --disable-vv switch.
Michael Ruprecht <maiku@pidgin.im>
parents: 23697
diff changeset
381 /* TODO: send proper error response */
23704
9b88c9b23aed Use USE_VV instead of USE_FARSIGHT.
Michael Ruprecht <maiku@pidgin.im>
parents: 23700
diff changeset
382 #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
383 }
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
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
385 static void
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
386 jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
387 {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
388 const char *type = xmlnode_get_attrib(packet, "type");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
389 xmlnode *child;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
390 xmlnode *message, *sender_node, *subject_node;
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
391 const char *from, *to, *url, *tid;
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
392 char *subject;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
393 const char *in_str;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
394 char *to_name;
20097
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
395 char *default_tos[1];
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
396
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
397 int i, count = 1, returned_count;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
398
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
399 const char **tos, **froms, **urls;
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
400 char **subjects;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
401
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
402 if (strcmp(type, "result"))
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
403 return;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
404
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
405 child = xmlnode_get_child(packet, "mailbox");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
406 if (!child)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
407 return;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
408
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
409 in_str = xmlnode_get_attrib(child, "total-matched");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
410 if (in_str && *in_str)
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
411 count = atoi(in_str);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
412
20097
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
413 /* 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
414 to = xmlnode_get_attrib(packet, "to");
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
415 default_tos[0] = jabber_get_bare_jid(to);
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
416
20114
96e715e155e0 applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents: 20107
diff changeset
417 message = xmlnode_get_child(child, "mail-thread-info");
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
418
20114
96e715e155e0 applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents: 20107
diff changeset
419 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
420 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
421 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
422 g_free(default_tos[0]);
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
423 return;
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
424 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
425
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
426 /* Loop once to see how many messages were returned so we can allocate arrays
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
427 * accordingly */
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
428 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message));
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
429
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
430 froms = g_new0(const char* , returned_count);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
431 tos = g_new0(const char* , returned_count);
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
432 subjects = g_new0(char* , returned_count);
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
433 urls = g_new0(const char* , returned_count);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
434
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
435 to = xmlnode_get_attrib(packet, "to");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
436 to_name = jabber_get_bare_jid(to);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
437 url = xmlnode_get_attrib(child, "url");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
438 if (!url || !*url)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
439 url = "http://www.gmail.com";
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
440
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
441 message= xmlnode_get_child(child, "mail-thread-info");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
442 for (i=0; message; message = xmlnode_get_next_twin(message), i++) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
443 subject_node = xmlnode_get_child(message, "subject");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
444 sender_node = xmlnode_get_child(message, "senders");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
445 sender_node = xmlnode_get_child(sender_node, "sender");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
446
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
447 while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") ||
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
448 !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0")))
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
449 sender_node = xmlnode_get_next_twin(sender_node);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
450
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
451 if (!sender_node) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
452 i--;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
453 continue;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
454 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
455
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
456 from = xmlnode_get_attrib(sender_node, "name");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
457 if (!from || !*from)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
458 from = xmlnode_get_attrib(sender_node, "address");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
459 subject = xmlnode_get_data(subject_node);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
460 /*
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
461 * url = xmlnode_get_attrib(message, "url");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
462 */
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
463 tos[i] = (to_name != NULL ? to_name : "");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
464 froms[i] = (from != NULL ? from : "");
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
465 subjects[i] = (subject != NULL ? subject : g_strdup(""));
20225
684334efdc19 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20209
diff changeset
466 urls[i] = url;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
467
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
468 tid = xmlnode_get_attrib(message, "tid");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
469 if (tid &&
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
470 (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
471 g_free(js->gmail_last_tid);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
472 js->gmail_last_tid = g_strdup(tid);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
473 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
474 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
475
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
476 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
477 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos,
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
478 urls, NULL, NULL);
20114
96e715e155e0 applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents: 20107
diff changeset
479 else
20107
c2fafb2681d1 applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@pidgin.im>
parents: 20097
diff changeset
480 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
481
15261
109ac4fcc3e7 [gaim-migrate @ 17989]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
482
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
483 g_free(to_name);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
484 g_free(tos);
20097
f5bef80db09e applied changes from 19e3744fd4b392cdc631c9efe0ce658537070713
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
485 g_free(default_tos[0]);
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
486 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
487 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
488 g_free(subjects[i - 1]);
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
489 g_free(subjects);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
490 g_free(urls);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
491
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
492 in_str = xmlnode_get_attrib(child, "result-time");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
493 if (in_str && *in_str) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
494 g_free(js->gmail_last_time);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
495 js->gmail_last_time = g_strdup(in_str);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
496 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
497 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
498
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
499 void
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
500 jabber_gmail_poke(JabberStream *js, xmlnode *packet)
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
501 {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
502 const char *type;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
503 xmlnode *query;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
504 JabberIq *iq;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
505
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
506 /* bail if the user isn't interested */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
507 if (!purple_account_get_check_mail(js->gc->account))
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
508 return;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
509
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
510 type = xmlnode_get_attrib(packet, "type");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
511
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
512
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
513 /* Is this an initial incoming mail notification? If so, send a request for more info */
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
514 if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail"))
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
515 return;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
516
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
517 purple_debug(PURPLE_DEBUG_MISC, "jabber",
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
518 "Got new mail notification. Sending request for more info\n");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
519
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
520 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
521 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
522 query = xmlnode_get_child(iq->node, "query");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
523
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
524 if (js->gmail_last_time)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
525 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
526 if (js->gmail_last_tid)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
527 xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
528
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
529 jabber_iq_send(iq);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
530 return;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
531 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
532
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
533 void jabber_gmail_init(JabberStream *js) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
534 JabberIq *iq;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
535
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
536 if (!purple_account_get_check_mail(js->gc->account))
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
537 return;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
538
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
539 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
540 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
541 jabber_iq_send(iq);
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
542 }
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
543
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
544 void jabber_google_roster_init(JabberStream *js)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
545 {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
546 JabberIq *iq;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
547 xmlnode *query;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
548
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
549 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
550 query = xmlnode_get_child(iq->node, "query");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
551
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
552 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
553 xmlnode_set_attrib(query, "gr:ext", "2");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
554
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
555 jabber_iq_send(iq);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
556 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
557
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
558 void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
559 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
560 PurpleAccount *account = purple_connection_get_account(js->gc);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
561 GSList *list = account->deny;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
562 const char *jid = xmlnode_get_attrib(item, "jid");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
563 char *jid_norm = g_strdup(jabber_normalize(account, jid));
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
564
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
565 while (list) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
566 if (!strcmp(jid_norm, (char*)list->data)) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
567 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
568 xmlnode_set_attrib(item, "gr:t", "B");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
569 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
570 xmlnode_set_attrib(query, "gr:ext", "2");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
571 return;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
572 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
573 list = list->next;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
574 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
575
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
576 g_free(jid_norm);
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
577
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
578 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
579
15530
9355a1be068e Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
580 gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item)
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
581 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
582 PurpleAccount *account = purple_connection_get_account(js->gc);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
583 GSList *list = account->deny;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
584 const char *jid = xmlnode_get_attrib(item, "jid");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
585 gboolean on_block_list = FALSE;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
586
20209
c1bbdde1f373 applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20186
diff changeset
587 char *jid_norm;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
588
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
589 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
590 const char *subscription = xmlnode_get_attrib(item, "subscription");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
591
17327
c0ba0055387a This should be better
Sean Egan <seanegan@pidgin.im>
parents: 17322
diff changeset
592 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
593 /* 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
594 * 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
595 */
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
596 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
597 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
598
20209
c1bbdde1f373 applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20186
diff changeset
599 jid_norm = g_strdup(jabber_normalize(account, jid));
c1bbdde1f373 applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20186
diff changeset
600
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
601 while (list) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
602 if (!strcmp(jid_norm, (char*)list->data)) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
603 on_block_list = TRUE;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
604 break;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
605 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
606 list = list->next;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
607 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
608
15530
9355a1be068e Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
609 if (grt && (*grt == 'H' || *grt == 'h')) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
610 PurpleBuddy *buddy = purple_find_buddy(account, jid_norm);
20114
96e715e155e0 applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents: 20107
diff changeset
611 if (buddy)
96e715e155e0 applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@pidgin.im>
parents: 20107
diff changeset
612 purple_blist_remove_buddy(buddy);
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
613 g_free(jid_norm);
15530
9355a1be068e Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
614 return FALSE;
9355a1be068e Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
615 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
616
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
617 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
618 purple_debug_info("jabber", "Blocking %s\n", jid_norm);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
619 purple_privacy_deny_add(account, jid_norm, TRUE);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
620 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
621 purple_debug_info("jabber", "Unblocking %s\n", jid_norm);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
622 purple_privacy_deny_remove(account, jid_norm, TRUE);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
623 }
18739
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
624
3cd45d53cf26 Various leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents: 18233
diff changeset
625 g_free(jid_norm);
15530
9355a1be068e Make deleting Google Talk buddies work
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
626 return TRUE;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
627 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
628
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
629 void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who)
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
630 {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
631 JabberStream *js;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
632 GSList *buddies;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
633 JabberIq *iq;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
634 xmlnode *query;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
635 xmlnode *item;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
636 xmlnode *group;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
637 PurpleBuddy *b;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
638 JabberBuddy *jb;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
639
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
640 js = (JabberStream*)(gc->proto_data);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
641
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
642 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
643 return;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
644
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
645 jb = jabber_buddy_find(js, who, TRUE);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
646
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
647 buddies = purple_find_buddies(js->gc->account, who);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
648 if(!buddies)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
649 return;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
650
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
651 b = buddies->data;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
652
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
653 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
654
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
655 query = xmlnode_get_child(iq->node, "query");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
656 item = xmlnode_new_child(query, "item");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
657
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
658 while(buddies) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
659 PurpleGroup *g;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
660
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
661 b = buddies->data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
662 g = purple_buddy_get_group(b);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
663
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
664 group = xmlnode_new_child(item, "group");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
665 xmlnode_insert_data(group, g->name, -1);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
666
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
667 buddies = buddies->next;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
668 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
669
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
670 xmlnode_set_attrib(item, "jid", who);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
671 xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
672 xmlnode_set_attrib(item, "gr:t", "B");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
673 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
674 xmlnode_set_attrib(query, "gr:ext", "2");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
675
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
676 jabber_iq_send(iq);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
677
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
678 /* Synthesize a sign-off */
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
679 if (jb) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
680 JabberBuddyResource *jbr;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
681 GList *l = jb->resources;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
682 while (l) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
683 jbr = l->data;
15346
ef48613b5b9b [gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents: 15265
diff changeset
684 if (jbr && jbr->name)
ef48613b5b9b [gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents: 15265
diff changeset
685 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
686 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
687 jabber_buddy_remove_resource(jb, jbr->name);
ef48613b5b9b [gaim-migrate @ 18074]
Evan Schoenberg <evands@pidgin.im>
parents: 15265
diff changeset
688 }
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
689 l = l->next;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
690 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
691 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
692 purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
693 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
694
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
695 void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
696 {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
697 JabberStream *js;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
698 GSList *buddies;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
699 JabberIq *iq;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
700 xmlnode *query;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
701 xmlnode *item;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
702 xmlnode *group;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
703 PurpleBuddy *b;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
704
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
705 g_return_if_fail(gc != NULL);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
706 g_return_if_fail(who != NULL);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
707
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
708 js = (JabberStream*)(gc->proto_data);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
709
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
710 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
711 return;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
712
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
713 buddies = purple_find_buddies(js->gc->account, who);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
714 if(!buddies)
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
715 return;
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
716
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
717 b = buddies->data;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
718
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
719 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
720
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
721 query = xmlnode_get_child(iq->node, "query");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
722 item = xmlnode_new_child(query, "item");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
723
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
724 while(buddies) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
725 PurpleGroup *g;
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
726
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
727 b = buddies->data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15587
diff changeset
728 g = purple_buddy_get_group(b);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
729
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
730 group = xmlnode_new_child(item, "group");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
731 xmlnode_insert_data(group, g->name, -1);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
732
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
733 buddies = buddies->next;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
734 }
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
735
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
736 xmlnode_set_attrib(item, "jid", who);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
737 xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
738 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
739 xmlnode_set_attrib(query, "gr:ext", "2");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
740
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
741 jabber_iq_send(iq);
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
742
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
743 /* See if he's online */
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
744 jabber_presence_subscription_set(js, who, "probe");
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15261
diff changeset
745 }
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
746
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
747 /* 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
748 * 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
749 * 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
750 * 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
751 * 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
752 */
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
753 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
754 {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
755 const char *p;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
756
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
757 /* 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
758 gboolean preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
759
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
760 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
761 gboolean in_tag = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
762
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
763 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
764
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
765 GString *str;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
766
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
767 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
768 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
769 if (c == '*' && !in_tag) {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
770 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
771 *(p+1) == '\0' ||
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
772 *(p+1) == '<')) {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
773 bold_count++;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
774 in_bold = FALSE;
16988
1aaf51bf0f23 Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents: 15884
diff changeset
775 } 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
776 bold_count++;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
777 in_bold = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
778 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
779 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
780 } 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
781 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
782 *(p+1) == '\0' ||
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
783 *(p+1) == '<')) {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
784 italic_count++;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
785 in_italic = FALSE;
16988
1aaf51bf0f23 Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents: 15884
diff changeset
786 } 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
787 italic_count++;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
788 in_italic = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
789 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
790 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
791 } 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
792 in_tag = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
793 } 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
794 in_tag = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
795 } else if (!in_tag) {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
796 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
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
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
799 preceding_space = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
800 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
801 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
802
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
803 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
804 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
805 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
806
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
807 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
808 gunichar c = g_utf8_get_char(p);
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
809
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
810 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
811 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
812 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
813 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
814
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
815
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
816 if (c == '*' && !in_tag) {
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
817 if (in_bold &&
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
818 (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
819 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
820 in_bold = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
821 bold_count--;
16988
1aaf51bf0f23 Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents: 15884
diff changeset
822 } 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
823 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
824 bold_count--;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
825 in_bold = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
826 } else {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
827 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
828 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
829 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
830 } 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
831 if (in_italic &&
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
832 (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
833 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
834 italic_count--;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
835 in_italic = FALSE;
16988
1aaf51bf0f23 Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@pidgin.im>
parents: 15884
diff changeset
836 } 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
837 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
838 italic_count--;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
839 in_italic = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
840 } else {
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_unichar(str, c);
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
842 }
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
843 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
844 } 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
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 in_tag = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
847 } 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
848 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
849 in_tag = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
850 } else if (!in_tag) {
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_unichar(str, c);
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
852 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
853 preceding_space = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
854 else
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
855 preceding_space = FALSE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
856 } else {
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
857 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
858 }
18233
32e258000a57 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17327
diff changeset
859 }
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15530
diff changeset
860 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
861 }
21195
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
862
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
863 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
864 {
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
865 if (!js->googletalk)
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
866 return;
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
867 if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) {
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
868 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
869 PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL);
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
870 jbr->status = NULL;
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
871 } else {
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
872 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
873 }
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
874 }
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
875
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
876 char *jabber_google_presence_outgoing(PurpleStatus *tune)
fd63ef5027d7 Music support for Google Talk
Sean Egan <seanegan@pidgin.im>
parents: 20107
diff changeset
877 {
21714
5956ea2cb4af don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@pidgin.im>
parents: 21204
diff changeset
878 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
879 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
880 }

mercurial