Mercurial > pidgin.yaz
comparison src/protocols/qq/utils.c @ 13989:16102b9c5c4a
[gaim-migrate @ 16562]
*Eliminated all Gtk-related code from the prpl. Notably, this included the group ("Qun") administrative dialog and a dialog for setting and viewing personal information. Code for the latter now uses the gaim UI, while the former is currently disabled.
*Disabled a few non-functional/non-essential menu actions. These included: IP lookup, system logging, about dialog, and qq_buddy_menu.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Mon, 24 Jul 2006 13:39:12 +0000 |
parents | 983fd420e86b |
children | 9516a796ed5f |
comparison
equal
deleted
inserted
replaced
13988:4d5cc9e4cb12 | 13989:16102b9c5c4a |
---|---|
123 /*****************************************************************************/ | 123 /*****************************************************************************/ |
124 // given a four-byte ip data, convert it into a human readable ip string | 124 // given a four-byte ip data, convert it into a human readable ip string |
125 // the return needs to be freed | 125 // the return needs to be freed |
126 gchar *gen_ip_str(guint8 * ip) | 126 gchar *gen_ip_str(guint8 * ip) |
127 { | 127 { |
128 return g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); | 128 if (ip == NULL || ip[0] == 0) |
129 } // gen_ip_str | 129 return g_strdup_printf(""); |
130 else | |
131 return g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); | |
132 } | |
130 | 133 |
131 // by gfhuang | 134 // by gfhuang |
132 guint8 *str_ip_gen(gchar *str) { | 135 guint8 *str_ip_gen(gchar *str) { |
133 guint8 *ip = g_new(guint8, 4); | 136 guint8 *ip = g_new(guint8, 4); |
134 int a, b, c, d; | 137 int a, b, c, d; |
166 | 169 |
167 p = g_strrstr(name, QQ_NAME_PREFIX); | 170 p = g_strrstr(name, QQ_NAME_PREFIX); |
168 // atoi is not thread-safe and also not async-cancel safe | 171 // atoi is not thread-safe and also not async-cancel safe |
169 // atoi is deprecated by strtol() and should not be used in new code | 172 // atoi is deprecated by strtol() and should not be used in new code |
170 return (p == NULL) ? 0 : strtol(p + strlen(QQ_NAME_PREFIX), NULL, 10); | 173 return (p == NULL) ? 0 : strtol(p + strlen(QQ_NAME_PREFIX), NULL, 10); |
171 } // gaim_name_to_uid | 174 } |
172 | |
173 /*****************************************************************************/ | |
174 // convert QQ icon index into its pixbuf | |
175 GdkPixbuf *get_face_gdkpixbuf(guint8 index) | |
176 { | |
177 gint set, suffix; | |
178 gchar *image_name, *file_name; | |
179 GdkPixbuf *pixbuf; | |
180 const gchar *datadir; | |
181 | |
182 set = (index / 3) + 1; | |
183 suffix = (index % 3) + 1; | |
184 | |
185 image_name = g_strdup_printf("%s.png", get_icon_name(set, suffix)); | |
186 // we need to configure DATADIR in Makefile.am | |
187 // st = -DDATADIR=\"$(datadir)\" | |
188 datadir = gaim_prefs_get_string("/plugins/prpl/qq/datadir"); | |
189 if (datadir == NULL || strlen(datadir) == 0) | |
190 file_name = g_build_filename(datadir, "pixmaps", "gaim", "status", "default", image_name, NULL); | |
191 else | |
192 file_name = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image_name, NULL); | |
193 | |
194 pixbuf = gdk_pixbuf_new_from_file(file_name, NULL); | |
195 | |
196 g_free(image_name); | |
197 g_free(file_name); | |
198 | |
199 return pixbuf; | |
200 } // get_face_gdkpixbuf | |
201 | 175 |
202 /*****************************************************************************/ | 176 /*****************************************************************************/ |
203 // try to dump the data as GBK | 177 // try to dump the data as GBK |
204 void try_dump_as_gbk(guint8 * data, gint len) | 178 void try_dump_as_gbk(guint8 * data, gint len) |
205 { | 179 { |
225 g_free(msg_utf8); | 199 g_free(msg_utf8); |
226 } // msg_utf8 != NULL | 200 } // msg_utf8 != NULL |
227 } // try_dump_gbk | 201 } // try_dump_gbk |
228 | 202 |
229 /*****************************************************************************/ | 203 /*****************************************************************************/ |
204 | |
230 // dump a chunk of raw data into hex string | 205 // dump a chunk of raw data into hex string |
231 // the return should be freed later | 206 // the return should be freed later |
232 gchar *hex_dump_to_str(const guint8 * buffer, gint bytes) | 207 gchar *hex_dump_to_str(const guint8 * buffer, gint bytes) |
233 { | 208 { |
234 GString *str; | 209 GString *str; |
253 ch = buffer[i + j] & 127; | 228 ch = buffer[i + j] & 127; |
254 if (ch < ' ' || ch == 127) | 229 if (ch < ' ' || ch == 127) |
255 g_string_append_c(str, '.'); | 230 g_string_append_c(str, '.'); |
256 else | 231 else |
257 g_string_append_c(str, ch); | 232 g_string_append_c(str, ch); |
258 } // for j | 233 } |
259 g_string_append_c(str, '\n'); | 234 g_string_append_c(str, '\n'); |
260 } // for i | 235 } |
261 | 236 |
262 ret = str->str; | 237 ret = str->str; |
263 // GString can be freed without freeing it character data | 238 // GString can be freed without freeing it character data |
264 g_string_free(str, FALSE); | 239 g_string_free(str, FALSE); |
265 | 240 |
266 return ret; | 241 return ret; |
267 } // hex_dump_to_str | 242 } |
268 | 243 |
269 /*****************************************************************************/ | 244 /*****************************************************************************/ |
270 // ENF OF FILE | 245 // ENF OF FILE |