Mercurial > pidgin.yaz
comparison libpurple/protocols/bonjour/bonjour.c @ 17733:d7b50cac1c7a
This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
There are a few changes by me, mainly to fix the howl implementation.
Fixes #1117 .
There appear to be a few bugs, but I believe that they were also present previously. I'm hoping to do some more tweaking before the next release.
The howl implementation will eventually be supersceded by a native avahi implementation, so I opted for a somewhat dirty hack to enable it instead of doing something with config.h.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 05 Jun 2007 03:38:22 +0000 |
parents | 56042b2f8b64 |
children | c96b085ddf5c |
comparison
equal
deleted
inserted
replaced
17726:7e856734b712 | 17733:d7b50cac1c7a |
---|---|
35 #include "debug.h" | 35 #include "debug.h" |
36 #include "util.h" | 36 #include "util.h" |
37 #include "version.h" | 37 #include "version.h" |
38 | 38 |
39 #include "bonjour.h" | 39 #include "bonjour.h" |
40 #include "dns_sd.h" | 40 #include "mdns_common.h" |
41 #include "jabber.h" | 41 #include "jabber.h" |
42 #include "buddy.h" | 42 #include "buddy.h" |
43 | 43 |
44 /* | 44 /* |
45 * TODO: Should implement an add_buddy callback that removes the buddy | 45 * TODO: Should implement an add_buddy callback that removes the buddy |
118 return; | 118 return; |
119 } | 119 } |
120 | 120 |
121 /* Connect to the mDNS daemon looking for buddies in the LAN */ | 121 /* Connect to the mDNS daemon looking for buddies in the LAN */ |
122 bd->dns_sd_data = bonjour_dns_sd_new(); | 122 bd->dns_sd_data = bonjour_dns_sd_new(); |
123 bd->dns_sd_data->name = (sw_string)purple_account_get_username(account); | 123 bd->dns_sd_data->name = purple_account_get_username(account); |
124 bd->dns_sd_data->txtvers = g_strdup("1"); | 124 bd->dns_sd_data->txtvers = g_strdup("1"); |
125 bd->dns_sd_data->version = g_strdup("1"); | 125 bd->dns_sd_data->version = g_strdup("1"); |
126 bd->dns_sd_data->first = g_strdup(purple_account_get_string(account, "first", default_firstname)); | 126 bd->dns_sd_data->first = g_strdup(purple_account_get_string(account, "first", default_firstname)); |
127 bd->dns_sd_data->last = g_strdup(purple_account_get_string(account, "last", default_lastname)); | 127 bd->dns_sd_data->last = g_strdup(purple_account_get_string(account, "last", default_lastname)); |
128 bd->dns_sd_data->port_p2pj = bd->jabber_data->port; | 128 bd->dns_sd_data->port_p2pj = bd->jabber_data->port; |
489 | 489 |
490 if (myNetUserGetInfo) { | 490 if (myNetUserGetInfo) { |
491 LPUSER_INFO_10 user_info = NULL; | 491 LPUSER_INFO_10 user_info = NULL; |
492 LPSERVER_INFO_100 server_info = NULL; | 492 LPSERVER_INFO_100 server_info = NULL; |
493 wchar_t *servername = NULL; | 493 wchar_t *servername = NULL; |
494 wchar_t username[UNLEN + 1] = {'\0'}; | 494 wchar_t username[UNLEN + 1]; |
495 DWORD dwLenUsername = sizeof(username); | 495 DWORD dwLenUsername = UNLEN + 1; |
496 FARPROC myNetServerEnum = wpurple_find_and_loadproc( | 496 FARPROC myNetServerEnum = wpurple_find_and_loadproc( |
497 "Netapi32.dll", "NetServerEnum"); | 497 "Netapi32.dll", "NetServerEnum"); |
498 FARPROC myNetApiBufferFree = wpurple_find_and_loadproc( | 498 FARPROC myNetApiBufferFree = wpurple_find_and_loadproc( |
499 "Netapi32.dll", "NetApiBufferFree"); | 499 "Netapi32.dll", "NetApiBufferFree"); |
500 | 500 |
515 } else { | 515 } else { |
516 purple_debug_warning("bonjour", "Unable to look up domain controller. NET_API_STATUS = %d, Entries Read = %d, Total Entries = %d\n", nStatus, dwEntriesRead, dwTotalEntries); | 516 purple_debug_warning("bonjour", "Unable to look up domain controller. NET_API_STATUS = %d, Entries Read = %d, Total Entries = %d\n", nStatus, dwEntriesRead, dwTotalEntries); |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 if (!GetUserNameW(&username, &dwLenUsername)) { | 520 if (!GetUserNameW((LPWSTR) &username, &dwLenUsername)) { |
521 purple_debug_warning("bonjour", | 521 purple_debug_warning("bonjour", |
522 "Unable to look up username\n"); | 522 "Unable to look up username\n"); |
523 } | 523 } |
524 | 524 |
525 if (username != NULL && *username != '\0' | 525 if (username != NULL && *username != '\0' |
551 /* The last name may be followed by a comma and additional data. | 551 /* The last name may be followed by a comma and additional data. |
552 * Only use the last name itself. | 552 * Only use the last name itself. |
553 */ | 553 */ |
554 splitpoint = strchr(tmp, ','); | 554 splitpoint = strchr(tmp, ','); |
555 if (splitpoint != NULL) | 555 if (splitpoint != NULL) |
556 default_lastname = g_strndup(tmp, splitpoint - tmp); | 556 default_lastname = g_strndup(tmp, splitpoint - tmp); |
557 else | 557 else |
558 default_lastname = g_strdup(tmp); | 558 default_lastname = g_strdup(tmp); |
559 } | 559 } |
560 else | 560 else |
561 { | 561 { |