mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
6e975666c1
@ -2485,14 +2485,14 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
if (g_strcmp0(value, "on") == 0) {
|
||||
form_set_value(form, tag, "1");
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else if (g_strcmp0(value, "off") == 0) {
|
||||
form_set_value(form, tag, "0");
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
}
|
||||
break;
|
||||
@ -2503,24 +2503,24 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
value = args[0];
|
||||
if (value == NULL) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
} else {
|
||||
form_set_value(form, tag, value);
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
}
|
||||
break;
|
||||
case FIELD_LIST_SINGLE:
|
||||
value = args[0];
|
||||
if ((value == NULL) || !form_field_contains_option(form, tag, value)) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
} else {
|
||||
form_set_value(form, tag, value);
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2531,32 +2531,32 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
}
|
||||
if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
if (value == NULL) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
if (g_strcmp0(cmd, "add") == 0) {
|
||||
form_add_value(form, tag, value);
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
break;
|
||||
}
|
||||
if (g_strcmp0(args[0], "remove") == 0) {
|
||||
if (!g_str_has_prefix(value, "val")) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
if (strlen(value) < 4) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
@ -2564,7 +2564,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
int index = strtol(&value[3], NULL, 10);
|
||||
if ((index < 1) || (index > form_get_value_count(form, tag))) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
@ -2572,7 +2572,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
removed = form_remove_text_multi_value(form, tag, index);
|
||||
if (removed) {
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("Could not remove %s from %s", value, tag);
|
||||
}
|
||||
@ -2585,13 +2585,13 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
}
|
||||
if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
if (value == NULL) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
@ -2601,13 +2601,13 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
added = form_add_unique_value(form, tag, value);
|
||||
if (added) {
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("Value %s already selected for %s", value, tag);
|
||||
}
|
||||
} else {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
}
|
||||
break;
|
||||
@ -2618,13 +2618,13 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
removed = form_remove_value(form, tag, value);
|
||||
if (removed) {
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("Value %s is not currently set for %s", value, tag);
|
||||
}
|
||||
} else {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
}
|
||||
}
|
||||
@ -2636,13 +2636,13 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
}
|
||||
if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
if (value == NULL) {
|
||||
ui_current_print_line("Invalid command, usage:");
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
ui_current_print_line("");
|
||||
break;
|
||||
}
|
||||
@ -2650,7 +2650,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
added = form_add_unique_value(form, tag, value);
|
||||
if (added) {
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("JID %s already exists in %s", value, tag);
|
||||
}
|
||||
@ -2660,7 +2660,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
|
||||
removed = form_remove_value(form, tag, value);
|
||||
if (removed) {
|
||||
ui_current_print_line("Field updated...");
|
||||
ui_show_form_field(window, form, tag);
|
||||
mucconfwin_show_form_field(confwin, form, tag);
|
||||
} else {
|
||||
ui_current_print_line("Field %s does not contain %s", tag, value);
|
||||
}
|
||||
@ -2702,16 +2702,16 @@ cmd_form(ProfWin *window, const char *const command, gchar **args)
|
||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||
|
||||
if (g_strcmp0(args[0], "show") == 0) {
|
||||
ui_show_form(confwin);
|
||||
mucconfwin_show_form(confwin);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "help") == 0) {
|
||||
char *tag = args[1];
|
||||
if (tag) {
|
||||
ui_show_form_field_help(confwin, tag);
|
||||
mucconfwin_field_help(confwin, tag);
|
||||
} else {
|
||||
ui_show_form_help(confwin);
|
||||
mucconfwin_form_help(confwin);
|
||||
|
||||
const gchar **help_text = NULL;
|
||||
Command *command = g_hash_table_lookup(commands, "/form");
|
||||
|
@ -39,10 +39,10 @@
|
||||
#include "ui/win_types.h"
|
||||
#include "window_list.h"
|
||||
|
||||
static void _ui_handle_form_field(ProfWin *window, char *tag, FormField *field);
|
||||
static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field);
|
||||
|
||||
void
|
||||
ui_show_form(ProfMucConfWin *confwin)
|
||||
mucconfwin_show_form(ProfMucConfWin *confwin)
|
||||
{
|
||||
ProfWin *window = (ProfWin*) confwin;
|
||||
if (confwin->form->title) {
|
||||
@ -53,7 +53,7 @@ ui_show_form(ProfMucConfWin *confwin)
|
||||
}
|
||||
win_print(window, '-', 0, NULL, 0, 0, "", "");
|
||||
|
||||
ui_show_form_help(confwin);
|
||||
mucconfwin_form_help(confwin);
|
||||
|
||||
GSList *fields = confwin->form->fields;
|
||||
GSList *curr_field = fields;
|
||||
@ -67,7 +67,7 @@ ui_show_form(ProfMucConfWin *confwin)
|
||||
}
|
||||
} else if (g_strcmp0(field->type, "hidden") != 0 && field->var) {
|
||||
char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var);
|
||||
_ui_handle_form_field(window, tag, field);
|
||||
_mucconfwin_form_field(window, tag, field);
|
||||
}
|
||||
|
||||
curr_field = g_slist_next(curr_field);
|
||||
@ -75,22 +75,25 @@ ui_show_form(ProfMucConfWin *confwin)
|
||||
}
|
||||
|
||||
void
|
||||
ui_show_form_field(ProfWin *window, DataForm *form, char *tag)
|
||||
mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
FormField *field = form_get_field_by_tag(form, tag);
|
||||
_ui_handle_form_field(window, tag, field);
|
||||
ProfWin *window = (ProfWin*)confwin;
|
||||
_mucconfwin_form_field(window, tag, field);
|
||||
win_println(window, 0, "");
|
||||
}
|
||||
|
||||
void
|
||||
ui_handle_room_configuration(const char *const roomjid, DataForm *form)
|
||||
mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form)
|
||||
{
|
||||
ProfWin *window = wins_new_muc_config(roomjid, form);
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||
assert(confwin != NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)confwin;
|
||||
ui_focus_win(window);
|
||||
ui_show_form(confwin);
|
||||
|
||||
mucconfwin_show_form(confwin);
|
||||
|
||||
win_print(window, '-', 0, NULL, 0, 0, "", "");
|
||||
win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes.");
|
||||
@ -100,8 +103,10 @@ ui_handle_room_configuration(const char *const roomjid, DataForm *form)
|
||||
}
|
||||
|
||||
void
|
||||
ui_show_form_field_help(ProfMucConfWin *confwin, char *tag)
|
||||
mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*) confwin;
|
||||
FormField *field = form_get_field_by_tag(confwin->form, tag);
|
||||
if (field) {
|
||||
@ -181,8 +186,10 @@ ui_show_form_field_help(ProfMucConfWin *confwin, char *tag)
|
||||
}
|
||||
|
||||
void
|
||||
ui_show_form_help(ProfMucConfWin *confwin)
|
||||
mucconfwin_form_help(ProfMucConfWin *confwin)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
if (confwin->form->instructions) {
|
||||
ProfWin *window = (ProfWin*) confwin;
|
||||
win_print(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:");
|
||||
@ -192,7 +199,7 @@ ui_show_form_help(ProfMucConfWin *confwin)
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
_mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
{
|
||||
win_vprint(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag);
|
||||
win_vprint(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label);
|
||||
|
10
src/ui/ui.h
10
src/ui/ui.h
@ -108,14 +108,14 @@ void ui_handle_recipient_error(const char *const recipient, const char *const er
|
||||
void ui_handle_error(const char *const err_msg);
|
||||
void ui_clear_win_title(void);
|
||||
void ui_goodbye_title(void);
|
||||
void ui_handle_room_configuration(const char *const roomjid, DataForm *form);
|
||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||
void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message);
|
||||
void ui_handle_room_config_submit_result(const char *const roomjid);
|
||||
void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message);
|
||||
void ui_show_form(ProfMucConfWin *confwin);
|
||||
void ui_show_form_field(ProfWin *window, DataForm *form, char *tag);
|
||||
void ui_show_form_help(ProfMucConfWin *confwin);
|
||||
void ui_show_form_field_help(ProfMucConfWin *confwin, char *tag);
|
||||
void mucconfwin_show_form(ProfMucConfWin *confwin);
|
||||
void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag);
|
||||
void mucconfwin_form_help(ProfMucConfWin *confwin);
|
||||
void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag);
|
||||
void ui_show_lines(ProfWin *window, const gchar** lines);
|
||||
void ui_redraw_all_room_rosters(void);
|
||||
void ui_show_all_room_rosters(void);
|
||||
|
@ -1260,7 +1260,8 @@ _room_config_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
|
||||
}
|
||||
|
||||
DataForm *form = form_create(x);
|
||||
ui_handle_room_configuration(from, form);
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)wins_new_muc_config(from, form);
|
||||
mucconfwin_handle_configuration(confwin, form);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ void ui_handle_error(const char * const err_msg)
|
||||
|
||||
void ui_clear_win_title(void) {}
|
||||
void ui_goodbye_title(void) {}
|
||||
void ui_handle_room_configuration(const char * const roomjid, DataForm *form) {}
|
||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form) {}
|
||||
void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {}
|
||||
void ui_handle_room_config_submit_result(const char * const roomjid) {}
|
||||
void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {}
|
||||
@ -257,10 +257,10 @@ void mucwin_role_set_error(ProfMucWin *mucwin, const char * const nick, const ch
|
||||
void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const char * const error) {}
|
||||
void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {}
|
||||
void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {}
|
||||
void ui_show_form(ProfMucConfWin *confwin) {}
|
||||
void ui_show_form_field(ProfWin *window, DataForm *form, char *tag) {}
|
||||
void ui_show_form_help(ProfMucConfWin *confwin) {}
|
||||
void ui_show_form_field_help(ProfMucConfWin *confwin, char *tag) {}
|
||||
void mucconfwin_show_form(ProfMucConfWin *confwin) {}
|
||||
void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag) {}
|
||||
void mucconfwin_form_help(ProfMucConfWin *confwin) {}
|
||||
void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) {}
|
||||
void ui_show_lines(ProfWin *window, const gchar** lines) {}
|
||||
void ui_redraw_all_room_rosters(void) {}
|
||||
void ui_show_all_room_rosters(void) {}
|
||||
|
Loading…
Reference in New Issue
Block a user