void replaces_chat_session_on_recipient_activity_with_different_resource(void **state)
{
    char *barejid = "*****@*****.**";
    char *resource1 = "tablet";
    char *resource2 = "mobile";

    chat_session_recipient_active(barejid, resource1, FALSE);
    chat_session_recipient_active(barejid, resource2, FALSE);
    ChatSession *session = chat_session_get(barejid);

    assert_string_equal(session->resource, resource2);
}
void lost_connection_clears_chat_sessions(void **state)
{
    chat_sessions_init();
    chat_session_recipient_active("*****@*****.**", "laptop", FALSE);
    chat_session_recipient_active("*****@*****.**", "mobile", FALSE);
    expect_any_cons_show_error();

    sv_ev_lost_connection();

    ChatSession *session1 = chat_session_get("*****@*****.**");
    ChatSession *session2 = chat_session_get("*****@*****.**");
    assert_null(session1);
    assert_null(session2);
}
Exemple #3
0
void
sv_ev_activity(const char *const barejid, const char *const resource, gboolean send_states)
{
    if (wins_chat_exists(barejid)) {
        chat_session_recipient_active(barejid, resource, send_states);
    }
}
void removes_chat_session(void **state)
{
    char *barejid = "*****@*****.**";
    char *resource1 = "laptop";

    chat_session_recipient_active(barejid, resource1, FALSE);
    chat_session_remove(barejid);
    ChatSession *session = chat_session_get(barejid);

    assert_null(session);
}
void creates_chat_session_on_recipient_activity(void **state)
{
    char *barejid = "*****@*****.**";
    char *resource = "tablet";

    chat_session_recipient_active(barejid, resource, FALSE);
    ChatSession *session = chat_session_get(barejid);

    assert_non_null(session);
    assert_string_equal(session->resource, resource);
}
void clears_chat_sessions(void **state)
{
    chat_sessions_init();
    roster_create();
    chat_session_recipient_active("*****@*****.**", "laptop", FALSE);
    chat_session_recipient_active("*****@*****.**", "work", FALSE);

    will_return(connection_get_status, JABBER_CONNECTED);
    will_return(connection_get_fulljid, "*****@*****.**");
    expect_any_cons_show();

    gboolean result = cmd_disconnect(NULL, CMD_DISCONNECT, NULL);

    assert_true(result);

    ChatSession *session1 = chat_session_get("*****@*****.**");
    ChatSession *session2 = chat_session_get("*****@*****.**");
    assert_null(session1);
    assert_null(session2);
}
void handle_offline_removes_chat_session(void **state)
{
    chat_sessions_init();
    char *barejid = "*****@*****.**";
    char *resource = "home";
    roster_init();
    roster_add(barejid, "bob", NULL, "both", FALSE);
    Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10);
    roster_update_presence(barejid, resourcep, NULL);
    chat_session_recipient_active(barejid, resource, FALSE);
    sv_ev_contact_offline(barejid, resource, NULL);
    ChatSession *session = chat_session_get(barejid);

    assert_null(session);

    roster_clear();
    chat_sessions_clear();
}
void handle_offline_removes_chat_session(void **state)
{
    plugins_init();
    roster_create();
    chat_sessions_init();
    char *barejid = "*****@*****.**";
    char *resource = "home";
    roster_add(barejid, "bob", NULL, "both", FALSE);
    Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10);
    roster_update_presence(barejid, resourcep, NULL);
    chat_session_recipient_active(barejid, resource, FALSE);
    ProfConsoleWin *console = malloc(sizeof(ProfConsoleWin));
    will_return(win_create_console, &console->window);
    wins_init();
    sv_ev_contact_offline(barejid, resource, NULL);
    ChatSession *session = chat_session_get(barejid);

    assert_null(session);

    roster_destroy();
    chat_sessions_clear();
    plugins_shutdown();
}
Exemple #9
0
void
chat_session_recipient_inactive(const char * const barejid, const char * const resource)
{
    chat_session_recipient_active(barejid, resource, TRUE);
}