Beispiel #1
0
static gboolean
_bookmark_remove(const char *jid, gboolean autojoin)
{
    Bookmark *item = malloc(sizeof(*item));
    item->jid = strdup(jid);
    item->nick = NULL;
    item->autojoin = autojoin;

    GList *found = g_list_find_custom(bookmark_list, item, _match_bookmark_by_jid);
    _bookmark_item_destroy(item);
    gboolean removed = found != NULL;

    if (removed) {
        // set autojoin FALSE
        if (autojoin) {
            Bookmark *bookmark = found->data;
            bookmark->autojoin = FALSE;

        // remove bookmark
        } else {
            bookmark_list = g_list_remove_link(bookmark_list, found);
            _bookmark_item_destroy(found->data);
            g_list_free(found);
            autocomplete_remove(bookmark_ac, jid);
        }

        _send_bookmarks();
    }

    return removed;
}
Beispiel #2
0
gboolean
bookmark_join(const char *jid)
{
    Bookmark *item = malloc(sizeof(*item));
    item->jid = strdup(jid);
    item->nick = NULL;
    item->password = NULL;
    item->autojoin = FALSE;

    GList *found = g_list_find_custom(bookmark_list, item, _match_bookmark_by_jid);
    _bookmark_item_destroy(item);
    if (found == NULL) {
        return FALSE;
    } else {
        char *account_name = jabber_get_account_name();
        ProfAccount *account = accounts_get_account(account_name);
        Bookmark *item = found->data;
        if (!muc_active(item->jid)) {
            char *nick = item->nick;
            if (nick == NULL) {
                nick = account->muc_nick;
            }
            presence_join_room(item->jid, nick, item->password);
            muc_join(item->jid, nick, item->password, FALSE);
            account_free(account);
        } else if (muc_roster_complete(item->jid)) {
            ui_room_join(item->jid, TRUE);
        }
        return TRUE;
    }
}
Beispiel #3
0
gboolean
bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str)
{
    Bookmark *item = malloc(sizeof(*item));
    item->jid = strdup(jid);
    item->nick = NULL;
    item->password = NULL;
    item->autojoin = FALSE;

    GList *found = g_list_find_custom(bookmark_list, item, _match_bookmark_by_jid);
    _bookmark_item_destroy(item);
    if (found == NULL) {
        return FALSE;
    } else {
        Bookmark *bm = found->data;
        if (nick) {
            free(bm->nick);
            bm->nick = strdup(nick);
        }
        if (password) {
            free(bm->password);
            bm->password = strdup(password);
        }
        if (autojoin_str) {
            if (g_strcmp0(autojoin_str, "on") == 0) {
                bm->autojoin = TRUE;
            } else if (g_strcmp0(autojoin_str, "off") == 0) {
                bm->autojoin = FALSE;
            }
        }
        _send_bookmarks();
        return TRUE;
    }
}
Beispiel #4
0
static gboolean
_bookmark_add(const char *jid, const char *nick, gboolean autojoin)
{
    gboolean added = TRUE;
    if (autocomplete_contains(bookmark_ac, jid)) {
        added = FALSE;
    }

    /* this may be command for modifying */
    Bookmark *item = malloc(sizeof(*item));
    item->jid = strdup(jid);
    if (nick != NULL) {
        item->nick = strdup(nick);
    } else {
        item->nick = NULL;
    }
    item->autojoin = autojoin;

    GList *found = g_list_find_custom(bookmark_list, item, _match_bookmark_by_jid);
    if (found != NULL) {
        bookmark_list = g_list_remove_link(bookmark_list, found);
        _bookmark_item_destroy(found->data);
        g_list_free(found);
    }
    bookmark_list = g_list_append(bookmark_list, item);

    autocomplete_remove(bookmark_ac, jid);
    autocomplete_add(bookmark_ac, jid);

    _send_bookmarks();

    return added;
}
Beispiel #5
0
gboolean
bookmark_remove(const char *jid)
{
    Bookmark *item = malloc(sizeof(*item));
    item->jid = strdup(jid);
    item->nick = NULL;
    item->password = NULL;
    item->autojoin = FALSE;

    GList *found = g_list_find_custom(bookmark_list, item, _match_bookmark_by_jid);
    _bookmark_item_destroy(item);
    gboolean removed = found != NULL;

    if (removed) {
        bookmark_list = g_list_remove_link(bookmark_list, found);
        _bookmark_item_destroy(found->data);
        g_list_free(found);
        autocomplete_remove(bookmark_ac, jid);
        _send_bookmarks();
        return TRUE;
    } else {
        return FALSE;
    }
}