diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ebda4..d37e1db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,37 @@ Changelog --------- +##### 1.2.5 + +- Include libtgl fix to prevent crashes on certain channel messages +- Improve error handling to be more graceful + +##### 1.2.4 + +- Fix crash on unknown media type +- Fix crash on logout after cancelling a file transfer + +##### 1.2.3 + +- Build: Allow compilation on Windows #52 Thanks Eion! +- Build: Drop dependency on LodePNG, Thanks Ben! +- Build: Gettext is now optional + +- Fix issue that prevented to send messages to deleted users in certain cases (#174) +- Fix own user being added to the buddy list in certain cases +- Fix that read recipes of own messages are being displayed (#139) +- Fix encoding inconsistencies with Unicode characters (#177) +- Fix auto-joining for chats (#179) +- Fix client not reconnecting anymore under certain circumstances (#173) +- Fix crash on compat-verification (PullRequest #183) + +- Remove pointless "create chat" confirmation dialogue +- Improve logging messages +- Always send read recipes when the user is typing or sending a message +- Improve translation and user messages (#139) +- Use native password prompts (Adium) + + ##### 1.2.2 - fix some licensing issues by not depending on OpenSSL any longer (thanks Ben!) diff --git a/README.md b/README.md index 6e58930..99a5ec0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Telegram-Purple Unofficial (Beta) Telegram-purple is a Libpurple protocol plugin that adds support for the Telegram messenger. I keep getting many questions about this plugin in my E-mail, so I've created a -[telegram group chat](https://goo.gl/bhmM7N) for +[telegram group chat](https://goo.gl/a8SigQ) for telegram-purple related discussions or questions. Installation @@ -17,7 +17,7 @@ If your platform is not supported or you want to contribute by testing or develo #### OSX (Adium) -1. Download and execute the [Telegram-Adium bundle] (https://github.com/majn/telegram-purple/releases/download/v1.2.4/telegram-adium-1.2.4.AdiumLibpurplePlugin.zip) +1. Download and execute the [Telegram-Adium bundle] (https://github.com/majn/telegram-purple/releases/download/v1.2.5/telegram-adium-1.2.5.AdiumLibpurplePlugin.zip) 2. Restart Adium #### Windows @@ -217,32 +217,12 @@ and `.dsc` files, do this: Note that the parenthesis are important. -1.2.4 +1.2.5 ----- -- Fix crash on unknown media type -- Fix crash on logout after cancelling a file transfer - -1.2.3 ------ - -- Build: Allow compilation on Windows #52 Thanks Eion! -- Build: Drop dependency on LodePNG, Thanks Ben! -- Build: Gettext is now optional - -- Fix issue that prevented to send messages to deleted users in certain cases (#174) -- Fix own user being added to the buddy list in certain cases -- Fix that read recipes of own messages are being displayed (#139) -- Fix encoding inconsistencies with Unicode characters (#177) -- Fix auto-joining for chats (#179) -- Fix client not reconnecting anymore under certain circumstances (#173) -- Fix crash on compat-verification (PullRequest #183) - -- Remove pointless "create chat" confirmation dialogue -- Improve logging messages -- Always send read recipes when the user is typing or sending a message -- Improve translation and user messages (#139) -- Use native password prompts (Adium) +- Handle revoked sessions automatically +- Include libtgl fix to prevent crashes on certain channel messages +- Improve error handling Discussion / Help @@ -273,7 +253,7 @@ FAQ Telegram group chat for telegram-purple or libtgl related discussions or questions: - - https://goo.gl/bhmM7N + - https://goo.gl/a8SigQ Submitting Bug Reports diff --git a/configure b/configure index de8496c..f577d06 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for telegram-purple 1.2.4. +# Generated by GNU Autoconf 2.69 for telegram-purple 1.2.5. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='telegram-purple' PACKAGE_TARNAME='telegram-purple' -PACKAGE_VERSION='1.2.4' -PACKAGE_STRING='telegram-purple 1.2.4' +PACKAGE_VERSION='1.2.5' +PACKAGE_STRING='telegram-purple 1.2.5' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1249,7 +1249,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures telegram-purple 1.2.4 to adapt to many kinds of systems. +\`configure' configures telegram-purple 1.2.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1310,7 +1310,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of telegram-purple 1.2.4:";; + short | recursive ) echo "Configuration of telegram-purple 1.2.5:";; esac cat <<\_ACEOF @@ -1418,7 +1418,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -telegram-purple configure 1.2.4 +telegram-purple configure 1.2.5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1837,7 +1837,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by telegram-purple $as_me 1.2.4, which was +It was created by telegram-purple $as_me 1.2.5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -5098,7 +5098,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by telegram-purple $as_me 1.2.4, which was +This file was extended by telegram-purple $as_me 1.2.5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5160,7 +5160,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -telegram-purple config.status 1.2.4 +telegram-purple config.status 1.2.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 4bddbd4..8aaf7ff 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([telegram-purple], [1.2.4]) +AC_INIT([telegram-purple], [1.2.5]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) diff --git a/rpm/purple-telegram.spec b/rpm/purple-telegram.spec index cb0232c..fe93ff9 100644 --- a/rpm/purple-telegram.spec +++ b/rpm/purple-telegram.spec @@ -39,9 +39,18 @@ appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/appdata/telegram- %{_datadir}/pixmaps/pidgin/protocols/48/telegram.png %changelog -* Thu Dec 10 2015 tuxmaster 1.3.0 +* Thu Dec 10 2015 tuxmaster 1.3.0-1 - Build for 1.3.0 +* Sat Jan 23 mjentsch 1.2.5-1 +- build for 1.2.5 + +* Thu Dec 10 2015 tuxmaster 1.2.4-2 +- Fix build for appdata. + +* Thu Dec 10 2015 mjentsch 1.2.4-1 +- build for 1.2.4 + * Thu Dec 10 2015 tuxmaster 1.2.4-2 - Fix build for appdata. diff --git a/telegram-adium/telegram-adium/telegram-adium-Info.plist b/telegram-adium/telegram-adium/telegram-adium-Info.plist index f7f7cdc..eb2aa25 100644 --- a/telegram-adium/telegram-adium/telegram-adium-Info.plist +++ b/telegram-adium/telegram-adium/telegram-adium-Info.plist @@ -19,11 +19,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.2.4 + 1.2.5 CFBundleSignature AdIM CFBundleVersion - 1 + 1.2.5 CFPlugInDynamicRegisterFunction CFPlugInDynamicRegistration diff --git a/telegram-purple.c b/telegram-purple.c index d964b38..56c0d56 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -35,6 +35,7 @@ static void update_user_handler (struct tgl_state *TLS, struct tgl_user *U, unsi static void update_secret_chat_handler (struct tgl_state *TLS, struct tgl_secret_chat *C, unsigned flags); static void update_chat_handler (struct tgl_state *TLS, struct tgl_chat *C, unsigned flags); static void update_channel_handler (struct tgl_state *TLS, struct tgl_channel *C, unsigned flags); +static void update_on_failed_login (struct tgl_state *TLS); const char *config_dir = "telegram-purple"; const char *user_pk_filename = "server.tglpub"; @@ -59,8 +60,8 @@ struct tgl_update_callback tgp_callback = { .secret_chat_update = update_secret_chat_handler, .msg_receive = update_message_handler, .user_status_update = update_user_status_handler, - .create_print_name = tgp_blist_create_print_name - // FIXME: on_failed_login ? + .create_print_name = tgp_blist_create_print_name, + .on_failed_login = update_on_failed_login }; static void _update_buddy (struct tgl_state *TLS, tgl_peer_t *user, unsigned flags) { @@ -528,6 +529,18 @@ static void update_on_ready (struct tgl_state *TLS) { tgl_do_update_contact_list (TLS, 0, 0); } +static void update_on_failed_login (struct tgl_state *TLS) { + info ("update_on_failed_login(): Login to telegram failed."); + + // 401: SESSION_REVOKED is called when the session is cancelled during runtime + // 401: AUTH_KEY_UNREGISTERED is called when logging into a revoked session + if (strstr (TLS->error, "SESSION_REVOKED") || + strstr (TLS->error, "AUTH_KEY_UNREGISTERED")) { + purple_account_set_bool (tls_get_pa (TLS), TGP_KEY_RESET_AUTH, TRUE); + } + purple_connection_error (tls_get_conn (TLS), TLS->error); +} + static void tgprpl_login (PurpleAccount * acct) { info ("tgprpl_login(): Purple is telling the prpl to connect the account"); @@ -587,6 +600,7 @@ static void tgprpl_login (PurpleAccount * acct) { tgl_set_timer_methods (TLS, &tgp_timers); tgl_set_callback (TLS, &tgp_callback); tgl_register_app_id (TLS, TGP_APP_ID, TGP_APP_HASH); + tgl_set_app_version (TLS, PACKAGE_VERSION); tgl_init (TLS); if (! tgp_startswith (purple_account_get_username (acct), "+")) { @@ -604,6 +618,12 @@ static void tgprpl_login (PurpleAccount * acct) { read_auth_file (TLS); read_state_file (TLS); + if (purple_account_get_bool (acct, TGP_KEY_RESET_AUTH, FALSE)) { + info ("last login attempt failed, resetting authorization ..."); + purple_account_set_bool (tls_get_pa (TLS), TGP_KEY_RESET_AUTH, FALSE); + bl_do_reset_authorization (TLS); + } + purple_connection_set_state (conn->gc, PURPLE_CONNECTING); tgl_login (TLS); } diff --git a/telegram-purple.h b/telegram-purple.h index e2a55db..161cb39 100644 --- a/telegram-purple.h +++ b/telegram-purple.h @@ -87,6 +87,8 @@ #define TGP_DEFAULT_SEND_READ_NOTIFICATIONS TRUE #define TGP_KEY_SEND_READ_NOTIFICATIONS "send-read-notifications" +#define TGP_KEY_RESET_AUTH "reset-authorization" + extern const char *pk_path; extern const char *user_pk_filename; extern const char *config_dir; diff --git a/tgp-msg.c b/tgp-msg.c index 07da700..01845fb 100644 --- a/tgp-msg.c +++ b/tgp-msg.c @@ -43,15 +43,15 @@ g_utf8_substring (const gchar *str, #endif static char *format_service_msg (struct tgl_state *TLS, struct tgl_message *M) { - assert (M && M->flags & TGLMF_SERVICE); + g_return_val_if_fail(M && M->flags & TGLMF_SERVICE, NULL); + connection_data *conn = TLS->ev_base; char *txt = NULL; tgl_peer_t *fromPeer = tgl_peer_get (TLS, M->from_id); - if (! fromPeer) { - return NULL; - } - char *txt_user = fromPeer->print_name; + g_return_val_if_fail(fromPeer != NULL, NULL); + + const char *txt_user = fromPeer->print_name; switch (M->action.type) { case tgl_message_action_chat_create: @@ -101,7 +101,7 @@ static char *format_service_msg (struct tgl_state *TLS, struct tgl_message *M) { if (peer) { tgl_peer_t *chatPeer = tgl_peer_get (TLS, M->to_id); - assert (tgl_get_peer_type(chatPeer->id) == TGL_PEER_CHAT); + g_return_val_if_fail(tgl_get_peer_type (chatPeer->id) == TGL_PEER_CHAT, NULL); // make sure that the chat is showing before deleting the user, otherwise the chat will be // initialised after removing the chat and the chat will still contain the deleted user @@ -171,6 +171,7 @@ static char *format_service_msg (struct tgl_state *TLS, struct tgl_message *M) { break; } default: + g_warn_if_reached(); break; } return txt; @@ -437,10 +438,21 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) { return; } - // Mark messages that contain a mention like if they contained our current nick name + // Mark messages that contain a mention as if they contained our current nick name + // FIXME: doesn't work in Adium if (M->flags & TGLMF_MENTION) { flags |= PURPLE_MESSAGE_NICK; } + + // handle messages that failed to load + if (C->error) { + const char *err = C->error_msg; + if (! err) { + err = _("failed loading message"); + } + tgp_msg_err_out (TLS, err, tgp_our_msg (TLS, M) ? M->from_id : M->to_id); + return; + } // format the message text if (M->flags & TGLMF_SERVICE) { @@ -452,7 +464,8 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) { case tgl_message_media_photo: { if (M->media.photo) { - assert (C->data); + g_return_if_fail(C->data != NULL); + text = tgp_msg_photo_display (TLS, C->data, &flags); if (str_not_empty (text)) { if (str_not_empty (M->media.caption)) { @@ -467,10 +480,10 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) { case tgl_message_media_document: if (M->media.document->flags & TGLDF_STICKER) { - assert (C->data); + g_return_if_fail(C->data != NULL); text = tgp_msg_sticker_display (TLS, M->from_id, C->data, &flags); } else if (M->media.document->flags & TGLDF_IMAGE) { - assert (C->data); + g_return_if_fail(C->data != NULL); text = tgp_msg_photo_display (TLS, C->data, &flags); } else { if (! tgp_our_msg(TLS, M)) { @@ -490,10 +503,10 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) { case tgl_message_media_document_encr: if (M->media.encr_document->flags & TGLDF_STICKER) { - assert (C->data); + g_return_if_fail(C->data != NULL); text = tgp_msg_sticker_display (TLS, M->from_id, C->data, &flags); } if (M->media.encr_document->flags & TGLDF_IMAGE) { - assert (C->data); + g_return_if_fail(C->data != NULL); text = tgp_msg_photo_display (TLS, C->data, &flags); } else { if (! tgp_our_msg(TLS, M)) { @@ -608,6 +621,8 @@ static void tgp_msg_display (struct tgl_state *TLS, struct tgp_msg_loading *C) { switch (tgl_get_peer_type (M->to_id)) { case TGL_PEER_CHAT: { tgl_peer_t *P = tgl_peer_get (TLS, M->to_id); + g_return_if_fail(P != NULL); + if (tgp_chat_show (TLS, &P->chat)) { p2tgl_got_chat_in (TLS, M->to_id, M->from_id, text, flags, M->date); } @@ -658,27 +673,43 @@ static void tgp_msg_process_in_ready (struct tgl_state *TLS) { if (C->data) { g_free (C->data); } + + if (C->error_msg) { + g_free (C->error_msg); + } + tgp_msg_loading_free (C); } } static void tgp_msg_on_loaded_document (struct tgl_state *TLS, void *extra, int success, const char *filename) { debug ("tgp_msg_on_loaded_document()"); - assert (success); - + struct tgp_msg_loading *C = extra; - C->data = (void *) g_strdup (filename); + + if (success) { + C->data = (void *) g_strdup (filename); + } else { + g_warn_if_reached(); + C->error = TRUE; + C->error_msg = g_strdup (_("loading document or picture failed")); + } + -- C->pending; tgp_msg_process_in_ready (TLS); } static void tgp_msg_on_loaded_chat_full (struct tgl_state *TLS, void *extra, int success, struct tgl_chat *chat) { debug ("tgp_msg_on_loaded_chat_full()"); - assert (success); tgp_chat_on_loaded_chat_full (TLS, chat); - struct tgp_msg_loading *C = extra; + + if (! success) { + // foreign user's names won't be displayed in the user list + g_warn_if_reached(); + } + -- C->pending; tgp_msg_process_in_ready (TLS); } @@ -766,11 +797,10 @@ void tgp_msg_recv (struct tgl_state *TLS, struct tgl_message *M) { */ if (tgl_get_peer_type (M->to_id) == TGL_PEER_CHAT) { - - tgl_peer_t *peer = tgl_peer_get (TLS, M->to_id); - assert (peer); - - if (! peer->chat.user_list_size) { + + tgl_peer_t *P = tgl_peer_get (TLS, M->to_id); + g_warn_if_fail(P); + if (P && ! P->chat.user_list_size) { // To display a chat the full name of every single user is needed, but the updates received from the server only // contain the names of users mentioned in the events. In order to display a messages we always need to fetch the // full chat info first. If the user list is empty, this means that we still haven't fetched the full chat information. diff --git a/tgp-structs.c b/tgp-structs.c index 5747cee..e90b5ab 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -72,7 +72,7 @@ void tgp_msg_loading_free (gpointer data) { } struct tgp_msg_loading *tgp_msg_loading_init (struct tgl_message *M) { - struct tgp_msg_loading *C = malloc (sizeof (struct tgp_msg_loading)); + struct tgp_msg_loading *C = talloc0 (sizeof (struct tgp_msg_loading)); C->pending = 0; C->msg = M; C->data = NULL; diff --git a/tgp-structs.h b/tgp-structs.h index 5026c3f..2468090 100644 --- a/tgp-structs.h +++ b/tgp-structs.h @@ -62,6 +62,8 @@ struct tgp_msg_loading { int pending; struct tgl_message *msg; void *data; + int error; + char *error_msg; }; struct tgp_msg_sending {