Mercurial > pidgin.yaz
comparison src/protocols/rendezvous/rendezvous.c @ 8636:005c96dab551
[gaim-migrate @ 9388]
I finished all my overflow checking and what not. If anyone else
wants to look over it feel free... Null resource records (buddy
icons) should be getting sent now, too. I'm not really sure why
I'm not showing up in my iChat buddy list. Gaim rendezvous people
show up in gaim rendezvous buddy lists, I think.
Eh, I still have to deal with caching and handling queries.
And then messaging.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 12 Apr 2004 01:17:10 +0000 |
parents | bcb09cc97b63 |
children | a32481f393b9 |
comparison
equal
deleted
inserted
replaced
8635:4aee5a47937d | 8636:005c96dab551 |
---|---|
268 /* | 268 /* |
269 * Parse a resource record and do stuff if we need to. | 269 * Parse a resource record and do stuff if we need to. |
270 */ | 270 */ |
271 static void rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr) | 271 static void rendezvous_handle_rr(GaimConnection *gc, ResourceRecord *rr) |
272 { | 272 { |
273 RendezvousData *rd = gc->proto_data; | |
273 gchar *name; | 274 gchar *name; |
274 | 275 |
275 gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s\n", rr->name); | 276 gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s\n", rr->name); |
276 | 277 |
277 /* | 278 /* |
293 } break; | 294 } break; |
294 | 295 |
295 case RENDEZVOUS_RRTYPE_PTR: { | 296 case RENDEZVOUS_RRTYPE_PTR: { |
296 gchar *rdata = rr->rdata; | 297 gchar *rdata = rr->rdata; |
297 if ((name = rendezvous_extract_name(rdata)) != NULL) { | 298 if ((name = rendezvous_extract_name(rdata)) != NULL) { |
298 if (rr->ttl > 0) | 299 if (rr->ttl > 0) { |
300 /* Add them to our buddy list and request their icon */ | |
299 rendezvous_addtolocal(gc, name, "Rendezvous"); | 301 rendezvous_addtolocal(gc, name, "Rendezvous"); |
300 else | 302 mdns_query(rd->fd, rdata, RENDEZVOUS_RRTYPE_NULL); |
303 } else { | |
304 /* Remove them from our buddy list */ | |
301 rendezvous_removefromlocal(gc, name, "Rendezvous"); | 305 rendezvous_removefromlocal(gc, name, "Rendezvous"); |
306 } | |
302 g_free(name); | 307 g_free(name); |
303 } | 308 } |
304 } break; | 309 } break; |
305 | 310 |
306 case RENDEZVOUS_RRTYPE_TXT: { | 311 case RENDEZVOUS_RRTYPE_TXT: { |
413 node->name = g_strdup(name); | 418 node->name = g_strdup(name); |
414 node->value = value != NULL ? g_strdup(value) : NULL; | 419 node->value = value != NULL ? g_strdup(value) : NULL; |
415 rd->mytxtdata = g_slist_append(rd->mytxtdata, node); | 420 rd->mytxtdata = g_slist_append(rd->mytxtdata, node); |
416 } | 421 } |
417 | 422 |
423 static void rendezvous_send_icon(GaimConnection *gc) | |
424 { | |
425 RendezvousData *rd = gc->proto_data; | |
426 GaimAccount *account = gaim_connection_get_account(gc); | |
427 const char *iconfile = gaim_account_get_buddy_icon(account); | |
428 struct stat st; | |
429 FILE *file; | |
430 unsigned char *rdata; | |
431 unsigned short rdlength; | |
432 gchar *myname; | |
433 | |
434 if (iconfile == NULL) | |
435 return; | |
436 | |
437 if (stat(iconfile, &st)) | |
438 return; | |
439 | |
440 if (!(file = fopen(iconfile, "rb"))) | |
441 return; | |
442 | |
443 rdlength = st.st_size; | |
444 rdata = g_malloc(rdlength); | |
445 fread(rdata, 1, rdlength, file); | |
446 fclose(file); | |
447 | |
448 myname = g_strdup_printf("%s._presence._tcp.local", gaim_account_get_username(account)); | |
449 mdns_advertise_null(rd->fd, myname, rdata, rdlength); | |
450 g_free(myname); | |
451 } | |
452 | |
418 static void rendezvous_send_online(GaimConnection *gc) | 453 static void rendezvous_send_online(GaimConnection *gc) |
419 { | 454 { |
420 RendezvousData *rd = gc->proto_data; | 455 RendezvousData *rd = gc->proto_data; |
421 GaimAccount *account = gaim_connection_get_account(gc); | 456 GaimAccount *account = gaim_connection_get_account(gc); |
422 const char *me; | 457 const gchar *me; |
423 char *myname, *mycomp; | 458 gchar *myname, *mycomp; |
424 | 459 |
425 me = gaim_account_get_username(account); | 460 me = gaim_account_get_username(account); |
426 myname = g_strdup_printf("%s._presence._tcp.local", me); | 461 myname = g_strdup_printf("%s._presence._tcp.local", me); |
427 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1); | 462 mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1); |
428 | 463 |
450 rendezvous_add_to_txt(rd, "msg", "Groovin'"); | 485 rendezvous_add_to_txt(rd, "msg", "Groovin'"); |
451 rendezvous_add_to_txt(rd, "port.p2pj", "5298"); | 486 rendezvous_add_to_txt(rd, "port.p2pj", "5298"); |
452 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User"))); | 487 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User"))); |
453 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata); | 488 mdns_advertise_txt(rd->fd, myname, rd->mytxtdata); |
454 | 489 |
490 rendezvous_send_icon(gc); | |
491 | |
455 g_free(myname); | 492 g_free(myname); |
456 g_free(mycomp); | 493 g_free(mycomp); |
457 } | 494 } |
458 | 495 |
459 static void rendezvous_prpl_login(GaimAccount *account) | 496 static void rendezvous_prpl_login(GaimAccount *account) |
476 } | 513 } |
477 | 514 |
478 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); | 515 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); |
479 gaim_connection_set_state(gc, GAIM_CONNECTED); | 516 gaim_connection_set_state(gc, GAIM_CONNECTED); |
480 | 517 |
481 mdns_query(rd->fd, "_presence._tcp.local"); | 518 mdns_query(rd->fd, "_presence._tcp.local", RENDEZVOUS_RRTYPE_ALL); |
482 rendezvous_send_online(gc); | 519 rendezvous_send_online(gc); |
483 } | 520 } |
484 | 521 |
485 static void rendezvous_prpl_close(GaimConnection *gc) | 522 static void rendezvous_prpl_close(GaimConnection *gc) |
486 { | 523 { |
525 | 562 |
526 static GaimPlugin *my_protocol = NULL; | 563 static GaimPlugin *my_protocol = NULL; |
527 | 564 |
528 static GaimPluginProtocolInfo prpl_info = | 565 static GaimPluginProtocolInfo prpl_info = |
529 { | 566 { |
530 OPT_PROTO_NO_PASSWORD, | 567 OPT_PROTO_NO_PASSWORD | OPT_PROTO_BUDDY_ICON, |
531 NULL, | 568 NULL, |
532 NULL, | 569 NULL, |
533 NULL, | 570 NULL, |
534 rendezvous_prpl_list_icon, | 571 rendezvous_prpl_list_icon, |
535 rendezvous_prpl_list_emblems, | 572 rendezvous_prpl_list_emblems, |