changeset 18636:7a5bf42aa8d1

merge of '59e56959de867035d1f66b2c04b5cdc539d18c59' and '99c63bdb0045fe571cc0f1fc5138b1c9c83dd43a'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 24 Jul 2007 21:49:14 +0000
parents ce3c8d30a200 (diff) 5551e5ec1ce0 (current diff)
children 3597903cf8ff 132be6c181dd
files
diffstat 4 files changed, 64 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugin.c	Tue Jul 24 21:44:24 2007 +0000
+++ b/libpurple/plugin.c	Tue Jul 24 21:49:14 2007 +0000
@@ -692,7 +692,10 @@
 
 		dependency = purple_plugins_find_with_id(dep_name);
 
-		dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id);
+		if (dependency != NULL)
+			dependency->dependent_plugins = g_list_remove(dependency->dependent_plugins, plugin->info->id);
+		else
+			purple_debug_error("plugins", "Unable to remove from dependency list for %s\n", dep_name);
 	}
 
 	if (plugin->native_plugin) {
--- a/libpurple/protocols/oscar/family_locate.c	Tue Jul 24 21:44:24 2007 +0000
+++ b/libpurple/protocols/oscar/family_locate.c	Tue Jul 24 21:49:14 2007 +0000
@@ -636,13 +636,15 @@
 	 * Parse out the Type-Length-Value triples as they're found.
 	 */
 	for (curtlv = 0; curtlv < tlvcnt; curtlv++) {
+		guint16 type;
+		guint8 number, length;
 		int endpos;
-		guint16 type, length;
 
 		type = byte_stream_get16(bs);
-		length = byte_stream_get16(bs);
+		number = byte_stream_get8(bs);
+		length = byte_stream_get8(bs);
 
-		endpos = byte_stream_curpos(bs) + length;
+		endpos = byte_stream_curpos(bs) + MIN(length, byte_stream_empty(bs));
 
 		if (type == 0x0001) {
 			/*
@@ -814,27 +816,33 @@
 			 * contain information about the buddy icon the user
 			 * has stored on the server.
 			 */
-			int type2, number, length2;
+			guint16 type2;
+			guint8 number2, length2;
+			int endpos2;
 
-			while (byte_stream_curpos(bs) < endpos) {
+			/*
+			 * Continue looping as long as we're able to read type2,
+			 * number2, and length2.
+			 */
+			while (byte_stream_curpos(bs) + 4 <= endpos) {
 				type2 = byte_stream_get16(bs);
-				number = byte_stream_get8(bs);
+				number2 = byte_stream_get8(bs);
 				length2 = byte_stream_get8(bs);
 
+				endpos2 = byte_stream_curpos(bs) + MIN(length2, byte_stream_empty(bs));
+
 				switch (type2) {
 					case 0x0000: { /* This is an official buddy icon? */
 						/* This is always 5 bytes of "0x02 01 d2 04 72"? */
-						byte_stream_advance(bs, length2);
 					} break;
 
 					case 0x0001: { /* A buddy icon checksum */
-						if ((length2 > 0) && ((number == 0x00) || (number == 0x01))) {
+						if ((length2 > 0) && ((number2 == 0x00) || (number2 == 0x01))) {
 							g_free(outinfo->iconcsum);
-							outinfo->iconcsumtype = number;
+							outinfo->iconcsumtype = number2;
 							outinfo->iconcsum = byte_stream_getraw(bs, length2);
 							outinfo->iconcsumlen = length2;
-						} else
-							byte_stream_advance(bs, length2);
+						}
 					} break;
 
 					case 0x0002: { /* A status/available message */
@@ -879,11 +887,10 @@
 							outinfo->itmsurl_encoding = NULL;
 						}
 					} break;
+				}
 
-					default: {
-						byte_stream_advance(bs, length2);
-					} break;
-				}
+				/* Save ourselves. */
+				byte_stream_setpos(bs, endpos2);
 			}
 
 		} else if (type == 0x001e) {
--- a/pidgin/gtkconv.c	Tue Jul 24 21:44:24 2007 +0000
+++ b/pidgin/gtkconv.c	Tue Jul 24 21:49:14 2007 +0000
@@ -8269,8 +8269,8 @@
 		return FALSE; /* carry on normally */
 
         /* store the position */
-        purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/x",      x);
-	purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/y",      y);
+        purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/x", x);
+	purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/y", y);
 	purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width",  event->width);
 	purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height);
 
@@ -8279,6 +8279,38 @@
 						
 }
 
+static void
+pidgin_conv_restore_position(PidginWindow *win) {
+	int conv_x, conv_y, conv_width, conv_height;
+
+	conv_width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width");
+
+	 /* if the window exists, is hidden, we're saving positions, and the
+          * position is sane... */
+        if (win && win->window &&
+                !GTK_WIDGET_VISIBLE(win->window) && conv_width != 0) {
+
+                conv_x      = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/x");
+                conv_y      = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/y");
+                conv_height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height");
+
+	       /* ...check position is on screen... */
+                if (conv_x >= gdk_screen_width())
+                        conv_x = gdk_screen_width() - 100;
+                else if (conv_x + conv_width < 0)
+                        conv_x = 100;
+
+                if (conv_y >= gdk_screen_height())
+                        conv_y = gdk_screen_height() - 100;
+                else if (conv_y + conv_height < 0)
+                        conv_y = 100;
+
+                /* ...and move it back. */
+                gtk_window_move(GTK_WINDOW(win->window), conv_x, conv_y);
+                gtk_window_resize(GTK_WINDOW(win->window), conv_width, conv_height);
+        }
+}
+
 PidginWindow *
 pidgin_conv_window_new()
 {
@@ -8293,8 +8325,7 @@
 
 	/* Create the window. */
 	win->window = pidgin_create_window(NULL, 0, "conversation", TRUE);
-	gtk_window_set_default_size(GTK_WINDOW(win->window), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"),
-							     purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height"));
+	pidgin_conv_restore_position(win);
 
 	if (available_list == NULL) {
 		create_icon_lists(win->window);
--- a/pidgin/plugins/gtkbuddynote.c	Tue Jul 24 21:44:24 2007 +0000
+++ b/pidgin/plugins/gtkbuddynote.c	Tue Jul 24 21:49:14 2007 +0000
@@ -107,8 +107,6 @@
 
 		bninfo->flags = PURPLE_PLUGIN_FLAG_INVISIBLE;
 
-		info.dependencies = g_list_append(info.dependencies,
-		                                  "core-plugin_pack-buddynote");
 
 		/* If non-gtk buddy note plugin is loaded, but we are not, then load
 		 * ourselves, otherwise people upgrading from pre-gtkbuddynote days
@@ -134,6 +132,9 @@
 	/* Use g_idle_add so that the rest of the plugins can get loaded
 	 * before we do our check. */
 	g_idle_add(check_for_buddynote, plugin);
+
+	info.dependencies = g_list_append(info.dependencies,
+	                                  "core-plugin_pack-buddynote");
 }
 
 PURPLE_INIT_PLUGIN(gtkbuddynote, init_plugin, info)