Mercurial > pidgin.yaz
changeset 29351:08296b862f98
Move the three phone numbers from the MsnUser struct into a separate
struct that gets added as needed. Makes MsnUser smaller by 2 pointers.
In practice nobody has phone numbers
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 04 Feb 2010 00:35:15 +0000 |
parents | 99d1b433dba0 |
children | 7f5a406a3b50 |
files | libpurple/protocols/msn/notification.c libpurple/protocols/msn/user.c libpurple/protocols/msn/user.h libpurple/protocols/msn/userlist.c |
diffstat | 4 files changed, 48 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/notification.c Thu Feb 04 00:15:41 2010 +0000 +++ b/libpurple/protocols/msn/notification.c Thu Feb 04 00:35:15 2010 +0000 @@ -1144,7 +1144,7 @@ msn_user_set_object(user, msnobj); - user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+'); + user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone && user->phone->mobile && user->phone->mobile[0] == '+'); msn_user_set_clientid(user, clientid); msn_user_set_network(user, networkid); @@ -1316,7 +1316,7 @@ } clientid = strtoul(cmd->params[4], NULL, 10); - user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+'); + user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone && user->phone->mobile && user->phone->mobile[0] == '+'); msn_user_set_clientid(user, clientid); msn_user_set_network(user, networkid);
--- a/libpurple/protocols/msn/user.c Thu Feb 04 00:15:41 2010 +0000 +++ b/libpurple/protocols/msn/user.c Thu Feb 04 00:35:15 2010 +0000 @@ -67,9 +67,12 @@ g_free(user->passport); g_free(user->friendly_name); g_free(user->uid); - g_free(user->phone.home); - g_free(user->phone.work); - g_free(user->phone.mobile); + if (user->phone) { + g_free(user->phone->home); + g_free(user->phone->work); + g_free(user->phone->mobile); + g_free(user->phone); + } if (user->media) { g_free(user->media->artist); g_free(user->media->title); @@ -367,8 +370,15 @@ { g_return_if_fail(user != NULL); - g_free(user->phone.home); - user->phone.home = g_strdup(number); + if (!number && !user->phone) + return; + + if (user->phone) + g_free(user->phone->home); + else + user->phone = g_new0(MsnUserPhoneInfo, 1); + + user->phone->home = g_strdup(number); } void @@ -376,8 +386,15 @@ { g_return_if_fail(user != NULL); - g_free(user->phone.work); - user->phone.work = g_strdup(number); + if (!number && !user->phone) + return; + + if (user->phone) + g_free(user->phone->work); + else + user->phone = g_new0(MsnUserPhoneInfo, 1); + + user->phone->work = g_strdup(number); } void @@ -385,8 +402,15 @@ { g_return_if_fail(user != NULL); - g_free(user->phone.mobile); - user->phone.mobile = g_strdup(number); + if (!number && !user->phone) + return; + + if (user->phone) + g_free(user->phone->mobile); + else + user->phone = g_new0(MsnUserPhoneInfo, 1); + + user->phone->mobile = g_strdup(number); } void @@ -461,7 +485,7 @@ { g_return_val_if_fail(user != NULL, NULL); - return user->phone.home; + return user->phone ? user->phone->home : NULL; } const char * @@ -469,7 +493,7 @@ { g_return_val_if_fail(user != NULL, NULL); - return user->phone.work; + return user->phone ? user->phone->work : NULL; } const char * @@ -477,7 +501,7 @@ { g_return_val_if_fail(user != NULL, NULL); - return user->phone.mobile; + return user->phone ? user->phone->mobile : NULL; } guint
--- a/libpurple/protocols/msn/user.h Thu Feb 04 00:15:41 2010 +0000 +++ b/libpurple/protocols/msn/user.h Thu Feb 04 00:35:15 2010 +0000 @@ -61,6 +61,13 @@ char *album; /**< Album. */ } CurrentMedia; +typedef struct _MsnUserPhoneInfo +{ + char *home; /**< Home phone number. */ + char *work; /**< Work phone number. */ + char *mobile; /**< Mobile phone number. */ +} MsnUserPhoneInfo; + /** * A user. */ @@ -79,13 +86,7 @@ gboolean idle; /**< The idle state of the user. */ - struct - { - char *home; /**< Home phone number. */ - char *work; /**< Work phone number. */ - char *mobile; /**< Mobile phone number. */ - - } phone; + MsnUserPhoneInfo *phone; /**< This user's phone numbers. */ gboolean authorized; /**< Authorized to add this user. */ gboolean mobile; /**< Signed up with MSN Mobile. */
--- a/libpurple/protocols/msn/userlist.c Thu Feb 04 00:15:41 2010 +0000 +++ b/libpurple/protocols/msn/userlist.c Thu Feb 04 00:35:15 2010 +0000 @@ -335,11 +335,11 @@ for (l = userlist->users; l != NULL; l = l->next) { MsnUser *user = (MsnUser *)l->data; - if (user->phone.mobile == NULL) { + if (!user->phone || !user->phone->mobile) { continue; } - if (!g_ascii_strcasecmp(number, user->phone.mobile)) { + if (!g_ascii_strcasecmp(number, user->phone->mobile)) { return user; } }