annotate src/protocols/rendezvous/rendezvous.c @ 10027:5151c6788f3d

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