Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/majn/telegram-purple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjentsch <mtthsjntsch@gmail.com>2016-01-25 02:51:33 +0300
committermjentsch <mtthsjntsch@gmail.com>2016-01-25 02:51:33 +0300
commit8100114319603becb0e63de0fff3dc01bacd7446 (patch)
tree363c1279d0b45392288f2ee80378b4e5ea0a9597 /tgp-blist.c
parent00b709e39f7e1f9bde775bea69136e2ad9c39712 (diff)
Handle contacts added on different devices
Assure to add contacts, even when they are not in the dialog list. Refactor contact handling.
Diffstat (limited to 'tgp-blist.c')
-rw-r--r--tgp-blist.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tgp-blist.c b/tgp-blist.c
index 66b56bb..46cfa2c 100644
--- a/tgp-blist.c
+++ b/tgp-blist.c
@@ -150,6 +150,24 @@ PurpleBuddy *tgp_blist_buddy_find (struct tgl_state *TLS, tgl_peer_id_t user) {
return (PurpleBuddy *) tgp_blist_iterate (TLS, tgp_blist_buddy_find_cb, GINT_TO_POINTER(tgl_get_peer_id (user)));
}
+// contacts
+
+void tgp_blist_contact_add (struct tgl_state *TLS, struct tgl_user *U) {
+ PurpleBuddy *buddy = tgp_blist_buddy_find (TLS, U->id);
+
+ if (! buddy) {
+ tgl_peer_t *P = tgl_peer_get (TLS, U->id);
+
+ info ("Adding contact '%s' to buddy list", tgp_blist_lookup_purple_name (TLS, U->id));
+ buddy = tgp_blist_buddy_new (TLS, P);
+ purple_blist_add_buddy (buddy, NULL, tgp_blist_group_init (_("Telegram")), NULL);
+
+ tgp_info_update_photo (buddy, P);
+ }
+
+ p2tgl_prpl_got_user_status (TLS, U->id, &U->status);
+}
+
// chats
static int tgp_blist_chat_find_cb (PurpleBlistNode *node, void *extra) {