summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-29 22:43:38 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-29 22:43:38 +0200
commitb8f64685900fe73781fbdc00a28d3438eedc4ed5 (patch)
treef0595a2e39bfb2b2093ada26c9fd60c2b87274b1
parentde2492160978639d6c5aac3cdd82aecbdedf8e11 (diff)
downloadweechat-b8f64685900fe73781fbdc00a28d3438eedc4ed5.zip
relay/api: add color names for groups and nicks in GET /api/buffers
-rw-r--r--src/plugins/relay/api/relay-api-msg.c3
-rw-r--r--tests/unit/plugins/relay/api/test-relay-api-msg.cpp10
2 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/relay/api/relay-api-msg.c b/src/plugins/relay/api/relay-api-msg.c
index a63cb7a90..929428469 100644
--- a/src/plugins/relay/api/relay-api-msg.c
+++ b/src/plugins/relay/api/relay-api-msg.c
@@ -584,8 +584,10 @@ relay_api_msg_nick_to_json (struct t_gui_nick *nick,
(ptr_group) ?
weechat_hdata_longlong (relay_hdata_nick_group, ptr_group, "id") : -1));
MSG_ADD_HDATA_STR("prefix", "prefix");
+ MSG_ADD_HDATA_STR("prefix_color_name", "prefix_color");
MSG_ADD_HDATA_COLOR("prefix_color", "prefix_color");
MSG_ADD_HDATA_STR("name", "name");
+ MSG_ADD_HDATA_STR("color_name", "color");
MSG_ADD_HDATA_COLOR("color", "color");
MSG_ADD_HDATA_VAR(Bool, "visible", integer, "visible");
@@ -625,6 +627,7 @@ relay_api_msg_nick_group_to_json (struct t_gui_nick_group *nick_group,
(ptr_group) ?
weechat_hdata_longlong (relay_hdata_nick_group, ptr_group, "id") : -1));
MSG_ADD_HDATA_STR("name", "name");
+ MSG_ADD_HDATA_STR("color_name", "color");
MSG_ADD_HDATA_COLOR("color", "color");
MSG_ADD_HDATA_VAR(Bool, "visible", integer, "visible");
diff --git a/tests/unit/plugins/relay/api/test-relay-api-msg.cpp b/tests/unit/plugins/relay/api/test-relay-api-msg.cpp
index ffd5dcab6..940321021 100644
--- a/tests/unit/plugins/relay/api/test-relay-api-msg.cpp
+++ b/tests/unit/plugins/relay/api/test-relay-api-msg.cpp
@@ -193,6 +193,7 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_IsObject (json_nicklist_root));
WEE_CHECK_OBJ_NUM(0, json_nicklist_root, "id");
WEE_CHECK_OBJ_STR("root", json_nicklist_root, "name");
+ WEE_CHECK_OBJ_STR("", json_nicklist_root, "color_name");
WEE_CHECK_OBJ_STR("", json_nicklist_root, "color");
json_groups = cJSON_GetObjectItem (json_nicklist_root, "groups");
CHECK(json_groups);
@@ -211,6 +212,7 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_IsNumber (json_obj));
CHECK(cJSON_GetNumberValue (json_obj) == 0);
WEE_CHECK_OBJ_STR("group1", json_group, "name");
+ WEE_CHECK_OBJ_STR("magenta", json_group, "color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("magenta"));
WEE_CHECK_OBJ_STR(color, json_group, "color");
free (color);
@@ -227,10 +229,12 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_GetNumberValue (json_obj) > 0);
WEE_CHECK_OBJ_NUM(group_id, json_nick, "parent_group_id");
WEE_CHECK_OBJ_STR("@", json_nick, "prefix");
+ WEE_CHECK_OBJ_STR("lightred", json_nick, "prefix_color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("lightred"));
WEE_CHECK_OBJ_STR(color, json_nick, "prefix_color");
free (color);
WEE_CHECK_OBJ_STR("nick1", json_nick, "name");
+ WEE_CHECK_OBJ_STR("blue", json_nick, "color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("blue"));
WEE_CHECK_OBJ_STR(color, json_nick, "color");
free (color);
@@ -244,8 +248,10 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_GetNumberValue (json_obj) > 0);
WEE_CHECK_OBJ_NUM(group_id, json_nick, "parent_group_id");
WEE_CHECK_OBJ_STR("", json_nick, "prefix");
+ WEE_CHECK_OBJ_STR("", json_nick, "prefix_color_name");
WEE_CHECK_OBJ_STR("", json_nick, "prefix_color");
WEE_CHECK_OBJ_STR("nick2", json_nick, "name");
+ WEE_CHECK_OBJ_STR("green", json_nick, "color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("green"));
WEE_CHECK_OBJ_STR(color, json_nick, "color");
free (color);
@@ -259,8 +265,10 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_GetNumberValue (json_obj) > 0);
WEE_CHECK_OBJ_NUM(group_id, json_nick, "parent_group_id");
WEE_CHECK_OBJ_STR("", json_nick, "prefix");
+ WEE_CHECK_OBJ_STR("", json_nick, "prefix_color_name");
WEE_CHECK_OBJ_STR("", json_nick, "prefix_color");
WEE_CHECK_OBJ_STR("nick3", json_nick, "name");
+ WEE_CHECK_OBJ_STR("yellow", json_nick, "color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("yellow"));
WEE_CHECK_OBJ_STR(color, json_nick, "color");
free (color);
@@ -278,10 +286,12 @@ TEST(RelayApiMsg, BufferToJson)
CHECK(cJSON_GetNumberValue (json_obj) > 0);
WEE_CHECK_OBJ_NUM(0, json_nick, "parent_group_id");
WEE_CHECK_OBJ_STR("+", json_nick, "prefix");
+ WEE_CHECK_OBJ_STR("yellow", json_nick, "prefix_color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("yellow"));
WEE_CHECK_OBJ_STR(color, json_nick, "prefix_color");
free (color);
WEE_CHECK_OBJ_STR("root_nick_hidden", json_nick, "name");
+ WEE_CHECK_OBJ_STR("cyan", json_nick, "color_name");
color = gui_color_encode_ansi (gui_color_get_custom ("cyan"));
WEE_CHECK_OBJ_STR(color, json_nick, "color");
free (color);