39 static void dbwrite_operator (
void *key,
void *value,
void *udata);
40 static void dbwrite_coll_attributes (
const char *key,
xmmsv_t *value,
void *udata);
41 static void dbwrite_strip_tmpprops (
void *key,
void *value,
void *udata);
43 static gint value_get_dict_int (
xmmsv_t *val,
const gchar *key);
44 static const gchar *value_get_dict_string (
xmmsv_t *val,
const gchar *key);
68 coll_dbwrite_t dbinfos = { session, 1, 0 };
75 dbwrite_strip_tmpprops, NULL);
97 query =
"SELECT op.id AS id, lbl.name AS label, "
98 " lbl.namespace AS nsid, op.type AS type "
99 "FROM CollectionOperators AS op, CollectionLabels as lbl "
100 "WHERE op.id=lbl.collid "
111 id = value_get_dict_int (cmdval,
"id");
112 type = value_get_dict_int (cmdval,
"type");
113 nsid = value_get_dict_int (cmdval,
"nsid");
114 label = value_get_dict_string (cmdval,
"label");
117 if (previd < 0 ||
id != previd) {
118 coll = xmms_collection_dbread_operator (session,
id, type);
128 res = g_list_delete_link (res, res);
161 g_snprintf (query,
sizeof (query),
162 "SELECT attr.key AS key, attr.value AS value "
163 "FROM CollectionOperators AS op, CollectionAttributes AS attr "
164 "WHERE op.id=%d AND attr.collid=op.id",
id);
167 for (n = res; n; n = n->next) {
168 const gchar *key, *value;
171 key = value_get_dict_string (cmdval,
"key");
172 value = value_get_dict_string (cmdval,
"value");
180 g_snprintf (query,
sizeof (query),
181 "SELECT idl.mid AS mid "
182 "FROM CollectionOperators AS op, CollectionIdlists AS idl "
183 "WHERE op.id=%d AND idl.collid=op.id "
184 "ORDER BY idl.position",
id);
187 for (n = res; n; n = n->next) {
197 g_snprintf (query,
sizeof (query),
198 "SELECT op.id AS id, op.type AS type "
199 "FROM CollectionOperators AS op, CollectionConnections AS conn "
200 "WHERE conn.to_id=%d AND conn.from_id=op.id",
id);
203 for (n = res; n; n = n->next) {
208 _id = value_get_dict_int (cmdval,
"id");
209 type = value_get_dict_int (cmdval,
"type");
211 op = xmms_collection_dbread_operator (session, _id, type);
240 coll_dbwrite_t dbwrite_infos = { session, collid, 0 };
243 g_snprintf (query,
sizeof (query),
244 "INSERT INTO CollectionOperators VALUES(%d, %d)",
261 g_snprintf (query,
sizeof (query),
262 "INSERT INTO CollectionIdlists VALUES(%d, %d, %d)",
284 nextid = xmms_collection_dbwrite_operator (session, newid, op);
285 g_snprintf (query,
sizeof (query),
286 "INSERT INTO CollectionConnections VALUES(%d, %d)",
301 dbwrite_operator (
void *key,
void *value,
void *udata)
306 coll_dbwrite_t *dbinfos = udata;
312 serial_id = dbinfos->collid;
313 dbinfos->collid = xmms_collection_dbwrite_operator (dbinfos->session,
314 dbinfos->collid, coll);
319 query = g_strdup_printf (
"INSERT INTO CollectionLabels VALUES(%d, %d, %s)",
320 serial_id, dbinfos->nsid, esc_label);
329 dbwrite_coll_attributes (
const char *key,
xmmsv_t *value,
void *udata)
332 coll_dbwrite_t *dbwrite_infos = udata;
339 g_return_if_fail (r);
343 query = g_strdup_printf (
"INSERT INTO CollectionAttributes VALUES(%d, %s, %s)",
344 dbwrite_infos->collid, esc_key, esc_val);
354 dbwrite_strip_tmpprops (
void *key,
void *value,
void *udata)
363 value_get_dict_int (
xmmsv_t *val,
const gchar *key)
372 value_get_dict_string (
xmmsv_t *val,
const gchar *key)