comparison libpurple/protocols/msn/user.c @ 23122:b30f54a72031

propagate from branch 'im.pidgin.pidgin' (head 8ab7bcf180c3d8cc09b9d82060417bcf3fcfff95) to branch 'im.pidgin.pidgin.custom_smiley' (head aeaf4e99a407c48978426a7866b921b380471dad)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 31 Mar 2008 21:04:51 +0000
parents 1168dc635ac1 b65997110933
children 5cdd93dac7a2
comparison
equal deleted inserted replaced
22595:0998ae2e4838 23122:b30f54a72031
244 } 244 }
245 245
246 void 246 void
247 msn_user_set_buddy_icon(MsnUser *user, PurpleStoredImage *img) 247 msn_user_set_buddy_icon(MsnUser *user, PurpleStoredImage *img)
248 { 248 {
249 MsnObject *msnobj = msn_user_get_object(user); 249 MsnObject *msnobj;
250 250
251 g_return_if_fail(user != NULL); 251 g_return_if_fail(user != NULL);
252 252
253 if (img == NULL) 253 msnobj = msn_object_new_from_image(img, "TFR2C2.tmp",
254 msn_user_set_object(user, NULL); 254 user->passport, MSN_OBJECT_USERTILE);
255 else 255
256 { 256 if (!msnobj)
257 PurpleCipherContext *ctx; 257 purple_debug_error("msn", "Unable to open buddy icon from %s!\n", user->passport);
258 char *buf; 258
259 gconstpointer data = purple_imgstore_get_data(img); 259 msn_user_set_object(user, msnobj);
260 size_t size = purple_imgstore_get_size(img);
261 char *base64;
262 unsigned char digest[20];
263
264 if (msnobj == NULL)
265 {
266 msnobj = msn_object_new();
267 msn_object_set_local(msnobj);
268 msn_object_set_type(msnobj, MSN_OBJECT_USERTILE);
269 msn_object_set_location(msnobj, "TFR2C2.tmp");
270 msn_object_set_creator(msnobj, msn_user_get_passport(user));
271
272 msn_user_set_object(user, msnobj);
273 }
274
275 msn_object_set_image(msnobj, img);
276
277 /* Compute the SHA1D field. */
278 memset(digest, 0, sizeof(digest));
279
280 ctx = purple_cipher_context_new_by_name("sha1", NULL);
281 purple_cipher_context_append(ctx, data, size);
282 purple_cipher_context_digest(ctx, sizeof(digest), digest, NULL);
283
284 base64 = purple_base64_encode(digest, sizeof(digest));
285 msn_object_set_sha1d(msnobj, base64);
286 g_free(base64);
287
288 msn_object_set_size(msnobj, size);
289
290 /* Compute the SHA1C field. */
291 buf = g_strdup_printf(
292 "Creator%sSize%dType%dLocation%sFriendly%sSHA1D%s",
293 msn_object_get_creator(msnobj),
294 msn_object_get_size(msnobj),
295 msn_object_get_type(msnobj),
296 msn_object_get_location(msnobj),
297 msn_object_get_friendly(msnobj),
298 msn_object_get_sha1d(msnobj));
299
300 memset(digest, 0, sizeof(digest));
301
302 purple_cipher_context_reset(ctx, NULL);
303 purple_cipher_context_append(ctx, (const guchar *)buf, strlen(buf));
304 purple_cipher_context_digest(ctx, sizeof(digest), digest, NULL);
305 purple_cipher_context_destroy(ctx);
306 g_free(buf);
307
308 base64 = purple_base64_encode(digest, sizeof(digest));
309 msn_object_set_sha1c(msnobj, base64);
310 g_free(base64);
311 }
312 } 260 }
313 261
314 /*add group id to User object*/ 262 /*add group id to User object*/
315 void 263 void
316 msn_user_add_group_id(MsnUser *user, const char* id) 264 msn_user_add_group_id(MsnUser *user, const char* id)