# HG changeset patch # User Jeffrey Connelly # Date 1203197342 0 # Node ID bf4902fce6e41a3579ff1309d1b2d29cc4489057 # Parent c3dc9e0d2c089acf7cd2909b4ad97d64f72230e3 In msimprpl, add msim_is_valid_username() to check whether a username is valid (not whether it exists). Not used anywhere, but will help #4855. diff -r c3dc9e0d2c08 -r bf4902fce6e4 libpurple/protocols/myspace/myspace.h --- a/libpurple/protocols/myspace/myspace.h Sat Feb 16 21:07:09 2008 +0000 +++ b/libpurple/protocols/myspace/myspace.h Sat Feb 16 21:29:02 2008 +0000 @@ -89,6 +89,9 @@ * warn user that it may be too long. */ #define MSIM_MAX_PASSWORD_LENGTH 10 +/* Maximum length of usernames, when setting. */ +#define MSIM_MAX_USERNAME_LENGTH 25 + /* Build version of MySpaceIM to report to servers (1.0.xxx.0) */ #define MSIM_CLIENT_VERSION 697 diff -r c3dc9e0d2c08 -r bf4902fce6e4 libpurple/protocols/myspace/user.c --- a/libpurple/protocols/myspace/user.c Sat Feb 16 21:07:09 2008 +0000 +++ b/libpurple/protocols/myspace/user.c Sat Feb 16 21:29:02 2008 +0000 @@ -496,6 +496,19 @@ return strspn(user, "0123456789") == strlen(user); } +/** Return whether a given username is syntactically valid. + * Note: does not actually check that the user exists. */ +gboolean +msim_is_valid_username(const gchar *user) +{ + return !msim_is_userid(user) && /* Not all numeric */ + strlen(user) <= MSIM_MAX_USERNAME_LENGTH + && strspn(user, "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "_" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user); +} + /** * Check if a string is an email address (contains an @). * diff -r c3dc9e0d2c08 -r bf4902fce6e4 libpurple/protocols/myspace/user.h --- a/libpurple/protocols/myspace/user.h Sat Feb 16 21:07:09 2008 +0000 +++ b/libpurple/protocols/myspace/user.h Sat Feb 16 21:29:02 2008 +0000 @@ -51,6 +51,7 @@ gboolean msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user); gboolean msim_is_userid(const gchar *user); gboolean msim_is_email(const gchar *user); +gboolean msim_is_valid_username(const gchar *user); void msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data); void msim_set_username_cb(PurpleConnection *gc); void msim_do_not_set_username_cb(PurpleConnection *gc);