mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added XML Console window
This commit is contained in:
parent
bf185d9907
commit
e6e0a13e89
@ -789,6 +789,14 @@ static struct cmd_t command_defs[] =
|
||||
"The default is 'all' for all windows.",
|
||||
NULL } } },
|
||||
|
||||
{ "/xmlconsole",
|
||||
cmd_xmlconsole, parse_args, 0, 0, NULL,
|
||||
{ "/xmlconsole", "Open the XML console",
|
||||
{ "/xmlconsole",
|
||||
"-----------",
|
||||
"Open the XML console to view incoming and outgoing XMPP traffic.",
|
||||
NULL } } },
|
||||
|
||||
{ "/away",
|
||||
cmd_away, parse_args_with_freetext, 0, 1, NULL,
|
||||
{ "/away [msg]", "Set status to away.",
|
||||
@ -1937,4 +1945,4 @@ _account_autocomplete(char *input, int *size)
|
||||
|
||||
found = autocomplete_param_with_ac(input, size, "/account", account_ac);
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
@ -2443,6 +2443,18 @@ cmd_vercheck(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_xmlconsole(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
if (!ui_xmlconsole_exists()) {
|
||||
ui_create_xmlconsole_win();
|
||||
} else {
|
||||
ui_open_xmlconsole_win();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_flash(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
|
@ -110,5 +110,6 @@ gboolean cmd_win(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_wins(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_xa(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_alias(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help);
|
||||
|
||||
#endif
|
||||
|
@ -219,18 +219,28 @@ _ui_duck_exists(void)
|
||||
return wins_duck_exists();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_ui_xmlconsole_exists(void)
|
||||
{
|
||||
return wins_xmlconsole_exists();
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_handle_stanza(const char * const msg)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
if (g_str_has_prefix(msg, "SENT:")) {
|
||||
win_vprint_line(console, '!', COLOUR_ONLINE, "<- %s", &msg[6]);
|
||||
} else if (g_str_has_prefix(msg, "RECV:")) {
|
||||
win_vprint_line(console, '!', COLOUR_AWAY, "-> %s", &msg[6]);
|
||||
}
|
||||
win_update_virtual(console);
|
||||
if (wins_is_current(console)) {
|
||||
ui_current_page_off();
|
||||
if (ui_xmlconsole_exists()) {
|
||||
ProfWin *xmlconsole = wins_get_xmlconsole();
|
||||
|
||||
if (g_str_has_prefix(msg, "SENT:")) {
|
||||
win_vprint_line(xmlconsole, '!', COLOUR_ONLINE, "<- %s", &msg[6]);
|
||||
} else if (g_str_has_prefix(msg, "RECV:")) {
|
||||
win_vprint_line(xmlconsole, '!', COLOUR_AWAY, "-> %s", &msg[6]);
|
||||
}
|
||||
|
||||
win_update_virtual(xmlconsole);
|
||||
if (wins_is_current(xmlconsole)) {
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1117,6 +1127,14 @@ _ui_create_duck_win(void)
|
||||
win_print_line(window, '-', 0, "Type ':help' to find out more.");
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_create_xmlconsole_win(void)
|
||||
{
|
||||
ProfWin *window = wins_new("XML Console", WIN_XML);
|
||||
int num = wins_get_num(window);
|
||||
ui_switch_win(num);
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_open_duck_win(void)
|
||||
{
|
||||
@ -1939,4 +1957,6 @@ ui_init_module(void)
|
||||
ui_replace_input = _ui_replace_input;
|
||||
ui_invalid_command_usage = _ui_invalid_command_usage;
|
||||
ui_handle_stanza = _ui_handle_stanza;
|
||||
ui_create_xmlconsole_win = _ui_create_xmlconsole_win;
|
||||
ui_xmlconsole_exists = _ui_xmlconsole_exists;
|
||||
}
|
||||
|
@ -163,6 +163,10 @@ void (*ui_replace_input)(char *input, const char * const new_input, int *size);
|
||||
|
||||
void (*ui_invalid_command_usage)(const char * const usage, void (**setting_func)(void));
|
||||
|
||||
void (*ui_create_xmlconsole_win)(void);
|
||||
gboolean (*ui_xmlconsole_exists)(void);
|
||||
void (*ui_open_xmlconsole_win)(void);
|
||||
|
||||
// console window actions
|
||||
void (*cons_show)(const char * const msg, ...);
|
||||
void (*cons_about)(void);
|
||||
|
@ -41,7 +41,8 @@ typedef enum {
|
||||
WIN_CHAT,
|
||||
WIN_MUC,
|
||||
WIN_PRIVATE,
|
||||
WIN_DUCK
|
||||
WIN_DUCK,
|
||||
WIN_XML
|
||||
} win_type_t;
|
||||
|
||||
typedef struct prof_win_t {
|
||||
|
@ -297,6 +297,38 @@ wins_duck_exists(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wins_xmlconsole_exists(void)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
|
||||
while (curr != NULL) {
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_XML)
|
||||
return TRUE;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
wins_get_xmlconsole(void)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
|
||||
while (curr != NULL) {
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_XML)
|
||||
return window;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSList *
|
||||
wins_get_chat_recipients(void)
|
||||
{
|
||||
@ -428,6 +460,7 @@ wins_create_summary(void)
|
||||
GString *priv_string;
|
||||
GString *muc_string;
|
||||
GString *duck_string;
|
||||
GString *xml_string;
|
||||
|
||||
switch (window->type)
|
||||
{
|
||||
@ -501,6 +534,14 @@ wins_create_summary(void)
|
||||
|
||||
break;
|
||||
|
||||
case WIN_XML:
|
||||
xml_string = g_string_new("");
|
||||
g_string_printf(xml_string, "%d: XML console", ui_index);
|
||||
result = g_slist_append(result, strdup(xml_string->str));
|
||||
g_string_free(xml_string, TRUE);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -48,5 +48,7 @@ gboolean wins_tidy(void);
|
||||
GSList * wins_create_summary(void);
|
||||
void wins_destroy(void);
|
||||
GList * wins_get_nums(void);
|
||||
gboolean wins_xmlconsole_exists(void);
|
||||
ProfWin * wins_get_xmlconsole(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user