mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 23:06:38 +02:00
relay: redefine bar item "input_prompt" to display the connection status on remote buffers, if different from "connected"
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## Version 4.5.0 (under dev)
|
||||
|
||||
### Added
|
||||
|
||||
- relay: redefine bar item "input_prompt" to display the connection status on remote buffers, if different from "connected"
|
||||
|
||||
### Fixed
|
||||
|
||||
- lua: fix compilation on Fedora with Lua < 5.2.0 ([#2173](https://github.com/weechat/weechat/issues/2173), [#2174](https://github.com/weechat/weechat/issues/2174))
|
||||
|
||||
@@ -326,6 +326,7 @@ WeeChat "core" is located in following directories:
|
||||
| relay/ | Relay plugin (IRC proxy and relay for remote interfaces).
|
||||
| relay.c | Main relay functions.
|
||||
| relay-auth.c | Clients authentication.
|
||||
| relay-bar-item.c | Relay bar items.
|
||||
| relay-buffer.c | Relay buffer.
|
||||
| relay-client.c | Clients of relay.
|
||||
| relay-command.c | Relay commands.
|
||||
|
||||
@@ -328,6 +328,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|
||||
| relay/ | Extension Relay (proxy IRC et relai pour des interfaces distantes).
|
||||
| relay.c | Fonctions principales de Relay.
|
||||
| relay-auth.c | Authentification des clients.
|
||||
| relay-bar-item.c | Objets de barre Relay.
|
||||
| relay-buffer.c | Tampon Relay.
|
||||
| relay-client.c | Clients du relai.
|
||||
| relay-command.c | Commandes de Relay.
|
||||
|
||||
@@ -347,6 +347,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
|
||||
| relay.c | relay の主要関数
|
||||
// TRANSLATION MISSING
|
||||
| relay-auth.c | Clients authentification.
|
||||
// TRANSLATION MISSING
|
||||
| relay-bar-item.c | Relay bar items.
|
||||
| relay-buffer.c | relay バッファ
|
||||
| relay-client.c | relay クライアント
|
||||
| relay-command.c | relay コマンド
|
||||
|
||||
@@ -328,6 +328,8 @@ WeeChat „језгро” се налази у следећим директо
|
||||
| relay/ | Релеј додатак (IRC прокси и релеј за удаљене интерфејсе).
|
||||
| relay.c | Главне релеј функције.
|
||||
| relay-auth.c | Аутентификација клијената.
|
||||
// TRANSLATION MISSING
|
||||
| relay-bar-item.c | Relay bar items.
|
||||
| relay-buffer.c | Релеј бафер.
|
||||
| relay-client.c | Клијенти релеја.
|
||||
| relay-command.c | Релеј команде.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
set(RELAY_SRC
|
||||
relay.c relay.h
|
||||
relay-auth.c relay-auth.h
|
||||
relay-bar-item.c relay-bar-item.h
|
||||
relay-buffer.c relay-buffer.h
|
||||
relay-client.c relay-client.h
|
||||
relay-command.c relay-command.h
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* relay-bar-item.c - bar items for relay plugin
|
||||
*
|
||||
* Copyright (C) 2024 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "relay.h"
|
||||
#include "relay-config.h"
|
||||
#include "relay-remote.h"
|
||||
|
||||
|
||||
/*
|
||||
* Returns content of bar item "input_prompt".
|
||||
*/
|
||||
|
||||
char *
|
||||
relay_bar_item_input_prompt (const void *pointer, void *data,
|
||||
struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
char str_status[512], *input_prompt;
|
||||
const char *ptr_input_prompt;
|
||||
struct t_relay_remote *ptr_remote;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
str_status[0] = '\0';
|
||||
ptr_remote = relay_remote_search (weechat_buffer_get_string (buffer, "localvar_relay_remote"));
|
||||
if (ptr_remote && (ptr_remote->status != RELAY_STATUS_CONNECTED))
|
||||
{
|
||||
snprintf (str_status, sizeof (str_status),
|
||||
"%s<%s>",
|
||||
weechat_color (weechat_config_string (relay_config_color_status[ptr_remote->status])),
|
||||
_(relay_status_string[ptr_remote->status]));
|
||||
}
|
||||
|
||||
ptr_input_prompt = weechat_buffer_get_string (buffer, "input_prompt");
|
||||
if (!ptr_input_prompt && !str_status[0])
|
||||
return NULL;
|
||||
|
||||
if (weechat_asprintf (
|
||||
&input_prompt, "%s%s%s",
|
||||
(ptr_input_prompt) ? ptr_input_prompt : "",
|
||||
(ptr_input_prompt && ptr_input_prompt[0] && str_status[0]) ? " " : "",
|
||||
str_status) >= 0)
|
||||
return input_prompt;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes relay bar items.
|
||||
*/
|
||||
|
||||
void
|
||||
relay_bar_item_init ()
|
||||
{
|
||||
weechat_bar_item_new ("input_prompt",
|
||||
&relay_bar_item_input_prompt, NULL, NULL);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEECHAT_PLUGIN_RELAY_BAR_ITEM_H
|
||||
#define WEECHAT_PLUGIN_RELAY_BAR_ITEM_H
|
||||
|
||||
extern void relay_bar_item_init ();
|
||||
|
||||
#endif /* WEECHAT_PLUGIN_RELAY_BAR_ITEM_H */
|
||||
@@ -650,6 +650,7 @@ relay_remote_set_status (struct t_relay_remote *remote,
|
||||
remote->status = status;
|
||||
|
||||
relay_remote_send_signal (remote);
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "relay.h"
|
||||
#include "relay-bar-item.h"
|
||||
#include "relay-buffer.h"
|
||||
#include "relay-client.h"
|
||||
#include "relay-command.h"
|
||||
@@ -297,6 +298,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* hook completions */
|
||||
relay_completion_init ();
|
||||
|
||||
relay_bar_item_init ();
|
||||
|
||||
weechat_hook_signal ("upgrade", &relay_signal_upgrade_cb, NULL, NULL);
|
||||
weechat_hook_signal ("debug_dump", &relay_debug_dump_cb, NULL, NULL);
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ endif()
|
||||
if (ENABLE_RELAY)
|
||||
list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC
|
||||
unit/plugins/relay/test-relay-auth.cpp
|
||||
unit/plugins/relay/test-relay-bar-item.cpp
|
||||
unit/plugins/relay/test-relay-http.cpp
|
||||
unit/plugins/relay/test-relay-raw.cpp
|
||||
unit/plugins/relay/test-relay-remote.cpp
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* test-relay-bar-item.cpp - test relay bar item functions
|
||||
*
|
||||
* Copyright (C) 2024 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "src/plugins/relay/relay.h"
|
||||
#include "src/plugins/relay/relay-bar-item.h"
|
||||
}
|
||||
|
||||
TEST_GROUP(RelayBarItem)
|
||||
{
|
||||
};
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* relay_bar_item_input_prompt
|
||||
*/
|
||||
|
||||
TEST(RelayBarItem, InputPrompt)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* relay_bar_item_init
|
||||
*/
|
||||
|
||||
TEST(RelayBarItem, Init)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
}
|
||||
Reference in New Issue
Block a user