Updated Macedonian Translation <ufo@linux.net.mk>
[rhythmbox.git] / rhythmdb / rhythmdb-private.h
blob872333b6dd79b97e10ff8afa29a1c055f588dc1a
1 /*
2 * arch-tag: Header for RhythmDB private bits
4 * Copyright (C) 2004 Colin Walters <walters@rhythmbox.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef RHYTHMDB_PRIVATE_H
23 #define RHYTHMDB_PRIVATE_H
25 #include "config.h"
27 #include "rhythmdb.h"
28 #include "rb-refstring.h"
29 #include "rb-metadata.h"
31 #include <libgnomevfs/gnome-vfs-utils.h>
32 #include <libgnomevfs/gnome-vfs-file-info.h>
33 #include <libgnomevfs/gnome-vfs-ops.h>
34 #include <libgnomevfs/gnome-vfs-async-ops.h>
36 G_BEGIN_DECLS
38 RhythmDBEntry * rhythmdb_entry_allocate (RhythmDB *db, RhythmDBEntryType type);
39 void rhythmdb_entry_insert (RhythmDB *db, RhythmDBEntry *entry);
41 typedef struct {
42 /* podcast */
43 RBRefString *description;
44 RBRefString *subtitle;
45 RBRefString *summary;
46 RBRefString *lang;
47 RBRefString *copyright;
48 RBRefString *image;
49 gulong status; /* 0-99: downloading
50 100: Complete
51 101: Error
52 102: wait
53 103: pause */
54 gulong post_time;
55 } RhythmDBPodcastFields;
57 enum {
58 RHYTHMDB_ENTRY_HIDDEN = 1,
59 RHYTHMDB_ENTRY_INSERTED = 2,
60 RHYTHMDB_ENTRY_LAST_PLAYED_DIRTY = 4,
61 RHYTHMDB_ENTRY_FIRST_SEEN_DIRTY = 8,
62 RHYTHMDB_ENTRY_LAST_SEEN_DIRTY = 16,
64 /* the backend can use the top 16 bits for private flags */
65 RHYTHMDB_ENTRY_PRIVATE_FLAG_BASE = 65536,
68 struct RhythmDBEntry_ {
69 /* internal bits */
70 guint flags;
71 volatile gint refcount;
72 void *data;
73 RhythmDBEntryType type;
75 /* metadata */
76 RBRefString *title;
77 RBRefString *artist;
78 RBRefString *album;
79 RBRefString *genre;
80 RBRefString *musicbrainz_trackid;
81 gulong tracknum;
82 gulong discnum;
83 gulong duration;
84 gulong bitrate;
85 double track_gain;
86 double track_peak;
87 double album_gain;
88 double album_peak;
89 GDate date;
91 /* filesystem */
92 RBRefString *location;
93 RBRefString *mountpoint;
94 guint64 file_size;
95 RBRefString *mimetype;
96 gulong mtime;
97 gulong first_seen;
98 gulong last_seen;
100 /* user data */
101 gdouble rating;
102 glong play_count;
103 gulong last_played;
105 /* cached data */
106 gpointer last_played_str;
107 gpointer first_seen_str;
108 gpointer last_seen_str;
110 /* playback error string */
111 RBRefString *playback_error;
114 struct RhythmDBPrivate
116 char *name;
118 gint read_counter;
120 RBMetaData *metadata;
122 xmlChar **column_xml_names;
124 RBRefString *empty_string;
125 RBRefString *octet_stream_str;
127 gboolean action_thread_running;
128 gint outstanding_threads;
129 GAsyncQueue *action_queue;
130 GAsyncQueue *event_queue;
131 GAsyncQueue *restored_queue;
132 GThreadPool *query_thread_pool;
134 GList *stat_list;
135 GHashTable *stat_events;
136 GnomeVFSAsyncHandle *stat_handle;
137 GList *outstanding_stats;
138 GMutex *stat_mutex;
140 GHashTable *monitored_directories;
141 GHashTable *changed_files;
142 guint library_location_notify_id;
143 guint changed_files_id;
144 GSList *library_locations;
146 gboolean dry_run;
147 gboolean no_update;
149 GMutex *change_mutex;
150 GHashTable *added_entries;
151 GHashTable *changed_entries;
152 GHashTable *deleted_entries;
154 GHashTable *propname_map;
156 GMutex *exit_mutex;
157 gboolean exiting;
159 GCond *saving_condition;
160 GMutex *saving_mutex;
162 guint event_poll_id;
163 guint commit_timeout_id;
164 guint save_timeout_id;
166 guint emit_entry_signals_id;
167 GList *added_entries_to_emit;
168 GList *deleted_entries_to_emit;
170 gboolean saving;
171 gboolean dirty;
173 GHashTable *entry_type_map;
174 GMutex *entry_type_map_mutex;
175 GMutex *entry_type_mutex;
178 typedef struct
180 enum {
181 RHYTHMDB_EVENT_STAT,
182 RHYTHMDB_EVENT_METADATA_LOAD,
183 RHYTHMDB_EVENT_DB_LOAD,
184 RHYTHMDB_EVENT_THREAD_EXITED,
185 RHYTHMDB_EVENT_DB_SAVED,
186 RHYTHMDB_EVENT_QUERY_COMPLETE,
187 RHYTHMDB_EVENT_FILE_CREATED_OR_MODIFIED,
188 RHYTHMDB_EVENT_FILE_DELETED,
189 RHYTHMDB_EVENT_ENTRY_SET
190 } type;
191 RBRefString *uri;
192 RBRefString *real_uri; /* Target of a symlink, if any */
193 RhythmDBEntryType entry_type;
195 GError *error;
196 RhythmDB *db;
198 /* STAT */
199 GnomeVFSFileInfo *vfsinfo;
200 GnomeVFSAsyncHandle *handle;
201 /* LOAD */
202 RBMetaData *metadata;
203 /* QUERY_COMPLETE */
204 RhythmDBQueryResults *results;
205 /* ENTRY_SET */
206 RhythmDBEntry *entry;
207 /* ENTRY_SET */
208 gboolean signal_change;
209 RhythmDBEntryChange change;
210 } RhythmDBEvent;
212 /* from rhythmdb.c */
213 void queue_stat_uri (const char *uri, RhythmDB *db, RhythmDBEntryType type);
214 void rhythmdb_entry_set_visibility (RhythmDB *db, RhythmDBEntry *entry,
215 gboolean visibility);
216 void rhythmdb_entry_set_internal (RhythmDB *db, RhythmDBEntry *entry,
217 gboolean notify_if_inserted, guint propid,
218 const GValue *value);
219 void rhythmdb_entry_type_foreach (RhythmDB *db, GHFunc func, gpointer data);
220 RhythmDBEntry * rhythmdb_entry_lookup_by_location_refstring (RhythmDB *db, RBRefString *uri);
222 /* from rhythmdb-monitor.c */
223 void rhythmdb_init_monitoring (RhythmDB *db);
224 void rhythmdb_finalize_monitoring (RhythmDB *db);
225 void rhythmdb_stop_monitoring (RhythmDB *db);
226 void rhythmdb_start_monitoring (RhythmDB *db);
227 void rhythmdb_monitor_uri_path (RhythmDB *db, const char *uri, GError **error);
229 /* from rhythmdb-query.c */
230 GPtrArray *rhythmdb_query_parse_valist (RhythmDB *db, va_list args);
231 void rhythmdb_read_encoded_property (RhythmDB *db, const char *data, RhythmDBPropType propid, GValue *val);
233 G_END_DECLS
235 #endif /* __RHYTHMDB_PRIVATE_H */