changeset 18582:882ea30935a9

merge of '68531d78c3d980fcba8b12d95053cfc541f7be31' and 'de1edd80332006c829962910c72b5d0edb9ab54d'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 21 Jul 2007 05:47:46 +0000
parents 743d183d09da (diff) dcb1d1af30a1 (current diff)
children cf7297803a73
files
diffstat 4 files changed, 45 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/Makefile.mingw	Sat Jul 21 05:45:04 2007 +0000
+++ b/libpurple/protocols/bonjour/Makefile.mingw	Sat Jul 21 05:47:46 2007 +0000
@@ -57,6 +57,7 @@
 			-lws2_32 \
 			-lintl \
 			-ldnssd \
+			-lnetapi32 \
 			-lpurple
 
 include $(PIDGIN_COMMON_RULES)
--- a/libpurple/protocols/bonjour/bonjour.c	Sat Jul 21 05:45:04 2007 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Sat Jul 21 05:47:46 2007 +0000
@@ -478,61 +478,53 @@
 	}
 
 #else
-	FARPROC myNetUserGetInfo = wpurple_find_and_loadproc("Netapi32.dll",
-		"NetUserGetInfo");
+	wchar_t username[UNLEN + 1];
+	DWORD dwLenUsername = UNLEN + 1;
+
+	if (!GetUserNameW((LPWSTR) &username, &dwLenUsername))
+		purple_debug_warning("bonjour", "Unable to look up username\n");
 
-	if (myNetUserGetInfo) {
-		LPUSER_INFO_10 user_info = NULL;
-		LPSERVER_INFO_100 server_info = NULL;
-		wchar_t *servername = NULL;
-		wchar_t username[UNLEN + 1];
-		DWORD dwLenUsername = UNLEN + 1;
-		FARPROC myNetServerEnum = wpurple_find_and_loadproc(
-			"Netapi32.dll", "NetServerEnum");
-		FARPROC myNetApiBufferFree = wpurple_find_and_loadproc(
-			"Netapi32.dll", "NetApiBufferFree");
+	if (username != NULL && *username != '\0') {
+		LPBYTE servername = NULL;
+		LPBYTE info = NULL;
+
+		NetGetDCName(NULL, NULL, &servername);
+
+		purple_debug_info("bonjour", "Looking up the full name from the %s.\n", (servername ? "domain controller" : "local machine"));
 
-		if (myNetServerEnum && myNetApiBufferFree) {
-			DWORD dwEntriesRead = 0;
-			DWORD dwTotalEntries = 0;
-			DWORD dwResumeHandle = 0;
+		if (NetUserGetInfo((LPCWSTR) servername, username, 10, &info) == NERR_Success
+				&& info != NULL && ((LPUSER_INFO_10) info)->usri10_full_name != NULL
+				&& *(((LPUSER_INFO_10) info)->usri10_full_name) != '\0') {
+			fullname = g_utf16_to_utf8(
+				((LPUSER_INFO_10) info)->usri10_full_name,
+				-1, NULL, NULL, NULL);
+		}
+		/* Fall back to the local machine if we didn't get the full name from the domain controller */
+		else if (servername != NULL) {
+			purple_debug_info("bonjour", "Looking up the full name from the local machine");
 
-			NET_API_STATUS nStatus = (myNetServerEnum)(NULL, 100,
-				&server_info, MAX_PREFERRED_LENGTH,
-				&dwEntriesRead, &dwTotalEntries,
-				SV_TYPE_DOMAIN_CTRL, NULL, &dwResumeHandle);
+			if (info != NULL) NetApiBufferFree(info);
+			info = NULL;
 
-			if ((nStatus == NERR_Success
-					|| nStatus == ERROR_MORE_DATA)
-					&& dwEntriesRead > 0) {
-				servername = server_info->sv100_name;
-			} else {
-				purple_debug_warning("bonjour", "Unable to look up domain controller. NET_API_STATUS = %d, Entries Read = %d, Total Entries = %d\n", nStatus, dwEntriesRead, dwTotalEntries);
+			if (NetUserGetInfo(NULL, username, 10, &info) == NERR_Success
+					&& info != NULL && ((LPUSER_INFO_10) info)->usri10_full_name != NULL
+					&& *(((LPUSER_INFO_10) info)->usri10_full_name) != '\0') {
+				fullname = g_utf16_to_utf8(
+					((LPUSER_INFO_10) info)->usri10_full_name,
+					-1, NULL, NULL, NULL);
 			}
 		}
 
-		if (!GetUserNameW((LPWSTR) &username, &dwLenUsername)) {
-			purple_debug_warning("bonjour",
-				"Unable to look up username\n");
-		}
-
-		if (username != NULL && *username != '\0'
-				&& (myNetUserGetInfo)(servername, username, 10,
-					&user_info) == NERR_Success) {
-			if (user_info != NULL) {
-				fullname = g_utf16_to_utf8(
-					user_info->usri10_full_name,
-					-1, NULL, NULL, NULL);
-			}
-		}
-		if (user_info != NULL)
-			(myNetApiBufferFree)(user_info);
-		if (server_info != NULL)
-			(myNetApiBufferFree)(server_info);
+		if (info != NULL) NetApiBufferFree(info);
+		if (servername != NULL) NetApiBufferFree(servername);
 	}
 
-	if (!fullname)
-		fullname = g_strdup(_("Purple Person"));
+	if (!fullname) {
+		if (username != NULL && *username != '\0')
+			fullname = g_utf16_to_utf8(username, -1, NULL, NULL, NULL);
+		else
+			fullname = g_strdup(_("Purple Person"));
+	}
 #endif
 
 	/* Split the real name into a first and last name */
--- a/libpurple/protocols/null/Makefile.mingw	Sat Jul 21 05:45:04 2007 +0000
+++ b/libpurple/protocols/null/Makefile.mingw	Sat Jul 21 05:47:46 2007 +0000
@@ -55,13 +55,15 @@
 ##
 ## TARGET DEFINITIONS
 ##
-.PHONY: all install clean
+.PHONY: all install install_real clean
 
 all: $(TARGET).dll
 
-install: all $(DLL_INSTALL_DIR) $(PURPLE_INSTALL_DIR)
+install_real: all $(DLL_INSTALL_DIR) $(PURPLE_INSTALL_DIR)
 	cp $(TARGET).dll $(DLL_INSTALL_DIR)
 
+install: all
+
 $(OBJECTS): $(PURPLE_CONFIG_H)
 
 $(TARGET).dll: $(PURPLE_DLL).a $(OBJECTS)
--- a/pidgin/gtknotify.c	Sat Jul 21 05:45:04 2007 +0000
+++ b/pidgin/gtknotify.c	Sat Jul 21 05:47:46 2007 +0000
@@ -672,13 +672,12 @@
 
 		for (j = 1; j < col_num; j++) {
 			GValue v;
-			char *escaped = g_markup_escape_text(g_list_nth_data(row, j - 1), -1);
+			char *data = g_list_nth_data(row, j - 1);
 
 			v.g_type = 0;
 			g_value_init(&v, G_TYPE_STRING);
-			g_value_set_string(&v, escaped);
+			g_value_set_string(&v, data);
 			gtk_list_store_set_value(model, &iter, j, &v);
-			g_free(escaped);
 		}
 	}