im.pidgin.pidgin: 69ca65a19d58168311263e62480f7f6e05ec29c7

jeff2 at soc.pidgin.im jeff2 at soc.pidgin.im
Sat Jan 19 23:55:38 EST 2008


-----------------------------------------------------------------
Revision: 69ca65a19d58168311263e62480f7f6e05ec29c7
Ancestor: f371b7eddb9b845c0eb7148611f00f1aabcd1326
Author: jeff2 at soc.pidgin.im
Date: 2008-01-20T03:02:24
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/myspace/myspace.h

ChangeLog: 

a

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	05c7086a97082f4c49b014e0eeb35e30545d4591
+++ libpurple/protocols/myspace/myspace.c	a05b23c104a123293966b4593aaa971b5c82d7d5
@@ -555,7 +555,20 @@ msim_send_im(PurpleConnection *gc, const
 		 */
 		/* TODO: maybe if message is delayed, don't echo to conv window,
 		 * but do echo it to conv window manually once it is actually
-		 * sent? Would be complicated. */
+		 * sent? Would be complicated. 
+		 *
+		 * Actually, we should instead show in the IM window if an error
+		 * occurred sending the message, but still show it. For example, in AIM
+		 * sending a message to a non-existent or offline user does this:
+		 *
+		 * (5:33:02 PM) me: hi
+		 * (5:33:02 PM) Unable to send message: Not logged in
+		 *
+		 * msimprpl currently pops up a dialog if an error occurs in user
+		 * lookup, but it should be shown in the IM window instead.
+		 *
+		 * Filed as bug #4687.
+		 */
 		rc = 1;
 	} else {
 		rc = -1;
@@ -563,19 +576,6 @@ msim_send_im(PurpleConnection *gc, const
 
 	g_free(message_msim);
 
-	/*
-	 * In MySpace, you login with your email address, but don't talk to other
-	 * users using their email address. So there is currently an asymmetry in the 
-	 * IM windows when using this plugin:
-	 *
-	 * you at example.com: hello
-	 * some_other_user: what's going on?
-	 * you at example.com: just coding a prpl
-	 *
-	 * TODO: Make the sent IM's appear as from the user's username, instead of
-	 * their email address. Purple uses the login (in MSIM, the email)--change this.
-	 */
-
 	return rc;
 }
 
@@ -745,7 +745,10 @@ msim_unrecognized(MsimSession *session, 
 
 	/* TODO: dump unknown msgs to file, so user can send them to me
 	 * if they wish, to help add support for new messages (inspired
-	 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */
+	 * by Alexandr Shutko, who maintains OSCAR protocol documentation). 
+	 *
+	 * Filed enhancement ticket for libpurple as #4688.
+	 */
 
 	purple_debug_info("msim", "Unrecognized data on account for %s\n", 
 			(session && session->account && session->account->username) ? 
@@ -787,9 +790,6 @@ msim_incoming_action(MsimSession *sessio
 			msg_text, username);
 
 	if (g_str_equal(msg_text, "%typing%")) {
-		/* TODO: find out if msim repeatedly sends typing messages, so we can 
-		 * give it a timeout. Right now, there does seem to be an inordinately 
-		 * amount of time between typing stopped-typing notifications. */
 		serv_got_typing(session->gc, username, 0, PURPLE_TYPING);
 		rc = TRUE;
 	} else if (g_str_equal(msg_text, "%stoptyping%")) {
@@ -959,6 +959,7 @@ msim_get_info_cb(MsimSession *session, M
 
 	if (!user) {
 		/* User isn't on blist, create a temporary user to store info. */
+		/* TODO: is this legit, or is it somehow responsible for #3444? */
 		PurpleBuddy *buddy;
 
 		user = g_new0(MsimUser, 1);
@@ -1052,6 +1053,7 @@ msim_set_status(PurpleAccount *account, 
 	guint status_code;
 	const gchar *message;
 	gchar *stripped;
+	gchar *unrecognized_msg;
 
 	session = (MsimSession *)account->gc->proto_data;
 
@@ -1083,6 +1085,12 @@ msim_set_status(PurpleAccount *account, 
 			purple_debug_info("msim", "msim_set_status: unknown "
 					"status interpreting as online");
 			status_code = MSIM_STATUS_CODE_ONLINE;
+
+			unrecognized_msg = g_strdup_printf("msim_set_status, unrecognized status type: %d\n", 
+					purple_status_type_get_primitive(type));
+			msim_unrecognized(session, NULL, unrecognized_msg);
+			g_free(unrecognized_msg);
+
 			break;
 	}
 
@@ -1203,7 +1211,7 @@ msim_incoming_resolved(MsimSession *sess
 	msim_process(session, msg);
 
 	/* TODO: Free copy cloned from  msim_preprocess_incoming(). */
-	//XXX msim_msg_free(msg);
+	/* msim_msg_free(msg); */
 	msim_msg_free(body);
 }
 
@@ -1211,7 +1219,9 @@ msim_incoming_resolved(MsimSession *sess
  *
  * @param wanted_uid
  *
- * @return Username of wanted_uid, if on blist, or NULL. Static string. 
+ * @return Username of wanted_uid, if on blist, or NULL. Static string.
+ * 	TODO: The username string here is a new string from g_strdup(), not
+ * 	a static string that doesn't need to be fixed. Probably leaks. TODO: fix.
  *
  */
 static const gchar *
@@ -1313,13 +1323,13 @@ msim_check_alive(gpointer data)
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 
 	delta = time(NULL) - session->last_comm;
-	//purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta);
+	/* purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); */
 	if (delta >= MSIM_KEEPALIVE_INTERVAL) {
 		errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta);
 
 		purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n",
 				errmsg, MSIM_KEEPALIVE_INTERVAL);
-		purple_connection_error_reason (session->gc,
+		purple_connection_error_reason(session->gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, errmsg);
 
 		purple_notify_error(session->gc, NULL, errmsg, NULL);
@@ -1741,7 +1751,7 @@ msim_web_challenge(MsimSession *session,
 static gboolean
 msim_web_challenge(MsimSession *session, MsimMessage *msg)
 {
-	/* TODO: web challenge, store token */
+	/* TODO: web challenge, store token. #2659. */
 	return FALSE;
 }
 
@@ -1832,13 +1842,14 @@ msim_error(MsimSession *session, MsimMes
 	if (msim_msg_get(msg, "fatal")) {
 		PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 		purple_debug_info("msim", "fatal error, closing\n");
+
 		switch (err) {
-			case 260: /* Incorrect password */
+			case MSIM_ERROR_INCORRECT_PASSWORD: /* Incorrect password */
 				reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
 				if (!purple_account_get_remember_password(session->account))
 					purple_account_set_password(session->account, NULL);
 				break;
-			case 6: /* Logged in elsewhere */
+			case MSIM_ERROR_LOGGED_IN_ELSEWHERE: /* Logged in elsewhere */
 				reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE;
 				if (!purple_account_get_remember_password(session->account))
 					purple_account_set_password(session->account, NULL);
@@ -1871,6 +1882,7 @@ msim_incoming_status(MsimSession *sessio
 	gchar *status_headline, *status_headline_escaped;
 	gint status_code, purple_status_code;
 	gchar *username;
+	gchar *unrecognized_msg;
 
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
@@ -1903,7 +1915,8 @@ msim_incoming_status(MsimSession *sessio
 
 	blist = purple_get_blist();
 
-	/* Add buddy if not found */
+	/* Add buddy if not found.
+	 * TODO: Could this be responsible for #3444? */
 	user = msim_find_user(session, username);
 	if (!user) {
 		PurpleBuddy *buddy;
@@ -1915,7 +1928,7 @@ msim_incoming_status(MsimSession *sessio
 
 		user = msim_get_user_from_buddy(buddy);
 
-		/* All buddies on list should have 'uid' integer associated with them. */
+		/* All buddies on list should have a UserID integer associated with them. */
 		purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f"));
 		
 		msim_store_user_info(session, msg, NULL);
@@ -1959,9 +1972,15 @@ msim_incoming_status(MsimSession *sessio
 			break;
 
 		default:
-			purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n",
+			purple_debug_info("msim", "msim_incoming_status for %s, unknown status code %d, treating as available\n",
 						username, status_code);
 			purple_status_code = PURPLE_STATUS_AVAILABLE;
+
+			unrecognized_msg = g_strdup_printf("msim_incoming_status, unrecognized status code: %d\n", 
+					status_code);
+			msim_unrecognized(session, NULL, unrecognized_msg);
+			g_free(unrecognized_msg);
+
 	}
 
 	purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL);
@@ -2159,7 +2178,9 @@ msim_postprocess_outgoing_cb(MsimSession
 		purple_notify_error(NULL, NULL, _("User lookup"), msg);
 		g_free(msg);
 		g_free(username);
-		//msim_msg_free(msg);
+		/* TODO: free
+		 * msim_msg_free(msg);
+		 */
 		return;
 	}
 
@@ -2180,7 +2201,9 @@ msim_postprocess_outgoing_cb(MsimSession
 	g_free(uid_field_name);
 	g_free(uid_before);
 	g_free(username);
-	//msim_msg_free(msg);
+	/* TODO: free 
+	 * msim_msg_free(msg);
+	 */
 }
 
 /** Postprocess and send a message.
@@ -2222,8 +2245,7 @@ msim_postprocess_outgoing(MsimSession *s
 			uid = 0;
 		}
 
-		if (!buddy || !uid)
-		{
+		if (!buddy || !uid) {
 			/* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */
 			purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n",
 					username ? username : "(NULL)");
@@ -2244,7 +2266,9 @@ msim_postprocess_outgoing(MsimSession *s
 	
 	rc = msim_msg_send(session, msg);
 
-	//msim_msg_free(msg);
+	/* TODO: free
+	 * msim_msg_free(msg);
+	 */
 
 	return rc;
 }
@@ -2304,7 +2328,7 @@ msim_remove_buddy(PurpleConnection *gc, 
 			"blocklist", MSIM_TYPE_BOOLEAN, TRUE,
 			"sesskey", MSIM_TYPE_INTEGER, session->sesskey,
 			/* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */
-			//"idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"),
+			/* "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), */
 			"idlist", MSIM_TYPE_LIST, blocklist_updates,
 			NULL);
 
@@ -2317,9 +2341,12 @@ msim_remove_buddy(PurpleConnection *gc, 
 }
 
 /**
- * Borrowed this code from oscar_normalize. Added checking for "if userid, get name before normalizing"
+ * Returns a string of a username in canonical form. Basically removes all the
+ * spaces, lowercases the string, and looks up user IDs to usernames.
+ * Normalizing tom, TOM, Tom, and 6221 wil all return 'tom'.
  *
- * Basically... Returns a string that has been formated with all the spaces and caps removed.
+ * Borrowed this code from oscar_normalize. Added checking for 
+ * "if userid, get name before normalizing"
  */
 const char *msim_normalize(const PurpleAccount *account, const char *str) {
 	static char normalized[BUF_LEN];
@@ -2345,7 +2372,7 @@ const char *msim_normalize(const PurpleA
 		id = atol(str);
 		username = msim_uid2username_from_blist(session, id);
 		if (!username) {
-			/* Not in buddy list... scheisse... TODO: Manual Lookup! */
+			/* Not in buddy list... scheisse... TODO: Manual Lookup! Bug #4631 */
 			/* Note: manual lookup using msim_lookup_user() is a problem inside 
 			 * msim_normalize(), because msim_lookup_user() calls a callback function
 			 * when the user information has been looked up, but msim_normalize() expects
@@ -2376,6 +2403,13 @@ const char *msim_normalize(const PurpleA
 	g_free(tmp2);
 	g_free(tmp1);
 
+	/* TODO: re-add caps and spacing back to what the user wanted.
+	 * User can format their own names, for example 'msimprpl' is shown
+	 * as 'MsIm PrPl' in the official client.
+	 *
+	 * TODO: file a ticket to add this enhancement.
+	 */
+
 	return normalized;
 }
 
@@ -2427,16 +2461,17 @@ msim_input_cb(gpointer gc_uncasted, gint
 	g_return_if_fail(cond == PURPLE_INPUT_READ);
 	g_return_if_fail(MSIM_SESSION_VALID(session));
 
-	/* Mark down that we got data, so don't timeout. */
+	/* Mark down that we got data, so we don't timeout. */
 	session->last_comm = time(NULL);
 
 	/* Only can handle so much data at once... 
-	 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE.
 	 * Should be large enough to hold the largest protocol message.
 	 */
 	if (session->rxoff >= MSIM_READ_BUF_SIZE) {
 		purple_debug_error("msim", 
-				"msim_input_cb: %d-byte read buffer full! rxoff=%d\n",
+				"msim_input_cb: %d-byte read buffer full! rxoff=%d. "
+				"If this happens, try recompiling with a higher "
+				"MSIM_READ_BUF_SIZE.",
 				MSIM_READ_BUF_SIZE, session->rxoff);
 		purple_connection_error_reason (gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
@@ -2534,8 +2569,9 @@ msim_input_cb(gpointer gc_uncasted, gint
 		memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), 
 				MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf));
 
-		/* Clear end of buffer */
-		//memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf));
+		/* Clear end of buffer 
+		 * memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf));
+		 */
 	}
 }
 
============================================================
--- libpurple/protocols/myspace/myspace.h	1e711bf17c9e1b576fedd729e14870b317618dc9
+++ libpurple/protocols/myspace/myspace.h	f8ea908a2c9689bcf7b63adbc16bd3271b468999
@@ -180,6 +180,10 @@
 #define MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS	1
 #define MSIM_CONTACT_LIST_IMPORT_TOP_FRIENDS	2
 
+/* Error codes */
+#define MSIM_ERROR_INCORRECT_PASSWORD           260
+#define MSIM_ERROR_LOGGED_IN_ELSEWHERE          6
+
 /* Functions */
 gboolean msim_load(PurplePlugin *plugin);
 GList *msim_status_types(PurpleAccount *acct);


More information about the Commits mailing list