comparison src/protocols/rendezvous/rendezvous.c @ 8612:219e9638e8f3

[gaim-migrate @ 9363] Make sending mDNS datagrams more object oriented. And allow for advertising PTR records. And some other changes. Just wanted to commit this to the public archives in case my computer it seized in a hostile buy-out by kopete. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 08 Apr 2004 01:23:49 +0000
parents f3b928825a72
children fdff0f31002d
comparison
equal deleted inserted replaced
8611:05bc76d8e1b7 8612:219e9638e8f3
37 int fd; 37 int fd;
38 GHashTable *buddies; 38 GHashTable *buddies;
39 } RendezvousData; 39 } RendezvousData;
40 40
41 typedef struct _RendezvousBuddy { 41 typedef struct _RendezvousBuddy {
42 #if 0
43 guint ttltimer;
44 #endif
42 gchar *firstandlast; 45 gchar *firstandlast;
43 gchar *aim; 46 gchar *aim;
44 int p2pjport; 47 int p2pjport;
45 int status; 48 int status;
46 int idle; 49 int idle;
85 } 88 }
86 89
87 /****************************/ 90 /****************************/
88 /* Buddy List Functions */ 91 /* Buddy List Functions */
89 /****************************/ 92 /****************************/
93
90 static void rendezvous_addtolocal(GaimConnection *gc, const char *name, const char *domain) 94 static void rendezvous_addtolocal(GaimConnection *gc, const char *name, const char *domain)
91 { 95 {
92 GaimAccount *account = gaim_connection_get_account(gc); 96 GaimAccount *account = gaim_connection_get_account(gc);
93 GaimBuddy *b; 97 GaimBuddy *b;
94 GaimGroup *g; 98 GaimGroup *g;
104 return; 108 return;
105 109
106 b = gaim_buddy_new(account, name, NULL); 110 b = gaim_buddy_new(account, name, NULL);
107 gaim_blist_add_buddy(b, NULL, g, NULL); 111 gaim_blist_add_buddy(b, NULL, g, NULL);
108 serv_got_update(gc, b->name, 1, 0, 0, 0, 0); 112 serv_got_update(gc, b->name, 1, 0, 0, 0, 0);
113
114 #if 0
115 RendezvousBuddy *rb;
116 rb = g_hash_table_lookup(rd->buddies, name);
117 if (rb == NULL) {
118 rb = g_malloc0(sizeof(RendezvousBuddy));
119 g_hash_table_insert(rd->buddies, g_strdup(name), rb);
120 }
121 rb->ttltimer = gaim_timeout_add(time * 10000, rendezvous_buddy_timeout, gc);
122
123 gaim_timeout_remove(rb->ttltimer);
124 rb->ttltimer = 0;
125 #endif
109 } 126 }
110 127
111 static void rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain) 128 static void rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain)
112 { 129 {
113 GaimAccount *account = gaim_connection_get_account(gc); 130 GaimAccount *account = gaim_connection_get_account(gc);
123 return; 140 return;
124 141
125 serv_got_update(gc, b->name, 0, 0, 0, 0, 0); 142 serv_got_update(gc, b->name, 0, 0, 0, 0, 0);
126 gaim_blist_remove_buddy(b); 143 gaim_blist_remove_buddy(b);
127 /* XXX - This results in incorrect group counts--needs to be fixed in the core */ 144 /* XXX - This results in incorrect group counts--needs to be fixed in the core */
145
146 /*
147 * XXX - Instead of removing immediately, wait 10 seconds and THEN remove
148 * them. If you do it immediately you don't see the door close icon.
149 */
128 } 150 }
129 151
130 static void rendezvous_removeallfromlocal(GaimConnection *gc) 152 static void rendezvous_removeallfromlocal(GaimConnection *gc)
131 { 153 {
132 GaimAccount *account = gaim_connection_get_account(gc); 154 GaimAccount *account = gaim_connection_get_account(gc);
207 rb->status = 0; 229 rb->status = 0;
208 } else if (!strcmp(tmp1, "away")) { 230 } else if (!strcmp(tmp1, "away")) {
209 /* Idle */ 231 /* Idle */
210 tmp2 = g_hash_table_lookup(rdata, "away"); 232 tmp2 = g_hash_table_lookup(rdata, "away");
211 rb->idle = atoi(tmp2); 233 rb->idle = atoi(tmp2);
212 gaim_debug_error("XXX", "User has been idle for %d\n", rb->idle); 234 gaim_debug_error("XXX", "User has been idle since %d\n", rb->idle);
213 rb->status = UC_IDLE; 235 rb->status = UC_IDLE;
214 } else if (!strcmp(tmp1, "avail")) { 236 } else if (!strcmp(tmp1, "avail")) {
215 /* Away */ 237 /* Away */
216 rb->status = UC_UNAVAILABLE; 238 rb->status = UC_UNAVAILABLE;
217 } 239 }
274 if ((name = rendezvous_extract_name(rdata)) != NULL) { 296 if ((name = rendezvous_extract_name(rdata)) != NULL) {
275 if (rr->ttl > 0) 297 if (rr->ttl > 0)
276 rendezvous_addtolocal(gc, name, "Rendezvous"); 298 rendezvous_addtolocal(gc, name, "Rendezvous");
277 else 299 else
278 rendezvous_removefromlocal(gc, name, "Rendezvous"); 300 rendezvous_removefromlocal(gc, name, "Rendezvous");
279
280 g_free(name); 301 g_free(name);
281 } 302 }
282 } break; 303 } break;
283 304
284 case RENDEZVOUS_RRTYPE_TXT: { 305 case RENDEZVOUS_RRTYPE_TXT: {
405 426
406 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); 427 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc);
407 gaim_connection_set_state(gc, GAIM_CONNECTED); 428 gaim_connection_set_state(gc, GAIM_CONNECTED);
408 429
409 mdns_query(rd->fd, "_presence._tcp.local"); 430 mdns_query(rd->fd, "_presence._tcp.local");
431 /* mdns_advertise_ptr(rd->fd, "_presence._tcp.local", "mark@diverge._presence._tcp.local"); */
410 432
411 #if 0 433 #if 0
412 text_record_add("txtvers", "1"); 434 text_record_add("txtvers", "1");
413 text_record_add("status", "avail"); 435 text_record_add("status", "avail");
414 text_record_add("1st", gaim_account_get_string(account, "first", "Gaim")); 436 text_record_add("1st", gaim_account_get_string(account, "first", "Gaim"));