annotate libpurple/protocols/jabber/google.c @ 26006:d703474d6b81

Fix a GLib warning when add_stream fails in google.c. Thanks to mlundblad for finding it.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Wed, 07 Jan 2009 20:18:44 +0000
parents f671d406f62c
children 0605c1121613
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
2 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18751
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "debug.h"
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
23 #include "mediamanager.h"
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
24 #include "util.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "privacy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "google.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "jabber.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "presence.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
23804
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23800
diff changeset
33 #ifdef USE_VV
23800
4b9b265a8100 Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23797
diff changeset
34 #include <gst/farsight/fs-conference-iface.h>
4b9b265a8100 Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23797
diff changeset
35
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
36 typedef struct {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
37 char *id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
38 char *initiator;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
39 } GoogleSessionId;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
40
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
41 typedef enum {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
42 UNINIT,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
43 SENT_INITIATE,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
44 RECEIVED_INITIATE,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
45 IN_PRORESS,
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
46 TERMINATED
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
47 } GoogleSessionState;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
48
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
49 typedef struct {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
50 GoogleSessionId id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
51 GoogleSessionState state;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
52 PurpleMedia *media;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
53 JabberStream *js;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
54 char *remote_jid;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
55 } GoogleSession;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
56
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
57 GHashTable *sessions = NULL;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
58
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
59 static guint
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
60 google_session_id_hash(gconstpointer key)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
61 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
62 GoogleSessionId *id = (GoogleSessionId*)key;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
63
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
64 guint id_hash = g_str_hash(id->id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
65 guint init_hash = g_str_hash(id->initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
66
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
67 return 23 * id_hash + init_hash;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
68 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
69
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
70 static gboolean
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
71 google_session_id_equal(gconstpointer a, gconstpointer b)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
72 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
73 GoogleSessionId *c = (GoogleSessionId*)a;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
74 GoogleSessionId *d = (GoogleSessionId*)b;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
75
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
76 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
77 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
78
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
79 static void
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
80 google_session_destroy(GoogleSession *session)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
81 {
26006
d703474d6b81 Fix a GLib warning when add_stream fails in google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26001
diff changeset
82 if (sessions != NULL)
d703474d6b81 Fix a GLib warning when add_stream fails in google.c.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26001
diff changeset
83 g_hash_table_remove(sessions, &(session->id));
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
84 g_free(session->id.id);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
85 g_free(session->id.initiator);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
86 g_free(session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
87 g_free(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
88 }
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
89
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
90 static xmlnode *
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
91 google_session_create_xmlnode(GoogleSession *session, const char *type)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
92 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
93 xmlnode *node = xmlnode_new("session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
94 xmlnode_set_namespace(node, "http://www.google.com/session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
95 xmlnode_set_attrib(node, "id", session->id.id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
96 xmlnode_set_attrib(node, "initiator", session->id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
97 xmlnode_set_attrib(node, "type", type);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
98 return node;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
99 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
100
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
101 static void
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
102 google_session_send_accept(GoogleSession *session)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
103 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
104 xmlnode *sess, *desc, *payload;
24960
a5f1804fcb4b Combine get_*_codecs functions to mirror Farsight 2.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24933
diff changeset
105 GList *codecs = purple_media_get_codecs(session->media, "google-voice");
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
106 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
107
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
108 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
109 sess = google_session_create_xmlnode(session, "accept");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
110 xmlnode_insert_child(iq->node, sess);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
111 desc = xmlnode_new_child(sess, "description");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
112 xmlnode_set_namespace(desc, "http://www.google.com/session/phone");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
113
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
114 for (;codecs; codecs = codecs->next) {
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
115 FsCodec *codec = (FsCodec*)codecs->data;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
116 char id[8], clockrate[10];
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
117 payload = xmlnode_new_child(desc, "payload-type");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
118 g_snprintf(id, sizeof(id), "%d", codec->id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
119 g_snprintf(clockrate, sizeof(clockrate), "%d", codec->clock_rate);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
120 xmlnode_set_attrib(payload, "name", codec->encoding_name);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
121 xmlnode_set_attrib(payload, "id", id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
122 xmlnode_set_attrib(payload, "clockrate", clockrate);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
123 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
124
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
125 fs_codec_list_destroy(codecs);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
126 jabber_iq_send(iq);
23821
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23804
diff changeset
127 gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_PLAYING);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
128 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
129
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
130 static void
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
131 google_session_send_terminate(GoogleSession *session)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
132 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
133 xmlnode *sess;
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
134 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
135
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
136 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
137 sess = google_session_create_xmlnode(session, "terminate");
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
138 xmlnode_insert_child(iq->node, sess);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
139
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
140 jabber_iq_send(iq);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
141 google_session_destroy(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
142 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
143
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
144 static void
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
145 google_session_send_reject(GoogleSession *session)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
146 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
147 xmlnode *sess;
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
148 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
149
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
150 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
151 sess = google_session_create_xmlnode(session, "reject");
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
152 xmlnode_insert_child(iq->node, sess);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
153
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
154 jabber_iq_send(iq);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
155 google_session_destroy(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
156 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
157
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
158
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
159 static void
24964
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
160 google_session_candidates_prepared (PurpleMedia *media, gchar *session_id,
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
161 gchar *participant, GoogleSession *session)
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
162 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
163 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
23821
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23804
diff changeset
164 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice",
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23804
diff changeset
165 session->remote_jid);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
166 FsCandidate *transport;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
167 xmlnode *sess;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
168 xmlnode *candidate;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
169 sess = google_session_create_xmlnode(session, "candidates");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
170 xmlnode_insert_child(iq->node, sess);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
171 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
172
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
173 for (;candidates;candidates = candidates->next) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
174 char port[8];
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
175 char pref[8];
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
176 transport = (FsCandidate*)(candidates->data);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
177
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
178 if (!strcmp(transport->ip, "127.0.0.1"))
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
179 continue;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
180
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
181 candidate = xmlnode_new("candidate");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
182
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
183 g_snprintf(port, sizeof(port), "%d", transport->port);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
184 g_snprintf(pref, sizeof(pref), "%d", transport->priority);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
185
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
186 xmlnode_set_attrib(candidate, "address", transport->ip);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
187 xmlnode_set_attrib(candidate, "port", port);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
188 xmlnode_set_attrib(candidate, "name", "rtp");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
189 xmlnode_set_attrib(candidate, "username", transport->username);
25001
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
190 /*
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
191 * As of this writing, Farsight 2 in Google compatibility
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
192 * mode doesn't provide a password. The Gmail client
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
193 * requires this to be set.
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
194 */
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
195 xmlnode_set_attrib(candidate, "password",
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
196 transport->password != NULL ?
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
197 transport->password : "");
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
198 xmlnode_set_attrib(candidate, "preference", pref);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
199 xmlnode_set_attrib(candidate, "protocol", transport->proto == FS_NETWORK_PROTOCOL_UDP ? "udp" : "tcp");
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
200 xmlnode_set_attrib(candidate, "type", transport->type == FS_CANDIDATE_TYPE_HOST ? "local" :
25001
2a1873a30474 Fix receiving voice calls from Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24999
diff changeset
201 transport->type == FS_CANDIDATE_TYPE_SRFLX ? "stun" :
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
202 transport->type == FS_CANDIDATE_TYPE_RELAY ? "relay" : NULL);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
203 xmlnode_set_attrib(candidate, "generation", "0");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
204 xmlnode_set_attrib(candidate, "network", "0");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
205 xmlnode_insert_child(sess, candidate);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
206
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
207 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
208 jabber_iq_send(iq);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
209 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
210
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
211 static void
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
212 google_session_ready(PurpleMedia *media, gchar *id,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
213 gchar *participant, GoogleSession *session)
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
214 {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
215 if (id == NULL && participant == NULL) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
216 gchar *me = g_strdup_printf("%s@%s/%s",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
217 session->js->user->node,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
218 session->js->user->domain,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
219 session->js->user->resource);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
220 if (!strcmp(session->id.initiator, me)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
221 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
26001
f671d406f62c Remove unused variable.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25006
diff changeset
222 xmlnode *sess, *desc, *payload;
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
223 GList *codecs, *iter;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
224
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
225 sess = google_session_create_xmlnode(session, "initiate");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
226 xmlnode_insert_child(iq->node, sess);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
227 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
228 xmlnode_set_attrib(iq->node, "from", session->id.initiator);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
229 desc = xmlnode_new_child(sess, "description");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
230 xmlnode_set_namespace(desc, "http://www.google.com/session/phone");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
231
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
232 codecs = purple_media_get_codecs(media, "google-voice");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
233
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
234 for (iter = codecs; iter; iter = g_list_next(iter)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
235 FsCodec *codec = (FsCodec*)iter->data;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
236 gchar *id = g_strdup_printf("%d", codec->id);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
237 gchar *clock_rate = g_strdup_printf("%d", codec->clock_rate);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
238 payload = xmlnode_new_child(desc, "payload-type");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
239 xmlnode_set_attrib(payload, "id", id);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
240 xmlnode_set_attrib(payload, "name", codec->encoding_name);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
241 xmlnode_set_attrib(payload, "clockrate", clock_rate);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
242 g_free(clock_rate);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
243 g_free(id);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
244 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
245 fs_codec_list_destroy(codecs);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
246
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
247 jabber_iq_send(iq);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
248
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
249 google_session_candidates_prepared(session->media,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
250 "google-voice", session->remote_jid, session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
251 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
252 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
253 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
254
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
255 PurpleMedia*
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
256 jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
257 {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
258 GoogleSession *session;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
259 JabberBuddy *jb;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
260 JabberBuddyResource *jbr;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
261 gchar *jid;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
262 GParameter param;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
263
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
264 /* construct JID to send to */
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
265 jb = jabber_buddy_find(js, who, FALSE);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
266 if (!jb) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
267 purple_debug_error("jingle-rtp",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
268 "Could not find Jabber buddy\n");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
269 return NULL;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
270 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
271 jbr = jabber_buddy_find_resource(jb, NULL);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
272 if (!jbr) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
273 purple_debug_error("jingle-rtp",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
274 "Could not find buddy's resource\n");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
275 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
276
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
277 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
278 jid = g_strdup_printf("%s/%s", who, jbr->name);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
279 } else {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
280 jid = g_strdup(who);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
281 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
282
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
283 session = g_new0(GoogleSession, 1);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
284 session->id.id = jabber_get_next_id(js);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
285 session->id.initiator = g_strdup_printf("%s@%s/%s", js->user->node,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
286 js->user->domain, js->user->resource);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
287 session->state = SENT_INITIATE;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
288 session->js = js;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
289 session->remote_jid = jid;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
290
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
291 session->media = purple_media_manager_create_media(
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
292 purple_media_manager_get(), js->gc,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
293 "fsrtpconference", session->remote_jid, TRUE);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
294
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
295 /* GTalk requires the NICE_COMPATIBILITY_GOOGLE param */
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
296 param.name = "compatibility-mode";
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
297 memset(&param.value, 0, sizeof(GValue));
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
298 g_value_init(&param.value, G_TYPE_UINT);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
299 g_value_set_uint(&param.value, 1); /* NICE_COMPATIBILITY_GOOGLE */
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
300
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
301 if (purple_media_add_stream(session->media, "google-voice",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
302 session->remote_jid, PURPLE_MEDIA_AUDIO,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
303 "nice", 1, &param) == FALSE) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
304 purple_media_error(session->media, "Error adding stream.");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
305 purple_media_hangup(session->media);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
306 google_session_destroy(session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
307 return NULL;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
308 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
309
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
310 g_signal_connect(G_OBJECT(session->media), "ready-new",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
311 G_CALLBACK(google_session_ready), session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
312 g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
313 G_CALLBACK(google_session_send_accept), session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
314 g_signal_connect_swapped(G_OBJECT(session->media), "reject",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
315 G_CALLBACK(google_session_send_reject), session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
316 g_signal_connect_swapped(G_OBJECT(session->media), "hangup",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
317 G_CALLBACK(google_session_send_terminate), session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
318 purple_media_ready(session->media);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
319
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
320 if (sessions == NULL)
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
321 sessions = g_hash_table_new(google_session_id_hash,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
322 google_session_id_equal);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
323 g_hash_table_insert(sessions, &(session->id), session);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
324
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
325 return session->media;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
326 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
327
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
328 static void
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
329 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
330 {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
331 JabberIq *result;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
332 GList *codecs = NULL;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
333 xmlnode *desc_element, *codec_element;
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
334 FsCodec *codec;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
335 const char *id, *encoding_name, *clock_rate;
24964
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
336 GParameter param;
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23769
diff changeset
337
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
338 if (session->state != UNINIT) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
339 purple_debug_error("jabber", "Received initiate for active session.\n");
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
340 return;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
341 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
342
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
343 session->media = purple_media_manager_create_media(purple_media_manager_get(), js->gc,
24987
c7d4b67b3332 Add initiator property to PurpleMedia.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24964
diff changeset
344 "fsrtpconference", session->remote_jid, FALSE);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
345
24964
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
346 /* GTalk requires the NICE_COMPATIBILITY_GOOGLE param */
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
347 param.name = "compatibility-mode";
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
348 memset(&param.value, 0, sizeof(GValue));
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
349 g_value_init(&param.value, G_TYPE_UINT);
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
350 g_value_set_uint(&param.value, 1); /* NICE_COMPATIBILITY_GOOGLE */
0101d6e97f12 Very basic receive only GTalk audio sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24960
diff changeset
351
24999
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
352 if (purple_media_add_stream(session->media, "google-voice", session->remote_jid,
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
353 PURPLE_MEDIA_AUDIO, "nice", 1, &param) == FALSE) {
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
354 purple_media_error(session->media, "Error adding stream.");
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
355 purple_media_hangup(session->media);
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
356 google_session_send_terminate(session);
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
357 return;
f45301cc2c84 End google call if stream creation fails.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24987
diff changeset
358 }
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
359
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
360 desc_element = xmlnode_get_child(sess, "description");
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
361
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
362 for (codec_element = xmlnode_get_child(desc_element, "payload-type");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
363 codec_element;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
364 codec_element = xmlnode_get_next_twin(codec_element)) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
365 encoding_name = xmlnode_get_attrib(codec_element, "name");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
366 id = xmlnode_get_attrib(codec_element, "id");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
367 clock_rate = xmlnode_get_attrib(codec_element, "clockrate");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
368
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
369 codec = fs_codec_new(atoi(id), encoding_name, FS_MEDIA_TYPE_AUDIO,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
370 clock_rate ? atoi(clock_rate) : 0);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
371 codecs = g_list_append(codecs, codec);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
372 }
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
373
23821
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23804
diff changeset
374 purple_media_set_remote_codecs(session->media, "google-voice", session->remote_jid, codecs);
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
375
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
376 g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
377 G_CALLBACK(google_session_send_accept), session);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
378 g_signal_connect_swapped(G_OBJECT(session->media), "reject",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
379 G_CALLBACK(google_session_send_reject), session);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
380 g_signal_connect_swapped(G_OBJECT(session->media), "hangup",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
381 G_CALLBACK(google_session_send_terminate), session);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
382 g_signal_connect(G_OBJECT(session->media), "candidates-prepared",
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
383 G_CALLBACK(google_session_candidates_prepared), session);
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
384 purple_media_ready(session->media);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
385
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
386 fs_codec_list_destroy(codecs);
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
387
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
388 result = jabber_iq_new(js, JABBER_IQ_RESULT);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
389 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
390 xmlnode_set_attrib(result->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
391 jabber_iq_send(result);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
392 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
393
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
394 static void
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
395 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
396 {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
397 JabberIq *result;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
398 GList *list = NULL;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
399 xmlnode *cand;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
400 static int name = 0;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
401 char n[4];
23787
92e71f6e10d4 Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23769
diff changeset
402
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
403 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) {
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
404 FsCandidate *info;
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
405 g_snprintf(n, sizeof(n), "S%d", name++);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
406 info = fs_candidate_new(n, FS_COMPONENT_RTP, !strcmp(xmlnode_get_attrib(cand, "type"), "local") ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
407 FS_CANDIDATE_TYPE_HOST :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
408 !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
409 FS_CANDIDATE_TYPE_PRFLX :
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
410 !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
411 FS_CANDIDATE_TYPE_RELAY : FS_CANDIDATE_TYPE_HOST,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
412 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ?
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
413 FS_NETWORK_PROTOCOL_UDP : FS_NETWORK_PROTOCOL_TCP,
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
414 xmlnode_get_attrib(cand, "address"), atoi(xmlnode_get_attrib(cand, "port")));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
415
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
416 info->username = g_strdup(xmlnode_get_attrib(cand, "username"));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
417 info->password = g_strdup(xmlnode_get_attrib(cand, "password"));
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
418
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
419 list = g_list_append(list, info);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
420 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
421
23821
12a16471f94e Refactored PurpleMedia to make creating audio or video sessions virtually identical. Audio, video, and audio/video sessions now work. Also added videotestsrc to the video plugin preference.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23804
diff changeset
422 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list);
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
423 fs_candidate_list_destroy(list);
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
424
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
425 result = jabber_iq_new(js, JABBER_IQ_RESULT);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
426 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
427 xmlnode_set_attrib(result->node, "to", session->remote_jid);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
428 jabber_iq_send(result);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
429 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
430
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
431 static void
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
432 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
433 {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
434 xmlnode *desc_element = xmlnode_get_child(sess, "description");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
435 xmlnode *codec_element = xmlnode_get_child(desc_element, "payload-type");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
436 GList *codecs = NULL;
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
437
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
438 for (; codec_element; codec_element =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
439 xmlnode_get_next_twin(codec_element)) {
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
440 const gchar *encoding_name =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
441 xmlnode_get_attrib(codec_element, "name");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
442 const gchar *id = xmlnode_get_attrib(codec_element, "id");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
443 const gchar *clock_rate =
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
444 xmlnode_get_attrib(codec_element, "clockrate");
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
445
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
446 FsCodec *codec = fs_codec_new(atoi(id), encoding_name,
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
447 FS_MEDIA_TYPE_AUDIO, clock_rate ?
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
448 atoi(clock_rate) : 0);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
449 codecs = g_list_append(codecs, codec);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
450 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
451
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
452 purple_media_set_remote_codecs(session->media, "google-voice",
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
453 session->remote_jid, codecs);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
454
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
455 purple_media_got_accept(session->media);
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
456 }
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
457
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
458 static void
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
459 google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
460 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
461 purple_media_got_hangup(session->media);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
462
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
463 google_session_destroy(session);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
464 }
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
465
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
466 static void
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
467 google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
468 {
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
469 purple_media_got_hangup(session->media);
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
470
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
471 google_session_destroy(session);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
472 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
473
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
474 static void
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
475 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *packet)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
476 {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
477 xmlnode *sess = xmlnode_get_child(packet, "session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
478 const char *type = xmlnode_get_attrib(sess, "type");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
479
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
480 if (!strcmp(type, "initiate")) {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
481 google_session_handle_initiate(js, session, packet, sess);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
482 } else if (!strcmp(type, "accept")) {
25005
44a528094cbf Support initiating voice calls to GTalk and Gmail.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 25001
diff changeset
483 google_session_handle_accept(js, session, packet, sess);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
484 } else if (!strcmp(type, "reject")) {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
485 google_session_handle_reject(js, session, packet, sess);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
486 } else if (!strcmp(type, "terminate")) {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
487 google_session_handle_terminate(js, session, packet, sess);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
488 } else if (!strcmp(type, "candidates")) {
23762
70cdff43ec76 You can actually receive Google Talk voice calls with crappy UI now
Sean Egan <seanegan@gmail.com>
parents: 23759
diff changeset
489 google_session_handle_candidates(js, session, packet, sess);
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
490 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
491 }
23804
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23800
diff changeset
492 #endif /* USE_VV */
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
493
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
494 void
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
495 jabber_google_session_parse(JabberStream *js, xmlnode *packet)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
496 {
23804
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23800
diff changeset
497 #ifdef USE_VV
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
498 GoogleSession *session;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
499 GoogleSessionId id;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
500
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
501 xmlnode *session_node;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
502 xmlnode *desc_node;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
503
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
504 if (strcmp(xmlnode_get_attrib(packet, "type"), "set"))
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
505 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
506
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
507 session_node = xmlnode_get_child(packet, "session");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
508 if (!session_node)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
509 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
510
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
511 id.id = (gchar*)xmlnode_get_attrib(session_node, "id");
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
512 if (!id.id)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
513 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
514
23797
e1c8ec1259de Updates voice and video to use Farsight 2, gets XMPP voice conferences
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23787
diff changeset
515 id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator");
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
516 if (!id.initiator)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
517 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
518
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
519 if (sessions == NULL)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
520 sessions = g_hash_table_new(google_session_id_hash, google_session_id_equal);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
521 session = (GoogleSession*)g_hash_table_lookup(sessions, &id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
522
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
523 if (session) {
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
524 google_session_parse_iq(js, session, packet);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
525 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
526 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
527
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
528 /* If the session doesn't exist, this has to be an initiate message */
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
529 if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate"))
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
530 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
531 desc_node = xmlnode_get_child(session_node, "description");
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
532 if (!desc_node)
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
533 return;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
534 session = g_new0(GoogleSession, 1);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
535 session->id.id = g_strdup(id.id);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
536 session->id.initiator = g_strdup(id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
537 session->state = UNINIT;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
538 session->js = js;
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
539 session->remote_jid = g_strdup(session->id.initiator);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
540 g_hash_table_insert(sessions, &(session->id), session);
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
541
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
542 google_session_parse_iq(js, session, packet);
23800
4b9b265a8100 Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23797
diff changeset
543 #else
4b9b265a8100 Fix compiling with the --disable-vv switch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23797
diff changeset
544 /* TODO: send proper error response */
23804
cbe97caec684 Use USE_VV instead of USE_FARSIGHT.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 23800
diff changeset
545 #endif /* USE_VV */
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
546 }
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18751
diff changeset
547
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
548 static void
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 const char *type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 xmlnode *child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 xmlnode *message, *sender_node, *subject_node;
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
554 const char *from, *to, *url, *tid;
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
555 char *subject;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 const char *in_str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 char *to_name;
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
558 char *default_tos[1];
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
559
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 int i, count = 1, returned_count;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
561
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
562 const char **tos, **froms, **urls;
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
563 char **subjects;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
564
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 if (strcmp(type, "result"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
567
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 child = xmlnode_get_child(packet, "mailbox");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 if (!child)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 in_str = xmlnode_get_attrib(child, "total-matched");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
573 if (in_str && *in_str)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 count = atoi(in_str);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
575
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
576 /* If Gmail doesn't tell us who the mail is to, let's use our JID */
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
577 to = xmlnode_get_attrib(packet, "to");
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
578 default_tos[0] = jabber_get_bare_jid(to);
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
579
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
580 message = xmlnode_get_child(child, "mail-thread-info");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
582 if (count == 0 || !message) {
20281
d41907afb521 Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents: 20218
diff changeset
583 if (count > 0)
d41907afb521 Don't display mail notifications for 0 new emails in Google Talk
Evan Schoenberg <evan.s@dreskin.net>
parents: 20218
diff changeset
584 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
585 g_free(default_tos[0]);
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
586 return;
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
587 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
588
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 /* Loop once to see how many messages were returned so we can allocate arrays
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 * accordingly */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message));
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
592
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 froms = g_new0(const char* , returned_count);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 tos = g_new0(const char* , returned_count);
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
595 subjects = g_new0(char* , returned_count);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 urls = g_new0(const char* , returned_count);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
597
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 to = xmlnode_get_attrib(packet, "to");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 to_name = jabber_get_bare_jid(to);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 url = xmlnode_get_attrib(child, "url");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 if (!url || !*url)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 url = "http://www.gmail.com";
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
603
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 message= xmlnode_get_child(child, "mail-thread-info");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 for (i=0; message; message = xmlnode_get_next_twin(message), i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 subject_node = xmlnode_get_child(message, "subject");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 sender_node = xmlnode_get_child(message, "senders");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 sender_node = xmlnode_get_child(sender_node, "sender");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
610 while (sender_node && (!xmlnode_get_attrib(sender_node, "unread") ||
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 !strcmp(xmlnode_get_attrib(sender_node, "unread"),"0")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 sender_node = xmlnode_get_next_twin(sender_node);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
613
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 if (!sender_node) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 i--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
618
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 from = xmlnode_get_attrib(sender_node, "name");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 if (!from || !*from)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 from = xmlnode_get_attrib(sender_node, "address");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 subject = xmlnode_get_data(subject_node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 * url = xmlnode_get_attrib(message, "url");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 tos[i] = (to_name != NULL ? to_name : "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 froms[i] = (from != NULL ? from : "");
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
628 subjects[i] = (subject != NULL ? subject : g_strdup(""));
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20317
diff changeset
629 urls[i] = url;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
630
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 tid = xmlnode_get_attrib(message, "tid");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
632 if (tid &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 (js->gmail_last_tid == NULL || strcmp(tid, js->gmail_last_tid) > 0)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 g_free(js->gmail_last_tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 js->gmail_last_tid = g_strdup(tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
639 if (i>0)
18492
94c23019a864 Only display the "detailed" email notifications for gtalk if we really have all the details to show. Fixes #1813.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18491
diff changeset
640 purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos,
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
641 urls, NULL, NULL);
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
642 else
20211
a5d366d614f5 applied changes from 606266f42c25624ce35e54483778d855641806be
Richard Laager <rlaager@wiktel.com>
parents: 20169
diff changeset
643 purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
644
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 g_free(to_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 g_free(tos);
20169
575d8c84ccba Show when Gmail count falls, instead of only when it rises. Fixes #1462
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
648 g_free(default_tos[0]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 g_free(froms);
18751
0580b246b2c5 Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18492
diff changeset
650 for (; i > 0; i--)
0580b246b2c5 Fix a stupid crash (that I introduced) that occurs when parsing gmail notifications. Fixes #2323
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18492
diff changeset
651 g_free(subjects[i - 1]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 g_free(subjects);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 g_free(urls);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 in_str = xmlnode_get_attrib(child, "result-time");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 if (in_str && *in_str) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 g_free(js->gmail_last_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 js->gmail_last_time = g_strdup(in_str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
662 void
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
663 jabber_gmail_poke(JabberStream *js, xmlnode *packet)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 const char *type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 JabberIq *iq;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
668
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 /* bail if the user isn't interested */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
670 if (!purple_account_get_check_mail(js->gc->account))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 type = xmlnode_get_attrib(packet, "type");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
674
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 /* Is this an initial incoming mail notification? If so, send a request for more info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 if (strcmp(type, "set") || !xmlnode_get_child(packet, "new-mail"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
680 purple_debug(PURPLE_DEBUG_MISC, "jabber",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 "Got new mail notification. Sending request for more info\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 if (js->gmail_last_time)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 if (js->gmail_last_tid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 void jabber_gmail_init(JabberStream *js) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
699 if (!purple_account_get_check_mail(js->gc->account))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 void jabber_google_roster_init(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 query = xmlnode_get_child(iq->node, "query");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
714
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
723 PurpleAccount *account = purple_connection_get_account(js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 GSList *list = account->deny;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 const char *jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 char *jid_norm = g_strdup(jabber_normalize(account, jid));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 if (!strcmp(jid_norm, (char*)list->data)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 xmlnode_set_attrib(item, "gr:t", "B");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
739 g_free(jid_norm);
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
740
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742
15466
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
743 gboolean jabber_google_roster_incoming(JabberStream *js, xmlnode *item)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
745 PurpleAccount *account = purple_connection_get_account(js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 GSList *list = account->deny;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 const char *jid = xmlnode_get_attrib(item, "jid");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 gboolean on_block_list = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749
20317
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
750 char *jid_norm;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 const char *grt = xmlnode_get_attrib_with_namespace(item, "t", "google:roster");
17040
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
753 const char *subscription = xmlnode_get_attrib(item, "subscription");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
754
17235
a7c07b57f3e4 This should be better
Sean Egan <seanegan@gmail.com>
parents: 17225
diff changeset
755 if (!subscription || !strcmp(subscription, "none")) {
17040
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
756 /* The Google Talk servers will automatically add people from your Gmail address book
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
757 * with subscription=none. If we see someone with subscription=none, ignore them.
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
758 */
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
759 return FALSE;
1863cdac4be3 If Google Talk tells you a roster item as a none subscription, we probably don't ever want to show it. Fixes #1189
Sean Egan <seanegan@gmail.com>
parents: 16932
diff changeset
760 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
761
20317
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
762 jid_norm = g_strdup(jabber_normalize(account, jid));
ac46ffeb5b2b applied changes from 6b5f1f48667171fe73de619dd8f80cacd231a2e2
Luke Schierer <lschiere@pidgin.im>
parents: 20281
diff changeset
763
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 if (!strcmp(jid_norm, (char*)list->data)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 on_block_list = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
771
15466
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
772 if (grt && (*grt == 'H' || *grt == 'h')) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
773 PurpleBuddy *buddy = purple_find_buddy(account, jid_norm);
20218
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
774 if (buddy)
99ceb1329a5b applied changes from 3fcc47961d378fa0cd4eeb00dc6923b16a3a4151
Richard Laager <rlaager@wiktel.com>
parents: 20211
diff changeset
775 purple_blist_remove_buddy(buddy);
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
776 g_free(jid_norm);
15466
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
777 return FALSE;
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
778 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
779
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 if (!on_block_list && (grt && (*grt == 'B' || *grt == 'b'))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
781 purple_debug_info("jabber", "Blocking %s\n", jid_norm);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
782 purple_privacy_deny_add(account, jid_norm, TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 } else if (on_block_list && (!grt || (*grt != 'B' && *grt != 'b' ))){
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
784 purple_debug_info("jabber", "Unblocking %s\n", jid_norm);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
785 purple_privacy_deny_remove(account, jid_norm, TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 }
18491
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
787
8f172a8b8cce Various leak fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18161
diff changeset
788 g_free(jid_norm);
15466
2c81b0a81790 Make deleting Google Talk buddies work
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
789 return TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
792 void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 GSList *buddies;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 xmlnode *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 xmlnode *group;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
800 PurpleBuddy *b;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 js = (JabberStream*)(gc->proto_data);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
804
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 jb = jabber_buddy_find(js, who, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
810 buddies = purple_find_buddies(js->gc->account, who);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
813
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 b = buddies->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
817
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 while(buddies) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
822 PurpleGroup *g;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 b = buddies->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
825 g = purple_buddy_get_group(b);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 group = xmlnode_new_child(item, "group");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 xmlnode_insert_data(group, g->name, -1);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
829
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 buddies = buddies->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 xmlnode_set_attrib(item, "jid", who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 xmlnode_set_attrib(item, "gr:t", "B");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 /* Synthesize a sign-off */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 if (jb) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 JabberBuddyResource *jbr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 GList *l = jb->resources;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 while (l) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 jbr = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 if (jbr && jbr->name)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
849 purple_debug(PURPLE_DEBUG_MISC, "jabber", "Removing resource %s\n", jbr->name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 jabber_buddy_remove_resource(jb, jbr->name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 l = l->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
855 purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
858 void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 GSList *buddies;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 xmlnode *item;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 xmlnode *group;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
866 PurpleBuddy *b;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 g_return_if_fail(gc != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 g_return_if_fail(who != NULL);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
870
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 js = (JabberStream*)(gc->proto_data);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
872
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
875
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
876 buddies = purple_find_buddies(js->gc->account, who);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 if(!buddies)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 return;
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
879
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 b = buddies->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:roster");
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
883
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 item = xmlnode_new_child(query, "item");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 while(buddies) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
888 PurpleGroup *g;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 b = buddies->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15522
diff changeset
891 g = purple_buddy_get_group(b);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 group = xmlnode_new_child(item, "group");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 xmlnode_insert_data(group, g->name, -1);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
895
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 buddies = buddies->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 xmlnode_set_attrib(item, "jid", who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 xmlnode_set_attrib(query, "gr:ext", "2");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 /* See if he's online */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 jabber_presence_subscription_set(js, who, "probe");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 }
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
909
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
910 /* This does two passes on the string. The first pass goes through
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
911 * and determine if all the structured text is properly balanced, and
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
912 * how many instances of each there is. The second pass goes and converts
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
913 * everything to HTML, depending on what's figured out by the first pass.
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
914 * It will short circuit once it knows it has no more replacements to make
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
915 */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
916 char *jabber_google_format_to_html(const char *text)
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
917 {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
918 const char *p;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
919
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
920 /* The start of the screen may be consdiered a space for this purpose */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
921 gboolean preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
922
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
923 gboolean in_bold = FALSE, in_italic = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
924 gboolean in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
925
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
926 gint bold_count = 0, italic_count = 0;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
927
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
928 GString *str;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
929
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
930 for (p = text; *p != '\0'; p = g_utf8_next_char(p)) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
931 gunichar c = g_utf8_get_char(p);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
932 if (c == '*' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
933 if (in_bold && (g_unichar_isspace(*(p+1)) ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
934 *(p+1) == '\0' ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
935 *(p+1) == '<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
936 bold_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
937 in_bold = FALSE;
16932
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
938 } else if (preceding_space && !in_bold && !g_unichar_isspace(*(p+1))) {
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
939 bold_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
940 in_bold = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
941 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
942 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
943 } else if (c == '_' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
944 if (in_italic && (g_unichar_isspace(*(p+1)) ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
945 *(p+1) == '\0' ||
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
946 *(p+1) == '<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
947 italic_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
948 in_italic = FALSE;
16932
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
949 } else if (preceding_space && !in_italic && !g_unichar_isspace(*(p+1))) {
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
950 italic_count++;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
951 in_italic = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
952 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
953 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
954 } else if (c == '<' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
955 in_tag = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
956 } else if (c == '>' && in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
957 in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
958 } else if (!in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
959 if (g_unichar_isspace(c))
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
960 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
961 else
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
962 preceding_space = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
963 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
964 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
965
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
966 str = g_string_new(NULL);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
967 in_bold = in_italic = in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
968 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
969
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
970 for (p = text; *p != '\0'; p = g_utf8_next_char(p)) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
971 gunichar c = g_utf8_get_char(p);
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
972
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
973 if (bold_count < 2 && italic_count < 2 && !in_bold && !in_italic) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
974 g_string_append(str, p);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
975 return g_string_free(str, FALSE);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
976 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
977
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
978
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
979 if (c == '*' && !in_tag) {
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
980 if (in_bold &&
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
981 (g_unichar_isspace(*(p+1))||*(p+1)=='<')) { /* This is safe in UTF-8 */
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
982 str = g_string_append(str, "</b>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
983 in_bold = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
984 bold_count--;
16932
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
985 } else if (preceding_space && bold_count > 1 && !g_unichar_isspace(*(p+1))) {
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
986 str = g_string_append(str, "<b>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
987 bold_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
988 in_bold = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
989 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
990 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
991 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
992 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
993 } else if (c == '_' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
994 if (in_italic &&
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
995 (g_unichar_isspace(*(p+1))||*(p+1)=='<')) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
996 str = g_string_append(str, "</i>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
997 italic_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
998 in_italic = FALSE;
16932
3d0aec991e5d Patch #265. Fix to Google Talk formatting
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
999 } else if (preceding_space && italic_count > 1 && !g_unichar_isspace(*(p+1))) {
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1000 str = g_string_append(str, "<i>");
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1001 italic_count--;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1002 in_italic = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1003 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1004 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1005 }
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1006 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1007 } else if (c == '<' && !in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1008 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1009 in_tag = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1010 } else if (c == '>' && in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1011 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1012 in_tag = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1013 } else if (!in_tag) {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1014 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1015 if (g_unichar_isspace(c))
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1016 preceding_space = TRUE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1017 else
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1018 preceding_space = FALSE;
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1019 } else {
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1020 str = g_string_append_unichar(str, c);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1021 }
18161
3a1a9e8c1506 whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 17235
diff changeset
1022 }
15522
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1023 return g_string_free(str, FALSE);
ccbdf500f13a Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@gmail.com>
parents: 15466
diff changeset
1024 }
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1025
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1026 void jabber_google_presence_incoming(JabberStream *js, const char *user, JabberBuddyResource *jbr)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1027 {
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1028 if (!js->googletalk)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1029 return;
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1030 if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) {
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1031 purple_prpl_got_user_status(js->gc->account, user, "tune",
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1032 PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL);
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1033 jbr->status = NULL;
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1034 } else {
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1035 purple_prpl_got_user_status_deactive(js->gc->account, user, "tune");
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1036 }
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1037 }
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1038
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1039 char *jabber_google_presence_outgoing(PurpleStatus *tune)
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1040 {
21634
1853d9d0cc65 don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents: 21220
diff changeset
1041 const char *attr = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
1853d9d0cc65 don't set the current tune title if it's NULL
Ka-Hing Cheung <khc@hxbc.us>
parents: 21220
diff changeset
1042 return attr ? g_strdup_printf("♫ %s", attr) : g_strdup("");
20571
c97e3ab9ef11 Music support for Google Talk
Sean Egan <seanegan@gmail.com>
parents: 20211
diff changeset
1043 }