gui
[lbook_fbreader.git] / fbreader / src / formats / PluginCollection.cpp
blob0d2ad4891b2fb840b9d265b83da8bd64588c1800
1 /*
2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #include <ZLStringUtil.h>
22 #include "FormatPlugin.h"
24 #include "fb2/FB2Plugin.h"
25 //#include "docbook/DocBookPlugin.h"
26 #include "html/HtmlPlugin.h"
27 #include "txt/TxtPlugin.h"
28 #include "pdb/PdbPlugin.h"
29 #include "tcr/TcrPlugin.h"
30 #include "oeb/OEBPlugin.h"
31 #include "chm/CHMPlugin.h"
32 #include "rtf/RtfPlugin.h"
33 #include "openreader/OpenReaderPlugin.h"
35 PluginCollection *PluginCollection::ourInstance = 0;
37 PluginCollection &PluginCollection::instance() {
38 if (ourInstance == 0) {
39 ourInstance = new PluginCollection();
40 ourInstance->myPlugins.push_back(new FB2Plugin());
41 //ourInstance->myPlugins.push_back(new DocBookPlugin());
42 ourInstance->myPlugins.push_back(new HtmlPlugin());
43 ourInstance->myPlugins.push_back(new TxtPlugin());
44 ourInstance->myPlugins.push_back(new PluckerPlugin());
45 ourInstance->myPlugins.push_back(new PalmDocPlugin());
46 ourInstance->myPlugins.push_back(new MobipocketPlugin());
47 ourInstance->myPlugins.push_back(new ZTXTPlugin());
48 ourInstance->myPlugins.push_back(new TcrPlugin());
49 ourInstance->myPlugins.push_back(new CHMPlugin());
50 ourInstance->myPlugins.push_back(new OEBPlugin());
51 ourInstance->myPlugins.push_back(new RtfPlugin());
52 ourInstance->myPlugins.push_back(new OpenReaderPlugin());
54 return *ourInstance;
57 void PluginCollection::deleteInstance() {
58 if (ourInstance != 0) {
59 delete ourInstance;
60 ourInstance = 0;
64 PluginCollection::PluginCollection() :
65 LanguageAutoDetectOption(ZLCategoryKey::CONFIG, "Format", "AutoDetect", true),
66 DefaultLanguageOption(ZLCategoryKey::CONFIG, "Format", "DefaultLanguageS", "en"),
67 DefaultEncodingOption(ZLCategoryKey::CONFIG, "Format", "DefaultEncoding", "windows-1252") {
70 PluginCollection::~PluginCollection() {
71 for (std::vector<FormatPlugin*>::const_iterator it = myPlugins.begin(); it != myPlugins.end(); ++it) {
72 delete *it;
76 FormatPlugin *PluginCollection::plugin(const ZLFile &file, bool strong) {
77 for (std::vector<FormatPlugin*>::iterator it = myPlugins.begin(); it != myPlugins.end(); ++it) {
78 if ((!strong || (*it)->providesMetaInfo()) && (*it)->acceptsFile(file)) {
79 return *it;
82 return 0;