pidgin: 4add4bb1: Move the three phone numbers from the Ms...
markdoliner at pidgin.im
markdoliner at pidgin.im
Wed Feb 3 19:40:26 EST 2010
-----------------------------------------------------------------
Revision: 4add4bb18f9d282b1c7369e7485f27a6017821ff
Ancestor: c53f3e9685d0d537b1dd9ec203a6301399bad0c4
Author: markdoliner at pidgin.im
Date: 2010-02-04T00:35:15
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4add4bb18f9d282b1c7369e7485f27a6017821ff
Modified files:
libpurple/protocols/msn/notification.c
libpurple/protocols/msn/user.c
libpurple/protocols/msn/user.h
libpurple/protocols/msn/userlist.c
ChangeLog:
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
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c 7b37a9c706cec9fbfd70b73c993f247e0a796dca
+++ libpurple/protocols/msn/notification.c bdf9fa74438242fba052a0a9da2898fd839aba23
@@ -1144,7 +1144,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand
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 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand
}
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);
============================================================
--- libpurple/protocols/msn/user.c 433ba117bf989bcbf8092136af7ac9f0a0632d9a
+++ libpurple/protocols/msn/user.c 9ec9126a97330012f251f490c4c86eaa995d9b80
@@ -67,9 +67,12 @@ msn_user_destroy(MsnUser *user)
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 @@ msn_user_set_home_phone(MsnUser *user, c
{
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 @@ msn_user_set_work_phone(MsnUser *user, c
{
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 @@ msn_user_set_mobile_phone(MsnUser *user,
{
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 @@ msn_user_get_home_phone(const MsnUser *u
{
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 @@ msn_user_get_work_phone(const MsnUser *u
{
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 @@ msn_user_get_mobile_phone(const MsnUser
{
g_return_val_if_fail(user != NULL, NULL);
- return user->phone.mobile;
+ return user->phone ? user->phone->mobile : NULL;
}
guint
============================================================
--- libpurple/protocols/msn/user.h a951dafd308cd5482c25503b74f9e6f252a9f649
+++ libpurple/protocols/msn/user.h b6619056b1681176caaaf5bf4ee349a06d08079e
@@ -61,6 +61,13 @@ typedef struct _CurrentMedia
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,14 +86,8 @@ struct _MsnUser
gboolean idle; /**< The idle state of the user. */
- struct
- {
- char *home; /**< Home phone number. */
- char *work; /**< Work phone number. */
- char *mobile; /**< Mobile phone number. */
+ MsnUserPhoneInfo *phone; /**< This user's phone numbers. */
- } phone;
-
gboolean authorized; /**< Authorized to add this user. */
gboolean mobile; /**< Signed up with MSN Mobile. */
============================================================
--- libpurple/protocols/msn/userlist.c c05e859588dff1534487aa18b641838571d7c51c
+++ libpurple/protocols/msn/userlist.c 71b528f31418cd8ef6b1a97734fa9c390df8775c
@@ -335,11 +335,11 @@ msn_userlist_find_user_with_mobile_phone
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;
}
}
More information about the Commits
mailing list