From 3236a31551d90225c5b63f2bf08b73528f6c11d7 Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 1 Dec 2015 20:51:30 -0300 Subject: [PATCH 01/12] timer_alarm: Set fd to -1 to avoid warnings on tgl_timer_delete Warnings like this: GLib-CRITICAL **: Source ID N was not found when attempting to remove it --- tgp-timers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tgp-timers.c b/tgp-timers.c index 7330abf..3157a6e 100644 --- a/tgp-timers.c +++ b/tgp-timers.c @@ -31,6 +31,7 @@ struct tgl_timer { static int timer_alarm (gpointer arg) { struct tgl_timer *t = arg; + t->fd = -1; t->cb (t->TLS, t->arg); return FALSE; } From 18c2539f755753ce683178a49322853aaac89cb8 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Wed, 9 Dec 2015 01:08:45 +0100 Subject: [PATCH 02/12] Fix regressions: chat actions not available for chats --- telegram-purple.c | 30 +++++++++++++++++++++++------- tgp-chat.c | 11 +++++++++++ tgp-chat.h | 3 +++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/telegram-purple.c b/telegram-purple.c index 8281d10..db5ee12 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -389,7 +389,7 @@ static void create_chat_link_done (struct tgl_state *TLS, void *extra, int succe } } -static void create_chat_link (PurpleBlistNode *node, gpointer data) { +static void export_chat_link_checked_gw (PurpleBlistNode *node, gpointer data) { PurpleChat *chat = (PurpleChat*)node; export_chat_link_checked (pbn_get_data (node)->TLS, purple_chat_get_name (chat)); } @@ -408,6 +408,13 @@ void export_chat_link_checked (struct tgl_state *TLS, const char *name) { tgl_do_export_chat_link (TLS, C->id, create_chat_link_done, C); } +static void leave_and_delete_chat_gw (PurpleBlistNode *node, gpointer data) { + PurpleChat *C = (PurpleChat *)node; + g_return_if_fail(tgp_chat_has_id (C)); + + leave_and_delete_chat (pbn_get_data (node)->TLS, tgl_peer_get (pbn_get_data (node)->TLS, tgp_chat_get_id (C))); +} + void leave_and_delete_chat (struct tgl_state *TLS, tgl_peer_t *P) { g_return_if_fail (P); if (P && P->chat.users_num) { @@ -436,29 +443,38 @@ void import_chat_link_checked (struct tgl_state *TLS, const char *link) { static GList* tgprpl_blist_node_menu (PurpleBlistNode *node) { debug ("tgprpl_blist_node_menu()"); - // orphaned buddy in "old" format that didn't migrate - if (! tgp_blist_buddy_has_id ((PurpleBuddy *)node)) { + // skip orphaned buddies in "old" format that didn't migrate and don't have an ID + if (PURPLE_BLIST_NODE_IS_BUDDY(node) && ! tgp_blist_buddy_has_id ((PurpleBuddy *)node)) { + return NULL; + } + + // chats that dont have a proper ID arent usable + if (PURPLE_BLIST_NODE_IS_CHAT(node) && ! tgp_chat_has_id ((PurpleChat *)node)) { return NULL; } GList* menu = NULL; if (PURPLE_BLIST_NODE_IS_BUDDY(node) && tgl_get_peer_type (tgp_blist_buddy_get_id ((PurpleBuddy *)node)) == TGL_PEER_USER) { + // Add encrypted chat option to the right click menu of all buddies - PurpleBuddy* buddy = (PurpleBuddy*)node; + PurpleBuddy* buddy = (PurpleBuddy *)node; PurpleMenuAction* action = purple_menu_action_new (_("Start secret chat..."), PURPLE_CALLBACK(start_secret_chat), buddy, NULL); menu = g_list_append (menu, (gpointer)action); } if (PURPLE_BLIST_NODE_IS_CHAT(node)) { + // Generate Public Link - PurpleMenuAction* action = purple_menu_action_new (_("Invite users by link..."), PURPLE_CALLBACK(create_chat_link), - NULL, NULL); + PurpleMenuAction* action = purple_menu_action_new (_("Invite users by link..."), + PURPLE_CALLBACK(export_chat_link_checked_gw), NULL, NULL); menu = g_list_append (menu, (gpointer)action); } + if (PURPLE_BLIST_NODE_IS_CHAT(node)) { + // Delete self from chat - PurpleMenuAction* action = purple_menu_action_new (_("Delete and exit..."), PURPLE_CALLBACK(leave_and_delete_chat), + PurpleMenuAction* action = purple_menu_action_new (_("Delete and exit..."), PURPLE_CALLBACK(leave_and_delete_chat_gw), NULL, NULL); menu = g_list_append (menu, (gpointer)action); } diff --git a/tgp-chat.c b/tgp-chat.c index 5651311..49361c0 100644 --- a/tgp-chat.c +++ b/tgp-chat.c @@ -41,6 +41,17 @@ void p2tgl_chat_update (struct tgl_state *TLS, PurpleChat *chat, tgl_peer_id_t i g_hash_table_replace (ht, g_strdup ("subject"), g_strdup (subject)); } +int tgp_chat_has_id (PurpleChat *C) { + const char *id = g_hash_table_lookup (purple_chat_get_components (C), "id"); + return id && *id; +} + +tgl_peer_id_t tgp_chat_get_id (PurpleChat *C) { + const char *id = g_hash_table_lookup (purple_chat_get_components (C), "id"); + assert (id && *id); + return TGL_MK_CHAT(atoi (id)); +} + void tgp_chat_on_loaded_chat_full (struct tgl_state *TLS, struct tgl_chat *C) { PurpleChat *PC = tgp_blist_chat_find (TLS, C->id); if (!PC) { diff --git a/tgp-chat.h b/tgp-chat.h index 917c990..75593a9 100644 --- a/tgp-chat.h +++ b/tgp-chat.h @@ -25,6 +25,9 @@ PurpleChat *p2tgl_chat_new (struct tgl_state *TLS, struct tgl_chat *chat); +tgl_peer_id_t tgp_chat_get_id (PurpleChat *C); +int tgp_chat_has_id (PurpleChat *C); + void tgp_chat_on_loaded_chat_full (struct tgl_state *TLS, struct tgl_chat *C); PurpleConversation *tgp_chat_show (struct tgl_state *TLS, struct tgl_chat *C); void tgp_chat_users_update (struct tgl_state *TLS, struct tgl_chat *C); From 97e295dddea94363968737bd95429e8bef9f66c5 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Thu, 10 Dec 2015 11:56:48 +0100 Subject: [PATCH 03/12] Fix format warning --- tgp-ft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgp-ft.c b/tgp-ft.c index 53c0693..7f3cfad 100644 --- a/tgp-ft.c +++ b/tgp-ft.c @@ -55,7 +55,7 @@ static char *tgp_strdup_determine_filename (const char *mime, const char *captio type = "bin"; } } - return g_strdup_printf ("%" G_GINT64_MODIFIER "d.%s", ABS(hash), type); + return g_strdup_printf ("%" G_GINT64_MODIFIER "d.%s", (gint64) ABS(hash), type); } static void tgprpl_xfer_recv_on_finished (struct tgl_state *TLS, void *_data, int success, const char *filename) { From 261a1e5f5470236ff0e24e2ece871b332a9ceaca Mon Sep 17 00:00:00 2001 From: tuxmaster Date: Thu, 10 Dec 2015 12:28:11 +0100 Subject: [PATCH 04/12] Prepare rpm for 1.2.3 --- rpm/purple-telegram.spec | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rpm/purple-telegram.spec b/rpm/purple-telegram.spec index 8435853..99a24d6 100644 --- a/rpm/purple-telegram.spec +++ b/rpm/purple-telegram.spec @@ -1,13 +1,13 @@ Name: purple-telegram -Version: 1.2.2 -Release: 2%{?dist} +Version: 1.2.3 +Release: 1%{?dist} Summary: Adds support for Libpurple based messengers Group: Applications/Internet License: GPLv2+ URL: https://github.com/majn/telegram-purple Source0: https://codeload.github.com/majn/telegram-purple/tar.gz/v%{version}.tar.gz -BuildRequires: gettext, libgcrypt-devel, pkgconfig(zlib), pkgconfig(purple), pkgconfig(libwebp) +BuildRequires: gettext, libgcrypt-devel >= 1.6, pkgconfig(zlib), pkgconfig(purple), pkgconfig(libwebp) %description Adds support for Telegram to Pidgin, Adium, Finch @@ -34,11 +34,17 @@ chmod 755 %{buildroot}/%{_libdir}/purple-2/telegram-purple.so %{_datadir}/pixmaps/pidgin/protocols/48/telegram.png %changelog +* Thu Dec 10 2015 tuxmaster 1.2.3-1 +- build for 1.2.3 + +* Wed Nov 18 2015 tuxmaster 1.2.2-3 +- Add required version for libgcrypt. + * Wed Oct 14 2015 tuxmaster 1.2.2-2 - Use the better pkconfig for build requires. - Add translations. - Switch to libgcrypt from openssl. -* Thu Okt 07 2015 mjentsch 1.2.2-1 +* Wed Oct 07 2015 mjentsch 1.2.2-1 - update version to 1.2.2 From ce442eef22256d5015fc4c4c87a9a38880dd3beb Mon Sep 17 00:00:00 2001 From: mjentsch Date: Fri, 11 Dec 2015 00:43:28 +0100 Subject: [PATCH 05/12] Fix including libgcrypt in Adium bundle --- telegram-adium/TelegramJoinChatView.xib | 5 +- .../telegram-adium.xcodeproj/project.pbxproj | 91 ++++++++----------- 2 files changed, 43 insertions(+), 53 deletions(-) diff --git a/telegram-adium/TelegramJoinChatView.xib b/telegram-adium/TelegramJoinChatView.xib index f12c6cd..c328f33 100644 --- a/telegram-adium/TelegramJoinChatView.xib +++ b/telegram-adium/TelegramJoinChatView.xib @@ -1,7 +1,8 @@ - + - + + diff --git a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj index eb39a2f..b2610eb 100644 --- a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj +++ b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj @@ -7,9 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 33070C10341336CD4EC97534 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 33070D636377BD8BA47CBF63 /* InfoPlist.strings */; }; C40564871A7937C600A293B9 /* AdiumLibpurple.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40564861A7937C600A293B9 /* AdiumLibpurple.framework */; }; C410948A19BB2D7D0083BF3F /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C410948919BB2D7D0083BF3F /* CoreFoundation.framework */; }; - C410949019BB2D7D0083BF3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C410948E19BB2D7D0083BF3F /* InfoPlist.strings */; }; C410949B19BB337A0083BF3F /* TelegramPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = C410949A19BB337A0083BF3F /* TelegramPlugin.m */; }; C41D58411A16D88E00B22448 /* tgp-2prpl.c in Sources */ = {isa = PBXBuildFile; fileRef = C41D58401A16D88E00B22448 /* tgp-2prpl.c */; }; C425F9181A7069C300361AFC /* tgp-utils.c in Sources */ = {isa = PBXBuildFile; fileRef = C425F9161A7069C300361AFC /* tgp-utils.c */; }; @@ -24,6 +24,8 @@ C438CE351A12C07800E1DA0F /* tgp-net.c in Sources */ = {isa = PBXBuildFile; fileRef = C438CE301A12C07800E1DA0F /* tgp-net.c */; }; C438CE361A12C07800E1DA0F /* tgp-timers.c in Sources */ = {isa = PBXBuildFile; fileRef = C438CE311A12C07800E1DA0F /* tgp-timers.c */; }; C448ADA71AB0789A001B7ECD /* tgp-msg.c in Sources */ = {isa = PBXBuildFile; fileRef = C448ADA61AB0789A001B7ECD /* tgp-msg.c */; }; + C465FC211C0D0191001CCEE8 /* libgcrypt.20.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C465FC1B1C0CF43A001CCEE8 /* libgcrypt.20.dylib */; }; + C465FC231C0D01B5001CCEE8 /* libgcrypt.20.dylib in Resources */ = {isa = PBXBuildFile; fileRef = C465FC221C0D01B5001CCEE8 /* libgcrypt.20.dylib */; }; C466937819E703370036A108 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C466937719E703370036A108 /* AppKit.framework */; }; C479A8021BB69C2100C153DF /* tgp-request.c in Sources */ = {isa = PBXBuildFile; fileRef = C479A8001BB69C2100C153DF /* tgp-request.c */; settings = {ASSET_TAGS = (); }; }; C4877C1819BB37EA006FA91F /* TelegramService.m in Sources */ = {isa = PBXBuildFile; fileRef = C4877C1719BB37EA006FA91F /* TelegramService.m */; }; @@ -40,7 +42,6 @@ C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */; }; C4B57BF01B1598D4006997F4 /* libtgl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B57BEF1B1598D4006997F4 /* libtgl.a */; }; C4D12DF01BC534CF00C0F6E1 /* tgp-blist.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */; settings = {ASSET_TAGS = (); }; }; - C4D432D61BC2768C00561667 /* libgcrypt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C4D432D51BC2768C00561667 /* libgcrypt.dylib */; }; C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */ = {isa = PBXBuildFile; fileRef = C4D432D71BC2783C00561667 /* tg-server.tglpub */; }; C4D819061A5C862E0044CBA9 /* tgp-structs.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D819041A5C862E0044CBA9 /* tgp-structs.c */; }; C4E528111A8A907200C4B915 /* tgp-ft.c in Sources */ = {isa = PBXBuildFile; fileRef = C4E5280F1A8A907200C4B915 /* tgp-ft.c */; }; @@ -50,12 +51,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 33070918C1B3F67A227F6286 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 33070A9DBCF625AD9E07CE94 /* telegram-adium-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.info; path = "telegram-adium-Info.plist"; sourceTree = ""; }; + 33070CD59974365A33795EAF /* telegram-adium-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "telegram-adium-Prefix.pch"; sourceTree = ""; }; C40564861A7937C600A293B9 /* AdiumLibpurple.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdiumLibpurple.framework; path = Frameworks/Adium/AdiumLibpurple.framework; sourceTree = ""; }; C410948619BB2D7D0083BF3F /* telegram-adium.AdiumLibpurplePlugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "telegram-adium.AdiumLibpurplePlugin"; sourceTree = BUILT_PRODUCTS_DIR; }; C410948919BB2D7D0083BF3F /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; - C410948D19BB2D7D0083BF3F /* telegram-adium-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "telegram-adium-Info.plist"; sourceTree = ""; }; - C410948F19BB2D7D0083BF3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - C410949119BB2D7D0083BF3F /* telegram-adium-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "telegram-adium-Prefix.pch"; sourceTree = ""; }; C410949919BB337A0083BF3F /* TelegramPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelegramPlugin.h; sourceTree = ""; }; C410949A19BB337A0083BF3F /* TelegramPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TelegramPlugin.m; sourceTree = ""; }; C41D583F1A16D86A00B22448 /* tgp-2prpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tgp-2prpl.h"; path = "../tgp-2prpl.h"; sourceTree = ""; }; @@ -82,6 +83,8 @@ C438CE3C1A12C15100E1DA0F /* tg-server.pub */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "tg-server.pub"; path = "../tg-server.pub"; sourceTree = ""; }; C448ADA61AB0789A001B7ECD /* tgp-msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-msg.c"; path = "../tgp-msg.c"; sourceTree = ""; }; C448ADA81AB078BB001B7ECD /* tgp-msg.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "tgp-msg.h"; path = "../tgp-msg.h"; sourceTree = ""; }; + C465FC1B1C0CF43A001CCEE8 /* libgcrypt.20.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgcrypt.20.dylib; path = Frameworks/Adium/libgcrypt.20.dylib; sourceTree = ""; }; + C465FC221C0D01B5001CCEE8 /* libgcrypt.20.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgcrypt.20.dylib; path = Frameworks/Adium/libgcrypt.20.dylib; sourceTree = ""; }; C466937719E703370036A108 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; C479A7FE1BB1C95300C153DF /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = Frameworks/libcrypto.a; sourceTree = ""; }; C479A8001BB69C2100C153DF /* tgp-request.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-request.c"; path = "../tgp-request.c"; sourceTree = ""; }; @@ -91,7 +94,6 @@ C4877C1C19BB676B006FA91F /* TelegramAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelegramAccount.h; sourceTree = ""; }; C4877C1D19BB676B006FA91F /* TelegramAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TelegramAccount.m; sourceTree = ""; }; C487A1781A792CD80044F135 /* libssl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libssl.dylib; path = usr/lib/libssl.dylib; sourceTree = SDKROOT; }; - C487A17A1A792CF00044F135 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = usr/lib/libcrypto.dylib; sourceTree = SDKROOT; }; C487A1891A792E9B0044F135 /* Adium.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Adium.framework; path = Frameworks/Adium/Adium.framework; sourceTree = ""; }; C487A18B1A792E9B0044F135 /* AIUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AIUtilities.framework; path = Frameworks/Adium/AIUtilities.framework; sourceTree = ""; }; C487A18F1A792EA50044F135 /* libglib.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libglib.framework; path = Frameworks/Adium/libglib.framework; sourceTree = ""; }; @@ -112,11 +114,7 @@ C4B57BEF1B1598D4006997F4 /* libtgl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtgl.a; path = ../libs/libtgl.a; sourceTree = ""; }; C4D12DEE1BC534CF00C0F6E1 /* tgp-blist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tgp-blist.h"; path = "../tgp-blist.h"; sourceTree = ""; }; C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-blist.c"; path = "../tgp-blist.c"; sourceTree = ""; }; - C4D432D31BC2766E00561667 /* libgcrypt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgcrypt.dylib; path = ../../../../../usr/local/Cellar/libgcrypt/1.6.4/lib/libgcrypt.dylib; sourceTree = ""; }; - C4D432D51BC2768C00561667 /* libgcrypt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgcrypt.dylib; path = ../../../../../usr/local/lib/libgcrypt.dylib; sourceTree = ""; }; C4D432D71BC2783C00561667 /* tg-server.tglpub */ = {isa = PBXFileReference; lastKnownFileType = file; name = "tg-server.tglpub"; path = "../tg-server.tglpub"; sourceTree = ""; }; - C4D819011A5C85FE0044CBA9 /* lodepng.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lodepng.c; sourceTree = ""; }; - C4D819021A5C85FE0044CBA9 /* lodepng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lodepng.h; sourceTree = ""; }; C4D819041A5C862E0044CBA9 /* tgp-structs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-structs.c"; path = "../tgp-structs.c"; sourceTree = ""; }; C4D819051A5C862E0044CBA9 /* tgp-structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tgp-structs.h"; path = "../tgp-structs.h"; sourceTree = ""; }; C4E5280F1A8A907200C4B915 /* tgp-ft.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-ft.c"; path = "../tgp-ft.c"; sourceTree = ""; }; @@ -131,16 +129,16 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C465FC211C0D0191001CCEE8 /* libgcrypt.20.dylib in Frameworks */, + C49A915819BBC5C5001B3DC0 /* libz.dylib in Frameworks */, + C466937819E703370036A108 /* AppKit.framework in Frameworks */, C4B57BF01B1598D4006997F4 /* libtgl.a in Frameworks */, C4EA965A1B204C67006CBAD0 /* libwebp.a in Frameworks */, - C49A915819BBC5C5001B3DC0 /* libz.dylib in Frameworks */, - C4D432D61BC2768C00561667 /* libgcrypt.dylib in Frameworks */, C40564871A7937C600A293B9 /* AdiumLibpurple.framework in Frameworks */, C487A18C1A792E9B0044F135 /* Adium.framework in Frameworks */, C487A18E1A792E9B0044F135 /* AIUtilities.framework in Frameworks */, C487A1911A792EA50044F135 /* libglib.framework in Frameworks */, C487A1921A792EA50044F135 /* libpurple.framework in Frameworks */, - C466937819E703370036A108 /* AppKit.framework in Frameworks */, C410948A19BB2D7D0083BF3F /* CoreFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -148,6 +146,24 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 330704C72BA03B848124B6F7 /* telegram-adium */ = { + isa = PBXGroup; + children = ( + 3307063DD9566C77D08006F9 /* Supporting Files */, + ); + path = "telegram-adium"; + sourceTree = ""; + }; + 3307063DD9566C77D08006F9 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 33070A9DBCF625AD9E07CE94 /* telegram-adium-Info.plist */, + 33070D636377BD8BA47CBF63 /* InfoPlist.strings */, + 33070CD59974365A33795EAF /* telegram-adium-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; C410947D19BB2D7D0083BF3F = { isa = PBXGroup; children = ( @@ -170,11 +186,10 @@ C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */, C4B4BE301AB393800064AC17 /* TelegramAccountViewController.h */, C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */, + C465FC221C0D01B5001CCEE8 /* libgcrypt.20.dylib */, C4BF990319BB8B200038D507 /* telegram-purple */, - C410948B19BB2D7D0083BF3F /* telegram-adium */, C410948819BB2D7D0083BF3F /* Frameworks */, C410948719BB2D7D0083BF3F /* Products */, - C4D819001A5C85FE0044CBA9 /* lodepng */, C4877C2919BB6D22006FA91F /* Resources */, ); sourceTree = ""; @@ -190,8 +205,7 @@ C410948819BB2D7D0083BF3F /* Frameworks */ = { isa = PBXGroup; children = ( - C4D432D51BC2768C00561667 /* libgcrypt.dylib */, - C4D432D31BC2766E00561667 /* libgcrypt.dylib */, + C465FC1B1C0CF43A001CCEE8 /* libgcrypt.20.dylib */, C479A7FE1BB1C95300C153DF /* libcrypto.a */, C4B57BEF1B1598D4006997F4 /* libtgl.a */, C4EA96591B204C67006CBAD0 /* libwebp.a */, @@ -201,7 +215,6 @@ C487A1901A792EA50044F135 /* libpurple.framework */, C487A1891A792E9B0044F135 /* Adium.framework */, C487A18B1A792E9B0044F135 /* AIUtilities.framework */, - C487A17A1A792CF00044F135 /* libcrypto.dylib */, C49A915719BBC5C5001B3DC0 /* libz.dylib */, C487A1781A792CD80044F135 /* libssl.dylib */, C438CE2B1A12BF3400E1DA0F /* libtgl.a */, @@ -211,24 +224,6 @@ name = Frameworks; sourceTree = ""; }; - C410948B19BB2D7D0083BF3F /* telegram-adium */ = { - isa = PBXGroup; - children = ( - C410948C19BB2D7D0083BF3F /* Supporting Files */, - ); - path = "telegram-adium"; - sourceTree = ""; - }; - C410948C19BB2D7D0083BF3F /* Supporting Files */ = { - isa = PBXGroup; - children = ( - C410948D19BB2D7D0083BF3F /* telegram-adium-Info.plist */, - C410948E19BB2D7D0083BF3F /* InfoPlist.strings */, - C410949119BB2D7D0083BF3F /* telegram-adium-Prefix.pch */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; C4877C2919BB6D22006FA91F /* Resources */ = { isa = PBXGroup; children = ( @@ -271,20 +266,11 @@ C479A8011BB69C2100C153DF /* tgp-request.h */, C4D12DEE1BC534CF00C0F6E1 /* tgp-blist.h */, C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */, + 330704C72BA03B848124B6F7 /* telegram-adium */, ); name = "telegram-purple"; sourceTree = ""; }; - C4D819001A5C85FE0044CBA9 /* lodepng */ = { - isa = PBXGroup; - children = ( - C4D819011A5C85FE0044CBA9 /* lodepng.c */, - C4D819021A5C85FE0044CBA9 /* lodepng.h */, - ); - name = lodepng; - path = ../lodepng; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -336,6 +322,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C465FC231C0D01B5001CCEE8 /* libgcrypt.20.dylib in Resources */, C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */, C438CE271A12BEAF00E1DA0F /* telegram.png in Resources */, C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */, @@ -343,8 +330,8 @@ C438CE281A12BEAF00E1DA0F /* telegram16.png in Resources */, C438CE291A12BEAF00E1DA0F /* telegram22.png in Resources */, C438CE2A1A12BEAF00E1DA0F /* telegram48.png in Resources */, - C410949019BB2D7D0083BF3F /* InfoPlist.strings in Resources */, C4B4BE331AB4536F0064AC17 /* PurpleDefaultsTelegram.plist in Resources */, + 33070C10341336CD4EC97534 /* InfoPlist.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -381,10 +368,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - C410948E19BB2D7D0083BF3F /* InfoPlist.strings */ = { + 33070D636377BD8BA47CBF63 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( - C410948F19BB2D7D0083BF3F /* en */, + 33070918C1B3F67A227F6286 /* en */, ); name = InfoPlist.strings; sourceTree = ""; @@ -427,7 +414,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.11; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx10.11; }; @@ -466,7 +453,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.11; SDKROOT = macosx10.11; }; name = Release; @@ -503,6 +490,7 @@ "$(PROJECT_DIR)", "$(PROJECT_DIR)/Frameworks", /usr/local/Cellar/libgcrypt/1.6.4/lib, + "$(PROJECT_DIR)/Frameworks/Adium", ); OTHER_CFLAGS = "-DPURPLE_STATIC_PRPL"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -543,6 +531,7 @@ /usr/local/lib, "$(PROJECT_DIR)/Frameworks", /usr/local/Cellar/libgcrypt/1.6.4/lib, + "$(PROJECT_DIR)/Frameworks/Adium", ); OTHER_CFLAGS = "-DPURPLE_STATIC_PRPL"; PRODUCT_NAME = "$(TARGET_NAME)"; From 9f34c13384e1bc1e140a1a5e5755d20c23e76e0c Mon Sep 17 00:00:00 2001 From: mjentsch Date: Sat, 12 Dec 2015 00:49:00 +0100 Subject: [PATCH 06/12] Fix reconnect failing Fail complete connection when a reconnect to the main data center fails. --- tgp-net.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tgp-net.c b/tgp-net.c index 6f554d4..4d0e16f 100644 --- a/tgp-net.c +++ b/tgp-net.c @@ -269,8 +269,14 @@ static void net_on_connected (gpointer arg, gint fd, const gchar *error_message) static void net_on_connected_assert_success (gpointer arg, gint fd, const gchar *error_message) { struct connection *c = arg; - struct tgl_state *TLS = c->TLS; + + if (c->fail_ev >= 0) { + purple_timeout_remove (c->fail_ev); + c->fail_ev = -1; + } + if (fd == -1) { + struct tgl_state *TLS = c->TLS; info ("Connection to main data center (%d) %s:%d not possible\n", c->dc->id, c->ip, c->port); purple_connection_error_reason (tls_get_conn (TLS), PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Cannot connect to main server")); return; @@ -302,7 +308,7 @@ struct connection *tgln_create_connection (struct tgl_state *TLS, const char *ho c->methods = methods; c->prpl_data = purple_proxy_connect (tls_get_conn (TLS), tls_get_pa (TLS), host, port, - TLS->dc_working_num == dc->id ? net_on_connected_assert_success : net_on_connected, c); + TLS->dc_working_num == dc->id ? net_on_connected_assert_success : net_on_connected, c); start_fail_timer (c); @@ -317,7 +323,8 @@ static void restart_connection (struct connection *c) { return; } purple_proxy_connect_cancel (c->prpl_data); - c->prpl_data = purple_proxy_connect (tls_get_conn (c->TLS), tls_get_pa (c->TLS), c->ip, c->port, net_on_connected, c); + c->prpl_data = purple_proxy_connect (tls_get_conn (c->TLS), tls_get_pa (c->TLS), c->ip, c->port, + c->TLS->dc_working_num == c->dc->id ? net_on_connected_assert_success : net_on_connected, c); } static void fail_connection (struct connection *c) { @@ -358,7 +365,6 @@ static void fail_connection (struct connection *c) { _("Lost connection to the server...")); } -//extern FILE *log_net_f; static void try_write (struct connection *c) { // debug ("try write: fd = %d\n", c->fd); int x = 0; From f681aa21e29161f3a657f1ae93367a804ad94c4e Mon Sep 17 00:00:00 2001 From: mjentsch Date: Sat, 12 Dec 2015 19:40:24 +0100 Subject: [PATCH 07/12] Fix adium bundle not loading --- README.md | 26 +++++++++++++------ .../telegram-adium.xcodeproj/project.pbxproj | 13 ++++++---- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 17ff85b..400fe4a 100644 --- a/README.md +++ b/README.md @@ -152,19 +152,29 @@ Compiling with XCode is a little bit problematic, since it requires you to compi 1. Get the Adium source, compile it with XCode and copy the build output into telegram-adium/Frameworks/Adium. It should contain at least Adium.framework, AdiumLibpurple.framework and AIUitilies.framework 2. Open the Adium source code, go to ./Frameworks and copy libglib.framework and libpurple.framework into telegram-adium/Frameworks/Adium 3. Build the tgl submodule and delete libtgl.so from libs/ (it should only contain libtgl.a) -4. Install libwebp with homebrew and copy it into your project: +4. Install libwebp, libgcrypt and gnupg with homebrew: - brew install webp - cp /usr/local/Cellar/webp/0.4.3/lib/libwebp.a ./telegram-adium/Frameworks/ + brew install webp + brew install libgcrypt libgpg-error -5. Install libgcrypt with homebrew and make sure that libgcrypt.dylib is present in /usr/local/lib +5. If you already downloaded libwebp/libgcrypt in previous builds make sure that the binaries are up-to-date - brew install libgcrypt + brew update + brew upgrade webp libgcrypt -6. If you already downloaded libwebp/libgcrypt in previous builds make sure that the binaries are up-to-date +6. Installwith homebrew and move it into the appropriate directory so that XCode can find them. Note that the versions might differ, use the one that is - brew update - brew upgrade webp libgcrypt + mkdir -p ./telegram-adium/Frameworks/Adium + cp /usr/local/Cellar/webp/0.4.3/lib/libwebp.a ./telegram-adium/Frameworks + cp /usr/local/Cellar/libgcrypt/1.6.4/lib/libgcrypt.20.dylib ./telegram-adium/Frameworks/Adium + cp /usr/local/Cellar/libgpg-error/1.20_1/lib/libgpg-error.0.dylib ./telegram-adium/Frameworks/Adium + +7. Update the paths in the dylibs, to assure that the resulting binary will load them form within the bundle. + + cd ./telegram-adium/Frameworks/Adium + install_name_tool -id "@loader_path/../Resources/libgcrypt.20.dylib" ./libgcrypt.20.dylib + install_name_tool -id "@loader_path/../Resources/libgpg-error.0.dylib" ./libgpg-error.0.dylib + install_name_tool -change "/usr/local/lib/libgpg-error.0.dylib" "@loader_path/../Resources/libgpg-error.0.dylib" ./libgcrypt.20.dylib 7. Build the XCode-Project and execute the created bundle diff --git a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj index b2610eb..dbde3e2 100644 --- a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj +++ b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj @@ -27,7 +27,7 @@ C465FC211C0D0191001CCEE8 /* libgcrypt.20.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C465FC1B1C0CF43A001CCEE8 /* libgcrypt.20.dylib */; }; C465FC231C0D01B5001CCEE8 /* libgcrypt.20.dylib in Resources */ = {isa = PBXBuildFile; fileRef = C465FC221C0D01B5001CCEE8 /* libgcrypt.20.dylib */; }; C466937819E703370036A108 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C466937719E703370036A108 /* AppKit.framework */; }; - C479A8021BB69C2100C153DF /* tgp-request.c in Sources */ = {isa = PBXBuildFile; fileRef = C479A8001BB69C2100C153DF /* tgp-request.c */; settings = {ASSET_TAGS = (); }; }; + C479A8021BB69C2100C153DF /* tgp-request.c in Sources */ = {isa = PBXBuildFile; fileRef = C479A8001BB69C2100C153DF /* tgp-request.c */; }; C4877C1819BB37EA006FA91F /* TelegramService.m in Sources */ = {isa = PBXBuildFile; fileRef = C4877C1719BB37EA006FA91F /* TelegramService.m */; }; C4877C1E19BB676B006FA91F /* TelegramAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = C4877C1D19BB676B006FA91F /* TelegramAccount.m */; }; C487A18C1A792E9B0044F135 /* Adium.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C487A1891A792E9B0044F135 /* Adium.framework */; }; @@ -41,9 +41,11 @@ C4B4BE371AB5FB5C0064AC17 /* TelegramJoinChatViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4B4BE351AB5FB5C0064AC17 /* TelegramJoinChatViewController.m */; }; C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */; }; C4B57BF01B1598D4006997F4 /* libtgl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B57BEF1B1598D4006997F4 /* libtgl.a */; }; - C4D12DF01BC534CF00C0F6E1 /* tgp-blist.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */; settings = {ASSET_TAGS = (); }; }; + C4D12DF01BC534CF00C0F6E1 /* tgp-blist.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D12DEF1BC534CF00C0F6E1 /* tgp-blist.c */; }; C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */ = {isa = PBXBuildFile; fileRef = C4D432D71BC2783C00561667 /* tg-server.tglpub */; }; C4D819061A5C862E0044CBA9 /* tgp-structs.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D819041A5C862E0044CBA9 /* tgp-structs.c */; }; + C4D9185B1C1C6B3900AECCA2 /* libgpg-error.0.dylib in Resources */ = {isa = PBXBuildFile; fileRef = C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */; }; + C4D9185C1C1C6B9C00AECCA2 /* libgpg-error.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */; }; C4E528111A8A907200C4B915 /* tgp-ft.c in Sources */ = {isa = PBXBuildFile; fileRef = C4E5280F1A8A907200C4B915 /* tgp-ft.c */; }; C4EA965A1B204C67006CBAD0 /* libwebp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C4EA96591B204C67006CBAD0 /* libwebp.a */; }; C4FFD0DC1B5FC48B00939D8A /* TelegramAutocompletionDelegate.h in Sources */ = {isa = PBXBuildFile; fileRef = C4FFD0DB1B5FC48B00939D8A /* TelegramAutocompletionDelegate.h */; }; @@ -117,6 +119,7 @@ C4D432D71BC2783C00561667 /* tg-server.tglpub */ = {isa = PBXFileReference; lastKnownFileType = file; name = "tg-server.tglpub"; path = "../tg-server.tglpub"; sourceTree = ""; }; C4D819041A5C862E0044CBA9 /* tgp-structs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-structs.c"; path = "../tgp-structs.c"; sourceTree = ""; }; C4D819051A5C862E0044CBA9 /* tgp-structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tgp-structs.h"; path = "../tgp-structs.h"; sourceTree = ""; }; + C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libgpg-error.0.dylib"; path = "Frameworks/Adium/libgpg-error.0.dylib"; sourceTree = ""; }; C4E5280F1A8A907200C4B915 /* tgp-ft.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-ft.c"; path = "../tgp-ft.c"; sourceTree = ""; }; C4E528101A8A907200C4B915 /* tgp-ft.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tgp-ft.h"; path = "../tgp-ft.h"; sourceTree = ""; }; C4EA96591B204C67006CBAD0 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwebp.a; path = Frameworks/libwebp.a; sourceTree = ""; }; @@ -129,6 +132,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C4D9185C1C1C6B9C00AECCA2 /* libgpg-error.0.dylib in Frameworks */, C465FC211C0D0191001CCEE8 /* libgcrypt.20.dylib in Frameworks */, C49A915819BBC5C5001B3DC0 /* libz.dylib in Frameworks */, C466937819E703370036A108 /* AppKit.framework in Frameworks */, @@ -187,6 +191,7 @@ C4B4BE301AB393800064AC17 /* TelegramAccountViewController.h */, C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */, C465FC221C0D01B5001CCEE8 /* libgcrypt.20.dylib */, + C4D9185A1C1C6B3900AECCA2 /* libgpg-error.0.dylib */, C4BF990319BB8B200038D507 /* telegram-purple */, C410948819BB2D7D0083BF3F /* Frameworks */, C410948719BB2D7D0083BF3F /* Products */, @@ -322,6 +327,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C4D9185B1C1C6B3900AECCA2 /* libgpg-error.0.dylib in Resources */, C465FC231C0D01B5001CCEE8 /* libgcrypt.20.dylib in Resources */, C4D432D81BC2783C00561667 /* tg-server.tglpub in Resources */, C438CE271A12BEAF00E1DA0F /* telegram.png in Resources */, @@ -489,7 +495,6 @@ "$(PROJECT_DIR)/../libs", "$(PROJECT_DIR)", "$(PROJECT_DIR)/Frameworks", - /usr/local/Cellar/libgcrypt/1.6.4/lib, "$(PROJECT_DIR)/Frameworks/Adium", ); OTHER_CFLAGS = "-DPURPLE_STATIC_PRPL"; @@ -528,9 +533,7 @@ LIBRARY_SEARCH_PATHS = ( "$(PROJECT_DIR)", "$(PROJECT_DIR)/../libs", - /usr/local/lib, "$(PROJECT_DIR)/Frameworks", - /usr/local/Cellar/libgcrypt/1.6.4/lib, "$(PROJECT_DIR)/Frameworks/Adium", ); OTHER_CFLAGS = "-DPURPLE_STATIC_PRPL"; From de17ccb982bf5cab38ca1b15ccdc7071a29b5ce5 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Sun, 13 Dec 2015 01:03:40 +0100 Subject: [PATCH 08/12] Fix trailing whitespace on users without a last name --- tgp-blist.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tgp-blist.c b/tgp-blist.c index 62562e0..e09f658 100644 --- a/tgp-blist.c +++ b/tgp-blist.c @@ -146,6 +146,10 @@ char *tgp_blist_create_print_name (struct tgl_state *TLS, tgl_peer_id_t id, cons // libtgl passes 0 for all unused strings, therefore the last passed string will always be followed // by a NULL-termination as expected gchar *name = g_strjoin (" ", a1, a2, a3, a4, NULL); + + // When the user doesn't provide some input (like last name) ugly trailing or leading + // whitespaces may occur due to empty strings in the join operator + name = g_strstrip(name); /* Assure that all print_names are unique by checking the following conditions: 1. No other peer with that print_name should exists. If those names are not unique it will not be possible From ccf28caa8cd573f0fa787f49b9d7c07022ce2770 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Wed, 16 Dec 2015 22:37:53 +0100 Subject: [PATCH 09/12] Adium: Fix adding contacts with non-ascii names to buddy list --- telegram-adium/TelegramAccount.m | 13 +++++++++++++ telegram-adium/TelegramJoinChatView.xib | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/telegram-adium/TelegramAccount.m b/telegram-adium/TelegramAccount.m index 60ba0c6..21fa14a 100644 --- a/telegram-adium/TelegramAccount.m +++ b/telegram-adium/TelegramAccount.m @@ -103,6 +103,19 @@ intValue]); } +/**! + * @brief Returns the name passed to new_purple_buddy, when adding a new contact + * + * This function is called when creating a new contact from the purple GUI. + */ +- (NSString *)_UIDForAddingObject:(AIListContact *)object +{ + // The contact UID in Adium was encoded with decomposoed unicode codepoints (see http://unicode.org/reports/tr15/). + // Since libtgl and libpurple (and apparently the rest of the world) encode with composed code points, the name + // needs to be converted to the composed format to prevent inequality in binary string comparison. + return [object.UID precomposedStringWithCanonicalMapping]; +} + #pragma mark Action Menu -(NSMenu*)actionMenuForChat:(AIChat*)chat { diff --git a/telegram-adium/TelegramJoinChatView.xib b/telegram-adium/TelegramJoinChatView.xib index c328f33..5790daa 100644 --- a/telegram-adium/TelegramJoinChatView.xib +++ b/telegram-adium/TelegramJoinChatView.xib @@ -1,5 +1,5 @@ - + From b85fc85322113c68b5b8d5d26eef241951af679e Mon Sep 17 00:00:00 2001 From: mjentsch Date: Fri, 18 Dec 2015 22:59:51 +0100 Subject: [PATCH 10/12] Fix auto-joining chats --- telegram-purple.c | 18 ++++++++++++++++-- tgp-chat.c | 27 +++++++++++++++++++++++++++ tgp-chat.h | 1 + tgp-structs.c | 1 + tgp-structs.h | 2 ++ tgp-utils.c | 6 ++++-- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/telegram-purple.c b/telegram-purple.c index db5ee12..5e762a4 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -251,6 +251,11 @@ static void on_userpic_loaded (struct tgl_state *TLS, void *extra, int success, static void on_get_dialog_list_done (struct tgl_state *TLS, void *callback_extra, int success, int size, tgl_peer_id_t peers[], tgl_message_id_t *last_msg_id[], int unread_count[]) { info ("Fetched dialogue list of size: %d", size); + if (tgp_error_if_false (TLS, success, "Fetching dialogue list failed", TLS->error)) { + return; + } + + // add all peers in the dialogue list to the buddy list int i; for (i = size - 1; i >= 0; i--) { tgl_peer_t *UC = tgl_peer_get (TLS, peers[i]); @@ -288,6 +293,10 @@ static void on_get_dialog_list_done (struct tgl_state *TLS, void *callback_extra } } } + + // now that the dialogue list is loaded, handle all pending chat joins + tls_get_data (TLS)->dialogues_ready = TRUE; + tgp_chat_join_all_pending (TLS); } void on_user_get_info (struct tgl_state *TLS, void *info_data, int success, struct tgl_user *U) { @@ -318,7 +327,6 @@ static const char *tgprpl_list_icon (PurpleAccount *acct, PurpleBuddy *buddy) { } static void tgprpl_tooltip_text (PurpleBuddy *buddy, PurpleNotifyUserInfo *info, gboolean full) { - // buddy in old format that didn't migrate if (! tgp_blist_buddy_has_id (buddy)) { return; @@ -497,7 +505,13 @@ static void update_on_logged_in (struct tgl_state *TLS) { static void update_on_ready (struct tgl_state *TLS) { info ("update_on_ready(): The account is done fetching new history"); - purple_connection_set_display_name (tls_get_conn (TLS), purple_account_get_username (tls_get_pa (TLS))); + + tgl_peer_t *P = tgl_peer_get (TLS, TLS->our_id); + g_warn_if_fail(P); + if (P) { + purple_connection_set_display_name (tls_get_conn (TLS), P->print_name); + } + tgl_do_get_dialog_list (TLS, 200, 0, on_get_dialog_list_done, NULL); tgl_do_update_contact_list (TLS, 0, 0); } diff --git a/tgp-chat.c b/tgp-chat.c index 49361c0..fa14103 100644 --- a/tgp-chat.c +++ b/tgp-chat.c @@ -156,6 +156,19 @@ GHashTable *tgprpl_chat_info_defaults (PurpleConnection *gc, const char *chat_na void tgprpl_chat_join (PurpleConnection *gc, GHashTable *data) { debug ("tgprpl_chat_join()"); + g_return_if_fail(data); + + // auto joins will cause chat joins at a time when the dialogue list is not ready, remember + // those chats and join them once the dialogue list is fetched + if (! gc_get_data (gc)->dialogues_ready) { + g_return_if_fail (data); + const char *id = g_hash_table_lookup (data, "id"); + if (id) { + debug ("attempting to join chat %s while not ready, queue up for later", id); + gc_get_data (gc)->pending_joins = g_list_append (gc_get_data (gc)->pending_joins, g_strdup (id)); + } + return; + } // join existing chat by id when the user clicks on a chat in the buddy list void *value = g_hash_table_lookup (data, "id"); @@ -253,3 +266,17 @@ void tgprpl_roomlist_cancel (PurpleRoomlist *list) { purple_roomlist_unref (list); } } + +void tgp_chat_join_all_pending (struct tgl_state *TLS) { + GList *pending; + for (pending = tls_get_data (TLS)->pending_joins; pending != NULL; pending = g_list_next(pending)) { + GHashTable *data = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (data, "id", pending->data); + tgprpl_chat_join (tls_get_conn (TLS), data); + g_hash_table_destroy (data); + } + if (tls_get_data (TLS)->pending_joins) { + g_list_free (tls_get_data (TLS)->pending_joins); + tls_get_data (TLS)->pending_joins = NULL; + } +} diff --git a/tgp-chat.h b/tgp-chat.h index 75593a9..4171189 100644 --- a/tgp-chat.h +++ b/tgp-chat.h @@ -38,4 +38,5 @@ GList *tgprpl_chat_join_info (PurpleConnection *gc); PurpleRoomlist *tgprpl_roomlist_get_list (PurpleConnection *gc); void tgprpl_roomlist_cancel (PurpleRoomlist *list); GHashTable *tgprpl_chat_info_defaults (PurpleConnection *gc, const char *chat_name); +void tgp_chat_join_all_pending (struct tgl_state *TLS); #endif diff --git a/tgp-structs.c b/tgp-structs.c index 15c8eeb..9a69b87 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -114,6 +114,7 @@ void *connection_data_free (connection_data *conn) { tgp_g_queue_free_full (conn->new_messages, tgp_msg_loading_free); tgp_g_queue_free_full (conn->out_messages, tgp_msg_sending_free); tgp_g_list_free_full (conn->used_images, used_image_free); + tgp_g_list_free_full (conn->pending_joins, g_free); g_hash_table_destroy (conn->pending_reads); g_hash_table_destroy (conn->pending_chat_info); g_hash_table_destroy (conn->id_to_purple_name); diff --git a/tgp-structs.h b/tgp-structs.h index 7ce0a7c..c90d991 100644 --- a/tgp-structs.h +++ b/tgp-structs.h @@ -45,6 +45,8 @@ typedef struct { PurpleRoomlist *roomlist; GHashTable *pending_chat_info; GHashTable *id_to_purple_name; + GList *pending_joins; + int dialogues_ready; } connection_data; typedef struct { diff --git a/tgp-utils.c b/tgp-utils.c index 8d332a1..6f4dcfe 100644 --- a/tgp-utils.c +++ b/tgp-utils.c @@ -93,8 +93,10 @@ void tgp_g_queue_free_full (GQueue *queue, GDestroyNotify free_func) { } void tgp_g_list_free_full (GList *list, GDestroyNotify free_func) { - g_list_foreach (list, (GFunc)free_func, NULL); - g_list_free (list); + if (list) { + g_list_foreach (list, (GFunc)free_func, NULL); + g_list_free (list); + } } const char *tgp_mime_to_filetype (const char *mime) { From 91a4c3b8457ed40dbeefc5bfd44823a3cdf306a0 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Fri, 18 Dec 2015 23:03:31 +0100 Subject: [PATCH 11/12] Fix use after free --- tgp-structs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tgp-structs.c b/tgp-structs.c index 9a69b87..edcf01b 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -119,8 +119,9 @@ void *connection_data_free (connection_data *conn) { g_hash_table_destroy (conn->pending_chat_info); g_hash_table_destroy (conn->id_to_purple_name); tgprpl_xfer_free_all (conn); - tgl_free_all (conn->TLS); g_free (conn->TLS->base_path); + tgl_free_all (conn->TLS); + free (conn); return NULL; } From 88d39639295039349f1957ac3c859792509d2aca Mon Sep 17 00:00:00 2001 From: mjentsch Date: Fri, 18 Dec 2015 23:09:12 +0100 Subject: [PATCH 12/12] Fix compiler warning Remove unused function --- telegram-purple.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/telegram-purple.c b/telegram-purple.c index 5e762a4..31dd775 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -33,8 +33,6 @@ static void update_user_typing (struct tgl_state *TLS, struct tgl_user *U, enum static void update_marked_read (struct tgl_state *TLS, int num, struct tgl_message *list[]); static void update_on_logged_in (struct tgl_state *TLS); static void update_on_ready (struct tgl_state *TLS); -static char *format_print_name (struct tgl_state *TLS, tgl_peer_id_t id, const char *a1, const char *a2, const char *a3, - const char *a4); static void on_user_get_info (struct tgl_state *TLS, void *info_data, int success, struct tgl_user *U); const char *config_dir = "telegram-purple";