void mucconfwin_show_form(ProfMucConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { win_print(window, THEME_DEFAULT, '-', "Form title: "); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); } else { win_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); } win_println(window, THEME_DEFAULT, '-', ""); mucconfwin_form_help(confwin); GSList *fields = confwin->form->fields; GSList *curr_field = fields; while (curr_field) { FormField *field = curr_field->data; if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { char *value = field->values->data; win_println(window, THEME_DEFAULT, '-', "%s", value); } } 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); } curr_field = g_slist_next(curr_field); } }
void mucconfwin_form_help(ProfMucConfWin *confwin) { assert(confwin != NULL); if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; win_println(window, THEME_DEFAULT, '-', "Supplied instructions:"); win_println(window, THEME_DEFAULT, '-', "%s", confwin->form->instructions); win_println(window, THEME_DEFAULT, '-', ""); } }
void ui_show_software_version(const char *const jid, const char *const presence, const char *const name, const char *const version, const char *const os) { Jid *jidp = jid_create(jid); ProfWin *window = NULL; ProfWin *chatwin = (ProfWin*)wins_get_chat(jidp->barejid); ProfWin *mucwin = (ProfWin*)wins_get_muc(jidp->barejid); ProfWin *privwin = (ProfWin*)wins_get_private(jidp->fulljid); ProfWin *console = wins_get_console(); jid_destroy(jidp); if (chatwin) { if (wins_is_current(chatwin)) { window = chatwin; } else { window = console; } } else if (privwin) { if (wins_is_current(privwin)) { window = privwin; } else { window = console; } } else if (mucwin) { if (wins_is_current(mucwin)) { window = mucwin; } else { window = console; } } else { window = console; } if (name || version || os) { win_println(window, THEME_DEFAULT, '-', ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); win_print(window, presence_colour, '-', "%s", jid); win_appendln(window, THEME_DEFAULT, ":"); } if (name) { win_println(window, THEME_DEFAULT, '-', "Name : %s", name); } if (version) { win_println(window, THEME_DEFAULT, '-', "Version : %s", version); } if (os) { win_println(window, THEME_DEFAULT, '-', "OS : %s", os); } }
int api_chat_show(const char *const barejid, const char *message) { if (message == NULL) { log_warning("%s", "api_chat_show failed, message is NULL"); return 0; } if (barejid == NULL) { log_warning("%s", "api_chat_show failed, barejid is NULL"); return 0; } ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin == NULL) { log_warning("%s", "api_chat_show failed, could not find chat window for %s", barejid); return 0; } char *parsed = str_replace(message, "\r\n", "\n"); win_println((ProfWin*)chatwin, THEME_TEXT, '-', "%s", parsed); free(parsed); return 1; }
int api_room_show(const char *const roomjid, const char *message) { if (message == NULL) { log_warning("%s", "api_room_show failed, message is NULL"); return 0; } if (roomjid == NULL) { log_warning("%s", "api_room_show failed, roomjid is NULL"); return 0; } ProfMucWin *mucwin = wins_get_muc(roomjid); if (mucwin == NULL) { log_warning("%s", "api_room_show failed, could not find room window for %s", roomjid); return 0; } char *parsed = str_replace(message, "\r\n", "\n"); win_println((ProfWin*)mucwin, THEME_TEXT, '-', "%s", parsed); free(parsed); return 1; }
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form) { assert(confwin != NULL); ProfWin *window = (ProfWin*)confwin; ui_focus_win(window); mucconfwin_show_form(confwin); win_println(window, THEME_DEFAULT, '-', ""); win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes."); win_println(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes."); win_println(window, THEME_DEFAULT, '-', "See '/form help' for more information."); win_println(window, THEME_DEFAULT, '-', ""); }
void ui_handle_room_config_submit_result(const char *const roomjid) { if (roomjid) { ProfWin *form_window = NULL; ProfWin *muc_window = (ProfWin*)wins_get_muc(roomjid); GString *form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { int num = wins_get_num(form_window); wins_close_by_num(num); } if (muc_window) { ui_focus_win((ProfWin*)muc_window); win_println(muc_window, THEME_ROOMINFO, '!', "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); cons_show("Room configuration successful: %s", roomjid); } } else { cons_show("Room configuration successful"); } }
void ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); if (window == NULL) { log_error("Received ban, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); GString *message = g_string_new("Banned from "); g_string_append(message, roomjid); if (actor) { g_string_append(message, " by "); g_string_append(message, actor); } if (reason) { g_string_append(message, ", reason: "); g_string_append(message, reason); } ProfWin *console = wins_get_console(); win_println(console, THEME_TYPING, '!', "<- %s", message->str); g_string_free(message, TRUE); } GList *privwins = wins_get_private_chats(roomjid); GList *curr = privwins; while (curr) { ProfPrivateWin *privwin = curr->data; privwin_room_banned(privwin, actor, reason); curr = g_list_next(curr); } g_list_free(privwins); }
void api_encryption_reset(const char *const barejid) { if (barejid == NULL) { log_warning("%s", "api_encryption_reset failed, barejid is NULL"); return; } ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin == NULL) { log_warning("%s", "api_encryption_reset failed, could not find chat window for %s", barejid); return; } #ifdef HAVE_LIBGPGME if (chatwin->pgp_send) { chatwin->pgp_send = FALSE; win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "PGP encryption disabled."); } #endif #ifdef HAVE_LIBOTR if (chatwin->is_otr) { chatwin_otr_unsecured(chatwin); otr_end_session(chatwin->barejid); } #endif }
void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp) { gboolean new_win = FALSE; ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { ProfWin *window = wins_new_chat(barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; } // OTR suported, PGP supported #ifdef HAVE_LIBOTR #ifdef HAVE_LIBGPGME if (pgp_message) { if (chatwin->is_otr) { win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session."); } else { // PROF_ENC_NONE, PROF_ENC_PGP _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp); } } else { _sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp); } rosterwin_roster(); return; #endif #endif // OTR supported, PGP unsupported #ifdef HAVE_LIBOTR #ifndef HAVE_LIBGPGME _sv_ev_incoming_otr(chatwin, new_win, barejid, resource, message, timestamp); rosterwin_roster(); return; #endif #endif // OTR unsupported, PGP supported #ifndef HAVE_LIBOTR #ifdef HAVE_LIBGPGME if (pgp_message) { _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp); } else { _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp); } rosterwin_roster(); return; #endif #endif // OTR unsupported, PGP unsupported #ifndef HAVE_LIBOTR #ifndef HAVE_LIBGPGME _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, timestamp); rosterwin_roster(); return; #endif #endif }
void ui_show_lines(ProfWin *window, gchar** lines) { if (lines) { int i; for (i = 0; lines[i] != NULL; i++) { win_println(window, THEME_DEFAULT, '-', "%s", lines[i]); } } }
void ui_handle_otr_error(const char *const barejid, const char *const message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message); } else { cons_show_error("%s - %s", barejid, message); } }
void mucconfwin_show_form_field(ProfMucConfWin *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); win_println(window, THEME_DEFAULT, '-', ""); }
void ui_current_print_line(const char *const msg, ...) { ProfWin *window = wins_get_current(); va_list arg; va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(window, 0, fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); }
char* ui_ask_pgp_passphrase(const char *hint, int prev_fail) { ProfWin *current = wins_get_current(); win_println(current, THEME_DEFAULT, '-', ""); if (prev_fail) { win_println(current, THEME_DEFAULT, '!', "Incorrect passphrase"); } if (hint) { win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint); } else { win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase"); } ui_update(); status_bar_get_password(); status_bar_update_virtual(); return inp_get_password(); }
void ui_handle_recipient_error(const char *const recipient, const char *const err_msg) { // always show in console cons_show_error("Error from %s: %s", recipient, err_msg); ProfChatWin *chatwin = wins_get_chat(recipient); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfMucWin *mucwin = wins_get_muc(recipient); if (mucwin) { win_println((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfPrivateWin *privatewin = wins_get_private(recipient); if (privatewin) { win_println((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } }
void ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid, const char *const password) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); if (window == NULL) { log_error("Received room destroy, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); ProfWin *console = wins_get_console(); if (reason) { win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason); } else { win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid); } if (new_jid) { if (password) { win_println(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password); } else { win_println(console, THEME_TYPING, '!', "Replacement room: %s", new_jid); } } } GList *privwins = wins_get_private_chats(roomjid); GList *curr = privwins; while (curr) { ProfPrivateWin *privwin = curr->data; privwin_room_destroyed(privwin); curr = g_list_next(curr); } g_list_free(privwins); }
int api_cons_show_themed(const char *const group, const char *const key, const char *const def, const char *const message) { if (message == NULL) { log_warning("%s", "prof_cons_show_themed failed, message is NULL"); return 0; } char *parsed = str_replace(message, "\r\n", "\n"); theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *console = wins_get_console(); win_println(console, themeitem, '-', "%s", parsed); free(parsed); return 1; }
void ui_handle_software_version_error(const char *const roomjid, const char *const message) { GString *message_str = g_string_new(""); ProfWin *window = wins_get_console(); g_string_printf(message_str, "Could not get software version"); if (message) { g_string_append(message_str, ": "); g_string_append(message_str, message); } win_println(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); }
void ui_room_join(const char *const roomjid, gboolean focus) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); if (!window) { window = wins_new_muc(roomjid); } char *nick = muc_nick(roomjid); win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { char *role = muc_role_str(roomjid); char *affiliation = muc_affiliation_str(roomjid); if (role) { win_append(window, THEME_ROOMINFO, ", role: %s", role); } if (affiliation) { win_append(window, THEME_ROOMINFO, ", affiliation: %s", affiliation); } } win_appendln(window, THEME_ROOMINFO, ""); if (focus) { ui_focus_win(window); } else { int num = wins_get_num(window); status_bar_active(num); ProfWin *console = wins_get_console(); char *nick = muc_nick(roomjid); win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); } GList *privwins = wins_get_private_chats(roomjid); GList *curr = privwins; while (curr) { ProfPrivateWin *privwin = curr->data; privwin_room_joined(privwin); curr = g_list_next(curr); } g_list_free(privwins); }
void ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) { GString *msg = g_string_new(""); g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]); if (setting_func) { cons_show(""); (*setting_func)(); cons_show(msg->str); } else { cons_show(""); cons_show(msg->str); ProfWin *current = wins_get_current(); if (current->type == WIN_CHAT) { win_println(current, THEME_DEFAULT, '-', "%s", msg->str); } } g_string_free(msg, TRUE); }
void ui_print_system_msg_from_recipient(const char *const barejid, const char *message) { if (barejid == NULL || message == NULL) return; ProfWin *window = (ProfWin*)wins_get_chat(barejid); if (window == NULL) { int num = 0; window = wins_new_chat(barejid); if (window) { num = wins_get_num(window); status_bar_active(num); } else { num = 0; window = wins_get_console(); status_bar_active(1); } } win_println(window, THEME_DEFAULT, '-', "*%s %s", barejid, message); }
int api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def, const char *const ch, const char *const message) { if (message == NULL) { log_warning("%s", "api_room_show_themed failed, message is NULL"); return 0; } if (roomjid == NULL) { log_warning("%s", "api_room_show_themed failed, roomjid is NULL"); return 0; } char show_ch = '-'; if (ch) { if (strlen(ch) != 1) { log_warning("%s", "api_room_show_themed failed, ch must be a string of length 1"); return 0; } else { show_ch = ch[0]; } } ProfMucWin *mucwin = wins_get_muc(roomjid); if (mucwin == NULL) { log_warning("%s", "api_room_show_themed failed, could not find room window for %s", roomjid); return 0; } char *parsed = str_replace(message, "\r\n", "\n"); theme_item_t themeitem = plugin_themes_get(group, key, def); win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed); free(parsed); return 1; }
void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message) { ProfWin *window = NULL; GString *message_str = g_string_new(""); if (roomjid) { window = (ProfWin*)wins_get_muc(roomjid); g_string_printf(message_str, "Could not get room configuration for %s", roomjid); } else { window = wins_get_console(); g_string_printf(message_str, "Could not get room configuration"); } if (message) { g_string_append(message_str, ": "); g_string_append(message_str, message); } win_println(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); }
int api_win_show(const char *tag, const char *line) { if (tag == NULL) { log_warning("%s", "prof_win_show failed, tag is NULL"); return 0; } if (line == NULL) { log_warning("%s", "prof_win_show failed, line is NULL"); return 0; } ProfPluginWin *pluginwin = wins_get_plugin(tag); if (pluginwin == NULL) { log_warning("prof_win_show failed, no window with tag: %s", tag); return 0; } ProfWin *window = (ProfWin*)pluginwin; win_println(window, THEME_DEFAULT, '!', "%s", line); return 1; }
int api_win_show_themed(const char *tag, const char *const group, const char *const key, const char *const def, const char *line) { if (tag == NULL) { log_warning("%s", "prof_win_show_themed failed, tag is NULL"); return 0; } if (line == NULL) { log_warning("%s", "prof_win_show_themed failed, line is NULL"); return 0; } ProfPluginWin *pluginwin = wins_get_plugin(tag); if (pluginwin == NULL) { log_warning("prof_win_show_themed failed, no window with tag: %s", tag); return 0; } theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; win_println(window, themeitem, '!', "%s", line); return 1; }
void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message) { ProfWin *console = wins_get_console(); if (roomjid) { ProfWin *muc_window = NULL; ProfWin *form_window = NULL; muc_window = (ProfWin*)wins_get_muc(roomjid); GString *form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { if (message) { win_println(form_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { win_println(form_window, THEME_ERROR, '!', "Configuration error"); } } else if (muc_window) { if (message) { win_println(muc_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { win_println(muc_window, THEME_ERROR, '!', "Configuration error"); } } else { if (message) { win_println(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message); } else { win_println(console, THEME_ERROR, '!', "Configuration error for %s", roomjid); } } } else { win_println(console, THEME_ERROR, '!', "Configuration error"); } }
void 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) { win_print(window, THEME_DEFAULT, '-', "%s", field->label); if (field->required) { win_appendln(window, THEME_DEFAULT, " (Required):"); } else { win_appendln(window, THEME_DEFAULT, ":"); } if (field->description) { win_println(window, THEME_DEFAULT, '-', " Description : %s", field->description); } win_println(window, THEME_DEFAULT, '-', " Type : %s", field->type); int num_values = 0; GSList *curr_option = NULL; FormOption *option = NULL; switch (field->type_t) { case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text"); if (num_values > 0) { win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> between 'val1' and 'val%d'", num_values); } break; case FIELD_BOOLEAN: win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; win_println(window, THEME_DEFAULT, '-', " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_LIST_MULTI: win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; win_println(window, THEME_DEFAULT, '-', " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_JID_SINGLE: win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); break; case FIELD_JID_MULTI: win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); break; case FIELD_FIXED: case FIELD_UNKNOWN: case FIELD_HIDDEN: default: break; } } else { win_println(window, THEME_DEFAULT, '-', "No such field %s", tag); } }
void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_message) { gboolean new_win = FALSE; ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { ProfWin *window = wins_new_chat(barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; } // OTR suported, PGP supported #ifdef HAVE_LIBOTR #ifdef HAVE_LIBGPGME prof_enc_t enc_mode = chatwin->enc_mode; if (enc_message) { if (enc_mode == PROF_ENC_OTR) { win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session."); } else { // PROF_ENC_NONE, PROF_ENC_PGP char *decrypted = p_gpg_decrypt(barejid, enc_message); if (decrypted) { if (enc_mode == PROF_ENC_NONE) { win_println((ProfWin*)chatwin, "PGP encryption enabled."); } ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } } } else { if (enc_mode == PROF_ENC_PGP) { win_println((ProfWin*)chatwin, "PGP encryption disabled."); ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } else { gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } } } return; #endif #endif // OTR supported, PGP unsupported #ifdef HAVE_LIBOTR #ifndef HAVE_LIBGPGME gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } return; #endif #endif // OTR unsupported, PGP supported #ifndef HAVE_LIBOTR #ifdef HAVE_LIBGPGME if (enc_message) { char *decrypted = p_gpg_decrypt(barejid, enc_message); if (decrypted) { ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } return; #endif #endif // OTR unsupported, PGP unsupported #ifndef HAVE_LIBOTR #ifndef HAVE_LIBGPGME ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; return; #endif #endif }
static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { win_print(window, THEME_AWAY, '-', "[%s] ", tag); win_append(window, THEME_DEFAULT, "%s", field->label); if (field->required) { win_append(window, THEME_DEFAULT, " (required): "); } else { win_append(window, THEME_DEFAULT, ": "); } GSList *values = field->values; GSList *curr_value = values; switch (field->type_t) { case FIELD_HIDDEN: break; case FIELD_TEXT_SINGLE: if (curr_value) { char *value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { win_append(window, THEME_ONLINE, "[hidden]"); } else { win_append(window, THEME_ONLINE, "%s", value); } } } win_newline(window); break; case FIELD_TEXT_PRIVATE: if (curr_value) { char *value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "[hidden]"); } } win_newline(window); break; case FIELD_TEXT_MULTI: win_newline(window); int index = 1; while (curr_value) { char *value = curr_value->data; GString *val_tag = g_string_new(""); g_string_printf(val_tag, "val%d", index++); win_println(window, THEME_ONLINE, '-', " [%s] %s", val_tag->str, value); g_string_free(val_tag, TRUE); curr_value = g_slist_next(curr_value); } break; case FIELD_BOOLEAN: if (curr_value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { char *value = curr_value->data; if (value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { if (g_strcmp0(value, "0") == 0) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { win_appendln(window, THEME_ONLINE, "TRUE"); } } } break; case FIELD_LIST_SINGLE: if (curr_value) { win_newline(window); char *value = curr_value->data; GSList *options = field->options; GSList *curr_option = options; while (curr_option) { FormOption *option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } } break; case FIELD_LIST_MULTI: if (curr_value) { win_newline(window); GSList *options = field->options; GSList *curr_option = options; while (curr_option) { FormOption *option = curr_option->data; if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } } break; case FIELD_JID_SINGLE: if (curr_value) { char *value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "%s", value); } } win_newline(window); break; case FIELD_JID_MULTI: win_newline(window); while (curr_value) { char *value = curr_value->data; win_println(window, THEME_ONLINE, '-', " %s", value); curr_value = g_slist_next(curr_value); } break; case FIELD_FIXED: if (curr_value) { char *value = curr_value->data; if (value) { win_append(window, THEME_DEFAULT, "%s", value); } } win_newline(window); break; default: break; } }