index_db.h

Go to the documentation of this file.
00001 #ifndef __DB_H__
00002 #define __DB_H__
00003 
00004 /**
00005  * File Name  : index_db.h
00006  *
00007  */
00008 
00009 /*
00010  * This file is part of ctb.
00011  *
00012  * ctb is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation, either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * ctb is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00024  */
00025 
00026 /**
00027  * Copyright (C) 2008 iRex Technologies B.V.
00028  * All rights reserved.
00029  */
00030  
00031 #include <glib.h>
00032 #include <libermetadb/ermetadb.h>
00033 
00034 typedef enum {
00035    UNKNOWN = 0,
00036    SAME,
00037    CHANGED,
00038    NEW,
00039 } DBState;
00040 
00041 typedef struct
00042 {
00043     gint64 file_id;
00044     const gchar* filename;
00045     const gchar* filepath;
00046     gboolean is_dir;
00047     gint64 filesize;
00048     gint64 last_modified;
00049     DBState state;
00050 } db_entry_t;
00051 
00052 // Database state during the san of a directory 
00053 // (holds info on one metadata.db)
00054 typedef struct {
00055     erMetadb mdb;
00056     int transaction_started;
00057     metadata_table *values;
00058     metadata_cell *db;
00059     int num_rows;
00060     int num_cols;
00061     int row;
00062 } db_state_t;
00063 
00064 int db_open_global (db_state_t *db_state, const gchar *directory);
00065 void db_close (db_state_t *db_state);
00066 
00067 int db_start_transaction (db_state_t *db_state);
00068 int db_end_transaction (db_state_t *db_state);
00069 
00070 // returns list of db_entry_t*
00071 GSList* db_get_model(const gchar* dir);
00072 
00073 void db_add_entry(db_state_t *db_state,
00074                   const db_entry_t* entry,
00075                   const char* tag,
00076                   const char* display_name,
00077                   const char* author);
00078 void db_update_entry(db_state_t *db_state, const db_entry_t* entry);
00079 void db_update_shortcut_entry(db_state_t *db_state,
00080                               const db_entry_t* entry,
00081                               const char* display_name,
00082                               const char* author);
00083 int db_delete_entry(db_state_t *db_state, const db_entry_t *entry);
00084 
00085 #endif
Generated by  doxygen 1.6.2-20100208