Example #1
0
int
main(int argc , char *argv[])
{
    int port = 0;
    int httpport = 0;
    char *loglevelarg = "INFO";
    stbbr_log_t loglevel = STBBR_LOGINFO;

    GOptionEntry entries[] =
    {
        { "port", 'p', 0, G_OPTION_ARG_INT, &port, "Listen port", NULL },
        { "http", 'h', 0, G_OPTION_ARG_INT, &httpport, "HTTP Listen port", NULL },
        { "log",'l', 0, G_OPTION_ARG_STRING, &loglevelarg, "Set logging levels, DEBUG, INFO (default), WARN, ERROR", "LEVEL" },
        { NULL }
    };

    GError *error = NULL;
    GOptionContext *context;

    context = g_option_context_new(NULL);
    g_option_context_add_main_entries(context, entries, NULL);
    if (!g_option_context_parse(context, &argc, &argv, &error)) {
        g_print("%s\n", error->message);
        g_option_context_free(context);
        g_error_free(error);
        return 1;
    }

    g_option_context_free(context);

    if (port == 0) {
        printf("Port must be specified with -p <port>\n");
        return 1;
    }

    if (g_strcmp0(loglevelarg, "INFO") == 0) {
        loglevel = STBBR_LOGINFO;
    } else if (g_strcmp0(loglevelarg, "DEBUG") == 0) {
        loglevel = STBBR_LOGDEBUG;
    } else if (g_strcmp0(loglevelarg, "WARN") == 0) {
        loglevel = STBBR_LOGWARN;
    } else if (g_strcmp0(loglevelarg, "ERROR") == 0) {
        loglevel = STBBR_LOGERROR;
    } else {
        printf("Invalid log level supplied, must be one of DEBUG, INFO, WARN, ERROR.\n");
        return 1;
    }

    stbbr_start(loglevel, port, httpport);

    pthread_exit(0);
}
Example #2
0
void
init_prof_test(void **state)
{
    if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
        assert_true(FALSE);
        return;
    }

    config_orig = getenv("XDG_CONFIG_HOME");
    data_orig = getenv("XDG_DATA_HOME");

    setenv("XDG_CONFIG_HOME", XDG_CONFIG_HOME, 1);
    setenv("XDG_DATA_HOME", XDG_DATA_HOME, 1);

    _cleanup_dirs();

    _create_config_dir();
    _create_data_dir();
    _create_chatlogs_dir();
    _create_logs_dir();

    prof_start();
    assert_true(prof_output_exact("Profanity"));

    // set UI options to make expect assertions faster and more reliable
    prof_input("/inpblock timeout 5");
    assert_true(prof_output_exact("Input blocking set to 5 milliseconds"));
    prof_input("/inpblock dynamic off");
    assert_true(prof_output_exact("Dynamic input blocking disabled"));
    prof_input("/notify chat off");
    assert_true(prof_output_exact("Chat notifications disabled"));
    prof_input("/notify room off");
    assert_true(prof_output_exact("Room notifications disabled"));
    prof_input("/wrap off");
    assert_true(prof_output_exact("Word wrap disabled"));
    prof_input("/roster hide");
    assert_true(prof_output_exact("Roster disabled"));
    prof_input("/time console off");
    prof_input("/time console off");
    assert_true(prof_output_exact("Console time display disabled."));
    prof_input("/time chat off");
    assert_true(prof_output_exact("Chat time display disabled."));
    prof_input("/time muc off");
    assert_true(prof_output_exact("MUC time display disabled."));
    prof_input("/time mucconfig off");
    assert_true(prof_output_exact("MUC config time display disabled."));
    prof_input("/time private off");
    assert_true(prof_output_exact("Private chat time display disabled."));
    prof_input("/time xml off");
    assert_true(prof_output_exact("XML Console time display disabled."));
}
Example #3
0
int main(void)
{
    stbbr_start(STBBR_LOGDEBUG, 5230, 5231);

    stbbr_auth_passwd("password");

    stbbr_for_id("roster",
        "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">"
            "<query xmlns=\"jabber:iq:roster\" ver=\"362\">"
                "<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>"
                "<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>"
            "</query>"
        "</iq>");

    stbbr_for_id("prof_presence_1",
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
            "<show>dnd</show>"
            "<status>busy!</status>"
        "</presence>"
        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/laptop\">"
            "<show>chat</show>"
            "<status>Talk to me!</status>"
        "</presence>"
        "<presence to=\"stabber@localhost\" from=\"buddy2@localhost/work\">"
            "<show>away</show>"
            "<status>Out of office</status>"
        "</presence>");

    stbbr_for_id("prof_msg_2",
        "<message id=\"message1\" to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\" type=\"chat\">"
        "<body>Welcome!!</body>"
        "</message>");

    stbbr_for_id("prof_msg_3",
        "<message id=\"message2\" to=\"stabber@localhost\" from=\"buddy1@localhost/laptop\" type=\"chat\">"
        "<body>From me laptop</body>"
        "</message>");

    pthread_exit(NULL);
}