char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick) { NICK_REC *nickrec; char *emptystr; g_return_val_if_fail(nick != NULL, NULL); if (!settings_get_bool("show_nickmode")) return ""; emptystr = settings_get_bool("show_nickmode_empty") ? " " : ""; nickrec = channel == NULL ? NULL : nicklist_find(channel, nick); return nickrec == NULL ? emptystr : (nickrec->op ? "@" : (nickrec->voice ? "+" : emptystr)); }
static void create_windows(void) { WINDOW_REC *window; int have_status = settings_get_bool("use_status_window"); window = window_find_name("(status)"); if (have_status) { if (window == NULL) { window = window_create(NULL, TRUE); window_set_refnum(window, 1); window_set_name(window, "(status)"); window_set_level(window, MSGLEVEL_ALL ^ (settings_get_bool("use_msgs_window") ? MSGS_WINDOW_LEVELS : 0)); window_set_immortal(window, TRUE); } } else { if (window != NULL) { window_set_name(window, NULL); window_set_level(window, 0); window_set_immortal(window, FALSE); } } window = window_find_name("(msgs)"); if (settings_get_bool("use_msgs_window")) { if (window == NULL) { window = window_create(NULL, TRUE); window_set_refnum(window, have_status ? 2 : 1); window_set_name(window, "(msgs)"); window_set_level(window, MSGS_WINDOW_LEVELS); window_set_immortal(window, TRUE); } } else { if (window != NULL) { window_set_name(window, NULL); window_set_level(window, 0); window_set_immortal(window, FALSE); } } if (windows == NULL) { /* we have to have at least one window.. */ window = window_create(NULL, TRUE); } }
static void sig_server_connecting(XMPP_SERVER_REC *server) { if (!IS_XMPP_SERVER(server)) return; if (settings_get_bool("xmpp_status_window")) fe_xmpp_status_get_window(server); }
void read_settings(void) { GSList *tmp; XMPP_SERVER_REC *server; const char *str; for (tmp = servers; tmp != NULL; tmp = tmp->next) { if ((server = XMPP_SERVER(tmp->data)) == NULL) continue; /* update priority */ if (server->priority != settings_get_int("xmpp_priority")) signal_emit("xmpp set presence", 4, server, server->show, server->away_reason, settings_get_int("xmpp_priority")); /* update nick */ if (settings_get_bool("xmpp_set_nick_as_username")) { if (strcmp(server->nick, server->user) != 0) { g_free(server->nick); server->nick = g_strdup(server->user); } } else { if (strcmp(server->nick, server->jid) != 0) { g_free(server->nick); server->nick = g_strdup(server->jid); } } } /* check validity */ str = settings_get_str("xmpp_proxy_type"); #if 0 /* TODO print error message */ if (settings_get_bool("xmpp_use_proxy") && (str == NULL || g_ascii_strcasecmp(str, XMPP_PROXY_HTTP) != 0)) ; str = settings_get_str("xmpp_default_away_mode"); if (str == NULL || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_AWAY]) != 0 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_CHAT]) != 0 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_DND]) != 0 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_XA]) != 0 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_ONLINE]) != 0) ; #endif }
static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item) { CHANNEL_REC *channel; GList *comp; char *line, *str, *ptr, comp_char; g_return_if_fail(data != NULL); if (item == NULL) return; line = settings_get_bool("expand_escapes") ? expand_escapes(data, server, item) : g_strdup(data); comp_char = *settings_get_str("completion_char"); /* check for automatic nick completion */ ptr = NULL; comp = NULL; channel = CHANNEL(item); if (channel != NULL && comp_char != '\0' && settings_get_bool("completion_auto")) { ptr = strchr(line, comp_char); if (ptr != NULL) { *ptr++ = '\0'; if (nicklist_find(channel, line) == NULL) { comp = completion_channel_nicks(channel, line, NULL); } } } str = g_strdup_printf(ptr == NULL ? "%s %s" : "%s %s%c%s", item->name, comp != NULL ? (char *) comp->data : line, comp_char, ptr); signal_emit("command msg", 3, str, server, item); g_free(str); g_free(line); if (comp != NULL) { g_list_foreach(comp, (GFunc) g_free, NULL); g_list_free(comp); } signal_stop(); }
static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel) { GList *tmp; int inspos; g_return_if_fail(window != NULL); if (settings_get_bool("actlist_moves")) { /* Move the window to the first in the activity list */ if (g_list_find(activity_list, window) != NULL) activity_list = g_list_remove(activity_list, window); if (window->new_data != 0) activity_list = g_list_prepend(activity_list, window); statusbar_item_redraw(activity_item); return; } if (g_list_find(activity_list, window) != NULL) { /* already in activity list */ if (window->new_data == 0) { /* remove from activity list */ activity_list = g_list_remove(activity_list, window); statusbar_item_redraw(activity_item); } else if (window->new_data != GPOINTER_TO_INT(oldlevel) || window->last_color != 0) { /* different level as last time (or maybe different hilight color?), just redraw it. */ statusbar_item_redraw(activity_item); } return; } if (window->new_data == 0) return; /* add window to activity list .. */ inspos = 0; for (tmp = activity_list; tmp != NULL; tmp = tmp->next, inspos++) { WINDOW_REC *rec = tmp->data; if (window->refnum < rec->refnum) { activity_list = g_list_insert(activity_list, window, inspos); break; } } if (tmp == NULL) activity_list = g_list_append(activity_list, window); statusbar_item_redraw(activity_item); }
void gui_windows_reset_settings(void) { GSList *tmp; for (tmp = windows; tmp != NULL; tmp = tmp->next) { WINDOW_REC *rec = tmp->data; GUI_WINDOW_REC *gui = WINDOW_GUI(rec); textbuffer_view_set_default_indent(gui->view, settings_get_int("indent"), !settings_get_bool("indent_always"), get_default_indent_func()); textbuffer_view_set_scroll(gui->view, gui->use_scroll ? gui->scroll : settings_get_bool("scroll")); } }
static void sig_message_own_nick(SERVER_REC *server, const char *newnick, const char *oldnick, const char *address) { if (!settings_get_bool("show_own_nickchange_once")) print_nick_change(server, newnick, oldnick, address, TRUE); else { printformat(server, NULL, MSGLEVEL_NICKS, TXT_YOUR_NICK_CHANGED, oldnick, newnick, ""); } }
static void sig_message_own_public(SERVER_REC *server, char *msg, char *target) { WINDOW_REC *window; CHANNEL_REC *channel; char *nick, *nickmode, *freemsg = NULL, *recoded; gboolean print_channel; g_return_if_fail(server != NULL); g_return_if_fail(msg != NULL); g_return_if_fail(target != NULL); if (!IS_XMPP_SERVER(server)) return; channel = channel_find(server, target); if (channel == NULL || channel->ownnick == NULL) return; nick = channel->ownnick->nick; nickmode = channel_get_nickmode(CHANNEL(channel), nick); window = (channel == NULL) ? NULL : window_item_window((WI_ITEM_REC *)channel); print_channel = (window == NULL || window->active != (WI_ITEM_REC *) channel); if (!print_channel && settings_get_bool("print_active_channel") && window != NULL && g_slist_length(window->items) > 1) print_channel = TRUE; if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis((WI_ITEM_REC *)channel, msg); /* ugly from irssi: recode the sent message back for printing */ recoded = recode_in(SERVER(server), msg, target); if (!print_channel) printformat_module(CORE_MODULE_NAME, server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG, nick, recoded, nickmode); else printformat_module(CORE_MODULE_NAME, server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, nick, target, recoded, nickmode); g_free(recoded); g_free(nickmode); g_free_not_null(freemsg); signal_stop(); /* emit signal for chat-completion */ }
static char *channel_get_nickmode_rec(NICK_REC *nickrec) { char *emptystr; char *nickmode; if (!settings_get_bool("show_nickmode")) return g_strdup(""); emptystr = settings_get_bool("show_nickmode_empty") ? " " : ""; if (nickrec == NULL || nickrec->prefixes[0] == '\0') nickmode = g_strdup(emptystr); else { nickmode = g_malloc(2); nickmode[0] = nickrec->prefixes[0]; nickmode[1] = '\0'; } return nickmode; }
static void read_settings(void) { if (daytag != -1) { g_source_remove(daytag); daytag = -1; } if (settings_get_bool("timestamps")) daytag = g_timeout_add(30000, (GSourceFunc) sig_check_daychange, NULL); }
static void event_motd(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr) { /* don't ignore motd anymore after 3 seconds of connection time - we might have called /MOTD */ if (settings_get_bool("skip_motd") && !server->motd_got) return; print_event_received(server, data, nick, FALSE); }
static void set_boolean(const char *key, const char *value) { if (g_strcasecmp(value, "ON") == 0) settings_set_bool(key, TRUE); else if (g_strcasecmp(value, "OFF") == 0) settings_set_bool(key, FALSE); else if (g_strcasecmp(value, "TOGGLE") == 0) settings_set_bool(key, !settings_get_bool(key)); else printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_NOT_TOGGLE); }
static void read_settings(void) { int old_autolog = autolog_level; autolog_path = settings_get_str("autolog_path"); autolog_level = !settings_get_bool("autolog") ? 0 : level2bits(settings_get_str("autolog_level")); if (old_autolog && !autolog_level) autologs_close_all(); }
void fe_xmpp_status_init(void) { signal_add("server connecting", (SIGNAL_FUNC)sig_server_connecting); signal_add("setup changed", (SIGNAL_FUNC)sig_setup_changed); settings_add_bool("xmpp_lookandfeel", "xmpp_status_window", FALSE); if (settings_get_bool("xmpp_status_window")) signal_add("xmpp presence changed", sig_presence_changed); }
static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) { void *item; const char *oldtarget; char *freemsg = NULL; int level; oldtarget = target; target = skip_target(IRC_SERVER(server), target); level = MSGLEVEL_ACTIONS | (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); if (ignore_check(SERVER(server), nick, address, target, msg, level)) return; if (ignore_check(SERVER(server), nick, address, target, msg, level | MSGLEVEL_NO_ACT)) level |= MSGLEVEL_NO_ACT; if (ischannel(*target)) item = irc_channel_find(server, target); else item = privmsg_get_query(SERVER(server), nick, FALSE, level); if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis(item, msg); if (ischannel(*target)) { /* channel action */ if (window_item_is_active(item) && target == oldtarget) { /* message to active channel in window */ printformat(server, target, level, IRCTXT_ACTION_PUBLIC, nick, msg); } else { /* message to not existing/active channel, or to @/+ */ printformat(server, target, level, IRCTXT_ACTION_PUBLIC_CHANNEL, nick, oldtarget, msg); } } else { /* private action */ printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS, item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, nick, address == NULL ? "" : address, msg); } g_free_not_null(freemsg); }
static GUI_WINDOW_REC *gui_window_init(WINDOW_REC *window, MAIN_WINDOW_REC *parent) { GUI_WINDOW_REC *gui; window->width = parent->width; window->height = MAIN_WINDOW_TEXT_HEIGHT(parent); gui = g_new0(GUI_WINDOW_REC, 1); gui->parent = parent; gui->view = textbuffer_view_create(textbuffer_create(), window->width, window->height, settings_get_bool("scroll"), term_type == TERM_TYPE_UTF8); textbuffer_view_set_default_indent(gui->view, settings_get_int("indent"), !settings_get_bool("indent_always"), get_default_indent_func()); if (parent->active == window) textbuffer_view_set_window(gui->view, parent->screen_win); return gui; }
/* SYNTAX: ROSTER FULL */ static void cmd_roster_full(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item) { gboolean oldvalue; CMD_XMPP_SERVER(server); oldvalue = settings_get_bool("xmpp_roster_show_offline"); if (!oldvalue) settings_set_bool("xmpp_roster_show_offline", TRUE); signal_emit("xmpp roster show", 1, server); if (!oldvalue) settings_set_bool("xmpp_roster_show_offline", oldvalue); }
/* starts connecting to server */ int server_start_connect(SERVER_REC *server) { const char *connect_address; int fd[2]; g_return_val_if_fail(server != NULL, FALSE); if (!server->connrec->unix_socket && server->connrec->port <= 0) return FALSE; server->rawlog = rawlog_create(); if (server->connrec->connect_handle != NULL) { /* already connected */ GIOChannel *handle = server->connrec->connect_handle; server->connrec->connect_handle = NULL; server->handle = net_sendbuffer_create(handle, 0); server_connect_finished(server); } else if (server->connrec->unix_socket) { /* connect with unix socket */ server_real_connect(server, NULL, server->connrec->address); } else { /* resolve host name */ if (pipe(fd) != 0) { g_warning("server_connect(): pipe() failed."); g_free(server->tag); g_free(server->nick); return FALSE; } server->connect_pipe[0] = g_io_channel_unix_new(fd[0]); server->connect_pipe[1] = g_io_channel_unix_new(fd[1]); connect_address = server->connrec->proxy != NULL ? server->connrec->proxy : server->connrec->address; server->connect_pid = net_gethostbyname_nonblock(connect_address, server->connect_pipe[1], settings_get_bool("resolve_reverse_lookup")); server->connect_tag = g_input_add(server->connect_pipe[0], G_INPUT_READ, (GInputFunction) server_connect_callback_readpipe, server); lookup_servers = g_slist_append(lookup_servers, server); signal_emit("server looking", 1, server); } return TRUE; }
char *recode_out(const SERVER_REC *server, const char *str, const char *target) { char *recoded = NULL; const char *from = NULL; const char *to = NULL; char *translit_to = NULL; gboolean translit, term_is_utf8, recode; int len; if (!str) return NULL; recode = settings_get_bool("recode"); if (!recode) return g_strdup(str); len = strlen(str); translit = settings_get_bool("recode_transliterate"); to = find_conversion(server, target); if (to == NULL) /* default outgoing charset if set */ to = settings_get_str("recode_out_default_charset"); if (to && *to != '\0') { if (translit && !is_translit(to)) to = translit_to = g_strconcat(to ,"//TRANSLIT", NULL); term_is_utf8 = recode_get_charset(&from); recoded = g_convert(str, len, to, from, NULL, NULL, NULL); } g_free(translit_to); if (!recoded) recoded = g_strdup(str); return recoded; }
static void read_settings(void) { const char *str; int old_colors = term_use_colors; int old_colors24 = term_use_colors24; int old_type = term_type; /* set terminal type */ str = settings_get_str("term_charset"); if (g_ascii_strcasecmp(str, "utf-8") == 0) term_type = TERM_TYPE_UTF8; else if (g_ascii_strcasecmp(str, "big5") == 0) term_type = TERM_TYPE_BIG5; else term_type = TERM_TYPE_8BIT; if (old_type != term_type) term_set_input_type(term_type); /* change color stuff */ if (force_colors != settings_get_bool("term_force_colors")) { force_colors = settings_get_bool("term_force_colors"); term_force_colors(force_colors); } term_use_colors = settings_get_bool("colors") && (force_colors || term_has_colors()); #ifdef TERM_TRUECOLOR term_use_colors24 = settings_get_bool("colors_ansi_24bit") && (force_colors || term_has_colors()); #else term_use_colors24 = FALSE; #endif if (term_use_colors != old_colors || term_use_colors24 != old_colors24) irssi_redraw(); }
static void sig_message_own_public(SERVER_REC *server, const char *msg, const char *target) { WINDOW_REC *window; CHANNEL_REC *channel; char *nickmode; char *freemsg = NULL; int print_channel; channel = channel_find(server, target); if (channel != NULL) target = channel->visible_name; nickmode = channel_get_nickmode(channel, server->nick); window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel); print_channel = window == NULL || window->active != (WI_ITEM_REC *) channel; if (!print_channel && settings_get_bool("print_active_channel") && window != NULL && g_slist_length(window->items) > 1) print_channel = TRUE; if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg); if (!print_channel) { printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG, server->nick, msg, nickmode); } else { printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode); } g_free_not_null(nickmode); g_free_not_null(freemsg); }
CHAT_DCC_REC *dcc_chat_create(IRC_SERVER_REC *server, CHAT_DCC_REC *chat, const char *nick, const char *arg) { CHAT_DCC_REC *dcc; dcc = g_new0(CHAT_DCC_REC, 1); dcc->orig_type = dcc->type = DCC_CHAT_TYPE; dcc->mirc_ctcp = settings_get_bool("dcc_mirc_ctcp"); dcc->id = dcc_chat_get_new_id(nick); dcc_init_rec(DCC(dcc), server, chat, nick, arg); return dcc; }
static char *get_internal_setting(const char *key, int type, int *free_ret) { switch (type) { case SETTING_TYPE_BOOLEAN: return settings_get_bool(key) ? "yes" : "no"; case SETTING_TYPE_INT: *free_ret = TRUE; return g_strdup_printf("%d", settings_get_int(key)); case SETTING_TYPE_STRING: return (char *) settings_get_str(key); } return NULL; }
static void read_settings(void) { int old_group; old_group = group_multi_mode; group_multi_mode = settings_get_bool("group_multi_mode"); if (old_group && !group_multi_mode) { g_source_remove(mode_tag); mode_tag = -1; } else if (!old_group && group_multi_mode) { mode_tag = g_timeout_add(1000, (GSourceFunc) sig_check_modes, NULL); } }
static void autolog_open(SERVER_REC *server, const char *server_tag, const char *target) { LOG_REC *log; char *fname, *dir, *fixed_target, *params; log = logs_find_item(LOG_ITEM_TARGET, target, server_tag, NULL); if (log != NULL && !log->failed) { log_start_logging(log); return; } /* '/' -> '_' - don't even accidentally try to log to #../../../file if you happen to join to such channel.. similar for some characters that are metacharacters and/or illegal in Windows filenames. '%' -> '%%' - so strftime() won't mess with them */ fixed_target = escape_target(target); if (CHAT_PROTOCOL(server)->case_insensitive) ascii_strdown(fixed_target); /* $0 = target, $1 = server tag */ params = g_strconcat(fixed_target, " ", server_tag, NULL); g_free(fixed_target); fname = parse_special_string(autolog_path, server, NULL, params, NULL, 0); g_free(params); if (log_find(fname) == NULL) { log = log_create_rec(fname, autolog_level); if (!settings_get_bool("autolog_colors")) log->colorizer = log_colorizer_strip; log_item_add(log, LOG_ITEM_TARGET, target, server_tag); dir = g_path_get_dirname(log->real_fname); #ifdef HAVE_CAPSICUM capsicum_mkdir_with_parents_wrapper(dir, log_dir_create_mode); #else g_mkdir_with_parents(dir, log_dir_create_mode); #endif g_free(dir); log->temp = TRUE; log_update(log); log_start_logging(log); } g_free(fname); }
static void read_settings(void) { use_colors = settings_get_bool("colors"); if (settings_get_bool("topicbar")) topicbar_create(); else if (!settings_get_bool("topicbar")) topicbar_destroy(); lag_min_show = settings_get_int("lag_min_show")*10; sbar_color_background = settings_get_int("statusbar_background") << 4; sbar_color_dim = sbar_color_background | settings_get_int("statusbar_dim"); sbar_color_normal = sbar_color_background | settings_get_int("statusbar_normal"); sbar_color_bold = sbar_color_background | settings_get_int("statusbar_bold"); sbar_color_away = sbar_color_background | settings_get_int("statusbar_away"); sbar_color_act_highlight = sbar_color_background | settings_get_int("statusbar_act_highlight"); statusbar_redraw(NULL); }
void term_common_init(void) { const char *dummy; #ifdef SIGWINCH struct sigaction act; #endif settings_add_bool("lookandfeel", "colors", TRUE); settings_add_bool("lookandfeel", "term_force_colors", FALSE); settings_add_bool("lookandfeel", "mirc_blink_fix", FALSE); force_colors = FALSE; term_use_colors = term_has_colors() && settings_get_bool("colors"); #ifdef TERM_TRUECOLOR settings_add_bool("lookandfeel", "colors_ansi_24bit", FALSE); term_use_colors24 = term_has_colors() && settings_get_bool("colors_ansi_24bit"); #else term_use_colors24 = FALSE; #endif read_settings(); if (g_get_charset(&dummy)) { term_type = TERM_TYPE_UTF8; term_set_input_type(TERM_TYPE_UTF8); } signal_add("beep", (SIGNAL_FUNC) term_beep); signal_add("setup changed", (SIGNAL_FUNC) read_settings); command_bind("resize", NULL, (SIGNAL_FUNC) cmd_resize); command_bind("redraw", NULL, (SIGNAL_FUNC) cmd_redraw); #ifdef SIGWINCH sigemptyset (&act.sa_mask); act.sa_flags = 0; act.sa_handler = sig_winch; sigaction(SIGWINCH, &act, NULL); #endif }
static void sig_message_delay_action(SERVER_REC *server, const char *msg, const char *nick, const char *target, time_t *t, gpointer gpointer_type) { void *item; char *text, *freemsg = NULL; char stamp[BUFSIZ]; int level, type; g_return_if_fail(server != NULL); g_return_if_fail(msg != NULL); g_return_if_fail(nick != NULL); g_return_if_fail(target != NULL); type = GPOINTER_TO_INT(gpointer_type); level = MSGLEVEL_ACTIONS | MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); item = type == SEND_TARGET_CHANNEL ? (void *)get_muc((XMPP_SERVER_REC *)server, target) : query_find(server, nick); if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis(item, msg); /* MUC */ if (type == SEND_TARGET_CHANNEL) { if (item && window_item_is_active(item)) text = format_get_text(IRC_MODULE_NAME, NULL, server, target, IRCTXT_ACTION_PUBLIC, nick, msg); else text = format_get_text(IRC_MODULE_NAME, NULL, server, target, IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, msg); /* General */ } else text = format_get_text(IRC_MODULE_NAME, NULL, server, nick, (item == NULL) ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, nick, nick, msg); if (strftime(stamp, sizeof(stamp)-1, settings_get_str("xmpp_timestamp_format"), localtime(t)) == 0) stamp[sizeof(stamp)-1] = '\0'; printformat_module(MODULE_NAME, server, target, level, XMPPTXT_MESSAGE_TIMESTAMP, stamp, text); g_free(freemsg); }
/* * format outgoing (encrypted) messages (add crypt-mark or remove plain-prefix) */ void format_msg(SERVER_REC * server, char *msg, char *target, char *orig_target) { char contactName[CONTACT_SIZE] = "", myMark[20] = "", formattedMsg[800] = ""; int i, markPos; char *plainMsg; if (IsNULLorEmpty(msg) || IsNULLorEmpty(target)) return; if (settings_get_bool("process_outgoing") == 0) return; if (getIniSectionForContact(server, target, contactName) == FALSE) return; if (getContactKey(contactName, NULL) == FALSE) return; plainMsg = isPlainPrefix(msg); if (plainMsg) { signal_continue(4, server, plainMsg, target, orig_target); return; } // generally cut a message to a size of 512 byte, as everything above will never arrive complete anyway if (strlen(msg) > 512) msg[512] = '\0'; // append crypt-mark? strncpy(myMark, settings_get_str("mark_encrypted"), sizeof(myMark)); if (*myMark != '\0') { strcpy(formattedMsg, msg); markPos = settings_get_int("mark_position"); if (markPos == 0) strcat(formattedMsg, myMark); //append mark at the end else { // prefix mark i = strlen(myMark); memmove(formattedMsg + i, formattedMsg, strlen(formattedMsg) + 1); strncpy(formattedMsg, myMark, i); } signal_continue(4, server, formattedMsg, target, orig_target); ZeroMemory(formattedMsg, sizeof(formattedMsg)); } return; }