changeset 12257:ca27de274225

[gaim-migrate @ 14559] Patches from Bartosz Oler with some changes by me. The summary of changes is: 1. Fix a silly bug I introduced when editing previous patches. 2. Add some error handling. 3. Unify some types. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 29 Nov 2005 19:26:03 +0000
parents 0eed625872f7
children 2b61f681ff99
files plugins/ChangeLog.API src/gtknotify.c src/notify.c src/notify.h src/protocols/gg/gg.c src/protocols/oscar/oscar.c
diffstat 6 files changed, 54 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Tue Nov 29 18:25:12 2005 +0000
+++ b/plugins/ChangeLog.API	Tue Nov 29 19:26:03 2005 +0000
@@ -62,6 +62,8 @@
 	  don't support html need to gaim_unescape_html() the message.
 	* Notify API: GCallback -> GaimNotifyCloseCallback,
 	              void *user_data -> gpointer user_data
+	* gaim_notify_searchresults_get_rows_count,
+	  gaim_notify_searchresults_get_columns_count: return type now guint
 
 	Removed:
 	* gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
--- a/src/gtknotify.c	Tue Nov 29 18:25:12 2005 +0000
+++ b/src/gtknotify.c	Tue Nov 29 19:26:03 2005 +0000
@@ -437,8 +437,9 @@
 	GtkListStore *model = data->model;
 	GtkTreeIter iter;
 	GdkPixbuf *icon, *scaled;
-	int col_num;
-	int i, j;
+	guint col_num;
+	guint i;
+	guint j;
 	
 	gtk_list_store_clear(data->model);
 
@@ -477,9 +478,8 @@
 	GType *col_types;
 	GtkListStore *model;
 	GtkCellRenderer *renderer;
-	int col_num;
-	int i;
-	guint j;
+	guint col_num;
+	guint i;
 	GList *buttons = NULL;
 
 	GtkWidget *vbox;
@@ -490,6 +490,9 @@
 	char *label_text;
 	char *primary_esc, *secondary_esc;
 
+	g_return_val_if_fail(gc != NULL, NULL);
+	g_return_val_if_fail(results != NULL, NULL);
+
 	data = g_malloc(sizeof(GaimNotifySearchResultsData));
 
 	/* Create the window */
@@ -575,8 +578,8 @@
 	gtk_box_set_spacing(GTK_BOX(button_area), GAIM_HIG_BORDER);
 	gtk_widget_show(button_area);
 
-	for (j = 0; j < g_list_length(results->buttons); j++) {
-		GaimNotifySearchButton *b = g_list_nth_data(results->buttons, j);
+	for (i = 0; i < g_list_length(results->buttons); i++) {
+		GaimNotifySearchButton *b = g_list_nth_data(results->buttons, i);
 		button = NULL;
 		switch (b->type) {
 			case GAIM_NOTIFY_BUTTON_CONTINUE:
@@ -609,7 +612,7 @@
 	gaim_gtk_notify_searchresults_new_rows(gc, results, data, NULL);
 
 	/* Connect Signals */
-	for (j = 0; j < g_list_length(results->buttons); j++) {
+	for (i = 0; i < g_list_length(results->buttons); i++) {
 		GaimNotifySearchResultsButtonData *bd = g_new0(GaimNotifySearchResultsButtonData, 1);
 		bd->button = g_list_nth_data(results->buttons, i);
 		bd->data = data;
--- a/src/notify.c	Tue Nov 29 18:25:12 2005 +0000
+++ b/src/notify.c	Tue Nov 29 19:26:03 2005 +0000
@@ -301,18 +301,18 @@
 	return sc;
 }
 
-int
+guint
 gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results)
 {
-	g_return_val_if_fail(results != NULL, -1);
+	g_return_val_if_fail(results != NULL, 0);
 
 	return g_list_length(results->columns);
 }
 
-int
+guint
 gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results)
 {
-	g_return_val_if_fail(results != NULL, -1);
+	g_return_val_if_fail(results != NULL, 0);
 
 	return g_list_length(results->rows);
 }
--- a/src/notify.h	Tue Nov 29 18:25:12 2005 +0000
+++ b/src/notify.h	Tue Nov 29 19:26:03 2005 +0000
@@ -228,18 +228,18 @@
  * 
  * @param results The search results object.
  *
- * @return Number of the result rows. Or -1 if an error occurrs.
+ * @return Number of the result rows.
  */
-int gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results);
+guint gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results);
 
 /**
  * Returns a number of the columns in the search results object.
  *
  * @param results The search results object.
  *
- * @return Number of the columns. Or -1 if an error occurrs.
+ * @return Number of the columns.
  */
-int gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results);
+guint gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results);
 
 /**
  * Returns a row of the results from the search results object.
--- a/src/protocols/gg/gg.c	Tue Nov 29 18:25:12 2005 +0000
+++ b/src/protocols/gg/gg.c	Tue Nov 29 19:26:03 2005 +0000
@@ -971,6 +971,16 @@
 
 	results = gaim_notify_searchresults_new();
 
+	if (results == NULL) {
+		gaim_debug_error("gg", "ggp_pubdir_reply_handler: "
+				 "Unable to display the search results.\n");
+		gaim_notify_error(gc, NULL,
+				  _("Unable to display the search results."),
+				  NULL);
+		ggp_sr_close_cb(gaim_connection_get_account(gc));
+		return;
+	}
+
 	column = gaim_notify_searchresults_column_new(_("UIN"));
 	gaim_notify_searchresults_column_add(results, column);
 
@@ -1025,8 +1035,19 @@
 		void *h = gaim_notify_searchresults(gc,
 				_("Gadu-Gadu Public Directory"),
 				_("Search results"), NULL, results,
-				(GHookFunc)ggp_sr_close_cb,
+				(GaimNotifyCloseCallback)ggp_sr_close_cb,
 				gaim_connection_get_account(gc));
+
+		if (h == NULL) {
+			gaim_debug_error("gg", "ggp_pubdir_reply_handler: "
+					 "Unable to display the search results.\n");
+			gaim_notify_error(gc, NULL,
+					  _("Unable to display the search results."),
+					  NULL);
+			ggp_sr_close_cb(gaim_connection_get_account(gc));
+			return;
+		}
+
 		info->searchresults_window = h;
 	} else {
 		gaim_notify_searchresults_new_rows(gc, results,
--- a/src/protocols/oscar/oscar.c	Tue Nov 29 18:25:12 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Tue Nov 29 19:26:03 2005 +0000
@@ -6156,13 +6156,23 @@
 	SNs = va_arg(ap, char *);
 	va_end(ap);
 
+	results = gaim_notify_searchresults_new();
+
+	if (results == NULL) {
+		gaim_debug_error("oscar", "gaim_parse_searchreply: "
+						 "Unable to display the search results.\n");
+		gaim_notify_error(gc, NULL,
+						  _("Unable to display the search results."),
+						  NULL);
+		return 0;
+	}
+
 	secondary = g_strdup_printf(
 					ngettext("The following screen name is associated with %s",
 						 "The following screen names are associated with %s",
 						 num),
 					email);
 
-	results = gaim_notify_searchresults_new();
 	column = gaim_notify_searchresults_column_new("Screen name");
 	gaim_notify_searchresults_column_add(results, column);