hello-world/include/db.h

Go to the documentation of this file.
00001 #ifndef __DB_H__
00002 #define __DB_H__
00003 
00004 /**
00005  * File Name  : db.h
00006  *
00007  * Description: Metadb interface functions
00008  */
00009 
00010 /*
00011  * This file is part of hello-world.
00012  *
00013  * hello-world is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * hello-world is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2009 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 #include <glib.h>
00038 
00039 // ereader include files, between < >
00040 #include <libermetadb/ermetadb.h>
00041 
00042 G_BEGIN_DECLS
00043 
00044 
00045 //----------------------------------------------------------------------------
00046 // Macro Definitions
00047 //---------------------------------------------------------------------------- 
00048 
00049 // some empty macros that show the usaga of paramerts in functions
00050 // IN   : input parameter
00051 // OUT  : output parameter
00052 // INOUT: input parameter that is changed by the function
00053 
00054 #define IN
00055 #define OUT
00056 #define INOUT
00057 
00058 //----------------------------------------------------------------------------
00059 // Forward Declarations
00060 //----------------------------------------------------------------------------
00061 
00062 
00063 //----------------------------------------------------------------------------
00064 // Type Declarations
00065 //----------------------------------------------------------------------------
00066 
00067 // struct to hold thumbnail data
00068 typedef struct {
00069     guchar* data;   // data is in png format
00070     gint size;
00071 } thumbType;
00072 
00073 
00074 //----------------------------------------------------------------------------
00075 // Global Constants
00076 //----------------------------------------------------------------------------
00077 
00078 
00079 //============================================================================
00080 // Public Functions
00081 //============================================================================
00082 
00083 // Note: there are example functions to illustrate how to retreive
00084 // metadata from the database using libermetadb, see db.c for implemetation
00085 // Use your own (and better) defined functions to retrieve and save 
00086 // file metadata from and to the database
00087 
00088 // database lifecycle -> open and close
00089 
00090 /**---------------------------------------------------------------------------
00091  *
00092  * Name :  open_database
00093  *
00094  * @brief  Opens metadata database in directory
00095  *
00096  * @param  dir  directory where the database resides. This is the same 
00097  *              place as where the files are stored.
00098  *
00099  * @return pointer to a valid erMedadb object on success, NULL on failure
00100  *
00101  *--------------------------------------------------------------------------*/ 
00102 erMetadb open_database(const char* IN dir);
00103 
00104 /**---------------------------------------------------------------------------
00105  *
00106  * Name :  close_database
00107  *
00108  * @brief  Closes an open metadata database in directory
00109  *
00110  * @param  db     pointer to a valid erMetadb object
00111  *
00112  * @return --
00113  *
00114  *--------------------------------------------------------------------------*/ 
00115 void close_database(erMetadb IN db); 
00116 
00117 /**---------------------------------------------------------------------------
00118  *
00119  * Name :  load_file_metadata
00120  *
00121  * @brief  Loads the file metadata from database
00122  *
00123  * @param  db       pointer to a valid erMetadb object
00124  * @param  filepath filename for which to load metadata
00125  * @param  filename filename for which to load metadata
00126  * @param  title    pointer to GString to store the title
00127  *                  NULL -> title should not be retreived
00128  * @param  author   pointer to GString to store the author
00129  *                  NULL -> author should not be retreived
00130  *
00131  * @return FALSE on failure, TRUE on success
00132  *
00133  *--------------------------------------------------------------------------*/ 
00134 gboolean load_file_metadata(erMetadb        IN  db,        
00135                             const gchar*    IN  filepath,
00136                             const gchar*    IN  filename,
00137                             GString*        OUT title,
00138                             GString*        OUT author,
00139                             thumbType*      OUT small,
00140                             thumbType*      OUT medium);
00141 
00142 
00143 /**---------------------------------------------------------------------------
00144  *
00145  * Name :  save_file_metadata
00146  *
00147  * @brief  Saves the file metadata to database
00148  *
00149  * @param  db       pointer to a valid erMetadb object
00150  * @param  filepath filepath for which to save metadata
00151  * @param  filename filename for which to save metadata
00152  * @param  title    pointer to GString to store the title
00153  *                  NULL -> title should not be stored
00154  * @param  author   pointer to GString to store the author
00155  *                  NULL -> author should not be stored
00156  *
00157  * @return FALSE on failure, TRUE on success
00158  *
00159  *--------------------------------------------------------------------------*/ 
00160 gboolean save_file_metadata(erMetadb        IN db,
00161                             const gchar*    IN filepath,
00162                             const gchar*    IN filename,
00163                             GString*        IN title,
00164                             GString*        IN author,
00165                             thumbType*      IN small,
00166                             thumbType*      IN medium);
00167 
00168 /**---------------------------------------------------------------------------
00169  *
00170  * Name :  pixbuf_draw_rectangle
00171  *
00172  * @brief  Draw a rectangle border in a pixbuf
00173  *
00174  * @param  pixbuf    pointer to GdkPixbuf to be converted to BLOB
00175  * @param  xx        x position offset
00176  * @param  yy        y position offset
00177  * @param  ww        width in pixels
00178  * @param  hh        height pixels
00179  * @param  color     RGB color 
00180  *
00181  * @return --
00182  *
00183  *--------------------------------------------------------------------------*/ 
00184 void pixbuf_draw_rectangle (GdkPixbuf* pixbuf, 
00185                             gint xx, 
00186                             gint yy, 
00187                             gint ww, 
00188                             gint hh, 
00189                             gint color);
00190 
00191 /**---------------------------------------------------------------------------
00192  *
00193  * Name :  pixbuf_to_blob
00194  *
00195  * @brief  Converts a GdkPixbuf* to a BLOB buffer
00196  *
00197  * @param  pixbuf    pointer to GdkPixbuf to be converted to BLOB
00198  * @param  buffer    buffer in where the data of the BLOB is stored
00199  * @param  buf_size  size of the buffer after conversion
00200  *
00201  * @return FALSE on failure, TRUE on success
00202  *
00203  *--------------------------------------------------------------------------*/ 
00204 gboolean pixbuf_to_blob(GdkPixbuf* IN pixbuf, gchar** OUT buffer, gsize* OUT buf_size);
00205 
00206 
00207 G_END_DECLS
00208 
00209 #endif
Generated by  doxygen 1.6.2-20100208