static char *tgp_msg_photo_display (struct tgl_state *TLS, const char *filename, int *flags) { connection_data *conn = TLS->ev_base; int img = p2tgl_imgstore_add_with_id (filename); if (img <= 0) { failure ("Cannot display picture, adding to imgstore failed."); return NULL; } used_images_add (conn, img); *flags |= PURPLE_MESSAGE_IMAGES; return tgp_format_img (img); }
static char *tgp_msg_sticker_display (struct tgl_state *TLS, tgl_peer_id_t from, const char *filename, int *flags) { char *text = NULL; #ifdef HAVE_LIBWEBP connection_data *conn = TLS->ev_base; int img = p2tgl_imgstore_add_with_id_webp ((char *) filename); if (img <= 0) { failure ("Cannot display sticker, adding to imgstore failed"); return NULL; } used_images_add (conn, img); text = tgp_format_img (img); *flags |= PURPLE_MESSAGE_IMAGES; #else const char *txt_user = tgp_blist_lookup_purple_name (TLS, from); g_return_val_if_fail (txt_user, NULL); text = g_strdup_printf (_("%s sent a sticker."), txt_user); *flags |= PURPLE_MESSAGE_SYSTEM; #endif return text; }
static void tgp_info_load_user_done (struct tgl_state *TLS, void *extra, int success, struct tgl_user *U) { g_return_if_fail(success); // user info PurpleNotifyUserInfo *info = purple_notify_user_info_new (); if (str_not_empty (U->first_name) && str_not_empty (U->last_name)) { purple_notify_user_info_add_pair (info, _("First name"), U->first_name); purple_notify_user_info_add_pair (info, _("Last name"), U->last_name); } else { purple_notify_user_info_add_pair (info, _("Name"), U->print_name); } if (str_not_empty (U->username)) { char *username = g_strdup_printf ("@%s", U->username); purple_notify_user_info_add_pair (info, _("Username"), username); g_free (username); } char *status = tgp_format_user_status (&U->status); purple_notify_user_info_add_pair (info, _("Last seen"), status); g_free (status); if (str_not_empty (U->phone)) { char *phone = g_strdup_printf ("+%s", U->phone); purple_notify_user_info_add_pair (info, _("Phone"), phone); g_free (phone); } // secret chat info tgl_peer_t *O = extra; if (O && tgl_get_peer_type (O->id) == TGL_PEER_ENCR_CHAT) { struct tgl_secret_chat *secret = &O->encr_chat; if (secret->state == sc_waiting) { purple_notify_user_info_add_pair (info, "", _("Waiting for the user to get online...")); } else { const char *ttl_key = _("Self destruction timer"); if (secret->ttl) { char *ttl = g_strdup_printf ("%d", secret->ttl); purple_notify_user_info_add_pair (info, ttl_key, ttl); g_free (ttl); } else { purple_notify_user_info_add_pair (info, ttl_key, _("Timer is not enabled.")); } if (secret->first_key_sha[0]) { int sha1key = tgp_visualize_key (TLS, secret->first_key_sha); if (sha1key != -1) { char *ident_icon = tgp_format_img (sha1key); purple_notify_user_info_add_pair (info, _("Secret key"), ident_icon); g_free(ident_icon); } } } } const char *who = NULL; if (tgl_get_peer_type (O->id) == TGL_PEER_ENCR_CHAT) { who = tgp_blist_lookup_purple_name (TLS, O->id); } else { who = tgp_blist_lookup_purple_name (TLS, U->id); } purple_notify_userinfo (tls_get_conn (TLS), who, info, NULL, NULL); }