mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 20:56:20 +00:00
Rename mucconf wins into conf wins
Configuration windows are now being used by both muc and cmd.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* mucconfwin.c
|
||||
* confwin.c
|
||||
*
|
||||
* Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
|
||||
*
|
||||
@@ -40,10 +40,10 @@
|
||||
#include "ui/win_types.h"
|
||||
#include "ui/window_list.h"
|
||||
|
||||
static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field);
|
||||
static void _confwin_form_field(ProfWin *window, char *tag, FormField *field);
|
||||
|
||||
void
|
||||
mucconfwin_show_form(ProfMucConfWin *confwin)
|
||||
confwin_show_form(ProfConfWin *confwin)
|
||||
{
|
||||
ProfWin *window = (ProfWin*) confwin;
|
||||
if (confwin->form->title) {
|
||||
@@ -54,7 +54,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin)
|
||||
}
|
||||
win_println(window, THEME_DEFAULT, '-', "");
|
||||
|
||||
mucconfwin_form_help(confwin);
|
||||
confwin_form_help(confwin);
|
||||
|
||||
GSList *fields = confwin->form->fields;
|
||||
GSList *curr_field = fields;
|
||||
@@ -68,7 +68,7 @@ mucconfwin_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);
|
||||
_mucconfwin_form_field(window, tag, field);
|
||||
_confwin_form_field(window, tag, field);
|
||||
}
|
||||
|
||||
curr_field = g_slist_next(curr_field);
|
||||
@@ -76,25 +76,25 @@ mucconfwin_show_form(ProfMucConfWin *confwin)
|
||||
}
|
||||
|
||||
void
|
||||
mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag)
|
||||
confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
FormField *field = form_get_field_by_tag(form, tag);
|
||||
ProfWin *window = (ProfWin*)confwin;
|
||||
_mucconfwin_form_field(window, tag, field);
|
||||
_confwin_form_field(window, tag, field);
|
||||
win_println(window, THEME_DEFAULT, '-', "");
|
||||
}
|
||||
|
||||
void
|
||||
mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form)
|
||||
confwin_handle_configuration(ProfConfWin *confwin, DataForm *form)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)confwin;
|
||||
ui_focus_win(window);
|
||||
|
||||
mucconfwin_show_form(confwin);
|
||||
confwin_show_form(confwin);
|
||||
|
||||
win_println(window, THEME_DEFAULT, '-', "");
|
||||
win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes.");
|
||||
@@ -104,7 +104,7 @@ mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form)
|
||||
}
|
||||
|
||||
void
|
||||
mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
|
||||
confwin_field_help(ProfConfWin *confwin, char *tag)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
@@ -187,7 +187,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
|
||||
}
|
||||
|
||||
void
|
||||
mucconfwin_form_help(ProfMucConfWin *confwin)
|
||||
confwin_form_help(ProfConfWin *confwin)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
@@ -200,7 +200,7 @@ mucconfwin_form_help(ProfMucConfWin *confwin)
|
||||
}
|
||||
|
||||
static void
|
||||
_mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
_confwin_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
{
|
||||
win_print(window, THEME_AWAY, '-', "[%s] ", tag);
|
||||
win_append(window, THEME_DEFAULT, "%s", field->label);
|
||||
@@ -331,7 +331,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
|
||||
}
|
||||
|
||||
char*
|
||||
mucconfwin_get_string(ProfMucConfWin *confwin)
|
||||
confwin_get_string(ProfConfWin *confwin)
|
||||
{
|
||||
assert(confwin != NULL);
|
||||
|
||||
@@ -1282,12 +1282,12 @@ cons_time_setting(void)
|
||||
cons_show("Time MUC (/time) : %s", pref_time_muc);
|
||||
prefs_free_string(pref_time_muc);
|
||||
|
||||
char *pref_time_mucconf = prefs_get_string(PREF_TIME_MUCCONFIG);
|
||||
if (g_strcmp0(pref_time_mucconf, "off") == 0)
|
||||
cons_show("Time MUC config (/time) : OFF");
|
||||
char *pref_time_conf = prefs_get_string(PREF_TIME_CONFIG);
|
||||
if (g_strcmp0(pref_time_conf, "off") == 0)
|
||||
cons_show("Time config (/time) : OFF");
|
||||
else
|
||||
cons_show("Time MUC config (/time) : %s", pref_time_mucconf);
|
||||
prefs_free_string(pref_time_mucconf);
|
||||
cons_show("Time config (/time) : %s", pref_time_conf);
|
||||
prefs_free_string(pref_time_conf);
|
||||
|
||||
char *pref_time_private = prefs_get_string(PREF_TIME_PRIVATE);
|
||||
if (g_strcmp0(pref_time_private, "off") == 0)
|
||||
|
||||
@@ -632,8 +632,8 @@ ui_win_has_unsaved_form(int num)
|
||||
{
|
||||
ProfWin *window = wins_get_by_num(num);
|
||||
|
||||
if (window->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
if (window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||
return confwin->form->modified;
|
||||
} else {
|
||||
@@ -651,13 +651,13 @@ ui_focus_win(ProfWin *window)
|
||||
}
|
||||
|
||||
ProfWin *old_current = wins_get_current();
|
||||
if (old_current->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)old_current;
|
||||
if (old_current->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*)old_current;
|
||||
cmd_ac_remove_form_fields(confwin->form);
|
||||
}
|
||||
|
||||
if (window->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
if (window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
cmd_ac_add_form_fields(confwin->form);
|
||||
}
|
||||
|
||||
@@ -681,8 +681,8 @@ void
|
||||
ui_close_win(int index)
|
||||
{
|
||||
ProfWin *window = wins_get_by_num(index);
|
||||
if (window && window->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
if (window && window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
if (confwin->form) {
|
||||
cmd_ac_remove_form_fields(confwin->form);
|
||||
}
|
||||
@@ -1135,7 +1135,7 @@ ui_handle_room_config_submit_result(const char *const roomjid)
|
||||
|
||||
GString *form_recipient = g_string_new(roomjid);
|
||||
g_string_append(form_recipient, " config");
|
||||
form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str);
|
||||
form_window = (ProfWin*) wins_get_conf(form_recipient->str);
|
||||
g_string_free(form_recipient, TRUE);
|
||||
|
||||
if (form_window) {
|
||||
@@ -1167,7 +1167,7 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char
|
||||
|
||||
GString *form_recipient = g_string_new(roomjid);
|
||||
g_string_append(form_recipient, " config");
|
||||
form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str);
|
||||
form_window = (ProfWin*) wins_get_conf(form_recipient->str);
|
||||
g_string_free(form_recipient, TRUE);
|
||||
|
||||
if (form_window) {
|
||||
|
||||
@@ -544,7 +544,7 @@ _display_name(StatusBarTab *tab)
|
||||
} else {
|
||||
fullname = strdup(tab->identifier);
|
||||
}
|
||||
} else if (tab->window_type == WIN_MUC_CONFIG) {
|
||||
} else if (tab->window_type == WIN_CONFIG) {
|
||||
char *pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
GString *display_str = g_string_new("");
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
|
||||
16
src/ui/ui.h
16
src/ui/ui.h
@@ -217,13 +217,13 @@ void privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const
|
||||
void privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||
void privwin_room_joined(ProfPrivateWin *privwin);
|
||||
|
||||
// MUC room config window
|
||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||
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);
|
||||
char* mucconfwin_get_string(ProfMucConfWin *confwin);
|
||||
// room config window
|
||||
void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form);
|
||||
void confwin_show_form(ProfConfWin *confwin);
|
||||
void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag);
|
||||
void confwin_form_help(ProfConfWin *confwin);
|
||||
void confwin_field_help(ProfConfWin *confwin, char *tag);
|
||||
char* confwin_get_string(ProfConfWin *confwin);
|
||||
|
||||
// xml console
|
||||
void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg);
|
||||
@@ -346,7 +346,7 @@ ProfWin* win_create_console(void);
|
||||
ProfWin* win_create_xmlconsole(void);
|
||||
ProfWin* win_create_chat(const char *const barejid);
|
||||
ProfWin* win_create_muc(const char *const roomjid);
|
||||
ProfWin* win_create_muc_config(const char *const title, DataForm *form);
|
||||
ProfWin* win_create_config(const char *const title, DataForm *form);
|
||||
ProfWin* win_create_private(const char *const fulljid);
|
||||
ProfWin* win_create_plugin(const char *const plugin_name, const char *const tag);
|
||||
void win_update_virtual(ProfWin *window);
|
||||
|
||||
@@ -128,7 +128,7 @@ typedef enum {
|
||||
WIN_CONSOLE,
|
||||
WIN_CHAT,
|
||||
WIN_MUC,
|
||||
WIN_MUC_CONFIG,
|
||||
WIN_CONFIG,
|
||||
WIN_PRIVATE,
|
||||
WIN_XML,
|
||||
WIN_PLUGIN
|
||||
@@ -172,12 +172,12 @@ typedef struct prof_muc_win_t {
|
||||
char *message_char;
|
||||
} ProfMucWin;
|
||||
|
||||
typedef struct prof_mucconf_win_t {
|
||||
typedef struct prof_conf_win_t {
|
||||
ProfWin window;
|
||||
char *roomjid;
|
||||
DataForm *form;
|
||||
unsigned long memcheck;
|
||||
} ProfMucConfWin;
|
||||
} ProfConfWin;
|
||||
|
||||
typedef struct prof_private_win_t {
|
||||
ProfWin window;
|
||||
|
||||
@@ -203,10 +203,10 @@ win_create_muc(const char *const roomjid)
|
||||
}
|
||||
|
||||
ProfWin*
|
||||
win_create_muc_config(const char *const roomjid, DataForm *form)
|
||||
win_create_config(const char *const roomjid, DataForm *form)
|
||||
{
|
||||
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
|
||||
new_win->window.type = WIN_MUC_CONFIG;
|
||||
ProfConfWin *new_win = malloc(sizeof(ProfConfWin));
|
||||
new_win->window.type = WIN_CONFIG;
|
||||
new_win->window.layout = _win_create_simple_layout();
|
||||
new_win->roomjid = strdup(roomjid);
|
||||
new_win->form = form;
|
||||
@@ -289,8 +289,8 @@ win_get_title(ProfWin *window)
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
return strdup(mucwin->roomjid);
|
||||
}
|
||||
if (window->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*) window;
|
||||
if (window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*) window;
|
||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||
GString *title = g_string_new(confwin->roomjid);
|
||||
g_string_append(title, " config");
|
||||
@@ -338,10 +338,10 @@ win_get_tab_identifier(ProfWin *window)
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
return strdup(mucwin->roomjid);
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
case WIN_CONFIG:
|
||||
{
|
||||
ProfMucConfWin *mucconfwin = (ProfMucConfWin*)window;
|
||||
return strdup(mucconfwin->roomjid);
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
return strdup(confwin->roomjid);
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
@@ -383,10 +383,10 @@ win_to_string(ProfWin *window)
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
return mucwin_get_string(mucwin);
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
case WIN_CONFIG:
|
||||
{
|
||||
ProfMucConfWin *mucconfwin = (ProfMucConfWin*)window;
|
||||
return mucconfwin_get_string(mucconfwin);
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
return confwin_get_string(confwin);
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
@@ -491,11 +491,11 @@ win_free(ProfWin* window)
|
||||
free(mucwin->message_char);
|
||||
break;
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
case WIN_CONFIG:
|
||||
{
|
||||
ProfMucConfWin *mucconf = (ProfMucConfWin*)window;
|
||||
free(mucconf->roomjid);
|
||||
form_destroy(mucconf->form);
|
||||
ProfConfWin *conf = (ProfConfWin*)window;
|
||||
free(conf->roomjid);
|
||||
form_destroy(conf->form);
|
||||
break;
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
@@ -1389,8 +1389,8 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim
|
||||
case WIN_MUC:
|
||||
time_pref = prefs_get_string(PREF_TIME_MUC);
|
||||
break;
|
||||
case WIN_MUC_CONFIG:
|
||||
time_pref = prefs_get_string(PREF_TIME_MUCCONFIG);
|
||||
case WIN_CONFIG:
|
||||
time_pref = prefs_get_string(PREF_TIME_CONFIG);
|
||||
break;
|
||||
case WIN_PRIVATE:
|
||||
time_pref = prefs_get_string(PREF_TIME_PRIVATE);
|
||||
|
||||
@@ -139,16 +139,16 @@ wins_get_chat_unsubscribed(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
ProfMucConfWin*
|
||||
wins_get_muc_conf(const char *const roomjid)
|
||||
ProfConfWin*
|
||||
wins_get_conf(const char *const roomjid)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
|
||||
while (curr) {
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_MUC_CONFIG) {
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
if (window->type == WIN_CONFIG) {
|
||||
ProfConfWin *confwin = (ProfConfWin*)window;
|
||||
if (g_strcmp0(confwin->roomjid, roomjid) == 0) {
|
||||
g_list_free(values);
|
||||
return confwin;
|
||||
@@ -584,7 +584,7 @@ wins_close_by_num(int i)
|
||||
autocomplete_remove(wins_close_ac, pluginwin->tag);
|
||||
break;
|
||||
}
|
||||
case WIN_MUC_CONFIG:
|
||||
case WIN_CONFIG:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -657,12 +657,12 @@ wins_new_muc(const char *const roomjid)
|
||||
}
|
||||
|
||||
ProfWin*
|
||||
wins_new_muc_config(const char *const roomjid, DataForm *form)
|
||||
wins_new_config(const char *const roomjid, DataForm *form)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = _wins_get_next_available_num(keys);
|
||||
g_list_free(keys);
|
||||
ProfWin *newwin = win_create_muc_config(roomjid, form);
|
||||
ProfWin *newwin = win_create_config(roomjid, form);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
return newwin;
|
||||
}
|
||||
@@ -812,7 +812,7 @@ wins_get_prune_wins(void)
|
||||
ProfWin *window = curr->data;
|
||||
if (win_unread(window) == 0 &&
|
||||
window->type != WIN_MUC &&
|
||||
window->type != WIN_MUC_CONFIG &&
|
||||
window->type != WIN_CONFIG &&
|
||||
window->type != WIN_XML &&
|
||||
window->type != WIN_CONSOLE) {
|
||||
result = g_slist_append(result, window);
|
||||
|
||||
@@ -42,7 +42,7 @@ void wins_init(void);
|
||||
ProfWin* wins_new_xmlconsole(void);
|
||||
ProfWin* wins_new_chat(const char *const barejid);
|
||||
ProfWin* wins_new_muc(const char *const roomjid);
|
||||
ProfWin* wins_new_muc_config(const char *const roomjid, DataForm *form);
|
||||
ProfWin* wins_new_config(const char *const roomjid, DataForm *form);
|
||||
ProfWin* wins_new_private(const char *const fulljid);
|
||||
ProfWin* wins_new_plugin(const char *const plugin_name, const char *const tag);
|
||||
|
||||
@@ -56,7 +56,7 @@ ProfWin* wins_get_console(void);
|
||||
ProfChatWin* wins_get_chat(const char *const barejid);
|
||||
GList* wins_get_chat_unsubscribed(void);
|
||||
ProfMucWin* wins_get_muc(const char *const roomjid);
|
||||
ProfMucConfWin* wins_get_muc_conf(const char *const roomjid);
|
||||
ProfConfWin* wins_get_conf(const char *const roomjid);
|
||||
ProfPrivateWin* wins_get_private(const char *const fulljid);
|
||||
ProfPluginWin* wins_get_plugin(const char *const tag);
|
||||
ProfXMLWin* wins_get_xmlconsole(void);
|
||||
|
||||
Reference in New Issue
Block a user