diff --git a/telegram-base.c b/telegram-base.c index a2ccca1..11386d6 100644 --- a/telegram-base.c +++ b/telegram-base.c @@ -457,9 +457,9 @@ void chat_add_all_users (PurpleConversation *pc, struct tgl_chat *chat) { } /** - * This function generates a png image to visulize the sha1 key from an encrypted chat. + * This function generates a png image to visualize the sha1 key from an encrypted chat. */ -int generate_ident_icon (unsigned char* sha1_key) +int generate_ident_icon (struct tgl_state *TLS, unsigned char* sha1_key) { int colors[4] = { 0xffffff, @@ -469,6 +469,7 @@ int generate_ident_icon (unsigned char* sha1_key) }; unsigned img_size = 160; unsigned char* image = (unsigned char*)malloc (img_size * img_size * 4); + assert (image); unsigned x, y, i, j, idx = 0; int bitpointer = 0; for (y = 0; y < 8; y++) @@ -502,9 +503,9 @@ int generate_ident_icon (unsigned char* sha1_key) int imgStoreId = -1; if(!error) { - imgStoreId = purple_imgstore_add_with_id(g_memdup(png, pngsize), pngsize, NULL); + imgStoreId = purple_imgstore_add_with_id (png, pngsize, NULL); + used_images_add ((connection_data*)TLS->ev_base, imgStoreId); } g_free(image); - g_free(png); return imgStoreId; } diff --git a/telegram-base.h b/telegram-base.h index dbe1c33..72ed30f 100644 --- a/telegram-base.h +++ b/telegram-base.h @@ -32,6 +32,6 @@ PurpleConversation *chat_show (PurpleConnection *gc, int id); int chat_add_message (struct tgl_state *TLS, struct tgl_message *M, char *text); void chat_add_all_users (PurpleConversation *pc, struct tgl_chat *chat); void request_code_entered (gpointer data, const gchar *code); -int generate_ident_icon(unsigned char* sha1_key); +int generate_ident_icon(struct tgl_state *TLS, unsigned char* sha1_key); #endif diff --git a/telegram-purple.c b/telegram-purple.c index 96e523f..b38b0d4 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -488,12 +488,12 @@ static void on_userpic_loaded (struct tgl_state *TLS, void *extra, int success, purple_notify_user_info_add_pair (info, "Profile image", profile_image); //TODO: get the sha1key from the secret chat unsigned char sha1_key[20] = {129, 236, 235, 161, 62, 139, 244, 162, 120, 99, 99, 26, 171, 224, 25, 125}; - int sha1key_store_id = generate_ident_icon(sha1_key); + int sha1key_store_id = generate_ident_icon(TLS, sha1_key); if(sha1key_store_id != -1) { char *ident_icon = g_strdup_printf("
", sha1key_store_id); purple_notify_user_info_add_pair(info, "Identification icon", ident_icon); - g_free(ident_icon); + g_free(ident_icon); } purple_notify_userinfo (conn->gc, who, info, NULL, NULL);