src/bookmarks/bdb/include/engine_bookmark.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 This file is part of mdictionary.
00003 
00004 mdictionary is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 mdictionary is distributed in the hope that it will be useful, 
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License 
00015 along with mdictionary; if not, write to the Free Software
00016 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00017 
00018 Copyright 2006-2008 ComArch S.A.
00019 *******************************************************************************/
00035 #ifndef _DICTIONARY_ENGINE_BOOKMARK
00036 #define _DICTIONARY_ENGINE_BOOKMARK
00037 
00038 #ifdef __cplusplus
00039         extern "C" {
00040 #endif
00041 
00042 
00043 /* headers with unix types/functions - only for timers */
00044 #include <sys/types.h>
00045 #include <sys/stat.h>
00046 #include <sys/time.h>
00047 #include <fcntl.h>
00048 #include <unistd.h>
00049 
00050 /* header with GLIB definitions/functions/types */
00051 #include <glib.h>
00052 
00053 /* header wit engine API */
00054 #include <dictionary_engine.h>
00055 
00056 /* header with Berkeley DB API */
00057 #include <db/db.h>
00058 
00059 /* operation on strings */
00060 #include <string.h>
00061 
00062 
00066 #define TIMER_START     TRUE
00067 
00068 #define TIMER_STOP      FALSE
00069 
00077 /* in final releases timer capapilities should be removed for increase
00078  * performance */
00079 /* static double bm_timer(gboolean start, gchar* message); */
00080 
00084 static const gchar* DIC_ENG_VERSION = "0.2";
00085 
00087 static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
00088 
00090 static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' book"
00091                                           "marks. Based on Berkeley DB 1.85";
00092 
00094 #define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
00095 
00096 
00099 struct _BookData {
00100         DB*                     db_words;
00103         DB*                     db_trans;
00106         BTREEINFO               info_words;
00109         BTREEINFO               info_trans;
00112         guint                   freeID;
00116         gchar*                  dict_path;
00118         EngineStatus            last_error;
00120         gboolean                auto_free;
00123         cb_progress             cb_progress_caching;
00126         gpointer                cb_progress_caching_data;
00129         gdouble                 cb_progress_caching_seed;
00133         cb_progress             cb_progress_word_list;
00136         gpointer                cb_progress_word_list_data;
00139         gdouble                 cb_progress_word_list_seed;
00143         cb_progress             cb_progress_word_trans;
00146         gpointer                cb_progress_word_trans_data;
00149         gdouble                 cb_progress_word_trans_seed;
00153         cb_word_list            cb_search_word_list;
00156         gpointer                cb_search_word_list_data;
00160         cb_word_translation     cb_search_word_trans;
00163         gpointer                cb_search_word_trans_data;
00166 };
00167 typedef struct _BookData        BookData;
00168 
00169 
00171 static gchar* string_to_path(gchar** string);
00172 
00174 static gboolean is_Bookmark_db_file(gchar* file);
00175 
00177 static gboolean bm_add_new_entry( gchar* word,
00178                                   gchar* translation,
00179                                   BookData* data );
00180 
00182 static void bm_load_freeID(BookData* data);
00183 
00185 static void bm_save_freeID(BookData* data);
00186 
00188 static gboolean bm_add_only_translation( BookData* data,
00189                                          gchar* translation,
00190                                          guint id );
00191 
00193 static gint bm_compare_key_trans(const DBT *a, const DBT *b);
00194 
00196 static gint bm_compare_key_words(const DBT *a, const DBT *b);
00197 
00198 
00201 
00203 gboolean        bm_engine_check(gchar* location);
00204 
00206 gchar*          bm_engine_description();
00207 
00209 gchar*          bm_engine_format();
00210 
00212 gchar*          bm_engine_version();
00213 
00215 Engine*         bm_engine_create( gchar* location, 
00216                                   EngineOptimizationFlag flags,
00217                                   cb_progress progress_handler,
00218                                   gpointer progress_data,
00219                                   gdouble seed );
00224 
00226 gboolean        bm_engine_add_word( Engine* engine,
00227                                     gchar*  word,
00228                                     gchar*  translation );
00229 
00231 gboolean        bm_engine_remove_word( Engine* engine, gchar*  word );
00232 
00234 gchar*          bm_engine_get_lang_from(Engine* engine);
00235 
00237 gchar*          bm_engine_get_lang_to(Engine* engine);
00238 
00240 gchar*          bm_engine_get_title(Engine* engine);
00241 
00243 gchar*          bm_engine_get_icon_path(Engine* engine);
00244 
00246 void            bm_engine_close(Engine* engine);
00247 
00249 gchar*          bm_engine_location(Engine* engine);
00250 
00252 void            bm_engine_optimize(Engine* engine);
00253 
00255 gboolean        bm_engine_is_optimized(Engine* engine);
00256 
00258 void            bm_engine_set_auto_free(Engine* engine, gboolean state);
00259 
00261 gpointer        bm_engine_set_callback( Engine* engine,
00262                                         gchar* event,
00263                                         gpointer c_handler,
00264                                         gpointer user_data );
00265 
00267 void            bm_engine_set_progress_seed( Engine* engine,
00268                                              gchar* signal,
00269                                              gdouble seed );
00270 
00272 void            bm_engine_search_word_list( Engine* engine,
00273                                             gchar* pattern,
00274                                             gpointer data );
00275 
00277 void            bm_engine_search_word_translation( Engine* engine,
00278                                                    gchar* word,
00279                                                    gpointer data );
00280 
00282 EngineStatus    bm_engine_status(Engine* engine);
00283 
00284 
00286 gchar*          bm_engine_status_message(EngineStatus error);
00287 
00291 EngineModule    engine_global_functions();
00292 
00293 #ifdef __cplusplus
00294 }
00295 #endif
00296 #endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
00297 

Generated on Fri Jan 11 14:30:17 2008 for mDictionary Project by  doxygen 1.5.1