Exemple #1
0
static gint
update_active_playlist (xmmsv_t *val, void *udata)
{
    cli_cache_t *cache = (cli_cache_t *) udata;
    xmmsc_result_t *refres;
    gint pos, newpos, type;
    gint id;
    const gchar *name;

    xmmsv_dict_entry_get_int (val, "type", &type);
    xmmsv_dict_entry_get_int (val, "position", &pos);
    xmmsv_dict_entry_get_int (val, "id", &id);
    xmmsv_dict_entry_get_string (val, "name", &name);

    /* Active playlist not changed, nevermind */
    if (strcmp (name, cache->active_playlist_name) != 0) {
        return TRUE;
    }

    /* Apply changes to the cached playlist */
    switch (type) {
    case XMMS_PLAYLIST_CHANGED_ADD:
        xmmsv_list_append_int (cache->active_playlist, id);
        break;

    case XMMS_PLAYLIST_CHANGED_INSERT:
        xmmsv_list_insert_int (cache->active_playlist, pos, id);
        break;

    case XMMS_PLAYLIST_CHANGED_MOVE:
        xmmsv_dict_entry_get_int (val, "newposition", &newpos);
        xmmsv_list_remove (cache->active_playlist, pos);
        xmmsv_list_insert_int (cache->active_playlist, newpos, id);
        break;

    case XMMS_PLAYLIST_CHANGED_REMOVE:
        xmmsv_list_remove (cache->active_playlist, pos);
        break;

    case XMMS_PLAYLIST_CHANGED_SHUFFLE:
    case XMMS_PLAYLIST_CHANGED_SORT:
    case XMMS_PLAYLIST_CHANGED_CLEAR:
        /* Oops, reload the whole playlist */
        refres = xmmsc_playlist_list_entries (cache->conn, XMMS_ACTIVE_PLAYLIST);
        xmmsc_result_notifier_set (refres, &refresh_active_playlist, cache);
        xmmsc_result_unref (refres);
        freshness_requested (&cache->freshness_active_playlist);
        break;
    }

    return TRUE;
}
Exemple #2
0
/**
 * Insert a value at a given position in the idlist.
 * @param coll  The collection to update.
 * @param id    The id to insert in the idlist.
 * @param index The position at which to insert the value.
 * @return  TRUE on success, false otherwise.
 */
int
xmmsv_coll_idlist_insert (xmmsv_t *coll, int index, int64_t id)
{
	x_return_val_if_fail (coll, 0);

	return xmmsv_list_insert_int (coll->value.coll->idlist, index, id);
}