diff --git a/CHANGELOG.md b/CHANGELOG.md index b508c55c5..6a9070f66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ - relay/api: fix "body_type" returned when lines or nicks of a buffer are requested - relay/api: fix read of one buffer line - relay/api: automatically disconnect when the command `/upgrade` is executed on the remote +- relay/api: fix send of data to remote after command `/upgrade` executed in the remote client - relay/api: disconnect from remote in case of error when sending data - relay/api: disconnect cleanly when the remote is quitting ([#2168](https://github.com/weechat/weechat/issues/2168)) - relay: fix websocket permessage-deflate extension when the client doesn't send the max window bits parameters ([#1549](https://github.com/weechat/weechat/issues/1549)) diff --git a/src/plugins/relay/api/remote/relay-remote-event.c b/src/plugins/relay/api/remote/relay-remote-event.c index 70479bfbd..f31a24b46 100644 --- a/src/plugins/relay/api/remote/relay-remote-event.c +++ b/src/plugins/relay/api/remote/relay-remote-event.c @@ -33,6 +33,7 @@ #include "../../../weechat-plugin.h" #include "../../relay.h" #include "../../relay-auth.h" +#include "../../relay-buffer.h" #include "../../relay-config.h" #include "../../relay-http.h" #include "../../relay-raw.h" @@ -617,23 +618,18 @@ relay_remote_event_apply_props (void *data, * Callback for remote buffer input. */ -int -relay_remote_event_buffer_input_cb (const void *pointer, - void *data, - struct t_gui_buffer *buffer, - const char *input_data) +void +relay_remote_event_buffer_input (struct t_gui_buffer *buffer, + const char *input_data) { struct t_relay_remote *ptr_remote; cJSON *json, *json_body; long long buffer_id; - /* make C compiler happy */ - (void) pointer; - (void) data; - - ptr_remote = relay_remote_search (weechat_buffer_get_string (buffer, "localvar_relay_remote")); + ptr_remote = relay_remote_search ( + weechat_buffer_get_string (buffer, "localvar_relay_remote")); if (!ptr_remote) - return WEECHAT_RC_OK; + return; json = NULL; @@ -669,12 +665,12 @@ relay_remote_event_buffer_input_cb (const void *pointer, cJSON_Delete (json); - return WEECHAT_RC_OK; + return; error: if (json) cJSON_Delete (json); - return WEECHAT_RC_OK; + return; } /* @@ -923,7 +919,7 @@ RELAY_REMOTE_EVENT_CALLBACK(buffer) weechat_hashtable_set (buffer_props, "input_pos", str_number); ptr_buffer = weechat_buffer_new_props ( full_name, buffer_props, - &relay_remote_event_buffer_input_cb, NULL, NULL, + &relay_buffer_input_cb, NULL, NULL, NULL, NULL, NULL); apply_props = 0; } diff --git a/src/plugins/relay/api/remote/relay-remote-event.h b/src/plugins/relay/api/remote/relay-remote-event.h index 8a99cd134..b1053b3cb 100644 --- a/src/plugins/relay/api/remote/relay-remote-event.h +++ b/src/plugins/relay/api/remote/relay-remote-event.h @@ -20,6 +20,8 @@ #ifndef WEECHAT_PLUGIN_RELAY_REMOTE_EVENT_H #define WEECHAT_PLUGIN_RELAY_REMOTE_EVENT_H +#include + #define RELAY_REMOTE_EVENT_ID_INITIAL_SYNC "initial_sync" #define RELAY_REMOTE_EVENT_CALLBACK(__body_type) \ @@ -43,6 +45,8 @@ struct t_relay_remote_event_cb t_relay_remote_event_func *func; /* callback (can be NULL) */ }; +extern void relay_remote_event_buffer_input (struct t_gui_buffer *buffer, + const char *input_data); extern void relay_remote_event_recv (struct t_relay_remote *remote, const char *data); diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c index 88466a08b..57171a52a 100644 --- a/src/plugins/relay/relay-buffer.c +++ b/src/plugins/relay/relay-buffer.c @@ -29,6 +29,7 @@ #include "relay-buffer.h" #include "relay-client.h" #include "relay-config.h" +#include "relay-remote.h" #include "relay-raw.h" @@ -172,6 +173,7 @@ relay_buffer_input_cb (const void *pointer, void *data, const char *input_data) { struct t_relay_client *client, *ptr_client, *next_client; + const char *ptr_remote_name, *ptr_remote_id; /* make C compiler happy */ (void) pointer; @@ -223,6 +225,18 @@ relay_buffer_input_cb (const void *pointer, void *data, } } } + else + { + ptr_remote_name = weechat_buffer_get_string (buffer, + "localvar_relay_remote"); + ptr_remote_id = weechat_buffer_get_string (buffer, + "localvar_relay_remote_id"); + if (ptr_remote_name && ptr_remote_name[0] + && ptr_remote_id && ptr_remote_id[0]) + { + relay_remote_buffer_input (buffer, input_data); + } + } return WEECHAT_RC_OK; } diff --git a/src/plugins/relay/relay-remote.c b/src/plugins/relay/relay-remote.c index 4a77b0e8d..55b7b1c5c 100644 --- a/src/plugins/relay/relay-remote.c +++ b/src/plugins/relay/relay-remote.c @@ -37,6 +37,7 @@ #include "relay-remote.h" #include "relay-websocket.h" #ifdef HAVE_CJSON +#include "api/remote/relay-remote-event.h" #include "api/remote/relay-remote-network.h" #endif @@ -957,6 +958,18 @@ relay_remote_disconnect_all () } } +/* + * Callback for input data in a remote buffer. + */ + +void +relay_remote_buffer_input (struct t_gui_buffer *buffer, const char *input_data) +{ +#ifdef HAVE_CJSON + relay_remote_event_buffer_input (buffer, input_data); +#endif +} + /* * Deletes a remote. */ diff --git a/src/plugins/relay/relay-remote.h b/src/plugins/relay/relay-remote.h index cba611344..4c7283bc4 100644 --- a/src/plugins/relay/relay-remote.h +++ b/src/plugins/relay/relay-remote.h @@ -111,6 +111,8 @@ extern int relay_remote_reconnect (struct t_relay_remote *remote); extern void relay_remote_timer (); extern void relay_remote_disconnect_all (); extern int relay_remote_rename (struct t_relay_remote *remote, const char *name); +extern void relay_remote_buffer_input (struct t_gui_buffer *buffer, + const char *input_data); extern void relay_remote_free (struct t_relay_remote *remote); extern void relay_remote_free_all (); extern int relay_remote_add_to_infolist (struct t_infolist *infolist,