Mercurial > pidgin.yaz
diff src/protocols/rendezvous/rendezvous.c @ 8594:f3b928825a72
[gaim-migrate @ 9345]
Some minor rendezvous changes. You still shouldn't use this yet,
it has a long way to go.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 06 Apr 2004 05:16:02 +0000 |
parents | f96795b786d2 |
children | 219e9638e8f3 |
line wrap: on
line diff
--- a/src/protocols/rendezvous/rendezvous.c Tue Apr 06 02:52:58 2004 +0000 +++ b/src/protocols/rendezvous/rendezvous.c Tue Apr 06 05:16:02 2004 +0000 @@ -163,14 +163,19 @@ GHashTable *rdata; gchar *tmp1, *tmp2; + rdata = rr->rdata; + + /* Don't do a damn thing if the version is greater than 1 */ + tmp1 = g_hash_table_lookup(rdata, "version"); + if ((tmp1 == NULL) || (strcmp(tmp1, "1"))) + return; + rb = g_hash_table_lookup(rd->buddies, name); if (rb == NULL) { rb = g_malloc0(sizeof(RendezvousBuddy)); g_hash_table_insert(rd->buddies, g_strdup(name), rb); } - rdata = rr->rdata; - tmp1 = g_hash_table_lookup(rdata, "1st"); tmp2 = g_hash_table_lookup(rdata, "last"); g_free(rb->firstandlast); @@ -186,8 +191,14 @@ rb->aim = g_strdup(tmp1); } - tmp1 = g_hash_table_lookup(rdata, "port.p2pj"); - rb->p2pjport = atoi(tmp1); + /* + * We only want to use this port as a back-up. Ideally the port + * is specified in a separate, SRV resource record. + */ + if (rb->p2pjport == 0) { + tmp1 = g_hash_table_lookup(rdata, "port.p2pj"); + rb->p2pjport = atoi(tmp1); + } tmp1 = g_hash_table_lookup(rdata, "status"); if (tmp1 != NULL) { @@ -212,8 +223,23 @@ g_free(rb->msg); rb->msg = g_strdup(tmp1); } +} - /* XXX - Use the TTL value of the rr to cause this data to expire */ +static void rendezvous_handle_rr_srv(GaimConnection *gc, ResourceRecord *rr, const gchar *name) +{ + RendezvousData *rd = gc->proto_data; + RendezvousBuddy *rb; + ResourceRecordSRV *rdata; + + rdata = rr->rdata; + + rb = g_hash_table_lookup(rd->buddies, name); + if (rb == NULL) { + rb = g_malloc0(sizeof(RendezvousBuddy)); + g_hash_table_insert(rd->buddies, g_strdup(name), rb); + } + + rb->p2pjport = rdata->port; } /* @@ -223,7 +249,13 @@ { gchar *name; - gaim_debug_error("XXX", "Parsing resource record with domain name %s\n", rr->name); + gaim_debug_misc("rendezvous", "Parsing resource record with domain name %s\n", rr->name); + + /* + * XXX - Cache resource records from this function, if needed. + * Use the TTL value of the rr to cause this data to expire, but let + * the mdns_cache stuff handle that as much as possible. + */ switch (rr->type) { case RENDEZVOUS_RRTYPE_NULL: { @@ -255,6 +287,13 @@ g_free(name); } } break; + + case RENDEZVOUS_RRTYPE_SRV: { + if ((name = rendezvous_extract_name(rr->name)) != NULL) { + rendezvous_handle_rr_srv(gc, rr, name); + g_free(name); + } + } break; } } @@ -315,8 +354,6 @@ g_string_append_printf(ret, "\n<b>%s</b>: %s", _("Available"), rb->msg); } - /* XXX - Fix blist.c so we can prepend the \n's rather than appending them */ - return g_string_free(ret, FALSE); }