#include <gtk/gtk.h>
#include <libermetadb/ermetadb.h>
#include "filemodel.h"
Go to the source code of this file.
enum mdb_column_idx_t |
File Name : db.h
Description: Content browser metadb interface Copyright (C) 2009 iRex Technologies B.V. All rights reserved.
Definition at line 38 of file ctb/include/db.h.
00039 { 00040 COL_FILENAME = 0, 00041 COL_DIRECTORY_PATH, 00042 COL_SORT_PRIORITY, 00043 COL_IS_DIRECTORY, 00044 COL_FILETYPE, 00045 COL_FILESIZE, 00046 COL_FILETIME_MODIFIED, 00047 COL_FILETIME_LASTREAD, 00048 COL_FILETIME_ADDED, 00049 COL_TITLE, 00050 COL_AUTHOR, 00051 COL_THUMB_MINI, 00052 COL_THUMB_SMALL, 00053 COL_THUMB_MEDIUM, 00054 COL_THUMB_LARGE, 00055 N_METADATA_COLUMNS 00056 } mdb_column_idx_t;
void close_database | ( | ) |
Definition at line 98 of file ctb/src/db.c.
References ermetadb_close(), and g_metadb.
Referenced by do_example_db_actions(), filemodel_chdir(), filemodel_quit(), and open_global_database().
00099 { 00100 if (g_metadb) 00101 { 00102 ermetadb_close(g_metadb); 00103 g_metadb = NULL; 00104 } 00105 }
int db_query_create | ( | int | column1, | |
... | ||||
) |
Definition at line 108 of file ctb/src/db.c.
References ER_FAIL, ER_OK, g_query_in_progress, MDB_COLUMN_NAMES, metadata_table_add_column(), metadata_table_free, metadata_table_new(), and WARNPRINTF.
Referenced by create_query().
00109 { 00110 va_list ap; 00111 int col; 00112 00113 if (g_query_in_progress) 00114 { 00115 WARNPRINTF("trying to start a new query mid-query"); 00116 if (g_query_names) 00117 metadata_table_free(g_query_names); 00118 } 00119 00120 g_query_in_progress = TRUE; 00121 g_query_names = metadata_table_new(); 00122 if (!g_query_names) 00123 return ER_FAIL; 00124 00125 va_start(ap, column1); 00126 for (col = column1; col!=-1; col = va_arg(ap, int)) 00127 { 00128 int rc = metadata_table_add_column(g_query_names, MDB_COLUMN_NAMES[col]); 00129 if (rc!=ER_OK) 00130 { 00131 va_end(ap); 00132 return rc; 00133 } 00134 } 00135 va_end(ap); 00136 return ER_OK; 00137 }
int db_query_execute | ( | int | sort_order, | |
gboolean | sort_asc, | |||
metadata_table ** | values, | |||
const gchar * | tag_filter | |||
) |
Definition at line 148 of file ctb/src/db.c.
References ermetadb_global_select_files(), g_metadb, g_query_in_progress, get_sort_order_name(), and metadata_table_free.
Referenced by load_dir_from_metadb().
00152 { 00153 int rc = ermetadb_global_select_files( g_metadb, 00154 get_sort_order_name(sort_order, FALSE), 00155 sort_asc, 00156 g_query_names, 00157 values, 00158 tag_filter ); 00159 metadata_table_free(g_query_names); 00160 g_query_in_progress = FALSE; 00161 return rc; 00162 }
int db_query_execute_path_filter | ( | int | sort_order, | |
gboolean | sort_asc, | |||
metadata_table ** | values, | |||
const gchar * | path_filter, | |||
gboolean | show_filenames | |||
) |
Definition at line 195 of file ctb/src/db.c.
References ermetadb_global_select_subdir(), g_metadb, g_query_in_progress, get_sort_order_name(), and metadata_table_free.
Referenced by load_dir_from_metadb().
00200 { 00201 int rc = ermetadb_global_select_subdir( g_metadb, 00202 get_sort_order_name(sort_order, show_filenames), 00203 sort_asc, 00204 g_query_names, 00205 values, 00206 path_filter); 00207 metadata_table_free(g_query_names); 00208 g_query_in_progress = FALSE; 00209 return rc; 00210 }
int db_query_execute_recent | ( | metadata_table ** | values, | |
int | limit | |||
) |
Definition at line 165 of file ctb/src/db.c.
References CTB_SORT_BY_DATE_ADDED, ermetadb_global_select_recent(), g_metadb, g_query_in_progress, get_sort_order_name(), and metadata_table_free.
Referenced by load_dir_from_metadb().
00166 { 00167 int rc = ermetadb_global_select_recent( g_metadb, 00168 get_sort_order_name(CTB_SORT_BY_DATE_ADDED, FALSE), 00169 limit, 00170 g_query_names, 00171 values); 00172 metadata_table_free(g_query_names); 00173 g_query_in_progress = FALSE; 00174 return rc; 00175 }
int db_query_execute_search_filter | ( | int | sort_order, | |
gboolean | sort_asc, | |||
metadata_table ** | values, | |||
const gchar * | search_filter | |||
) |
Definition at line 178 of file ctb/src/db.c.
References ermetadb_global_select_search(), g_metadb, g_query_in_progress, get_sort_order_name(), and metadata_table_free.
Referenced by load_dir_from_metadb().
00182 { 00183 int rc = ermetadb_global_select_search( g_metadb, 00184 get_sort_order_name(sort_order, FALSE), 00185 sort_asc, 00186 g_query_names, 00187 values, 00188 search_filter); 00189 metadata_table_free(g_query_names); 00190 g_query_in_progress = FALSE; 00191 return rc; 00192 }
int db_query_get_metadata | ( | const gchar * | filename, | |
const gchar * | dirpath, | |||
metadata_table ** | values | |||
) |
Definition at line 213 of file ctb/src/db.c.
References ermetadb_global_get_file(), g_metadb, g_query_in_progress, and metadata_table_free.
00216 { 00217 int rc = ermetadb_global_get_file( g_metadb, 00218 dirpath, 00219 filename, 00220 g_query_names, 00221 values); 00222 metadata_table_free(g_query_names); 00223 g_query_in_progress = FALSE; 00224 return rc; 00225 }
int db_query_update_lastread | ( | const GString * | filename, | |
const GString * | directory, | |||
int | value | |||
) |
Definition at line 228 of file ctb/src/db.c.
References COL_FILETIME_LASTREAD, ER_OK, ermetadb_global_change_file(), g_metadb, MDB_COLUMN_NAMES, metadata_table_add_column(), metadata_table_free, metadata_table_new(), and metadata_table_set_int64().
00229 { 00230 metadata_table *query = metadata_table_new(); 00231 00232 int rc = metadata_table_add_column(query, MDB_COLUMN_NAMES[COL_FILETIME_LASTREAD]); 00233 if (rc == ER_OK) rc = metadata_table_set_int64(query, 0, value); 00234 if (rc == ER_OK) rc = ermetadb_global_change_file(g_metadb, 00235 directory->str, 00236 filename->str, 00237 query); 00238 metadata_table_free(query); 00239 return rc; 00240 }
erMetadb get_database | ( | ) |
Definition at line 75 of file ctb/src/db.c.
References g_metadb.
Referenced by filemodel_get_database().
00076 { 00077 return g_metadb; 00078 }
int open_global_database | ( | const gchar * | current_dir | ) |
Definition at line 81 of file ctb/src/db.c.
References close_database(), ER_FAIL, ER_OK, ermetadb_get_dir(), ermetadb_global_open(), ERRORPRINTF, and g_metadb.
Referenced by filemodel_chdir().
00082 { 00083 if (g_metadb && strcmp(directory, ermetadb_get_dir(g_metadb)) == 0 ) 00084 { 00085 return ER_OK; 00086 } 00087 00088 close_database(); 00089 g_metadb = ermetadb_global_open(directory, FALSE); 00090 if (!g_metadb) { 00091 ERRORPRINTF("error opening global database in at [%s]", directory); 00092 return ER_FAIL; 00093 } 00094 return ER_OK; 00095 }