Mercurial > pidgin
comparison src/protocols/rendezvous/rendezvous.c @ 8629:fdff0f31002d
[gaim-migrate @ 9381]
Rendezvous updates: Advertise txt stuff for Gaim; just a step
toward having Gaim users show up in iChat rendezvous buddy
lists. Also a fix to make away people show up as away and
available people to not show up as away.
No one should be using this yet.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 11 Apr 2004 03:27:11 +0000 |
| parents | 219e9638e8f3 |
| children | 7b8f2818f38a |
comparison
equal
deleted
inserted
replaced
| 8628:54baaec95c05 | 8629:fdff0f31002d |
|---|---|
| 34 #define RENDEZVOUS_CONNECT_STEPS 2 | 34 #define RENDEZVOUS_CONNECT_STEPS 2 |
| 35 | 35 |
| 36 typedef struct _RendezvousData { | 36 typedef struct _RendezvousData { |
| 37 int fd; | 37 int fd; |
| 38 GHashTable *buddies; | 38 GHashTable *buddies; |
| 39 GSList *mytxtdata; | |
| 39 } RendezvousData; | 40 } RendezvousData; |
| 40 | 41 |
| 41 typedef struct _RendezvousBuddy { | 42 typedef struct _RendezvousBuddy { |
| 42 #if 0 | 43 #if 0 |
| 43 guint ttltimer; | 44 guint ttltimer; |
| 222 rb->p2pjport = atoi(tmp1); | 223 rb->p2pjport = atoi(tmp1); |
| 223 } | 224 } |
| 224 | 225 |
| 225 tmp1 = g_hash_table_lookup(rdata, "status"); | 226 tmp1 = g_hash_table_lookup(rdata, "status"); |
| 226 if (tmp1 != NULL) { | 227 if (tmp1 != NULL) { |
| 227 if (!strcmp(tmp1, "dnd")) { | 228 if (!strcmp(tmp1, "avail")) { |
| 228 /* Available */ | 229 /* Available */ |
| 229 rb->status = 0; | 230 rb->status = 0; |
| 230 } else if (!strcmp(tmp1, "away")) { | 231 } else if (!strcmp(tmp1, "away")) { |
| 231 /* Idle */ | 232 /* Idle */ |
| 232 tmp2 = g_hash_table_lookup(rdata, "away"); | 233 tmp2 = g_hash_table_lookup(rdata, "away"); |
| 233 rb->idle = atoi(tmp2); | 234 rb->idle = atoi(tmp2); |
| 234 gaim_debug_error("XXX", "User has been idle since %d\n", rb->idle); | 235 gaim_debug_error("XXX", "User has been idle since %d\n", rb->idle); |
| 235 rb->status = UC_IDLE; | 236 rb->status = UC_IDLE; |
| 236 } else if (!strcmp(tmp1, "avail")) { | 237 } else if (!strcmp(tmp1, "dnd")) { |
| 237 /* Away */ | 238 /* Away */ |
| 238 rb->status = UC_UNAVAILABLE; | 239 rb->status = UC_UNAVAILABLE; |
| 239 } | 240 } |
| 240 serv_got_update(gc, name, 1, 0, 0, 0, rb->status); | 241 serv_got_update(gc, name, 1, 0, 0, 0, rb->status); |
| 241 } | 242 } |
| 403 rendezvous_handle_rr(gc, &dns->additional[i]); | 404 rendezvous_handle_rr(gc, &dns->additional[i]); |
| 404 | 405 |
| 405 mdns_free(dns); | 406 mdns_free(dns); |
| 406 } | 407 } |
| 407 | 408 |
| 409 static void rendezvous_add_to_txt(RendezvousData *rd, const char *name, const char *value) | |
| 410 { | |
| 411 ResourceRecordTXTRDataNode *node; | |
| 412 node = g_malloc(sizeof(ResourceRecordTXTRDataNode)); | |
| 413 node->name = g_strdup(name); | |
| 414 node->value = value != NULL ? g_strdup(value) : NULL; | |
| 415 rd->mytxtdata = g_slist_append(rd->mytxtdata, node); | |
| 416 } | |
| 417 | |
| 418 static void rendezvous_send_online(GaimConnection *gc) | |
| 419 { | |
| 420 RendezvousData *rd = gc->proto_data; | |
| 421 GaimAccount *account = gaim_connection_get_account(gc); | |
| 422 | |
| 423 mdns_advertise_ptr(rd->fd, "_presence._tcp.local", "mark@diverge._presence._tcp.local"); | |
| 424 | |
| 425 rendezvous_add_to_txt(rd, "txtvers", "1"); | |
| 426 rendezvous_add_to_txt(rd, "status", "avail"); | |
| 427 rendezvous_add_to_txt(rd, "1st", gaim_account_get_string(account, "first", "Gaim")); | |
| 428 rendezvous_add_to_txt(rd, "AIM", "markdoliner"); | |
| 429 rendezvous_add_to_txt(rd, "version", "1"); | |
| 430 rendezvous_add_to_txt(rd, "port.p2pj", "5298"); | |
| 431 rendezvous_add_to_txt(rd, "last", gaim_account_get_string(account, "last", _("User"))); | |
| 432 mdns_advertise_txt(rd->fd, "mark@diverge._presence._tcp.local", rd->mytxtdata); | |
| 433 | |
| 434 #if 0 | |
| 435 mdns_advertise_srv(rd->fd, "mark@diverge._presence._tcp.local", port 5298, IP?); | |
| 436 #endif | |
| 437 } | |
| 438 | |
| 408 static void rendezvous_prpl_login(GaimAccount *account) | 439 static void rendezvous_prpl_login(GaimAccount *account) |
| 409 { | 440 { |
| 410 GaimConnection *gc = gaim_account_get_connection(account); | 441 GaimConnection *gc = gaim_account_get_connection(account); |
| 411 RendezvousData *rd; | 442 RendezvousData *rd; |
| 412 | 443 |
| 426 | 457 |
| 427 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); | 458 gc->inpa = gaim_input_add(rd->fd, GAIM_INPUT_READ, rendezvous_callback, gc); |
| 428 gaim_connection_set_state(gc, GAIM_CONNECTED); | 459 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 429 | 460 |
| 430 mdns_query(rd->fd, "_presence._tcp.local"); | 461 mdns_query(rd->fd, "_presence._tcp.local"); |
| 431 /* mdns_advertise_ptr(rd->fd, "_presence._tcp.local", "mark@diverge._presence._tcp.local"); */ | 462 rendezvous_send_online(gc); |
| 432 | |
| 433 #if 0 | |
| 434 text_record_add("txtvers", "1"); | |
| 435 text_record_add("status", "avail"); | |
| 436 text_record_add("1st", gaim_account_get_string(account, "first", "Gaim")); | |
| 437 text_record_add("AIM", "markdoliner"); | |
| 438 text_record_add("version", "1"); | |
| 439 text_record_add("port.p2pj", "5298"); | |
| 440 text_record_add("last", gaim_account_get_string(account, "last", _("User"))); | |
| 441 | |
| 442 publish(account->username, "_presence._tcp", 5298); | |
| 443 #endif | |
| 444 } | 463 } |
| 445 | 464 |
| 446 static void rendezvous_prpl_close(GaimConnection *gc) | 465 static void rendezvous_prpl_close(GaimConnection *gc) |
| 447 { | 466 { |
| 448 RendezvousData *rd = (RendezvousData *)gc->proto_data; | 467 RendezvousData *rd = (RendezvousData *)gc->proto_data; |
| 468 ResourceRecordTXTRDataNode *node; | |
| 449 | 469 |
| 450 if (gc->inpa) | 470 if (gc->inpa) |
| 451 gaim_input_remove(gc->inpa); | 471 gaim_input_remove(gc->inpa); |
| 452 | 472 |
| 453 rendezvous_removeallfromlocal(gc); | 473 rendezvous_removeallfromlocal(gc); |
| 457 | 477 |
| 458 if (rd->fd >= 0) | 478 if (rd->fd >= 0) |
| 459 close(rd->fd); | 479 close(rd->fd); |
| 460 | 480 |
| 461 g_hash_table_destroy(rd->buddies); | 481 g_hash_table_destroy(rd->buddies); |
| 482 | |
| 483 while (rd->mytxtdata != NULL) { | |
| 484 node = rd->mytxtdata->data; | |
| 485 rd->mytxtdata = g_slist_remove(rd->mytxtdata, node); | |
| 486 g_free(node->name); | |
| 487 g_free(node->value); | |
| 488 g_free(node); | |
| 489 } | |
| 462 | 490 |
| 463 g_free(rd); | 491 g_free(rd); |
| 464 } | 492 } |
| 465 | 493 |
| 466 static int rendezvous_prpl_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags) | 494 static int rendezvous_prpl_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags) |
