summaryrefslogtreecommitdiff
path: root/src/backend/sword_main.hh
blob: 2e0cb1adac4a0ced364c0f35f001f30f9bd7c84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * Xiphos Bible Study Tool
 * sword_main.hh - 
 *
 * Copyright (C) 2000-2009 Xiphos Developer Team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef _SWORD_MAIN_HH_
#define _SWORD_MAIN_HH_

#include <swmgr.h>
#include <swbuf.h>
#include <versekey.h>
#include <treekeyidx.h>

#include <swdisp.h>

#include "main/lists.h"

using std::map;
using std::list;
using namespace sword;
	
class BackEnd {
	SWMgr *main_mgr;
	SWMgr *display_mgr;
	//TreeKeyIdx *tree_key;
	ListKey results;
	ListKey search_range;
	ListKey	search_scope_list; //--search list for searching verses found on last search
	ListKey verses;
	VerseKey search_scope_bounds; //----- sets lower and upper search bounds
	SWKey *current_scope;
	SWModule *search_mod;
	//SWFilter *thml2osis;
	//SWFilter *osis2html;
	
public:	
	TreeKeyIdx *tree_key;
	SWModule *display_mod;
		
	const char *version;	
	SWDisplay *commDisplay;	
	SWDisplay *bookDisplay;	
	SWDisplay *dictDisplay;
	SWDisplay *textDisplay;
	SWDisplay *RTOLDisplay;
	SWDisplay *entryDisplay;		
	SWDisplay *chapDisplay;			
	SWDisplay *dialogRTOLDisplay;
	SWDisplay *verselistDisplay;		
	SWDisplay *viewerDisplay;

	BackEnd();
	~BackEnd();
	void init_SWORD(int gsType);
	char *set_sword_locale(const char *sys_locale);
	void init_lists(MOD_LISTS * mods);
	const char *get_sword_version(void);

	GList *get_module_options(void);
	int has_global_option(char *mod_name, char *option);
	void set_cipher_key(char * mod_name, char * key);
	char *get_config_entry(char * module_name, char * entry);
	int is_Bible_key(const char * list, char * current_key);
	char *get_render_text(const char *module_name, const char *key);
	char *get_raw_text(const char *module_name, const char *key);
	char *render_this_text(const char * module_name, const char * text);
	char *get_strip_text(const char *module_name, const char *key);
	char *get_strip_text_from_string(const char * module_name, const char *string);
	char *get_valid_key(const char *key);
	char *key_get_book(const char *key);
	int key_get_chapter(const char *key);
	int key_get_verse(const char *key);
	unsigned int key_chapter_count(const char *key);
	unsigned int key_verse_count(const char *key);
	
	
	char *get_module_key(void);
	void save_entry(const char * entry);
	void save_note_entry(const char * module, const char * key, const char * entry);
	void delete_entry(void);
	int set_module_key(const char *module_name, const char *key);
	int set_key(const char *key);
	int get_key_testament(const char * key);
	int is_module(const char *mod_name);
	int set_module(const char *module_name);
	char *navigate_module(int direction);
	
	int module_type(const char *mod_name);
	char *module_description(char *mod_name);
	char *module_name_from_description(char *description);
	const char *module_get_language(const char *module_name);
	int module_has_testament(const char * module_name,  int testament);
	int module_get_testaments(const char * module_name);
	
	char *get_entry_attribute(const char *level1, const char *level2, const char *level3);
	
	char *get_key_from_offset(unsigned long offset);
	void set_treekey(unsigned long offset);
	unsigned long get_treekey_offset(void);
	unsigned long get_treekey_offset_from_key(const char * mod_name, const char * key);
	int treekey_parent(unsigned long offset);
	int treekey_has_children(unsigned long offset);
	int treekey_first_child(unsigned long offset);
	char *treekey_get_local_name(unsigned long offset);
	unsigned long  treekey_set_key(char * key) ;
	int treekey_prev_sibling(unsigned long offset);
	int treekey_next_sibling(unsigned long offset);
	GList *parse_verse_list(const char * list, char * current_key);
	GList *parse_range_list(const char * list);
	void set_listkey_position(char pos);
	const char *get_next_listkey(void);
	int clear_scope(void);
	int clear_search_list(void);
	int set_range(char * list);
	void set_scope2range(void);
	int set_scope2last_search(void);
	int check_for_optimal_search(char * module_name);
	int do_module_index(char *module_name);
	int do_module_delete_index(char *module_name);
	int do_module_search(char *module_name, const char *search_string, 
				int search_type, int search_params, int is_dialog);
	void terminate_search();
	
	char *get_conf_file_item(const char * file, const char * mod_name, const char * item);
	void save_conf_file_item(const char * file, const char * mod_name, const char * item, const char * value);
	void save_module_key(char *mod_name, char *key);
	SWMgr *get_display_mgr(void) {return(display_mgr);};
	SWMgr *get_main_mgr(void) {return(main_mgr);};
};
extern BackEnd *backend;

#endif /* _SWORD_MAIN_HH_ */