annotate src/protocols/rendezvous/rendezvous.c @ 10816:c94f40ffcafb

[gaim-migrate @ 12471] rlaager reverted objectionable spacing changes committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 11 Apr 2005 15:26:51 +0000
parents d087e928ffd1
children 50224ac8184d
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"
10705
194167d8a3b6 [gaim-migrate @ 12289]
Mark Doliner <mark@kingant.net>
parents: 10596
diff changeset
28 #include "cipher.h"
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 #include "debug.h"
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
30 #include "network.h"
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 #include "prpl.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
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
126 /* Remove the buddy if the TTL on their PTR record expires */
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
127 RendezvousBuddy *rb;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
128 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8612
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
129 rb->ttltimer = gaim_timeout_add(time * 10000, rendezvous_buddy_timeout, gc);
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
130
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
131 gaim_timeout_remove(rb->ttltimer);
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
132 rb->ttltimer = 0;
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
133 #endif
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
136 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
137 rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
138 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 GaimAccount *account = gaim_connection_get_account(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 GaimBuddy *b;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141 GaimGroup *g;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 g = gaim_find_group(domain);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 if (g == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147 b = gaim_find_buddy_in_group(account, name, g);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 if (b == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9965
diff changeset
151 gaim_prpl_got_user_status(account, b->name, "offline", NULL);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 gaim_blist_remove_buddy(b);
8546
9aa6017da568 [gaim-migrate @ 9288]
Mark Doliner <mark@kingant.net>
parents: 8489
diff changeset
153 /* 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
154 /* 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
155
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
156 /*
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
157 * XXX - Instead of removing immediately, wait 10 seconds and THEN remove
219e9638e8f3 [gaim-migrate @ 9363]
Mark Doliner <mark@kingant.net>
parents: 8594
diff changeset
158 * 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
159 */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
162 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
163 rendezvous_removeallfromlocal(GaimConnection *gc)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 GaimAccount *account = gaim_connection_get_account(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166 GaimBuddyList *blist;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 GaimBlistNode *gnode, *cnode, *bnode;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168 GaimBuddy *b;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 /* Go through and remove all buddies that belong to this account */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 if ((blist = gaim_get_blist()) != NULL) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172 for (gnode = blist->root; gnode; gnode = gnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 for (cnode = gnode->child; cnode; cnode = cnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 for (bnode = cnode->child; bnode; bnode = bnode->next) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 continue;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 b = (GaimBuddy *)bnode;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182 if (b->account != account)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
183 continue;
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9965
diff changeset
184 gaim_prpl_got_user_status(account, b->name, "offline", NULL);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185 gaim_blist_remove_buddy(b);
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 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
191
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
192 static gboolean
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
193 rendezvous_find_buddy_by_host(gpointer key, gpointer value, gpointer user_data)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
194 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
195 const gchar *domain;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
196
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
197 if (key == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
198 return FALSE;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
199
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
200 domain = strchr(key, '@');
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
201 if (domain == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
202 return FALSE;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
203 domain++;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
204
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
205 return !strcasecmp(user_data, domain);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
206 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
207
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
208 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
209 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
210 {
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
211 RendezvousData *rd = gc->proto_data;
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
212 RendezvousBuddy *rb;
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
213 ResourceRecordRDataSRV *rdata;
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
214 const gchar *end;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
215 gchar *domain;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
216
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
217 /*
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
218 * Remove the trailing ".local" from the domain. If there is no
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
219 * trailing ".local" then do nothing and exit
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
220 */
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
221 end = g_strrstr(name, ".local");
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
222 if (end == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
223 return;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
224
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
225 domain = g_strndup(name, (gpointer)end - (gpointer)name);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
226 rb = g_hash_table_find(rd->buddies, rendezvous_find_buddy_by_host, domain);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
227 g_free(domain);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
228
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
229 if (rb == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
230 return;
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
231
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
232 rdata = rr->rdata;
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
233
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
234 memcpy(rb->ipv4, rdata, 4);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
235 }
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
236
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
237 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
238 rendezvous_handle_rr_txt(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 {
10011
32467b63f55a [gaim-migrate @ 10928]
Mark Doliner <mark@kingant.net>
parents: 10009
diff changeset
240 GaimAccount *account = gaim_connection_get_account(gc);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241 RendezvousBuddy *rb;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
242 GSList *rdata;
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
243 ResourceRecordRDataTXTNode *node1, *node2;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
245 rdata = rr->rdata;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
246
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
247 /* 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
248 node1 = mdns_txt_find(rdata, "version");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
249 if ((node1 == NULL) || (node1->value == NULL) || (strcmp(node1->value, "1")))
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
250 return;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
251
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
252 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
253
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
254 node1 = mdns_txt_find(rdata, "1st");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
255 node2 = mdns_txt_find(rdata, "last");
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
256 g_free(rb->firstandlast);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
257 rb->firstandlast = g_strdup_printf("%s%s%s",
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
258 (node1 && node1->value ? node1->value : ""),
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
259 (node1 && node1->value && node2 && node2->value ? " " : ""),
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
260 (node2 && node2->value ? node2->value : ""));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
261 serv_got_alias(gc, name, rb->firstandlast);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
262
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
263 node1 = mdns_txt_find(rdata, "aim");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
264 if ((node1 != NULL) && (node1->value != NULL)) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
265 g_free(rb->aim);
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
266 rb->aim = g_strdup(node1->value);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
267 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
268
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
269 /*
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
270 * 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
271 * is specified in a separate, SRV resource record.
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
272 */
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
273 if (rb->p2pjport == 0) {
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
274 node1 = mdns_txt_find(rdata, "port.p2pj");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
275 if ((node1 != NULL) && (node1->value))
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
276 rb->p2pjport = atoi(node1->value);
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
277 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
278
9775
4c1a1be8ce33 [gaim-migrate @ 10643]
Mark Doliner <mark@kingant.net>
parents: 9416
diff changeset
279 node1 = mdns_txt_find(rdata, "status");
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
280 if ((node1 != NULL) && (node1->value != NULL)) {
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
281 if (!strcmp(node1->value, "avail")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
282 /* Available */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
283 rb->status = 0;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
284 } else if (!strcmp(node1->value, "away")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
285 /* Idle */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
286 node2 = mdns_txt_find(rdata, "away");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
287 if ((node2 != NULL) && (node2->value)) {
9289
a2792c5f3ffd [gaim-migrate @ 10092]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
288 /* Time is seconds since January 1st 2001 GMT */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
289 rb->idle = atoi(node2->value);
9289
a2792c5f3ffd [gaim-migrate @ 10092]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
290 rb->idle += 978307200; /* convert to seconds-since-epoch */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
291 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
292 rb->status = UC_IDLE;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
293 /* 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
294 /* gaim_prpl_got_user_idle(account, name, TRUE, rb->idle); */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
295 } else if (!strcmp(node1->value, "dnd")) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
296 /* Away */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
297 rb->status = UC_UNAVAILABLE;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
298 }
10011
32467b63f55a [gaim-migrate @ 10928]
Mark Doliner <mark@kingant.net>
parents: 10009
diff changeset
299 gaim_prpl_got_user_status(account, name, "online", NULL);
9965
269029c55169 [gaim-migrate @ 10874]
Mark Doliner <mark@kingant.net>
parents: 9954
diff changeset
300 /* XXX - Idle time is rb->idle and status is rb->status */
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
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
303 node1 = mdns_txt_find(rdata, "msg");
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
304 if ((node1 != NULL) && (node1->value != NULL)) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
305 g_free(rb->msg);
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
306 rb->msg = g_strdup(node1->value);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
307 }
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
308 }
8546
9aa6017da568 [gaim-migrate @ 9288]
Mark Doliner <mark@kingant.net>
parents: 8489
diff changeset
309
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
310 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
311 rendezvous_handle_rr_aaaa(GaimConnection *gc, ResourceRecord *rr, const gchar *name)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
312 {
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
313 RendezvousData *rd = gc->proto_data;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
314 RendezvousBuddy *rb;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
315 ResourceRecordRDataSRV *rdata;
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
316 const gchar *end;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
317 gchar *domain;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
318
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
319 /*
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
320 * Remove the trailing ".local" from the domain. If there is no
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
321 * trailing ".local" then do nothing and exit
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
322 */
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
323 end = g_strrstr(name, ".local");
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
324 if (end == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
325 return;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
326
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
327 domain = g_strndup(name, (gpointer)end - (gpointer)name);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
328 rb = g_hash_table_find(rd->buddies, rendezvous_find_buddy_by_host, domain);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
329 g_free(domain);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
330
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
331 if (rb == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
332 return;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
333
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
334 rdata = rr->rdata;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
335
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
336 memcpy(rb->ipv6, rdata, 16);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
337 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
338
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
339 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
340 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
341 {
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
342 RendezvousBuddy *rb;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
343 ResourceRecordRDataSRV *rdata;
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
344
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
345 rdata = rr->rdata;
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
346
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
347 rb = rendezvous_find_or_create_rendezvousbuddy(gc, name);
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
348
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
349 rb->p2pjport = rdata->port;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
350 }
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 /*
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
353 * Parse a resource record and do stuff if we need to.
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
354 */
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
355 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
356 rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
357 {
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
358 RendezvousData *rd = gc->proto_data;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
359 gchar *name;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
360
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
361 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
362
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
363 switch (rr->type) {
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
364 case RENDEZVOUS_RRTYPE_A: {
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
365 rendezvous_handle_rr_a(gc, rr, rr->name);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
366 } break;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
367
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
368 case RENDEZVOUS_RRTYPE_NULL: {
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) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
371 if (rr->rdlength > 0) {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
372 /* Data is a buddy icon */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
373 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
374 }
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 g_free(name);
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 } break;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
379
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
380 case RENDEZVOUS_RRTYPE_PTR: {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
381 gchar *rdata = rr->rdata;
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
382
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
383 name = rendezvous_extract_name(rdata);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
384 if (name != NULL) {
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
385 if (rr->ttl > 0) {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
386 /* Add them to our buddy list and request their icon */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
387 rendezvous_addtolocal(gc, name, "Rendezvous");
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
388 mdns_query(rd->fd, rdata, RENDEZVOUS_RRTYPE_NULL);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
389 } else {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
390 /* Remove them from our buddy list */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
391 rendezvous_removefromlocal(gc, name, "Rendezvous");
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
392 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
393 g_free(name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
394 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
395 } break;
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 case RENDEZVOUS_RRTYPE_TXT: {
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
398 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
399 if (name != NULL) {
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
400 rendezvous_handle_rr_txt(gc, rr, name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
401 g_free(name);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
402 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
403 } break;
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
404
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
405 case RENDEZVOUS_RRTYPE_AAAA: {
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
406 rendezvous_handle_rr_aaaa(gc, rr, rr->name);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
407 } break;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
408
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
409 case RENDEZVOUS_RRTYPE_SRV: {
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
410 name = rendezvous_extract_name(rr->name);
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
411 if (name != NULL) {
8594
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
412 rendezvous_handle_rr_srv(gc, rr, name);
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
413 g_free(name);
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
414 }
f3b928825a72 [gaim-migrate @ 9345]
Mark Doliner <mark@kingant.net>
parents: 8591
diff changeset
415 } break;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
416 }
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
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
419 /****************************/
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8721
diff changeset
420 /* Connection Functions */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
421 /****************************/
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
422 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
423 rendezvous_callback(gpointer data, gint source, GaimInputCondition condition)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
424 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
425 GaimConnection *gc = data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
426 RendezvousData *rd = gc->proto_data;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
427 DNSPacket *dns;
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
428 GSList *cur;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
429
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
430 gaim_debug_misc("rendezvous", "Received rendezvous datagram\n");
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 dns = mdns_read(rd->fd);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
433 if (dns == NULL)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
434 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
435
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
436 /* Handle the DNS packet */
8806
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
437 for (cur = dns->answers; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
438 rendezvous_handle_rr(gc, cur->data);
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
439 for (cur = dns->authority; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
440 rendezvous_handle_rr(gc, cur->data);
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
441 for (cur = dns->additional; cur != NULL; cur = cur->next)
8212661dc3cc [gaim-migrate @ 9568]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
442 rendezvous_handle_rr(gc, cur->data);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
443
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
444 mdns_free(dns);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
445 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
446
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
447 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
448 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
449 {
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
450 ResourceRecordRDataTXTNode *node;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
451 node = g_malloc(sizeof(ResourceRecordRDataTXTNode));
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
452 node->name = g_strdup(name);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
453 node->value = value != NULL ? g_strdup(value) : NULL;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
454 rd->mytxtdata = g_slist_append(rd->mytxtdata, node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
455 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
456
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
457 static guchar *
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
458 rendezvous_read_icon_data(const char *filename, unsigned short *length)
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
459 {
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
460 struct stat st;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
461 FILE *file;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
462 guchar *data;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
463
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
464 *length = 0;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
465
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
466 g_return_val_if_fail(filename != NULL, NULL);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
467
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10549
diff changeset
468 if (g_stat(filename, &st))
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
469 return NULL;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
470
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10549
diff changeset
471 if (!(file = g_fopen(filename, "rb")))
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
472 return NULL;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
473
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
474 *length = st.st_size;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
475 data = g_malloc(*length);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
476 fread(data, 1, *length, file);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
477 fclose(file);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
478
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
479 return data;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
480 }
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
481
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
482 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
483 rendezvous_add_to_txt_iconhash(RendezvousData *rd, const char *iconfile)
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
484 {
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
485 guchar *icondata;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
486 unsigned short iconlength;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
487 unsigned char hash[20];
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
488 gchar *base16;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
489
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
490 g_return_if_fail(rd != NULL);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
491
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
492 if (iconfile == NULL)
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
493 return;
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
494
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
495 icondata = rendezvous_read_icon_data(iconfile, &iconlength);
10705
194167d8a3b6 [gaim-migrate @ 12289]
Mark Doliner <mark@kingant.net>
parents: 10596
diff changeset
496 gaim_cipher_digest_region("sha1", (guint8 *)icondata, iconlength, sizeof(hash), hash, NULL);
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
497 g_free(icondata);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
498
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
499 base16 = gaim_base16_encode(hash, 20);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
500 rendezvous_add_to_txt(rd, "phsh", base16);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
501 g_free(base16);
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
502 }
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
503
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
504 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
505 rendezvous_send_icon(GaimConnection *gc)
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
506 {
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
507 RendezvousData *rd = gc->proto_data;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
508 GaimAccount *account = gaim_connection_get_account(gc);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
509 const char *iconfile = gaim_account_get_buddy_icon(account);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
510 unsigned char *rdata;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
511 unsigned short rdlength;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
512 gchar *myname;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
513
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
514 if (iconfile == NULL)
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
515 return;
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
516
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
517 rdata = rendezvous_read_icon_data(iconfile, &rdlength);
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
518
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
519 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
520 mdns_advertise_null(rd->fd, myname, rdata, rdlength);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
521 g_free(myname);
8695
a32481f393b9 [gaim-migrate @ 9448]
Mark Doliner <mark@kingant.net>
parents: 8636
diff changeset
522
a32481f393b9 [gaim-migrate @ 9448]
Mark Doliner <mark@kingant.net>
parents: 8636
diff changeset
523 g_free(rdata);
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
524 }
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
525
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
526 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
527 rendezvous_send_online(GaimConnection *gc)
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
528 {
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
529 RendezvousData *rd = gc->proto_data;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
530 GaimAccount *account = gaim_connection_get_account(gc);
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
531 const gchar *me, *myip;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
532 gchar *myname, *mycomp, *myport;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
533 gchar **mysplitip;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
534 unsigned char myipv4[4];
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
535
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
536 me = gaim_account_get_username(account);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
537 myname = g_strdup_printf("%s._presence._tcp.local", me);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
538 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
539 myport = g_strdup_printf("%d", rd->listener_port);
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
540
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
541 myip = gaim_network_get_local_system_ip(-1);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
542 mysplitip = g_strsplit(myip, ".", 0);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
543 myipv4[0] = atoi(mysplitip[0]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
544 myipv4[1] = atoi(mysplitip[1]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
545 myipv4[2] = atoi(mysplitip[2]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
546 myipv4[3] = atoi(mysplitip[3]);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
547 g_strfreev(mysplitip);
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
548
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
549 mdns_advertise_a(rd->fd, mycomp, myipv4);
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
550 mdns_advertise_ptr(rd->fd, "_presence._tcp.local", myname);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
551 mdns_advertise_srv(rd->fd, myname, rd->listener_port, mycomp);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
552
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
553 rendezvous_add_to_txt(rd, "txtvers", "1");
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
554 rendezvous_add_to_txt(rd, "status", "avail");
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
555 /* rendezvous_add_to_txt(rd, "vc", "A!"); */
9416
f63abdb00499 [gaim-migrate @ 10231]
Mark Doliner <mark@kingant.net>
parents: 9394
diff changeset
556 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
557 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
558 if (gaim_account_get_bool(account, "shareaim", FALSE)) {
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
559 GList *l;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
560 GaimAccount *cur;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
561 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
562 cur = (GaimAccount *)l->data;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
563 if (!strcmp(gaim_account_get_protocol_id(cur), "prpl-oscar")) {
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
564 rendezvous_add_to_txt(rd, "AIM", gaim_normalize(cur, gaim_account_get_username(cur)));
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
565 break;
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
566 }
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
567 }
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
568 }
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
569 rendezvous_add_to_txt(rd, "version", "1");
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
570 rendezvous_add_to_txt(rd, "msg", "Groovin'");
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
571 rendezvous_add_to_txt(rd, "port.p2pj", myport);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
572 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
573 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
574
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
575 rendezvous_send_icon(gc);
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
576
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
577 g_free(myname);
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
578 g_free(mycomp);
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
579 g_free(myport);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
580 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
581
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
582 static void
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
583 rendezvous_send_offline(GaimConnection *gc)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
584 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
585 RendezvousData *rd = gc->proto_data;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
586 GaimAccount *account = gaim_connection_get_account(gc);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
587 const gchar *me;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
588 gchar *myname;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
589
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
590 me = gaim_account_get_username(account);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
591 myname = g_strdup_printf("%s._presence._tcp.local", me);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
592
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
593 mdns_advertise_ptr_with_ttl(rd->fd, "_presence._tcp.local", myname, 0);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
594 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
595
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
596 /***********************************/
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
597 /* All the PRPL Callback Functions */
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
598 /***********************************/
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
599 static const char *
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
600 rendezvous_prpl_list_icon(GaimAccount *a, GaimBuddy *b)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
601 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
602 return "rendezvous";
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
603 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
604
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
605 static void
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
606 rendezvous_prpl_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
607 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
608 if (GAIM_BUDDY_IS_ONLINE(b)) {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
609 if (b->uc & UC_UNAVAILABLE)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
610 *se = "away";
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
611 } else {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
612 *se = "offline";
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
613 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
614 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
615
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
616 static gchar *
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
617 rendezvous_prpl_status_text(GaimBuddy *b)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
618 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
619 GaimConnection *gc = b->account->gc;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
620 RendezvousData *rd = gc->proto_data;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
621 RendezvousBuddy *rb;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
622 gchar *ret;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
623
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
624 rb = g_hash_table_lookup(rd->buddies, b->name);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
625 if ((rb == NULL) || (rb->msg == NULL))
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
626 return NULL;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
627
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
628 ret = g_strdup(rb->msg);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
629
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
630 return ret;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
631 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
632
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
633 static gchar *
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
634 rendezvous_prpl_tooltip_text(GaimBuddy *b)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
635 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
636 GaimConnection *gc = b->account->gc;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
637 RendezvousData *rd = gc->proto_data;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
638 RendezvousBuddy *rb;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
639 GString *ret;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
640
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
641 rb = g_hash_table_lookup(rd->buddies, b->name);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
642 if (rb == NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
643 return NULL;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
644
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
645 ret = g_string_new("");
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
646
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
647 if (rb->aim != NULL)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
648 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("AIM Screen name"), rb->aim);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
649
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
650 if (rb->msg != NULL) {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
651 if (rb->status == UC_UNAVAILABLE)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
652 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("Away"), rb->msg);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
653 else
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
654 g_string_append_printf(ret, "\n<b>%s</b>: %s", _("Available"), rb->msg);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
655 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
656
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
657 return g_string_free(ret, FALSE);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
658 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
659
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
660 static GList *
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
661 rendezvous_prpl_status_types(GaimAccount *account)
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
662 {
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
663 GList *status_types = NULL;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
664 GaimStatusType *type;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
665
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
666 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, "offline", _("Offline"), FALSE, TRUE, FALSE);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
667 status_types = g_list_append(status_types, type);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
668
10719
1da76f22c750 [gaim-migrate @ 12317]
Mark Doliner <mark@kingant.net>
parents: 10713
diff changeset
669 type = gaim_status_type_new_with_attrs(GAIM_STATUS_ONLINE, "available", _("Available"), FALSE, TRUE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL);
1da76f22c750 [gaim-migrate @ 12317]
Mark Doliner <mark@kingant.net>
parents: 10713
diff changeset
670 status_types = g_list_append(status_types, type);
1da76f22c750 [gaim-migrate @ 12317]
Mark Doliner <mark@kingant.net>
parents: 10713
diff changeset
671
1da76f22c750 [gaim-migrate @ 12317]
Mark Doliner <mark@kingant.net>
parents: 10713
diff changeset
672 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL);
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
673 status_types = g_list_append(status_types, type);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
674
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
675 return status_types;
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
676 }
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
677
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
678 static void
10401
3e4ecbdf8d0a [gaim-migrate @ 11638]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10321
diff changeset
679 rendezvous_prpl_login(GaimAccount *account, GaimStatus *status)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
680 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
681 GaimConnection *gc = gaim_account_get_connection(account);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
682 RendezvousData *rd;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
683
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
684 rd = g_new0(RendezvousData, 1);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
685 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
686 gc->proto_data = rd;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
687
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
688 gaim_connection_update_progress(gc, _("Preparing Buddy List"), 0, RENDEZVOUS_CONNECT_STEPS);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
689 rendezvous_removeallfromlocal(gc);
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 rd->listener = gaim_network_listen_range(5298, 5308);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
692 if (rd->listener == -1) {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
693 gaim_connection_error(gc, _("Unable to establish listening port."));
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
694 return;
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
695 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
696 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
697 rd->listener_port = gaim_network_get_port_from_fd(rd->listener);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
698
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
699 gaim_connection_update_progress(gc, _("Connecting"), 1, RENDEZVOUS_CONNECT_STEPS);
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
700 rd->fd = mdns_socket_establish();
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
701 if (rd->fd == -1) {
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
702 gaim_connection_error(gc, _("Unable to establish mDNS socket."));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
703 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
704 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
705
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
706 /*
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
707 * Watch our listening multicast UDP socket for incoming DNS
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
708 * packets.
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
709 */
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
710 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc);
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
711
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
712 gaim_connection_set_state(gc, GAIM_CONNECTED);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
713
8636
005c96dab551 [gaim-migrate @ 9388]
Mark Doliner <mark@kingant.net>
parents: 8634
diff changeset
714 mdns_query(rd->fd, "_presence._tcp.local", RENDEZVOUS_RRTYPE_ALL);
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
715 rendezvous_send_online(gc);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
716 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
717
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
718 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
719 rendezvous_prpl_close(GaimConnection *gc)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
720 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
721 RendezvousData *rd = (RendezvousData *)gc->proto_data;
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
722 ResourceRecordRDataTXTNode *node;
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
723
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
724 rendezvous_send_offline(gc);
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
725
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
726 if (gc->inpa)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
727 gaim_input_remove(gc->inpa);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
728
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
729 rendezvous_removeallfromlocal(gc);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
730
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
731 if (rd == NULL)
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
732 return;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
733
8834
beb7be215db3 [gaim-migrate @ 9598]
Mark Doliner <mark@kingant.net>
parents: 8806
diff changeset
734 mdns_socket_close(rd->fd);
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
735
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
736 if (rd->listener >= 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
737 close(rd->listener);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
738
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
739 if (rd->listener_watcher != 0)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
740 gaim_input_remove(rd->listener_watcher);
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
741
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
742 g_hash_table_destroy(rd->buddies);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
743
8629
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
744 while (rd->mytxtdata != NULL) {
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
745 node = rd->mytxtdata->data;
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
746 rd->mytxtdata = g_slist_remove(rd->mytxtdata, node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
747 g_free(node->name);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
748 g_free(node->value);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
749 g_free(node);
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
750 }
fdff0f31002d [gaim-migrate @ 9381]
Mark Doliner <mark@kingant.net>
parents: 8612
diff changeset
751
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
752 g_free(rd);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
753 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
754
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
755 static int
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
756 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
757 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
758 gaim_debug_info("rendezvous", "Sending IM\n");
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
759
10596
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
760 /*
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
761 * TODO: Need to interpret any GaimConvImFlags here, before
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
762 * calling rendezvous_direct_send_message().
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
763 */
913ec44675c3 [gaim-migrate @ 12011]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
764 rendezvous_direct_send_message(gc, who, message);
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
765
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
766 return 1;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
767 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
768
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
769 static void
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
770 rendezvous_prpl_set_status(GaimAccount *account, GaimStatus *status)
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
771 {
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
772 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
773 }
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
774
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
775 static GaimPlugin *my_protocol = NULL;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
776
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
777 static GaimPluginProtocolInfo prpl_info;
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 static GaimPluginInfo info =
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
780 {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
781 GAIM_PLUGIN_MAGIC,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
782 GAIM_MAJOR_VERSION,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9927
diff changeset
783 GAIM_MINOR_VERSION,
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784 GAIM_PLUGIN_PROTOCOL, /**< type */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
785 NULL, /**< ui_requirement */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
786 0, /**< flags */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
787 NULL, /**< dependencies */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788 GAIM_PRIORITY_DEFAULT, /**< priority */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
789
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
790 "prpl-rendezvous", /**< id */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
791 "Rendezvous", /**< name */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
792 VERSION, /**< version */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
793 /** summary */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
794 N_("Rendezvous Protocol Plugin"),
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
795 /** description */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
796 N_("Rendezvous Protocol Plugin"),
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
797 NULL, /**< author */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
798 GAIM_WEBSITE, /**< homepage */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
799
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
800 NULL, /**< load */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
801 NULL, /**< unload */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
802 NULL, /**< destroy */
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
803
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
804 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
805 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
806 NULL,
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8842
diff changeset
807 NULL
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
808 };
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
809
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
810 static void init_plugin(GaimPlugin *plugin)
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
811 {
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
812 GaimAccountUserSplit *split;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
813 GaimAccountOption *option;
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
814 char hostname[255];
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
815
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
816 prpl_info.options = OPT_PROTO_NO_PASSWORD;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
817 prpl_info.icon_spec.format = "jpeg";
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
818 prpl_info.icon_spec.min_width = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
819 prpl_info.icon_spec.min_height = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
820 prpl_info.icon_spec.max_width = 0;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
821 prpl_info.icon_spec.max_height = 0;
9394
ef79ee090cc5 [gaim-migrate @ 10203]
Mark Doliner <mark@kingant.net>
parents: 9318
diff changeset
822 prpl_info.icon_spec.scale_rules = 0;
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
823 prpl_info.list_icon = rendezvous_prpl_list_icon;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
824 prpl_info.list_emblems = rendezvous_prpl_list_emblems;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
825 prpl_info.status_text = rendezvous_prpl_status_text;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
826 prpl_info.tooltip_text = rendezvous_prpl_tooltip_text;
10549
8bc7ba019e96 [gaim-migrate @ 11919]
Mark Doliner <mark@kingant.net>
parents: 10401
diff changeset
827 prpl_info.status_types = rendezvous_prpl_status_types;
9318
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
828 prpl_info.login = rendezvous_prpl_login;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
829 prpl_info.close = rendezvous_prpl_close;
01c50436203e [gaim-migrate @ 10126]
Nathan Walp <nwalp@pidgin.im>
parents: 9313
diff changeset
830 prpl_info.send_im = rendezvous_prpl_send_im;
10321
782c1b564906 [gaim-migrate @ 11528]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
831 prpl_info.set_status = rendezvous_prpl_set_status;
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
832
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
833 if (gethostname(hostname, 255) != 0) {
10816
c94f40ffcafb [gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents: 10812
diff changeset
834 gaim_debug_warning("rendezvous", "Error %d when getting host name. Using \"localhost.\"\n", errno);
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
835 strcpy(hostname, "localhost");
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
836 }
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
837
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
838 /* Try to avoid making this configurable... */
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
839 split = gaim_account_user_split_new(_("Host name"), hostname, '@');
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
840 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
841
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
842 option = gaim_account_option_string_new(_("First name"), "first", "Gaim");
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
843 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
844 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
845
8842
ad3633f92f91 [gaim-migrate @ 9609]
Mark Doliner <mark@kingant.net>
parents: 8840
diff changeset
846 option = gaim_account_option_string_new(_("Last name"), "last", _("User"));
8487
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
847 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
848 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
849
8631
7b8f2818f38a [gaim-migrate @ 9383]
Mark Doliner <mark@kingant.net>
parents: 8629
diff changeset
850 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
851 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
852 option);
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
853
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
854 my_protocol = plugin;
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
855 }
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
856
c3ffec7fab94 [gaim-migrate @ 9222]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
857 GAIM_INIT_PLUGIN(rendezvous, init_plugin, info);