annotate src/protocols/rendezvous/rendezvous.c @ 10589:0f7452b1f777

[gaim-migrate @ 11994] Use GLib 2.6's gstdio functions. This should fix gaim not liking non-ascii filenames in win32. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Feb 2005 05:10:40 +0000
parents 8bc7ba019e96
children 913ec44675c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * gaim - Rendezvous Protocol Plugin
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 * source distribution.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 *
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * (at your option) any later version.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 *
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * GNU General Public License for more details.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 *
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 #include "internal.h"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 #include "account.h"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 #include "accountopt.h"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 #include "blist.h"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 #include "conversation.h"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 #include "debug.h"
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
29 #include "network.h"
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 #include "prpl.h"
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
31 #include "sha.h"
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
32 #include "version.h"
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
34 #include "direct.h"
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
35 #include "mdns.h"
9965
269029c55169 [gaim-migrate @ 10874]
Mark Doliner <mark@kingant.net>
parents: 9954
diff changeset
36 #include "rendezvous.h"
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
37 #include "util.h"
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 /****************************/
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 /* Utility Functions */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 /****************************/
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
42 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
43 rendezvous_buddy_free(gpointer data)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 RendezvousBuddy *rb = data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
47 if (rb->fd >= 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
48 close(rb->fd);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
49 if (rb->watcher >= 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
50 gaim_input_remove(rb->watcher);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
51
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 g_free(rb->firstandlast);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 g_free(rb->msg);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 g_free(rb);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56
8546
9aa6017da568 [gaim-migrate @ 9288]
Mark Doliner <mark@kingant.net>
parents: 8489
diff changeset
57 /**
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * Extract the "user@host" name from a full presence domain
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 * of the form "user@host._presence._tcp.local"
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 *
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 * @return If the domain is NOT a _presence._tcp.local domain
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 * then return NULL. Otherwise return a newly allocated
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 * null-terminated string containing the "user@host" for
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 * the given domain. This string should be g_free'd
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65 * when no longer needed.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 */
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
67 static gchar *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
68 rendezvous_extract_name(gchar *domain)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 gchar *ret, *suffix;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
72 if (!gaim_str_has_suffix(domain, "._presence._tcp.local"))
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 return NULL;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 suffix = strstr(domain, "._presence._tcp.local");
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 ret = g_strndup(domain, suffix - domain);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 return ret;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 /****************************/
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 /* Buddy List Functions */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83 /****************************/
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
84
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
85 static RendezvousBuddy *
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
86 rendezvous_find_or_create_rendezvousbuddy(GaimConnection *gc, const char *name)
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
87 {
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
88 RendezvousData *rd = gc->proto_data;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
89 RendezvousBuddy *rb;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
90
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
91 rb = g_hash_table_lookup(rd->buddies, name);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
92 if (rb == NULL) {
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
93 rb = g_malloc0(sizeof(RendezvousBuddy));
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
94 rb->fd = -1;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
95 rb->watcher = -1;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
96 g_hash_table_insert(rd->buddies, g_strdup(name), rb);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
97 }
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
98
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
99 return rb;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
100 }
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
101
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
102 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
103 rendezvous_addtolocal(GaimConnection *gc, const char *name, const char *domain)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 GaimAccount *account = gaim_connection_get_account(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 GaimBuddy *b;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107 GaimGroup *g;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 g = gaim_find_group(domain);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 if (g == NULL) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 g = gaim_group_new(domain);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
112 gaim_blist_add_group(g, NULL);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
113 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
114
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115 b = gaim_find_buddy_in_group(account, name, g);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
116 if (b != NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
117 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
118
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
119 b = gaim_buddy_new(account, name, NULL);
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
120 gaim_blist_node_set_flags((GaimBlistNode *)b, GAIM_BLIST_NODE_FLAG_NO_SAVE);
9817
5afa28c94201 [gaim-migrate @ 10688]
Mark Doliner <mark@kingant.net>
parents: 9775
diff changeset
121 /* gaim_blist_node_set_flag(b, GAIM_BLIST_NODE_FLAG_NO_SAVE); */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
122 gaim_blist_add_buddy(b, NULL, g, NULL);
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9965
diff changeset
123 gaim_prpl_got_user_status(account, b->name, "online", NULL);
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
124
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
125 #if 0
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
126 RendezvousBuddy *rb;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
127 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
128 rb->ttltimer = gaim_timeout_add(time * 10000, rendezvous_buddy_timeout, gc);
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
129
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
130 gaim_timeout_remove(rb->ttltimer);
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
131 rb->ttltimer = 0;
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
132 #endif
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
135 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
136 rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
137 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
138 GaimAccount *account = gaim_connection_get_account(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 GaimBuddy *b;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 GaimGroup *g;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 g = gaim_find_group(domain);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 if (g == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146 b = gaim_find_buddy_in_group(account, name, g);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147 if (b == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9965
diff changeset
150 gaim_prpl_got_user_status(account, b->name, "offline", NULL);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151 gaim_blist_remove_buddy(b);
8546
9aa6017da568 [gaim-migrate @ 9288]
Mark Doliner <mark@kingant.net>
parents: 8489
diff changeset
152 /* XXX - This results in incorrect group counts--needs to be fixed in the core */
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10011
diff changeset
153 /* XXX - We also need to call remove_idle_buddy() in server.c for idle buddies */
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
154
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
155 /*
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
156 * XXX - Instead of removing immediately, wait 10 seconds and THEN remove
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
157 * them. If you do it immediately you don't see the door close icon.
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
158 */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
161 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
162 rendezvous_removeallfromlocal(GaimConnection *gc)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 GaimAccount *account = gaim_connection_get_account(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 GaimBuddyList *blist;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166 GaimBlistNode *gnode, *cnode, *bnode;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 GaimBuddy *b;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 /* Go through and remove all buddies that belong to this account */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 if ((blist = gaim_get_blist()) != NULL) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 for (gnode = blist->root; gnode; gnode = gnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174 for (cnode = gnode->child; cnode; cnode = cnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 for (bnode = cnode->child; bnode; bnode = bnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 b = (GaimBuddy *)bnode;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 if (b->account != account)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182 continue;
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9965
diff changeset
183 gaim_prpl_got_user_status(account, b->name, "offline", NULL);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
184 gaim_blist_remove_buddy(b);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
186 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
191 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
192 rendezvous_handle_rr_a(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
193 {
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
194 RendezvousBuddy *rb;
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
195 ResourceRecordRDataSRV *rdata;
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
196
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
197 rdata = rr->rdata;
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
198
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
199 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
200
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
201 memcpy(rb->ipv4, rdata, 4);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
202 }
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
203
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
204 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
205 rendezvous_handle_rr_txt(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 {
10011
32467b63f55a [gaim-migrate @ 10928]
Mark Doliner <mark@kingant.net>
parents: 10009
diff changeset
207 GaimAccount *account = gaim_connection_get_account(gc);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
208 RendezvousBuddy *rb;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
209 GSList *rdata;
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
210 ResourceRecordRDataTXTNode *node1, *node2;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
212 rdata = rr->rdata;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
213
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
214 /* Don't do a damn thing if the version is greater than 1 */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
215 node1 = mdns_txt_find(rdata, "version");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
216 if ((node1 == NULL) || (node1->value == NULL) || (strcmp(node1->value, "1")))
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
217 return;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
218
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
219 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
221 node1 = mdns_txt_find(rdata, "1st");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
222 node2 = mdns_txt_find(rdata, "last");
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223 g_free(rb->firstandlast);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 rb->firstandlast = g_strdup_printf("%s%s%s",
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
225 (node1 && node1->value ? node1->value : ""),
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
226 (node1 && node1->value && node2 && node2->value ? " " : ""),
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
227 (node2 && node2->value ? node2->value : ""));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 serv_got_alias(gc, name, rb->firstandlast);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
230 node1 = mdns_txt_find(rdata, "aim");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
231 if ((node1 != NULL) && (node1->value != NULL)) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232 g_free(rb->aim);
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
233 rb->aim = g_strdup(node1->value);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
234 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
235
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
236 /*
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
237 * We only want to use this port as a back-up. Ideally the port
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
238 * is specified in a separate, SRV resource record.
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
239 */
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
240 if (rb->p2pjport == 0) {
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
241 node1 = mdns_txt_find(rdata, "port.p2pj");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
242 if ((node1 != NULL) && (node1->value))
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
243 rb->p2pjport = atoi(node1->value);
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
244 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245
9775
4c1a1be8ce33 [gaim-migrate @ 10643]
Mark Doliner <mark@kingant.net>
parents: 9416
diff changeset
246 node1 = mdns_txt_find(rdata, "status");
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
247 if ((node1 != NULL) && (node1->value != NULL)) {
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
248 if (!strcmp(node1->value, "avail")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
249 /* Available */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
250 rb->status = 0;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
251 } else if (!strcmp(node1->value, "away")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
252 /* Idle */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
253 node2 = mdns_txt_find(rdata, "away");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
254 if ((node2 != NULL) && (node2->value)) {
9289
a2792c5f3ffd [gaim-migrate @ 10092]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
255 /* Time is seconds since January 1st 2001 GMT */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
256 rb->idle = atoi(node2->value);
9289
a2792c5f3ffd [gaim-migrate @ 10092]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
257 rb->idle += 978307200; /* convert to seconds-since-epoch */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
258 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
259 rb->status = UC_IDLE;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
260 /* TODO: Do this when the user is added to the buddy list? Definitely not here! */
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
261 /* gaim_prpl_got_user_idle(account, name, TRUE, rb->idle); */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
262 } else if (!strcmp(node1->value, "dnd")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
263 /* Away */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
264 rb->status = UC_UNAVAILABLE;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
265 }
10011
32467b63f55a [gaim-migrate @ 10928]
Mark Doliner <mark@kingant.net>
parents: 10009
diff changeset
266 gaim_prpl_got_user_status(account, name, "online", NULL);
9965
269029c55169 [gaim-migrate @ 10874]
Mark Doliner <mark@kingant.net>
parents: 9954
diff changeset
267 /* XXX - Idle time is rb->idle and status is rb->status */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
268 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
269
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
270 node1 = mdns_txt_find(rdata, "msg");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
271 if ((node1 != NULL) && (node1->value != NULL)) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
272 g_free(rb->msg);
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
273 rb->msg = g_strdup(node1->value);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
274 }
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
275 }
8546
9aa6017da568 [gaim-migrate @ 9288]
Mark Doliner <mark@kingant.net>
parents: 8489
diff changeset
276
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
277 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
278 rendezvous_handle_rr_aaaa(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
279 {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
280 RendezvousBuddy *rb;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
281 ResourceRecordRDataSRV *rdata;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
282
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
283 rdata = rr->rdata;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
284
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
285 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
286
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
287 memcpy(rb->ipv6, rdata, 16);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
288 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
289
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
290 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
291 rendezvous_handle_rr_srv(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
292 {
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
293 RendezvousBuddy *rb;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
294 ResourceRecordRDataSRV *rdata;
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
295
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
296 rdata = rr->rdata;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
297
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
298 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
299
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
300 rb->p2pjport = rdata->port;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
301 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
302
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
303 /*
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
304 * Parse a resource record and do stuff if we need to.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
305 */
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
306 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
307 rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
308 {
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
309 RendezvousData *rd = gc->proto_data;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
310 gchar *name;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
311
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
312 gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s and type %d\n", rr->name, rr->type);
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
313
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
314 switch (rr->type) {
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
315 case RENDEZVOUS_RRTYPE_A: {
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
316 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
317 if (name != NULL) {
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
318 rendezvous_handle_rr_a(gc, rr, name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
319 g_free(name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
320 }
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
321 } break;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
322
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
323 case RENDEZVOUS_RRTYPE_NULL: {
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
324 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
325 if (name != NULL) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
326 if (rr->rdlength > 0) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
327 /* Data is a buddy icon */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
328 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), name, rr->rdata, rr->rdlength);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
329 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
330
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
331 g_free(name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
332 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
333 } break;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
334
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
335 case RENDEZVOUS_RRTYPE_PTR: {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
336 gchar *rdata = rr->rdata;
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
337
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
338 name = rendezvous_extract_name(rdata);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
339 if (name != NULL) {
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
340 if (rr->ttl > 0) {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
341 /* Add them to our buddy list and request their icon */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
342 rendezvous_addtolocal(gc, name, "Rendezvous");
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
343 mdns_query(rd->fd, rdata, RENDEZVOUS_RRTYPE_NULL);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
344 } else {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
345 /* Remove them from our buddy list */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
346 rendezvous_removefromlocal(gc, name, "Rendezvous");
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
347 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
348 g_free(name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
349 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
350 } break;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
351
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
352 case RENDEZVOUS_RRTYPE_TXT: {
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
353 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
354 if (name != NULL) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
355 rendezvous_handle_rr_txt(gc, rr, name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
356 g_free(name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
357 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
358 } break;
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
359
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
360 case RENDEZVOUS_RRTYPE_AAAA: {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
361 name = rendezvous_extract_name(rr->name);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
362 if (name != NULL) {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
363 rendezvous_handle_rr_aaaa(gc, rr, name);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
364 g_free(name);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
365 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
366 } break;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
367
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
368 case RENDEZVOUS_RRTYPE_SRV: {
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
369 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
370 if (name != NULL) {
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
371 rendezvous_handle_rr_srv(gc, rr, name);
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
372 g_free(name);
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
373 }
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
374 } break;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
375 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
376 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
377
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
378 /****************************/
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8721
diff changeset
379 /* Icon and Emblem Functions */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
380 /****************************/
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
381 static const char *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
382 rendezvous_prpl_list_icon(GaimAccount *a, GaimBuddy *b)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
383 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
384 return "rendezvous";
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
385 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
386
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
387 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
388 rendezvous_prpl_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
389 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
390 if (GAIM_BUDDY_IS_ONLINE(b)) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
391 if (b->uc & UC_UNAVAILABLE)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
392 *se = "away";
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
393 } else {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
394 *se = "offline";
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
395 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
396 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
397
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
398 static gchar *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
399 rendezvous_prpl_status_text(GaimBuddy *b)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
400 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
401 GaimConnection *gc = b->account->gc;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
402 RendezvousData *rd = gc->proto_data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
403 RendezvousBuddy *rb;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
404 gchar *ret;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
405
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
406 rb = g_hash_table_lookup(rd->buddies, b->name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
407 if ((rb == NULL) || (rb->msg == NULL))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
408 return NULL;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
409
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
410 ret = g_strdup(rb->msg);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
411
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
412 return ret;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
413 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
414
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
415 static gchar *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
416 rendezvous_prpl_tooltip_text(GaimBuddy *b)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
417 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
418 GaimConnection *gc = b->account->gc;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
419 RendezvousData *rd = gc->proto_data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
420 RendezvousBuddy *rb;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
421 GString *ret;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
422
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
423 rb = g_hash_table_lookup(rd->buddies, b->name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
424 if (rb == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
425 return NULL;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
426
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
427 ret = g_string_new("");
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
428
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
429 if (rb->aim != NULL)
8591
f96795b786d2 [gaim-migrate @ 9342]
Mark Doliner <mark@kingant.net>
parents: 8589
diff changeset
430 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("AIM Screen name"), rb->aim);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
431
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
432 if (rb->msg != NULL) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
433 if (rb->status == UC_UNAVAILABLE)
8591
f96795b786d2 [gaim-migrate @ 9342]
Mark Doliner <mark@kingant.net>
parents: 8589
diff changeset
434 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("Away"), rb->msg);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
435 else
8591
f96795b786d2 [gaim-migrate @ 9342]
Mark Doliner <mark@kingant.net>
parents: 8589
diff changeset
436 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("Available"), rb->msg);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
437 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
438
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
439 return g_string_free(ret, FALSE);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
440 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
441
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
442 static GList *
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
443 rendezvous_prpl_status_types(GaimAccount *account)
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
444 {
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
445 GList *status_types = NULL;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
446 GaimStatusType *type;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
447
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
448 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, "offline", _("Offline"), FALSE, TRUE, FALSE);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
449 status_types = g_list_append(status_types, type);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
450
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
451 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, "online", _("Online"), FALSE, TRUE, FALSE);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
452 status_types = g_list_append(status_types, type);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
453
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
454 return status_types;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
455 }
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
456
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
457 /****************************/
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8721
diff changeset
458 /* Connection Functions */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
459 /****************************/
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
460 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
461 rendezvous_callback(gpointer data, gint source, GaimInputCondition condition)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
462 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
463 GaimConnection *gc = data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
464 RendezvousData *rd = gc->proto_data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
465 DNSPacket *dns;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
466 GSList *cur;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
467
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
468 gaim_debug_misc("rendezvous", "Received rendezvous datagram\n");
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
469
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
470 dns = mdns_read(rd->fd);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
471 if (dns == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
472 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
473
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
474 /* Handle the DNS packet */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
475 for (cur = dns->answers; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
476 rendezvous_handle_rr(gc, cur->data);
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
477 for (cur = dns->authority; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
478 rendezvous_handle_rr(gc, cur->data);
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
479 for (cur = dns->additional; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
480 rendezvous_handle_rr(gc, cur->data);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
481
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
482 mdns_free(dns);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
483 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
484
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
485 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
486 rendezvous_add_to_txt(RendezvousData *rd, const char *name, const char *value)
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
487 {
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
488 ResourceRecordRDataTXTNode *node;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
489 node = g_malloc(sizeof(ResourceRecordRDataTXTNode));
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
490 node->name = g_strdup(name);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
491 node->value = value != NULL ? g_strdup(value) : NULL;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
492 rd->mytxtdata = g_slist_append(rd->mytxtdata, node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
493 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
494
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
495 static guchar *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
496 rendezvous_read_icon_data(const char *filename, unsigned short *length)
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
497 {
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
498 struct stat st;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
499 FILE *file;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
500 guchar *data;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
501
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
502 *length = 0;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
503
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
504 g_return_val_if_fail(filename != NULL, NULL);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
505
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10549
diff changeset
506 if (g_stat(filename, &st))
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
507 return NULL;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
508
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10549
diff changeset
509 if (!(file = g_fopen(filename, "rb")))
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
510 return NULL;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
511
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
512 *length = st.st_size;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
513 data = g_malloc(*length);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
514 fread(data, 1, *length, file);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
515 fclose(file);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
516
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
517 return data;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
518 }
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
519
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
520 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
521 rendezvous_add_to_txt_iconhash(RendezvousData *rd, const char *iconfile)
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
522 {
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
523 guchar *icondata;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
524 unsigned short iconlength;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
525 unsigned char hash[20];
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
526 gchar *base16;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
527
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
528 g_return_if_fail(rd != NULL);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
529
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
530 if (iconfile == NULL)
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
531 return;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
532
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
533 icondata = rendezvous_read_icon_data(iconfile, &iconlength);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
534 shaBlock((unsigned char *)icondata, iconlength, hash);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
535 g_free(icondata);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
536
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
537 base16 = gaim_base16_encode(hash, 20);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
538 rendezvous_add_to_txt(rd, "phsh", base16);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
539 g_free(base16);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
540 }
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
541
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
542 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
543 rendezvous_send_icon(GaimConnection *gc)
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
544 {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
545 RendezvousData *rd = gc->proto_data;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
546 GaimAccount *account = gaim_connection_get_account(gc);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
547 const char *iconfile = gaim_account_get_buddy_icon(account);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
548 unsigned char *rdata;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
549 unsigned short rdlength;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
550 gchar *myname;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
551
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
552 if (iconfile == NULL)
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
553 return;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
554
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
555 rdata = rendezvous_read_icon_data(iconfile, &rdlength);
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
556
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
557 myname = g_strdup_printf("%s._presence._tcp.local", gaim_account_get_username(account));
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
558 mdns_advertise_null(rd->fd, myname, rdata, rdlength);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
559 g_free(myname);
8695
a32481f393b9 [gaim-migrate @ 9448]
Mark Doliner <mark@kingant.net>
parents: 8636
diff changeset
560
a32481f393b9 [gaim-migrate @ 9448]
Mark Doliner <mark@kingant.net>
parents: 8636
diff changeset
561 g_free(rdata);
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
562 }
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
563
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
564 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
565 rendezvous_send_online(GaimConnection *gc)
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
566 {
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
567 RendezvousData *rd = gc->proto_data;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
568 GaimAccount *account = gaim_connection_get_account(gc);
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
569 const gchar *me, *myip;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
570 gchar *myname, *mycomp, *myport;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
571 gchar **mysplitip;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
572 unsigned char myipv4[4];
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
573
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
574 me = gaim_account_get_username(account);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
575 myname = g_strdup_printf("%s._presence._tcp.local", me);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
576 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
577 myport = g_strdup_printf("%d", rd->listener_port);
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
578
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
579 myip = gaim_network_get_local_system_ip(-1);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
580 mysplitip = g_strsplit(myip, ".", 0);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
581 myipv4[0] = atoi(mysplitip[0]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
582 myipv4[1] = atoi(mysplitip[1]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
583 myipv4[2] = atoi(mysplitip[2]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
584 myipv4[3] = atoi(mysplitip[3]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
585 g_strfreev(mysplitip);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
586
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
587 mdns_advertise_a(rd->fd, mycomp, myipv4);
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
588 mdns_advertise_ptr(rd->fd, "_presence._tcp.local", myname);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
589 mdns_advertise_srv(rd->fd, myname, rd->listener_port, mycomp);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
590
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
591 rendezvous_add_to_txt(rd, "txtvers", "1");
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
592 rendezvous_add_to_txt(rd, "status", "avail");
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
593 /* rendezvous_add_to_txt(rd, "vc", "A!"); */
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
594 rendezvous_add_to_txt_iconhash(rd, gaim_account_get_buddy_icon(account));
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
595 rendezvous_add_to_txt(rd, "1st", gaim_account_get_string(account, "first", "Gaim"));
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
596 if (gaim_account_get_bool(account, "shareaim", FALSE)) {
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
597 GList *l;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
598 GaimAccount *cur;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
599 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
600 cur = (GaimAccount *)l->data;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
601 if (!strcmp(gaim_account_get_protocol_id(cur), "prpl-oscar")) {
8634
bcb09cc97b63 [gaim-migrate @ 9386]
Mark Doliner <mark@kingant.net>
parents: 8631
diff changeset
602 /* XXX - Should the name be normalized? */
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
603 rendezvous_add_to_txt(rd, "AIM", gaim_account_get_username(cur));
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
604 break;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
605 }
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
606 }
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
607 }
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
608 rendezvous_add_to_txt(rd, "version", "1");
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
609 rendezvous_add_to_txt(rd, "msg", "Groovin'");
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
610 rendezvous_add_to_txt(rd, "port.p2pj", myport);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
611 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User")));
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
612 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
613
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
614 rendezvous_send_icon(gc);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
615
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
616 g_free(myname);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
617 g_free(mycomp);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
618 g_free(myport);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
619 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
620
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
621 static void
10401
3e4ecbdf8d0a [gaim-migrate @ 11638]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10321
diff changeset
622 rendezvous_prpl_login(GaimAccount *account, GaimStatus *status)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
623 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
624 GaimConnection *gc = gaim_account_get_connection(account);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
625 RendezvousData *rd;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
626
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
627 rd = g_new0(RendezvousData, 1);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
628 rd->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, rendezvous_buddy_free);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
629 gc->proto_data = rd;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
630
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
631 gaim_connection_update_progress(gc, _("Preparing Buddy List"), 0, RENDEZVOUS_CONNECT_STEPS);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
632 rendezvous_removeallfromlocal(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
633
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
634 rd->listener = gaim_network_listen_range(5298, 5308);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
635 if (rd->listener == -1) {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
636 gaim_connection_error(gc, _("Unable to establish listening port."));
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
637 return;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
638 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
639 rd->listener_watcher = gaim_input_add(rd->listener, GAIM_INPUT_READ, rendezvous_direct_acceptconnection, gc);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
640 rd->listener_port = gaim_network_get_port_from_fd(rd->listener);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
641
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
642 gaim_connection_update_progress(gc, _("Connecting"), 1, RENDEZVOUS_CONNECT_STEPS);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
643 rd->fd = mdns_socket_establish();
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
644 if (rd->fd == -1) {
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
645 gaim_connection_error(gc, _("Unable to establish mDNS socket."));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
646 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
647 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
648
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
649 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
650 gaim_connection_set_state(gc, GAIM_CONNECTED);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
651
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
652 mdns_query(rd->fd, "_presence._tcp.local", RENDEZVOUS_RRTYPE_ALL);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
653 rendezvous_send_online(gc);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
654 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
655
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
656 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
657 rendezvous_prpl_close(GaimConnection *gc)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
658 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
659 RendezvousData *rd = (RendezvousData *)gc->proto_data;
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
660 ResourceRecordRDataTXTNode *node;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
662 if (gc->inpa)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 gaim_input_remove(gc->inpa);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665 rendezvous_removeallfromlocal(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
666
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
667 if (rd == NULL)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
668 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
670 mdns_socket_close(rd->fd);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
671
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
672 if (rd->listener >= 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
673 close(rd->listener);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
674
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
675 if (rd->listener_watcher != 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
676 gaim_input_remove(rd->listener_watcher);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
677
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
678 g_hash_table_destroy(rd->buddies);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
679
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
680 while (rd->mytxtdata != NULL) {
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
681 node = rd->mytxtdata->data;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
682 rd->mytxtdata = g_slist_remove(rd->mytxtdata, node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
683 g_free(node->name);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
684 g_free(node->value);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
685 g_free(node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
686 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
687
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
688 g_free(rd);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
689 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
690
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
691 static int
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
692 rendezvous_prpl_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
693 {
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
694 RendezvousData *rd = gc->proto_data;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
695 RendezvousBuddy *rb;
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
696
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
697 gaim_debug_info("rendezvous", "Sending IM\n");
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
698
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
699 rb = g_hash_table_lookup(rd->buddies, who);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
700 if (rb == NULL) {
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
701 /* TODO: Should print an error to the user, here */
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
702 gaim_debug_error("rendezvous", "Could not send message to %s: Could not find user information.\n", who);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
703 }
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
704
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
705 /* TODO: Establish a direct connection then send IM. Will need to queue the message somewhere. */
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
706
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
707 return 1;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
708 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
709
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
710 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
711 rendezvous_prpl_set_status(GaimAccount *account, GaimStatus *status)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
712 {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
713 gaim_debug_error("rendezvous", "Set status to %s\n", gaim_status_get_name(status));
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
714 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
715
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
716 static GaimPlugin *my_protocol = NULL;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
717
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
718 static GaimPluginProtocolInfo prpl_info;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
719
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
720 static GaimPluginInfo info =
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
721 {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
722 GAIM_PLUGIN_MAGIC,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
723 GAIM_MAJOR_VERSION,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
724 GAIM_MINOR_VERSION,
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
725 GAIM_PLUGIN_PROTOCOL, /**< type */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
726 NULL, /**< ui_requirement */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
727 0, /**< flags */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
728 NULL, /**< dependencies */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
729 GAIM_PRIORITY_DEFAULT, /**< priority */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
730
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
731 "prpl-rendezvous", /**< id */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
732 "Rendezvous", /**< name */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
733 VERSION, /**< version */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
734 /** summary */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
735 N_("Rendezvous Protocol Plugin"),
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
736 /** description */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
737 N_("Rendezvous Protocol Plugin"),
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
738 NULL, /**< author */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
739 GAIM_WEBSITE, /**< homepage */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
740
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
741 NULL, /**< load */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
742 NULL, /**< unload */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
743 NULL, /**< destroy */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
744
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
745 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
746 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
747 NULL,
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
748 NULL
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
749 };
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
750
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
751 static void init_plugin(GaimPlugin *plugin)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
752 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
753 GaimAccountUserSplit *split;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
754 GaimAccountOption *option;
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
755 char hostname[255];
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
756
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
757 prpl_info.options = OPT_PROTO_NO_PASSWORD;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
758 prpl_info.icon_spec.format = "jpeg";
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
759 prpl_info.icon_spec.min_width = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
760 prpl_info.icon_spec.min_height = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
761 prpl_info.icon_spec.max_width = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
762 prpl_info.icon_spec.max_height = 0;
9394
ef79ee090cc5 [gaim-migrate @ 10203]
Mark Doliner <mark@kingant.net>
parents: 9318
diff changeset
763 prpl_info.icon_spec.scale_rules = 0;
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
764 prpl_info.list_icon = rendezvous_prpl_list_icon;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
765 prpl_info.list_emblems = rendezvous_prpl_list_emblems;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
766 prpl_info.status_text = rendezvous_prpl_status_text;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
767 prpl_info.tooltip_text = rendezvous_prpl_tooltip_text;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
768 prpl_info.status_types = rendezvous_prpl_status_types;
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
769 prpl_info.login = rendezvous_prpl_login;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
770 prpl_info.close = rendezvous_prpl_close;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
771 prpl_info.send_im = rendezvous_prpl_send_im;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
772 prpl_info.set_status = rendezvous_prpl_set_status;
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
773
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
774 if (gethostname(hostname, 255) != 0) {
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
775 gaim_debug_warning("rendezvous", "Error %d when getting host name. Using \"localhost.\"\n", errno);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
776 strcpy(hostname, "localhost");
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
777 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
778
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
779 /* Try to avoid making this configurable... */
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
780 split = gaim_account_user_split_new(_("Host name"), hostname, '@');
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
781 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
782
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
783 option = gaim_account_option_string_new(_("First name"), "first", "Gaim");
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
785 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
786
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
787 option = gaim_account_option_string_new(_("Last name"), "last", _("User"));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
789 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
790
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
791 option = gaim_account_option_bool_new(_("Share AIM screen name"), "shareaim", FALSE);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
792 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
793 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
794
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
795 my_protocol = plugin;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
796 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
797
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
798 GAIM_INIT_PLUGIN(rendezvous, init_plugin, info);