Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo_aliases.c @ 22794:0d7ceae153bd
Leak fixes.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 02 May 2008 22:01:01 +0000 |
parents | 3225c99785b8 |
children | 0b11895cc564 |
comparison
equal
deleted
inserted
replaced
22793:6b182ab4bc05 | 22794:0d7ceae153bd |
---|---|
66 | 66 |
67 if (len == 0) { | 67 if (len == 0) { |
68 purple_debug_info("yahoo", "No Aliases to process.%s%s\n", | 68 purple_debug_info("yahoo", "No Aliases to process.%s%s\n", |
69 error_message ? " Error:" : "", error_message ? error_message : ""); | 69 error_message ? " Error:" : "", error_message ? error_message : ""); |
70 } else { | 70 } else { |
71 const char *yid, *full_name, *nick_name, *alias, *id, *fn, *ln, *nn; | 71 gchar *full_name, *nick_name, *alias; |
72 const char *yid, *id, *fn, *ln, *nn; | |
72 PurpleBuddy *b = NULL; | 73 PurpleBuddy *b = NULL; |
73 xmlnode *item, *contacts; | 74 xmlnode *item, *contacts; |
74 | 75 |
75 /* Put our web response into a xmlnode for easy management */ | 76 /* Put our web response into a xmlnode for easy management */ |
76 contacts = xmlnode_from_str(url_text, -1); | 77 contacts = xmlnode_from_str(url_text, -1); |
90 fn = xmlnode_get_attrib(item,"fn"); | 91 fn = xmlnode_get_attrib(item,"fn"); |
91 ln = xmlnode_get_attrib(item,"ln"); | 92 ln = xmlnode_get_attrib(item,"ln"); |
92 nn = xmlnode_get_attrib(item,"nn"); | 93 nn = xmlnode_get_attrib(item,"nn"); |
93 id = xmlnode_get_attrib(item,"id"); | 94 id = xmlnode_get_attrib(item,"id"); |
94 | 95 |
95 /* Yahoo stores first and last names separately, lets put them together into a full name */ | 96 full_name = nick_name = alias = NULL; |
97 | |
98 /* Yahoo stores first and last names separately, lets put them together into a full name */ | |
96 if (yd->jp) | 99 if (yd->jp) |
97 full_name = g_strstrip(g_strdup_printf("%s %s", (ln != NULL ? ln : "") , (fn != NULL ? fn : ""))); | 100 full_name = g_strstrip(g_strdup_printf("%s %s", (ln != NULL ? ln : "") , (fn != NULL ? fn : ""))); |
98 else | 101 else |
99 full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); | 102 full_name = g_strstrip(g_strdup_printf("%s %s", (fn != NULL ? fn : "") , (ln != NULL ? ln : ""))); |
100 nick_name = (nn != NULL ? g_strstrip(g_strdup_printf("%s", nn)) : NULL); | 103 nick_name = (nn != NULL ? g_strstrip(g_strdup_printf("%s", nn)) : NULL); |
101 | 104 |
102 if (nick_name != NULL) | 105 if (nick_name != NULL) |
103 alias = nick_name; /* If we have a nickname from Yahoo, let's use it */ | 106 alias = nick_name; /* If we have a nickname from Yahoo, let's use it */ |
104 else if (strlen(full_name) != 0) | 107 else if (strlen(full_name) != 0) |
105 alias = full_name; /* If no Yahoo nickname, we can use the full_name created above */ | 108 alias = full_name; /* If no Yahoo nickname, we can use the full_name created above */ |
106 else | |
107 alias = NULL; /* No nickname, first name or last name, then you get no alias !! */ | |
108 | 109 |
109 /* Find the local buddy that matches */ | 110 /* Find the local buddy that matches */ |
110 b = purple_find_buddy(cb->gc->account, yid); | 111 b = purple_find_buddy(cb->gc->account, yid); |
111 | 112 |
112 /* If we don't find a matching buddy, ignore the alias !! */ | 113 /* If we don't find a matching buddy, ignore the alias !! */ |
116 yu = g_new0(struct YahooUser, 1); | 117 yu = g_new0(struct YahooUser, 1); |
117 yu->id = g_strdup(id); | 118 yu->id = g_strdup(id); |
118 yu->firstname = g_strdup(fn); | 119 yu->firstname = g_strdup(fn); |
119 yu->lastname = g_strdup(ln); | 120 yu->lastname = g_strdup(ln); |
120 yu->nickname = g_strdup(nn); | 121 yu->nickname = g_strdup(nn); |
122 /* TODO: Isn't there a possiblity that b->proto_data is already set? */ | |
121 b->proto_data=yu; | 123 b->proto_data=yu; |
122 | 124 |
123 /* Finally, if we received an alias, we better update the buddy list */ | 125 /* Finally, if we received an alias, we better update the buddy list */ |
124 if (alias != NULL) { | 126 if (alias != NULL) { |
125 serv_got_alias(cb->gc, yid, alias); | 127 serv_got_alias(cb->gc, yid, alias); |
130 purple_debug_info("yahoo","Sent alias '%s'\n", b->alias); | 132 purple_debug_info("yahoo","Sent alias '%s'\n", b->alias); |
131 } | 133 } |
132 } else { | 134 } else { |
133 purple_debug_info("yahoo", "Bizarre, received alias for %s, but they are not on your list...\n", yid); | 135 purple_debug_info("yahoo", "Bizarre, received alias for %s, but they are not on your list...\n", yid); |
134 } | 136 } |
137 | |
138 g_free(full_name); | |
139 g_free(nick_name); | |
135 } | 140 } |
136 } | 141 } |
137 xmlnode_free(contacts); | 142 xmlnode_free(contacts); |
138 } | 143 } |
139 g_free(cb->id); | 144 g_free(cb->id); |