Beispiel #1
0
gboolean
scripts_exec(const char *const script)
{
    char *scriptsdir = files_get_data_path(DIR_SCRIPTS);
    GString *scriptpath = g_string_new(scriptsdir);
    free(scriptsdir);
    g_string_append(scriptpath, "/");
    g_string_append(scriptpath, script);

    FILE *scriptfile = g_fopen(scriptpath->str, "r");
    if (!scriptfile) {
        log_info("Script not found: %s", scriptpath->str);
        g_string_free(scriptpath, TRUE);
        return FALSE;
    }

    g_string_free(scriptpath, TRUE);

    char *line = NULL;
    size_t len = 0;
    ssize_t read;

    while ((read = getline(&line, &len, scriptfile)) != -1) {
        ProfWin *win = wins_get_current();
        cmd_process_input(win, line);
        session_process_events();
        ui_update();
    }

    fclose(scriptfile);
    if (line) free(line);

    return TRUE;
}
Beispiel #2
0
void
connection_disconnect(void)
{
    conn.conn_status = JABBER_DISCONNECTING;
    xmpp_disconnect(conn.xmpp_conn);

    while (conn.conn_status == JABBER_DISCONNECTING) {
        session_process_events();
    }

    if (conn.xmpp_conn) {
        xmpp_conn_release(conn.xmpp_conn);
        conn.xmpp_conn = NULL;
    }

    if (conn.xmpp_ctx) {
        xmpp_ctx_free(conn.xmpp_ctx);
        conn.xmpp_ctx = NULL;
    }
}
Beispiel #3
0
void
prof_run(char *log_level, char *account_name)
{
    _init(log_level);
    plugins_on_start();
    _connect_default(account_name);

    ui_update();

    log_info("Starting main event loop");

    session_init_activity();

    char *line = NULL;
    while(cont && !force_quit) {
        log_stderr_handler();
        session_check_autoaway();

        line = inp_readline();
        if (line) {
            ProfWin *window = wins_get_current();
            cont = cmd_process_input(window, line);
            free(line);
            line = NULL;
        } else {
            cont = TRUE;
        }

#ifdef HAVE_LIBOTR
        otr_poll();
#endif
        plugins_run_timed();
        notify_remind();
        session_process_events();
        iq_autoping_check();
        ui_update();
#ifdef HAVE_GTK
        tray_update();
#endif
    }
}