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);
110 static GHashTable *xmms_collection_media_info (guint mid,
xmms_error_t *err);
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);
160 const gchar *plname,
const gchar *
namespace)
164 dict = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
167 g_tree_insert (dict, (gpointer)
"type",
xmmsv_new_int (type));
177 g_return_if_fail (colldag);
178 g_return_if_fail (dict);
185 g_tree_destroy (dict);
188 #define XMMS_COLLECTION_CHANGED_MSG(type, name, namespace) xmms_collection_changed_msg_send (dag, xmms_collection_changed_msg_new (type, name, namespace))
203 struct xmms_coll_dag_St {
233 ret->mutex = g_mutex_new ();
234 ret->playlist = playlist;
239 ret->collrefs[i] = g_hash_table_new_full (g_str_hash, g_str_equal,
311 "application/x-xmms2-playlist-entries",
313 global_stream_type = g_list_prepend (NULL, f);
319 add_metadata_from_tree (
const gchar *key,
xmmsv_t *value, gpointer user_data)
348 xmms_collection_client_idlist_from_pls (
xmms_coll_dag_t *dag,
const gchar *path,
384 xmms_log_error (
"Playlist plugin did not set realpath; probably a bug in plugin");
386 n = g_list_delete_link (n, n);
397 udata.session = session;
410 n = g_list_delete_link (n, n);
430 xmms_collection_client_remove (
xmms_coll_dag_t *dag,
const gchar *name,
434 gboolean retval = FALSE;
443 g_mutex_lock (dag->mutex);
448 retval = xmms_collection_unreference (dag, name, i) || retval;
451 retval = xmms_collection_unreference (dag, name, nsid);
454 g_mutex_unlock (dag->mutex);
456 if (retval == FALSE) {
457 xmms_error_set (err,
XMMS_ERROR_NOENT,
"Failed to remove this collection!");
472 xmms_collection_client_save (
xmms_coll_dag_t *dag,
const gchar *name,
const gchar *
namespace,
478 gchar *newkey = NULL;
490 if (!xmms_collection_validate (dag, coll, name,
namespace)) {
495 g_mutex_lock (dag->mutex);
499 if (existing != NULL) {
501 coll_rebind_infos_t infos = { name,
namespace, existing, coll };
509 if (existing != NULL) {
511 existing, NULL)) != NULL) {
512 newkey = g_strdup (alias);
525 newkey = g_strdup (name);
534 g_mutex_unlock (dag->mutex);
567 g_mutex_lock (dag->mutex);
580 g_mutex_unlock (dag->mutex);
595 g_return_if_fail (dag);
597 g_mutex_lock (dag->mutex);
601 g_mutex_unlock (dag->mutex);
622 xmms_collection_client_list (
xmms_coll_dag_t *dag,
const gchar *
namespace,
634 g_mutex_lock (dag->mutex);
639 g_mutex_unlock (dag->mutex);
654 xmms_collection_client_find (
xmms_coll_dag_t *dag, gint32 mid,
const gchar *
namespace,
657 GHashTable *mediainfo;
661 GHashTable *match_table;
676 match_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
680 mediainfo = xmms_collection_media_info (mid, err);
683 while (g_hash_table_find (match_table, find_unchecked, &open_name) != NULL) {
686 if (xmms_collection_media_match (dag, mediainfo, coll, nsid, match_table)) {
691 g_hash_table_replace (match_table, g_strdup (open_name), match);
695 g_hash_table_foreach (match_table, build_list_matches, &ret);
696 g_hash_table_destroy (match_table);
698 g_hash_table_destroy (mediainfo);
714 xmms_collection_client_rename (
xmms_coll_dag_t *dag,
const gchar *from_name,
715 const gchar *to_name,
const gchar *
namespace,
727 xmms_error_set (err,
XMMS_ERROR_GENERIC,
"cannot rename collection in all namespaces");
731 g_mutex_lock (dag->mutex);
737 if (from_coll == NULL) {
741 }
else if (to_coll != NULL) {
742 xmms_error_set (err,
XMMS_ERROR_NOENT,
"a collection already exists with the target name");
754 g_hash_table_remove (dag->collrefs[nsid], from_name);
757 coll_rename_infos_t infos = { from_name, to_name,
namespace };
762 from_name,
namespace);
769 g_mutex_unlock (dag->mutex);
786 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
790 xmmsv_t *fetch, *group, *idval;
798 res = xmms_collection_client_query_infos (dag, coll, lim_start, lim_len, order, fetch, group, err);
801 for (n = res; n; n = n->next) {
803 xmmsv_t *id_val, *cmdval = n->data;
822 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
841 gint32 lim_start, gint32 lim_len,
xmmsv_t *order,
868 if (!xmms_collection_validate (dag, coll, NULL, NULL)) {
875 g_mutex_lock (dag->mutex);
878 order, fetch, group);
880 g_mutex_unlock (dag->mutex);
882 XMMS_DBG (
"COLLECTIONS: query_infos with %s", query->str);
889 g_string_free (query, TRUE);
916 g_hash_table_replace (dag->collrefs[nsid], key, newcoll);
935 coll = g_hash_table_lookup (dag->collrefs[i], collname);
938 coll = g_hash_table_lookup (dag->collrefs[nsid], collname);
954 gboolean retval = FALSE;
960 buf = strtol (str, &endptr, 10);
963 if (*endptr ==
'\0') {
983 gboolean retval = FALSE;
987 written = g_snprintf (str,
sizeof (str),
"%d", newval);
1012 const gchar *otherkey = NULL;
1013 coll_table_pair_t search_pair = { key, value };
1015 if (g_hash_table_find (dag->collrefs[nsid], value_match_save_key,
1016 &search_pair) != NULL) {
1017 otherkey = search_pair.key;
1071 g_return_if_fail (dag);
1076 g_mutex_free (dag->mutex);
1079 g_hash_table_destroy (dag->collrefs[i]);
1099 const gchar *save_name,
const gchar *save_namespace)
1102 if (save_namespace != NULL &&
1113 return xmms_collection_validate_recurs (dag, coll, save_name,
1123 const gchar *save_name,
const gchar *save_namespace)
1125 guint num_operands = 0;
1127 gchar *attr, *attr2;
1128 gboolean valid = TRUE;
1140 if (num_operands > 1) {
1148 }
else if (strcmp (attr,
"All Media") != 0) {
1151 if (attr2 == NULL) {
1160 g_mutex_lock (dag->mutex);
1163 g_mutex_unlock (dag->mutex);
1167 if (save_name && save_namespace) {
1169 if (strcmp (attr, save_name) == 0 &&
1170 strcmp (attr2, save_namespace) == 0) {
1172 g_mutex_unlock (dag->mutex);
1176 }
else if (xmms_collection_has_reference_to (dag, ref, save_name,
1178 g_mutex_unlock (dag->mutex);
1183 g_mutex_unlock (dag->mutex);
1190 if (num_operands == 1) {
1204 if (num_operands == 0) {
1211 if (num_operands != 1) {
1218 if (num_operands != 1) {
1234 if (num_operands != 1) {
1257 if (num_operands > 0) {
1264 if (num_operands != 1) {
1289 if (!xmms_collection_validate_recurs (dag, op, save_name,
1309 xmms_collection_unreference (
xmms_coll_dag_t *dag,
const gchar *name, guint nsid)
1312 gboolean retval = FALSE;
1314 existing = g_hash_table_lookup (dag->collrefs[nsid], name);
1319 if (existing != NULL && existing != active_pl) {
1320 const gchar *matchkey;
1322 coll_rebind_infos_t infos = { name, nsname, existing, NULL };
1332 existing, NULL)) != NULL) {
1338 g_hash_table_remove (dag->collrefs[nsid], matchkey);
1412 const gchar *tg_name,
const gchar *tg_ns)
1414 coll_refcheck_t check = { tg_name, tg_ns, FALSE };
1435 g_hash_table_foreach (dag->collrefs[i], f, udata);
1438 g_hash_table_foreach (dag->collrefs[nsid], f, udata);
1453 coll_call_infos_t callinfos = { dag, f, udata };
1456 g_hash_table_foreach (dag->collrefs[i], call_apply_to_coll, &callinfos);
1472 xmms_collection_apply_to_collection_recurs (dag, coll, NULL, f, udata);
1485 f (dag, coll, parent, udata);
1501 xmms_collection_apply_to_collection_recurs (dag, op, coll, f,
1514 call_apply_to_coll (gpointer name, gpointer coll, gpointer udata)
1516 coll_call_infos_t *callinfos = (coll_call_infos_t*)udata;
1519 callinfos->func, callinfos->udata);
1526 prepend_key_string (gpointer key, gpointer value, gpointer udata)
1528 GList **list = (GList**)udata;
1538 value_match_save_key (gpointer key, gpointer val, gpointer udata)
1540 gboolean found = FALSE;
1541 coll_table_pair_t *pair = (coll_table_pair_t*)udata;
1545 if ((coll == pair->value) &&
1546 (pair->key == NULL || strcmp (pair->key, key) != 0)) {
1564 gchar *target_namespace;
1569 if (target_name == NULL || target_namespace == NULL ||
1570 strcmp (target_name,
"All Media") == 0) {
1580 if (target == NULL) {
1597 coll_rebind_infos_t *infos;
1599 gchar *target_name = NULL;
1600 gchar *target_namespace = NULL;
1602 infos = (coll_rebind_infos_t*)udata;
1608 if (strcmp (infos->name, target_name) != 0 ||
1609 strcmp (infos->namespace, target_namespace) != 0) {
1626 coll_rename_infos_t *infos;
1628 gchar *target_name = NULL;
1629 gchar *target_namespace = NULL;
1631 infos = (coll_rename_infos_t*)udata;
1635 if (strcmp (infos->oldname, target_name) == 0 &&
1636 strcmp (infos->namespace, target_namespace) == 0) {
1650 coll_rebind_infos_t *infos;
1651 gchar *target_name = NULL;
1652 gchar *target_namespace = NULL;
1656 infos = (coll_rebind_infos_t*)udata;
1673 if (strcmp (infos->name, target_name) != 0 ||
1674 strcmp (infos->namespace, target_namespace) != 0) {
1698 coll_refcheck_t *check = (coll_refcheck_t*)udata;
1700 gchar *target_name, *target_namespace;
1704 if (strcmp (check->target_name, target_name) == 0 &&
1705 strcmp (check->target_namespace, target_namespace) == 0) {
1706 check->found = TRUE;
1713 xmms_collection_apply_to_collection_recurs (dag, op, coll,
1714 check_for_reference,
1727 coll_unref (
void *coll)
1738 build_match_table (gpointer key, gpointer value, gpointer udata)
1740 GHashTable *match_table = udata;
1743 g_hash_table_replace (match_table, g_strdup (key), match);
1750 find_unchecked (gpointer name, gpointer value, gpointer udata)
1753 gchar **open = udata;
1762 build_list_matches (gpointer key, gpointer value, gpointer udata)
1764 gchar *coll_name = key;
1766 GList **list = udata;
1782 xmms_collection_media_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1784 GHashTable *match_table)
1786 gboolean match = FALSE;
1788 gchar *attr1 = NULL, *attr2 = NULL;
1798 if (strcmp (attr1,
"All Media") == 0) {
1801 match = xmms_collection_media_match_reference (dag, mediainfo,
1820 match = xmms_collection_media_match (dag, mediainfo, op,
1838 match = xmms_collection_media_match (dag, mediainfo, op,
1846 match = !xmms_collection_media_match_operand (dag, mediainfo, coll,
1851 match = xmms_collection_media_filter_has (dag, mediainfo, coll,
1856 match = xmms_collection_media_filter_equals (dag, mediainfo, coll,
1861 match = xmms_collection_media_filter_match (dag, mediainfo, coll,
1866 match = xmms_collection_media_filter_smaller (dag, mediainfo, coll,
1871 match = xmms_collection_media_filter_greater (dag, mediainfo, coll,
1879 val = g_hash_table_lookup (mediainfo,
"id");
1883 for (i = 0; idlist[i] != 0; i++) {
1885 if (idlist[i] ==
id) {
1895 XMMS_DBG (
"invalid collection operator in xmms_collection_media_match");
1896 g_assert_not_reached ();
1915 xmms_collection_media_match_reference (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1917 GHashTable *match_table,
1918 const gchar *refname,
const gchar *refns)
1926 if (refnsid == nsid) {
1927 matchstate = g_hash_table_lookup (match_table, refname);
1931 match = xmms_collection_media_match_operand (dag,
1942 g_hash_table_replace (match_table, g_strdup (refname), matchstate);
1950 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
1968 xmms_collection_media_match_operand (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
1970 GHashTable *match_table)
1974 gboolean match = FALSE;
1979 match = xmms_collection_media_match (dag, mediainfo, op, nsid, match_table);
1991 xmms_collection_media_info (guint mid,
xmms_error_t *err)
2006 infos = g_hash_table_new_full (g_str_hash, g_str_equal,
2008 for (state = 0, n = res; n; state = (state + 1) % 3, n = n->next) {
2016 name = g_strdup (buf);
2023 if (g_hash_table_lookup (infos, name) == NULL) {
2024 g_hash_table_replace (infos, name, value);
2044 GHashTable *mediainfo, gchar **val)
2046 gboolean retval = FALSE;
2051 cmdval = g_hash_table_lookup (mediainfo, attr);
2052 if (cmdval != NULL) {
2058 *val = g_strdup (s);
2066 *val = g_strdup_printf (
"%d", i);
2085 filter_get_mediainfo_field_int (
xmmsv_coll_t *coll, GHashTable *mediainfo, gint *val)
2087 gboolean retval = FALSE;
2092 cmdval = g_hash_table_lookup (mediainfo, attr);
2104 filter_get_operator_value_string (
xmmsv_coll_t *coll,
const gchar **val)
2119 filter_get_operator_value_int (
xmmsv_coll_t *coll, gint *val)
2135 filter_get_operator_case (
xmmsv_coll_t *coll, gboolean *val)
2140 *val = (strcmp (attr,
"true") == 0);
2151 xmms_collection_media_filter_has (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2153 GHashTable *match_table)
2155 gboolean match = FALSE;
2159 if (filter_get_mediainfo_field_string (coll, mediainfo, &mediaval)) {
2160 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2171 xmms_collection_media_filter_equals (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2173 GHashTable *match_table)
2175 gboolean match = FALSE;
2176 gchar *mediaval = NULL;
2180 if (filter_get_mediainfo_field_string (coll, mediainfo, &mediaval) &&
2181 filter_get_operator_value_string (coll, &opval) &&
2182 filter_get_operator_case (coll, &case_sens)) {
2185 match = (strcmp (mediaval, opval) == 0);
2187 match = (g_ascii_strcasecmp (mediaval, opval) == 0);
2193 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2197 if (mediaval != NULL) {
2206 xmms_collection_media_filter_match (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2208 GHashTable *match_table)
2210 gboolean match = FALSE;
2211 gchar *buf, *opval, *mediaval;
2215 if (filter_get_mediainfo_field_string (coll, mediainfo, &buf) &&
2216 filter_get_operator_value_string (coll, &s) &&
2217 filter_get_operator_case (coll, &case_sens)) {
2221 opval = g_strdup (s);
2222 mediaval = g_strdup (buf);
2224 opval = g_utf8_strdown (s, -1);
2225 mediaval = g_utf8_strdown (buf, -1);
2228 match = g_pattern_match_simple (opval, mediaval);
2236 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2246 xmms_collection_media_filter_smaller (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2248 GHashTable *match_table)
2250 gboolean match = FALSE;
2255 if (filter_get_mediainfo_field_int (coll, mediainfo, &mediaval) &&
2256 filter_get_operator_value_int (coll, &opval) &&
2257 (mediaval < opval) ) {
2259 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
2268 xmms_collection_media_filter_greater (
xmms_coll_dag_t *dag, GHashTable *mediainfo,
2270 GHashTable *match_table)
2272 gboolean match = FALSE;
2277 if (filter_get_mediainfo_field_int (coll, mediainfo, &mediaval) &&
2278 filter_get_operator_value_int (coll, &opval) &&
2279 (mediaval > opval) ) {
2281 match = xmms_collection_media_match_operand (dag, mediainfo, coll,
#define XMMS_CMD_FUNC(cmdid)
int xmmsv_coll_idlist_append(xmmsv_coll_t *coll, unsigned int id)
Append a value to the idlist.
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_coll_attribute_get(xmmsv_coll_t *coll, const char *key, char **value)
Retrieve the value of the attribute of the given collection.
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_list_get(xmmsv_t *listv, int pos, xmmsv_t **val)
Get the element at the given position in the list xmmsv_t.
void(* FuncApplyToColl)(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata)
int xmmsv_get_list_iter(const xmmsv_t *val, xmmsv_list_iter_t **it)
Retrieves a list iterator from a list xmmsv_t.
#define xmms_error_iserror(e)
struct xmms_stream_type_St xmms_stream_type_t
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).
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_object_cmd_add(xmms_object_t *object, guint cmdid, const xmms_object_cmd_desc_t *desc)
Add a command that could be called from the client API to a object.
int xmmsv_list_iter_entry(xmmsv_list_iter_t *it, xmmsv_t **val)
Get the element currently pointed at by the iterator.
void xmms_ipc_broadcast_register(xmms_object_t *object, xmms_ipc_signals_t signalid)
Register a broadcast signal.
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 xmmsv_list_iter_first(xmmsv_list_iter_t *it)
Rewind the iterator to the start of the list.
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
int xmmsv_list_append(xmmsv_t *listv, xmmsv_t *val)
Append an element to the end of the list xmmsv_t.
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)
XMMS_CMD_DEFINE4(query_ids, xmms_collection_client_query_ids, xmms_coll_dag_t *, LIST, COLL, INT32, INT32, LIST)
XMMS_CMD_DEFINE3(collection_save, xmms_collection_client_save, xmms_coll_dag_t *, NONE, STRING, STRING, COLL)
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_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).
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.
xmms_collection_namespace_id_t
#define xmms_log_error(fmt,...)
#define XMMS_COLLECTION_CHANGED_MSG(type, name, namespace)
void xmmsv_list_iter_explicit_destroy(xmmsv_list_iter_t *it)
Explicitly free list iterator.
XMMS_CMD_DEFINE(collection_get, xmms_collection_client_get, xmms_coll_dag_t *, COLL, STRING, STRING)
int xmmsv_get_coll(const xmmsv_t *val, xmmsv_coll_t **coll)
Retrieves a collection from the value.
#define XMMS_COLLECTION_NS_PLAYLISTS
xmmsv_t * xmmsv_new_coll(xmmsv_coll_t *coll)
Allocates a new collection xmmsv_t.
void xmms_object_emit_f(xmms_object_t *object, guint32 signalid, xmmsv_type_t type,...)
Emits a signal on the current object.
struct xmmsv_coll_St xmmsv_coll_t
int xmmsv_list_get_size(xmmsv_t *listv)
Return the size of the list.
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)
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.
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_list_iter_next(xmmsv_list_iter_t *it)
Advance the iterator to the next element in the list.
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
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.
int xmmsv_list_clear(xmmsv_t *listv)
Empty the list from all its elements.
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.
void xmms_ipc_object_unregister(xmms_ipc_objects_t objectid)
Remove a object from the IPC core.
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.
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.
xmms_stream_type_t * _xmms_stream_type_new(void *dumb,...)
#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.
xmmsv_t * xmmsv_new_list(void)
Allocates a new list xmmsv_t.
#define XMMS_DBG(fmt,...)
XMMS_CMD_DEFINE6(query_infos, xmms_collection_client_query_infos, xmms_coll_dag_t *, LIST, COLL, INT32, INT32, LIST, LIST, LIST)
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.
void xmms_ipc_broadcast_unregister(xmms_ipc_signals_t signalid)
Unregister a broadcast signal.
xmms_coll_dag_t * xmms_collection_init(xmms_playlist_t *playlist)
Initializes a new xmms_coll_dag_t.
int xmmsv_get_string(const xmmsv_t *val, const char **r)
Retrieves a string from the value.
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
uint32_t * xmmsv_coll_get_idlist(xmmsv_coll_t *coll)
Return the list of ids stored in the collection.
void xmms_ipc_object_register(xmms_ipc_objects_t objectid, xmms_object_t *object)
Register a object to the IPC core.
#define XMMS_COLLECTION_NS_COLLECTIONS
void xmms_collection_sync(xmms_coll_dag_t *dag)
Synchronize collection data to the database (i.e.
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)
struct xmmsv_list_iter_St xmmsv_list_iter_t
int xmmsv_list_iter_valid(xmmsv_list_iter_t *it)
Check whether the iterator is valid and points to a valid element.
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...