Mercurial > pidgin
comparison src/protocols/rendezvous/rendezvous.c @ 10321:782c1b564906
[gaim-migrate @ 11528]
Some rendezvous changes I've had sitting around for a while.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 05 Dec 2004 21:25:44 +0000 |
parents | 61852117568f |
children | 3e4ecbdf8d0a |
comparison
equal
deleted
inserted
replaced
10320:61852117568f | 10321:782c1b564906 |
---|---|
27 #include "conversation.h" | 27 #include "conversation.h" |
28 #include "debug.h" | 28 #include "debug.h" |
29 #include "network.h" | 29 #include "network.h" |
30 #include "prpl.h" | 30 #include "prpl.h" |
31 #include "sha.h" | 31 #include "sha.h" |
32 #include "version.h" | |
33 | |
34 #include "direct.h" | |
35 #include "mdns.h" | |
36 #include "rendezvous.h" | |
32 #include "util.h" | 37 #include "util.h" |
33 #include "version.h" | |
34 | |
35 #include "rendezvous.h" | |
36 #include "mdns.h" | |
37 | 38 |
38 /****************************/ | 39 /****************************/ |
39 /* Utility Functions */ | 40 /* Utility Functions */ |
40 /****************************/ | 41 /****************************/ |
41 static void rendezvous_buddy_free(gpointer data) | 42 static void |
43 rendezvous_buddy_free(gpointer data) | |
42 { | 44 { |
43 RendezvousBuddy *rb = data; | 45 RendezvousBuddy *rb = data; |
46 | |
47 if (rb->fd >= 0) | |
48 close(rb->fd); | |
49 if (rb->watcher >= 0) | |
50 gaim_input_remove(rb->watcher); | |
44 | 51 |
45 g_free(rb->firstandlast); | 52 g_free(rb->firstandlast); |
46 g_free(rb->msg); | 53 g_free(rb->msg); |
47 g_free(rb); | 54 g_free(rb); |
48 } | 55 } |
55 * then return NULL. Otherwise return a newly allocated | 62 * then return NULL. Otherwise return a newly allocated |
56 * null-terminated string containing the "user@host" for | 63 * null-terminated string containing the "user@host" for |
57 * the given domain. This string should be g_free'd | 64 * the given domain. This string should be g_free'd |
58 * when no longer needed. | 65 * when no longer needed. |
59 */ | 66 */ |
60 static gchar *rendezvous_extract_name(gchar *domain) | 67 static gchar * |
68 rendezvous_extract_name(gchar *domain) | |
61 { | 69 { |
62 gchar *ret, *suffix; | 70 gchar *ret, *suffix; |
63 | 71 |
64 if (!g_str_has_suffix(domain, "._presence._tcp.local")) | 72 if (!gaim_str_has_suffix(domain, "._presence._tcp.local")) |
65 return NULL; | 73 return NULL; |
66 | 74 |
67 suffix = strstr(domain, "._presence._tcp.local"); | 75 suffix = strstr(domain, "._presence._tcp.local"); |
68 ret = g_strndup(domain, suffix - domain); | 76 ret = g_strndup(domain, suffix - domain); |
69 | 77 |
72 | 80 |
73 /****************************/ | 81 /****************************/ |
74 /* Buddy List Functions */ | 82 /* Buddy List Functions */ |
75 /****************************/ | 83 /****************************/ |
76 | 84 |
77 static void rendezvous_addtolocal(GaimConnection *gc, const char *name, const char *domain) | 85 static void |
86 rendezvous_addtolocal(GaimConnection *gc, const char *name, const char *domain) | |
78 { | 87 { |
79 GaimAccount *account = gaim_connection_get_account(gc); | 88 GaimAccount *account = gaim_connection_get_account(gc); |
80 GaimBuddy *b; | 89 GaimBuddy *b; |
81 GaimGroup *g; | 90 GaimGroup *g; |
82 | 91 |
107 gaim_timeout_remove(rb->ttltimer); | 116 gaim_timeout_remove(rb->ttltimer); |
108 rb->ttltimer = 0; | 117 rb->ttltimer = 0; |
109 #endif | 118 #endif |
110 } | 119 } |
111 | 120 |
112 static void rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain) | 121 static void |
122 rendezvous_removefromlocal(GaimConnection *gc, const char *name, const char *domain) | |
113 { | 123 { |
114 GaimAccount *account = gaim_connection_get_account(gc); | 124 GaimAccount *account = gaim_connection_get_account(gc); |
115 GaimBuddy *b; | 125 GaimBuddy *b; |
116 GaimGroup *g; | 126 GaimGroup *g; |
117 | 127 |
132 * XXX - Instead of removing immediately, wait 10 seconds and THEN remove | 142 * XXX - Instead of removing immediately, wait 10 seconds and THEN remove |
133 * them. If you do it immediately you don't see the door close icon. | 143 * them. If you do it immediately you don't see the door close icon. |
134 */ | 144 */ |
135 } | 145 } |
136 | 146 |
137 static void rendezvous_removeallfromlocal(GaimConnection *gc) | 147 static void |
148 rendezvous_removeallfromlocal(GaimConnection *gc) | |
138 { | 149 { |
139 GaimAccount *account = gaim_connection_get_account(gc); | 150 GaimAccount *account = gaim_connection_get_account(gc); |
140 GaimBuddyList *blist; | 151 GaimBuddyList *blist; |
141 GaimBlistNode *gnode, *cnode, *bnode; | 152 GaimBlistNode *gnode, *cnode, *bnode; |
142 GaimBuddy *b; | 153 GaimBuddy *b; |
161 } | 172 } |
162 } | 173 } |
163 } | 174 } |
164 } | 175 } |
165 | 176 |
166 static void rendezvous_handle_rr_a(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | 177 static void |
178 rendezvous_handle_rr_a(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | |
167 { | 179 { |
168 RendezvousData *rd = gc->proto_data; | 180 RendezvousData *rd = gc->proto_data; |
169 RendezvousBuddy *rb; | 181 RendezvousBuddy *rb; |
170 ResourceRecordRDataSRV *rdata; | 182 ResourceRecordRDataSRV *rdata; |
171 | 183 |
175 if (rb == NULL) { | 187 if (rb == NULL) { |
176 rb = g_malloc0(sizeof(RendezvousBuddy)); | 188 rb = g_malloc0(sizeof(RendezvousBuddy)); |
177 g_hash_table_insert(rd->buddies, g_strdup(name), rb); | 189 g_hash_table_insert(rd->buddies, g_strdup(name), rb); |
178 } | 190 } |
179 | 191 |
180 #if 0 | 192 /* rb->ipv4 = gaim_network_convert_ipv4_to_string((unsigned char *)rdata); */ |
181 memcpy(rb->ip, rdata, 4); | 193 } |
182 #endif | 194 |
183 } | 195 static void |
184 | 196 rendezvous_handle_rr_txt(GaimConnection *gc, ResourceRecord *rr, const gchar *name) |
185 static void rendezvous_handle_rr_txt(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | |
186 { | 197 { |
187 RendezvousData *rd = gc->proto_data; | 198 RendezvousData *rd = gc->proto_data; |
188 GaimAccount *account = gaim_connection_get_account(gc); | 199 GaimAccount *account = gaim_connection_get_account(gc); |
189 RendezvousBuddy *rb; | 200 RendezvousBuddy *rb; |
190 GSList *rdata; | 201 GSList *rdata; |
256 g_free(rb->msg); | 267 g_free(rb->msg); |
257 rb->msg = g_strdup(node1->value); | 268 rb->msg = g_strdup(node1->value); |
258 } | 269 } |
259 } | 270 } |
260 | 271 |
261 static void rendezvous_handle_rr_srv(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | 272 static void |
273 rendezvous_handle_rr_aaaa(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | |
262 { | 274 { |
263 RendezvousData *rd = gc->proto_data; | 275 RendezvousData *rd = gc->proto_data; |
264 RendezvousBuddy *rb; | 276 RendezvousBuddy *rb; |
265 ResourceRecordRDataSRV *rdata; | 277 ResourceRecordRDataSRV *rdata; |
266 | 278 |
270 if (rb == NULL) { | 282 if (rb == NULL) { |
271 rb = g_malloc0(sizeof(RendezvousBuddy)); | 283 rb = g_malloc0(sizeof(RendezvousBuddy)); |
272 g_hash_table_insert(rd->buddies, g_strdup(name), rb); | 284 g_hash_table_insert(rd->buddies, g_strdup(name), rb); |
273 } | 285 } |
274 | 286 |
287 /* rb->ip = gaim_network_convert_ipv6_to_string((unsigned char *)rdata); */ | |
288 } | |
289 | |
290 static void | |
291 rendezvous_handle_rr_srv(GaimConnection *gc, ResourceRecord *rr, const gchar *name) | |
292 { | |
293 RendezvousData *rd = gc->proto_data; | |
294 RendezvousBuddy *rb; | |
295 ResourceRecordRDataSRV *rdata; | |
296 | |
297 rdata = rr->rdata; | |
298 | |
299 rb = g_hash_table_lookup(rd->buddies, name); | |
300 if (rb == NULL) { | |
301 rb = g_malloc0(sizeof(RendezvousBuddy)); | |
302 g_hash_table_insert(rd->buddies, g_strdup(name), rb); | |
303 } | |
304 | |
275 rb->p2pjport = rdata->port; | 305 rb->p2pjport = rdata->port; |
276 } | 306 } |
277 | 307 |
278 /* | 308 /* |
279 * Parse a resource record and do stuff if we need to. | 309 * Parse a resource record and do stuff if we need to. |
280 */ | 310 */ |
281 static void rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr) | 311 static void |
312 rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr) | |
282 { | 313 { |
283 RendezvousData *rd = gc->proto_data; | 314 RendezvousData *rd = gc->proto_data; |
284 gchar *name; | 315 gchar *name; |
285 | 316 |
286 gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s\n", rr->name); | 317 gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s and type %d\n", rr->name, rr->type); |
287 | 318 |
288 switch (rr->type) { | 319 switch (rr->type) { |
289 case RENDEZVOUS_RRTYPE_A: { | 320 case RENDEZVOUS_RRTYPE_A: { |
290 name = rendezvous_extract_name(rr->name); | 321 name = rendezvous_extract_name(rr->name); |
291 if (name != NULL) { | 322 if (name != NULL) { |
329 rendezvous_handle_rr_txt(gc, rr, name); | 360 rendezvous_handle_rr_txt(gc, rr, name); |
330 g_free(name); | 361 g_free(name); |
331 } | 362 } |
332 } break; | 363 } break; |
333 | 364 |
365 case RENDEZVOUS_RRTYPE_AAAA: { | |
366 name = rendezvous_extract_name(rr->name); | |
367 if (name != NULL) { | |
368 rendezvous_handle_rr_aaaa(gc, rr, name); | |
369 g_free(name); | |
370 } | |
371 } break; | |
372 | |
334 case RENDEZVOUS_RRTYPE_SRV: { | 373 case RENDEZVOUS_RRTYPE_SRV: { |
335 name = rendezvous_extract_name(rr->name); | 374 name = rendezvous_extract_name(rr->name); |
336 if (name != NULL) { | 375 if (name != NULL) { |
337 rendezvous_handle_rr_srv(gc, rr, name); | 376 rendezvous_handle_rr_srv(gc, rr, name); |
338 g_free(name); | 377 g_free(name); |
342 } | 381 } |
343 | 382 |
344 /****************************/ | 383 /****************************/ |
345 /* Icon and Emblem Functions */ | 384 /* Icon and Emblem Functions */ |
346 /****************************/ | 385 /****************************/ |
347 static const char* rendezvous_prpl_list_icon(GaimAccount *a, GaimBuddy *b) | 386 static const char * |
387 rendezvous_prpl_list_icon(GaimAccount *a, GaimBuddy *b) | |
348 { | 388 { |
349 return "rendezvous"; | 389 return "rendezvous"; |
350 } | 390 } |
351 | 391 |
352 static void rendezvous_prpl_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) | 392 static void |
393 rendezvous_prpl_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) | |
353 { | 394 { |
354 if (GAIM_BUDDY_IS_ONLINE(b)) { | 395 if (GAIM_BUDDY_IS_ONLINE(b)) { |
355 if (b->uc & UC_UNAVAILABLE) | 396 if (b->uc & UC_UNAVAILABLE) |
356 *se = "away"; | 397 *se = "away"; |
357 } else { | 398 } else { |
358 *se = "offline"; | 399 *se = "offline"; |
359 } | 400 } |
360 } | 401 } |
361 | 402 |
362 static gchar *rendezvous_prpl_status_text(GaimBuddy *b) | 403 static gchar * |
404 rendezvous_prpl_status_text(GaimBuddy *b) | |
363 { | 405 { |
364 GaimConnection *gc = b->account->gc; | 406 GaimConnection *gc = b->account->gc; |
365 RendezvousData *rd = gc->proto_data; | 407 RendezvousData *rd = gc->proto_data; |
366 RendezvousBuddy *rb; | 408 RendezvousBuddy *rb; |
367 gchar *ret; | 409 gchar *ret; |
373 ret = g_strdup(rb->msg); | 415 ret = g_strdup(rb->msg); |
374 | 416 |
375 return ret; | 417 return ret; |
376 } | 418 } |
377 | 419 |
378 static gchar *rendezvous_prpl_tooltip_text(GaimBuddy *b) | 420 static gchar * |
421 rendezvous_prpl_tooltip_text(GaimBuddy *b) | |
379 { | 422 { |
380 GaimConnection *gc = b->account->gc; | 423 GaimConnection *gc = b->account->gc; |
381 RendezvousData *rd = gc->proto_data; | 424 RendezvousData *rd = gc->proto_data; |
382 RendezvousBuddy *rb; | 425 RendezvousBuddy *rb; |
383 GString *ret; | 426 GString *ret; |
402 } | 445 } |
403 | 446 |
404 /****************************/ | 447 /****************************/ |
405 /* Connection Functions */ | 448 /* Connection Functions */ |
406 /****************************/ | 449 /****************************/ |
407 static void rendezvous_callback(gpointer data, gint source, GaimInputCondition condition) | 450 static void |
451 rendezvous_callback(gpointer data, gint source, GaimInputCondition condition) | |
408 { | 452 { |
409 GaimConnection *gc = data; | 453 GaimConnection *gc = data; |
410 RendezvousData *rd = gc->proto_data; | 454 RendezvousData *rd = gc->proto_data; |
411 DNSPacket *dns; | 455 DNSPacket *dns; |
412 GSList *cur; | 456 GSList *cur; |
426 rendezvous_handle_rr(gc, cur->data); | 470 rendezvous_handle_rr(gc, cur->data); |
427 | 471 |
428 mdns_free(dns); | 472 mdns_free(dns); |
429 } | 473 } |
430 | 474 |
431 static void rendezvous_add_to_txt(RendezvousData *rd, const char *name, const char *value) | 475 static void |
476 rendezvous_add_to_txt(RendezvousData *rd, const char *name, const char *value) | |
432 { | 477 { |
433 ResourceRecordRDataTXTNode *node; | 478 ResourceRecordRDataTXTNode *node; |
434 node = g_malloc(sizeof(ResourceRecordRDataTXTNode)); | 479 node = g_malloc(sizeof(ResourceRecordRDataTXTNode)); |
435 node->name = g_strdup(name); | 480 node->name = g_strdup(name); |
436 node->value = value != NULL ? g_strdup(value) : NULL; | 481 node->value = value != NULL ? g_strdup(value) : NULL; |
437 rd->mytxtdata = g_slist_append(rd->mytxtdata, node); | 482 rd->mytxtdata = g_slist_append(rd->mytxtdata, node); |
438 } | 483 } |
439 | 484 |
440 static guchar *rendezvous_read_icon_data(const char *filename, unsigned short *length) | 485 static guchar * |
486 rendezvous_read_icon_data(const char *filename, unsigned short *length) | |
441 { | 487 { |
442 struct stat st; | 488 struct stat st; |
443 FILE *file; | 489 FILE *file; |
444 guchar *data; | 490 guchar *data; |
445 | 491 |
459 fclose(file); | 505 fclose(file); |
460 | 506 |
461 return data; | 507 return data; |
462 } | 508 } |
463 | 509 |
464 static void rendezvous_add_to_txt_iconhash(RendezvousData *rd, const char *iconfile) | 510 static void |
511 rendezvous_add_to_txt_iconhash(RendezvousData *rd, const char *iconfile) | |
465 { | 512 { |
466 guchar *icondata; | 513 guchar *icondata; |
467 unsigned short iconlength; | 514 unsigned short iconlength; |
468 unsigned char hash[20]; | 515 unsigned char hash[20]; |
469 gchar *base16; | 516 gchar *base16; |
480 base16 = gaim_base16_encode(hash, 20); | 527 base16 = gaim_base16_encode(hash, 20); |
481 rendezvous_add_to_txt(rd, "phsh", base16); | 528 rendezvous_add_to_txt(rd, "phsh", base16); |
482 g_free(base16); | 529 g_free(base16); |
483 } | 530 } |
484 | 531 |
485 static void rendezvous_send_icon(GaimConnection *gc) | 532 static void |
533 rendezvous_send_icon(GaimConnection *gc) | |
486 { | 534 { |
487 RendezvousData *rd = gc->proto_data; | 535 RendezvousData *rd = gc->proto_data; |
488 GaimAccount *account = gaim_connection_get_account(gc); | 536 GaimAccount *account = gaim_connection_get_account(gc); |
489 const char *iconfile = gaim_account_get_buddy_icon(account); | 537 const char *iconfile = gaim_account_get_buddy_icon(account); |
490 unsigned char *rdata; | 538 unsigned char *rdata; |
501 g_free(myname); | 549 g_free(myname); |
502 | 550 |
503 g_free(rdata); | 551 g_free(rdata); |
504 } | 552 } |
505 | 553 |
506 static void rendezvous_send_online(GaimConnection *gc) | 554 static void |
555 rendezvous_send_online(GaimConnection *gc) | |
507 { | 556 { |
508 RendezvousData *rd = gc->proto_data; | 557 RendezvousData *rd = gc->proto_data; |
509 GaimAccount *account = gaim_connection_get_account(gc); | 558 GaimAccount *account = gaim_connection_get_account(gc); |
510 const gchar *me; | 559 const gchar *me; |
511 gchar *myname, *mycomp; | 560 gchar *myname, *mycomp, *myport; |
512 unsigned char myip[4]; | 561 unsigned char myipv4[4]; |
513 | 562 |
514 me = gaim_account_get_username(account); | 563 me = gaim_account_get_username(account); |
515 myname = g_strdup_printf("%s._presence._tcp.local", me); | 564 myname = g_strdup_printf("%s._presence._tcp.local", me); |
516 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1); | 565 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1); |
517 /* myip = gaim_network_ip_atoi(gaim_network_get_local_system_ip(-1)); */ | 566 /* myipv4 = gaim_network_ip_atoi(gaim_network_get_local_system_ip(-1)); */ |
518 myip[0] = 192; | 567 myipv4[0] = 192; |
519 myip[1] = 168; | 568 myipv4[1] = 168; |
520 myip[2] = 1; | 569 myipv4[2] = 1; |
521 myip[3] = 41; | 570 myipv4[3] = 41; |
522 | 571 myport = g_strdup_printf("%d", rd->listener_port); |
523 mdns_advertise_a(rd->fd, mycomp, myip); | 572 |
573 mdns_advertise_a(rd->fd, mycomp, myipv4); | |
524 mdns_advertise_ptr(rd->fd, "_presence._tcp.local", myname); | 574 mdns_advertise_ptr(rd->fd, "_presence._tcp.local", myname); |
525 mdns_advertise_srv(rd->fd, myname, 5298, mycomp); | 575 mdns_advertise_srv(rd->fd, myname, rd->listener_port, mycomp); |
526 | 576 |
527 rendezvous_add_to_txt(rd, "txtvers", "1"); | 577 rendezvous_add_to_txt(rd, "txtvers", "1"); |
528 rendezvous_add_to_txt(rd, "status", "avail"); | 578 rendezvous_add_to_txt(rd, "status", "avail"); |
529 /* rendezvous_add_to_txt(rd, "vc", "A!"); */ | 579 /* rendezvous_add_to_txt(rd, "vc", "A!"); */ |
530 rendezvous_add_to_txt_iconhash(rd, gaim_account_get_buddy_icon(account)); | 580 rendezvous_add_to_txt_iconhash(rd, gaim_account_get_buddy_icon(account)); |
541 } | 591 } |
542 } | 592 } |
543 } | 593 } |
544 rendezvous_add_to_txt(rd, "version", "1"); | 594 rendezvous_add_to_txt(rd, "version", "1"); |
545 rendezvous_add_to_txt(rd, "msg", "Groovin'"); | 595 rendezvous_add_to_txt(rd, "msg", "Groovin'"); |
546 rendezvous_add_to_txt(rd, "port.p2pj", "5298"); | 596 rendezvous_add_to_txt(rd, "port.p2pj", myport); |
547 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User"))); | 597 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User"))); |
548 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata); | 598 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata); |
549 | 599 |
550 rendezvous_send_icon(gc); | 600 rendezvous_send_icon(gc); |
551 | 601 |
552 g_free(myname); | 602 g_free(myname); |
553 g_free(mycomp); | 603 g_free(mycomp); |
554 } | 604 g_free(myport); |
555 | 605 } |
556 static void rendezvous_prpl_login(GaimAccount *account) | 606 |
607 static void | |
608 rendezvous_prpl_login(GaimAccount *account) | |
557 { | 609 { |
558 GaimConnection *gc = gaim_account_get_connection(account); | 610 GaimConnection *gc = gaim_account_get_connection(account); |
559 RendezvousData *rd; | 611 RendezvousData *rd; |
560 | 612 |
561 rd = g_new0(RendezvousData, 1); | 613 rd = g_new0(RendezvousData, 1); |
563 gc->proto_data = rd; | 615 gc->proto_data = rd; |
564 | 616 |
565 gaim_connection_update_progress(gc, _("Preparing Buddy List"), 0, RENDEZVOUS_CONNECT_STEPS); | 617 gaim_connection_update_progress(gc, _("Preparing Buddy List"), 0, RENDEZVOUS_CONNECT_STEPS); |
566 rendezvous_removeallfromlocal(gc); | 618 rendezvous_removeallfromlocal(gc); |
567 | 619 |
620 rd->listener = gaim_network_listen_range(5298, 5308); | |
621 if (rd->listener == -1) { | |
622 gaim_connection_error(gc, _("Unable to establish listening port.")); | |
623 return; | |
624 } | |
625 rd->listener_watcher = gaim_input_add(rd->listener, GAIM_INPUT_READ, rendezvous_direct_acceptconnection, gc); | |
626 rd->listener_port = gaim_network_get_port_from_fd(rd->listener); | |
627 | |
568 gaim_connection_update_progress(gc, _("Connecting"), 1, RENDEZVOUS_CONNECT_STEPS); | 628 gaim_connection_update_progress(gc, _("Connecting"), 1, RENDEZVOUS_CONNECT_STEPS); |
569 rd->fd = mdns_socket_establish(); | 629 rd->fd = mdns_socket_establish(); |
570 if (rd->fd == -1) { | 630 if (rd->fd == -1) { |
571 gaim_connection_error(gc, _("Unable to login to rendezvous")); | 631 gaim_connection_error(gc, _("Unable to establish mDNS socket.")); |
572 return; | 632 return; |
573 } | 633 } |
574 | 634 |
575 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); | 635 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); |
576 gaim_connection_set_state(gc, GAIM_CONNECTED); | 636 gaim_connection_set_state(gc, GAIM_CONNECTED); |
577 | 637 |
578 mdns_query(rd->fd, "_presence._tcp.local", RENDEZVOUS_RRTYPE_ALL); | 638 mdns_query(rd->fd, "_presence._tcp.local", RENDEZVOUS_RRTYPE_ALL); |
579 rendezvous_send_online(gc); | 639 rendezvous_send_online(gc); |
580 } | 640 } |
581 | 641 |
582 static void rendezvous_prpl_close(GaimConnection *gc) | 642 static void |
643 rendezvous_prpl_close(GaimConnection *gc) | |
583 { | 644 { |
584 RendezvousData *rd = (RendezvousData *)gc->proto_data; | 645 RendezvousData *rd = (RendezvousData *)gc->proto_data; |
585 ResourceRecordRDataTXTNode *node; | 646 ResourceRecordRDataTXTNode *node; |
586 | 647 |
587 if (gc->inpa) | 648 if (gc->inpa) |
588 gaim_input_remove(gc->inpa); | 649 gaim_input_remove(gc->inpa); |
589 | 650 |
590 rendezvous_removeallfromlocal(gc); | 651 rendezvous_removeallfromlocal(gc); |
591 | 652 |
592 if (!rd) | 653 if (rd == NULL) |
593 return; | 654 return; |
594 | 655 |
595 mdns_socket_close(rd->fd); | 656 mdns_socket_close(rd->fd); |
657 | |
658 if (rd->listener >= 0) | |
659 close(rd->listener); | |
660 | |
661 if (rd->listener_watcher != 0) | |
662 gaim_input_remove(rd->listener_watcher); | |
596 | 663 |
597 g_hash_table_destroy(rd->buddies); | 664 g_hash_table_destroy(rd->buddies); |
598 | 665 |
599 while (rd->mytxtdata != NULL) { | 666 while (rd->mytxtdata != NULL) { |
600 node = rd->mytxtdata->data; | 667 node = rd->mytxtdata->data; |
605 } | 672 } |
606 | 673 |
607 g_free(rd); | 674 g_free(rd); |
608 } | 675 } |
609 | 676 |
610 static int rendezvous_prpl_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags) | 677 static int |
678 rendezvous_prpl_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags) | |
611 { | 679 { |
612 gaim_debug_info("rendezvous", "Sending IM\n"); | 680 gaim_debug_info("rendezvous", "Sending IM\n"); |
613 | 681 |
614 return 1; | 682 return 1; |
683 } | |
684 | |
685 static void | |
686 rendezvous_prpl_set_status(GaimAccount *account, GaimStatus *status) | |
687 { | |
688 gaim_debug_error("rendezvous", "Set status to %s\n", gaim_status_get_name(status)); | |
615 } | 689 } |
616 | 690 |
617 static GaimPlugin *my_protocol = NULL; | 691 static GaimPlugin *my_protocol = NULL; |
618 | 692 |
619 static GaimPluginProtocolInfo prpl_info; | 693 static GaimPluginProtocolInfo prpl_info; |
667 prpl_info.status_text = rendezvous_prpl_status_text; | 741 prpl_info.status_text = rendezvous_prpl_status_text; |
668 prpl_info.tooltip_text = rendezvous_prpl_tooltip_text; | 742 prpl_info.tooltip_text = rendezvous_prpl_tooltip_text; |
669 prpl_info.login = rendezvous_prpl_login; | 743 prpl_info.login = rendezvous_prpl_login; |
670 prpl_info.close = rendezvous_prpl_close; | 744 prpl_info.close = rendezvous_prpl_close; |
671 prpl_info.send_im = rendezvous_prpl_send_im; | 745 prpl_info.send_im = rendezvous_prpl_send_im; |
746 prpl_info.set_status = rendezvous_prpl_set_status; | |
672 | 747 |
673 if (gethostname(hostname, 255) != 0) { | 748 if (gethostname(hostname, 255) != 0) { |
674 gaim_debug_warning("rendezvous", "Error %d when getting host name. Using \"localhost.\"\n", errno); | 749 gaim_debug_warning("rendezvous", "Error %d when getting host name. Using \"localhost.\"\n", errno); |
675 strcpy(hostname, "localhost"); | 750 strcpy(hostname, "localhost"); |
676 } | 751 } |