1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Use class instead of base pointer

This commit is contained in:
James Booth 2014-12-21 19:40:15 +00:00
parent 13f73a30e7
commit 9a322a028f
6 changed files with 187 additions and 171 deletions

View File

@ -1605,11 +1605,12 @@ cmd_status(gchar **args, struct cmd_help_t help)
case WIN_MUC:
if (usr != NULL) {
ProfMucWin *mucwin = wins_get_current_muc();
ProfWin *window = (ProfWin*) mucwin;
Occupant *occupant = muc_roster_item(mucwin->roomjid, usr);
if (occupant) {
win_show_occupant(&mucwin->super, occupant);
win_show_occupant(window, occupant);
} else {
win_save_vprint(&mucwin->super, '-', NULL, 0, 0, "", "No such participant \"%s\" in room.", usr);
win_save_vprint(window, '-', NULL, 0, 0, "", "No such participant \"%s\" in room.", usr);
}
} else {
ui_current_print_line("You must specify a nickname.");
@ -1620,11 +1621,12 @@ cmd_status(gchar **args, struct cmd_help_t help)
ui_current_print_line("No parameter required when in chat.");
} else {
ProfChatWin *chatwin = wins_get_current_chat();
ProfWin *window = (ProfWin*) chatwin;
PContact pcontact = roster_get_contact(chatwin->barejid);
if (pcontact != NULL) {
win_show_contact(&chatwin->super, pcontact);
win_show_contact(window, pcontact);
} else {
win_save_println(&chatwin->super, "Error getting contact info.");
win_save_println(window, "Error getting contact info.");
}
}
break;
@ -1633,12 +1635,13 @@ cmd_status(gchar **args, struct cmd_help_t help)
ui_current_print_line("No parameter required when in chat.");
} else {
ProfPrivateWin *privatewin = wins_get_current_private();
ProfWin *window = (ProfWin*) privatewin;
Jid *jid = jid_create(privatewin->fulljid);
Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart);
if (occupant) {
win_show_occupant(&privatewin->super, occupant);
win_show_occupant(window, occupant);
} else {
win_save_println(&privatewin->super, "Error getting contact info.");
win_save_println(window, "Error getting contact info.");
}
jid_destroy(jid);
}
@ -1700,11 +1703,12 @@ cmd_info(gchar **args, struct cmd_help_t help)
ui_current_print_line("No parameter required when in chat.");
} else {
ProfChatWin *chatwin = wins_get_current_chat();
ProfWin *window = (ProfWin*) chatwin;
PContact pcontact = roster_get_contact(chatwin->barejid);
if (pcontact != NULL) {
win_show_info(&chatwin->super, pcontact);
win_show_info(window, pcontact);
} else {
win_save_println(&chatwin->super, "Error getting contact info.");
win_save_println(window, "Error getting contact info.");
}
}
break;
@ -1713,12 +1717,13 @@ cmd_info(gchar **args, struct cmd_help_t help)
ui_current_print_line("No parameter required when in chat.");
} else {
ProfPrivateWin *privatewin = wins_get_current_private();
ProfWin *window = (ProfWin*) privatewin;
Jid *jid = jid_create(privatewin->fulljid);
Occupant *occupant = muc_roster_item(jid->barejid, jid->resourcepart);
if (occupant) {
win_show_occupant_info(&privatewin->super, jid->barejid, occupant);
win_show_occupant_info(window, jid->barejid, occupant);
} else {
win_save_println(&privatewin->super, "Error getting contact info.");
win_save_println(window, "Error getting contact info.");
}
jid_destroy(jid);
}
@ -2278,7 +2283,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
help_text = command->help.long_help;
}
ui_show_lines(&confwin->super, help_text);
ui_show_lines((ProfWin*) confwin, help_text);
}
ui_current_print_line("");
return TRUE;
@ -2338,7 +2343,7 @@ cmd_kick(gchar **args, struct cmd_help_t help)
char *reason = args[1];
iq_room_kick_occupant(mucwin->roomjid, nick, reason);
} else {
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", "Occupant does not exist: %s", nick);
win_save_vprint((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Occupant does not exist: %s", nick);
}
} else {
cons_show("Usage: %s", help.usage);
@ -2392,14 +2397,15 @@ cmd_subject(gchar **args, struct cmd_help_t help)
}
ProfMucWin *mucwin = wins_get_current_muc();
ProfWin *window = (ProfWin*) mucwin;
if (args[0] == NULL) {
char *subject = muc_subject(mucwin->roomjid);
if (subject) {
win_save_vprint(&mucwin->super, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_save_vprint(&mucwin->super, '!', NULL, NO_DATE, 0, "", "%s", subject);
win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject);
} else {
win_save_print(&mucwin->super, '!', NULL, 0, THEME_ROOMINFO, "", "Room has no subject");
win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room has no subject");
}
return TRUE;
}
@ -2464,7 +2470,7 @@ cmd_affiliation(gchar **args, struct cmd_help_t help)
iq_room_affiliation_list(mucwin->roomjid, "member");
iq_room_affiliation_list(mucwin->roomjid, "outcast");
} else if (g_strcmp0(affiliation, "none") == 0) {
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Cannot list users with no affiliation.");
win_save_print((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Cannot list users with no affiliation.");
} else {
iq_room_affiliation_list(mucwin->roomjid, affiliation);
}
@ -2532,7 +2538,7 @@ cmd_role(gchar **args, struct cmd_help_t help)
iq_room_role_list(mucwin->roomjid, "participant");
iq_room_role_list(mucwin->roomjid, "visitor");
} else if (g_strcmp0(role, "none") == 0) {
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Cannot list users with no role.");
win_save_print((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Cannot list users with no role.");
} else {
iq_room_role_list(mucwin->roomjid, role);
}
@ -2584,7 +2590,8 @@ cmd_room(gchar **args, struct cmd_help_t help)
}
ProfMucWin *mucwin = wins_get_current_muc();
int num = wins_get_num(&mucwin->super);
ProfWin *window = (ProfWin*) mucwin;
int num = wins_get_num(window);
int ui_index = num;
if (ui_index == 10) {
@ -2594,12 +2601,12 @@ cmd_room(gchar **args, struct cmd_help_t help)
if (g_strcmp0(args[0], "accept") == 0) {
gboolean requires_config = muc_requires_config(mucwin->roomjid);
if (!requires_config) {
win_save_print(&mucwin->super, '!', NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration.");
win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration.");
return TRUE;
} else {
iq_confirm_instant_room(mucwin->roomjid);
muc_set_requires_config(mucwin->roomjid, FALSE);
win_save_print(&mucwin->super, '!', NULL, 0, THEME_ROOMINFO, "", "Room unlocked.");
win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room unlocked.");
return TRUE;
}
}
@ -2616,7 +2623,7 @@ cmd_room(gchar **args, struct cmd_help_t help)
g_string_free(win_title, TRUE);
if (confwin != NULL) {
num = wins_get_num(&confwin->super);
num = wins_get_num(window);
ui_switch_win(num);
} else {
iq_request_room_config_form(mucwin->roomjid);

View File

@ -270,6 +270,7 @@ static void
_ui_contact_typing(const char * const barejid)
{
ProfChatWin *chatwin = wins_get_chat(barejid);
ProfWin *window = (ProfWin*) chatwin;
if (prefs_get_boolean(PREF_INTYPE)) {
// no chat window for user
@ -277,22 +278,22 @@ _ui_contact_typing(const char * const barejid)
cons_show_typing(barejid);
// have chat window but not currently in it
} else if (!wins_is_current(&chatwin->super)) {
} else if (!wins_is_current(window)) {
cons_show_typing(barejid);
// in chat window with user
} else {
title_bar_set_typing(TRUE);
int num = wins_get_num(&chatwin->super);
int num = wins_get_num(window);
status_bar_active(num);
}
}
if (prefs_get_boolean(PREF_NOTIFY_TYPING)) {
gboolean is_current = FALSE;
if (&chatwin->super != NULL) {
is_current = wins_is_current(&chatwin->super);
if (window) {
is_current = wins_is_current(window);
}
if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT)) ) {
PContact contact = roster_get_contact(barejid);
@ -349,11 +350,13 @@ _ui_incoming_msg(const char * const barejid, const char * const message, GTimeVa
win_created = TRUE;
}
int num = wins_get_num(&chatwin->super);
ProfWin *window = (ProfWin*) chatwin;
int num = wins_get_num(window);
// currently viewing chat window with sender
if (wins_is_current(&chatwin->super)) {
win_print_incoming_message(&chatwin->super, tv_stamp, display_from, message);
if (wins_is_current(window)) {
win_print_incoming_message(window, tv_stamp, display_from, message);
title_bar_set_typing(FALSE);
status_bar_active(num);
@ -366,7 +369,7 @@ _ui_incoming_msg(const char * const barejid, const char * const message, GTimeVa
flash();
}
chatwin->super.unread++;
window->unread++;
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
_win_show_history(num, barejid);
}
@ -375,11 +378,11 @@ _ui_incoming_msg(const char * const barejid, const char * const message, GTimeVa
if ((tv_stamp != NULL) && (win_created)) {
PContact pcontact = roster_get_contact(barejid);
if (pcontact != NULL) {
win_show_contact(&chatwin->super, pcontact);
win_show_contact(window, pcontact);
}
}
win_print_incoming_message(&chatwin->super, tv_stamp, display_from, message);
win_print_incoming_message(window, tv_stamp, display_from, message);
}
int ui_index = num;
@ -392,7 +395,7 @@ _ui_incoming_msg(const char * const barejid, const char * const message, GTimeVa
}
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
gboolean is_current = wins_is_current(&chatwin->super);
gboolean is_current = wins_is_current(window);
if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
notify_message(display_from, ui_index, message);
@ -417,11 +420,12 @@ _ui_incoming_private_msg(const char * const fulljid, const char * const message,
privatewin = (ProfPrivateWin*)window;
}
int num = wins_get_num(&privatewin->super);
ProfWin *window = (ProfWin*) privatewin;
int num = wins_get_num(window);
// currently viewing chat window with sender
if (wins_is_current(&privatewin->super)) {
win_print_incoming_message(&privatewin->super, tv_stamp, display_from, message);
if (wins_is_current(window)) {
win_print_incoming_message(window, tv_stamp, display_from, message);
title_bar_set_typing(FALSE);
status_bar_active(num);
@ -434,12 +438,12 @@ _ui_incoming_private_msg(const char * const fulljid, const char * const message,
flash();
}
privatewin->super.unread++;
window->unread++;
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
_win_show_history(num, fulljid);
}
win_print_incoming_message(&privatewin->super, tv_stamp, display_from, message);
win_print_incoming_message(window, tv_stamp, display_from, message);
}
int ui_index = num;
@ -452,7 +456,7 @@ _ui_incoming_private_msg(const char * const fulljid, const char * const message,
}
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
gboolean is_current = wins_is_current(&privatewin->super);
gboolean is_current = wins_is_current(window);
if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
notify_message(display_from, ui_index, message);
@ -580,8 +584,7 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
ProfChatWin *chatwin = wins_get_chat(recipient);
if (chatwin) {
cons_show_error("Recipient %s not found: %s", recipient, err_msg);
// TODO change super references to superclass cast
win_save_vprint(&chatwin->super, '!', NULL, 0, THEME_ERROR, "", "Recipient %s not found: %s", recipient, err_msg);
win_save_vprint((ProfWin*) chatwin, '!', NULL, 0, THEME_ERROR, "", "Recipient %s not found: %s", recipient, err_msg);
return;
}
@ -589,7 +592,7 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
ProfMucWin *mucwin = wins_get_muc(recipient);
if (mucwin) {
cons_show_error("Room %s not found: %s", recipient, err_msg);
win_save_vprint(&mucwin->super, '!', NULL, 0, THEME_ERROR, "", "Room %s not found: %s", recipient, err_msg);
win_save_vprint((ProfWin*) mucwin, '!', NULL, 0, THEME_ERROR, "", "Room %s not found: %s", recipient, err_msg);
return;
}
@ -597,7 +600,7 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
ProfPrivateWin *privatewin = wins_get_private(recipient);
if (privatewin) {
cons_show_error("Recipient %s not found: %s", recipient, err_msg);
win_save_vprint(&privatewin->super, '!', NULL, 0, THEME_ERROR, "", "Recipient %s not found: %s", recipient, err_msg);
win_save_vprint((ProfWin*) privatewin, '!', NULL, 0, THEME_ERROR, "", "Recipient %s not found: %s", recipient, err_msg);
return;
}
@ -2342,42 +2345,44 @@ _ui_show_room_info(ProfMucWin *mucwin)
char *role = muc_role_str(mucwin->roomjid);
char *affiliation = muc_affiliation_str(mucwin->roomjid);
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", "Room: %s", mucwin->roomjid);
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", "Affiliation: %s", affiliation);
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", "Role: %s", role);
win_save_print(&mucwin->super, '-', NULL, 0, 0, "", "");
ProfWin *window = (ProfWin*) mucwin;
win_save_vprint(window, '!', NULL, 0, 0, "", "Room: %s", mucwin->roomjid);
win_save_vprint(window, '!', NULL, 0, 0, "", "Affiliation: %s", affiliation);
win_save_vprint(window, '!', NULL, 0, 0, "", "Role: %s", role);
win_save_print(window, '-', NULL, 0, 0, "", "");
}
static void
_ui_show_room_role_list(ProfMucWin *mucwin, muc_role_t role)
{
ProfWin *window = (ProfWin*) mucwin;
GSList *occupants = muc_occupants_by_role(mucwin->roomjid, role);
if (!occupants) {
switch (role) {
case MUC_ROLE_MODERATOR:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No moderators found.");
win_save_print(window, '!', NULL, 0, 0, "", "No moderators found.");
break;
case MUC_ROLE_PARTICIPANT:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No participants found.");
win_save_print(window, '!', NULL, 0, 0, "", "No participants found.");
break;
case MUC_ROLE_VISITOR:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No visitors found.");
win_save_print(window, '!', NULL, 0, 0, "", "No visitors found.");
break;
default:
break;
}
win_save_print(&mucwin->super, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, 0, 0, "", "");
} else {
switch (role) {
case MUC_ROLE_MODERATOR:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Moderators:");
win_save_print(window, '!', NULL, 0, 0, "", "Moderators:");
break;
case MUC_ROLE_PARTICIPANT:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Participants:");
win_save_print(window, '!', NULL, 0, 0, "", "Participants:");
break;
case MUC_ROLE_VISITOR:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Visitors:");
win_save_print(window, '!', NULL, 0, 0, "", "Visitors:");
break;
default:
break;
@ -2388,55 +2393,56 @@ _ui_show_room_role_list(ProfMucWin *mucwin, muc_role_t role)
Occupant *occupant = curr_occupant->data;
if (occupant->role == role) {
if (occupant->jid) {
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid);
win_save_vprint(window, '!', NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid);
} else {
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", " %s", occupant->nick);
win_save_vprint(window, '!', NULL, 0, 0, "", " %s", occupant->nick);
}
}
curr_occupant = g_slist_next(curr_occupant);
}
win_save_print(&mucwin->super, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, 0, 0, "", "");
}
}
static void
_ui_show_room_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation)
{
ProfWin *window = (ProfWin*) mucwin;
GSList *occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation);
if (!occupants) {
switch (affiliation) {
case MUC_AFFILIATION_OWNER:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No owners found.");
win_save_print(window, '!', NULL, 0, 0, "", "No owners found.");
break;
case MUC_AFFILIATION_ADMIN:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No admins found.");
win_save_print(window, '!', NULL, 0, 0, "", "No admins found.");
break;
case MUC_AFFILIATION_MEMBER:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No members found.");
win_save_print(window, '!', NULL, 0, 0, "", "No members found.");
break;
case MUC_AFFILIATION_OUTCAST:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "No outcasts found.");
win_save_print(window, '!', NULL, 0, 0, "", "No outcasts found.");
break;
default:
break;
}
win_save_print(&mucwin->super, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, 0, 0, "", "");
} else {
switch (affiliation) {
case MUC_AFFILIATION_OWNER:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Owners:");
win_save_print(window, '!', NULL, 0, 0, "", "Owners:");
break;
case MUC_AFFILIATION_ADMIN:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Admins:");
win_save_print(window, '!', NULL, 0, 0, "", "Admins:");
break;
case MUC_AFFILIATION_MEMBER:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Members:");
win_save_print(window, '!', NULL, 0, 0, "", "Members:");
break;
case MUC_AFFILIATION_OUTCAST:
win_save_print(&mucwin->super, '!', NULL, 0, 0, "", "Outcasts:");
win_save_print(window, '!', NULL, 0, 0, "", "Outcasts:");
break;
default:
break;
@ -2447,16 +2453,16 @@ _ui_show_room_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation
Occupant *occupant = curr_occupant->data;
if (occupant->affiliation == affiliation) {
if (occupant->jid) {
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid);
win_save_vprint(window, '!', NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid);
} else {
win_save_vprint(&mucwin->super, '!', NULL, 0, 0, "", " %s", occupant->nick);
win_save_vprint(window, '!', NULL, 0, 0, "", " %s", occupant->nick);
}
}
curr_occupant = g_slist_next(curr_occupant);
}
win_save_print(&mucwin->super, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, 0, 0, "", "");
}
}
@ -2594,16 +2600,17 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
static void
_ui_show_form(ProfMucConfWin *confwin)
{
ProfWin *window = (ProfWin*) confwin;
if (confwin->form->title != NULL) {
win_save_print(&confwin->super, '-', NULL, NO_EOL, 0, "", "Form title: ");
win_save_print(&confwin->super, '-', NULL, NO_DATE, 0, "", confwin->form->title);
win_save_print(window, '-', NULL, NO_EOL, 0, "", "Form title: ");
win_save_print(window, '-', NULL, NO_DATE, 0, "", confwin->form->title);
} else {
gchar **split_recipient = g_strsplit(confwin->from, " ", 2);
char *roomjid = split_recipient[0];
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", "Configuration for room %s.", roomjid);
win_save_vprint(window, '-', NULL, 0, 0, "", "Configuration for room %s.", roomjid);
g_strfreev(split_recipient);
}
win_save_print(&confwin->super, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, 0, 0, "", "");
ui_show_form_help(confwin);
@ -2615,11 +2622,11 @@ _ui_show_form(ProfMucConfWin *confwin)
if ((g_strcmp0(field->type, "fixed") == 0) && field->values) {
if (field->values) {
char *value = field->values->data;
win_save_print(&confwin->super, '-', NULL, 0, 0, "", value);
win_save_print(window, '-', NULL, 0, 0, "", value);
}
} 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(&confwin->super, tag, field);
_ui_handle_form_field(window, tag, field);
}
curr_field = g_slist_next(curr_field);
@ -2755,18 +2762,19 @@ _ui_handle_room_config_submit_result_error(const char * const roomjid, const cha
static void
_ui_show_form_field_help(ProfMucConfWin *confwin, char *tag)
{
ProfWin *window = (ProfWin*) confwin;
FormField *field = form_get_field_by_tag(confwin->form, tag);
if (field != NULL) {
win_save_print(&confwin->super, '-', NULL, NO_EOL, 0, "", field->label);
win_save_print(window, '-', NULL, NO_EOL, 0, "", field->label);
if (field->required) {
win_save_print(&confwin->super, '-', NULL, NO_DATE, 0, "", " (Required):");
win_save_print(window, '-', NULL, NO_DATE, 0, "", " (Required):");
} else {
win_save_print(&confwin->super, '-', NULL, NO_DATE, 0, "", ":");
win_save_print(window, '-', NULL, NO_DATE, 0, "", ":");
}
if (field->description != NULL) {
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Description : %s", field->description);
win_save_vprint(window, '-', NULL, 0, 0, "", " Description : %s", field->description);
}
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Type : %s", field->type);
win_save_vprint(window, '-', NULL, 0, 0, "", " Type : %s", field->type);
int num_values = 0;
GSList *curr_option = NULL;
@ -2775,51 +2783,51 @@ _ui_show_form_field_help(ProfMucConfWin *confwin, char *tag)
switch (field->type_t) {
case FIELD_TEXT_SINGLE:
case FIELD_TEXT_PRIVATE:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is any text");
win_save_vprint(window, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is any text");
break;
case FIELD_TEXT_MULTI:
num_values = form_get_value_count(confwin->form, tag);
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is any text");
win_save_vprint(window, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is any text");
if (num_values > 0) {
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> between 'val1' and 'val%d'", num_values);
win_save_vprint(window, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_vprint(window, '-', NULL, 0, 0, "", " Where : <value> between 'val1' and 'val%d'", num_values);
}
break;
case FIELD_BOOLEAN:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is either 'on' or 'off'");
win_save_vprint(window, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is either 'on' or 'off'");
break;
case FIELD_LIST_SINGLE:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is one of");
win_save_vprint(window, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is one of");
curr_option = field->options;
while (curr_option != NULL) {
option = curr_option->data;
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " %s", option->value);
win_save_vprint(window, '-', NULL, 0, 0, "", " %s", option->value);
curr_option = g_slist_next(curr_option);
}
break;
case FIELD_LIST_MULTI:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is one of");
win_save_vprint(window, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_vprint(window, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is one of");
curr_option = field->options;
while (curr_option != NULL) {
option = curr_option->data;
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " %s", option->value);
win_save_vprint(window, '-', NULL, 0, 0, "", " %s", option->value);
curr_option = g_slist_next(curr_option);
}
break;
case FIELD_JID_SINGLE:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is a valid Jabber ID");
win_save_vprint(window, '-', NULL, 0, 0, "", " Set : /%s <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is a valid Jabber ID");
break;
case FIELD_JID_MULTI:
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", " Where : <value> is a valid Jabber ID");
win_save_vprint(window, '-', NULL, 0, 0, "", " Add : /%s add <value>", tag);
win_save_vprint(window, '-', NULL, 0, 0, "", " Remove : /%s remove <value>", tag);
win_save_print(window, '-', NULL, 0, 0, "", " Where : <value> is a valid Jabber ID");
break;
case FIELD_FIXED:
case FIELD_UNKNOWN:
@ -2828,7 +2836,7 @@ _ui_show_form_field_help(ProfMucConfWin *confwin, char *tag)
break;
}
} else {
win_save_vprint(&confwin->super, '-', NULL, 0, 0, "", "No such field %s", tag);
win_save_vprint(window, '-', NULL, 0, 0, "", "No such field %s", tag);
}
}
@ -2836,9 +2844,10 @@ static void
_ui_show_form_help(ProfMucConfWin *confwin)
{
if (confwin->form->instructions != NULL) {
win_save_print(&confwin->super, '-', NULL, 0, 0, "", "Supplied instructions:");
win_save_print(&confwin->super, '-', NULL, 0, 0, "", confwin->form->instructions);
win_save_print(&confwin->super, '-', NULL, 0, 0, "", "");
ProfWin *window = (ProfWin*) confwin;
win_save_print(window, '-', NULL, 0, 0, "", "Supplied instructions:");
win_save_print(window, '-', NULL, 0, 0, "", confwin->form->instructions);
win_save_print(window, '-', NULL, 0, 0, "", "");
}
}

View File

@ -61,7 +61,7 @@ _occupantswin_occupants(const char * const roomjid)
if (mucwin) {
GList *occupants = muc_roster(roomjid);
if (occupants) {
ProfLayoutSplit *layout = (ProfLayoutSplit*)mucwin->super.layout;
ProfLayoutSplit *layout = (ProfLayoutSplit*)mucwin->window.layout;
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
werase(layout->subwin);

View File

@ -83,15 +83,15 @@ _win_create_simple_layout(void)
int cols = getmaxx(stdscr);
ProfLayoutSimple *layout = malloc(sizeof(ProfLayoutSimple));
layout->super.type = LAYOUT_SIMPLE;
layout->super.win = newpad(PAD_SIZE, cols);
wbkgd(layout->super.win, theme_attrs(THEME_TEXT));
layout->super.buffer = buffer_create();
layout->super.y_pos = 0;
layout->super.paged = 0;
scrollok(layout->super.win, TRUE);
layout->base.type = LAYOUT_SIMPLE;
layout->base.win = newpad(PAD_SIZE, cols);
wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
scrollok(layout->base.win, TRUE);
return &layout->super;
return &layout->base;
}
static ProfLayout*
@ -100,40 +100,40 @@ _win_create_split_layout(void)
int cols = getmaxx(stdscr);
ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit));
layout->super.type = LAYOUT_SPLIT;
layout->super.win = newpad(PAD_SIZE, cols);
wbkgd(layout->super.win, theme_attrs(THEME_TEXT));
layout->super.buffer = buffer_create();
layout->super.y_pos = 0;
layout->super.paged = 0;
scrollok(layout->super.win, TRUE);
layout->base.type = LAYOUT_SPLIT;
layout->base.win = newpad(PAD_SIZE, cols);
wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
scrollok(layout->base.win, TRUE);
layout->subwin = NULL;
layout->sub_y_pos = 0;
layout->memcheck = LAYOUT_SPLIT_MEMCHECK;
return &layout->super;
return &layout->base;
}
ProfWin*
win_create_console(void)
{
ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin));
new_win->super.type = WIN_CONSOLE;
new_win->super.layout = _win_create_split_layout();
new_win->super.unread = 0;
new_win->window.type = WIN_CONSOLE;
new_win->window.layout = _win_create_split_layout();
new_win->window.unread = 0;
new_win->from = strdup(CONS_WIN_TITLE);
return &new_win->super;
return &new_win->window;
}
ProfWin*
win_create_chat(const char * const barejid)
{
ProfChatWin *new_win = malloc(sizeof(ProfChatWin));
new_win->super.type = WIN_CHAT;
new_win->super.layout = _win_create_simple_layout();
new_win->super.unread = 0;
new_win->window.type = WIN_CHAT;
new_win->window.layout = _win_create_simple_layout();
new_win->window.unread = 0;
new_win->barejid = strdup(barejid);
new_win->resource = NULL;
@ -143,7 +143,7 @@ win_create_chat(const char * const barejid)
new_win->memcheck = PROFCHATWIN_MEMCHECK;
return &new_win->super;
return &new_win->window;
}
ProfWin*
@ -152,80 +152,80 @@ win_create_muc(const char * const roomjid)
ProfMucWin *new_win = malloc(sizeof(ProfMucWin));
int cols = getmaxx(stdscr);
new_win->super.type = WIN_MUC;
new_win->window.type = WIN_MUC;
ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit));
layout->super.type = LAYOUT_SPLIT;
layout->base.type = LAYOUT_SPLIT;
if (prefs_get_boolean(PREF_OCCUPANTS)) {
int subwin_cols = win_occpuants_cols();
layout->super.win = newpad(PAD_SIZE, cols - subwin_cols);
wbkgd(layout->super.win, theme_attrs(THEME_TEXT));
layout->base.win = newpad(PAD_SIZE, cols - subwin_cols);
wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
layout->subwin = newpad(PAD_SIZE, subwin_cols);;
wbkgd(layout->subwin, theme_attrs(THEME_TEXT));
} else {
layout->super.win = newpad(PAD_SIZE, (cols));
wbkgd(layout->super.win, theme_attrs(THEME_TEXT));
layout->base.win = newpad(PAD_SIZE, (cols));
wbkgd(layout->base.win, theme_attrs(THEME_TEXT));
layout->subwin = NULL;
}
layout->sub_y_pos = 0;
layout->memcheck = LAYOUT_SPLIT_MEMCHECK;
layout->super.buffer = buffer_create();
layout->super.y_pos = 0;
layout->super.paged = 0;
scrollok(layout->super.win, TRUE);
new_win->super.layout = (ProfLayout*)layout;
layout->base.buffer = buffer_create();
layout->base.y_pos = 0;
layout->base.paged = 0;
scrollok(layout->base.win, TRUE);
new_win->window.layout = (ProfLayout*)layout;
new_win->roomjid = strdup(roomjid);
new_win->super.unread = 0;
new_win->window.unread = 0;
new_win->memcheck = PROFMUCWIN_MEMCHECK;
return &new_win->super;
return &new_win->window;
}
ProfWin*
win_create_muc_config(const char * const title, DataForm *form)
{
ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin));
new_win->super.type = WIN_MUC_CONFIG;
new_win->super.layout = _win_create_simple_layout();
new_win->super.unread = 0;
new_win->window.type = WIN_MUC_CONFIG;
new_win->window.layout = _win_create_simple_layout();
new_win->window.unread = 0;
new_win->from = strdup(title);
new_win->form = form;
new_win->memcheck = PROFCONFWIN_MEMCHECK;
return &new_win->super;
return &new_win->window;
}
ProfWin*
win_create_private(const char * const fulljid)
{
ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin));
new_win->super.type = WIN_PRIVATE;
new_win->super.layout = _win_create_simple_layout();
new_win->super.unread = 0;
new_win->window.type = WIN_PRIVATE;
new_win->window.layout = _win_create_simple_layout();
new_win->window.unread = 0;
new_win->fulljid = strdup(fulljid);
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
return &new_win->super;
return &new_win->window;
}
ProfWin*
win_create_xmlconsole(void)
{
ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin));
new_win->super.type = WIN_XML;
new_win->super.layout = _win_create_simple_layout();
new_win->super.unread = 0;
new_win->window.type = WIN_XML;
new_win->window.layout = _win_create_simple_layout();
new_win->window.unread = 0;
new_win->from = strdup(XML_WIN_TITLE);
return &new_win->super;
return &new_win->window;
}
void
@ -239,7 +239,7 @@ win_hide_subwin(ProfWin *window)
layout->subwin = NULL;
layout->sub_y_pos = 0;
int cols = getmaxx(stdscr);
wresize(layout->super.win, PAD_SIZE, cols);
wresize(layout->base.win, PAD_SIZE, cols);
win_redraw(window);
} else {
int cols = getmaxx(stdscr);
@ -267,7 +267,7 @@ win_show_subwin(ProfWin *window)
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
layout->subwin = newpad(PAD_SIZE, subwin_cols);
wbkgd(layout->subwin, theme_attrs(THEME_TEXT));
wresize(layout->super.win, PAD_SIZE, cols - subwin_cols);
wresize(layout->base.win, PAD_SIZE, cols - subwin_cols);
win_redraw(window);
}
@ -279,8 +279,8 @@ win_free(ProfWin* window)
if (layout->subwin) {
delwin(layout->subwin);
}
buffer_free(layout->super.buffer);
delwin(layout->super.win);
buffer_free(layout->base.buffer);
delwin(layout->base.win);
} else {
buffer_free(window->layout->buffer);
delwin(window->layout->win);
@ -374,10 +374,10 @@ win_update_virtual(ProfWin *window)
} else {
subwin_cols = win_roster_cols();
}
pnoutrefresh(layout->super.win, layout->super.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
} else {
pnoutrefresh(layout->super.win, layout->super.y_pos, 0, 1, 0, rows-3, cols-1);
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1);
}
} else {
pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1);

View File

@ -76,11 +76,11 @@ typedef struct prof_layout_t {
} ProfLayout;
typedef struct prof_layout_simple_t {
ProfLayout super;
ProfLayout base;
} ProfLayoutSimple;
typedef struct prof_layout_split_t {
ProfLayout super;
ProfLayout base;
WINDOW *subwin;
int sub_y_pos;
unsigned long memcheck;
@ -102,12 +102,12 @@ typedef struct prof_win_t {
} ProfWin;
typedef struct prof_console_win_t {
ProfWin super;
ProfWin window;
char *from;
} ProfConsoleWin;
typedef struct prof_chat_win_t {
ProfWin super;
ProfWin window;
char *barejid;
gboolean is_otr;
gboolean is_trusted;
@ -117,26 +117,26 @@ typedef struct prof_chat_win_t {
} ProfChatWin;
typedef struct prof_muc_win_t {
ProfWin super;
ProfWin window;
char *roomjid;
unsigned long memcheck;
} ProfMucWin;
typedef struct prof_mucconf_win_t {
ProfWin super;
ProfWin window;
char *from;
DataForm *form;
unsigned long memcheck;
} ProfMucConfWin;
typedef struct prof_private_win_t {
ProfWin super;
ProfWin window;
char *fulljid;
unsigned long memcheck;
} ProfPrivateWin;
typedef struct prof_xml_win_t {
ProfWin super;
ProfWin window;
char *from;
} ProfXMLWin;

View File

@ -505,11 +505,11 @@ wins_resize_all(void)
} else if (window->type == WIN_MUC) {
subwin_cols = win_occpuants_cols();
}
wresize(layout->super.win, PAD_SIZE, cols - subwin_cols);
wresize(layout->base.win, PAD_SIZE, cols - subwin_cols);
wresize(layout->subwin, PAD_SIZE, subwin_cols);
rosterwin_roster();
} else {
wresize(layout->super.win, PAD_SIZE, cols);
wresize(layout->base.win, PAD_SIZE, cols);
}
} else {
wresize(window->layout->win, PAD_SIZE, cols);
@ -551,12 +551,12 @@ wins_show_subwin(ProfWin *window)
if (current_win->type == WIN_MUC) {
ProfLayoutSplit *layout = (ProfLayoutSplit*)current_win->layout;
subwin_cols = win_occpuants_cols();
pnoutrefresh(layout->super.win, layout->super.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
} else if (current_win->type == WIN_CONSOLE) {
ProfLayoutSplit *layout = (ProfLayoutSplit*)current_win->layout;
subwin_cols = win_roster_cols();
pnoutrefresh(layout->super.win, layout->super.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1);
pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1);
}
}