Mercurial > pidgin.yaz
changeset 22305:bf4902fce6e4
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.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 16 Feb 2008 21:29:02 +0000 |
parents | c3dc9e0d2c08 |
children | 7d0e93198c39 3867cef6a0d5 |
files | libpurple/protocols/myspace/myspace.h libpurple/protocols/myspace/user.c libpurple/protocols/myspace/user.h |
diffstat | 3 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 @). *
--- 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);