void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) { if (timestamp == NULL) { timestamp = g_date_time_new_now_local(); } else { g_date_time_ref(timestamp); } buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); // TODO: cross-reference.. this should be replaced by a real event-based system ui_input_nonblocking(TRUE); g_date_time_unref(timestamp); }
static void _init(char *log_level) { setlocale(LC_ALL, ""); // ignore SIGPIPE signal(SIGPIPE, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGTSTP, SIG_IGN); signal(SIGWINCH, ui_sigwinch_handler); _create_directories(); log_level_t prof_log_level = log_level_from_string(log_level); prefs_load(); log_init(prof_log_level); log_stderr_init(PROF_LEVEL_ERROR); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); #endif } else { log_info("Starting Profanity (%s)...", PACKAGE_VERSION); } chat_log_init(); groupchat_log_init(); accounts_load(); char *theme = prefs_get_string(PREF_THEME); theme_init(theme); prefs_free_string(theme); ui_init(); jabber_init(); cmd_init(); log_info("Initialising contact list"); roster_init(); muc_init(); tlscerts_init(); scripts_init(); #ifdef HAVE_LIBOTR otr_init(); #endif #ifdef HAVE_LIBGPGME p_gpg_init(); #endif atexit(_shutdown); ui_input_nonblocking(TRUE); }
void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id) { GDateTime *time; if (tstamp == NULL) { time = g_date_time_new_now_local(); } else { time = g_date_time_new_from_timeval_utc(tstamp); } DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); receipt->id = strdup(id); receipt->received = FALSE; buffer_push(window->layout->buffer, show_char, pad_indent, time, flags, theme_item, from, message, receipt); _win_print(window, show_char, pad_indent, time, flags, theme_item, from, message, receipt); // TODO: cross-reference.. this should be replaced by a real event-based system ui_input_nonblocking(TRUE); g_date_time_unref(time); }
void prof_run(const int disable_tls, char *log_level, char *account_name) { _init(disable_tls, log_level); log_info("Starting main event loop"); ui_input_nonblocking(); GTimer *timer = g_timer_new(); gboolean cmd_result = TRUE; jabber_conn_status_t conn_status = jabber_get_connection_status(); char inp[INP_WIN_MAX]; int size = 0; char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (account_name != NULL) { char *cmd = "/connect"; snprintf(inp, sizeof(inp), "%s %s", cmd, account_name); process_input(inp); } else if (pref_connect_account != NULL) { char *cmd = "/connect"; snprintf(inp, sizeof(inp), "%s %s", cmd, pref_connect_account); process_input(inp); } prefs_free_string(pref_connect_account); ui_update(); while(cmd_result == TRUE) { wint_t ch = ERR; int result; size = 0; while(ch != '\n') { conn_status = jabber_get_connection_status(); if (conn_status == JABBER_CONNECTED) { _handle_idle_time(); } gdouble elapsed = g_timer_elapsed(timer, NULL); gint remind_period = prefs_get_notify_remind(); if (remind_period > 0 && elapsed >= remind_period) { notify_remind(); g_timer_start(timer); } ui_handle_special_keys(&ch, result, inp, size); #ifdef HAVE_LIBOTR otr_poll(); #endif jabber_process_events(); ui_update(); ch = ui_get_char(inp, &size, &result); } inp[size++] = '\0'; cmd_result = process_input(inp); } g_timer_destroy(timer); }