45 const gchar *
namespace;
48 } coll_rebind_infos_t;
53 const gchar*
namespace;
54 } coll_rename_infos_t;
63 const gchar *target_name;
64 const gchar *target_namespace;
79 typedef struct add_metadata_from_tree_user_data_St {
85 static GList *global_stream_type;
91 static gboolean xmms_collection_validate (
xmms_coll_dag_t *dag,
xmmsv_coll_t *coll,
const gchar *save_name,
const gchar *save_namespace);
92 static gboolean xmms_collection_validate_recurs (
xmms_coll_dag_t *dag,
xmmsv_coll_t *coll,
const gchar *save_name,
const gchar *save_namespace);
93 static gboolean xmms_collection_unreference (
xmms_coll_dag_t *dag,
const gchar *name, guint nsid);
95 static gboolean xmms_collection_has_reference_to (
xmms_coll_dag_t *dag,
xmmsv_coll_t *coll,
const gchar *tg_name,
const gchar *tg_ns);
99 static void call_apply_to_coll (gpointer name, gpointer coll, gpointer udata);
100 static void prepend_key_string (gpointer key, gpointer value, gpointer udata);
101 static gboolean value_match_save_key (gpointer key, gpointer val, gpointer udata);
108 static void coll_unref (
void *coll);
112 static gboolean filter_get_mediainfo_field_string (
xmmsv_coll_t *coll, GHashTable *mediainfo, gchar **val);
113 static gboolean filter_get_mediainfo_field_int (
xmmsv_coll_t *coll, GHashTable *mediainfo, gint *val);
114 static gboolean filter_get_operator_value_string (
xmmsv_coll_t *coll,
const gchar **val);
115 static gboolean filter_get_operator_value_int (
xmmsv_coll_t *coll, gint *val);
116 static gboolean filter_get_operator_case (
xmmsv_coll_t *coll, gboolean *val);
118 static void build_match_table (gpointer key, gpointer value, gpointer udata);
119 static gboolean find_unchecked (gpointer name, gpointer value, gpointer udata);
120 static void build_list_matches (gpointer key, gpointer value, gpointer udata);
122 static gboolean xmms_collection_media_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
123 static gboolean xmms_collection_media_match_operand (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
124 static gboolean xmms_collection_media_match_reference (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table,
const gchar *refname,
const gchar *refns);
125 static gboolean xmms_collection_media_filter_has (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
126 static gboolean xmms_collection_media_filter_equals (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
127 static gboolean xmms_collection_media_filter_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
128 static gboolean xmms_collection_media_filter_smaller (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
129 static gboolean xmms_collection_media_filter_greater (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
xmmsv_coll_t *coll, guint nsid, GHashTable *match_table);
134 static void xmms_collection_client_remove (
xmms_coll_dag_t *dag,
const gchar *collname,
const gchar *
namespace,
xmms_error_t *error);
136 static void xmms_collection_client_rename (
xmms_coll_dag_t *dag,
const gchar *from_name,
const gchar *to_name,
const gchar *
namespace,
xmms_error_t *error);
144 #include "collection_ipc.c" 148 const gchar *plname,
const gchar *
namespace)
152 dict = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
155 g_tree_insert (dict, (gpointer)
"type",
xmmsv_new_int (type));
165 g_return_if_fail (colldag);
166 g_return_if_fail (dict);
173 g_tree_destroy (dict);
176 #define XMMS_COLLECTION_CHANGED_MSG(type, name, namespace) xmms_collection_changed_msg_send (dag, xmms_collection_changed_msg_new (type, name, namespace)) 191 struct xmms_coll_dag_St {
221 ret->mutex = g_mutex_new ();
222 ret->playlist = playlist;
227 ret->collrefs[i] = g_hash_table_new_full (g_str_hash, g_str_equal,
231 xmms_collection_register_ipc_commands (
XMMS_OBJECT (ret));
256 "application/x-xmms2-playlist-entries",
258 global_stream_type = g_list_prepend (NULL, f);
264 add_metadata_from_tree (
const gchar *key,
xmmsv_t *value, gpointer user_data)
330 xmms_log_error (
"Playlist plugin did not set realpath; probably a bug in plugin");
332 n = g_list_delete_link (n, n);
343 udata.session = session;
356 n = g_list_delete_link (n, n);
376 xmms_collection_client_remove (
xmms_coll_dag_t *dag,
const gchar *name,
380 gboolean retval = FALSE;
389 g_mutex_lock (dag->mutex);
394 retval = xmms_collection_unreference (dag, name, i) || retval;
397 retval = xmms_collection_unreference (dag, name, nsid);
400 g_mutex_unlock (dag->mutex);
402 if (retval == FALSE) {
403 xmms_error_set (err,
XMMS_ERROR_NOENT,
"Failed to remove this collection!");
418 xmms_collection_client_save (
xmms_coll_dag_t *dag,
const gchar *name,
const gchar *
namespace,
424 gchar *newkey = NULL;
436 if (!xmms_collection_validate (dag, coll, name,
namespace)) {
441 g_mutex_lock (dag->mutex);
445 if (existing != NULL) {
447 coll_rebind_infos_t infos = { name,
namespace, existing, coll };
455 if (existing != NULL) {
457 existing, NULL)) != NULL) {
458 newkey = g_strdup (alias);
471 newkey = g_strdup (name);
480 g_mutex_unlock (dag->mutex);
513 g_mutex_lock (dag->mutex);
526 g_mutex_unlock (dag->mutex);
541 g_return_if_fail (dag);
543 g_mutex_lock (dag->mutex);
547 g_mutex_unlock (dag->mutex);
568 xmms_collection_client_list (
xmms_coll_dag_t *dag,
const gchar *
namespace,
580 g_mutex_lock (dag->mutex);
585 g_mutex_unlock (dag->mutex);
600 xmms_collection_client_find (
xmms_coll_dag_t *dag, gint32 mid,
const gchar *
namespace,
603 GHashTable *mediainfo;
607 GHashTable *match_table;
622 match_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
626 mediainfo = xmms_collection_media_info (mid, err);
629 while (g_hash_table_find (match_table, find_unchecked, &open_name) != NULL) {
632 if (xmms_collection_media_match (dag, mediainfo, coll, nsid, match_table)) {
637 g_hash_table_replace (match_table, g_strdup (open_name), match);
641 g_hash_table_foreach (match_table, build_list_matches, &ret);
642 g_hash_table_destroy (match_table);
644 g_hash_table_destroy (mediainfo);
660 xmms_collection_client_rename (
xmms_coll_dag_t *dag,
const gchar *from_name,
661 const gchar *to_name,
const gchar *
namespace,
673 xmms_error_set (err,
XMMS_ERROR_GENERIC,
"cannot rename collection in all namespaces");
677 g_mutex_lock (dag->mutex);
683 if (from_coll == NULL) {
687 }
else if (to_coll != NULL) {
688 xmms_error_set (err,
XMMS_ERROR_NOENT,
"a collection already exists with the target name");
700 g_hash_table_remove (dag->collrefs[nsid], from_name);
703 coll_rename_infos_t infos = { from_name, to_name,
namespace };
708 from_name,
namespace);
715 g_mutex_unlock (dag->mutex);
732 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
736 xmmsv_t *fetch, *group, *idval;
744 res = xmms_collection_client_query_infos (dag, coll, lim_start, lim_len, order, fetch, group, err);
747 for (n = res; n; n = n->next) {
749 xmmsv_t *id_val, *cmdval = n->data;
768 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
787 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
814 if (!xmms_collection_validate (dag, coll, NULL, NULL)) {
821 g_mutex_lock (dag->mutex);
824 order, fetch, group);
826 g_mutex_unlock (dag->mutex);
828 XMMS_DBG (
"COLLECTIONS: query_infos with %s", query->str);
835 g_string_free (query, TRUE);
862 g_hash_table_replace (dag->collrefs[nsid], key, newcoll);
881 coll = g_hash_table_lookup (dag->collrefs[i], collname);
884 coll = g_hash_table_lookup (dag->collrefs[nsid], collname);
900 gboolean retval = FALSE;
906 buf = strtol (str, &endptr, 10);
909 if (*endptr ==
'\0') {
929 gboolean retval = FALSE;
933 written = g_snprintf (str,
sizeof (str),
"%d", newval);
958 const gchar *otherkey = NULL;
959 coll_table_pair_t search_pair = { key, value };
961 if (g_hash_table_find (dag->collrefs[nsid], value_match_save_key,
962 &search_pair) != NULL) {
963 otherkey = search_pair.key;
1017 g_return_if_fail (dag);
1022 g_mutex_free (dag->mutex);
1025 g_hash_table_destroy (dag->collrefs[i]);
1028 xmms_collection_unregister_ipc_commands ();
1043 const gchar *save_name,
const gchar *save_namespace)
1046 if (save_namespace != NULL &&
1057 return xmms_collection_validate_recurs (dag, coll, save_name,
1067 const gchar *save_name,
const gchar *save_namespace)
1069 guint num_operands = 0;
1071 gchar *attr, *attr2;
1072 gboolean valid = TRUE;
1084 if (num_operands > 1) {
1092 }
else if (strcmp (attr,
"All Media") != 0) {
1095 if (attr2 == NULL) {
1104 g_mutex_lock (dag->mutex);
1107 g_mutex_unlock (dag->mutex);
1111 if (save_name && save_namespace) {
1113 if (strcmp (attr, save_name) == 0 &&
1114 strcmp (attr2, save_namespace) == 0) {
1116 g_mutex_unlock (dag->mutex);
1120 }
else if (xmms_collection_has_reference_to (dag, ref, save_name,
1122 g_mutex_unlock (dag->mutex);
1127 g_mutex_unlock (dag->mutex);
1134 if (num_operands == 1) {
1148 if (num_operands == 0) {
1155 if (num_operands != 1) {
1162 if (num_operands != 1) {
1178 if (num_operands != 1) {
1201 if (num_operands > 0) {
1208 if (num_operands != 1) {
1233 if (!xmms_collection_validate_recurs (dag, op, save_name,
1253 xmms_collection_unreference (
xmms_coll_dag_t *dag,
const gchar *name, guint nsid)
1256 gboolean retval = FALSE;
1258 existing = g_hash_table_lookup (dag->collrefs[nsid], name);
1263 if (existing != NULL && existing != active_pl) {
1264 const gchar *matchkey;
1266 coll_rebind_infos_t infos = { name, nsname, existing, NULL };
1276 existing, NULL)) != NULL) {
1282 g_hash_table_remove (dag->collrefs[nsid], matchkey);
1356 const gchar *tg_name,
const gchar *tg_ns)
1358 coll_refcheck_t check = { tg_name, tg_ns, FALSE };
1379 g_hash_table_foreach (dag->collrefs[i], f, udata);
1382 g_hash_table_foreach (dag->collrefs[nsid], f, udata);
1397 coll_call_infos_t callinfos = { dag, f, udata };
1400 g_hash_table_foreach (dag->collrefs[i], call_apply_to_coll, &callinfos);
1416 xmms_collection_apply_to_collection_recurs (dag, coll, NULL, f, udata);
1429 f (dag, coll, parent, udata);
1445 xmms_collection_apply_to_collection_recurs (dag, op, coll, f,
1458 call_apply_to_coll (gpointer name, gpointer coll, gpointer udata)
1460 coll_call_infos_t *callinfos = (coll_call_infos_t*)udata;
1463 callinfos->func, callinfos->udata);
1470 prepend_key_string (gpointer key, gpointer value, gpointer udata)
1472 GList **list = (GList**)udata;
1482 value_match_save_key (gpointer key, gpointer val, gpointer udata)
1484 gboolean found = FALSE;
1485 coll_table_pair_t *pair = (coll_table_pair_t*)udata;
1489 if ((coll == pair->value) &&
1490 (pair->key == NULL || strcmp (pair->key, key) != 0)) {
1508 gchar *target_namespace;
1513 if (target_name == NULL || target_namespace == NULL ||
1514 strcmp (target_name,
"All Media") == 0) {
1524 if (target == NULL) {
1541 coll_rebind_infos_t *infos;
1543 gchar *target_name = NULL;
1544 gchar *target_namespace = NULL;
1546 infos = (coll_rebind_infos_t*)udata;
1552 if (strcmp (infos->name, target_name) != 0 ||
1553 strcmp (infos->namespace, target_namespace) != 0) {
1570 coll_rename_infos_t *infos;
1572 gchar *target_name = NULL;
1573 gchar *target_namespace = NULL;
1575 infos = (coll_rename_infos_t*)udata;
1579 if (strcmp (infos->oldname, target_name) == 0 &&
1580 strcmp (infos->namespace, target_namespace) == 0) {
1594 coll_rebind_infos_t *infos;
1595 gchar *target_name = NULL;
1596 gchar *target_namespace = NULL;
1600 infos = (coll_rebind_infos_t*)udata;
1617 if (strcmp (infos->name, target_name) != 0 ||
1618 strcmp (infos->namespace, target_namespace) != 0) {
1642 coll_refcheck_t *check = (coll_refcheck_t*)udata;
1644 gchar *target_name, *target_namespace;
1648 if (strcmp (check->target_name, target_name) == 0 &&
1649 strcmp (check->target_namespace, target_namespace) == 0) {
1650 check->found = TRUE;
1657 xmms_collection_apply_to_collection_recurs (dag, op, coll,
1658 check_for_reference,
1671 coll_unref (
void *coll)
1682 build_match_table (gpointer key, gpointer value, gpointer udata)
1684 GHashTable *match_table = udata;
1687 g_hash_table_replace (match_table, g_strdup (key), match);
1694 find_unchecked (gpointer name, gpointer value, gpointer udata)
1697 gchar **open = udata;
1706 build_list_matches (gpointer key, gpointer value, gpointer udata)
1708 gchar *coll_name = key;
1710 GList **list = udata;
1726 xmms_collection_media_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1728 GHashTable *match_table)
1730 gboolean match = FALSE;
1732 gchar *attr1 = NULL, *attr2 = NULL;
1740 if (strcmp (attr1,
"All Media") == 0) {
1743 match = xmms_collection_media_match_reference (dag, mediainfo,
1762 match = xmms_collection_media_match (dag, mediainfo, op,
1780 match = xmms_collection_media_match (dag, mediainfo, op,
1788 match = !xmms_collection_media_match_operand (dag, mediainfo, coll,
1793 match = xmms_collection_media_filter_has (dag, mediainfo, coll,
1798 match = xmms_collection_media_filter_equals (dag, mediainfo, coll,
1803 match = xmms_collection_media_filter_match (dag, mediainfo, coll,
1808 match = xmms_collection_media_filter_smaller (dag, mediainfo, coll,
1813 match = xmms_collection_media_filter_greater (dag, mediainfo, coll,
1821 val = g_hash_table_lookup (mediainfo,
"id");
1842 XMMS_DBG (
"invalid collection operator in xmms_collection_media_match");
1843 g_assert_not_reached ();
1862 xmms_collection_media_match_reference (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1864 GHashTable *match_table,
1865 const gchar *refname,
const gchar *refns)
1873 if (refnsid == nsid) {
1874 matchstate = g_hash_table_lookup (match_table, refname);
1878 match = xmms_collection_media_match_operand (dag,
1889 g_hash_table_replace (match_table, g_strdup (refname), matchstate);
1897 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
1915 xmms_collection_media_match_operand (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1917 GHashTable *match_table)
1921 gboolean match = FALSE;
1926 match = xmms_collection_media_match (dag, mediainfo, op, nsid, match_table);
1953 infos = g_hash_table_new_full (g_str_hash, g_str_equal,
1955 for (state = 0, n = res; n; state = (state + 1) % 3, n = n->next) {
1963 name = g_strdup (buf);
1970 if (g_hash_table_lookup (infos, name) == NULL) {
1971 g_hash_table_replace (infos, name, value);
1991 GHashTable *mediainfo, gchar **val)
1993 gboolean retval = FALSE;
1998 cmdval = g_hash_table_lookup (mediainfo, attr);
1999 if (cmdval != NULL) {
2005 *val = g_strdup (s);
2013 *val = g_strdup_printf (
"%d", i);
2032 filter_get_mediainfo_field_int (
xmmsv_coll_t *coll, GHashTable *mediainfo, gint *val)
2034 gboolean retval = FALSE;
2039 cmdval = g_hash_table_lookup (mediainfo, attr);
2051 filter_get_operator_value_string (
xmmsv_coll_t *coll,
const gchar **val)
2066 filter_get_operator_value_int (
xmmsv_coll_t *coll, gint *val)
2082 filter_get_operator_case (
xmmsv_coll_t *coll, gboolean *val)
2087 *val = (strcmp (attr,
"true") == 0);
2098 xmms_collection_media_filter_has (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2100 GHashTable *match_table)
2102 gboolean match = FALSE;
2106 if (filter_get_mediainfo_field_string (coll, mediainfo, &mediaval)) {
2107 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2118 xmms_collection_media_filter_equals (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2120 GHashTable *match_table)
2122 gboolean match = FALSE;
2123 gchar *mediaval = NULL;
2127 if (filter_get_mediainfo_field_string (coll, mediainfo, &mediaval) &&
2128 filter_get_operator_value_string (coll, &opval) &&
2129 filter_get_operator_case (coll, &case_sens)) {
2132 match = (strcmp (mediaval, opval) == 0);
2134 match = (g_ascii_strcasecmp (mediaval, opval) == 0);
2140 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2144 if (mediaval != NULL) {
2153 xmms_collection_media_filter_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2155 GHashTable *match_table)
2157 gboolean match = FALSE;
2158 gchar *buf, *opval, *mediaval;
2162 if (filter_get_mediainfo_field_string (coll, mediainfo, &buf) &&
2163 filter_get_operator_value_string (coll, &s) &&
2164 filter_get_operator_case (coll, &case_sens)) {
2168 opval = g_strdup (s);
2169 mediaval = g_strdup (buf);
2171 opval = g_utf8_strdown (s, -1);
2172 mediaval = g_utf8_strdown (buf, -1);
2175 match = g_pattern_match_simple (opval, mediaval);
2183 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2193 xmms_collection_media_filter_smaller (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2195 GHashTable *match_table)
2197 gboolean match = FALSE;
2202 if (filter_get_mediainfo_field_int (coll, mediainfo, &mediaval) &&
2203 filter_get_operator_value_int (coll, &opval) &&
2204 (mediaval < opval) ) {
2206 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2215 xmms_collection_media_filter_greater (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2217 GHashTable *match_table)
2219 gboolean match = FALSE;
2224 if (filter_get_mediainfo_field_int (coll, mediainfo, &mediaval) &&
2225 filter_get_operator_value_int (coll, &opval) &&
2226 (mediaval > opval) ) {
2228 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
void xmmsv_list_iter_first(xmmsv_list_iter_t *it)
Rewind the iterator to the start of the list.
struct xmmsv_list_iter_St xmmsv_list_iter_t
xmms_medialib_entry_t xmms_collection_get_random_media(xmms_coll_dag_t *dag, xmmsv_coll_t *source)
Get a random media entry from the given collection.
const gchar * xmms_collection_get_namespace_string(xmms_collection_namespace_id_t nsid)
Find the namespace name (string) corresponding to a namespace id.
void xmmsv_unref(xmmsv_t *val)
Decreases the references for the xmmsv_t When the number of references reaches 0 it will be freed...
#define xmms_object_unref(obj)
int xmmsv_list_append(xmmsv_t *listv, xmmsv_t *val)
Append an element to the end of the list xmmsv_t.
int xmmsv_coll_attribute_get(xmmsv_coll_t *coll, const char *key, char **value)
Retrieve the value of the attribute of the given collection.
int xmmsv_list_clear(xmmsv_t *listv)
Empty the list from all its elements.
void bind_all_references(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata)
If a reference, add the operator of the pointed collection as an operand.
xmms_collection_namespace_id_t xmms_collection_get_namespace_id(const gchar *namespace)
Find the namespace id corresponding to a namespace string.
int xmmsv_coll_idlist_append(xmmsv_coll_t *coll, int id)
Append a value to the idlist.
#define xmms_error_iserror(e)
struct xmms_stream_type_St xmms_stream_type_t
int xmmsv_list_iter_remove(xmmsv_list_iter_t *it)
Remove the element in the list at the position pointed at by the iterator.
void xmmsv_coll_attribute_set(xmmsv_coll_t *coll, const char *key, const char *value)
Set an attribute in the given collection.
xmmsv_t * xmmsv_new_string(const char *s)
Allocates a new string xmmsv_t.
xmmsv_coll_t * xmmsv_coll_ref(xmmsv_coll_t *coll)
Increases the references for the xmmsv_coll_t.
void(* FuncApplyToColl)(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata)
int xmmsv_get_int(const xmmsv_t *val, int32_t *r)
Retrieves a signed integer from the value.
void xmms_coll_sync_init(xmms_coll_dag_t *dag)
Get the collection-to-database-synchronization thread running.
xmmsv_coll_t * xmms_collection_get_pointer(xmms_coll_dag_t *dag, const gchar *collname, guint nsid)
Find the collection structure corresponding to the given name in the given namespace.
#define XMMS_MAX_INT_ATTRIBUTE_LEN
gboolean check_string_list(xmmsv_t *list)
Checks that the list only contains string values.
void xmms_collection_changed_msg_send(xmms_coll_dag_t *colldag, GTree *dict)
int xmmsv_get_list_iter(const xmmsv_t *val, xmmsv_list_iter_t **it)
Retrieves a list iterator from a list xmmsv_t.
struct xmmsv_St * xmmsv_coll_operands_get(xmmsv_coll_t *coll)
gboolean xmms_collection_get_int_attr(xmmsv_coll_t *coll, const gchar *attrname, gint *val)
Extract an attribute from a collection as an integer.
int xmmsv_dict_foreach(xmmsv_t *dictv, xmmsv_dict_foreach_func func, void *user_data)
Apply a function to each key-element pair in the list.
GList * xmms_collection_query_ids(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, gint32 lim_start, gint32 lim_len, xmmsv_t *order, xmms_error_t *err)
Find the ids of the media matched by a collection.
struct xmmsv_St * xmmsv_coll_idlist_get(xmmsv_coll_t *coll)
Return the list of ids stored in the collection.
xmms_stream_type_t * _xmms_stream_type_new(const gchar *begin,...)
xmms_collection_namespace_id_t
#define xmms_log_error(fmt,...)
#define XMMS_COLLECTION_CHANGED_MSG(type, name, namespace)
#define XMMS_COLLECTION_NS_PLAYLISTS
int xmmsv_dict_get(xmmsv_t *dictv, const char *key, xmmsv_t **val)
Get the element corresponding to the given key in the dict xmmsv_t (if it exists).
void xmms_object_emit_f(xmms_object_t *object, guint32 signalid, xmmsv_type_t type,...)
Emits a signal on the current object.
void xmmsv_list_iter_next(xmmsv_list_iter_t *it)
Advance the iterator to the next element in the list.
xmmsv_t * xmmsv_new_list(void)
Allocates a new list xmmsv_t.
void xmmsv_list_iter_explicit_destroy(xmmsv_list_iter_t *it)
Explicitly free list iterator.
struct xmmsv_coll_St xmmsv_coll_t
int xmmsv_list_get(xmmsv_t *listv, int pos, xmmsv_t **val)
Get the element at the given position in the list xmmsv_t.
GString * xmms_collection_get_query(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, guint limit_start, guint limit_len, xmmsv_t *order, xmmsv_t *fetch, xmmsv_t *group)
#define XMMS_STREAM_TYPE_BEGIN
struct xmms_playlist_St xmms_playlist_t
void xmms_collection_apply_to_all_collections(xmms_coll_dag_t *dag, FuncApplyToColl f, void *udata)
Apply a function of type FuncApplyToColl to all the collections in all namespaces.
void xmms_collection_dag_save(xmms_coll_dag_t *dag)
Save the collection DAG in the database.
struct add_metadata_from_tree_user_data_St add_metadata_from_tree_user_data_t
xmmsv_t * xmmsv_new_coll(xmmsv_coll_t *coll)
Allocates a new collection xmmsv_t.
void xmms_collection_update_pointer(xmms_coll_dag_t *dag, const gchar *name, guint nsid, xmmsv_coll_t *newtarget)
Update a reference to point to a new collection.
xmmsv_coll_t * xmmsv_coll_new(xmmsv_coll_type_t type)
Allocate a new collection of the given type.
xmmsv_type_t xmmsv_get_type(const xmmsv_t *val)
Get the type of the value.
xmms_collection_changed_actions_t
xmmsv_t * xmmsv_new_int(int32_t i)
Allocates a new integer xmmsv_t.
gboolean xmms_collection_set_int_attr(xmmsv_coll_t *coll, const gchar *attrname, gint newval)
Set the attribute of a collection as an integer.
void xmmsv_coll_add_operand(xmmsv_coll_t *coll, xmmsv_coll_t *op)
Add the operand to the given collection.
int xmmsv_list_get_size(xmmsv_t *listv)
Return the size of the list.
xmmsv_t * xmmsv_ref(xmmsv_t *val)
References the xmmsv_t.
void xmms_collection_dag_replace(xmms_coll_dag_t *dag, xmms_collection_namespace_id_t nsid, gchar *key, xmmsv_coll_t *newcoll)
Update the DAG to update the value of the pair with the given key.
#define XMMS_ACTIVE_PLAYLIST
const gchar * xmms_collection_find_alias(xmms_coll_dag_t *dag, guint nsid, xmmsv_coll_t *value, const gchar *key)
Reverse-search the list of collections in the given namespace to find the first pair whose value matc...
void xmmsv_coll_remove_operand(xmmsv_coll_t *coll, xmmsv_coll_t *op)
Remove all the occurences of the operand in the given collection.
void xmms_coll_sync_shutdown()
Shutdown the collection-to-database-synchronization thread.
#define XMMS_PLAYLIST_COLLECTION_CHANGED_MSG(playlist, name)
void xmms_collection_apply_to_collection(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, FuncApplyToColl f, void *udata)
Apply a function of type FuncApplyToColl to the given collection.
#define XMMS_COLLECTION_NUM_NAMESPACES
void xmms_collection_dag_restore(xmms_coll_dag_t *dag)
Restore the collection DAG from the database.
void xmms_coll_sync_schedule_sync()
Schedule a collection-to-database-synchronization in 10 seconds.
#define XMMS_DBG(fmt,...)
void xmms_object_connect(xmms_object_t *object, guint32 signalid, xmms_object_handler_t handler, gpointer userdata)
Connect to a signal that is emitted by this object.
xmms_coll_dag_t * xmms_collection_init(xmms_playlist_t *playlist)
Initializes a new xmms_coll_dag_t.
int xmmsv_list_iter_valid(xmmsv_list_iter_t *it)
Check whether the iterator is valid and points to a valid element.
int xmmsv_get_string(const xmmsv_t *val, const char **r)
Retrieves a string from the value.
int xmmsv_list_iter_insert(xmmsv_list_iter_t *it, xmmsv_t *val)
Insert an element in the list at the position pointed at by the iterator.
void xmms_collection_foreach_in_namespace(xmms_coll_dag_t *dag, guint nsid, GHFunc f, void *udata)
Apply a function to all the collections in a given namespace.
#define xmms_object_new(objtype, destroyfunc)
G_BEGIN_DECLS struct xmms_error_St xmms_error_t
int xmmsv_list_iter_entry(xmmsv_list_iter_t *it, xmmsv_t **val)
Get the element currently pointed at by the iterator.
int xmmsv_list_iter_entry_int(xmmsv_list_iter_t *it, int32_t *val)
#define XMMS_COLLECTION_NS_COLLECTIONS
void xmms_collection_sync(xmms_coll_dag_t *dag)
Synchronize collection data to the database (i.e.
int xmmsv_dict_remove(xmmsv_t *dictv, const char *key)
Remove the element corresponding to a given key in the dict xmmsv_t (if it exists).
xmmsv_coll_type_t xmmsv_coll_get_type(xmmsv_coll_t *coll)
Return the type of the collection.
#define XMMS_COLLECTION_NS_ALL
GTree * xmms_collection_changed_msg_new(xmms_collection_changed_actions_t type, const gchar *plname, const gchar *namespace)
int xmmsv_get_coll(const xmmsv_t *val, xmmsv_coll_t **coll)
Retrieves a collection from the value.
struct xmms_coll_dag_St xmms_coll_dag_t
void xmmsv_coll_unref(xmmsv_coll_t *coll)
Decreases the references for the xmmsv_coll_t When the number of references reaches 0 it will be free...