Modification log added
[mediadatabase.git] / libdb / libdb.h
blob54a2e0e987fde579bd39b5951e62f293dccae01e
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * $Id: libdb.h,v 1.10 2005/03/05 21:39:44 nedko Exp $
6 * DESCRIPTION:
7 * Unified access to database.
9 * AUTHOR:
10 * Nedko Arnaudov <nedko@users.sourceforge.net>
12 * LICENSE:
13 * GNU GENERAL PUBLIC LICENSE version 2
15 *****************************************************************************/
17 #ifndef LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED
18 #define LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED
20 /* mediadb type is *handle*, use it as *handle* */
21 typedef struct { int unused; } * mediadb;
22 #define MEDIADB_INVALID_VALUE NULL
24 typedef unsigned long long mediadb_uint;
26 #define MEDIADB_MT_UNKNOWN 0
27 #define MEDIADB_MT_AUDIO 1
28 #define MEDIADB_MT_DATA 2
29 #define MEDIADB_MT_EMPTY 3
31 /* Contains on of MEDIADB_MT_XXX values */
32 typedef unsigned int mediadb_mediatype;
34 #define MEDIADB_DBTYPE_UNKNOWN 0
35 #define MEDIADB_DBTYPE_MYSQL 1
36 #define MEDIADB_DBTYPE_SQLITE 2
38 typedef unsigned int mediadb_filetype;
40 #define MEDIADB_FILETYPE_FILE 1
41 #define MEDIADB_FILETYPE_DIR 2
43 typedef unsigned int mediadb_bool;
45 #define MEDIADB_FALSE 0
46 #define MEDIADB_TRUE 1
48 struct mediadb_pattern_match_method
50 mediadb_uint nID;
51 const char *pszName;
52 const char *pszDescription;
53 const char *pszUsage;
56 #define MEDIADB_PMM_NULL 0
58 /* Open handle to media database */
59 mediadb_result
60 mediadb_open(
61 unsigned int nDBType, /* MEDIADB_DBTYPE_XXX */
62 const char *pszHost,
63 const char *pszUser,
64 const char *pszPass,
65 const char *pszDB,
66 mediadb *phDB);
68 /* Add new media to database */
69 mediadb_result
70 mediadb_media_add_new(
71 mediadb hDB,
72 const char *pszName,
73 const char *pszComment,
74 mediadb_mediatype nType,
75 mediadb_uint *pnNewMediaID);
77 /* Update media properties */
78 mediadb_result
79 mediadb_media_update_properties(
80 mediadb hDB,
81 mediadb_uint nMediaID,
82 mediadb_uint nTimeAdded,
83 mediadb_uint nTotalFiles,
84 mediadb_uint nTotalSize);
86 /* Add new file to database */
87 mediadb_result
88 mediadb_file_add_new(
89 mediadb hDB,
90 mediadb_uint nMediaID,
91 mediadb_filetype Filetype,
92 const char *pszPath,
93 const char *pszName,
94 mediadb_uint nFileSize,
95 mediadb_uint nFileTime);
97 mediadb_result
98 mediadb_media_get_properties(
99 mediadb hDB,
100 mediadb_uint nMediaID,
101 mediadb_uint *pnTimeAdded,
102 mediadb_mediatype *pnType,
103 mediadb_uint *pnLocationID,
104 char **ppszTitle);
106 mediadb_result
107 mediadb_location_get_properties(
108 mediadb hDB,
109 mediadb_uint nLocationID,
110 mediadb_uint *pnLocationTypeID,
111 char **ppszDescription);
113 mediadb_result
114 mediadb_location_type_get_properties(
115 mediadb hDB,
116 mediadb_uint nLocationTypeID,
117 char **ppszDescription);
119 mediadb_result
120 mediadb_media_get_properties_data(
121 mediadb hDB,
122 mediadb_uint nMediaID,
123 mediadb_uint *pnTotalFiles,
124 mediadb_uint *pnTotalSize);
127 mediadb_result
128 mediadb_media_get_properties_audio(
129 mediadb hDB,
130 mediadb_uint nMediaID);
133 mediadb_result
134 mediadb_delete_media_files(
135 mediadb hDB,
136 mediadb_uint nMediaID);
138 mediadb_result
139 mediadb_media_update_name(
140 mediadb hDB,
141 mediadb_uint nMediaID,
142 const char *pszName);
144 typedef void (* mediadb_media_callback)(
145 void *pUserContext,
146 mediadb_uint nMediaID,
147 mediadb_mediatype nType,
148 const char *pszName,
149 const char *pszComment,
150 mediadb_uint nTimeAdded,
151 mediadb_uint nTotalFiles,
152 mediadb_uint nTotalSize,
153 mediadb_uint nLocationID,
154 const char *pszLocation
157 mediadb_result
158 mediadb_media_get_all(
159 mediadb hDB,
160 mediadb_media_callback pCallback,
161 void *pUserContext);
163 typedef void (* mediadb_files_callback)(
164 void *pUserContext,
165 const char *pszPath,
166 const char *pszName,
167 mediadb_filetype Filetype,
168 mediadb_uint nSize,
169 mediadb_uint nTime);
171 mediadb_result
172 mediadb_files_get(
173 mediadb hDB,
174 mediadb_uint nMediaID,
175 const char *pszPath,
176 mediadb_files_callback pCallback,
177 void *pUserContext);
179 mediadb_result
180 mediadb_file_get_properties(
181 mediadb hDB,
182 mediadb_uint nMediaID,
183 const char *pszPath,
184 const char *pszName,
185 mediadb_filetype *pFiletype,
186 mediadb_uint *pnSize,
187 mediadb_uint *pnTime);
189 /* Close previously opened handle to database */
190 mediadb_result
191 mediadb_close(
192 mediadb hDB);
194 const char *
195 mediadb_get_error_message(
196 mediadb hDB);
198 /* *ppPSM is valid until hDB is valid */
199 mediadb_result
200 mediadb_get_pattern_match_methods(
201 mediadb hDB,
202 const struct mediadb_pattern_match_method **ppPMM);
204 typedef void (* mediadb_files_search_callback)(
205 void *pUserContext,
206 mediadb_uint nMediaID,
207 mediadb_mediatype nMediaType,
208 const char *pszMediaName,
209 const char *pszMediaLocation,
210 const char *pszPath,
211 const char *pszName,
212 mediadb_filetype Filetype,
213 mediadb_uint nSize,
214 mediadb_uint nTime);
216 mediadb_result
217 mediadb_files_search(
218 mediadb hDB,
219 mediadb_uint nFilenamePMMID,
220 const char *pszFilenamePattern,
221 mediadb_uint nPathPMMID,
222 const char *pszPathPattern,
223 const mediadb_uint *pnMinSize,
224 const mediadb_uint *pnMaxSize,
225 mediadb_files_search_callback pCallback,
226 void *pUserContext);
228 #endif /* #ifndef LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED */
230 /*****************************************************************************
232 * Modifications log:
234 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
236 * $Log: libdb.h,v $
237 * Revision 1.10 2005/03/05 21:39:44 nedko
238 * new functionality - file_get_properties()
240 * Revision 1.9 2004/09/18 21:34:35 nedko
241 * Return media name, media type and media location when searching files.
243 * Revision 1.8 2004/08/31 22:40:15 nedko
244 * Partitally implemented search feature.
246 * Revision 1.7 2004/08/08 00:47:42 nedko
247 * Get more info for media from database.
249 * Revision 1.6 2004/05/21 23:40:46 nedko
250 * New functionality: mediadb_files_get()
252 * Revision 1.5 2004/05/16 18:57:12 nedko
253 * media_get_all functionality implemented.
255 * Revision 1.4 2004/05/03 20:47:15 nedko
256 * Update mode for cui
258 * Revision 1.3 2004/05/02 20:12:11 nedko
259 * Improve error dumps.
261 * Revision 1.2 2004/05/02 13:16:58 nedko
262 * Supply filetype when adding new file
264 * Revision 1.1 2004/04/27 09:12:28 nedko
265 * Initial revision.
267 *****************************************************************************/