changeset 20505:909af554e239

merge of '0e444b80bb8aa9c005e8085c30a7b5a8a81423ee' and 'df112ef855b02f643d67e19bbf78ae78ef1a0e44'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 14 Sep 2007 04:32:43 +0000
parents d23c3a5884ee (current diff) 905891855710 (diff)
children 42365ba802c0
files
diffstat 8 files changed, 134 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/protocols/msn/contact.c	Fri Sep 14 04:32:43 2007 +0000
@@ -77,7 +77,8 @@
 void
 msn_callback_state_free(MsnCallbackState *state)
 {
-	g_return_if_fail(state != NULL);
+	if (state == NULL)
+		return;
 	
 	if (state->who != NULL)
 		g_free(state->who);
@@ -248,6 +249,9 @@
 	MsnSoapConn *soapconn = data;
 	MsnContact *contact;
 
+	if (soapconn->body == NULL)
+		return;
+
 	contact = soapconn->parent;
 	g_return_if_fail(contact != NULL);
 
@@ -533,6 +537,9 @@
 	const char *dynamicItemLastChange;
 	gchar *partner_scenario;
 
+	if (soapconn->body == NULL)
+		return;
+
 	purple_debug_misc("MSNCL","Got the contact list!\n");
 
 	contact = soapconn->parent;
@@ -902,6 +909,9 @@
 	MsnContact *contact;
 	MsnSession *session;
 
+	if (soapconn->body == NULL)
+		return;
+
 	contact = soapconn->parent;
 	g_return_if_fail(contact != NULL);
 	session = soapconn->session;
@@ -990,11 +1000,16 @@
 	g_return_if_fail(soapconn->data_cb != NULL);
 	g_return_if_fail(soapconn->session != NULL);
 	g_return_if_fail(soapconn->session->userlist != NULL);
+
+	state = (MsnCallbackState *) soapconn->data_cb;
+
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
 	
 	userlist = soapconn->session->userlist;
 	
-	state = (MsnCallbackState *) soapconn->data_cb;
-	
 	purple_debug_info("MSNCL","Contact added successfully\n");
 
 	// the code this block is replacing didn't send ADL for yahoo contacts,
@@ -1078,14 +1093,19 @@
 	MsnCallbackState *state; 
 	MsnUserList *userlist;
 
-        g_return_if_fail(soapconn->data_cb != NULL);
-        g_return_if_fail(soapconn->session != NULL);
-        g_return_if_fail(soapconn->session->userlist != NULL);
+	g_return_if_fail(soapconn->data_cb != NULL);
+	g_return_if_fail(soapconn->session != NULL);
+	g_return_if_fail(soapconn->session->userlist != NULL);
 
-        userlist = soapconn->session->userlist;
+	userlist = soapconn->session->userlist;
 
 	state = (MsnCallbackState *) soapconn->data_cb;
 
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
+	
 	if (msn_userlist_add_buddy_to_group(userlist, state->who, state->new_group_name) == TRUE) {
 		purple_debug_info("MSNCL", "Contact %s added to group %s successfully!\n", state->who, state->new_group_name);
 	} else {
@@ -1204,6 +1224,9 @@
 {
 	MsnSoapConn * soapconn = data;
 
+	if (soapconn->body == NULL)
+		return;
+
 	// we should probably delete it from the userlist aswell
 	purple_debug_info("MSNCL","Delete contact successful\n");
 	msn_soap_free_read_buf(soapconn);
@@ -1253,6 +1276,11 @@
 {
 	MsnSoapConn * soapconn = data;
 	MsnCallbackState *state = (MsnCallbackState *) soapconn->data_cb;
+
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
 	
 	if (msn_userlist_rem_buddy_from_group(soapconn->session->userlist, state->who, state->old_group_name)) {
 		purple_debug_info("MSN CL", "Contact %s deleted successfully from group %s\n", state->who, state->old_group_name);
@@ -1341,6 +1369,11 @@
 static void
 msn_update_contact_read_cb(gpointer data, gint source, PurpleInputCondition cond)
 {
+	MsnSoapConn *soapconn = data;
+
+	if (soapconn->body == NULL)
+		return;
+
 	purple_debug_info("MSN CL","Contact updated successfully\n");
 }
 
@@ -1394,6 +1427,11 @@
 
 	state = (MsnCallbackState *) soapconn->data_cb;
 
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
+	
 	purple_debug_info("MSN CL", "Contact %s deleted successfully from %s list on server!\n", state->who, MsnMemberRole[state->list_id]);
 
 	if (state->list_id == MSN_LIST_PL) {
@@ -1493,6 +1531,11 @@
 
 	state = (MsnCallbackState *) soapconn->data_cb;
 	
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
+	
 	purple_debug_info("MSN CL", "Contact %s added successfully to %s list on server!\n", state->who, MsnMemberRole[state->list_id]);
 
 	if (state->list_id == MSN_LIST_RL && (state->action & MSN_DENIED_BUDDY) ) {
@@ -1621,9 +1664,15 @@
 	g_return_if_fail(soapconn->session != NULL);
 	g_return_if_fail(soapconn->session->userlist != NULL);
 	g_return_if_fail(soapconn->session->contact != NULL);
+
+	state = (MsnCallbackState *) soapconn->data_cb;
 	
-	if (soapconn->data_cb != NULL) {
-		state = (MsnCallbackState *) soapconn->data_cb;
+	if (soapconn->body == NULL) {
+		msn_callback_state_free(state);
+		return;
+	}
+	
+	if (state) {
 		userlist = soapconn->session->userlist;
 		
 		if (state->action & MSN_RENAME_GROUP) {
--- a/libpurple/protocols/msn/msn.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Sep 14 04:32:43 2007 +0000
@@ -582,13 +582,31 @@
 	
 	if (purple_presence_is_online(presence))
 	{
-		const char *psm, *currentmedia;
+		const char *psm, *currentmedia, *name;
 		char *tmp;
 
 		psm = purple_status_get_attr_string(status, "message");
 		currentmedia = purple_status_get_attr_string(status, "currentmedia");
 
-		if (psm && *psm) {
+		if (!purple_presence_is_available(presence)) {
+			name = purple_status_get_name(status);
+		} else {
+			name = NULL;
+		}
+
+		if (name != NULL && *name) {
+			char *tmp2 = g_markup_escape_text(name, -1);
+
+			if (psm != NULL && *psm) {
+				tmp = g_markup_escape_text(psm, -1);
+				purple_notify_user_info_add_pair(user_info, tmp2, tmp);
+				g_free(tmp);
+			} else {
+				purple_notify_user_info_add_pair(user_info, _("Status"), tmp2);
+			}
+
+			g_free(tmp2);
+		} else {
 			tmp = g_markup_escape_text(psm, -1);
 			purple_notify_user_info_add_pair(user_info, _("Status"), tmp);
 			g_free(tmp);
--- a/libpurple/protocols/msn/oim.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/protocols/msn/oim.c	Fri Sep 14 04:32:43 2007 +0000
@@ -239,6 +239,9 @@
 	MsnSession *session = soapconn->session;
 	MsnOim * oim;
 
+	if (soapconn->body == NULL)
+		return;
+
 	g_return_if_fail(session != NULL);
 	oim = soapconn->session->oim;
 	g_return_if_fail(oim != NULL);
@@ -338,6 +341,8 @@
 {
 	MsnSoapConn * soapconn = data;
 
+	if (soapconn->body == NULL)
+		return;
 	purple_debug_info("MSNP14","OIM delete read buffer:{%s}\n",soapconn->body);
 
 	msn_soap_free_read_buf(soapconn);
@@ -450,14 +455,32 @@
 			}
 
 			if (sscanf(tz_ptr, "%02d%02d", &tzhrs, &tzmins) == 2) {
-				t.tm_year -= 1900;
-#if HAVE_TM_GMTOFF
-				t.tm_gmtoff = tzhrs * 60 * 60 + tzmins * 60;
+				time_t tzoff = tzhrs * 60 * 60 + tzmins * 60;
+#ifdef _WIN32
+				long sys_tzoff;
+#endif
+
 				if (!offset_positive)
-					t.tm_gmtoff *= -1;
+					tzoff *= -1;
+
+				t.tm_year -= 1900;
+				t.tm_isdst = 0;
+
+#ifdef _WIN32
+				if ((sys_tzoff = wpurple_get_tz_offset()) != -1)
+					tzoff += sys_tzoff;
+#else
+#ifdef HAVE_TM_GMTOFF
+				tzoff += t.tm_gmtoff;
+#else
+#	ifdef HAVE_TIMEZONE
+				tzset();    /* making sure */
+				tzoff -= timezone;
+#	endif
 #endif
-				t.tm_isdst = 0;
-				return mktime(&t);
+#endif /* _WIN32 */
+
+				return mktime(&t) + tzoff;
 			}
 		}
 	}
@@ -553,6 +576,9 @@
 	MsnSoapConn * soapconn = data;
 	MsnOim * oim = soapconn->session->oim;
 
+	if (soapconn->body == NULL)
+		return;
+
 	purple_debug_info("MSNP14","OIM get read buffer:{%s}\n",soapconn->body);
 
 	/*we need to process the read message!*/
--- a/libpurple/protocols/msn/soap.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/protocols/msn/soap.c	Fri Sep 14 04:32:43 2007 +0000
@@ -150,7 +150,12 @@
 
 	g_return_if_fail(soapconn != NULL);
 
+	soapconn->body = NULL;
+
 	while ((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){
+		if (soapconn->read_cb) {
+			soapconn->read_cb(soapconn, -1, 0);
+		}
 		msn_soap_request_free(request);
 	}
 }
@@ -510,14 +515,6 @@
 	soapconn->written_len = 0;
 }
 
-void
-msn_soap_free_data_cb(MsnSoapConn *soapconn)
-{
-	if (soapconn->data_cb) {
-		g_free(soapconn->data_cb);
-	}
-}
-
 /*Soap write process func*/
 static void
 msn_soap_write_cb(gpointer data, gint source, PurpleInputCondition cond)
@@ -625,7 +622,6 @@
 	g_free(request->login_path);
 	g_free(request->soap_action);
 	g_free(request->body);
-	g_free(request->data_cb);
 	request->read_cb	= NULL;
 	request->written_cb	= NULL;
 
--- a/libpurple/protocols/msn/soap.h	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/protocols/msn/soap.h	Fri Sep 14 04:32:43 2007 +0000
@@ -140,7 +140,6 @@
 void msn_soap_write(MsnSoapConn * soapconn, char *write_buf, PurpleInputFunction written_cb);
 void msn_soap_post(MsnSoapConn *soapconn,MsnSoapReq *request,MsnSoapConnectInitFunction msn_soap_init_func);
 
-void msn_soap_free_data_cb(MsnSoapConn *soapconn);
 void msn_soap_free_read_buf(MsnSoapConn *soapconn);
 void msn_soap_free_write_buf(MsnSoapConn *soapconn);
 void msn_soap_connect_cb(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond);
--- a/libpurple/util.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/util.c	Fri Sep 14 04:32:43 2007 +0000
@@ -514,23 +514,6 @@
  * Date/Time Functions
  **************************************************************************/
 
-#ifdef _WIN32
-static long win32_get_tz_offset() {
-	TIME_ZONE_INFORMATION tzi;
-	DWORD ret;
-	long off = -1;
-
-	if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
-	{
-		off = -(tzi.Bias * 60);
-		if (ret == TIME_ZONE_ID_DAYLIGHT)
-			off -= tzi.DaylightBias * 60;
-	}
-
-	return off;
-}
-#endif
-
 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso)
 {
 	static char buf[7];
@@ -545,7 +528,7 @@
 		g_return_val_if_reached("");
 
 #ifdef _WIN32
-	if ((off = win32_get_tz_offset()) == -1)
+	if ((off = wpurple_get_tz_offset()) == -1)
 		return "";
 #else
 # ifdef HAVE_TM_GMTOFF
@@ -853,7 +836,7 @@
 #endif
 
 #ifdef _WIN32
-				if ((sys_tzoff = win32_get_tz_offset()) == -1)
+				if ((sys_tzoff = wpurple_get_tz_offset()) == -1)
 					tzoff = PURPLE_NO_TZ_OFF;
 				else
 					tzoff += sys_tzoff;
--- a/libpurple/win32/win32dep.c	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/win32/win32dep.c	Fri Sep 14 04:32:43 2007 +0000
@@ -586,6 +586,22 @@
 	libpurpledll_hInstance = NULL;
 }
 
+long
+wpurple_get_tz_offset() {
+	TIME_ZONE_INFORMATION tzi;
+	DWORD ret;
+	long off = -1;
+
+	if ((ret = GetTimeZoneInformation(&tzi)) != TIME_ZONE_ID_INVALID)
+	{
+		off = -(tzi.Bias * 60);
+		if (ret == TIME_ZONE_ID_DAYLIGHT)
+			off -= tzi.DaylightBias * 60;
+	}
+
+	return off;
+}
+
 /* DLL initializer */
 /* suppress gcc "no previous prototype" warning */
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
--- a/libpurple/win32/win32dep.h	Fri Sep 14 04:32:30 2007 +0000
+++ b/libpurple/win32/win32dep.h	Fri Sep 14 04:32:43 2007 +0000
@@ -60,6 +60,7 @@
 void wpurple_init(void);
 void wpurple_cleanup(void);
 
+long wpurple_get_tz_offset(void);
 
 /*
  *  MACROS