static void setup_default_playlist (void) { xmmsv_coll_t *coll; coll = xmmsv_coll_new (XMMS_COLLECTION_TYPE_IDLIST); xmms_collection_dag_replace (colldag, XMMS_COLLECTION_NSID_PLAYLISTS, "Default", coll); xmmsv_coll_ref (coll); xmms_collection_dag_replace (colldag, XMMS_COLLECTION_NSID_PLAYLISTS, XMMS_ACTIVE_PLAYLIST, coll); }
/** Restore the collection DAG from the database. * * @param dag The collection DAG to restore to. */ void xmms_collection_dag_restore (xmms_coll_dag_t *dag) { xmmsv_coll_t *coll = NULL; xmms_medialib_session_t *session; xmmsv_t *cmdval; const gchar *query; GList *res; gint previd; session = xmms_medialib_begin (); /* Fetch all label-coll_operator for all namespaces, register in table */ query = "SELECT op.id AS id, lbl.name AS label, " " lbl.namespace AS nsid, op.type AS type " "FROM CollectionOperators AS op, CollectionLabels as lbl " "WHERE op.id=lbl.collid " "ORDER BY id"; res = xmms_medialib_select (session, query, NULL); previd = -1; while (res) { gint id, type, nsid; const gchar *label; cmdval = (xmmsv_t*) res->data; id = value_get_dict_int (cmdval, "id"); type = value_get_dict_int (cmdval, "type"); nsid = value_get_dict_int (cmdval, "nsid"); label = value_get_dict_string (cmdval, "label"); /* Do not duplicate operator if same id */ if (previd < 0 || id != previd) { coll = xmms_collection_dbread_operator (session, id, type); previd = id; } else { xmmsv_coll_ref (coll); /* New label references the coll */ } xmms_collection_dag_replace (dag, nsid, g_strdup (label), coll); xmmsv_unref (cmdval); res = g_list_delete_link (res, res); } xmms_medialib_end (session); /* FIXME: validate ? */ /* Link references in collections to actual operators */ xmms_collection_apply_to_all_collections (dag, bind_all_references, NULL); }