mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Merge branch 'master' into plugins
Conflicts: src/ui/window.h src/ui/windows.c
This commit is contained in:
commit
00fd7f4bce
@ -796,6 +796,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.",
|
||||
@ -1402,6 +1410,7 @@ cmd_execute_default(const char * const inp)
|
||||
break;
|
||||
|
||||
case WIN_CONSOLE:
|
||||
case WIN_XML:
|
||||
cons_show("Unknown command: %s", inp);
|
||||
break;
|
||||
|
||||
|
@ -2446,6 +2446,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)
|
||||
{
|
||||
|
@ -111,5 +111,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
|
||||
|
@ -553,3 +553,9 @@ handle_bookmark_autojoin(char *jid)
|
||||
ui_room_join(jid, FALSE);
|
||||
muc_remove_invite(jid);
|
||||
}
|
||||
|
||||
void
|
||||
handle_xmpp_stanza(const char * const msg)
|
||||
{
|
||||
ui_handle_stanza(msg);
|
||||
}
|
||||
|
@ -79,5 +79,6 @@ void handle_message_error(const char * const from, const char * const type,
|
||||
void handle_presence_error(const char *from, const char * const type,
|
||||
const char *err_msg);
|
||||
void handle_bookmark_autojoin(char *jid);
|
||||
void handle_xmpp_stanza(const char * const msg);
|
||||
|
||||
#endif
|
||||
|
@ -220,6 +220,35 @@ _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)
|
||||
{
|
||||
if (ui_xmlconsole_exists()) {
|
||||
ProfWin *xmlconsole = wins_get_xmlconsole();
|
||||
|
||||
if (g_str_has_prefix(msg, "SENT:")) {
|
||||
win_print_line_no_time(xmlconsole, 0, "SENT:");
|
||||
win_print_line_no_time(xmlconsole, COLOUR_ONLINE, &msg[6]);
|
||||
win_print_line_no_time(xmlconsole, COLOUR_ONLINE, "");
|
||||
} else if (g_str_has_prefix(msg, "RECV:")) {
|
||||
win_print_line_no_time(xmlconsole, 0, "RECV:");
|
||||
win_print_line_no_time(xmlconsole, COLOUR_AWAY, &msg[6]);
|
||||
win_print_line_no_time(xmlconsole, COLOUR_ONLINE, "");
|
||||
}
|
||||
|
||||
if (wins_is_current(xmlconsole)) {
|
||||
win_update_virtual(xmlconsole);
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_contact_typing(const char * const barejid)
|
||||
{
|
||||
@ -1105,6 +1134,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)
|
||||
{
|
||||
@ -1928,4 +1965,7 @@ ui_init_module(void)
|
||||
ui_input_nonblocking = _ui_input_nonblocking;
|
||||
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;
|
||||
}
|
||||
|
@ -302,14 +302,6 @@ status_bar_clear(void)
|
||||
message = NULL;
|
||||
}
|
||||
|
||||
int i;
|
||||
is_active[1] = TRUE;
|
||||
is_new[1] = FALSE;
|
||||
for (i = 2; i < 12; i++) {
|
||||
is_active[i] = FALSE;
|
||||
is_new[i] = FALSE;
|
||||
}
|
||||
|
||||
werase(status_bar);
|
||||
|
||||
int cols = getmaxx(stdscr);
|
||||
|
@ -92,6 +92,8 @@ gboolean (*ui_win_exists)(int index);
|
||||
int (*ui_win_unread)(int index);
|
||||
char * (*ui_ask_password)(void);
|
||||
|
||||
void (*ui_handle_stanza)(const char * const msg);
|
||||
|
||||
// ui events
|
||||
void (*ui_contact_typing)(const char * const from);
|
||||
void (*ui_incoming_msg)(const char * const from, const char * const message,
|
||||
@ -161,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);
|
||||
|
@ -89,6 +89,14 @@ win_print_line(ProfWin *window, const char show_char, int attrs,
|
||||
wattroff(window->win, attrs);
|
||||
}
|
||||
|
||||
void
|
||||
win_print_line_no_time(ProfWin *window, int attrs, const char * const msg)
|
||||
{
|
||||
wattron(window->win, attrs);
|
||||
wprintw(window->win, "%s\n", msg);
|
||||
wattroff(window->win, attrs);
|
||||
}
|
||||
|
||||
void
|
||||
win_vprint_line(ProfWin *window, const char show_char, int attrs,
|
||||
const char * const msg, ...)
|
||||
|
@ -42,7 +42,8 @@ typedef enum {
|
||||
WIN_MUC,
|
||||
WIN_PRIVATE,
|
||||
WIN_DUCK,
|
||||
WIN_PLUGIN
|
||||
WIN_PLUGIN,
|
||||
WIN_XML
|
||||
} win_type_t;
|
||||
|
||||
typedef struct prof_win_t {
|
||||
@ -63,6 +64,7 @@ void win_vprint_line(ProfWin *self, const char show_char, int attrs,
|
||||
const char * const msg, ...);
|
||||
void win_print_line(ProfWin *self, const char show_char, int attrs,
|
||||
const char * const msg);
|
||||
void win_print_line_no_time(ProfWin *window, int attrs, const char * const msg);
|
||||
void win_update_virtual(ProfWin *window);
|
||||
void win_move_to_end(ProfWin *window);
|
||||
void win_print_time(ProfWin *window, char show_char);
|
||||
|
@ -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)
|
||||
{
|
||||
@ -429,6 +461,7 @@ wins_create_summary(void)
|
||||
GString *muc_string;
|
||||
GString *duck_string;
|
||||
GString *plugin_string;
|
||||
GString *xml_string;
|
||||
|
||||
switch (window->type)
|
||||
{
|
||||
@ -516,6 +549,14 @@ wins_create_summary(void)
|
||||
g_string_free(plugin_string, TRUE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -50,5 +50,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
|
||||
|
@ -534,6 +534,9 @@ _xmpp_file_logger(void * const userdata, const xmpp_log_level_t level,
|
||||
{
|
||||
log_level_t prof_level = _get_log_level(level);
|
||||
log_msg(prof_level, area, msg);
|
||||
if ((g_strcmp0(area, "xmpp") == 0) || (g_strcmp0(area, "conn")) == 0) {
|
||||
handle_xmpp_stanza(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static xmpp_log_t *
|
||||
|
Loading…
Reference in New Issue
Block a user