# HG changeset patch # User Stu Tomlinson # Date 1180300417 0 # Node ID a1c6206f020528d1a7b9fb92b91380047d136658 # Parent 9053156d016a72e38f917d5a2dbe367cb995d0cf Make the MsnUser type an enum so we have fewer magic numbers diff -r 9053156d016a -r a1c6206f0205 libpurple/protocols/msn/contact.c --- a/libpurple/protocols/msn/contact.c Sun May 27 18:02:52 2007 +0000 +++ b/libpurple/protocols/msn/contact.c Sun May 27 21:13:37 2007 +0000 @@ -105,16 +105,16 @@ msn_get_user_type(char * type) { if(!strcmp(type,"Regular")){ - return 1; + return MSN_USER_TYPE_PASSPORT; } if(!strcmp(type,"Live")){ - return 1; + return MSN_USER_TYPE_PASSPORT; } if(!strcmp(type,"LivePending")){ - return 1; + return MSN_USER_TYPE_PASSPORT; } - return 0; + return MSN_USER_TYPE_UNKNOWN; } /*parse contact list*/ diff -r 9053156d016a -r a1c6206f0205 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Sun May 27 18:02:52 2007 +0000 +++ b/libpurple/protocols/msn/notification.c Sun May 27 21:13:37 2007 +0000 @@ -40,7 +40,7 @@ static void msn_notification_fqy_yahoo(MsnSession *session, const char *passport); static void msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len); -static void msn_add_contact_xml(xmlnode *mlNode, const char *passport, int list_op, int type); +static void msn_add_contact_xml(xmlnode *mlNode, const char *passport, int list_op, MsnUserType type); /************************************************************************** * Main @@ -586,7 +586,7 @@ **************************************************************************/ /* add contact to xmlnode */ static void -msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type) +msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op, MsnUserType type) { xmlnode *d_node,*c_node; char **tokens; @@ -633,10 +633,10 @@ xmlnode_set_attrib(c_node,"t",type_str); #else if(g_strrstr(domain,"yahoo") != NULL){ - type_str = g_strdup_printf("32"); + type_str = g_strdup_printf("%d", MSN_USER_TYPE_YAHOO); }else{ /*passport*/ - type_str = g_strdup_printf("1"); + type_str = g_strdup_printf("%d", MSN_USER_TYPE_PASSPORT); } /*mobile*/ //type_str = g_strdup_printf("4"); @@ -1864,7 +1864,7 @@ adl_node = xmlnode_new("ml"); adl_node->child = NULL; - msn_add_contact_xml(adl_node,who,1,1); + msn_add_contact_xml(adl_node,who,1,MSN_USER_TYPE_PASSPORT); payload = xmlnode_to_str(adl_node,&payload_len); xmlnode_free(adl_node); @@ -1894,7 +1894,7 @@ rml_node = xmlnode_new("ml"); rml_node->child = NULL; - msn_add_contact_xml(rml_node,who,1,1); + msn_add_contact_xml(rml_node,who,1,MSN_USER_TYPE_PASSPORT); payload = xmlnode_to_str(rml_node,&payload_len); xmlnode_free(rml_node); diff -r 9053156d016a -r a1c6206f0205 libpurple/protocols/msn/user.c --- a/libpurple/protocols/msn/user.c Sun May 27 18:02:52 2007 +0000 +++ b/libpurple/protocols/msn/user.c Sun May 27 21:13:37 2007 +0000 @@ -202,7 +202,7 @@ } void -msn_user_set_type(MsnUser *user, int type) +msn_user_set_type(MsnUser *user, MsnUserType type) { g_return_if_fail(user != NULL); diff -r 9053156d016a -r a1c6206f0205 libpurple/protocols/msn/user.h --- a/libpurple/protocols/msn/user.h Sun May 27 18:02:52 2007 +0000 +++ b/libpurple/protocols/msn/user.h Sun May 27 21:13:37 2007 +0000 @@ -31,6 +31,17 @@ #include "userlist.h" +typedef enum +{ + MSN_USER_TYPE_UNKNOWN = 0x00, + MSN_USER_TYPE_PASSPORT = 0x01, + MSN_USER_TYPE_UNKNOWN1 = 0x02, + MSN_USER_TYPE_MOBILE = 0x04, + MSN_USER_TYPE_UNKNOWN2 = 0x08, + MSN_USER_TYPE_UNKNOWN3 = 0x10, + MSN_USER_TYPE_YAHOO = 0x20 +} MsnUserType; + /** * A user. */ @@ -70,8 +81,8 @@ GHashTable *clientcaps; /**< The client's capabilities. */ - int type; - int list_op; + MsnUserType type; /**< The user type */ + int list_op; /**< Which lists the user is in */ }; /**************************************************************************/ @@ -205,7 +216,7 @@ void msn_user_set_work_phone(MsnUser *user, const char *number); void msn_user_set_uid(MsnUser *user, const char *uid); -void msn_user_set_type(MsnUser *user,int type); +void msn_user_set_type(MsnUser *user, MsnUserType type); /** * Sets the mobile phone number for a user.