changeset 20558:595f3ca5eb75

merge of '316f4132961f32fda272a61203f295e714e8238c' and 'd5cf4cb0cac4c37c29574a0a50ea04a1f4f8d929'
author Sean Egan <seanegan@gmail.com>
date Wed, 19 Sep 2007 19:27:43 +0000
parents 55183458cd51 (current diff) 7fc7edb4dcd0 (diff)
children fecae28132f5
files
diffstat 8 files changed, 71 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/finch/finch.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/finch/finch.c	Wed Sep 19 19:27:43 2007 +0000
@@ -297,6 +297,7 @@
 	if (opt_version) {
 		/* Translators may want to transliterate the name.
 		 It is not to be translated. */
+		gnt_quit();
 		printf("%s %s\n", _("Finch"), VERSION);
 		return 0;
 	}
@@ -419,13 +420,13 @@
 
 	gnt_init();
 
-	gnt_start(&argc, &argv);
-
-	gnt_main();
+	if (gnt_start(&argc, &argv)) {
+		gnt_main();
 
 #ifdef STANDALONE
-	purple_core_quit();
+		purple_core_quit();
 #endif
+	}
 
 	return 0;
 }
--- a/finch/gntconv.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/finch/gntconv.c	Wed Sep 19 19:27:43 2007 +0000
@@ -326,8 +326,8 @@
 		list = purple_get_chats();
 		while (list) {
 			PurpleConversation *conv = list->data;
-			gboolean del = FALSE;
 			PurpleChat *chat;
+			GHashTable *comps = NULL;
 
 			list = list->next;
 			if (conv->account != gc->account ||
@@ -336,15 +336,14 @@
 
 			chat = purple_blist_find_chat(conv->account, conv->name);
 			if (chat == NULL) {
-				GHashTable *hash = NULL;
 				if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL)
-					hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name);
-				chat = purple_chat_new(gc->account, conv->name, hash);
-				del = TRUE;
+					comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name);
+			} else {
+				comps = chat->components;
 			}
-			serv_join_chat(gc, chat->components);
-			if (del)
-				purple_blist_remove_chat(chat);
+			serv_join_chat(gc, comps);
+			if (chat == NULL && comps != NULL)
+				g_hash_table_destroy(comps);
 		}
 	}
 }
@@ -766,7 +765,8 @@
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
 					_("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD);
 
-	if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)))
+	if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) &&
+			!(flags & PURPLE_MESSAGE_NOTIFY))
 	{
 		char * name = NULL;
 
--- a/libpurple/blist.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/libpurple/blist.c	Wed Sep 19 19:27:43 2007 +0000
@@ -843,6 +843,13 @@
 		ops->update(purplebuddylist, (PurpleBlistNode *)buddy);
 }
 
+static gboolean
+purple_strings_are_different(const char *one, const char *two)
+{
+	return !((one && two && g_utf8_collate(one, two) == 0) ||
+			((one == NULL || *one == '\0') && (two == NULL || *two == '\0')));
+}
+
 void purple_blist_alias_contact(PurpleContact *contact, const char *alias)
 {
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
@@ -852,6 +859,9 @@
 
 	g_return_if_fail(contact != NULL);
 
+	if (!purple_strings_are_different(contact->alias, alias))
+		return;
+
 	old_alias = contact->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -886,6 +896,9 @@
 
 	g_return_if_fail(chat != NULL);
 
+	if (!purple_strings_are_different(chat->alias, alias))
+		return;
+
 	old_alias = chat->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -911,6 +924,9 @@
 
 	g_return_if_fail(buddy != NULL);
 
+	if (!purple_strings_are_different(buddy->alias, alias))
+		return;
+
 	old_alias = buddy->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -941,6 +957,9 @@
 
 	g_return_if_fail(buddy != NULL);
 
+	if (!purple_strings_are_different(buddy->server_alias, alias))
+		return;
+
 	old_alias = buddy->server_alias;
 
 	if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL))
@@ -1423,26 +1442,7 @@
 
 void purple_contact_set_alias(PurpleContact *contact, const char *alias)
 {
-	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
-	char *old_alias;
-
-	g_return_if_fail(contact != NULL);
-
-	old_alias = contact->alias;
-
-	if ((alias != NULL) && (*alias != '\0'))
-		contact->alias = g_strdup(alias);
-	else
-		contact->alias = NULL;
-
-	purple_blist_schedule_save();
-
-	if (ops && ops->update)
-		ops->update(purplebuddylist, (PurpleBlistNode*)contact);
-
-	purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
-					 contact, old_alias);
-	g_free(old_alias);
+	purple_blist_alias_contact(contact,alias);
 }
 
 const char *purple_contact_get_alias(PurpleContact* contact)
--- a/libpurple/blist.h	Wed Sep 19 18:08:44 2007 +0000
+++ b/libpurple/blist.h	Wed Sep 19 19:27:43 2007 +0000
@@ -65,11 +65,11 @@
 
 typedef enum
 {
-	PURPLE_BLIST_NODE_FLAG_NO_SAVE = 1 /**< node should not be saved with the buddy list */
+	PURPLE_BLIST_NODE_FLAG_NO_SAVE      = 1 << 0, /**< node should not be saved with the buddy list */
 
 } PurpleBlistNodeFlags;
 
-#define PURPLE_BLIST_NODE_HAS_FLAG(b, f) ((b)->flags & (f))
+#define PURPLE_BLIST_NODE_HAS_FLAG(b, f) (((PurpleBlistNode*)(b))->flags & (f))
 #define PURPLE_BLIST_NODE_SHOULD_SAVE(b) (! PURPLE_BLIST_NODE_HAS_FLAG(b, PURPLE_BLIST_NODE_FLAG_NO_SAVE))
 
 #define PURPLE_BLIST_NODE_NAME(n) ((n)->type == PURPLE_BLIST_CHAT_NODE  ? purple_chat_get_name((PurpleChat*)n) :        \
@@ -488,6 +488,8 @@
  *
  * @param contact  The contact
  * @param alias    The alias to set, or NULL to unset
+ *
+ * @deprecated Use purple_blist_alias_contact() instead.
  */
 void purple_contact_set_alias(PurpleContact *contact, const char *alias);
 
--- a/libpurple/protocols/msn/msn.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/libpurple/protocols/msn/msn.c	Wed Sep 19 19:27:43 2007 +0000
@@ -1573,7 +1573,7 @@
 msn_info_strip_search_link(const char *field, size_t len)
 {
 	const char *c;
-	if ((c = strstr(field, " (http://")) == NULL))
+	if ((c = strstr(field, " (http://")) == NULL)
 		return g_strndup(field, len);
 	return g_strndup(field, c - field);
 }
--- a/libpurple/protocols/myspace/myspace.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Wed Sep 19 19:27:43 2007 +0000
@@ -291,9 +291,10 @@
 		/* Notify an error message also, because this is important! */
 		purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL);
 
+		gc->wants_to_die = TRUE;
 		purple_connection_error(gc, str);
-		
 		g_free(str);
+		return;
 	}
 #endif
 
--- a/pidgin/gtkconn.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/pidgin/gtkconn.c	Wed Sep 19 19:27:43 2007 +0000
@@ -141,6 +141,7 @@
 {
 	PurpleAccount *account = NULL;
 	PidginAutoRecon *info;
+	GList *list;
 
 	account = purple_connection_get_account(gc);
 	info = g_hash_table_lookup(auto_reconns, account);
@@ -192,6 +193,17 @@
 		 */
 		purple_account_set_enabled(account, PIDGIN_UI, FALSE);
 	}
+
+	/* If we have any open chats, we probably want to rejoin when we get back online. */
+	list = purple_get_chats();
+	while (list) {
+		PurpleConversation *conv = list->data;
+		list = list->next;
+		if (conv->account != account ||
+				purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)))
+			continue;
+		purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE));
+	}
 }
 
 static void pidgin_connection_network_connected ()
--- a/pidgin/gtkconv.c	Wed Sep 19 18:08:44 2007 +0000
+++ b/pidgin/gtkconv.c	Wed Sep 19 19:27:43 2007 +0000
@@ -7241,6 +7241,23 @@
 		/* if (purple_conversation_get_account(conv) == account) */
 			pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON |
 							PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE);
+
+		if (PURPLE_CONNECTION_IS_CONNECTED(gc) &&
+				conv->type == PURPLE_CONV_TYPE_CHAT &&
+				conv->account == gc->account &&
+				purple_conversation_get_data(conv, "want-to-rejoin")) {
+			GHashTable *comps = NULL;
+			PurpleChat *chat = purple_blist_find_chat(conv->account, conv->name);
+			if (chat == NULL) {
+				if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL)
+					comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name);
+			} else {
+				comps = chat->components;
+			}
+			serv_join_chat(gc, comps);
+			if (chat == NULL && comps != NULL)
+				g_hash_table_destroy(comps);
+		}
 	}
 }
 
@@ -7385,6 +7402,7 @@
 	if (gtkconv->attach.current)
 		return TRUE;
 
+	g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL);
 	purple_signal_emit(pidgin_conversations_get_handle(),
 			"conversation-displayed", gtkconv);
 	g_source_remove(gtkconv->attach.timer);
@@ -7425,7 +7443,6 @@
 	timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer"));
 	if (timer)
 		purple_timeout_remove(timer);
-
 	return TRUE;
 }