1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2011 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.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.
20 #ifndef __METADATA_H__
21 #define __METADATA_H__
22 #include <libmpd/libmpd.h>
24 #include <glyr/glyr.h>
25 #include <glyr/cache.h>
28 META_ALBUM_ART
= 1, /* Album Cover art */
29 META_ARTIST_ART
= 2, /* Artist image */
30 META_ALBUM_TXT
= 4, /* Album story */
31 META_ARTIST_TXT
= 8, /* Artist biography */
32 META_SONG_TXT
= 16, /* Lyrics */
33 META_ARTIST_SIMILAR
= 32, /* Similar artists */
34 META_SONG_SIMILAR
= 64, /* Similar songs */
35 META_GENRE_SIMILAR
= 128,
36 META_SONG_GUITAR_TAB
= 256,
37 META_BACKDROP_ART
= 512, /* Backdrop */
38 META_QUERY_DATA_TYPES
= 65535, /* Bitmask for getting the metadata types only */
39 META_QUERY_NO_CACHE
= 65536 /* Do the query withouth checking the cache first */
44 META_DATA_UNAVAILABLE
,
50 * The MetaAata object that will be used in the future to pass metadata around
54 * This can be extended
57 META_DATA_CONTENT_EMPTY
,
58 /* contains a string with an uri to the data */
59 META_DATA_CONTENT_URI
,
60 /* Contains result (text) */
61 META_DATA_CONTENT_TEXT
,
62 /* Contains result (raw image data) */
63 META_DATA_CONTENT_RAW
,
64 /* Contains result (text) in html format */
65 META_DATA_CONTENT_HTML
,
66 /* A null-terminated array of strings, f.e. similar artists*/
67 META_DATA_CONTENT_TEXT_VECTOR
,
69 META_DATA_CONTENT_TEXT_LIST
70 } MetaDataContentType
;
73 /* The MetaDataType this holds */
75 /* The name of the plugin that provided the data
76 * This can be NULL if unknown.
80 MetaDataContentType content_type
;
83 /* size is only used for raw data. Might be set for text, but that needs to be
84 * null terminated anyway.
89 * The original result from the Metadata object.
93 * If type is an image (album art/artist art).
95 /** This allows us to be a bit more friendly for image providers */
100 typedef void (*MetaDataCallback
)(mpd_Song
*song
, MetaDataResult result
, MetaData
*met
, gpointer data
);
101 typedef void (*MetaDataListCallback
)(gpointer handle
, const char *plugin_name
, GList
*results
, gpointer data
);
103 * Create empty MetaData
105 MetaData
* meta_data_new(void);
107 * Free MetaData object
109 void meta_data_free(MetaData
*data
);
111 * copy a MetaData object
113 MetaData
*meta_data_dup(MetaData
*data
);
115 * Steals the data from the orginal.
116 * This can be used to avoid having large data blocks copied.
118 MetaData
*meta_data_dup_steal(MetaData
*data
);
121 gboolean
meta_data_is_empty(const MetaData
*data
);
123 gboolean
meta_data_is_uri(const MetaData
*data
);
124 const gchar
*meta_data_get_uri(const MetaData
*data
);
125 void meta_data_set_uri(MetaData
*data
, const gchar
*uri
);
126 void meta_data_set_thumbnail_uri(MetaData
*data
, const gchar
*uri
);
127 const gchar
*meta_data_get_thumbnail_uri(const MetaData
*data
);
129 gboolean
meta_data_is_text(const MetaData
*data
);
130 const gchar
* meta_data_get_text(const MetaData
*data
);
132 gchar
*meta_data_get_text_from_html(const MetaData
*data
);
134 gboolean
meta_data_is_html(const MetaData
*data
);
135 const gchar
* meta_data_get_html(const MetaData
*data
);
137 gboolean
meta_data_is_raw(const MetaData
*data
);
138 const guchar
* meta_data_get_raw(const MetaData
*data
, gsize
*length
);
139 /* set raw data (makes copy) */
140 void meta_data_set_raw(MetaData
*item
, guchar
*data
, gsize len
);
141 /* Take ownershit of data. (so no copy) */
142 void meta_data_set_raw_owned(MetaData
*item
, guchar
**data
, gsize
*len
);
144 gboolean
meta_data_is_text_vector(const MetaData
*data
);
145 const gchar
**meta_data_get_text_vector(const MetaData
*data
);
147 gboolean
meta_data_is_text_list(const MetaData
*data
);
148 const GList
*meta_data_get_text_list (const MetaData
*data
);
149 void meta_data_set_text(MetaData
*data
, const gchar
*text
);
151 /* ****************************************** */
152 void metadata_import_old_db(char *url
);
154 #include "gmpc-meta-watcher.h"
155 extern GmpcMetaWatcher
*gmw
;
157 /*guint meta_data_get_path_callback(mpd_Song *song, MetaDataType type, MetaDataCallback callback, gpointer data);*/
159 void meta_data_init(void);
160 void meta_data_check_plugin_changed(void);
161 void meta_data_handle_remove_request(guint id
);
162 void meta_data_destroy(void);
164 MetaDataResult
meta_data_get_path(mpd_Song
*tsong
, MetaDataType type
, MetaData
**met
,MetaDataCallback callback
, gpointer data
);
167 gchar
* gmpc_get_metadata_filename(MetaDataType type
, mpd_Song
*song
, char *extension
);
171 gpointer
metadata_get_list(mpd_Song
*song
, MetaDataType type
, void (*callback
)(gpointer handle
, const gchar
*plugin_name
, GList
*list
, gpointer data
), gpointer data
);
173 void metadata_get_list_cancel(gpointer data
);
174 mpd_Song
*rewrite_mpd_song(mpd_Song
*tsong
, MetaDataType type
);
177 * Clear an entry in the db.
179 void meta_data_clear_entry(mpd_Song
*song
, MetaDataType type
);
181 * Set an entry in the db.
183 void meta_data_set_entry ( mpd_Song
*song
, MetaData
*met
);