aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/prototype/biblecsmgr.cpp
blob: 553208190ebab13e27eafffe9d917fe6519df5e3 (plain) (blame)
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
//---------------------------------------------------------------------------
#include "BibleCSMGR.h"
#include <swconfig.h>
#include <gbfrtf.h>
#include <rwprtf.h>
#include <rawgbf.h>
#include <thmlrtf.h>
//---------------------------------------------------------------------------
BibleCSMGR::BibleCSMGR(TModInstFrm *iModInstFrm) : SWMgr(0, 0, false)
{
	gbftortf = new GBFRTF();
	rwptortf = new RWPRTF();
	thmltortf = new ThMLRTF();
	ModInstFrm = iModInstFrm;
	Load();
}


BibleCSMGR::~BibleCSMGR()
{
	if (gbftortf)
		delete gbftortf;
			
	if (rwptortf)
		delete rwptortf;

	if (thmltortf)
		delete thmltortf;
}
			

void BibleCSMGR::AddRenderFilters(SWModule *module, ConfigEntMap &section)
{
	string sourceformat;
	ConfigEntMap::iterator entry;

	sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (string)"";
	// Temporary: To support old module types
//	if (sourceformat.empty()) {
//		try {
//			if (dynamic_cast<RawGBF *>(module))
//				sourceformat = "GBF";
//		}
//		catch ( ... ) {}
//	}
//	
	if (!stricmp(sourceformat.c_str(), "GBF")) {
		module->AddRenderFilter(gbftortf);
	}

	if (!stricmp(module->Name(), "RWP"))
		module->AddRenderFilter(rwptortf);

	if (!stricmp(sourceformat.c_str(), "THML"))
		module->AddRenderFilter(thmltortf);
}


char BibleCSMGR::AddModToConfig(int conffd, const char *fname)
{
	SWConfig modconf(fname);
	SectionMap::iterator section;
	AnsiString abouttext = "";
	bool logflag;
	TMemoryStream *RTFStream = new TMemoryStream();
	char retval;

	section = modconf.Sections.begin();

	ModInstFrm->ModText->Caption = "";
	ModInstFrm->ModText->Caption = ModInstFrm->ModText->Caption + "Found new module [ " + (*(*section).second.find("Description")).second.c_str() + " ]. Installing...";

	abouttext = abouttext + "{\\fs20\\cf0 " + (*(*section).second.find("About")).second.c_str() + " }";
	RTFStream->Clear();
	RTFStream->WriteBuffer(abouttext.c_str(), abouttext.Length());
	RTFStream->Position = 0;
	ModInstFrm->AboutText->Lines->LoadFromStream(RTFStream);
	delete RTFStream;
	
	ModInstFrm->ShowModal();

	logflag = SWLog::systemlog->log;
	SWLog::systemlog->log = false;	
	retval = SWMgr::AddModToConfig(conffd, fname);
	SWLog::systemlog->log = logflag;
	
	return retval;
}