comparison libgaim/protocols/qq/utils.c @ 14319:69f594f56de5

[gaim-migrate @ 17012] Removed the prefix before user IDs, it was giving the Adium folks a hard time. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Thu, 24 Aug 2006 08:04:46 +0000
parents 584cbd1628d0
children 8ff8f1c897b5
comparison
equal deleted inserted replaced
14318:437ce90442cf 14319:69f594f56de5
34 #include "prefs.h" 34 #include "prefs.h"
35 #include "qq.h" 35 #include "qq.h"
36 #include "util.h" 36 #include "util.h"
37 #include "utils.h" 37 #include "utils.h"
38 38
39 #define QQ_NAME_FORMAT "qq-%d" 39 #define QQ_NAME_FORMAT "%d"
40 40
41 gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount) 41 gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount)
42 { 42 {
43 gint index; 43 gint index;
44 44
162 gchar *get_icon_name(gint set) 162 gchar *get_icon_name(gint set)
163 { 163 {
164 return g_strdup_printf("qq_%d", set); 164 return g_strdup_printf("qq_%d", set);
165 } 165 }
166 166
167 /* convert a QQ UID to a unique name of GAIM 167 /* convert a QQ UID to a unique name of Gaim
168 * the return needs to be freed */ 168 * the return needs to be freed */
169 gchar *uid_to_gaim_name(guint32 uid) 169 gchar *uid_to_gaim_name(guint32 uid)
170 { 170 {
171 return g_strdup_printf(QQ_NAME_FORMAT, uid); 171 return g_strdup_printf(QQ_NAME_FORMAT, uid);
172 } 172 }
173 173
174 /* convert GAIM name to original QQ UID */ 174 /* convert Gaim name to original QQ UID */
175 guint32 gaim_name_to_uid(const gchar *const name) 175 guint32 gaim_name_to_uid(const gchar *const name)
176 { 176 {
177 gchar *p; 177 guint32 ret;
178 178 g_return_val_if_fail(name != NULL, 0);
179 g_return_val_if_fail(gaim_str_has_prefix(name, QQ_NAME_PREFIX), 0); 179
180 180 ret = strtol(name, NULL, 10);
181 p = g_strrstr(name, QQ_NAME_PREFIX); 181 if (errno == ERANGE)
182 return (p == NULL) ? 0 : strtol(p + strlen(QQ_NAME_PREFIX), NULL, 10); 182 return 0;
183 else
184 return ret;
183 } 185 }
184 186
185 /* try to dump the data as GBK */ 187 /* try to dump the data as GBK */
186 void try_dump_as_gbk(const guint8 *const data, gint len) 188 void try_dump_as_gbk(const guint8 *const data, gint len)
187 { 189 {