Mercurial > pidgin
comparison libpurple/protocols/myspace/user.c @ 20753:61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
at the code and fix leaks.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 02 Oct 2007 06:13:27 +0000 |
parents | c43a36cb31a6 |
children | aee8d876fed1 |
comparison
equal
deleted
inserted
replaced
20752:e92c9987ba0d | 20753:61045691aa72 |
---|---|
28 * @return Return a new string (must be g_free()'d), or NULL. | 28 * @return Return a new string (must be g_free()'d), or NULL. |
29 */ | 29 */ |
30 static gchar * | 30 static gchar * |
31 msim_format_now_playing(gchar *band, gchar *song) | 31 msim_format_now_playing(gchar *band, gchar *song) |
32 { | 32 { |
33 if ((band && strlen(band)) || (song && strlen(song))) { | 33 if ((band && *band) || (song && *song)) { |
34 return g_strdup_printf("%s - %s", | 34 return g_strdup_printf("%s - %s", |
35 (band && strlen(band)) ? band : "Unknown Artist", | 35 (band && *band) ? band : "Unknown Artist", |
36 (song && strlen(song)) ? song : "Unknown Song"); | 36 (song && *song) ? song : "Unknown Song"); |
37 } else { | 37 } else { |
38 return NULL; | 38 return NULL; |
39 } | 39 } |
40 } | 40 } |
41 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */ | 41 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */ |
97 | 97 |
98 uid = purple_blist_node_get_int(&user->buddy->node, "UserID"); | 98 uid = purple_blist_node_get_int(&user->buddy->node, "UserID"); |
99 | 99 |
100 if (full) { | 100 if (full) { |
101 /* TODO: link to username, if available */ | 101 /* TODO: link to username, if available */ |
102 purple_notify_user_info_add_pair(user_info, _("Profile"), | 102 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>", |
103 g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>", | 103 uid, uid); |
104 uid, uid)); | 104 purple_notify_user_info_add_pair(user_info, _("Profile"), profile); |
105 g_free(profile); | |
105 } | 106 } |
106 | 107 |
107 | 108 |
108 /* a/s/l...the vitals */ | 109 /* a/s/l...the vitals */ |
109 if (user->age) { | 110 if (user->age) { |
110 purple_notify_user_info_add_pair(user_info, _("Age"), | 111 char age[16]; |
111 g_strdup_printf("%d", user->age)); | 112 g_snprintf(age, sizeof(age), "%d", user->age); |
112 } | 113 purple_notify_user_info_add_pair(user_info, _("Age"), age); |
113 | 114 } |
114 if (user->gender && strlen(user->gender)) { | 115 |
116 if (user->gender && *user->gender) { | |
115 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender); | 117 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender); |
116 } | 118 } |
117 | 119 |
118 if (user->location && strlen(user->location)) { | 120 if (user->location && *user->location) { |
119 purple_notify_user_info_add_pair(user_info, _("Location"), user->location); | 121 purple_notify_user_info_add_pair(user_info, _("Location"), user->location); |
120 } | 122 } |
121 | 123 |
122 /* Other information */ | 124 /* Other information */ |
123 if (user->headline && strlen(user->headline)) { | 125 if (user->headline && *user->headline) { |
124 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline); | 126 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline); |
125 } | 127 } |
126 | 128 |
127 str = msim_format_now_playing(user->band_name, user->song_name); | 129 str = msim_format_now_playing(user->band_name, user->song_name); |
128 if (str && strlen(str)) { | 130 if (str && *str) { |
129 purple_notify_user_info_add_pair(user_info, _("Song"), str); | 131 purple_notify_user_info_add_pair(user_info, _("Song"), str); |
130 } | 132 } |
133 g_free(str); | |
131 | 134 |
132 /* Note: total friends only available if looked up by uid, not username. */ | 135 /* Note: total friends only available if looked up by uid, not username. */ |
133 if (user->total_friends) { | 136 if (user->total_friends) { |
134 purple_notify_user_info_add_pair(user_info, _("Total Friends"), | 137 char friends[16]; |
135 g_strdup_printf("%d", user->total_friends)); | 138 g_snprintf(friends, sizeof(friends), "%d", user->total_friends); |
139 purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends); | |
136 } | 140 } |
137 | 141 |
138 if (full) { | 142 if (full) { |
139 /* Client information */ | 143 /* Client information */ |
144 char *client = NULL; | |
140 | 145 |
141 str = user->client_info; | 146 str = user->client_info; |
142 cv = user->client_cv; | 147 cv = user->client_cv; |
143 | 148 |
144 if (str && cv != 0) { | 149 if (str && cv != 0) { |
145 purple_notify_user_info_add_pair(user_info, _("Client Version"), | 150 client = g_strdup_printf("%s (build %d)", str, cv); |
146 g_strdup_printf("%s (build %d)", str, cv)); | |
147 } else if (str) { | 151 } else if (str) { |
148 purple_notify_user_info_add_pair(user_info, _("Client Version"), | 152 client = g_strdup(str); |
149 g_strdup(str)); | |
150 } else if (cv) { | 153 } else if (cv) { |
151 purple_notify_user_info_add_pair(user_info, _("Client Version"), | 154 client = g_strdup_printf("Build %d", cv); |
152 g_strdup_printf("Build %d", cv)); | |
153 } | 155 } |
156 if (client && *client) | |
157 purple_notify_user_info_add_pair(user_info, _("Client Version"), client); | |
158 g_free(client); | |
154 } | 159 } |
155 } | 160 } |
156 | 161 |
157 /** Store a field of information about a buddy. | 162 /** Store a field of information about a buddy. |
158 * | 163 * |