Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package purple-rocketchat for openSUSE:Factory checked in at 2022-11-16 15:43:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/purple-rocketchat (Old) and /work/SRC/openSUSE:Factory/.purple-rocketchat.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "purple-rocketchat" Wed Nov 16 15:43:23 2022 rev:9 rq:1035897 version:0.0+git20220925 Changes: -------- --- /work/SRC/openSUSE:Factory/purple-rocketchat/purple-rocketchat.changes 2021-01-22 21:52:37.269874366 +0100 +++ /work/SRC/openSUSE:Factory/.purple-rocketchat.new.1597/purple-rocketchat.changes 2022-11-16 15:43:36.871886375 +0100 @@ -1,0 +2,9 @@ +Tue Nov 15 15:33:05 UTC 2022 - zero mind <zerom...@gmx.com> + +- Update to version 0.0+git20220925 (changes since 0.0+git20210219): + * compatibility with rocketchat server 4.x + * fix various memory leaks + * handle http connection errors when building against Purple 2.x + * only start the actual login process when api/me could be reached + +------------------------------------------------------------------- Old: ---- purple-rocketchat-0.0+git20210119.tar.xz New: ---- purple-rocketchat-0.0+git20220925.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ purple-rocketchat.spec ++++++ --- /var/tmp/diff_new_pack.O4XioA/_old 2022-11-16 15:43:37.343888086 +0100 +++ /var/tmp/diff_new_pack.O4XioA/_new 2022-11-16 15:43:37.351888115 +0100 @@ -1,7 +1,7 @@ # # spec file for package purple-rocketchat # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %define _name rocketchat Name: purple-rocketchat -Version: 0.0+git20210119 +Version: 0.0+git20220925 Release: 0 Summary: RocketChat protocol plugin for libpurple License: GPL-2.0-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.O4XioA/_old 2022-11-16 15:43:37.391888260 +0100 +++ /var/tmp/diff_new_pack.O4XioA/_new 2022-11-16 15:43:37.395888275 +0100 @@ -4,7 +4,7 @@ <param name="url">https://github.com/EionRobb/purple-rocketchat</param> <param name="filename">purple-rocketchat</param> <param name="versionformat">0.0+git%cd</param> - <param name="revision">62090bc61f80fd0c4ea18319b6394990d9b0278a</param> + <param name="revision">a8a887c0c34402293bcf782f1cb76a0046f4a0a0</param> </service> <service mode="disabled" name="recompress"> <param name="file">*.tar</param> ++++++ purple-rocketchat-0.0+git20210119.tar.xz -> purple-rocketchat-0.0+git20220925.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/purple-rocketchat-0.0+git20210119/.gitignore new/purple-rocketchat-0.0+git20220925/.gitignore --- old/purple-rocketchat-0.0+git20210119/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/purple-rocketchat-0.0+git20220925/.gitignore 2022-09-25 07:49:21.000000000 +0200 @@ -0,0 +1 @@ +librocketchat.so \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/purple-rocketchat-0.0+git20210119/.hgignore new/purple-rocketchat-0.0+git20220925/.hgignore --- old/purple-rocketchat-0.0+git20210119/.hgignore 2021-01-19 09:37:18.000000000 +0100 +++ new/purple-rocketchat-0.0+git20220925/.hgignore 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -librocketchat.so \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/purple-rocketchat-0.0+git20210119/Makefile new/purple-rocketchat-0.0+git20220925/Makefile --- old/purple-rocketchat-0.0+git20210119/Makefile 2021-01-19 09:37:18.000000000 +0100 +++ new/purple-rocketchat-0.0+git20220925/Makefile 2022-09-25 07:49:21.000000000 +0200 @@ -8,8 +8,7 @@ PKG_CONFIG ?= pkg-config -REVISION_ID = $(shell hg id -i) -REVISION_NUMBER = $(shell hg id -n) +REVISION_ID = $(shell git rev-parse --short HEAD 2>/dev/null) DATE_FMT = %Y.%m.%d ifdef SOURCE_DATE_EPOCH BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") @@ -18,7 +17,7 @@ endif ifneq ($(REVISION_ID),) -PLUGIN_VERSION ?= 0.9.$(BUILD_DATE).hg.r$(REVISION_NUMBER).$(REVISION_ID) +PLUGIN_VERSION ?= 0.9.$(BUILD_DATE).git.r$(REVISION_ID) else PLUGIN_VERSION ?= 0.9.$(BUILD_DATE) endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/purple-rocketchat-0.0+git20210119/README.md new/purple-rocketchat-0.0+git20220925/README.md --- old/purple-rocketchat-0.0+git20210119/README.md 2021-01-19 09:37:18.000000000 +0100 +++ new/purple-rocketchat-0.0+git20220925/README.md 2022-09-25 07:49:21.000000000 +0200 @@ -49,5 +49,13 @@ * Click the "Get List" button * Add the chat to your buddy list +## Auth Issues? ## +If you're getting "Bad Username/Password" errors, and you're definitely sure that you're using the right username/password, or if your Rocket.Chat instance uses a 3rd party for authentication (eg Ookla, Google or Microsoft) then you'll need to make a Personal Access Token: +* In the official Rocket.Chat app, click on your profile then My Account -> Personal Access Token +* Add a new PAT without 2FA +* Copy-paste the token and user-id fields into Tools -> Accounts -> {Your rocket.chat account} -> Advanced -> Personal Access Token (and User ID) fields in Pidgin +More info about PATs at https://docs.rocket.chat/guides/user-guides/user-panel/managing-your-account/personal-access-token + + ## Like this plugin? ## Say "Thanks" by [sending $1](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PZMBF2QVF69GA) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/purple-rocketchat-0.0+git20210119/librocketchat.c new/purple-rocketchat-0.0+git20220925/librocketchat.c --- old/purple-rocketchat-0.0+git20210119/librocketchat.c 2021-01-19 09:37:18.000000000 +0100 +++ new/purple-rocketchat-0.0+git20220925/librocketchat.c 2022-09-25 07:49:21.000000000 +0200 @@ -108,7 +108,7 @@ #ifndef ROCKETCHAT_PLUGIN_VERSION #define ROCKETCHAT_PLUGIN_VERSION "0.1" #endif -#define ROCKETCHAT_PLUGIN_WEBSITE "https://bitbucket.org/EionRobb/purple-rocketchat" +#define ROCKETCHAT_PLUGIN_WEBSITE "https://github.com/EionRobb/purple-rocketchat" #define ROCKETCHAT_USERAGENT "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" @@ -293,6 +293,7 @@ RocketChatAccount *ya; RocketChatProxyCallbackFunc callback; gpointer user_data; + GDestroyNotify user_data_destroy_func; } RocketChatProxyConnection; @@ -567,7 +568,7 @@ } static const gchar * -rc_get_next_id_str_callback(RocketChatAccount *ya, RocketChatProxyCallbackFunc callback, gpointer user_data) +rc_get_next_id_str_callback(RocketChatAccount *ya, RocketChatProxyCallbackFunc callback, gpointer user_data, GDestroyNotify user_data_destroy_func) { const gchar *id = rc_get_next_id_str(ya); RocketChatProxyConnection *proxy = g_new0(RocketChatProxyConnection, 1); @@ -575,6 +576,7 @@ proxy->ya = ya; proxy->callback = callback; proxy->user_data = user_data; + proxy->user_data_destroy_func = user_data_destroy_func; g_hash_table_insert(ya->result_callbacks, g_strdup(id), proxy); @@ -716,9 +718,37 @@ gchar *error_msg_formatted = g_strdup_printf(_("Connection error: %s."), error_message); purple_connection_error(conn->ya->pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_msg_formatted); g_free(error_msg_formatted); - g_free(conn); - return; + goto out; } +#if !PURPLE_VERSION_CHECK(3, 0, 0) + else { + /* Purple 2.x doesn't check for the http status to be successful so let's + * do that here quick. + * Borrowed and then adapted from purple2compat http.c + */ + if (!error_message) { + gsize header_len = (body + 4 - url_text); + gchar header[header_len]; + g_strlcpy(header, url_text, header_len); + gchar** header_by_word = g_strsplit_set(header, " ", 2); + gint code = -1; + + sscanf(header_by_word[1], "%d", &code); + g_strfreev(header_by_word); + + if (!(code <= 0 || code / 100 == 2)) { + gchar *error_msg_formatted = g_strdup_printf( + _("Connection error: Invalid HTTP response code (%d)."), + code); + purple_connection_error(conn->ya->pc, + PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + error_msg_formatted); + g_free(error_msg_formatted); + goto out; + } + } + } +#endif if (body != NULL && !json_parser_load_from_data(parser, body, body_len, NULL)) { //purple_debug_error("rocketchat", "Error parsing response: %s\n", body); if (conn->callback) { @@ -744,9 +774,12 @@ conn->callback(conn->ya, root, conn->user_data, NULL); } } - + +out: g_object_unref(parser); g_free(conn); + + return; } static void @@ -903,7 +936,7 @@ json_object_set_string_member(response, "msg", "method"); json_object_set_string_member(response, "method", "login"); json_object_set_array_member(response, "params", params); - json_object_set_string_member(response, "id", rc_get_next_id_str_callback(ya, rc_login_response, NULL)); + json_object_set_string_member(response, "id", rc_get_next_id_str_callback(ya, rc_login_response, NULL, NULL)); rc_socket_write_json(ya, response); @@ -1175,7 +1208,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "rooms/get"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_open_rooms, NULL)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_open_rooms, NULL, NULL)); rc_socket_write_json(ya, data); @@ -1196,7 +1229,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "browseChannels"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_available_channels, NULL)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_available_channels, NULL, NULL)); rc_socket_write_json(ya, data); @@ -1751,7 +1784,7 @@ json_object_set_string_member(response, "msg", "method"); json_object_set_string_member(response, "method", "login"); json_object_set_array_member(response, "params", params); - json_object_set_string_member(response, "id", rc_get_next_id_str_callback(ya, rc_login_response, NULL)); + json_object_set_string_member(response, "id", rc_get_next_id_str_callback(ya, rc_login_response, NULL, NULL)); } else if (purple_strequal(msg, "result")) { @@ -1917,14 +1950,14 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "channelsList"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_roomlist_got_list, roomlist)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_roomlist_got_list, roomlist, NULL)); json_object_ref(data); rc_socket_write_json(ya, data); // Send the same request again without the second parameter for older servers json_array_remove_element(params, 1); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_roomlist_got_list, roomlist)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_roomlist_got_list, roomlist, NULL)); rc_socket_write_json(ya, data); } @@ -2038,6 +2071,18 @@ static gulong chat_conversation_typing_signal = 0; static void rc_mark_conv_seen(PurpleConversation *conv, PurpleConversationUpdateType type); static gulong conversation_updated_signal = 0; +static void rc_login_me_cb(RocketChatAccount *ya, JsonNode *node, gpointer user_data, + JsonObject *error); + +static void +rc_free_proxy(gpointer data) +{ + RocketChatProxyConnection *proxy = (RocketChatProxyConnection*)data; + if (proxy->user_data && proxy->user_data_destroy_func) { + (proxy->user_data_destroy_func)(proxy->user_data); + } + g_free(data); +} void rc_login(PurpleAccount *account) @@ -2073,7 +2118,7 @@ ya->group_chats = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ya->group_chats_rev = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ya->sent_message_ids = g_hash_table_new_full(g_str_insensitive_hash, g_str_insensitive_equal, g_free, NULL); - ya->result_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + ya->result_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, rc_free_proxy); ya->usernames_to_ids = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ya->ids_to_usernames = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ya->received_message_queue = g_queue_new(); @@ -2118,20 +2163,33 @@ //Build the initial hash tables from the current buddy list rc_build_groups_from_blist(ya); - - //TODO do something with this callback to make sure it's actually a rocket.chat server - url = g_strconcat("https://", ya->server, ya->path, "/api/info", NULL); - rc_fetch_url(ya, url, NULL, NULL, NULL); + + url = g_strconcat("https://", ya->server, ya->path, "/api/me", NULL); + rc_fetch_url(ya, url, NULL, rc_login_me_cb, NULL); g_free(url); - +} + + +static void +rc_login_me_cb(RocketChatAccount *ya, JsonNode *node, gpointer user_data, + JsonObject *error) +{ + if(!ya) return; + // TODO: Add else that parses the error status + rc_start_socket(ya); - - + if (!chat_conversation_typing_signal) { - chat_conversation_typing_signal = purple_signal_connect(purple_conversations_get_handle(), "chat-conversation-typing", purple_connection_get_protocol(pc), PURPLE_CALLBACK(rc_conv_send_typing), NULL); + chat_conversation_typing_signal = purple_signal_connect( + purple_conversations_get_handle(), "chat-conversation-typing", + purple_connection_get_protocol(ya->pc), PURPLE_CALLBACK(rc_conv_send_typing), + NULL); } if (!conversation_updated_signal) { - conversation_updated_signal = purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", purple_connection_get_protocol(pc), PURPLE_CALLBACK(rc_mark_conv_seen), NULL); + conversation_updated_signal = purple_signal_connect( + purple_conversations_get_handle(), "conversation-updated", + purple_connection_get_protocol(ya->pc), PURPLE_CALLBACK(rc_mark_conv_seen), + NULL); } } @@ -2153,6 +2211,8 @@ g_hash_table_unref(ya->one_to_ones_rev); g_hash_table_remove_all(ya->group_chats); g_hash_table_unref(ya->group_chats); + g_hash_table_remove_all(ya->group_chats_rev); + g_hash_table_unref(ya->group_chats_rev); g_hash_table_remove_all(ya->sent_message_ids); g_hash_table_unref(ya->sent_message_ids); g_hash_table_remove_all(ya->result_callbacks); @@ -2220,10 +2280,10 @@ return TRUE; } - root = json_parser_get_root(parser); + if (frame_type == 'a') { - if (root != NULL) { - if (frame_type == 'a') { + root = json_parser_get_root(parser); + if (root != NULL) { JsonArray *message_array = json_node_get_array(root); guint i, len = json_array_get_length(message_array); JsonParser *message_parser = json_parser_new(); @@ -2236,17 +2296,34 @@ } } g_object_unref(message_parser); - } else if (frame_type == 'o') { - //Open frame - } else if (frame_type == 'c') { - //Close frame - purple_debug_error("rocketchat", "server closed the connection\n"); - } else if (frame_type == 'h') { - //Heartbeat frame - } else { - //TODO is this going to happen? - purple_debug_error("rocketchat", "unknown frame type '%c'\n", frame_type); } + + } else if (frame_type == 'o') { + //Open frame + JsonObject *response = json_object_new(); + JsonArray *support = json_array_new(); + + json_array_add_string_element(support, "1"); + json_array_add_string_element(support, "pre2"); + json_array_add_string_element(support, "pre1"); + + json_object_set_string_member(response, "msg", "connect"); + json_object_set_string_member(response, "version", "1"); + json_object_set_array_member(response, "support", support); + + rc_socket_write_json(rca, response); + + } else if (frame_type == 'c') { + //Close frame + purple_debug_error("rocketchat", "server closed the connection\n"); + + } else if (frame_type == 'h') { + //Heartbeat frame + + } else { + //TODO is this going to happen? + purple_debug_error("rocketchat", "unknown frame type '%c'\n", frame_type); + } g_object_unref(parser); @@ -2359,6 +2436,7 @@ g_free(str); json_node_free(node); json_array_unref(data_array); + json_object_unref(data); } static void @@ -2786,8 +2864,6 @@ g_list_free(users); g_list_free(flags); } - - g_free(room_id); } static void @@ -2816,8 +2892,6 @@ if (rolling_last_message_timestamp != 0) { rc_set_room_last_timestamp(ya, room_id, rolling_last_message_timestamp); } - - g_free(room_id); } @@ -2892,8 +2966,8 @@ //["{\"msg\":\"method\",\"method\":\"getRoomRoles\",\"params\":[\"GENERAL\"],\"id\":\"15\"}"] //["{\"msg\":\"method\",\"method\":\"getUsersOfRoom\",\"params\":[\"GENERAL\",true],\"id\":\"15\"}"] //["{\"msg\":\"method\",\"method\":\"loadHistory\",\"params\":[\"GENERAL\",null,50,{\"$date\":1477203134888}],\"id\":\"5\"}"] - JsonObject *data = json_object_new(); - JsonArray *params = json_array_new(); + JsonObject *data; + JsonArray *params; JsonObject *date; gchar *id; gchar *sub_id; @@ -2943,7 +3017,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "getUsersOfRoom"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_users_of_room, g_strdup(room_id))); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_users_of_room, g_strdup(room_id), g_free)); rc_socket_write_json(ya, data); @@ -2962,7 +3036,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "loadHistory"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_history_of_room, g_strdup(room_id))); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_history_of_room, g_strdup(room_id), g_free)); rc_socket_write_json(ya, data); } @@ -3025,7 +3099,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "getRoomIdByNameOrId"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_chat_name_id, chatdata)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_got_chat_name_id, chatdata, NULL)); rc_socket_write_json(ya, data); @@ -3352,7 +3426,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "createDirectMessage"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_created_direct_message_send, msg)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_created_direct_message_send, msg, NULL)); rc_socket_write_json(ya, data); return 1; @@ -3475,7 +3549,7 @@ json_object_set_string_member(data, "msg", "method"); json_object_set_string_member(data, "method", "createDirectMessage"); json_object_set_array_member(data, "params", params); - json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_created_direct_message, buddy)); + json_object_set_string_member(data, "id", rc_get_next_id_str_callback(ya, rc_created_direct_message, buddy, NULL)); rc_socket_write_json(ya, data);