im.pidgin.pidgin: 264d4bc3abd6ada52ea199d083180cdedf78d38b

jeff2 at soc.pidgin.im jeff2 at soc.pidgin.im
Sat Feb 16 15:56:12 EST 2008


-----------------------------------------------------------------
Revision: 264d4bc3abd6ada52ea199d083180cdedf78d38b
Ancestor: 89bca708c0a79f6983b0b443a640c11f6e05a82e
Author: jeff2 at soc.pidgin.im
Date: 2008-02-16T20:49:20
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/264d4bc3abd6ada52ea199d083180cdedf78d38b

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

ChangeLog: 

In msimprpl, change to patch from Jaywalker regarding setting
usernames:

	If they choose "No", the protocol will not allow them to log in, 
	so therefore we have to disconnect. The newest patch I added fixes it.

I also made some minor fixes and general cleanup. Improves on #2844.

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	57e669c7d39b2d54aa1b7cb238a58413a3793d6c
+++ libpurple/protocols/myspace/myspace.c	ee341704dfd8a14b94fc3a2d9050b1990d6a3fda
@@ -1546,13 +1546,14 @@ msim_check_newer_version_cb(PurpleUtilFe
 }
 #endif
 
-/** Called when the session key arrives. */
+/** Called when the session key arrives to check whether the user
+ * has a username, and set one if desired. */
 static gboolean
-msim_is_username_set(MsimSession *session, MsimMessage *msg) {
-	/*MsimMessage *body;*/
-
+msim_is_username_set(MsimSession *session, MsimMessage *msg) 
+{
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
+	g_return_val_if_fail(session->gc != NULL, FALSE);
 
 	session->sesskey = msim_msg_get_integer(msg, "sesskey");
 	purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey);
@@ -1580,13 +1581,9 @@ msim_is_username_set(MsimSession *sessio
 	/* Set display name to username (otherwise will show email address) */
 	purple_connection_set_display_name(session->gc, session->username);
 
-
-	/* Additional post-connect operations */
-
-
+	/* If user lacks a username, help them get one. */
 	if (msim_msg_get_integer(msg, "uniquenick") == session->userid) {
-		purple_debug_info("msim_we_are_logged_on", "TODO: pick username\n");
-		g_return_val_if_fail(session->gc != NULL, FALSE);
+		purple_debug_info("msim_is_username_set", "no username is set\n");
 		purple_request_yes_no(session->gc,
 			_("MySpaceIM - No Username Set"),
 			_("You appear to have no MySpace username."),
@@ -1595,15 +1592,18 @@ msim_is_username_set(MsimSession *sessio
 			session->account,
 			NULL,
 			NULL,
-			session->gc, G_CALLBACK(msim_set_username_cb), G_CALLBACK(msim_do_not_set_username_cb));
-			purple_debug_info("msim","Username Not Set Alert Prompted\n");
+			session->gc, 
+			G_CALLBACK(msim_set_username_cb), 
+			G_CALLBACK(msim_do_not_set_username_cb));
+		purple_debug_info("msim_is_username_set","'username not set' alert prompted\n");
 		return FALSE;
 	}
 	return TRUE;
 }
 
-/** Called after username is set. */
-gboolean msim_we_are_logged_on(MsimSession *session) {
+/** Called after username is set, if necessary and we're open for business. */
+gboolean msim_we_are_logged_on(MsimSession *session) 
+{
 	MsimMessage *body;
 
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
============================================================
--- libpurple/protocols/myspace/myspace.h	8125af61362ed4039d08aa43321074a2a5db82c6
+++ libpurple/protocols/myspace/myspace.h	27bdbf2302bc6d261286b5d29145745aa05bc54b
@@ -45,7 +45,7 @@
 #include "cipher.h"     /* for SHA-1 */
 #include "util.h"       /* for base64 */
 #include "debug.h"      /* for purple_debug_info */
-#include "request.h" /* For dialogs used in setting the username */
+#include "request.h"    /* For dialogs used in setting the username */
 #include "xmlnode.h"
 #include "core.h"
 
@@ -109,6 +109,7 @@
 
 /* Time between keepalives (seconds) - if no data within this time, is dead. */
 #define MSIM_KEEPALIVE_INTERVAL     (3 * 60)
+/*#define MSIM_USE_KEEPALIVE*/
 
 /* Time to check if alive (milliseconds) */
 #define MSIM_KEEPALIVE_INTERVAL_CHECK   (30 * 1000)
============================================================
--- libpurple/protocols/myspace/user.c	d27bf6c290cb08eedae8acc1ce14a82e33abdc69
+++ libpurple/protocols/myspace/user.c	e979e6141e16cebdd74993a41620cc3ebffcf038
@@ -551,11 +551,13 @@ void msim_do_not_set_username_cb(PurpleC
  * Currently.. We're safe letting them get by without setting it.. Unless we hear otherwise..        *
  * So for now, give them a menu.. If this becomes an issue with the Official client.. boot them here */
 void msim_do_not_set_username_cb(PurpleConnection *gc) {
-	purple_debug_info("msim","Dont set username");
-	/* Give them the menu option to set one if they want to later */
+	purple_debug_info("msim", "Dont set username");
+
+	/* Protocol won't log in now without a username set.. Disconnect */
+	purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
 }
  
-/* They've decided to set a username! Yay! */
+/** They've decided to set a username! Yay! */
 void msim_set_username_cb(PurpleConnection *gc) {
 	g_return_if_fail(gc != NULL);
 	purple_debug_info("msim","Set username\n");
@@ -571,8 +573,10 @@ void msim_set_username_cb(PurpleConnecti
 			gc);
 }
 
-/* Once they've submited their new username, we need to see if its available here */
-static void msim_check_username_availability_cb(PurpleConnection *gc, const char *value) {
+/** Once they've submitted their desired new username, 
+ * check if it is available here. */
+static void msim_check_username_availability_cb(PurpleConnection *gc, const char *username_to_check) 
+{
 	MsimMessage *user_msg;
 	MsimSession *session;
 
@@ -582,28 +586,31 @@ static void msim_check_username_availabi
 
 	g_return_if_fail(MSIM_SESSION_VALID(session));
 
-	purple_debug_info("msim","Check username for %s\n",value);
+	purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check);
 	
 	user_msg = msim_msg_new(
-			"user", MSIM_TYPE_STRING, g_strdup(value),
+			"user", MSIM_TYPE_STRING, g_strdup(username_to_check),
 			NULL);
 
 	/* 25 characters: letters, numbers, underscores */
 	/* TODO: VERIFY ABOVE */
+
 	/* \persist\1\sesskey\288500516\cmd\1\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=Jaywalker\final\ */
 	/* Official client uses a standard lookup... So do we! */
-	msim_lookup_user(session, value, msim_username_is_available_cb, user_msg);
+	msim_lookup_user(session, username_to_check, msim_username_is_available_cb, user_msg);
 }
 
-/* \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\ */
-/* This is where we do a bit more than merely prompt the user. Now we have some real data to tell us the state of their requested username */
-static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) {
+/** This is where we do a bit more than merely prompt the user. 
+ * Now we have some real data to tell us the state of their requested username 
+ * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\ */
+static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) 
+{
 	MsimMessage *msg;
-	gchar *username, *errmsg;
+	gchar *username;
 	MsimMessage *body;
 	gint userid;
 
-	purple_debug_info("msim","Look up username callback made\n");
+	purple_debug_info("msim_username_is_available_cb", "Look up username callback made\n");
 	
 	msg = (MsimMessage *)data;
 	g_return_if_fail(MSIM_SESSION_VALID(session));
@@ -613,22 +620,25 @@ static void msim_username_is_available_c
 	body = msim_msg_get_dictionary(userinfo, "body");
 
 	if (!body) {
-		errmsg = g_strdup("An error occured while trying to set the username.\nPlease try again, or visit http://editprofile.myspace.com/index.cfm?fuseaction=profile.username to set your username.");
-		purple_debug_info("msim","No body for %s?!\n",username);
-		purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
+		purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username);
+		purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, 
+				"An error occured while trying to set the username.\n"
+				"Please try again, or visit http://editprofile.myspace.com/index.cfm?"
+				"fuseaction=profile.username to set your username.");
 		return;
 	}
 
 	userid = msim_msg_get_integer(body, "UserID");
 
-	purple_debug_info("msim","Returned username is %s and userid is %d\n", username,userid);
+	purple_debug_info("msim_username_is_available_cb", "Returned username is %s and userid is %d\n", username, userid);
 	msim_msg_free(body);
 	msim_msg_free(msg);
 
-	/* The response for a free username will ONLY have the UserName in it.. thus making UserID return 0 when we msg_get_integer it */
+	/* The response for a free username will ONLY have the UserName in it.. 
+	 * thus making UserID return 0 when we msg_get_integer it */
 	if (userid == 0) {
 		/* This username is currently unused */
-		purple_debug_info("msim","Username available. Prompting to Confirm.\n");
+		purple_debug_info("msim_username_is_available_cb", "Username available. Prompting to Confirm.\n");
 		msim_username_to_set = g_strdup(username);
 		g_free(username);
 		purple_request_yes_no(session->gc,
@@ -639,10 +649,15 @@ static void msim_username_is_available_c
 			session->account,
 			NULL,
 			NULL,
-			session->gc, G_CALLBACK(msim_set_username_confirmed_cb), G_CALLBACK(msim_do_not_set_username_cb));
+			session->gc, 
+			G_CALLBACK(msim_set_username_confirmed_cb), 
+			/* TODO: Should we really abort the whole process if the user changes their
+			 * mind about setting a username? Maybe should instead ask for another username,
+			 * but there should still be a way to get out of the loop. */
+			G_CALLBACK(msim_do_not_set_username_cb));
 	} else {
 		/* Looks like its in use or we have an invalid response */
-		purple_debug_info("msim","Username unavaiable. Prompting for new entry.\n");
+		purple_debug_info("msim_username_is_available_cb", "Username unavaiable. Prompting for new entry.\n");
 		purple_request_input(session->gc, _("MySpaceIM - Please Set a Username"),
 			_("This username is unavailable."),
 				_("Please try another username:"),
@@ -657,7 +672,8 @@ static void msim_username_is_available_c
 }
 
 /* They've confirmed that username that was available, Lets make the call to set it */
-static void msim_set_username_confirmed_cb(PurpleConnection *gc) {
+static void msim_set_username_confirmed_cb(PurpleConnection *gc) 
+{
 	MsimMessage *user_msg;
 	MsimSession *session;
 
@@ -672,7 +688,7 @@ static void msim_set_username_confirmed_
 			"user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set),
 			NULL);
 
-	purple_debug_info("msim","Setting username to %s\n",msim_username_to_set);
+	purple_debug_info("msim_set_username_confirmed_cb", "Setting username to %s\n", msim_username_to_set);
 	
 	/* Sets our username... keep your fingers crossed :) */
 	msim_set_username(session, msim_username_to_set, msim_username_is_set_cb, user_msg);
@@ -731,7 +747,9 @@ msim_set_username(MsimSession *session, 
 			 NULL));
 }
 
-static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) {
+/** Called after username is set. */
+static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) 
+{
 	gchar *username, *errmsg;
 	MsimMessage *body;
 


More information about the Commits mailing list