pidgin: a5416dfe: Fixed searching for buddies in Gadu-Gadu...

tomkiewicz at cpw.pidgin.im tomkiewicz at cpw.pidgin.im
Sat Jun 18 07:40:42 EDT 2011


----------------------------------------------------------------------
Revision: a5416dfeb373488f101a2c427d05130ed6824203
Parent:   d017acaf2df9b841859c8f49442ec64e3d752dd4
Author:   tomkiewicz at cpw.pidgin.im
Date:     06/18/11 07:29:11
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a5416dfeb373488f101a2c427d05130ed6824203

Changelog: 

Fixed searching for buddies in Gadu-Gadu public directory. Fixes #5242

Changes against parent d017acaf2df9b841859c8f49442ec64e3d752dd4

  patched  ChangeLog
  patched  libpurple/protocols/gg/gg.c
  patched  libpurple/protocols/gg/search.c
  patched  libpurple/protocols/gg/search.h

-------------- next part --------------
============================================================
--- ChangeLog	fb7edee9748a81183327c2a32000f0c7067f1526
+++ ChangeLog	c73ddcb3f79c54b6826cbf99155aca20f3e4abd1
@@ -11,6 +11,10 @@ version 2.8.1 (MM/DD/YYYY):
 	Plugins:
 	* The Evolution Integration plugin compiles again.
 
+	Gadu-Gadu:
+	* Fixed searching for buddies in public directory. (Tomasz Wasilczyk)
+	  (#5242)
+
 version 2.8.0 (06/07/2011):
 	General:
 	* Implement simple silence suppression for voice calls, preventing
============================================================
--- libpurple/protocols/gg/gg.c	441d8d1775e8bce5e1bf5d230823c11f8137c8a5
+++ libpurple/protocols/gg/gg.c	4947d4e2f17835153127f3cfaeff795dec4bdff7
@@ -487,15 +487,16 @@ static void ggp_callback_show_next(Purpl
 	GGPSearchForm *form = user_data;
 	guint32 seq;
 
-	g_free(form->offset);
-	form->offset = g_strdup(form->last_uin);
+	form->page_number++;
 
 	ggp_search_remove(info->searches, form->seq);
-	purple_debug_info("gg", "ggp_callback_show_next(): Removed seq %u", form->seq);
+	purple_debug_info("gg", "ggp_callback_show_next(): Removed seq %u\n",
+		form->seq);
 
 	seq = ggp_search_start(gc, form);
 	ggp_search_add(info->searches, seq, form);
-	purple_debug_info("gg", "ggp_callback_show_next(): Added seq %u", seq);
+	purple_debug_info("gg", "ggp_callback_show_next(): Added seq %u\n",
+		seq);
 }
 
 static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data)
@@ -526,21 +527,16 @@ static void ggp_callback_find_buddies(Pu
 	form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL);
 
 	form->user_data = info;
-	form->lastname  = charset_convert(
-				purple_request_fields_get_string(fields, "lastname"),
-				"UTF-8", "CP1250");
-	form->firstname = charset_convert(
-				purple_request_fields_get_string(fields, "firstname"),
-				"UTF-8", "CP1250");
-	form->nickname  = charset_convert(
-				purple_request_fields_get_string(fields, "nickname"),
-				"UTF-8", "CP1250");
-	form->city      = charset_convert(
-				purple_request_fields_get_string(fields, "city"),
-				"UTF-8", "CP1250");
-	form->birthyear = charset_convert(
-				purple_request_fields_get_string(fields, "year"),
-				"UTF-8", "CP1250");
+	form->lastname = g_strdup(
+		purple_request_fields_get_string(fields, "lastname"));
+	form->firstname = g_strdup(
+		purple_request_fields_get_string(fields, "firstname"));
+	form->nickname = g_strdup(
+		purple_request_fields_get_string(fields, "nickname"));
+	form->city = g_strdup(
+		purple_request_fields_get_string(fields, "city"));
+	form->birthyear = g_strdup(
+		purple_request_fields_get_string(fields, "year"));
 
 	switch (purple_request_fields_get_choice(fields, "gender")) {
 		case 1:
@@ -557,11 +553,10 @@ static void ggp_callback_find_buddies(Pu
 	form->active = purple_request_fields_get_bool(fields, "active")
 				   ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL;
 
-	form->offset = g_strdup("0");
-
 	seq = ggp_search_start(gc, form);
 	ggp_search_add(info->searches, seq, form);
-	purple_debug_info("gg", "ggp_callback_find_buddies(): Added seq %u", seq);
+	purple_debug_info("gg", "ggp_callback_find_buddies(): Added seq %u\n",
+		seq);
 }
 
 static void ggp_find_buddies(PurplePluginAction *action)
@@ -1131,7 +1126,8 @@ static void ggp_sr_close_cb(gpointer use
 	GGPInfo *info = form->user_data;
 
 	ggp_search_remove(info->searches, form->seq);
-	purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u", form->seq);
+	purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u\n",
+		form->seq);
 	ggp_search_form_destroy(form);
 }
 
@@ -1246,6 +1242,8 @@ static void ggp_pubdir_handle_full(Purpl
 
 	res_count = gg_pubdir50_count(req);
 	res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count;
+	if (form->page_size == 0)
+		form->page_size = res_count;
 
 	results = purple_notify_searchresults_new();
 
@@ -1255,7 +1253,8 @@ static void ggp_pubdir_handle_full(Purpl
 		purple_notify_error(gc, NULL,
 				  _("Unable to display the search results."),
 				  NULL);
-		ggp_sr_close_cb(form);
+		if (form->window == NULL)
+			ggp_sr_close_cb(form);
 		return;
 	}
 
@@ -1297,11 +1296,6 @@ static void ggp_pubdir_handle_full(Purpl
 			(birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-"));
 
 		purple_notify_searchresults_row_add(results, row);
-
-		if (i == res_count - 1) {
-			g_free(form->last_uin);
-			form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN);
-		}
 	}
 
 	purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE,
@@ -1342,7 +1336,8 @@ static void ggp_pubdir_reply_handler(Pur
 
 	seq = gg_pubdir50_seq(req);
 	form = ggp_search_get(info->searches, seq);
-	purple_debug_info("gg", "ggp_pubdir_reply_handler(): seq %u --> form %p", seq, form);
+	purple_debug_info("gg",
+		"ggp_pubdir_reply_handler(): seq %u --> form %p\n", seq, form);
 	/*
 	 * this can happen when user will request more results
 	 * and close the results window before they arrive.
@@ -1355,7 +1350,8 @@ static void ggp_pubdir_reply_handler(Pur
 		purple_notify_error(gc, NULL,
 			_("No matching users found"),
 			_("There are no users matching your search criteria."));
-		ggp_sr_close_cb(form);
+		if (form->window == NULL)
+			ggp_sr_close_cb(form);
 		return;
 	}
 
@@ -2382,8 +2378,6 @@ static void ggp_get_info(PurpleConnectio
 
 	form->user_data = info;
 	form->uin = g_strdup(name);
-	form->offset = g_strdup("0");
-	form->last_uin = g_strdup("0");
 
 	seq = ggp_search_start(gc, form);
 	ggp_search_add(info->searches, seq, form);
============================================================
--- libpurple/protocols/gg/search.c	3355e8266e67282ce253fd5b657bd75b3486b6c5
+++ libpurple/protocols/gg/search.c	4d0b0e6fbc1df100a9295e26ef66b7d670e5bf72
@@ -38,6 +38,8 @@ GGPSearchForm *ggp_search_form_new(GGPSe
 	form->window = NULL;
 	form->user_data = NULL;
 	form->seq = 0;
+	form->page_number = 0;
+	form->page_size = 0;
 
 	form->uin = NULL;
 	form->lastname = NULL;
@@ -47,8 +49,6 @@ GGPSearchForm *ggp_search_form_new(GGPSe
 	form->birthyear = NULL;
 	form->gender = NULL;
 	form->active = NULL;
-	form->offset = NULL;
-	form->last_uin = NULL;
 
 	return form;
 }
@@ -62,6 +62,8 @@ void ggp_search_form_destroy(GGPSearchFo
 	form->window = NULL;
 	form->user_data = NULL;
 	form->seq = 0;
+	form->page_number = 0;
+	form->page_size = 0;
 
 	g_free(form->uin);
 	g_free(form->lastname);
@@ -71,8 +73,6 @@ void ggp_search_form_destroy(GGPSearchFo
 	g_free(form->birthyear);
 	g_free(form->gender);
 	g_free(form->active);
-	g_free(form->offset);
-	g_free(form->last_uin);
 	g_free(form);
 }
 /* }}} */
@@ -137,7 +137,7 @@ guint32 ggp_search_start(PurpleConnectio
 {
 	GGPInfo *info = gc->proto_data;
 	gg_pubdir50_t req;
-	guint seq;
+	guint seq, offset;
 
 	purple_debug_info("gg", "It's time to perform a search...\n");
 
@@ -187,8 +187,10 @@ guint32 ggp_search_start(PurpleConnectio
 		}
 	}
 
-	purple_debug_info("gg", "offset: %s\n", form->offset);
-	gg_pubdir50_add(req, GG_PUBDIR50_START, g_strdup(form->offset));
+	offset = form->page_size * form->page_number;
+	purple_debug_info("gg", "page number: %u, page size: %u, offset: %u\n",
+		form->page_number, form->page_size, offset);
+	gg_pubdir50_add(req, GG_PUBDIR50_START, g_strdup_printf("%u", offset));
 
 	if ((seq = gg_pubdir50(info->session, req)) == 0) {
 		purple_debug_warning("gg", "ggp_bmenu_show_details: Search failed.\n");
============================================================
--- libpurple/protocols/gg/search.h	74550116ad813419caa8d938a3c035d91e7e3363
+++ libpurple/protocols/gg/search.h	23c916068529c5f317bdfb6b1f6d542ba1204bb8
@@ -46,12 +46,11 @@ typedef struct {
 	char *birthyear;
 	char *gender;
 	char *active;
-	char *offset;
 
-	char *last_uin;
-
 	GGPSearchType search_type;
 	guint32 seq;
+	guint16 page_number;
+	guint16 page_size; /* how many contacts fits into one page of results */
 
 	void *user_data;
 	void *window;


More information about the Commits mailing list