2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * This is the sticker database library. It is the backend of all the
22 * sticker code in MPD.
24 * "Stickers" are pieces of information attached to existing MPD
25 * objects (e.g. song files, directories, albums). Clients can create
26 * arbitrary name/value pairs. MPD itself does not assume any special
29 * The goal is to allow clients to share additional (possibly dynamic)
30 * information about songs, which is neither stored on the client (not
31 * available to other clients), nor stored in the song files (MPD has
34 * Client developers should create a standard for common sticker
35 * names, to ensure interoperability.
37 * Examples: song ratings; statistics; deferred tag writes; lyrics;
52 * Opens the sticker database (if path is not NULL).
54 * @param error_r location to store the error occuring, or NULL to
56 * @return true on success, false on error
59 sticker_global_init(const char *path
, GError
**error_r
);
62 * Close the sticker database.
65 sticker_global_finish(void);
68 * Returns true if the sticker database is configured and available.
71 sticker_enabled(void);
74 * Returns one value from an object's sticker record. The caller must
75 * free the return value with g_free().
78 sticker_load_value(const char *type
, const char *uri
, const char *name
);
81 * Sets a sticker value in the specified object. Overwrites existing
85 sticker_store_value(const char *type
, const char *uri
,
86 const char *name
, const char *value
);
89 * Deletes a sticker from the database. All sticker values of the
90 * specified object are deleted.
93 sticker_delete(const char *type
, const char *uri
);
96 * Deletes a sticker value. Fails if no sticker with this name
100 sticker_delete_value(const char *type
, const char *uri
, const char *name
);
103 * Frees resources held by the sticker object.
105 * @param sticker the sticker object to be freed
108 sticker_free(struct sticker
*sticker
);
111 * Determines a single value in a sticker.
113 * @param sticker the sticker object
114 * @param name the name of the sticker
115 * @return the sticker value, or NULL if none was found
118 sticker_get_value(const struct sticker
*sticker
, const char *name
);
121 * Iterates over all sticker items in a sticker.
123 * @param sticker the sticker object
124 * @param func a callback function
125 * @param user_data an opaque pointer for the callback function
128 sticker_foreach(const struct sticker
*sticker
,
129 void (*func
)(const char *name
, const char *value
,
134 * Loads the sticker for the specified resource.
136 * @param type the resource type, e.g. "song"
137 * @param uri the URI of the resource, e.g. the song path
138 * @return a sticker object, or NULL on error or if there is no sticker
141 sticker_load(const char *type
, const char *uri
);
144 * Finds stickers with the specified name below the specified URI.
146 * @param type the resource type, e.g. "song"
147 * @param base_uri the URI prefix of the resources, or NULL if all
148 * resources should be searched
149 * @param name the name of the sticker
150 * @return true on success (even if no sticker was found), false on
154 sticker_find(const char *type
, const char *base_uri
, const char *name
,
155 void (*func
)(const char *uri
, const char *value
,