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
prof_run(char *log_level, char *account_name)
{
    _init(log_level);
    _connect_default(account_name);
    ui_update();

    log_info("Starting main event loop");

    activity_state = ACTIVITY_ST_ACTIVE;
    saved_status = NULL;

    char *line = NULL;
    while(cont) {
        log_stderr_handler();
        _check_autoaway();

        line = ui_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
        notify_remind();
        jabber_process_events(10);
        ui_update();
    }
}
Beispiel #3
0
void
prof_run(const int disable_tls, char *log_level, char *account_name)
{
    _init(disable_tls, log_level);
    _connect_default(account_name);
    ui_update();

    char *line = NULL;
    gboolean cmd_result = TRUE;

    log_info("Starting main event loop");

    while(cmd_result) {
        while(!line) {
            _check_autoaway();
            line = ui_readline();
#ifdef HAVE_LIBOTR
            otr_poll();
#endif
            notify_remind();
            jabber_process_events();
            ui_update();
        }
        cmd_result = cmd_process_input(line);
        ui_input_clear();
        FREE_SET_NULL(line);
    }
}
Beispiel #4
0
void
prof_run(char *log_level, char *account_name)
{
#ifdef PROF_HAVE_GTK
    gtk_ready = gtk_init_check(0, NULL);
    log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
    if (gtk_ready) {
        gtk_init(0, NULL);
        gtk_main_iteration_do(false);
    }
#endif
    _init(log_level);
    plugins_on_start();
    _connect_default(account_name);

    ui_update();

    log_info("Starting main event loop");

    activity_state = ACTIVITY_ST_ACTIVE;
    saved_status = NULL;

    char *line = NULL;
    while(cont && !force_quit) {
        log_stderr_handler();
        _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 PROF_HAVE_LIBOTR
        otr_poll();
#endif
        plugins_run_timed();
        notify_remind();
        jabber_process_events(10);
        iq_autoping_check();
        ui_update();
#ifdef PROF_HAVE_GTK
        if (gtk_ready) {
            gtk_main_iteration_do(false);
        }
#endif
    }
}
Beispiel #5
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
    }
}
Beispiel #6
0
void
api_send_line(char *line)
{
    ProfWin *current = wins_get_current();
    cmd_process_input(current, line);
}