diff options
264 files changed, 5577 insertions, 5641 deletions
diff --git a/debian/libzlcore-tqt-dev.install b/debian/libzlcore-tqt-dev.install new file mode 100644 index 0000000..0c331fd --- /dev/null +++ b/debian/libzlcore-tqt-dev.install @@ -0,0 +1,2 @@ +/usr/include/zlibrary-tqt/core +/usr/lib/libzlcore-tqt.so diff --git a/debian/libzlcore-tqt.install b/debian/libzlcore-tqt.install index 0bf940b..059418a 100644 --- a/debian/libzlcore-tqt.install +++ b/debian/libzlcore-tqt.install @@ -1 +1 @@ -/usr/lib +/usr/lib/libzlcore-tqt.so.* diff --git a/fbreader/src/fbreader/FBReaderActions.cpp b/fbreader/src/fbreader/FBReaderActions.cpp index 4733383..9ca36cf 100644 --- a/fbreader/src/fbreader/FBReaderActions.cpp +++ b/fbreader/src/fbreader/FBReaderActions.cpp @@ -23,7 +23,7 @@ #include <ZLDialogManager.h> #include <ZLDialog.h> #include <ZLOptionsDialog.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include <ZLibrary.h> #include <ZLBlockTreeView.h> diff --git a/fbreader/src/formats/txt/PlainTextFormat.h b/fbreader/src/formats/txt/PlainTextFormat.h index 59cc61f..32ca258 100644 --- a/fbreader/src/formats/txt/PlainTextFormat.h +++ b/fbreader/src/formats/txt/PlainTextFormat.h @@ -22,7 +22,7 @@ #include <ZLInputStream.h> #include <ZLOptions.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include <ZLResource.h> #include "../FormatPlugin.h" diff --git a/fbreader/src/networkActions/AuthenticationDialog.cpp b/fbreader/src/networkActions/AuthenticationDialog.cpp index 4d59b43..4f4ed1a 100644 --- a/fbreader/src/networkActions/AuthenticationDialog.cpp +++ b/fbreader/src/networkActions/AuthenticationDialog.cpp @@ -22,7 +22,7 @@ #include <ZLOptionsDialog.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include "../network/NetworkLink.h" #include "AuthenticationDialog.h" diff --git a/fbreader/src/networkActions/PasswordRecoveryDialog.cpp b/fbreader/src/networkActions/PasswordRecoveryDialog.cpp index ac6fcaf..c02fa15 100644 --- a/fbreader/src/networkActions/PasswordRecoveryDialog.cpp +++ b/fbreader/src/networkActions/PasswordRecoveryDialog.cpp @@ -23,8 +23,8 @@ #include <ZLOptionsDialog.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLStringEditOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLStringEditOptionEntry.h> #include "PasswordRecoveryDialog.h" #include "NetworkOperationRunnable.h" diff --git a/fbreader/src/networkActions/RegisterUserDialog.cpp b/fbreader/src/networkActions/RegisterUserDialog.cpp index 27aca2b..4d93d8c 100644 --- a/fbreader/src/networkActions/RegisterUserDialog.cpp +++ b/fbreader/src/networkActions/RegisterUserDialog.cpp @@ -22,8 +22,8 @@ #include <ZLOptionsDialog.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLStringEditOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLStringEditOptionEntry.h> #include "RegisterUserDialog.h" diff --git a/fbreader/src/optionsDialog/IntegrationTab.cpp b/fbreader/src/optionsDialog/IntegrationTab.cpp index c1026f0..ca3ebf0 100644 --- a/fbreader/src/optionsDialog/IntegrationTab.cpp +++ b/fbreader/src/optionsDialog/IntegrationTab.cpp @@ -21,8 +21,8 @@ #include <ZLOptionEntry.h> #include <ZLStringUtil.h> -#include <optionEntries/ZLToggleBooleanOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLToggleBooleanOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include "AbstractOptionsDialog.h" diff --git a/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp index 09b1061..197bd98 100644 --- a/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp +++ b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp @@ -26,9 +26,9 @@ #include <ZLLanguageList.h> #include <ZLStringUtil.h> -#include <optionEntries/ZLStringInfoEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLLanguageOptionEntry.h> +#include <ZLStringInfoEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLLanguageOptionEntry.h> #include "BookInfoDialog.h" diff --git a/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp index 3e24b87..0b77548 100644 --- a/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp +++ b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp @@ -19,7 +19,7 @@ #include <ZLOptionsDialog.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include <ZLTextStyle.h> #include <ZLTextStyleCollection.h> diff --git a/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp index f33c915..b3c20ce 100644 --- a/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp +++ b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp @@ -21,8 +21,8 @@ #include <ZLOptionsDialog.h> #include <ZLPaintContext.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLColorOptionBuilder.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLColorOptionBuilder.h> #include <ZLTextStyleCollection.h> diff --git a/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp index 6fc00e6..c2086d1 100644 --- a/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp +++ b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp @@ -20,7 +20,7 @@ #include <ZLOptionsDialog.h> #include <ZLPaintContext.h> -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include <ZLTextView.h> #include <ZLTextStyle.h> diff --git a/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp index aa165e1..c7c4b10 100644 --- a/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp +++ b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp @@ -26,8 +26,8 @@ #include <ZLOptionEntry.h> #include <ZLOptionsDialog.h> #include <ZLNetworkManager.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLToggleBooleanOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLToggleBooleanOptionEntry.h> #include "../../fbreader/FBReader.h" diff --git a/fbreader/src/optionsDialog/reading/IndicatorTab.cpp b/fbreader/src/optionsDialog/reading/IndicatorTab.cpp index ac8b549..2049b16 100644 --- a/fbreader/src/optionsDialog/reading/IndicatorTab.cpp +++ b/fbreader/src/optionsDialog/reading/IndicatorTab.cpp @@ -19,7 +19,7 @@ #include <ZLOptionsDialog.h> -#include <optionEntries/ZLToggleBooleanOptionEntry.h> +#include <ZLToggleBooleanOptionEntry.h> #include <ZLTextStyleOptions.h> diff --git a/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp b/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp index 4d4cc10..b522578 100644 --- a/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp +++ b/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp @@ -21,8 +21,8 @@ #include <ZLApplication.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLSimpleKeyOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLSimpleKeyOptionEntry.h> #include "ReadingOptionsDialog.h" diff --git a/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp index 1ccb54d..98c079f 100644 --- a/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp +++ b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp @@ -20,8 +20,8 @@ #include <ZLDialogManager.h> #include <ZLOptionsDialog.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLToggleBooleanOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLToggleBooleanOptionEntry.h> #include "ReadingOptionsDialog.h" diff --git a/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp b/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp index 91b3c7a..aadc669 100644 --- a/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp +++ b/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp @@ -22,9 +22,9 @@ #include <ZLLanguageList.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLSimpleOptionEntry.h> -#include <optionEntries/ZLLanguageOptionEntry.h> -#include <optionEntries/ZLToggleBooleanOptionEntry.h> +#include <ZLSimpleOptionEntry.h> +#include <ZLLanguageOptionEntry.h> +#include <ZLToggleBooleanOptionEntry.h> #include "SystemOptionsDialog.h" diff --git a/zlibrary/CMakeLists.txt b/zlibrary/CMakeLists.txt index 31e538e..9b7ecf8 100644 --- a/zlibrary/CMakeLists.txt +++ b/zlibrary/CMakeLists.txt @@ -7,6 +7,11 @@ _tde_internal_setup_path( ) _tde_internal_setup_path( + ZL_INCLUDE_INSTALL_DIR "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/include/zlibrary-tqt" + "The subdirectory to the header prefix" +) + +_tde_internal_setup_path( ZL_LIB_INSTALL_DIR "${CMAKE_ZLIBRARY_INSTALL_PREFIX}/lib${LIB_SUFFIX}" "Base directory for zlibrary-tqt lib files" ) diff --git a/zlibrary/core/CMakeLists.txt b/zlibrary/core/CMakeLists.txt index ffe191d..92c3b5d 100644 --- a/zlibrary/core/CMakeLists.txt +++ b/zlibrary/core/CMakeLists.txt @@ -38,3 +38,12 @@ install( FILES ${_resources_files} DESTINATION ${ZL_SHARE_INSTALL_PREFIX}/resources ) + + +##### install header files + +file( GLOB_RECURSE _zlcore_h_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ) +install( + FILES ${_zlcore_h_files} + DESTINATION ${ZL_INCLUDE_INSTALL_DIR}/core +) diff --git a/zlibrary/core/src/unix/xmlconfig/AsciiEncoder.h b/zlibrary/core/include/AsciiEncoder.h index ad0aa9f..ad0aa9f 100644 --- a/zlibrary/core/src/unix/xmlconfig/AsciiEncoder.h +++ b/zlibrary/core/include/AsciiEncoder.h diff --git a/zlibrary/core/src/encoding/DummyEncodingConverter.h b/zlibrary/core/include/DummyEncodingConverter.h index 492db8a..492db8a 100644 --- a/zlibrary/core/src/encoding/DummyEncodingConverter.h +++ b/zlibrary/core/include/DummyEncodingConverter.h diff --git a/zlibrary/core/src/encoding/EncodingCollectionReader.h b/zlibrary/core/include/EncodingCollectionReader.h index da6e4cd..da6e4cd 100644 --- a/zlibrary/core/src/encoding/EncodingCollectionReader.h +++ b/zlibrary/core/include/EncodingCollectionReader.h diff --git a/zlibrary/core/src/unix/iconv/IConvEncodingConverter.h b/zlibrary/core/include/IConvEncodingConverter.h index 64c93a6..9fa834e 100644 --- a/zlibrary/core/src/unix/iconv/IConvEncodingConverter.h +++ b/zlibrary/core/include/IConvEncodingConverter.h @@ -21,7 +21,7 @@ #define __ICONVENCODINGCONVERTERS_H__ #include <ZLEncodingConverter.h> -#include "../../encoding/ZLEncodingConverterProvider.h" +#include "ZLEncodingConverterProvider.h" class IConvEncodingConverterProvider : public ZLEncodingConverterProvider { diff --git a/zlibrary/core/src/encoding/MyEncodingConverter.h b/zlibrary/core/include/MyEncodingConverter.h index f01043a..f01043a 100644 --- a/zlibrary/core/src/encoding/MyEncodingConverter.h +++ b/zlibrary/core/include/MyEncodingConverter.h diff --git a/zlibrary/core/src/encoding/Utf8EncodingConverter.h b/zlibrary/core/include/Utf8EncodingConverter.h index dcb06a3..dcb06a3 100644 --- a/zlibrary/core/src/encoding/Utf8EncodingConverter.h +++ b/zlibrary/core/include/Utf8EncodingConverter.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfig.h b/zlibrary/core/include/XMLConfig.h index 20ace07..ed80993 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfig.h +++ b/zlibrary/core/include/XMLConfig.h @@ -27,7 +27,7 @@ #include <shared_ptr.h> #include <ZLRunnable.h> -#include "../../options/ZLConfig.h" +#include "ZLConfig.h" #include "XMLConfigValue.h" diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigDelta.h b/zlibrary/core/include/XMLConfigDelta.h index 4cd3a58..4cd3a58 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfigDelta.h +++ b/zlibrary/core/include/XMLConfigDelta.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigDeltaWriter.h b/zlibrary/core/include/XMLConfigDeltaWriter.h index 71d54c6..71d54c6 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfigDeltaWriter.h +++ b/zlibrary/core/include/XMLConfigDeltaWriter.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigReader.h b/zlibrary/core/include/XMLConfigReader.h index a5f0d55..a5f0d55 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfigReader.h +++ b/zlibrary/core/include/XMLConfigReader.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigValue.h b/zlibrary/core/include/XMLConfigValue.h index 6c0bff3..6c0bff3 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfigValue.h +++ b/zlibrary/core/include/XMLConfigValue.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigWriter.h b/zlibrary/core/include/XMLConfigWriter.h index b295e53..b295e53 100644 --- a/zlibrary/core/src/unix/xmlconfig/XMLConfigWriter.h +++ b/zlibrary/core/include/XMLConfigWriter.h diff --git a/zlibrary/core/include/ZLApplication.h b/zlibrary/core/include/ZLApplication.h index 4648d93..cdffa6c 120000..100644 --- a/zlibrary/core/include/ZLApplication.h +++ b/zlibrary/core/include/ZLApplication.h @@ -1 +1,201 @@ -../src/application/ZLApplication.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLAPPLICATION_H__ +#define __ZLAPPLICATION_H__ + +#include <string> +#include <vector> +#include <map> +#include <set> + +#include <shared_ptr.h> +#include <ZLOptions.h> +#include <ZLTime.h> +#include <ZLResource.h> +#include <ZLMessage.h> +#include <ZLView.h> + +class ZLApplicationWindow; +class ZLViewWidget; +class ZLPaintContext; +class ZLKeyBindings; +class ZLToolbar; +class ZLPopupData; +class ZLMenubar; +class ZLFile; + +class ZLApplicationBase { + +protected: + ZLApplicationBase(const std::string &name); + ~ZLApplicationBase(); +}; + +class ZLApplication : public ZLApplicationBase { + +public: + static ZLApplication &Instance(); + static void deleteInstance(); + +private: + static ZLApplication *ourInstance; + +public: + static const std::string MouseScrollUpKey; + static const std::string MouseScrollDownKey; + static const std::string NoAction; + +public: + ZLIntegerOption RotationAngleOption; + ZLIntegerOption AngleStateOption; + + ZLBooleanOption KeyboardControlOption; + + ZLBooleanOption ConfigAutoSavingOption; + ZLIntegerRangeOption ConfigAutoSaveTimeoutOption; + + ZLIntegerRangeOption KeyDelayOption; + +public: + + class Action { + + public: + virtual ~Action(); + virtual bool isVisible() const; + virtual bool isEnabled() const; + void checkAndRun(); + virtual bool useKeyDelay() const; + + protected: + virtual void run() = 0; + }; + +protected: + class RotationAction : public Action { + + public: + bool isVisible() const; + void run(); + }; + friend class RotationAction; + +public: + class FullscreenAction : public Action { + + public: + void run(); + }; + friend class FullscreenAction; + + class PresentWindowHandler : public ZLMessageHandler { + + public: + void onMessageReceived(const std::vector<std::string> &arguments); + const std::string &lastCaller() const; + void resetLastCaller(); + + private: + std::string myLastCaller; + }; + +protected: + ZLApplication(const std::string &name); + + void addAction(const std::string &actionId, shared_ptr<Action> action); + void registerPopupData(const std::string &actionId, shared_ptr<ZLPopupData> popupData); + + void setView(shared_ptr<ZLView> view); + ZLView::Angle rotation() const; + + void setFullscreen(bool fullscreen); + bool isFullscreen() const; + +public: + virtual ~ZLApplication(); + virtual void initWindow(); + + shared_ptr<ZLView> currentView() const; + shared_ptr<ZLPaintContext> context(); + + void grabAllKeys(bool grab); + void trackStylus(bool track); + + void resetWindowCaption(); + void setHyperlinkCursor(bool hyperlink); + + shared_ptr<Action> action(const std::string &actionId) const; + bool isActionVisible(const std::string &actionId) const; + bool isActionEnabled(const std::string &actionId) const; + void doAction(const std::string &actionId); + + virtual shared_ptr<ZLKeyBindings> keyBindings(); + void doActionByKey(const std::string &key); + + void quit(); + virtual bool closeView(); + virtual void openFile(const ZLFile &file); + virtual bool canDragFiles(const std::vector<std::string> &filePaths) const; + virtual void dragFiles(const std::vector<std::string> &filePaths); + + virtual bool isViewFinal() const; + + virtual void refreshWindow(); + void presentWindow(); + + const std::string &lastCaller() const; + void resetLastCaller(); + + void setVisualParameter(const std::string &id, const std::string &value); + void setParameterValueList(const std::string &id, const std::vector<std::string> &values); + const std::string &visualParameter(const std::string &id); + +public: + virtual bool showAuthDialog(const std::string &siteName, std::string &userName, std::string &password, const ZLResourceKey &errorKey) = 0; + virtual void saveUserName(const std::string &siteName, std::string &userName) = 0; + +private: + void createToolbar(int index); + +// TODO: change access rights to private +public: + const ZLToolbar &toolbar(int index) const; + +private: + void createMenubar(); + const ZLMenubar &menubar() const; + +private: + shared_ptr<ZLViewWidget> myViewWidget; + shared_ptr<ZLView> myInitialView; + std::map<std::string,shared_ptr<Action> > myActionMap; + mutable shared_ptr<ZLToolbar> myToolbar; + mutable shared_ptr<ZLToolbar> myFullscreenToolbar; + mutable shared_ptr<ZLMenubar> myMenubar; + shared_ptr<ZLPaintContext> myContext; + shared_ptr <ZLApplicationWindow> myWindow; + ZLTime myLastKeyActionTime; + shared_ptr<ZLMessageHandler> myPresentWindowHandler; + +friend class ZLApplicationWindow; +friend class ZLMenuVisitor; +}; + +#endif /* __ZLAPPLICATION_H__ */ diff --git a/zlibrary/core/src/application/ZLApplicationWindow.h b/zlibrary/core/include/ZLApplicationWindow.h index 535ebd7..535ebd7 100644 --- a/zlibrary/core/src/application/ZLApplicationWindow.h +++ b/zlibrary/core/include/ZLApplicationWindow.h diff --git a/zlibrary/core/include/ZLAsynchronousInputStream.h b/zlibrary/core/include/ZLAsynchronousInputStream.h index 818ae7f..371d703 120000..100644 --- a/zlibrary/core/include/ZLAsynchronousInputStream.h +++ b/zlibrary/core/include/ZLAsynchronousInputStream.h @@ -1 +1,72 @@ -../src/network/ZLAsynchronousInputStream.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLASYNCHRONOUSINPUTSTREAM_H__ +#define __ZLASYNCHRONOUSINPUTSTREAM_H__ + +#include <string> + + +class ZLAsynchronousInputStream { + +public: + class Handler { + + public: + virtual ~Handler(); + virtual void initialize(const char *encoding) = 0; + virtual void shutdown() = 0; + virtual bool handleBuffer(const char *data, std::size_t len) = 0; + }; + +public: + ZLAsynchronousInputStream(const char *encoding = 0); + virtual ~ZLAsynchronousInputStream(); + + void setEof(); + void setBuffer(const char *data, std::size_t len); + bool eof() const; + bool initialized() const; + + bool processInput(Handler &handler); + +protected: + virtual bool processInputInternal(Handler &handler) = 0; + +protected: + const char *myData; + std::size_t myDataLen; + +private: + std::string myEncoding; + bool myInitialized; + bool myEof; + +private: + // disable copying + ZLAsynchronousInputStream(const ZLAsynchronousInputStream &); + const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &); +}; + +inline void ZLAsynchronousInputStream::setEof() { myEof = true; myData = 0; myDataLen = 0; } +inline void ZLAsynchronousInputStream::setBuffer(const char *data, std::size_t len) { myData = data; myDataLen = len; } +inline bool ZLAsynchronousInputStream::eof() const { return myEof; } +inline bool ZLAsynchronousInputStream::initialized() const { return myInitialized; } + +#endif /* __ZLASYNCHRONOUSINPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLBase64EncodedImage.h b/zlibrary/core/include/ZLBase64EncodedImage.h index fad684e..9e7a61e 120000..100644 --- a/zlibrary/core/include/ZLBase64EncodedImage.h +++ b/zlibrary/core/include/ZLBase64EncodedImage.h @@ -1 +1,47 @@ -../src/image/ZLBase64EncodedImage.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLBASE64ENCODEDIMAGE_H__ +#define __ZLBASE64ENCODEDIMAGE_H__ + +#include <vector> + +#include <ZLImage.h> + +class ZLBase64EncodedImage : public ZLSingleImage { + +public: + ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType); + ~ZLBase64EncodedImage(); + void addData(const std::string &text, std::size_t offset, std::size_t len); + void addData(const std::vector<std::string> &text); + const shared_ptr<std::string> stringData() const; + +private: + void decode() const; + +private: + mutable std::string myEncodedData; + mutable shared_ptr<std::string> myData; +}; + +inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType) : ZLSingleImage(mimeType) {} +inline ZLBase64EncodedImage::~ZLBase64EncodedImage() {} + +#endif /* __ZLBASE64ENCODEDIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLBase64InputStream.h b/zlibrary/core/include/ZLBase64InputStream.h index f326dae..4a073d6 120000..100644 --- a/zlibrary/core/include/ZLBase64InputStream.h +++ b/zlibrary/core/include/ZLBase64InputStream.h @@ -1 +1,54 @@ -../src/util/ZLBase64InputStream.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLBASE64INPUTSTREAM_H__ +#define __ZLBASE64INPUTSTREAM_H__ + +#include <ZLInputStream.h> + +class ZLBase64InputStream : public ZLInputStream { +public: + ZLBase64InputStream(shared_ptr<ZLInputStream> base); + ~ZLBase64InputStream(); + + bool open(); + int read(); + std::size_t read(char *buffer, std::size_t maxSize); + void close(); + + void seek(int offset, bool absoluteOffset); + std::size_t offset() const; + std::size_t sizeOfOpened(); + +private: + void fillDecodedBuffer(); + bool fillBuffer(); + static int decode(char b); + +private: + shared_ptr<ZLInputStream> myBaseStream; + int myDecoded0; + int myDecoded1; + int myDecoded2; + char* myBuffer; + int myBufferOffset; + int myBufferLength; +}; + +#endif /* __ZLBASE64INPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLBlockTreeNode.h b/zlibrary/core/include/ZLBlockTreeNode.h index de7022d..38b4a9e 120000..100644 --- a/zlibrary/core/include/ZLBlockTreeNode.h +++ b/zlibrary/core/include/ZLBlockTreeNode.h @@ -1 +1,104 @@ -../src/blockTreeView/ZLBlockTreeNode.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLBLOCKTREENODE_H__ +#define __ZLBLOCKTREENODE_H__ + +#include <map> +#include <vector> + +#include <shared_ptr.h> + +#include <ZLTypeId.h> +#include <ZLRunnable.h> +#include <ZLPaintContext.h> + +class ZLBlockTreeView; + +class ZLBlockTreeNode : public ZLObjectWithRTTI { + +public: + typedef std::vector<ZLBlockTreeNode*> List; + +protected: + struct Rectangle { + const std::size_t Left; + const std::size_t Top; + const std::size_t Right; + const std::size_t Bottom; + + Rectangle(std::size_t left, std::size_t vOffset, std::size_t right, std::size_t bottom); + + bool contains(std::size_t x, std::size_t y) const; + bool operator < (const Rectangle &r) const; + }; + +public: + static const ZLTypeId TYPE_ID; + +protected: + ZLBlockTreeNode(ZLBlockTreeView &view); + ZLBlockTreeNode(ZLBlockTreeNode *parent, std::size_t atPosition = -1); + +public: + virtual ~ZLBlockTreeNode(); + void clear(); + +public: + ZLBlockTreeNode *parent() const; + ZLBlockTreeNode *previous() const; + ZLBlockTreeNode *next() const; + const List &children() const; + + void open(bool openNotClose); + bool isOpen() const; + +protected: + std::size_t level() const; + + ZLBlockTreeView &view(); + +public: + virtual void paint(ZLPaintContext &context, int vOffset) = 0; + virtual int height(ZLPaintContext &context) const = 0; + + void onStylusPress(std::size_t x, std::size_t y); + bool isOverHyperlink(std::size_t x, std::size_t y); + +protected: + void addHyperlink(std::size_t left, std::size_t top, std::size_t right, std::size_t bottom, shared_ptr<ZLRunnableWithKey> action); + void removeAllHyperlinks(); + +private: + ZLBlockTreeView &myView; + ZLBlockTreeNode *myParent; + std::size_t myChildIndex; + + List myChildren; + bool myIsOpen; + + typedef std::map<Rectangle,shared_ptr<ZLRunnableWithKey> > LinkMap; + LinkMap myHyperlinks; + +private: + ZLBlockTreeNode(const ZLBlockTreeNode&); + const ZLBlockTreeNode &operator = (const ZLBlockTreeNode&); +}; + +#endif /* __ZLBLOCKTREENODE_H__ */ diff --git a/zlibrary/core/include/ZLBlockTreeView.h b/zlibrary/core/include/ZLBlockTreeView.h index 5fc578c..95d5e9a 120000..100644 --- a/zlibrary/core/include/ZLBlockTreeView.h +++ b/zlibrary/core/include/ZLBlockTreeView.h @@ -1 +1,97 @@ -../src/blockTreeView/ZLBlockTreeView.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLBLOCKTREEVIEW_H__ +#define __ZLBLOCKTREEVIEW_H__ + +#include <ZLView.h> + +#include <ZLBlockTreeNode.h> + +class ZLBlockTreeView : public ZLView { + +public: + class RootNode : public ZLBlockTreeNode { + + public: + static const ZLTypeId TYPE_ID; + + public: + RootNode(ZLBlockTreeView &view); + + private: + const ZLTypeId &typeId() const; + void paint(ZLPaintContext &context, int vOffset); + int height(ZLPaintContext &context) const; + }; + +public: + static const ZLTypeId TYPE_ID; + +protected: + ZLBlockTreeView(ZLPaintContext &context); + const ZLTypeId &typeId() const; + + RootNode &rootNode(); + void clear(); + +public: + ZLBlockTreeNode *firstVisibleNode() const; + void setFirstVisibleNode(ZLBlockTreeNode *node); + + enum VisibilityMode { + INVISIBLE, + VISIBLE, + VISIBLE_PARTIAL_AT_TOP, + VISIBLE_PARTIAL_AT_BOTTOM + }; + + VisibilityMode visibilityMode(ZLBlockTreeNode *node) const; + + void ensureVisible(ZLBlockTreeNode *node); + + enum ScrollingMode { + NONE, + PAGE, + ITEM, + }; + void scroll(ScrollingMode mode, bool back); + +protected: + void paint(); + +private: + bool onStylusPress(int x, int y); + bool onStylusMove(int x, int y); + + void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to); + void onScrollbarStep(Direction direction, int steps); + void onScrollbarPageStep(Direction direction, int steps); + +private: + ZLBlockTreeNode *findNode(int &y); + +private: + RootNode myRootNode; + ZLBlockTreeNode *myFirstVisibleNode; + std::size_t myNodePartToSkip; + bool myCanScrollForward; +}; + +#endif /* __ZLBLOCKTREEVIEW_H__ */ diff --git a/zlibrary/core/include/ZLBoolean3.h b/zlibrary/core/include/ZLBoolean3.h index f75d4b1..7371c41 120000..100644 --- a/zlibrary/core/include/ZLBoolean3.h +++ b/zlibrary/core/include/ZLBoolean3.h @@ -1 +1,29 @@ -../src/util/ZLBoolean3.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLBOOLEAN3_H__ +#define __ZLBOOLEAN3_H__ + +enum ZLBoolean3 { + B3_FALSE = 0, + B3_TRUE = 1, + B3_UNDEFINED = 2 +}; + +#endif /* __ZLBOOLEAN3_H__ */ diff --git a/zlibrary/core/src/filesystem/bzip2/ZLBzip2InputStream.h b/zlibrary/core/include/ZLBzip2InputStream.h index 39dd2e6..edeb288 100644 --- a/zlibrary/core/src/filesystem/bzip2/ZLBzip2InputStream.h +++ b/zlibrary/core/include/ZLBzip2InputStream.h @@ -29,7 +29,7 @@ #include <shared_ptr.h> -#include "../ZLInputStream.h" +#include "ZLInputStream.h" class ZLFSCompressorBzip2; diff --git a/zlibrary/core/src/language/ZLCharSequence.h b/zlibrary/core/include/ZLCharSequence.h index 6b4b112..6b4b112 100644 --- a/zlibrary/core/src/language/ZLCharSequence.h +++ b/zlibrary/core/include/ZLCharSequence.h diff --git a/zlibrary/core/include/ZLColor.h b/zlibrary/core/include/ZLColor.h index 7d199ce..59926a4 120000..100644 --- a/zlibrary/core/include/ZLColor.h +++ b/zlibrary/core/include/ZLColor.h @@ -1 +1,42 @@ -../src/util/ZLColor.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLCOLOR_H__ +#define __ZLCOLOR_H__ + +struct ZLColor { + unsigned char Red; + unsigned char Green; + unsigned char Blue; + + ZLColor(unsigned char r, unsigned char g, unsigned char b); + ZLColor(long longValue = 0); + long intValue(); + + bool operator == (const ZLColor &color) const; + bool operator != (const ZLColor &color) const; +}; + +inline ZLColor::ZLColor(unsigned char r, unsigned char g, unsigned char b) : Red(r), Green(g), Blue(b) {} +inline ZLColor::ZLColor(long longValue) : Red((unsigned char)(longValue >> 16)), Green((unsigned char)(longValue >> 8)), Blue((unsigned char)longValue) {} +inline long ZLColor::intValue() { return (((long)Red) << 16) + (((long)Green) << 8) + Blue; } +inline bool ZLColor::operator == (const ZLColor &color) const { return (Red == color.Red) && (Green == color.Green) && (Blue == color.Blue); } +inline bool ZLColor::operator != (const ZLColor &color) const { return !operator==(color); } + +#endif /* __ZLCOLOR_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLColorOptionBuilder.h b/zlibrary/core/include/ZLColorOptionBuilder.h index 54ba59a..54ba59a 100644 --- a/zlibrary/core/src/optionEntries/ZLColorOptionBuilder.h +++ b/zlibrary/core/include/ZLColorOptionBuilder.h diff --git a/zlibrary/core/src/options/ZLConfig.h b/zlibrary/core/include/ZLConfig.h index cee6465..cee6465 100644 --- a/zlibrary/core/src/options/ZLConfig.h +++ b/zlibrary/core/include/ZLConfig.h diff --git a/zlibrary/core/src/desktop/application/ZLDesktopApplicationWindow.h b/zlibrary/core/include/ZLDesktopApplicationWindow.h index bc8abd8..9f4171a 100644 --- a/zlibrary/core/src/desktop/application/ZLDesktopApplicationWindow.h +++ b/zlibrary/core/include/ZLDesktopApplicationWindow.h @@ -22,7 +22,7 @@ #include <ZLOptions.h> -#include "../../application/ZLApplicationWindow.h" +#include "ZLApplicationWindow.h" class ZLDesktopApplicationWindow : public ZLApplicationWindow { diff --git a/zlibrary/core/src/desktop/dialogs/ZLDesktopOpenFileDialog.h b/zlibrary/core/include/ZLDesktopOpenFileDialog.h index 72d163a..72d163a 100644 --- a/zlibrary/core/src/desktop/dialogs/ZLDesktopOpenFileDialog.h +++ b/zlibrary/core/include/ZLDesktopOpenFileDialog.h diff --git a/zlibrary/core/src/desktop/dialogs/ZLDesktopOptionsDialog.h b/zlibrary/core/include/ZLDesktopOptionsDialog.h index 95475c7..95475c7 100644 --- a/zlibrary/core/src/desktop/dialogs/ZLDesktopOptionsDialog.h +++ b/zlibrary/core/include/ZLDesktopOptionsDialog.h diff --git a/zlibrary/core/include/ZLDialog.h b/zlibrary/core/include/ZLDialog.h index 7e9423b..6bd29a5 120000..100644 --- a/zlibrary/core/include/ZLDialog.h +++ b/zlibrary/core/include/ZLDialog.h @@ -1 +1,51 @@ -../src/dialogs/ZLDialog.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLDIALOG_H__ +#define __ZLDIALOG_H__ + +#include <string> +#include <ZLDialogContent.h> +#include <ZLResource.h> + +class ZLDialog { + +protected: + ZLDialog(); + +public: + virtual ~ZLDialog(); + + virtual void addButton(const ZLResourceKey &key, bool accept) = 0; + + void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option); + void addOption(const ZLResourceKey &key, ZLOptionEntry *option); + void addOption(const ZLResourceKey &key, ZLSimpleOption &option); + + const ZLResource &resource(const ZLResourceKey &key) const; + + // TODO: change return type to int (or std::string?) + virtual bool run() = 0; + void acceptValues(); + +protected: + ZLDialogContent *myTab; +}; + +#endif /* __ZLDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLDialogContent.h b/zlibrary/core/include/ZLDialogContent.h index fcec7db..a39415d 120000..100644 --- a/zlibrary/core/include/ZLDialogContent.h +++ b/zlibrary/core/include/ZLDialogContent.h @@ -1 +1,65 @@ -../src/dialogs/ZLDialogContent.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLDIALOGCONTENT_H__ +#define __ZLDIALOGCONTENT_H__ + +#include <string> +#include <vector> + +#include <ZLOptions.h> +#include <ZLResource.h> + +class ZLOptionEntry; +class ZLOptionView; + +class ZLDialogContent { + +protected: + ZLDialogContent(const ZLResource &resource); + +public: + virtual ~ZLDialogContent(); + + const std::string &key() const; + const std::string &displayName() const; + const std::string &value(const ZLResourceKey &key) const; + const ZLResource &resource(const ZLResourceKey &key) const; + + virtual void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option) = 0; + void addOption(const ZLResourceKey &key, ZLOptionEntry *option); + void addOption(const ZLResourceKey &key, ZLSimpleOption &option); + virtual void addOptions(const std::string &name0, const std::string &tooltip0, ZLOptionEntry *option0, + const std::string &name1, const std::string &tooltip1, ZLOptionEntry *option1) = 0; + void addOptions(const ZLResourceKey &key0, ZLOptionEntry *option0, + const ZLResourceKey &key1, ZLOptionEntry *option1); + void addOptions(const ZLResourceKey &key0, ZLSimpleOption &option0, + const ZLResourceKey &key1, ZLSimpleOption &option1); + + void accept(); + +protected: + void addView(ZLOptionView *view); + +private: + const ZLResource &myResource; + std::vector<ZLOptionView*> myViews; +}; + +#endif /* __ZLDIALOGCONTENT_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLDialogContentBuilder.h b/zlibrary/core/include/ZLDialogContentBuilder.h index 49157dc..49157dc 100644 --- a/zlibrary/core/src/dialogs/ZLDialogContentBuilder.h +++ b/zlibrary/core/include/ZLDialogContentBuilder.h diff --git a/zlibrary/core/include/ZLDialogManager.h b/zlibrary/core/include/ZLDialogManager.h index 1bcf3cf..8d84d0c 120000..100644 --- a/zlibrary/core/include/ZLDialogManager.h +++ b/zlibrary/core/include/ZLDialogManager.h @@ -1 +1,101 @@ -../src/dialogs/ZLDialogManager.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLDIALOGMANAGER_H__ +#define __ZLDIALOGMANAGER_H__ + +#include <string> + +#include <shared_ptr.h> +#include <ZLRunnable.h> +#include <ZLResource.h> +#include <ZLOpenFileDialog.h> +#include <ZLTreeDialog.h> + +class ZLDialog; +class ZLOptionsDialog; +class ZLTreeHandler; +class ZLApplication; +class ZLImageData; +class ZLProgressDialog; + +class ZLDialogManager { + +public: + static const ZLResourceKey OK_BUTTON; + static const ZLResourceKey CANCEL_BUTTON; + static const ZLResourceKey YES_BUTTON; + static const ZLResourceKey NO_BUTTON; + static const ZLResourceKey APPLY_BUTTON; + + static const ZLResourceKey COLOR_KEY; + static const ZLResourceKey DIALOG_TITLE; + + static const std::string &dialogTitle(const ZLResourceKey &key); + static const std::string &dialogMessage(const ZLResourceKey &key); + static const std::string &buttonName(const ZLResourceKey &key); + static const std::string &waitMessageText(const ZLResourceKey &key); + +protected: + static const ZLResource &resource(); + +public: + static bool isInitialized(); + static ZLDialogManager &Instance(); + static void deleteInstance(); + +protected: + static ZLDialogManager *ourInstance; + +protected: + ZLDialogManager(); + virtual ~ZLDialogManager(); + +public: + virtual void createApplicationWindow(ZLApplication *application) const = 0; + + virtual shared_ptr<ZLDialog> createDialog(const ZLResourceKey &key) const = 0; + virtual shared_ptr<ZLOptionsDialog> createOptionsDialog(const ZLResourceKey &key, shared_ptr<ZLRunnable> applyAction = 0, bool showApplyButton = false) const = 0; + virtual shared_ptr<ZLOpenFileDialog> createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0; + virtual shared_ptr<ZLTreeDialog> createTreeDialog(const ZLResource &resource) const = 0; + + void informationBox(const ZLResourceKey &key) const; + void informationBox(const ZLResourceKey &key, const std::string &message) const; + virtual void informationBox(const std::string &title, const std::string &message) const = 0; + + void errorBox(const ZLResourceKey &key) const; + virtual void errorBox(const ZLResourceKey &key, const std::string &message) const = 0; + + int questionBox(const ZLResourceKey &key, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const; + virtual int questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const = 0; + + virtual shared_ptr<ZLProgressDialog> createProgressDialog(const ZLResourceKey &key, bool network) const = 0; + + void wait(const ZLResourceKey &key, ZLRunnable &runnable) const; + + enum ClipboardType { + CLIPBOARD_MAIN, + CLIPBOARD_SELECTION + }; + virtual bool isClipboardSupported(ClipboardType type) const = 0; + virtual void setClipboardText(const std::string &text, ClipboardType type) const = 0; + virtual void setClipboardImage(const ZLImageData &imageData, ClipboardType type) const = 0; +}; + +#endif /* __ZLDIALOGMANAGER_H__ */ diff --git a/zlibrary/core/include/ZLDir.h b/zlibrary/core/include/ZLDir.h index e7d4ad4..d353391 120000..100644 --- a/zlibrary/core/include/ZLDir.h +++ b/zlibrary/core/include/ZLDir.h @@ -1 +1,58 @@ -../src/filesystem/ZLDir.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLDIR_H__ +#define __ZLDIR_H__ + +#include <string> +#include <vector> + +#include <shared_ptr.h> + +class ZLDir { + +public: + static shared_ptr<ZLDir> root(); + +protected: + ZLDir(const std::string &path); + +public: + virtual ~ZLDir(); + const std::string &path() const; + std::string name() const; + std::string parentPath() const; + std::string itemPath(const std::string &name) const; + bool isRoot() const; + + virtual void collectSubDirs(std::vector<std::string> &names, bool includeSymlinks) = 0; + virtual void collectFiles(std::vector<std::string> &names, bool includeSymlinks) = 0; + +protected: + virtual std::string delimiter() const = 0; + +private: + std::string myPath; + +private: + ZLDir(const ZLDir&); + const ZLDir &operator = (const ZLDir&); +}; + +#endif /* __ZLDIR_H__ */ diff --git a/zlibrary/core/include/ZLEncodingConverter.h b/zlibrary/core/include/ZLEncodingConverter.h index 209f67a..84a61de 120000..100644 --- a/zlibrary/core/include/ZLEncodingConverter.h +++ b/zlibrary/core/include/ZLEncodingConverter.h @@ -1 +1,130 @@ -../src/encoding/ZLEncodingConverter.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLENCODINGCONVERTER_H__ +#define __ZLENCODINGCONVERTER_H__ + +#include <string> +#include <vector> +#include <map> + +#include <shared_ptr.h> + +class ZLEncodingConverter { + +public: + static const std::string ASCII; + static const std::string UTF8; + static const std::string UTF16; + static const std::string UTF16BE; + +protected: + ZLEncodingConverter(); + +public: + virtual ~ZLEncodingConverter(); + virtual void convert(std::string &dst, const char *srcStart, const char *srcEnd) = 0; + void convert(std::string &dst, const std::string &src); + virtual void reset() = 0; + virtual bool fillTable(int *map) = 0; + +private: + ZLEncodingConverter(const ZLEncodingConverter&); + ZLEncodingConverter &operator = (const ZLEncodingConverter&); +}; + +class ZLEncodingConverterInfo { + +public: + ZLEncodingConverterInfo(const std::string &name, const std::string ®ion); + void addAlias(const std::string &alias); + + const std::string &name() const; + const std::string &visibleName() const; + const std::vector<std::string> &aliases() const; + shared_ptr<ZLEncodingConverter> createConverter() const; + bool canCreateConverter() const; + +private: + const std::string myName; + const std::string myVisibleName; + std::vector<std::string> myAliases; + +private: + ZLEncodingConverterInfo(const ZLEncodingConverterInfo&); + ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&); +}; + +typedef shared_ptr<ZLEncodingConverterInfo> ZLEncodingConverterInfoPtr; + +class ZLEncodingSet { + +public: + ZLEncodingSet(const std::string &name); + void addInfo(ZLEncodingConverterInfoPtr info); + + const std::string &name() const; + const std::vector<ZLEncodingConverterInfoPtr> &infos() const; + +private: + const std::string myName; + std::vector<ZLEncodingConverterInfoPtr> myInfos; + +private: + ZLEncodingSet(const ZLEncodingSet&); + ZLEncodingSet &operator = (const ZLEncodingSet&); +}; + +class ZLEncodingConverterProvider; + +class ZLEncodingCollection { + +public: + static ZLEncodingCollection &Instance(); + static std::string encodingDescriptionPath(); + +private: + static ZLEncodingCollection *ourInstance; + +public: + const std::vector<shared_ptr<ZLEncodingSet> > &sets(); + ZLEncodingConverterInfoPtr info(const std::string &name); + ZLEncodingConverterInfoPtr info(int code); + shared_ptr<ZLEncodingConverter> defaultConverter(); + void registerProvider(shared_ptr<ZLEncodingConverterProvider> provider); + +private: + void addInfo(ZLEncodingConverterInfoPtr info); + const std::vector<shared_ptr<ZLEncodingConverterProvider> > &providers() const; + +private: + std::vector<shared_ptr<ZLEncodingSet> > mySets; + std::map<std::string,ZLEncodingConverterInfoPtr> myInfosByName; + std::vector<shared_ptr<ZLEncodingConverterProvider> > myProviders; + +private: + ZLEncodingCollection(); + ~ZLEncodingCollection(); + void init(); + +friend class ZLEncodingConverterInfo; +friend class ZLEncodingCollectionReader; +}; + +#endif /* __ZLENCODINGCONVERTER_H__ */ diff --git a/zlibrary/core/src/encoding/ZLEncodingConverterProvider.h b/zlibrary/core/include/ZLEncodingConverterProvider.h index 5a292eb..5a292eb 100644 --- a/zlibrary/core/src/encoding/ZLEncodingConverterProvider.h +++ b/zlibrary/core/include/ZLEncodingConverterProvider.h diff --git a/zlibrary/core/include/ZLExecutionUtil.h b/zlibrary/core/include/ZLExecutionUtil.h index c6270c4..83f08a6 120000..100644 --- a/zlibrary/core/include/ZLExecutionUtil.h +++ b/zlibrary/core/include/ZLExecutionUtil.h @@ -1 +1,77 @@ -../src/runnable/ZLExecutionUtil.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLEXECUTIONUTIL_H__ +#define __ZLEXECUTIONUTIL_H__ + +#include <ZLUserData.h> +#include "ZLNetworkRequest.h" + +class ZLExecutionUtil { + //code for convenient async syntax createListener method: + public: + template <typename T, typename Method> + static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data, T object, Method method) { + data->addUserData(ourHandlerId, new HandlerHelper<T, Method>(object, method)); + return createListener(data); + } + template <typename T, typename Method> + static shared_ptr<ZLNetworkRequest::Listener> createListener(T object, Method method) { + return createListener(new ZLUserDataHolder, object, method); + } + template <typename T, typename Method> + static shared_ptr<ZLNetworkRequest::Listener> createListener(ZLUserData *scope, T object, Method method) { + shared_ptr<ZLUserDataHolder> scopeData = new ZLUserDataHolder; + scopeData->addUserData("scope", scope); + return createListener(scopeData, object, method); + } + + private: + typedef void (*Handler)(ZLUserDataHolder &data, const std::string &error); + + class AbstractHandlerHelper : public ZLUserData { + public: + virtual void handle(ZLUserDataHolder &data, const std::string &error) = 0; + }; + + template <typename T, typename Method> + class HandlerHelper : public AbstractHandlerHelper { + public: + HandlerHelper(T object, Method method) : myObject(object), myMethod(method) { + } + + void handle(ZLUserDataHolder &data, const std::string &error) { + (myObject->*myMethod)(data, error); + } + + private: + T myObject; + Method myMethod; + }; + static void handleHelper(ZLUserDataHolder &data, const std::string &error); + static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data); + + static std::string ourHandlerId; + +friend class ZLExecutionHandler; +}; + + + +#endif /* __ZLEXECUTIONUTIL_H__ */ diff --git a/zlibrary/core/src/filesystem/tar/ZLFSArchiverTar.h b/zlibrary/core/include/ZLFSArchiverTar.h index b2d495c..703c746 100644 --- a/zlibrary/core/src/filesystem/tar/ZLFSArchiverTar.h +++ b/zlibrary/core/include/ZLFSArchiverTar.h @@ -20,7 +20,7 @@ #ifndef __ZLFSARCHIVERTAR_H__ #define __ZLFSARCHIVERTAR_H__ -#include "../ZLFSPlugin.h" +#include "ZLFSPlugin.h" class ZLFSArchiverTar : public ZLFSArchiver { diff --git a/zlibrary/core/src/filesystem/zip/ZLFSArchiverZip.h b/zlibrary/core/include/ZLFSArchiverZip.h index 359df79..7d7d650 100644 --- a/zlibrary/core/src/filesystem/zip/ZLFSArchiverZip.h +++ b/zlibrary/core/include/ZLFSArchiverZip.h @@ -20,7 +20,7 @@ #ifndef __ZLFSARCHIVERZIP_H__ #define __ZLFSARCHIVERZIP_H__ -#include "../ZLFSPlugin.h" +#include "ZLFSPlugin.h" class ZLFSArchiverZip : public ZLFSArchiver { diff --git a/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.h b/zlibrary/core/include/ZLFSCompressorBzip2.h index 97f1485..1339d93 100644 --- a/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.h +++ b/zlibrary/core/include/ZLFSCompressorBzip2.h @@ -20,7 +20,7 @@ #ifndef __ZLFSCOMPRESSORBZIP2_H__ #define __ZLFSCOMPRESSORBZIP2_H__ -#include "../ZLFSPlugin.h" +#include "ZLFSPlugin.h" class ZLFSCompressorBzip2 : public ZLFSCompressor { diff --git a/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.h b/zlibrary/core/include/ZLFSCompressorGzip.h index 633c4b4..8552880 100644 --- a/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.h +++ b/zlibrary/core/include/ZLFSCompressorGzip.h @@ -20,7 +20,7 @@ #ifndef __ZLFSCOMPRESSORGZIP_H__ #define __ZLFSCOMPRESSORGZIP_H__ -#include "../ZLFSPlugin.h" +#include "ZLFSPlugin.h" class ZLFSCompressorGzip : public ZLFSCompressor { diff --git a/zlibrary/core/src/filesystem/ZLFSDir.h b/zlibrary/core/include/ZLFSDir.h index 9c63443..9c63443 100644 --- a/zlibrary/core/src/filesystem/ZLFSDir.h +++ b/zlibrary/core/include/ZLFSDir.h diff --git a/zlibrary/core/src/filesystem/ZLFSManager.h b/zlibrary/core/include/ZLFSManager.h index 9103f69..9103f69 100644 --- a/zlibrary/core/src/filesystem/ZLFSManager.h +++ b/zlibrary/core/include/ZLFSManager.h diff --git a/zlibrary/core/src/filesystem/ZLFSPlugin.h b/zlibrary/core/include/ZLFSPlugin.h index 6e7651e..6e7651e 100644 --- a/zlibrary/core/src/filesystem/ZLFSPlugin.h +++ b/zlibrary/core/include/ZLFSPlugin.h diff --git a/zlibrary/core/src/filesystem/ZLFSPluginManager.h b/zlibrary/core/include/ZLFSPluginManager.h index 9cef53e..9cef53e 100644 --- a/zlibrary/core/src/filesystem/ZLFSPluginManager.h +++ b/zlibrary/core/include/ZLFSPluginManager.h diff --git a/zlibrary/core/include/ZLFile.h b/zlibrary/core/include/ZLFile.h index 5cdccc7..5dae04c 120000..100644 --- a/zlibrary/core/include/ZLFile.h +++ b/zlibrary/core/include/ZLFile.h @@ -1 +1,129 @@ -../src/filesystem/ZLFile.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLFILE_H__ +#define __ZLFILE_H__ + +#include <string> +#include <map> + +#include <shared_ptr.h> +#include <ZLFileInfo.h> +#include <ZLMimeType.h> + +class ZLDir; +class ZLInputStream; +class ZLOutputStream; +class ZLFSCompressor; +class ZLFSArchiver; +class ZLFSPluginManager; + +class ZLFile { + friend class ZLFSPluginManager; + friend class ZLFSArchiver; + +public: + static const ZLFile NO_FILE; + +private: + static std::map<std::string,weak_ptr<ZLInputStream> > ourPlainStreamCache; + +public: + static std::string fileNameToUtf8(const std::string &fileName); + static std::string replaceIllegalCharacters(const std::string &fileName, char replaceWith); + +public: + static const std::string ZIP; // = "zip" + typedef std::string ArchiveType; //ArchiveType is a string like "tag.gz", that describes sequence of compressors/archivers need to be used + ArchiveType archiveType() const; +private: + void setArchiveType(const ArchiveType type); + void setCompressed(bool compressed); + void setArchived(bool archived); +private: + ZLFile(); + +public: + explicit ZLFile(const std::string &path, shared_ptr<ZLMimeType> mimeType = ZLMimeType::EMPTY); + ~ZLFile(); + + bool exists() const; + std::size_t size() const; + + void forceArchiveType(const std::string & type) const; + + bool isCompressed() const; + bool isDirectory() const; + bool isArchive() const; + + bool remove() const; + bool canRemove() const; + + const std::string &path() const; + const std::string &name(bool hideExtension) const; + const std::string &extension() const; + + shared_ptr<ZLMimeType> mimeType() const; + + std::string physicalFilePath() const; + std::string resolvedPath() const; + + shared_ptr<ZLInputStream> inputStream() const; + shared_ptr<ZLOutputStream> outputStream(bool writeThrough = false) const; + shared_ptr<ZLDir> directory(bool createUnexisting = false) const; + + bool operator == (const ZLFile &other) const; + bool operator != (const ZLFile &other) const; + bool operator < (const ZLFile &other) const; + +private: + void fillInfo() const; + shared_ptr<ZLInputStream> envelopeCompressedStream(shared_ptr<ZLInputStream> &base) const; + +private: + std::string myPath; + std::string myNameWithExtension; + std::string myNameWithoutExtension; + std::string myExtension; + mutable shared_ptr<ZLMimeType> myMimeType; + mutable bool myMimeTypeIsUpToDate; + mutable ArchiveType myArchiveType; + bool myIsCompressed; + bool myIsArchive; + mutable ZLFileInfo myInfo; + mutable bool myInfoIsFilled; +}; + +inline ZLFile::~ZLFile() {} + +inline bool ZLFile::isCompressed() const { return myIsCompressed; } +inline bool ZLFile::isArchive() const { return myIsArchive; } +inline ZLFile::ArchiveType ZLFile::archiveType() const { return myArchiveType; } +inline void ZLFile::setCompressed(bool compressed) { myIsCompressed = compressed; } +inline void ZLFile::setArchived(bool archived) { myIsArchive = archived; } + +inline const std::string &ZLFile::path() const { return myPath; } +inline const std::string &ZLFile::name(bool hideExtension) const { return hideExtension ? myNameWithoutExtension : myNameWithExtension; } +inline const std::string &ZLFile::extension() const { return myExtension; } + +inline bool ZLFile::operator == (const ZLFile &other) const { return myPath == other.myPath; } +inline bool ZLFile::operator != (const ZLFile &other) const { return myPath != other.myPath; } +inline bool ZLFile::operator < (const ZLFile &other) const { return myPath < other.myPath; } + +#endif /* __ZLFILE_H__ */ diff --git a/zlibrary/core/include/ZLFileImage.h b/zlibrary/core/include/ZLFileImage.h index ccd63ad..ff7ed86 120000..100644 --- a/zlibrary/core/include/ZLFileImage.h +++ b/zlibrary/core/include/ZLFileImage.h @@ -1 +1,61 @@ -../src/image/ZLFileImage.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLFILEIMAGE_H__ +#define __ZLFILEIMAGE_H__ + +#include <string> +#include <vector> + +#include <ZLFile.h> +#include <ZLImage.h> + +class ZLFileImage : public ZLSingleImage { + +public: + struct Block { + unsigned int offset; + unsigned int size; + + Block(unsigned int off, unsigned int s); + }; + typedef std::vector<Block> Blocks; + +public: + static const std::string ENCODING_NONE; + static const std::string ENCODING_HEX; + static const std::string ENCODING_BASE64; + +public: + ZLFileImage(const ZLFile &file, std::size_t offset, std::size_t size = 0, const std::string &encoding = ZLFileImage::ENCODING_NONE); + ZLFileImage(const ZLFile &file, const Blocks &blocks, const std::string &encoding = ZLFileImage::ENCODING_NONE); + const shared_ptr<std::string> stringData() const; + +protected: + //shared_ptr<ZLInputStream> inputStream() const; + +private: + const ZLFile myFile; + const std::string myEncoding; + Blocks myBlocks; +}; + +inline ZLFileImage::Block::Block(unsigned int off, unsigned int s) : offset(off), size(s) {} + +#endif /* __ZLFILEIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLFileInfo.h b/zlibrary/core/include/ZLFileInfo.h index 2e46ebc..498c926 120000..100644 --- a/zlibrary/core/include/ZLFileInfo.h +++ b/zlibrary/core/include/ZLFileInfo.h @@ -1 +1,34 @@ -../src/filesystem/ZLFileInfo.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLFILEINFO_H__ +#define __ZLFILEINFO_H__ + +struct ZLFileInfo { + bool Exists; + bool IsDirectory; + std::size_t Size; + + ZLFileInfo(); +}; + +inline ZLFileInfo::ZLFileInfo() : Exists(false), IsDirectory(false), Size(0) { +} + +#endif /* __ZLFILEINFO_H__ */ diff --git a/zlibrary/core/include/ZLFileUtil.h b/zlibrary/core/include/ZLFileUtil.h index 7466928..b76b68d 120000..100644 --- a/zlibrary/core/include/ZLFileUtil.h +++ b/zlibrary/core/include/ZLFileUtil.h @@ -1 +1,34 @@ -../src/util/ZLFileUtil.h
\ No newline at end of file +/* + * Copyright (C) 2010-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLFILEUTIL_H__ +#define __ZLFILEUTIL_H__ + +#include <string> + +class ZLFileUtil { + +public: + static std::string normalizeUnixPath(const std::string &path); + +private: + ZLFileUtil(); +}; + +#endif /* __ZLFILEUTIL_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLFontFamilyOptionEntry.h b/zlibrary/core/include/ZLFontFamilyOptionEntry.h index 9a8a687..9a8a687 100644 --- a/zlibrary/core/src/optionEntries/ZLFontFamilyOptionEntry.h +++ b/zlibrary/core/include/ZLFontFamilyOptionEntry.h diff --git a/zlibrary/core/src/network/ZLGzipAsynchronousInputStream.h b/zlibrary/core/include/ZLGzipAsynchronousInputStream.h index b4cbfaa..b4cbfaa 100644 --- a/zlibrary/core/src/network/ZLGzipAsynchronousInputStream.h +++ b/zlibrary/core/include/ZLGzipAsynchronousInputStream.h diff --git a/zlibrary/core/src/image/ZLHexEncodedImage.h b/zlibrary/core/include/ZLHexEncodedImage.h index 134314f..134314f 100644 --- a/zlibrary/core/src/image/ZLHexEncodedImage.h +++ b/zlibrary/core/include/ZLHexEncodedImage.h diff --git a/zlibrary/core/include/ZLHexInputStream.h b/zlibrary/core/include/ZLHexInputStream.h index a519eb6..b846cdd 120000..100644 --- a/zlibrary/core/include/ZLHexInputStream.h +++ b/zlibrary/core/include/ZLHexInputStream.h @@ -1 +1,50 @@ -../src/util/ZLHexInputStream.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLHEXINPUTSTREAM_H__ +#define __ZLHEXINPUTSTREAM_H__ + +#include <ZLInputStream.h> + +class ZLHexInputStream : public ZLInputStream { +public: + ZLHexInputStream(shared_ptr<ZLInputStream> base); + ~ZLHexInputStream(); + + bool open(); + int read(); + std::size_t read(char *buffer, std::size_t maxSize); + void close(); + + void seek(int offset, bool absoluteOffset); + std::size_t offset() const; + std::size_t sizeOfOpened(); + +private: + bool fillBuffer(); + static int decode(char b); + +private: + shared_ptr<ZLInputStream> myBaseStream; + char* myBuffer; + int myBufferOffset; + int myBufferLength; +}; + +#endif /* __ZLHEXINPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLImage.h b/zlibrary/core/include/ZLImage.h index 3371017..15c88b9 120000..100644 --- a/zlibrary/core/include/ZLImage.h +++ b/zlibrary/core/include/ZLImage.h @@ -1 +1,83 @@ -../src/image/ZLImage.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLIMAGE_H__ +#define __ZLIMAGE_H__ + +#include <string> + +#include <shared_ptr.h> + +#include <ZLMimeType.h> + +class ZLNetworkRequest; + +class ZLImage { + +protected: + ZLImage(); + +public: + virtual ~ZLImage(); + virtual bool isSingle() const = 0; + virtual shared_ptr<ZLNetworkRequest> synchronizationData() const; + virtual bool good() const = 0; +}; + +class ZLSingleImage : public ZLImage { + +protected: + ZLSingleImage(shared_ptr<ZLMimeType> mimeType); + virtual ~ZLSingleImage(); + +public: + bool isSingle() const { return true; } + shared_ptr<ZLMimeType> mimeType() const; + bool good() const; + virtual const shared_ptr<std::string> stringData() const = 0; + +private: + shared_ptr<ZLMimeType> myMimeType; +}; + +class ZLMultiImage : public ZLImage { + +protected: + ZLMultiImage(); + virtual ~ZLMultiImage(); + +public: + bool isSingle() const { return false; } + bool good() const; + virtual unsigned int rows() const = 0; + virtual unsigned int columns() const = 0; + virtual shared_ptr<const ZLImage> subImage(unsigned int row, unsigned int column) const = 0; +}; + +inline ZLImage::ZLImage() {} +inline ZLImage::~ZLImage() {} + +inline ZLSingleImage::ZLSingleImage(shared_ptr<ZLMimeType> mimeType) : myMimeType(mimeType) {} +inline ZLSingleImage::~ZLSingleImage() {} +inline shared_ptr<ZLMimeType> ZLSingleImage::mimeType() const { return myMimeType; } + +inline ZLMultiImage::ZLMultiImage() : ZLImage() {} +inline ZLMultiImage::~ZLMultiImage() {} + +#endif /* __ZLIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLImageManager.h b/zlibrary/core/include/ZLImageManager.h index 62681ed..c845c2b 120000..100644 --- a/zlibrary/core/include/ZLImageManager.h +++ b/zlibrary/core/include/ZLImageManager.h @@ -1 +1,83 @@ -../src/image/ZLImageManager.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLIMAGEMANAGER_H__ +#define __ZLIMAGEMANAGER_H__ + +#include <string> +#include <vector> + +#include <shared_ptr.h> + +class ZLImage; +class ZLMultiImage; + +class ZLImageData { + +protected: + ZLImageData() {} + +public: + virtual ~ZLImageData() {} + + virtual unsigned int width() const = 0; + virtual unsigned int height() const = 0; + + virtual void init(unsigned int width, unsigned int height) = 0; + virtual void setPosition(unsigned int x, unsigned int y) = 0; + virtual void moveX(int delta) = 0; + virtual void moveY(int delta) = 0; + virtual void setPixel(unsigned char r, unsigned char g, unsigned char b) = 0; + void setGrayPixel(unsigned char c); + + virtual void copyFrom(const ZLImageData &source, unsigned int targetX, unsigned int targetY) = 0; +}; + +class ZLImageManager { + +public: + static const ZLImageManager &Instance(); + static void deleteInstance(); + +protected: + static ZLImageManager *ourInstance; + +public: + shared_ptr<ZLImageData> imageData(const ZLImage &image) const; + +public: + virtual shared_ptr<const ZLImage> makeBatchImage(const std::vector<shared_ptr<const ZLImage> > &images, shared_ptr<const ZLImage> defaultImage) const = 0; + +protected: + ZLImageManager() {} + virtual ~ZLImageManager() {} + + virtual shared_ptr<ZLImageData> createData() const = 0; + virtual bool convertImageDirect(const std::string &stringData, ZLImageData &imageData) const = 0; + +private: + bool convertMultiImage(const ZLMultiImage &multiImage, ZLImageData &imageData) const; + bool convertFromPalmImageFormat(const std::string &imageString, ZLImageData &imageData) const; +}; + +inline void ZLImageData::setGrayPixel(unsigned char c) { setPixel(c, c, c); } + +inline const ZLImageManager &ZLImageManager::Instance() { return *ourInstance; } + +#endif /* __IMAGEMANAGER_H__ */ diff --git a/zlibrary/core/include/ZLInputStream.h b/zlibrary/core/include/ZLInputStream.h index 9ce442d..7ac09c7 120000..100644 --- a/zlibrary/core/include/ZLInputStream.h +++ b/zlibrary/core/include/ZLInputStream.h @@ -1 +1,71 @@ -../src/filesystem/ZLInputStream.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLINPUTSTREAM_H__ +#define __ZLINPUTSTREAM_H__ + +#include <string> + +#include <shared_ptr.h> +#include <ZLUserData.h> + +class ZLInputStream : public ZLUserDataHolder { + +protected: + ZLInputStream(); + +public: + virtual ~ZLInputStream(); + virtual bool open() = 0; + virtual std::size_t read(char *buffer, std::size_t maxSize) = 0; + virtual void close() = 0; + + virtual void seek(int offset, bool absoluteOffset) = 0; + virtual std::size_t offset() const = 0; + virtual std::size_t sizeOfOpened() = 0; + +private: + // disable copying + ZLInputStream(const ZLInputStream&); + const ZLInputStream &operator = (const ZLInputStream&); +}; + +class ZLInputStreamDecorator : public ZLInputStream { + +public: + ZLInputStreamDecorator(shared_ptr<ZLInputStream> decoratee); + +private: + bool open(); + std::size_t read(char *buffer, std::size_t maxSize); + void close(); + + void seek(int offset, bool absoluteOffset); + std::size_t offset() const; + std::size_t sizeOfOpened(); + +private: + shared_ptr<ZLInputStream> myBaseStream; + std::size_t myBaseOffset; +}; + +inline ZLInputStream::ZLInputStream() {} +inline ZLInputStream::~ZLInputStream() {} + +#endif /* __ZLINPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLKeyBindings.h b/zlibrary/core/include/ZLKeyBindings.h index 34d8fef..322baa4 120000..100644 --- a/zlibrary/core/include/ZLKeyBindings.h +++ b/zlibrary/core/include/ZLKeyBindings.h @@ -1 +1,48 @@ -../src/application/ZLKeyBindings.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLKEYBINDINGS_H__ +#define __ZLKEYBINDINGS_H__ + +#include <map> +#include <string> + +class ZLKeyBindings { + +public: + ZLKeyBindings(const std::string &name); + ~ZLKeyBindings(); + + void bindKey(const std::string &key, const std::string &code); + const std::string &getBinding(const std::string &key); + +private: + void loadDefaultBindings(); + void loadCustomBindings(); + +public: + void saveCustomBindings(); + +private: + const std::string myName; + std::map<std::string,std::string> myBindingsMap; + bool myIsChanged; +}; + +#endif /* __KEYBINDINGS_H__ */ diff --git a/zlibrary/core/src/util/ZLKeyUtil.h b/zlibrary/core/include/ZLKeyUtil.h index 9368e5e..9368e5e 100644 --- a/zlibrary/core/src/util/ZLKeyUtil.h +++ b/zlibrary/core/include/ZLKeyUtil.h diff --git a/zlibrary/core/include/ZLLanguageDetector.h b/zlibrary/core/include/ZLLanguageDetector.h index 4c51044..7f5d8dc 120000..100644 --- a/zlibrary/core/include/ZLLanguageDetector.h +++ b/zlibrary/core/include/ZLLanguageDetector.h @@ -1 +1,51 @@ -../src/language/ZLLanguageDetector.h
\ No newline at end of file +/* + * Copyright (C) 2007-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLLANGUAGEDETECTOR_H__ +#define __ZLLANGUAGEDETECTOR_H__ + +#include <vector> +#include <string> + +//#include <shared_ptr.h> + +class ZLStatisticsBasedMatcher; + +class ZLLanguageDetector { + +public: + struct LanguageInfo { + LanguageInfo(const std::string &language, const std::string &encoding); + const std::string Language; + const std::string Encoding; + }; + +public: + ZLLanguageDetector(); + ~ZLLanguageDetector(); + + shared_ptr<LanguageInfo> findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0); + shared_ptr<LanguageInfo> findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0); + +private: + typedef std::vector<shared_ptr<ZLStatisticsBasedMatcher> > SBVector; + SBVector myMatchers; +}; + +#endif /* __ZLLANGUAGEDETECTOR_H__ */ diff --git a/zlibrary/core/include/ZLLanguageList.h b/zlibrary/core/include/ZLLanguageList.h index 2233797..318c545 120000..100644 --- a/zlibrary/core/include/ZLLanguageList.h +++ b/zlibrary/core/include/ZLLanguageList.h @@ -1 +1,41 @@ -../src/language/ZLLanguageList.h
\ No newline at end of file +/* + * Copyright (C) 2007-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLLANGUAGELIST_H__ +#define __ZLLANGUAGELIST_H__ + +#include <vector> + +#include <ZLDir.h> + +class ZLLanguageList { + +public: + static std::string patternsDirectoryPath(); + static const std::vector<std::string> &languageCodes(); + static std::string languageName(const std::string &code); + +private: + static std::vector<std::string> ourLanguageCodes; + +private: + ZLLanguageList(); +}; + +#endif /* __ZLLANGUAGELIST_H__ */ diff --git a/zlibrary/core/src/language/ZLLanguageMatcher.h b/zlibrary/core/include/ZLLanguageMatcher.h index 9460854..9460854 100644 --- a/zlibrary/core/src/language/ZLLanguageMatcher.h +++ b/zlibrary/core/include/ZLLanguageMatcher.h diff --git a/zlibrary/core/src/optionEntries/ZLLanguageOptionEntry.h b/zlibrary/core/include/ZLLanguageOptionEntry.h index 292b89d..292b89d 100644 --- a/zlibrary/core/src/optionEntries/ZLLanguageOptionEntry.h +++ b/zlibrary/core/include/ZLLanguageOptionEntry.h diff --git a/zlibrary/core/include/ZLLanguageUtil.h b/zlibrary/core/include/ZLLanguageUtil.h index 1766657..a0f912c 120000..100644 --- a/zlibrary/core/include/ZLLanguageUtil.h +++ b/zlibrary/core/include/ZLLanguageUtil.h @@ -1 +1,38 @@ -../src/util/ZLLanguageUtil.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLLANGUAGEUTIL_H__ +#define __ZLLANGUAGEUTIL_H__ + +#include <string> + +class ZLLanguageUtil { + +public: + static const std::string OtherLanguageCode; + +public: + static std::string languageByCode(unsigned char languageCode, unsigned char subLanguageCode); + static bool isRTLLanguage(const std::string &languageCode); + +private: + ZLLanguageUtil(); +}; + +#endif /* __ZLLANGUAGEUTIL_H__ */ diff --git a/zlibrary/core/include/ZLLogger.h b/zlibrary/core/include/ZLLogger.h index 7ba1ad3..5484b91 120000..100644 --- a/zlibrary/core/include/ZLLogger.h +++ b/zlibrary/core/include/ZLLogger.h @@ -1 +1,48 @@ -../src/logger/ZLLogger.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLLOGGER_H__ +#define __ZLLOGGER_H__ + +#include <string> +#include <set> + +class ZLLogger { + +public: + static const std::string DEFAULT_CLASS; + + static ZLLogger &Instance(); + +private: + static ZLLogger *ourInstance; + +private: + ZLLogger(); + +public: + void registerClass(const std::string &className); + void print(const std::string &className, const std::string &message) const; + void println(const std::string &className, const std::string &message) const; + +private: + std::set<std::string> myRegisteredClasses; +}; + +#endif /* __ZLLOGGER_H__ */ diff --git a/zlibrary/core/src/application/ZLMenu.h b/zlibrary/core/include/ZLMenu.h index 5f6064b..5f6064b 100644 --- a/zlibrary/core/src/application/ZLMenu.h +++ b/zlibrary/core/include/ZLMenu.h diff --git a/zlibrary/core/include/ZLMessage.h b/zlibrary/core/include/ZLMessage.h index 37065d3..1b0bf8e 120000..100644 --- a/zlibrary/core/include/ZLMessage.h +++ b/zlibrary/core/include/ZLMessage.h @@ -1 +1,92 @@ -../src/message/ZLMessage.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLMESSAGE_H__ +#define __ZLMESSAGE_H__ + +#include <vector> +#include <map> +#include <string> + +#include <shared_ptr.h> + +class ZLMessageOutputChannel; +class ZLMessageSender; + +class ZLMessageHandler; + +class ZLCommunicationManager { + +public: + static ZLCommunicationManager &Instance(); + static void deleteInstance(); + +protected: + static ZLCommunicationManager *ourInstance; + +public: + typedef std::map<std::string,std::string> Data; + +protected: + ZLCommunicationManager(); + virtual ~ZLCommunicationManager(); + void init(); + void onMessageReceived(const std::string &command, const std::vector<std::string> &arguments); + +public: + virtual shared_ptr<ZLMessageOutputChannel> createMessageOutputChannel(const std::string &protocol, const std::string &testFile) = 0; + virtual void addInputMessageDescription(const std::string &command, const std::string &protocol, const Data &data) = 0; + void registerHandler(const std::string &command, shared_ptr<ZLMessageHandler> receiver); + +private: + shared_ptr<ZLMessageHandler> handler(const std::string &command); + +private: + std::map<std::string,weak_ptr<ZLMessageHandler> > myRegisteredHandlers; + bool myInitialized; + +private: + ZLCommunicationManager(const ZLCommunicationManager&); + const ZLCommunicationManager &operator = (const ZLCommunicationManager&); +}; + +class ZLMessageOutputChannel { + +public: + virtual ~ZLMessageOutputChannel(); + + virtual shared_ptr<ZLMessageSender> createSender(const ZLCommunicationManager::Data &data) = 0; +}; + +class ZLMessageSender { + +public: + virtual ~ZLMessageSender(); + + virtual void sendStringMessage(const std::string &message) = 0; +}; + +class ZLMessageHandler { + +public: + virtual ~ZLMessageHandler(); + virtual void onMessageReceived(const std::vector<std::string> &arguments) = 0; +}; + +#endif /* __ZLMESSAGE_H__ */ diff --git a/zlibrary/core/include/ZLMimeType.h b/zlibrary/core/include/ZLMimeType.h index bf8cac0..307dc6c 120000..100644 --- a/zlibrary/core/include/ZLMimeType.h +++ b/zlibrary/core/include/ZLMimeType.h @@ -1 +1,93 @@ -../src/constants/ZLMimeType.h
\ No newline at end of file +/* + * Copyright (C) 2010-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLMIMETYPE_H__ +#define __ZLMIMETYPE_H__ + +#include <string> +#include <shared_ptr.h> +#include <map> + +class ZLMimeType { + +private: + + ZLMimeType(std::string& name, std::map<std::string,std::string>& parameters); + +private: + + static std::map<std::string,shared_ptr<ZLMimeType> > ourSimpleTypesMap; + +public: + static shared_ptr<ZLMimeType> get(const char *text); + static shared_ptr<ZLMimeType> get(std::string text); + static bool isImage(shared_ptr<ZLMimeType> mimeType); + +private: + + const std::map<std::string,std::string> myParameters; + const std::string myName; + +public: + + const std::string& getName() const; + const std::string& getParameter(const std::string &key) const; + + bool weakEquals(const ZLMimeType& t) const; + bool operator ==(const ZLMimeType& t) const; + bool operator !=(const ZLMimeType& t) const; + + static const shared_ptr<ZLMimeType> APPLICATION_XML; + static const shared_ptr<ZLMimeType> APPLICATION_ZIP; + static const shared_ptr<ZLMimeType> APPLICATION_EPUB_ZIP; + static const shared_ptr<ZLMimeType> APPLICATION_FB2_ZIP; + static const shared_ptr<ZLMimeType> APPLICATION_MOBIPOCKET_EBOOK; + static const shared_ptr<ZLMimeType> APPLICATION_PDF; + static const shared_ptr<ZLMimeType> APPLICATION_CHM; + static const shared_ptr<ZLMimeType> APPLICATION_PALM_DB; + static const shared_ptr<ZLMimeType> APPLICATION_ATOM_XML; + static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML; + static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_BOOKS; + static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_AUTHORS; + static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_GENRES; + static const shared_ptr<ZLMimeType> APPLICATION_OPENSEARCH_XML; + static const shared_ptr<ZLMimeType> APPLICATION_OR_XML; + + static const shared_ptr<ZLMimeType> APPLICATION_GZIP; + static const shared_ptr<ZLMimeType> APPLICATION_BZIP2; + static const shared_ptr<ZLMimeType> APPLICATION_TAR; + static const shared_ptr<ZLMimeType> APPLICATION_TAR_GZIP; + static const shared_ptr<ZLMimeType> APPLICATION_TAR_BZIP2; + static const shared_ptr<ZLMimeType> APPLICATION_TAR_7Z; + + static const shared_ptr<ZLMimeType> IMAGE_PNG; + static const shared_ptr<ZLMimeType> IMAGE_JPEG; + static const shared_ptr<ZLMimeType> IMAGE_SVG; + static const shared_ptr<ZLMimeType> IMAGE_PALM; + static const shared_ptr<ZLMimeType> IMAGE_AUTO; + + static const shared_ptr<ZLMimeType> TEXT_HTML; + static const shared_ptr<ZLMimeType> TEXT_PLAIN; + static const shared_ptr<ZLMimeType> TEXT_XML; + + static const shared_ptr<ZLMimeType> EMPTY; + +}; + +#endif /* __ZLMIMETYPE_H__ */ diff --git a/zlibrary/core/include/ZLMirroredPaintContext.h b/zlibrary/core/include/ZLMirroredPaintContext.h index 2c29c57..ff7272d 120000..100644 --- a/zlibrary/core/include/ZLMirroredPaintContext.h +++ b/zlibrary/core/include/ZLMirroredPaintContext.h @@ -1 +1,72 @@ -../src/view/ZLMirroredPaintContext.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLMIRROREDPAINTCONTEXT_H__ +#define __ZLMIRROREDPAINTCONTEXT_H__ + +#include <vector> +#include <string> + +#include <ZLColor.h> +#include <ZLPaintContext.h> + +class ZLMirroredPaintContext : public ZLPaintContext { + +public: + ZLMirroredPaintContext(ZLPaintContext &base); + +public: + int mirroredX(int x) const; + +private: + void clear(ZLColor color); + + void setFont(const std::string &family, int size, bool bold, bool italic); + void setColor(ZLColor color, LineStyle style); + void setFillColor(ZLColor color, FillStyle style); + + int width() const; + int height() const; + + int stringWidth(const char *str, int len, bool rtl) const; + int spaceWidth() const; + int stringHeight() const; + int descent() const; + void drawString(int x, int y, const char *str, int len, bool rtl); + + void drawImage(int x, int y, const ZLImageData &image); + void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type); + + void drawLine(int x0, int y0, int x1, int y1); + void fillRectangle(int x0, int y0, int x1, int y1); + void drawFilledCircle(int x, int y, int r); + + const std::string realFontFamilyName(std::string &fontFamily) const; + + void fillFamiliesList(std::vector<std::string> &families) const; + +private: + ZLPaintContext &myBase; +}; + +inline int ZLMirroredPaintContext::mirroredX(int x) const { + return myBase.width() - x - 1; +} + +#endif /* __ZLMIRROREDPAINTCONTEXT_H__ */ diff --git a/zlibrary/core/src/network/requests/ZLNetworkDownloadRequest.h b/zlibrary/core/include/ZLNetworkDownloadRequest.h index 07f9930..2726c65 100644 --- a/zlibrary/core/src/network/requests/ZLNetworkDownloadRequest.h +++ b/zlibrary/core/include/ZLNetworkDownloadRequest.h @@ -20,7 +20,7 @@ #ifndef __ZLNETWORKDOWNLOADREQUEST_H__ #define __ZLNETWORKDOWNLOADREQUEST_H__ -#include "../ZLNetworkRequest.h" +#include "ZLNetworkRequest.h" class ZLOutputStream; diff --git a/zlibrary/core/include/ZLNetworkImage.h b/zlibrary/core/include/ZLNetworkImage.h index 51c7cc4..98a8223 120000..100644 --- a/zlibrary/core/include/ZLNetworkImage.h +++ b/zlibrary/core/include/ZLNetworkImage.h @@ -1 +1,43 @@ -../src/image/ZLNetworkImage.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLNETWORKIMAGE_H__ +#define __ZLNETWORKIMAGE_H__ + +#include <ZLImage.h> + +class ZLFileImage; + +class ZLNetworkImage : public ZLSingleImage { + +public: + ZLNetworkImage(shared_ptr<ZLMimeType> mimeType, const std::string &url); + const shared_ptr<std::string> stringData() const; + +private: + shared_ptr<ZLNetworkRequest> synchronizationData() const; + +private: + const std::string myURL; + std::string myFileName; + mutable bool myIsSynchronized; + mutable shared_ptr<ZLFileImage> myCachedImage; +}; + +#endif /* __ZLNETWORKIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLNetworkManager.h b/zlibrary/core/include/ZLNetworkManager.h index 8e5cb56..b2fb817 120000..100644 --- a/zlibrary/core/include/ZLNetworkManager.h +++ b/zlibrary/core/include/ZLNetworkManager.h @@ -1 +1,103 @@ -../src/network/ZLNetworkManager.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLNETWORKMANAGER_H__ +#define __ZLNETWORKMANAGER_H__ + +#include <string> + +#include <shared_ptr.h> +#include <ZLOptions.h> + +#include <ZLNetworkRequest.h> +#include <ZLRunnable.h> + +class ZLNetworkData; +class ZLOutputStream; +class ZLXMLReader; + +class ZLNetworkManager { + +public: + static void deleteInstance(); + static ZLNetworkManager &Instance(); + + static std::string CacheDirectory(); + static std::string CookiesPath(); + +protected: + static ZLNetworkManager *ourInstance; + +public: + ZLIntegerRangeOption &ConnectTimeoutOption() const; + ZLIntegerRangeOption &TimeoutOption() const; + ZLBooleanOption &UseProxyOption() const; + ZLStringOption &ProxyHostOption() const; + ZLStringOption &ProxyPortOption() const; + +protected: + ZLNetworkManager(); + virtual ~ZLNetworkManager(); + +public: + virtual std::string perform(const ZLNetworkRequest::Vector &requests) const = 0; + virtual std::string performAsync(const ZLNetworkRequest::Vector &requests) const = 0; + std::string perform(shared_ptr<ZLNetworkRequest> request) const; + std::string performAsync(shared_ptr<ZLNetworkRequest> request) const; + +public: + virtual bool connect() const; + virtual void release() const; + + virtual bool providesProxyInfo() const; + +protected: + virtual bool useProxy() const; + virtual std::string proxyHost() const; + virtual std::string proxyPort() const; + +public: + // returns error message + std::string downloadFile(const std::string &url, const std::string &fileName, shared_ptr<ZLNetworkRequest::Listener> listener = 0) const; + +public: + shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, const std::string &fileName) const; + shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, shared_ptr<ZLOutputStream> stream) const; + shared_ptr<ZLNetworkRequest> createNoActionRequest(const std::string &url) const; + shared_ptr<ZLNetworkRequest> createReadToStringRequest(const std::string &url, std::string &buffer) const; + shared_ptr<ZLNetworkRequest> createXMLParserRequest(const std::string &url, shared_ptr<ZLXMLReader> reader, shared_ptr<ZLRunnable> runnable = 0) const; + +public: + void setUserAgent(const std::string &userAgent); + const std::string &userAgent() const; + +private: + mutable shared_ptr<ZLIntegerRangeOption> myConnectTimeoutOption; + mutable shared_ptr<ZLIntegerRangeOption> myTimeoutOption; + mutable shared_ptr<ZLBooleanOption> myUseProxyOption; + mutable shared_ptr<ZLStringOption> myProxyHostOption; + mutable shared_ptr<ZLStringOption> myProxyPortOption; + + std::string myUserAgent; +}; + +inline void ZLNetworkManager::setUserAgent(const std::string &userAgent) { myUserAgent = userAgent; } +inline const std::string &ZLNetworkManager::userAgent() const { return myUserAgent; } + +#endif /* __ZLNETWORKMANAGER_H__ */ diff --git a/zlibrary/core/src/network/requests/ZLNetworkNoActionRequest.h b/zlibrary/core/include/ZLNetworkNoActionRequest.h index 07e467e..96e21b3 100644 --- a/zlibrary/core/src/network/requests/ZLNetworkNoActionRequest.h +++ b/zlibrary/core/include/ZLNetworkNoActionRequest.h @@ -20,7 +20,7 @@ #ifndef __ZLNETWORKNOACTIONREQUEST_H__ #define __ZLNETWORKNOACTIONREQUEST_H__ -#include "../ZLNetworkRequest.h" +#include "ZLNetworkRequest.h" class ZLNetworkNoActionRequest : public ZLNetworkRequest { diff --git a/zlibrary/core/src/network/requests/ZLNetworkReadToStringRequest.h b/zlibrary/core/include/ZLNetworkReadToStringRequest.h index 4ec8df1..f1c37ba 100644 --- a/zlibrary/core/src/network/requests/ZLNetworkReadToStringRequest.h +++ b/zlibrary/core/include/ZLNetworkReadToStringRequest.h @@ -20,7 +20,7 @@ #ifndef __ZLNETWORKREADTOSTRINGREQUEST_H__ #define __ZLNETWORKREADTOSTRINGREQUEST_H__ -#include "../ZLNetworkRequest.h" +#include "ZLNetworkRequest.h" class ZLNetworkReadToStringRequest : public ZLNetworkRequest { diff --git a/zlibrary/core/include/ZLNetworkRequest.h b/zlibrary/core/include/ZLNetworkRequest.h index e029d68..431355a 120000..100644 --- a/zlibrary/core/include/ZLNetworkRequest.h +++ b/zlibrary/core/include/ZLNetworkRequest.h @@ -1 +1,120 @@ -../src/network/ZLNetworkRequest.h
\ No newline at end of file +/* + * Copyright (C) 2010-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLNETWORKREQUEST_H__ +#define __ZLNETWORKREQUEST_H__ + +#include <string> +#include <vector> + +#include <shared_ptr.h> + +class ZLNetworkRequest { + +public: + typedef std::vector<shared_ptr<ZLNetworkRequest> > Vector; + +public: + class Listener { + + protected: + Listener(); + + public: + virtual ~Listener(); + virtual void finished(const std::string &error = std::string()) = 0; + virtual void showPercent(int ready, int full); + virtual void setUIStatus(bool enabled); + + friend class ZLNetworkRequest; + }; + +protected: + ZLNetworkRequest(const std::string &url); + +public: + virtual bool handleHeader(void *ptr, std::size_t size); + virtual bool handleContent(void *ptr, std::size_t size) = 0; + + virtual bool doBefore() = 0; + + // When error is empty return false MUST make request fail; when error is not empty return value MUST be ignored + virtual bool doAfter(const std::string &error) = 0; + +protected: + void setErrorMessage(const std::string &message); + +public: + const std::string &errorMessage() const; + + const std::string &url() const; + +public: // HTTP parameters + void setupAuthentication(const std::string &userName, const std::string &password); + const std::string &userName() const; + const std::string &password() const; + + void setRedirectionSupported(bool supported); + bool isRedirectionSupported() const; + + const std::vector<std::pair<std::string, std::string> > &postParameters() const; + void setPostParameters(const std::vector<std::pair<std::string, std::string> > ¶meters); + + +public: //listeners methods + bool hasListener() const; + void setListener(shared_ptr<Listener> listener); + void setPercent(int ready, int full); + void setUIStatus(bool enabled); + +protected: + void finished(const std::string &error); + shared_ptr<Listener> listener() const; + +private: + const std::string myURL; + std::string myErrorMessage; + + std::string myUserName; + std::string myPassword; + + bool myRedirectionSupported; + + std::vector<std::pair<std::string, std::string> > myPostParameters; + + shared_ptr<Listener> myListener; + +private: // disable copying + ZLNetworkRequest(const ZLNetworkRequest &); + const ZLNetworkRequest &operator = (const ZLNetworkRequest &); +}; + +inline void ZLNetworkRequest::setupAuthentication(const std::string &userName, const std::string &password) { + myUserName = userName; + myPassword = password; +} +inline const std::string &ZLNetworkRequest::userName() const { return myUserName; } +inline const std::string &ZLNetworkRequest::password() const { return myPassword; } +inline void ZLNetworkRequest::setRedirectionSupported(bool supported) { myRedirectionSupported = supported; } +inline bool ZLNetworkRequest::isRedirectionSupported() const { return myRedirectionSupported; } +inline const std::vector<std::pair<std::string, std::string> > &ZLNetworkRequest::postParameters() const { return myPostParameters; } + +inline shared_ptr<ZLNetworkRequest::Listener> ZLNetworkRequest::listener() const { return myListener; } + +#endif /* __ZLNETWORKREQUEST_H__ */ diff --git a/zlibrary/core/include/ZLNetworkUtil.h b/zlibrary/core/include/ZLNetworkUtil.h index 51d7ba6..430044a 120000..100644 --- a/zlibrary/core/include/ZLNetworkUtil.h +++ b/zlibrary/core/include/ZLNetworkUtil.h @@ -1 +1,42 @@ -../src/network/ZLNetworkUtil.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLNETWORKUTIL_H__ +#define __ZLNETWORKUTIL_H__ + +#include <string> + +class ZLNetworkUtil { + +public: + static std::string htmlEncode(const std::string &stringToEncode); + static std::string hostFromUrl(const std::string &url); + static std::string url(const std::string &baseUrl, const std::string &relativePath); + + static std::string &appendParameter(std::string &url, const std::string &name, const std::string &value); + static bool hasParameter(const std::string &url, const std::string &name); + +private: + static bool isNonRelativeUrl(const std::string &url); + +private: + ZLNetworkUtil(); +}; + +#endif /* __ZLNETWORKUTIL_H__ */ diff --git a/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.h b/zlibrary/core/include/ZLNetworkXMLParserRequest.h index df2ac87..b03c847 100644 --- a/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.h +++ b/zlibrary/core/include/ZLNetworkXMLParserRequest.h @@ -22,7 +22,7 @@ #include <ZLRunnable.h> -#include "../ZLNetworkRequest.h" +#include "ZLNetworkRequest.h" class ZLXMLReader; class ZLAsynchronousInputStream; diff --git a/zlibrary/core/include/ZLOpenFileDialog.h b/zlibrary/core/include/ZLOpenFileDialog.h index 05fad51..e20673d 120000..100644 --- a/zlibrary/core/include/ZLOpenFileDialog.h +++ b/zlibrary/core/include/ZLOpenFileDialog.h @@ -1 +1,43 @@ -../src/dialogs/ZLOpenFileDialog.h
\ No newline at end of file +/* + * Copyright (C) 2010-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLOPENFILEDIALOG_H__ +#define __ZLOPENFILEDIALOG_H__ + +#include <string> + +class ZLFile; + +class ZLOpenFileDialog { + +public: + class Filter { + + public: + virtual ~Filter(); + virtual bool accepts(const ZLFile &file) const = 0; + }; + +public: + virtual bool run() = 0; + virtual std::string filePath() const = 0; + virtual std::string directoryPath() const = 0; +}; + +#endif /* __ZLOPENFILEDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLOptionEntry.h b/zlibrary/core/include/ZLOptionEntry.h index 90231c9..fb3a319 120000..100644 --- a/zlibrary/core/include/ZLOptionEntry.h +++ b/zlibrary/core/include/ZLOptionEntry.h @@ -1 +1,294 @@ -../src/dialogs/ZLOptionEntry.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLOPTIONENTRY_H__ +#define __ZLOPTIONENTRY_H__ + +#include <vector> +#include <string> + +#include <ZLOptions.h> + +class ZLOptionView; + +class ZLOptionEntry { + +public: + enum ZLOptionKind { + CHOICE, + BOOLEAN, + BOOLEAN3, + STRING, + PASSWORD, + SPIN, + COMBO, + COLOR, + KEY, + ORDER, + MULTILINE, + STATIC, + }; + +public: + ZLOptionEntry(); + virtual ~ZLOptionEntry(); + virtual ZLOptionKind kind() const = 0; + + void setView(ZLOptionView *view); + void resetView(); + + virtual void setVisible(bool visible); + bool isVisible() const; + + virtual void setActive(bool active); + bool isActive() const; + +private: + ZLOptionView *myView; + bool myIsVisible; + bool myIsActive; +}; + +class ZLChoiceOptionEntry : public ZLOptionEntry { + +protected: + ZLChoiceOptionEntry(); + +public: + ZLOptionKind kind() const; + + virtual const std::string &text(int index) const = 0; + virtual int choiceNumber() const = 0; + virtual int initialCheckedIndex() const = 0; + virtual void onAccept(int index) = 0; +}; + +class ZLTextOptionEntry : public ZLOptionEntry { + +public: + virtual const std::string &initialValue() const = 0; + void onAccept(const char *value); + virtual void onAccept(const std::string &value) = 0; + virtual bool useOnValueEdited() const; + void onValueEdited(const char *value); + virtual void onValueEdited(const std::string &value); +}; + +class ZLStringOptionEntry : public ZLTextOptionEntry { + +protected: + ZLStringOptionEntry(); + +public: + ZLOptionKind kind() const; +}; + +class ZLPasswordOptionEntry : public ZLTextOptionEntry { + +protected: + ZLPasswordOptionEntry(); + +public: + ZLOptionKind kind() const; +}; + +class ZLMultilineOptionEntry : public ZLTextOptionEntry { + +protected: + ZLMultilineOptionEntry(); + +public: + ZLOptionKind kind() const; +}; + +class ZLBooleanOptionEntry : public ZLOptionEntry { + +protected: + ZLBooleanOptionEntry(); + +public: + ZLOptionKind kind() const; + + virtual bool initialState() const = 0; + virtual void onStateChanged(bool state); + virtual void onAccept(bool state) = 0; +}; + +class ZLBoolean3OptionEntry : public ZLOptionEntry { + +protected: + ZLBoolean3OptionEntry(); + +public: + ZLOptionKind kind() const; + + virtual ZLBoolean3 initialState() const = 0; + virtual void onStateChanged(ZLBoolean3 state); + virtual void onAccept(ZLBoolean3 state) = 0; +}; + +class ZLSpinOptionEntry : public ZLOptionEntry { + +protected: + ZLSpinOptionEntry(); + +public: + ZLOptionKind kind() const; + + virtual int initialValue() const = 0; + virtual int minValue() const = 0; + virtual int maxValue() const = 0; + virtual int step() const = 0; + virtual void onAccept(int value) = 0; +}; + +class ZLComboOptionEntry : public ZLOptionEntry { + +protected: + ZLComboOptionEntry(bool editable = false); + +public: + ZLOptionKind kind() const; + + virtual const std::string &initialValue() const = 0; + virtual const std::vector<std::string> &values() const = 0; + virtual void onValueSelected(int index); + void onStringValueSelected(const char *value); + void onStringValueSelected(const std::string &value); + virtual bool useOnValueEdited() const; + void onValueEdited(const char *value); + virtual void onValueEdited(const std::string &value); + void onAccept(const char *value); + virtual void onAccept(const std::string &value) = 0; + + bool isEditable() const; + +private: + const bool myEditable; +}; + +class ZLColorOptionEntry : public ZLOptionEntry { + +protected: + ZLColorOptionEntry(); + +public: + ZLOptionKind kind() const; + + virtual const ZLColor initialColor() const = 0; + virtual const ZLColor color() const = 0; + virtual void onAccept(ZLColor color) = 0; + virtual void onReset(ZLColor color); +}; + +class ZLKeyOptionEntry : public ZLOptionEntry { + +public: + ZLKeyOptionEntry(); + void addActionName(const std::string &actionName); + const std::vector<std::string> &actionNames() const; + virtual void onAccept() = 0; + virtual int actionIndex(const std::string &key) = 0; + virtual void onValueChanged(const std::string &key, int index) = 0; + virtual void onKeySelected(const std::string &key) = 0; + +protected: + ZLOptionKind kind() const; + +private: + std::vector<std::string> myActionNames; +}; + +class ZLOrderOptionEntry : public ZLOptionEntry { + +public: + ZLOrderOptionEntry(); + std::vector<std::string> &values(); + +protected: + ZLOptionKind kind() const; + +private: + std::vector<std::string> myValues; +}; + +class ZLStaticTextOptionEntry : public ZLOptionEntry { + +public: + virtual ZLOptionKind kind() const; + + virtual const std::string &initialValue() const = 0; +}; + + +inline ZLOptionEntry::ZLOptionEntry() : myView(0), myIsVisible(true), myIsActive(true) {} +inline ZLOptionEntry::~ZLOptionEntry() {} +inline void ZLOptionEntry::setView(ZLOptionView *view) { myView = view; } +inline bool ZLOptionEntry::isVisible() const { return myIsVisible; } +inline bool ZLOptionEntry::isActive() const { return myIsActive; } + +inline ZLChoiceOptionEntry::ZLChoiceOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLChoiceOptionEntry::kind() const { return CHOICE; } + +inline bool ZLTextOptionEntry::useOnValueEdited() const { return false; } +inline void ZLTextOptionEntry::onValueEdited(const std::string&) {} + +inline ZLStringOptionEntry::ZLStringOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLStringOptionEntry::kind() const { return STRING; } + +inline ZLPasswordOptionEntry::ZLPasswordOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLPasswordOptionEntry::kind() const { return PASSWORD; } + +inline ZLMultilineOptionEntry::ZLMultilineOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLMultilineOptionEntry::kind() const { return MULTILINE; } + +inline ZLBooleanOptionEntry::ZLBooleanOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLBooleanOptionEntry::kind() const { return BOOLEAN; } +inline void ZLBooleanOptionEntry::onStateChanged(bool) {} + +inline ZLBoolean3OptionEntry::ZLBoolean3OptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLBoolean3OptionEntry::kind() const { return BOOLEAN3; } +inline void ZLBoolean3OptionEntry::onStateChanged(ZLBoolean3) {} + +inline ZLSpinOptionEntry::ZLSpinOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLSpinOptionEntry::kind() const { return SPIN; } + +inline ZLComboOptionEntry::ZLComboOptionEntry(bool editable) : myEditable(editable) {} +inline ZLOptionEntry::ZLOptionKind ZLComboOptionEntry::kind() const { return COMBO; } +inline void ZLComboOptionEntry::onValueSelected(int) {} +inline bool ZLComboOptionEntry::useOnValueEdited() const { return false; } +inline void ZLComboOptionEntry::onValueEdited(const std::string&) {} +inline bool ZLComboOptionEntry::isEditable() const { return myEditable; } + +inline ZLColorOptionEntry::ZLColorOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLColorOptionEntry::kind() const { return COLOR; } +inline void ZLColorOptionEntry::onReset(ZLColor) {} + +inline ZLKeyOptionEntry::ZLKeyOptionEntry() {} +inline void ZLKeyOptionEntry::addActionName(const std::string &actionName) { myActionNames.push_back(actionName); } +inline const std::vector<std::string> &ZLKeyOptionEntry::actionNames() const { return myActionNames; } +inline ZLOptionEntry::ZLOptionKind ZLKeyOptionEntry::kind() const { return KEY; } + +inline ZLOrderOptionEntry::ZLOrderOptionEntry() {} +inline ZLOptionEntry::ZLOptionKind ZLOrderOptionEntry::kind() const { return ORDER; } +inline std::vector<std::string> &ZLOrderOptionEntry::values() { return myValues; } + +inline ZLOptionEntry::ZLOptionKind ZLStaticTextOptionEntry::kind() const { return STATIC; } + +#endif /* __ZLOPTIONENTRY_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLOptionView.h b/zlibrary/core/include/ZLOptionView.h index b89bf48..b89bf48 100644 --- a/zlibrary/core/src/dialogs/ZLOptionView.h +++ b/zlibrary/core/include/ZLOptionView.h diff --git a/zlibrary/core/include/ZLOptions.h b/zlibrary/core/include/ZLOptions.h index 7a54134..80a6aec 120000..100644 --- a/zlibrary/core/include/ZLOptions.h +++ b/zlibrary/core/include/ZLOptions.h @@ -1 +1,217 @@ -../src/options/ZLOptions.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLOPTIONS_H__ +#define __ZLOPTIONS_H__ + +#include <vector> +#include <string> + +#include <ZLColor.h> +#include <ZLBoolean3.h> + +class ZLCategoryKey { + +public: + static const ZLCategoryKey EMPTY; + static const ZLCategoryKey LOOK_AND_FEEL; + static const ZLCategoryKey CONFIG; + static const ZLCategoryKey STATE; + static const ZLCategoryKey SYSTEM; + static const ZLCategoryKey NETWORK; + +protected: + explicit ZLCategoryKey(const std::string &name); + +public: + bool operator == (const ZLCategoryKey &key) const; + bool operator != (const ZLCategoryKey &key) const; + + const std::string Name; +}; + +class ZLConfig; + +class ZLOption { + +private: + static ZLConfig *ourConfig; + +public: + static void createInstance(); + static void deleteInstance(); + +protected: + const std::string &getConfigValue(const std::string &defaultValue) const; + const std::string &getConfigValue() const; + const std::string &getDefaultConfigValue(const std::string &defaultValue) const; + const std::string &getDefaultConfigValue() const; + void setConfigValue(const std::string &value) const; + void unsetConfigValue() const; + +public: + static const std::string PLATFORM_GROUP; + static const std::string FULL_KEYBOARD_CONTROL; + static const std::string KEYBOARD_PRESENTED; + static const std::string MOUSE_PRESENTED; + static const std::string TOUCHSCREEN_PRESENTED; + static const std::string FINGER_TAP_DETECTABLE; + +public: + static void clearGroup(const std::string &group); + static void listOptionNames(const std::string &group, std::vector<std::string> &names); + static void listOptionGroups(std::vector<std::string> &groups); + static bool isAutoSavingSupported(); + static void startAutoSave(int seconds); + +protected: + ZLOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName); + +public: + virtual ~ZLOption(); + +private: + const ZLCategoryKey &myCategory; + std::string myGroupName; + std::string myOptionName; + +protected: + mutable bool myIsSynchronized; + +private: + ZLOption(const ZLOption&); + const ZLOption &operator = (const ZLOption&); +}; + +class ZLSimpleOption : public ZLOption { + +public: + enum Type { + TYPE_BOOLEAN, + TYPE_BOOLEAN3, + //TYPE_COLOR, + TYPE_STRING, + }; + +protected: + ZLSimpleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName); + +public: + virtual Type type() const = 0; +}; + +class ZLBooleanOption : public ZLSimpleOption { + +public: + ZLBooleanOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, bool defaultValue); + Type type() const; + + bool value() const; + void setValue(bool value); + +private: + mutable bool myValue; + const bool myDefaultValue; +}; + +class ZLBoolean3Option : public ZLSimpleOption { + +public: + ZLBoolean3Option(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLBoolean3 defaultValue); + Type type() const; + + ZLBoolean3 value() const; + void setValue(ZLBoolean3 value); + +private: + mutable ZLBoolean3 myValue; + const ZLBoolean3 myDefaultValue; +}; + +class ZLIntegerOption : public ZLOption { + +public: + ZLIntegerOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long defaultValue); + + long value() const; + void setValue(long value); + +private: + mutable long myValue; + const long myDefaultValue; +}; + +class ZLIntegerRangeOption : public ZLOption { + +public: + ZLIntegerRangeOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long minValue, long maxValue, long defaultValue); + + long value() const; + void setValue(long value); + long minValue() const; + long maxValue() const; + +private: + mutable long myValue; + const long myMinValue; + const long myMaxValue; + const long myDefaultValue; +}; + +class ZLColorOption : public ZLOption { + +public: + ZLColorOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLColor defaultValue); + + ZLColor value() const; + void setValue(ZLColor value); + +private: + mutable long myIntValue; + const long myDefaultIntValue; +}; + +class ZLDoubleOption : public ZLOption { + +public: + ZLDoubleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, double defaultValue); + + double value() const; + void setValue(double value); + +private: + mutable double myValue; + const double myDefaultValue; +}; + +class ZLStringOption : public ZLSimpleOption { + +public: + ZLStringOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, const std::string &defaultValue); + Type type() const; + + const std::string &value() const; + void setValue(const std::string &value); + +private: + mutable std::string myValue; + const std::string myDefaultValue; +}; + +#endif /* __ZLOPTIONS_H__ */ diff --git a/zlibrary/core/include/ZLOptionsDialog.h b/zlibrary/core/include/ZLOptionsDialog.h index 1e935fd..0a72cdb 120000..100644 --- a/zlibrary/core/include/ZLOptionsDialog.h +++ b/zlibrary/core/include/ZLOptionsDialog.h @@ -1 +1,75 @@ -../src/dialogs/ZLOptionsDialog.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLOPTIONSDIALOG_H__ +#define __ZLOPTIONSDIALOG_H__ + +#include <vector> +#include <string> + +#include <shared_ptr.h> + +#include <ZLRunnable.h> +#include <ZLDialogContent.h> +#include <ZLOptions.h> +#include <ZLResource.h> + +class ZLOptionEntry; + +class ZLDialogContentBuilder; + +class ZLOptionsDialog { + +protected: + static void addPlatformDependentBuilder(shared_ptr<ZLDialogContentBuilder> builder); + +private: + static std::vector<shared_ptr<ZLDialogContentBuilder> > ourPlatformDependentBuilders; + +protected: + ZLOptionsDialog(const ZLResource &resource, shared_ptr<ZLRunnable> applyAction); + +public: + virtual ~ZLOptionsDialog(); + virtual ZLDialogContent &createTab(const ZLResourceKey &key) = 0; + void createPlatformDependentTabs(); + virtual bool run(); + +protected: + virtual const std::string &selectedTabKey() const = 0; + virtual void selectTab(const ZLResourceKey &key) = 0; + virtual bool runInternal() = 0; + + void accept(); + + const std::string &caption() const; + const ZLResource &tabResource(const ZLResourceKey &key) const; + +protected: + ZLStringOption TabOption; + +private: + const ZLResource &myResource; + +protected: + shared_ptr<ZLRunnable> myApplyAction; + std::vector<shared_ptr<ZLDialogContent> > myTabs; +}; + +#endif /* __ZLOPTIONSDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLOutputStream.h b/zlibrary/core/include/ZLOutputStream.h index 750bf94..63da97f 120000..100644 --- a/zlibrary/core/include/ZLOutputStream.h +++ b/zlibrary/core/include/ZLOutputStream.h @@ -1 +1,45 @@ -../src/filesystem/ZLOutputStream.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLOUTPUTSTREAM_H__ +#define __ZLOUTPUTSTREAM_H__ + +#include <string> + +class ZLOutputStream { + +protected: + ZLOutputStream(); + +public: + virtual ~ZLOutputStream(); + virtual bool open() = 0; + virtual void write(const char *data, std::size_t len) = 0; + virtual void write(const std::string &str) = 0; + virtual void close() = 0; + +private: + ZLOutputStream(const ZLOutputStream&); + const ZLOutputStream &operator = (const ZLOutputStream&); +}; + +inline ZLOutputStream::ZLOutputStream() {} +inline ZLOutputStream::~ZLOutputStream() {} + +#endif /* __ZLOUTPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLPaintContext.h b/zlibrary/core/include/ZLPaintContext.h index a75b5c0..7597a33 120000..100644 --- a/zlibrary/core/include/ZLPaintContext.h +++ b/zlibrary/core/include/ZLPaintContext.h @@ -1 +1,98 @@ -../src/view/ZLPaintContext.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLPAINTCONTEXT_H__ +#define __ZLPAINTCONTEXT_H__ + +#include <vector> +#include <string> + +#include <ZLColor.h> +#include <ZLImageManager.h> + +class ZLPaintContext { + +public: + enum LineStyle { + SOLID_LINE, + DASH_LINE, + }; + + enum FillStyle { + SOLID_FILL, + HALF_FILL, + }; + +protected: + ZLPaintContext(); + +public: + virtual ~ZLPaintContext(); + + virtual void clear(ZLColor color) = 0; + + virtual void setFont(const std::string &family, int size, bool bold, bool italic) = 0; + virtual void setColor(ZLColor color, LineStyle style = SOLID_LINE) = 0; + virtual void setFillColor(ZLColor color, FillStyle style = SOLID_FILL) = 0; + + virtual int width() const = 0; + virtual int height() const = 0; + + virtual int stringWidth(const char *str, int len, bool rtl) const = 0; + virtual int spaceWidth() const = 0; + virtual int stringHeight() const = 0; + virtual int descent() const = 0; + virtual void drawString(int x, int y, const char *str, int len, bool rtl) = 0; + + enum ScalingType { + SCALE_FIT_TO_SIZE, + SCALE_REDUCE_SIZE + }; + + int imageWidth(const ZLImageData &image) const; + int imageHeight(const ZLImageData &image) const; + int imageWidth(const ZLImageData &image, int width, int height, ScalingType type) const; + int imageHeight(const ZLImageData &image, int width, int height, ScalingType type) const; + virtual void drawImage(int x, int y, const ZLImageData &image) = 0; + virtual void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type) = 0; + + virtual void drawLine(int x0, int y0, int x1, int y1) = 0; + virtual void fillRectangle(int x0, int y0, int x1, int y1) = 0; + virtual void drawFilledCircle(int x, int y, int r) = 0; + + const std::vector<std::string> &fontFamilies() const; + virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0; + +protected: + virtual void fillFamiliesList(std::vector<std::string> &families) const = 0; + +private: + mutable std::vector<std::string> myFamilies; + +private: + ZLPaintContext(const ZLPaintContext&); + const ZLPaintContext &operator = (const ZLPaintContext&); + +friend class ZLMirroredPaintContext; +}; + +inline int ZLPaintContext::imageWidth(const ZLImageData &image) const { return image.width(); } +inline int ZLPaintContext::imageHeight(const ZLImageData &image) const { return image.height(); } + +#endif /* __ZLPAINTCONTEXT_H__ */ diff --git a/zlibrary/core/include/ZLPlainAsynchronousInputStream.h b/zlibrary/core/include/ZLPlainAsynchronousInputStream.h index ada7161..eb8d0a7 120000..100644 --- a/zlibrary/core/include/ZLPlainAsynchronousInputStream.h +++ b/zlibrary/core/include/ZLPlainAsynchronousInputStream.h @@ -1 +1,40 @@ -../src/network/ZLPlainAsynchronousInputStream.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ +#define __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ + +#include <ZLAsynchronousInputStream.h> + + +class ZLPlainAsynchronousInputStream : public ZLAsynchronousInputStream { + +public: + ZLPlainAsynchronousInputStream(const char *encoding = 0); + +private: + bool processInputInternal(Handler &handler); + +private: + // disable copying + ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &); + const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &); +}; + +#endif /* __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLPopupData.h b/zlibrary/core/include/ZLPopupData.h index 42d0e04..235826e 120000..100644 --- a/zlibrary/core/include/ZLPopupData.h +++ b/zlibrary/core/include/ZLPopupData.h @@ -1 +1,43 @@ -../src/application/ZLPopupData.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLPOPUPDATA_H__ +#define __ZLPOPUPDATA_H__ + +#include <string> + +#include <ZLResource.h> + +class ZLPopupData { + +public: + virtual ~ZLPopupData(); + + virtual std::size_t id() const = 0; + virtual std::size_t count() const = 0; + virtual const std::string text(std::size_t index) = 0; + virtual void run(std::size_t index) = 0; + + static const ZLResource &resource(const std::string &actionId); +}; + +inline ZLPopupData::~ZLPopupData() { +} + +#endif /* __ZLPOPUPDATA_H__ */ diff --git a/zlibrary/core/include/ZLProgressDialog.h b/zlibrary/core/include/ZLProgressDialog.h index f5d7ec9..be471a0 120000..100644 --- a/zlibrary/core/include/ZLProgressDialog.h +++ b/zlibrary/core/include/ZLProgressDialog.h @@ -1 +1,49 @@ -../src/dialogs/ZLProgressDialog.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLPROGRESSDIALOG_H__ +#define __ZLPROGRESSDIALOG_H__ + +#include <ZLResource.h> +#include <ZLNetworkRequest.h> +#include <ZLRunnable.h> + +class ZLProgressDialog { + +private: + class ProgressListener; + +protected: + ZLProgressDialog(const ZLResourceKey &key); + +public: + virtual ~ZLProgressDialog(); + + shared_ptr<ZLNetworkRequest::Listener> listener(); + virtual void run(ZLRunnable &runnable) = 0; + virtual void setMessage(const std::string &message) = 0; + + const std::string &messageText() const; + std::string messageText(int percent) const; + +private: + const std::string myMessage; +}; + +#endif /* __ZLPROGRESSDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLResource.h b/zlibrary/core/include/ZLResource.h index 5902f08..ee088f2 120000..100644 --- a/zlibrary/core/include/ZLResource.h +++ b/zlibrary/core/include/ZLResource.h @@ -1 +1,59 @@ -../src/resources/ZLResource.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLRESOURCE_H__ +#define __ZLRESOURCE_H__ + +#include <string> + +struct ZLResourceKey { + ZLResourceKey() {} + explicit ZLResourceKey(const std::string &name) : Name(name) {} + + std::string Name; +}; + +class ZLResource { + +public: + static const ZLResource &resource(const std::string &key); + static const ZLResource &resource(const ZLResourceKey &key); + +protected: + ZLResource(const std::string &name); + +public: + virtual ~ZLResource(); + const std::string &name() const; + virtual bool hasValue() const = 0; + virtual const std::string &value() const = 0; + virtual const std::string &value(int number) const = 0; + virtual const ZLResource &operator [] (const std::string &key) const = 0; + const ZLResource &operator [] (const ZLResourceKey &key) const; + +private: + const std::string myName; + +private: + // disable copying + ZLResource(const ZLResource&); + const ZLResource &operator = (const ZLResource&); +}; + +#endif /* __ZLRESOURCE_H__ */ diff --git a/zlibrary/core/include/ZLRunnable.h b/zlibrary/core/include/ZLRunnable.h index 1b0ebff..60914f1 120000..100644 --- a/zlibrary/core/include/ZLRunnable.h +++ b/zlibrary/core/include/ZLRunnable.h @@ -1 +1,45 @@ -../src/runnable/ZLRunnable.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLRUNNABLE_H__ +#define __ZLRUNNABLE_H__ + +#include <string> + +class ZLResource; +struct ZLResourceKey; + +class ZLRunnable { + +public: + virtual ~ZLRunnable(); + virtual void run() = 0; +}; + +class ZLRunnableWithKey : public ZLRunnable { + +public: + virtual ZLResourceKey key() const = 0; + virtual std::string text(const ZLResource &resource) const; + virtual bool makesSense() const; +}; + +inline ZLRunnable::~ZLRunnable() {} + +#endif /* __ZLRUNNABLE_H__ */ diff --git a/zlibrary/core/include/ZLSearchUtil.h b/zlibrary/core/include/ZLSearchUtil.h index 453b73c..797b7af 120000..100644 --- a/zlibrary/core/include/ZLSearchUtil.h +++ b/zlibrary/core/include/ZLSearchUtil.h @@ -1 +1,60 @@ -../src/util/ZLSearchUtil.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLSEARCHUTIL_H__ +#define __ZLSEARCHUTIL_H__ + +#include <string> + +class ZLSearchPattern { + +public: + ZLSearchPattern(const std::string &pattern, bool ignoreCase); + ~ZLSearchPattern(); + int length() const; + +private: + bool ignoreCase() const; + const std::string &lowerCasePattern() const; + const std::string &upperCasePattern() const; + +private: + bool myIgnoreCase; + std::string myLowerCasePattern; + std::string myUpperCasePattern; + +friend class ZLSearchUtil; +}; + +class ZLSearchUtil { + +private: + ZLSearchUtil(); + +public: + static int find(const char *text, std::size_t length, const ZLSearchPattern &pattern, int pos = 0); +}; + +inline ZLSearchPattern::~ZLSearchPattern() {} +inline int ZLSearchPattern::length() const { return myLowerCasePattern.length(); } +inline bool ZLSearchPattern::ignoreCase() const { return myIgnoreCase; } +inline const std::string &ZLSearchPattern::lowerCasePattern() const { return myLowerCasePattern; } +inline const std::string &ZLSearchPattern::upperCasePattern() const { return myUpperCasePattern; } + +#endif /* __ZLSEARCHUTIL_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLSimpleKeyOptionEntry.h b/zlibrary/core/include/ZLSimpleKeyOptionEntry.h index 439fb53..439fb53 100644 --- a/zlibrary/core/src/optionEntries/ZLSimpleKeyOptionEntry.h +++ b/zlibrary/core/include/ZLSimpleKeyOptionEntry.h diff --git a/zlibrary/core/src/optionEntries/ZLSimpleOptionEntry.h b/zlibrary/core/include/ZLSimpleOptionEntry.h index 12288c3..12288c3 100644 --- a/zlibrary/core/src/optionEntries/ZLSimpleOptionEntry.h +++ b/zlibrary/core/include/ZLSimpleOptionEntry.h diff --git a/zlibrary/core/include/ZLSliceInputStream.h b/zlibrary/core/include/ZLSliceInputStream.h index 6e20e5e..9333be8 120000..100644 --- a/zlibrary/core/include/ZLSliceInputStream.h +++ b/zlibrary/core/include/ZLSliceInputStream.h @@ -1 +1,43 @@ -../src/util/ZLSliceInputStream.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLSLICEINPUTSTREAM_H__ +#define __ZLSLICEINPUTSTREAM_H__ + +#include <ZLInputStream.h> + +class ZLSliceInputStream : public ZLInputStream { +public: + ZLSliceInputStream(shared_ptr<ZLInputStream> base, std::size_t start, std::size_t length); + + bool open(); + std::size_t read(char *buffer, std::size_t maxSize); + void close(); + + void seek(int offset, bool absoluteOffset); + std::size_t offset() const; + std::size_t sizeOfOpened(); + +private: + shared_ptr<ZLInputStream> myBaseStream; + std::size_t myStart; + std::size_t myLength; +}; + +#endif /* __ZLSLICEINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/language/ZLStatistics.h b/zlibrary/core/include/ZLStatistics.h index 98bd387..98bd387 100644 --- a/zlibrary/core/src/language/ZLStatistics.h +++ b/zlibrary/core/include/ZLStatistics.h diff --git a/zlibrary/core/src/language/ZLStatisticsGenerator.h b/zlibrary/core/include/ZLStatisticsGenerator.h index 2196725..2196725 100644 --- a/zlibrary/core/src/language/ZLStatisticsGenerator.h +++ b/zlibrary/core/include/ZLStatisticsGenerator.h diff --git a/zlibrary/core/src/language/ZLStatisticsItem.h b/zlibrary/core/include/ZLStatisticsItem.h index 10d465b..10d465b 100644 --- a/zlibrary/core/src/language/ZLStatisticsItem.h +++ b/zlibrary/core/include/ZLStatisticsItem.h diff --git a/zlibrary/core/src/language/ZLStatisticsXMLReader.h b/zlibrary/core/include/ZLStatisticsXMLReader.h index 8058f81..8058f81 100644 --- a/zlibrary/core/src/language/ZLStatisticsXMLReader.h +++ b/zlibrary/core/include/ZLStatisticsXMLReader.h diff --git a/zlibrary/core/src/language/ZLStatisticsXMLWriter.h b/zlibrary/core/include/ZLStatisticsXMLWriter.h index 64e6822..64e6822 100644 --- a/zlibrary/core/src/language/ZLStatisticsXMLWriter.h +++ b/zlibrary/core/include/ZLStatisticsXMLWriter.h diff --git a/zlibrary/core/include/ZLStreamImage.h b/zlibrary/core/include/ZLStreamImage.h index 9b2f7f6..95f03f8 120000..100644 --- a/zlibrary/core/include/ZLStreamImage.h +++ b/zlibrary/core/include/ZLStreamImage.h @@ -1 +1,44 @@ -../src/image/ZLStreamImage.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLSTREAMIMAGE_H__ +#define __ZLSTREAMIMAGE_H__ + +#include <string> + +#include <ZLImage.h> +#include <ZLInputStream.h> + +class ZLStreamImage : public ZLSingleImage { + +public: + ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size = 0); + const shared_ptr<std::string> stringData() const; + +private: + virtual shared_ptr<ZLInputStream> inputStream() const = 0; + +private: + std::size_t myOffset; + mutable std::size_t mySize; +}; + +inline ZLStreamImage::ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size) : ZLSingleImage(mimeType), myOffset(offset), mySize(size) {} + +#endif /* __ZLSTREAMIMAGE_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLStringEditOptionEntry.h b/zlibrary/core/include/ZLStringEditOptionEntry.h index c7e234a..c7e234a 100644 --- a/zlibrary/core/src/optionEntries/ZLStringEditOptionEntry.h +++ b/zlibrary/core/include/ZLStringEditOptionEntry.h diff --git a/zlibrary/core/src/optionEntries/ZLStringInfoEntry.h b/zlibrary/core/include/ZLStringInfoEntry.h index a419157..a419157 100644 --- a/zlibrary/core/src/optionEntries/ZLStringInfoEntry.h +++ b/zlibrary/core/include/ZLStringInfoEntry.h diff --git a/zlibrary/core/include/ZLStringUtil.h b/zlibrary/core/include/ZLStringUtil.h index 24f5e3e..71dda00 120000..100644 --- a/zlibrary/core/include/ZLStringUtil.h +++ b/zlibrary/core/include/ZLStringUtil.h @@ -1 +1,84 @@ -../src/util/ZLStringUtil.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLSTRINGUTIL_H__ +#define __ZLSTRINGUTIL_H__ + +#include <vector> +#include <string> + +class ZLStringUtil { + +private: + ZLStringUtil(); + +public: + static bool stringStartsWith(const std::string &str, const std::string &start); + static bool stringEndsWith(const std::string &str, const std::string &end); + + static bool isDigit(char c); + static bool isLatinLetter(char c); + + static void appendNumber(std::string &str, unsigned int n); + static void append(std::string &str, const std::vector<std::string> &buffer); + static void stripWhiteSpaces(std::string &str); + + static const std::string SPACE; + static std::vector<std::string> split(const std::string &str, const std::string &delimiter); + + static std::string printf(const std::string &format, const std::string &arg0); + static std::string printf(const std::string &format, unsigned int n); + + static std::string doubleToString(double value); + static double stringToDouble(const std::string &value, double defaultValue); + static int stringToInteger(const std::string &str, int defaultValue = 0); + + static std::string replaceAll(const std::string &str, const std::string& what, const std::string &to); + + template <typename T, typename F> + static std::string join(T iterable, F functor, std::string separator); + template <typename T> + static std::string join(T iterable, std::string separator); + + template <typename T> + struct self { + inline T operator()(const T &t) { + return t; + } + }; +}; + +template <typename T, typename F> +std::string ZLStringUtil::join(T iterable, F functor, std::string separator) { + std::string result; + for (typename T::const_iterator it=iterable.begin(); it != iterable.end(); ++it) { + if (it != iterable.begin()) { + result += separator; + } + result += functor(*it); + } + return result; +} + +template <typename T> +std::string ZLStringUtil::join(T iterable, std::string separator) { + return join(iterable, ZLStringUtil::self<typename T::value_type>(), separator); +} + +#endif /* __ZLSTRINGUTIL_H__ */ diff --git a/zlibrary/core/src/filesystem/tar/ZLTar.h b/zlibrary/core/include/ZLTar.h index e0d5aa6..b916a83 100644 --- a/zlibrary/core/src/filesystem/tar/ZLTar.h +++ b/zlibrary/core/include/ZLTar.h @@ -22,8 +22,8 @@ #include <shared_ptr.h> -#include "../ZLInputStream.h" -#include "../ZLDir.h" +#include "ZLInputStream.h" +#include "ZLDir.h" class ZLFSArchiverTar; diff --git a/zlibrary/core/include/ZLTime.h b/zlibrary/core/include/ZLTime.h index cd6a73a..c06478f 120000..100644 --- a/zlibrary/core/include/ZLTime.h +++ b/zlibrary/core/include/ZLTime.h @@ -1 +1,46 @@ -../src/time/ZLTime.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTIME_H__ +#define __ZLTIME_H__ + +class ZLTime { + +public: + ZLTime(); + ZLTime(long seconds, long milliseconds); + ~ZLTime(); + long millisecondsTo(const ZLTime &time) const; + long millisecondsFrom(const ZLTime &time) const; + + long inSeconds() const; + + short hours() const; + short minutes() const; + + short dayOfMonth() const; // from 1 to 31 + short month() const; // from 1 to 12 + short year() const; + +private: + long mySeconds; + long myMilliseconds; +}; + +#endif /* __ZLTIME_H__ */ diff --git a/zlibrary/core/include/ZLTimeManager.h b/zlibrary/core/include/ZLTimeManager.h index 801436b..639e420 120000..100644 --- a/zlibrary/core/include/ZLTimeManager.h +++ b/zlibrary/core/include/ZLTimeManager.h @@ -1 +1,94 @@ -../src/time/ZLTimeManager.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTIMEMANAGER_H__ +#define __ZLTIMEMANAGER_H__ + +#include <map> + +#include <shared_ptr.h> +#include <ZLRunnable.h> + +class ZLTime; + +class ZLTimeManager { + +private: + class AutoRemovableTask; + +protected: + static ZLTimeManager *ourInstance; + +public: + static ZLTimeManager &Instance(); + static void deleteInstance(); + +protected: + ZLTimeManager(); + virtual ~ZLTimeManager(); + +public: + virtual void addTask(shared_ptr<ZLRunnable> task, int interval) = 0; + void addAutoRemovableTask(shared_ptr<ZLRunnable> task, int delay = 0); + void removeTask(shared_ptr<ZLRunnable> task); + +protected: + virtual void removeTaskInternal(shared_ptr<ZLRunnable> task) = 0; + + virtual ZLTime currentTime() const = 0; + virtual short hoursBySeconds(long seconds) const = 0; + virtual short minutesBySeconds(long seconds) const = 0; + + virtual short yearBySeconds(long seconds) const = 0; + virtual short monthBySeconds(long seconds) const = 0; + virtual short dayOfMonthBySeconds(long seconds) const = 0; + +protected: + typedef void (*DeleteFunc)(void*); + template <typename T> struct DeleteHelper { + static void func(T *object) { delete object; } + }; + + class DeleteTask : public ZLRunnable { + + public: + DeleteTask(void *object, DeleteFunc func) : myObject(object), myFunc(func) {} + private: + void run() { myFunc(myObject); } + + void *myObject; + DeleteFunc myFunc; + }; + +public: + template <typename T> static void deleteLater(shared_ptr<T> object, int delay = 0) { + deleteLater(new shared_ptr<T>(object), delay); + } + template <typename T> static void deleteLater(T *object, int delay = 0) { + DeleteFunc func = reinterpret_cast<DeleteFunc>(&DeleteHelper<T>::func); + ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay); + } + +private: + std::map<shared_ptr<ZLRunnable>,shared_ptr<ZLRunnable> > myAutoRemovableTasks; + +friend class ZLTime; +}; + +#endif /* __ZLTIMEMANAGER_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLToggleBooleanOptionEntry.h b/zlibrary/core/include/ZLToggleBooleanOptionEntry.h index 864ad0b..8859267 100644 --- a/zlibrary/core/src/optionEntries/ZLToggleBooleanOptionEntry.h +++ b/zlibrary/core/include/ZLToggleBooleanOptionEntry.h @@ -20,7 +20,7 @@ #ifndef __ZLTOGGLEBOOLEANOPTIONENTRY_H__ #define __ZLTOGGLEBOOLEANOPTIONENTRY_H__ -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> class ZLToggleBooleanOptionEntry : public ZLSimpleBooleanOptionEntry { diff --git a/zlibrary/core/src/application/ZLToolbar.h b/zlibrary/core/include/ZLToolbar.h index f7e9f72..f7e9f72 100644 --- a/zlibrary/core/src/application/ZLToolbar.h +++ b/zlibrary/core/include/ZLToolbar.h diff --git a/zlibrary/core/include/ZLTreeActionNode.h b/zlibrary/core/include/ZLTreeActionNode.h index cf85954..6212aed 120000..100644 --- a/zlibrary/core/include/ZLTreeActionNode.h +++ b/zlibrary/core/include/ZLTreeActionNode.h @@ -1 +1,36 @@ -../src/tree/ZLTreeActionNode.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef ZLTREEACTIONNODE_H +#define ZLTREEACTIONNODE_H + +#include "ZLTreeTitledNode.h" + +class ZLTreeActionNode : public ZLTreeTitledNode { + +public: + static const ZLTypeId TYPE_ID; + const ZLTypeId &typeId() const; + +public: + // Return true if it is final action (dialog should be closed) + virtual bool activate() = 0; +}; + +#endif // ZLTREEACTIONNODE_H diff --git a/zlibrary/core/include/ZLTreeDialog.h b/zlibrary/core/include/ZLTreeDialog.h index 90e109a..2bf5289 120000..100644 --- a/zlibrary/core/include/ZLTreeDialog.h +++ b/zlibrary/core/include/ZLTreeDialog.h @@ -1 +1,54 @@ -../src/dialogs/ZLTreeDialog.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTREEDIALOG_H__ +#define __ZLTREEDIALOG_H__ + +#include <ZLTreeListener.h> +#include <ZLResource.h> +#include <ZLTreeSearcher.h> + +class ZLTreeDialog : public ZLTreeListener { + +protected: + ZLTreeDialog(const ZLResource &resource); + +public: + //TODO maybe run() should return an integer? + virtual void run(ZLTreeNode *rootNode) = 0; + +public: + void setSearcher(shared_ptr<ZLTreeSearcher> searcher); + + void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index); + void onNodeEndInsert(); + void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index); + void onNodeEndRemove(); + +protected: + const ZLResource &resource() const; + +protected: + shared_ptr<ZLTreeSearcher> mySearcher; + +private: + const ZLResource &myResource; +}; + +#endif /* __ZLTREEDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLTreeListener.h b/zlibrary/core/include/ZLTreeListener.h index 068e098..e602015 120000..100644 --- a/zlibrary/core/include/ZLTreeListener.h +++ b/zlibrary/core/include/ZLTreeListener.h @@ -1 +1,49 @@ -../src/tree/ZLTreeListener.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTREELISTENER_H__ +#define __ZLTREELISTENER_H__ + +#include "ZLTreeNode.h" + +//ZLTreeListener is used to get ability to node to notificate Tree Dialog about any changes + +class ZLTreeListener { + +public: + virtual void onExpandRequest(ZLTreeNode *node) = 0; + virtual void onCloseRequest() = 0; + // Parent has new or remove child at index + virtual void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index) = 0; + virtual void onNodeEndInsert() = 0; + virtual void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index) = 0; + virtual void onNodeEndRemove() = 0; + // This method should be called at every node state change except of adding/removing of children + virtual void onNodeUpdated(ZLTreeNode *node) = 0; + + virtual void onDownloadingStarted(ZLTreeNode *node) = 0; + virtual void onDownloadingStopped(ZLTreeNode *node) = 0; + + virtual void onSearchStarted(ZLTreeNode *node) = 0; + virtual void onSearchStopped(ZLTreeNode *node) = 0; + + virtual void onRefresh() = 0; +}; + +#endif /* __ZLTREELISTENER_H__ */ diff --git a/zlibrary/core/include/ZLTreeNode.h b/zlibrary/core/include/ZLTreeNode.h index 4dc2788..79c8b87 120000..100644 --- a/zlibrary/core/include/ZLTreeNode.h +++ b/zlibrary/core/include/ZLTreeNode.h @@ -1 +1,125 @@ -../src/tree/ZLTreeNode.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTREENODE_H__ +#define __ZLTREENODE_H__ + +#include <map> +#include <vector> + +#include <shared_ptr.h> + +#include <ZLTypeId.h> +#include <ZLRunnable.h> +#include <ZLPaintContext.h> +#include <ZLNetworkRequest.h> + +// Nowadays I see hierarchy in this way: +// +// ZLTreeNode +// | +// +-ZLTreeTitledNode -- simple node, as shown below +// | | +// | +- ZLTreeActionNode -- node with some action on click, i.e. BookNode at local library +// | +// +-ZLTreePageNode -- usually the leaf of the tree, smth like page with ZLDialogContent +// and some actions, i.e. BookInfo page at network library + +class ZLTreeListener; + +//class ZLTreeAction : public ZLNetworkRequest { //using ZLRunnableWithKey instead +//public: +// static const ZLTypeId TYPE_ID; + +// ZLTreeAction(); +// ~ZLTreeAction(); + +// const ZLTypeId &typeId() const; + +// virtual void run() = 0; +// virtual ZLResourceKey key() const = 0; +// virtual std::string text(const ZLResource &resource) const; +// virtual bool makesSense() const; +//}; + +typedef ZLRunnableWithKey ZLTreeAction; + +class ZLTreeNode : public ZLObjectWithRTTI { + +public: + typedef std::vector<ZLTreeNode*> List; + +public: + static const ZLTypeId TYPE_ID; + const ZLTypeId &typeId() const; + +protected: + ZLTreeNode(ZLTreeNode *parent = 0, std::size_t position = -1); + +public: + virtual ~ZLTreeNode(); + void clear(); + +public: + ZLTreeNode *parent() const; + ZLTreeNode *previous() const; + ZLTreeNode *next() const; + const List &children() const; + std::size_t childIndex() const; + // Children should be requested from network only if we need them + virtual void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0); + virtual void requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0); + + virtual const ZLResource &resource() const; + void registerAction(shared_ptr<ZLTreeAction> action); + const std::vector<shared_ptr<ZLTreeAction> > &actions() const; + std::string actionText(const shared_ptr<ZLTreeAction> &action) const; + + void close() const; + void insert(ZLTreeNode *node, std::size_t index); + void append(ZLTreeNode *node); + void remove(ZLTreeNode *node); + void remove(std::size_t index); + void updated(); + + void notifyDownloadStarted(); + void notifyDownloadStopped(); + + void notifySearchStarted(); + void notifySearchStopped(); + +protected: + std::size_t level() const; + + virtual ZLTreeListener *listener() const; + +private: + ZLTreeNode *myParent; + std::size_t myChildIndex; + + List myChildren; + // Looks like we should also handle actions for menu on "Tap and hold" + std::vector<shared_ptr<ZLTreeAction> > myActions; + +private: + ZLTreeNode(const ZLTreeNode&); + const ZLTreeNode &operator = (const ZLTreeNode&); +}; + +#endif /* __ZLTREENODE_H__ */ diff --git a/zlibrary/core/include/ZLTreePageNode.h b/zlibrary/core/include/ZLTreePageNode.h index fd6531c..8226ea1 120000..100644 --- a/zlibrary/core/include/ZLTreePageNode.h +++ b/zlibrary/core/include/ZLTreePageNode.h @@ -1 +1,53 @@ -../src/tree/ZLTreePageNode.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef ZLTREEPAGENODE_H +#define ZLTREEPAGENODE_H + +#include "ZLTreeTitledNode.h" +#include <ZLDialogContent.h> + +class ZLTreePageInfo { +public: + + virtual bool isPageInfoLoaded() = 0; + virtual void loadAll(shared_ptr<ZLNetworkRequest::Listener> listener) = 0; + + virtual std::string title() const = 0; + virtual std::vector<std::string> authors() const = 0; + virtual std::vector<std::string> tags() const = 0; + virtual std::string summary() const = 0; + virtual shared_ptr<const ZLImage> image() const = 0; + + virtual const std::vector<shared_ptr<ZLTreeAction> > &actions() const = 0; + virtual std::string actionText(const shared_ptr<ZLTreeAction> &action) const = 0; + virtual const std::vector<shared_ptr<ZLTreeAction> > relatedActions() const = 0; +}; + +class ZLTreePageNode : public ZLTreeTitledNode { + +public: + ZLTreePageNode(ZLTreeNode *parent = 0, std::size_t position = -1); + static const ZLTypeId TYPE_ID; + const ZLTypeId &typeId() const; + + virtual shared_ptr<ZLTreePageInfo> getPageInfo() = 0; +}; + +#endif // ZLTREEPAGENODE_H diff --git a/zlibrary/core/include/ZLTreeSearcher.h b/zlibrary/core/include/ZLTreeSearcher.h index 09d069d..747d9c5 120000..100644 --- a/zlibrary/core/include/ZLTreeSearcher.h +++ b/zlibrary/core/include/ZLTreeSearcher.h @@ -1 +1,30 @@ -../src/tree/ZLTreeSearcher.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTREESEARCHER_H__ +#define __ZLTREESEARCHER_H__ + +#include <string> + +class ZLTreeSearcher { +public: + virtual void simpleSearch(const std::string &pattern) = 0; +}; + +#endif /* __ZLTREESEARCHER_H__ */ diff --git a/zlibrary/core/include/ZLTreeTitledNode.h b/zlibrary/core/include/ZLTreeTitledNode.h index 9636416..a68a746 120000..100644 --- a/zlibrary/core/include/ZLTreeTitledNode.h +++ b/zlibrary/core/include/ZLTreeTitledNode.h @@ -1 +1,49 @@ -../src/tree/ZLTreeTitledNode.h
\ No newline at end of file +/* + * Copyright (C) 2009-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTREETITLEDNODE_H__ +#define __ZLTREETITLEDNODE_H__ + +#include "ZLTreeNode.h" +#include <ZLImage.h> + +class ZLTreeTitledNode : public ZLTreeNode { + +public: + static const ZLTypeId TYPE_ID; + const ZLTypeId &typeId() const; + + static const std::string ZLIMAGE_SCHEME; + static const std::string LOCALFILE_SCHEME; + static const std::string SCHEME_POSTFIX; + +public: + ZLTreeTitledNode(ZLTreeNode *parent = 0, std::size_t position = -1); + virtual ~ZLTreeTitledNode(); + + virtual std::string title() const = 0; + virtual std::string subtitle() const; + + // Url to image + //virtual std::string imageUrl() const; + // Or the image if there is no url + virtual shared_ptr<const ZLImage> image() const; +}; + +#endif /* __ZLTREETITLEDNODE_H__ */ diff --git a/zlibrary/core/include/ZLTypeId.h b/zlibrary/core/include/ZLTypeId.h index deebb9d..ed5679a 120000..100644 --- a/zlibrary/core/include/ZLTypeId.h +++ b/zlibrary/core/include/ZLTypeId.h @@ -1 +1,79 @@ -../src/typeId/ZLTypeId.h
\ No newline at end of file +/* + * Copyright (C) 2010-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLTYPEID_H__ +#define __ZLTYPEID_H__ + +class ZLTypeId { + +private: + ZLTypeId(); + +public: + explicit ZLTypeId(const ZLTypeId &base); + + bool operator == (const ZLTypeId &type) const; + bool operator != (const ZLTypeId &type) const; + bool isSubtypeOf(const ZLTypeId &type) const; + +private: + const ZLTypeId *myBase; + +friend class ZLObjectWithRTTI; +}; + +class ZLObjectWithRTTI { + +public: + static const ZLTypeId TYPE_ID; + +public: + virtual ~ZLObjectWithRTTI(); + bool isInstanceOf(const ZLTypeId &type, bool exact = false) const; + +protected: + virtual const ZLTypeId &typeId() const = 0; +}; + +template <typename T> +T zlobject_cast(ZLObjectWithRTTI *object) { + if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID)) + return 0; + return static_cast<T>(object); +} + +template <typename T> +T zlobject_cast(const ZLObjectWithRTTI *object) { + if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID)) + return 0; + return static_cast<T>(object); +} + +inline bool ZLTypeId::operator == (const ZLTypeId &type) const { + return this == &type; +} + +inline bool ZLTypeId::operator != (const ZLTypeId &type) const { + return this != &type; +} + +inline ZLObjectWithRTTI::~ZLObjectWithRTTI() { +} + +#endif /* __ZLTYPEID_H__ */ diff --git a/zlibrary/core/include/ZLUnicodeUtil.h b/zlibrary/core/include/ZLUnicodeUtil.h index b39784a..963e671 120000..100644 --- a/zlibrary/core/include/ZLUnicodeUtil.h +++ b/zlibrary/core/include/ZLUnicodeUtil.h @@ -1 +1,83 @@ -../src/util/ZLUnicodeUtil.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLUNICODEUTIL_H__ +#define __ZLUNICODEUTIL_H__ + +#include <stdint.h> +#include <string> +#include <vector> + +class ZLUnicodeUtil { + +private: + ZLUnicodeUtil(); + +public: + typedef uint16_t Ucs2Char; + typedef std::vector<Ucs2Char> Ucs2String; + typedef uint32_t Ucs4Char; + typedef std::vector<Ucs4Char> Ucs4String; + + enum Breakable { + NO_BREAKABLE, + BREAKABLE_BEFORE, + BREAKABLE_AFTER + }; + + static bool isUtf8String(const char *str, int len); + static bool isUtf8String(const std::string &str); + static void cleanUtf8String(std::string &str); + static int utf8Length(const char *str, int len); + static int utf8Length(const std::string &str); + static int length(const char *str, int utf8Length); + static int length(const std::string &str, int utf8Length); + static void utf8ToUcs4(Ucs4String &to, const char *from, int length, int toLength = -1); + static void utf8ToUcs4(Ucs4String &to, const std::string &from, int toLength = -1); + static void utf8ToUcs2(Ucs2String &to, const char *from, int length, int toLength = -1); + static void utf8ToUcs2(Ucs2String &to, const std::string &from, int toLength = -1); + static std::size_t firstChar(Ucs4Char &ch, const char *utf8String); + static std::size_t firstChar(Ucs4Char &ch, const std::string &utf8String); + static std::size_t lastChar(Ucs4Char &ch, const char *utf8String); + static std::size_t lastChar(Ucs4Char &ch, const std::string &utf8String); + static void ucs4ToUtf8(std::string &to, const Ucs4String &from, int toLength = -1); + static int ucs4ToUtf8(char *to, Ucs4Char ch); + static void ucs2ToUtf8(std::string &to, const Ucs2String &from, int toLength = -1); + static int ucs2ToUtf8(char *to, Ucs2Char ch); + static bool isLetter(Ucs4Char ch); + static bool isSpace(Ucs4Char ch); + static bool isNBSpace(Ucs4Char ch); + static Breakable isBreakable(Ucs4Char ch); + + static Ucs4Char toLower(Ucs4Char ch); + static void toLower(Ucs4String &str); + static std::string toLower(const std::string &utf8String); + + static Ucs4Char toUpper(Ucs4Char ch); + static void toUpper(Ucs4String &str); + static std::string toUpper(const std::string &utf8String); + + static void utf8Trim(std::string &utf8String); +}; + +inline bool ZLUnicodeUtil::isNBSpace(Ucs4Char ch) { + return ch == 160; +} + +#endif /* __ZLUNICODEUTIL_H__ */ diff --git a/zlibrary/core/src/unix/filesystem/ZLUnixFSDir.h b/zlibrary/core/include/ZLUnixFSDir.h index 7efbc4c..50bd44c 100644 --- a/zlibrary/core/src/unix/filesystem/ZLUnixFSDir.h +++ b/zlibrary/core/include/ZLUnixFSDir.h @@ -20,7 +20,7 @@ #ifndef __ZLUNIXFSDIR_H__ #define __ZLUNIXFSDIR_H__ -#include "../../filesystem/ZLFSDir.h" +#include "ZLFSDir.h" class ZLUnixFSDir : public ZLFSDir { diff --git a/zlibrary/core/src/unix/filesystem/ZLUnixFSManager.h b/zlibrary/core/include/ZLUnixFSManager.h index f2dd96f..fb80c16 100644 --- a/zlibrary/core/src/unix/filesystem/ZLUnixFSManager.h +++ b/zlibrary/core/include/ZLUnixFSManager.h @@ -20,7 +20,7 @@ #ifndef __ZLUNIXFSMANAGER_H__ #define __ZLUNIXFSMANAGER_H__ -#include "../../filesystem/ZLFSManager.h" +#include "ZLFSManager.h" class ZLUnixFSManager : public ZLFSManager { diff --git a/zlibrary/core/src/unix/filesystem/ZLUnixFileInputStream.h b/zlibrary/core/include/ZLUnixFileInputStream.h index 470489e..470489e 100644 --- a/zlibrary/core/src/unix/filesystem/ZLUnixFileInputStream.h +++ b/zlibrary/core/include/ZLUnixFileInputStream.h diff --git a/zlibrary/core/src/unix/filesystem/ZLUnixFileOutputStream.h b/zlibrary/core/include/ZLUnixFileOutputStream.h index 7f61a0c..7f61a0c 100644 --- a/zlibrary/core/src/unix/filesystem/ZLUnixFileOutputStream.h +++ b/zlibrary/core/include/ZLUnixFileOutputStream.h diff --git a/zlibrary/core/src/unix/message/ZLUnixMessage.h b/zlibrary/core/include/ZLUnixMessage.h index 69b33c9..69b33c9 100644 --- a/zlibrary/core/src/unix/message/ZLUnixMessage.h +++ b/zlibrary/core/include/ZLUnixMessage.h diff --git a/zlibrary/core/src/unix/time/ZLUnixTime.h b/zlibrary/core/include/ZLUnixTime.h index 5877f3d..5877f3d 100644 --- a/zlibrary/core/src/unix/time/ZLUnixTime.h +++ b/zlibrary/core/include/ZLUnixTime.h diff --git a/zlibrary/core/include/ZLUserData.h b/zlibrary/core/include/ZLUserData.h index 8a88707..db98346 120000..100644 --- a/zlibrary/core/include/ZLUserData.h +++ b/zlibrary/core/include/ZLUserData.h @@ -1 +1,50 @@ -../src/util/ZLUserData.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLUSERDATA_H__ +#define __ZLUSERDATA_H__ + +#include <map> +#include <string> + +#include <shared_ptr.h> + +class ZLUserData { + +public: + virtual ~ZLUserData(); +}; + +class ZLUserDataHolder { + +public: + ZLUserDataHolder(); + ZLUserDataHolder(const ZLUserDataHolder &other); + virtual ~ZLUserDataHolder(); + + void addUserData(const std::string &key, shared_ptr<ZLUserData> data); + void removeUserData(const std::string &key); + shared_ptr<ZLUserData> getUserData(const std::string &key) const; + +private: + ZLUserDataHolder &operator =(const ZLUserDataHolder &other); + std::map<std::string,shared_ptr<ZLUserData> > myDataMap; +}; + +#endif /* __ZLUSERDATA_H__ */ diff --git a/zlibrary/core/include/ZLView.h b/zlibrary/core/include/ZLView.h index 48f75fc..bc8e42b 120000..100644 --- a/zlibrary/core/include/ZLView.h +++ b/zlibrary/core/include/ZLView.h @@ -1 +1,110 @@ -../src/view/ZLView.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLVIEW_H__ +#define __ZLVIEW_H__ + +#include <string> + +#include <shared_ptr.h> + +#include <ZLColor.h> +#include <ZLTypeId.h> + +class ZLViewWidget; +class ZLPaintContext; + +class ZLView : public ZLObjectWithRTTI { + +public: + enum Angle { + DEGREES0 = 0, + DEGREES90 = 90, + DEGREES180 = 180, + DEGREES270 = 270 + }; + + enum Direction { + VERTICAL, + HORIZONTAL + }; + +protected: + static const ZLTypeId TYPE_ID; + +public: + ZLView(ZLPaintContext &context); + virtual ~ZLView(); + + virtual const std::string &caption() const = 0; + virtual void paint() = 0; + ZLPaintContext &context() const; + + /* + * returns true iff stylus/finger event was processed + */ + virtual bool onStylusPress(int x, int y); + virtual bool onStylusRelease(int x, int y); + virtual bool onStylusMove(int x, int y); + virtual bool onStylusMovePressed(int x, int y); + virtual bool onFingerTap(int x, int y); + +protected: + const ZLTypeId &typeId() const; + + virtual ZLColor backgroundColor() const = 0; + + void setScrollbarEnabled(Direction direction, bool enabled); + void setScrollbarParameters(Direction direction, std::size_t full, std::size_t from, std::size_t to); + virtual void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to); + virtual void onScrollbarStep(Direction direction, int steps); + virtual void onScrollbarPageStep(Direction direction, int steps); + +private: + struct ScrollBarInfo { + ScrollBarInfo(); + + bool Enabled; + bool StandardLocation; + std::size_t Full; + std::size_t From; + std::size_t To; + }; + + void updateScrollbarState(); + void updateScrollbarPlacement(); + void updateScrollbarParameters(); + void updateScrollbarParameters(Direction direction, const ScrollBarInfo &info, bool invert); + +private: + ZLViewWidget *myViewWidget; + ZLPaintContext &myContext; + ScrollBarInfo myVerticalScrollbarInfo; + ScrollBarInfo myHorizontalScrollbarInfo; + +private: + ZLView(const ZLView&); + const ZLView &operator=(const ZLView&); + +friend class ZLViewWidget; +}; + +inline ZLPaintContext &ZLView::context() const { return myContext; } + +#endif /* __ZLVIEW_H__ */ diff --git a/zlibrary/core/src/view/ZLViewWidget.h b/zlibrary/core/include/ZLViewWidget.h index cd1057f..cd1057f 100644 --- a/zlibrary/core/src/view/ZLViewWidget.h +++ b/zlibrary/core/include/ZLViewWidget.h diff --git a/zlibrary/core/include/ZLXMLNamespace.h b/zlibrary/core/include/ZLXMLNamespace.h index 0ce94d2..784e438 120000..100644 --- a/zlibrary/core/include/ZLXMLNamespace.h +++ b/zlibrary/core/include/ZLXMLNamespace.h @@ -1 +1,44 @@ -../src/constants/ZLXMLNamespace.h
\ No newline at end of file +/* + * Copyright (C) 2008-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLXMLNAMESPACE_H__ +#define __ZLXMLNAMESPACE_H__ + +#include <string> + +class ZLXMLNamespace { + +private: + ZLXMLNamespace(); + +public: + static const std::string DublinCore; + static const std::string DublinCoreLegacy; + static const std::string DublinCoreTerms; + static const std::string XLink; + static const std::string OpenPackagingFormat; + static const std::string Atom; + static const std::string OpenSearch; + static const std::string CalibreMetadata; + static const std::string Opds; + static const std::string DaisyNCX; + static const std::string FBReaderCatalogMetadata; +}; + +#endif /* __ZLXMLNAMESPACE_H__ */ diff --git a/zlibrary/core/include/ZLXMLReader.h b/zlibrary/core/include/ZLXMLReader.h index d35bb0e..c3c4c41 120000..100644 --- a/zlibrary/core/include/ZLXMLReader.h +++ b/zlibrary/core/include/ZLXMLReader.h @@ -1 +1,125 @@ -../src/xml/ZLXMLReader.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLXMLREADER_H__ +#define __ZLXMLREADER_H__ + +#include <string> +#include <vector> +#include <map> + +#include <shared_ptr.h> + +class ZLFile; +class ZLInputStream; +class ZLAsynchronousInputStream; +class ZLXMLReaderInternal; + +class ZLXMLReader { + +public: + class AttributeNamePredicate { + + public: + virtual ~AttributeNamePredicate(); + virtual bool accepts(const ZLXMLReader &reader, const char *name) const = 0; + }; + + class FixedAttributeNamePredicate : public AttributeNamePredicate { + + public: + FixedAttributeNamePredicate(const std::string &attributeName); + bool accepts(const ZLXMLReader &reader, const char *name) const; + + private: + const std::string myAttributeName; + }; + + class NamespaceAttributeNamePredicate : public AttributeNamePredicate { + + public: + NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name); + bool accepts(const ZLXMLReader &reader, const char *name) const; + + private: + const std::string myNamespaceName; + const std::string myAttributeName; + }; + +protected: + ZLXMLReader(const char *encoding = 0); + +public: + virtual ~ZLXMLReader(); + + bool readDocument(const ZLFile &file); + bool readDocument(shared_ptr<ZLInputStream> stream); + bool readDocument(shared_ptr<ZLAsynchronousInputStream> stream); + + const std::string &errorMessage() const; + + typedef std::map<std::string,std::string> nsMap; + const nsMap &namespaces() const; + + const char *attributeValue(const char **xmlattributes, const char *name); + const char *attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate); + static std::map<std::string,std::string> getAttributesMap(const char **xmlattributes); + +private: + void initialize(const char *encoding = 0); + void shutdown(); + bool readFromBuffer(const char *data, std::size_t len); + +protected: + virtual void startElementHandler(const char *tag, const char **attributes); + virtual void endElementHandler(const char *tag); + virtual void characterDataHandler(const char *text, std::size_t len); + virtual bool processNamespaces() const; + virtual const std::vector<std::string> &externalDTDs() const; + virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap); + + bool testTag(const std::string &ns, const std::string &name, const std::string &tag) const; + bool isInterrupted() const; + std::size_t getCurrentPosition() const; + +protected: + void interrupt(); + void setErrorMessage(const std::string &message); + +private: + bool myInterrupted; + ZLXMLReaderInternal *myInternalReader; + char *myParserBuffer; + std::vector<shared_ptr<nsMap> > myNamespaces; + + std::string myErrorMessage; + +friend class ZLXMLReaderInternal; +friend class ZLXMLReaderHandler; +}; + +inline bool ZLXMLReader::isInterrupted() const { + return myInterrupted; +} + +inline void ZLXMLReader::interrupt() { + myInterrupted = true; +} + +#endif /* __ZLXMLREADER_H__ */ diff --git a/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.h b/zlibrary/core/include/ZLXMLReaderInternal.h index 1fc73af..1fc73af 100644 --- a/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.h +++ b/zlibrary/core/include/ZLXMLReaderInternal.h diff --git a/zlibrary/core/include/ZLXMLWriter.h b/zlibrary/core/include/ZLXMLWriter.h index 071ffab..5966f1c 120000..100644 --- a/zlibrary/core/include/ZLXMLWriter.h +++ b/zlibrary/core/include/ZLXMLWriter.h @@ -1 +1,88 @@ -../src/xml/ZLXMLWriter.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLXMLWRITER_H__ +#define __ZLXMLWRITER_H__ + +#include <stack> +#include <vector> +#include <string> + +#include <ZLOutputStream.h> + +class ZLXMLWriter { + +private: + struct Attribute { + std::string Name; + std::string Value; + + Attribute(const std::string &name, const std::string &value); + ~Attribute(); + }; + + class Tag { + + public: + Tag(const std::string &name, bool single); + ~Tag(); + void addAttribute(const std::string &name, const std::string &value); + void addData(const std::string &data); + bool isSingle() const; + bool isDataEmpty() const; + + void writeStart(ZLOutputStream &stream) const; + void writeEnd(ZLOutputStream &stream) const; + + private: + std::string myName; + std::string myData; + bool mySingle; + std::vector<Attribute> myAttributes; + }; + +protected: + ZLXMLWriter(ZLOutputStream &stream); + virtual ~ZLXMLWriter(); + + void addTag(const std::string &name, bool single); + void addAttribute(const std::string &name, const std::string &value); + void addData(const std::string &data); + void closeTag(); + void closeAllTags(); + +private: + void flushTagStart(); + +private: + ZLOutputStream &myStream; + Tag *myCurrentTag; + std::stack<Tag*> myTags; +}; + +inline ZLXMLWriter::Attribute::Attribute(const std::string &name, const std::string &value) : Name(name), Value(value) {} +inline ZLXMLWriter::Attribute::~Attribute() {} + +inline bool ZLXMLWriter::Tag::isSingle() const { return mySingle; } +inline bool ZLXMLWriter::Tag::isDataEmpty() const { return myData.empty(); } +inline ZLXMLWriter::Tag::~Tag() {} + +inline ZLXMLWriter::~ZLXMLWriter() {} + +#endif /* __ZLXMLWRITER_H__ */ diff --git a/zlibrary/core/include/ZLZDecompressor.h b/zlibrary/core/include/ZLZDecompressor.h index 295ff9b..3264bc3 120000..100644 --- a/zlibrary/core/include/ZLZDecompressor.h +++ b/zlibrary/core/include/ZLZDecompressor.h @@ -1 +1,45 @@ -../src/filesystem/zip/ZLZDecompressor.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLZDECOMPRESSOR_H__ +#define __ZLZDECOMPRESSOR_H__ + +#include <zlib.h> + +#include <string> + +class ZLInputStream; + +class ZLZDecompressor { + +public: + ZLZDecompressor(std::size_t size); + ~ZLZDecompressor(); + + std::size_t decompress(ZLInputStream &stream, char *buffer, std::size_t maxSize); + +private: + z_stream *myZStream; + std::size_t myAvailableSize; + char *myInBuffer; + char *myOutBuffer; + std::string myBuffer; +}; + +#endif /* __ZLZDECOMPRESSOR_H__ */ diff --git a/zlibrary/core/src/filesystem/zip/ZLZip.h b/zlibrary/core/include/ZLZip.h index d925211..8789abb 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZip.h +++ b/zlibrary/core/include/ZLZip.h @@ -24,8 +24,8 @@ #include <shared_ptr.h> -#include "../ZLInputStream.h" -#include "../ZLDir.h" +#include "ZLInputStream.h" +#include "ZLDir.h" class ZLZDecompressor; class ZLFile; diff --git a/zlibrary/core/src/filesystem/zip/ZLZipHeader.h b/zlibrary/core/include/ZLZipHeader.h index c1ca54e..c1ca54e 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZipHeader.h +++ b/zlibrary/core/include/ZLZipHeader.h diff --git a/zlibrary/core/include/ZLibrary.h b/zlibrary/core/include/ZLibrary.h index 0e49f58..9f4a62d 120000..100644 --- a/zlibrary/core/include/ZLibrary.h +++ b/zlibrary/core/include/ZLibrary.h @@ -1 +1,89 @@ -../src/library/ZLibrary.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ZLIBRARY_H__ +#define __ZLIBRARY_H__ + +#include <string> + +class ZLApplication; +class ZLPaintContext; + +class ZLibrary { + +public: + static const std::string FileNameDelimiter; + static const std::string PathDelimiter; + static const std::string EndOfLine; + static std::string Language(); + static std::string Country(); + + static const std::string BaseDirectory; + static const std::string &ZLibraryDirectory(); + + static const std::string &ImageDirectory(); + static const std::string &ApplicationName(); + static const std::string &ApplicationImageDirectory(); + static const std::string &ApplicationDirectory(); + static const std::string &DefaultFilesPathPrefix(); + + static const std::string &ApplicationWritableDirectory(); + +public: + static bool init(int &argc, char **&argv); + static void parseArguments(int &argc, char **&argv); + static ZLPaintContext *createContext(); + static void run(ZLApplication *application); + static void shutdown(); + +private: + static void initLocale(); + +private: + static bool ourLocaleIsInitialized; + static std::string ourLanguage; + static std::string ourCountry; + static std::string ourZLibraryDirectory; + + static std::string ourImageDirectory; + static std::string ourApplicationImageDirectory; + static std::string ourApplicationName; + static std::string ourApplicationDirectory; + static std::string ourApplicationWritableDirectory; + static std::string ourDefaultFilesPathPrefix; + +private: + static std::string replaceRegExps(const std::string &pattern); + static void initApplication(const std::string &name); + +private: + ZLibrary(); + +friend class ZLApplicationBase; +}; + +inline const std::string &ZLibrary::ZLibraryDirectory() { return ourZLibraryDirectory; } +inline const std::string &ZLibrary::ApplicationName() { return ourApplicationName; } +inline const std::string &ZLibrary::ImageDirectory() { return ourImageDirectory; } +inline const std::string &ZLibrary::ApplicationImageDirectory() { return ourApplicationImageDirectory; } +inline const std::string &ZLibrary::ApplicationDirectory() { return ourApplicationDirectory; } +inline const std::string &ZLibrary::ApplicationWritableDirectory() { return ourApplicationWritableDirectory; } +inline const std::string &ZLibrary::DefaultFilesPathPrefix() { return ourDefaultFilesPathPrefix; } + +#endif /* __ZLIBRARY_H__ */ diff --git a/zlibrary/core/src/unix/library/ZLibraryImplementation.h b/zlibrary/core/include/ZLibraryImplementation.h index 24c7b10..24c7b10 100644 --- a/zlibrary/core/src/unix/library/ZLibraryImplementation.h +++ b/zlibrary/core/include/ZLibraryImplementation.h diff --git a/zlibrary/core/include/allocator.h b/zlibrary/core/include/allocator.h index 667a0fd..e756d98 120000..100644 --- a/zlibrary/core/include/allocator.h +++ b/zlibrary/core/include/allocator.h @@ -1 +1,83 @@ -../src/util/allocator.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __ALLOCATOR_H__ +#define __ALLOCATOR_H__ + +#include <vector> + +template<std::size_t ObjectSize, std::size_t PoolSize> class Allocator { + +public: + Allocator(); + ~Allocator(); + + void *allocate(); + void free(void *ptr); + +private: + void addPool(); + +private: + std::vector<void*> myPools; + void *myFirstUnused; + void *myLastUnused; +}; + +template<std::size_t ObjectSize, std::size_t PoolSize> +inline Allocator<ObjectSize,PoolSize>::Allocator() { + addPool(); +} + +template<std::size_t ObjectSize, std::size_t PoolSize> +inline Allocator<ObjectSize,PoolSize>::~Allocator() { + for (std::vector<void*>::const_iterator it = myPools.begin(); it != myPools.end(); ++it) { + delete[] (char*)*it; + } +} + +template<std::size_t ObjectSize, std::size_t PoolSize> +inline void Allocator<ObjectSize,PoolSize>::addPool() { + char *pool = new char[ObjectSize * PoolSize]; + myFirstUnused = (void*)pool; + myLastUnused = (void*)(pool + ObjectSize * (PoolSize - 1)); + for (std::size_t i = 0; i < PoolSize - 1; ++i) { + *(void**)(pool + ObjectSize * i) = pool + ObjectSize * (i + 1); + } + myPools.push_back(myFirstUnused); +} + +template<std::size_t ObjectSize, std::size_t PoolSize> +void *Allocator<ObjectSize,PoolSize>::allocate() { + void *ptr = myFirstUnused; + if (myFirstUnused == myLastUnused) { + addPool(); + } else { + myFirstUnused = *(void**)myFirstUnused; + } + return ptr; +} + +template<std::size_t ObjectSize, std::size_t PoolSize> +void Allocator<ObjectSize,PoolSize>::free(void *ptr) { + *(void**)myLastUnused = ptr; + myLastUnused = ptr; +} + +#endif /* __ALLOCATOR_H__ */ diff --git a/zlibrary/core/include/optionEntries/ZLColorOptionBuilder.h b/zlibrary/core/include/optionEntries/ZLColorOptionBuilder.h deleted file mode 120000 index 1477a88..0000000 --- a/zlibrary/core/include/optionEntries/ZLColorOptionBuilder.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLColorOptionBuilder.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLFontFamilyOptionEntry.h b/zlibrary/core/include/optionEntries/ZLFontFamilyOptionEntry.h deleted file mode 120000 index 18751a8..0000000 --- a/zlibrary/core/include/optionEntries/ZLFontFamilyOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLFontFamilyOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLLanguageOptionEntry.h b/zlibrary/core/include/optionEntries/ZLLanguageOptionEntry.h deleted file mode 120000 index e27bb66..0000000 --- a/zlibrary/core/include/optionEntries/ZLLanguageOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLLanguageOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLSimpleKeyOptionEntry.h b/zlibrary/core/include/optionEntries/ZLSimpleKeyOptionEntry.h deleted file mode 120000 index 6f90c3e..0000000 --- a/zlibrary/core/include/optionEntries/ZLSimpleKeyOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLSimpleKeyOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLSimpleOptionEntry.h b/zlibrary/core/include/optionEntries/ZLSimpleOptionEntry.h deleted file mode 120000 index c01e085..0000000 --- a/zlibrary/core/include/optionEntries/ZLSimpleOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLSimpleOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLStringEditOptionEntry.h b/zlibrary/core/include/optionEntries/ZLStringEditOptionEntry.h deleted file mode 120000 index 8a26351..0000000 --- a/zlibrary/core/include/optionEntries/ZLStringEditOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLStringEditOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLStringInfoEntry.h b/zlibrary/core/include/optionEntries/ZLStringInfoEntry.h deleted file mode 120000 index a06c15c..0000000 --- a/zlibrary/core/include/optionEntries/ZLStringInfoEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLStringInfoEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/optionEntries/ZLToggleBooleanOptionEntry.h b/zlibrary/core/include/optionEntries/ZLToggleBooleanOptionEntry.h deleted file mode 120000 index 0fa5349..0000000 --- a/zlibrary/core/include/optionEntries/ZLToggleBooleanOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../../src/optionEntries/ZLToggleBooleanOptionEntry.h
\ No newline at end of file diff --git a/zlibrary/core/include/shared_ptr.h b/zlibrary/core/include/shared_ptr.h index 18dde07..8a499c3 120000..100644 --- a/zlibrary/core/include/shared_ptr.h +++ b/zlibrary/core/include/shared_ptr.h @@ -1 +1,424 @@ -../src/util/shared_ptr.h
\ No newline at end of file +/* + * Copyright (C) 2004-2012 Geometer Plus <[email protected]> + * + * 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 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 Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifndef __SHARED_PTR_H__ +#define __SHARED_PTR_H__ + +template<class T> class shared_ptr_storage { + private: + unsigned int myCounter; + unsigned int myWeakCounter; + T* myPointer; + + public: + shared_ptr_storage(T *pointer); + ~shared_ptr_storage(); + + T* pointer() const; + T& content() const; + + void addReference(); + void removeReference(); + void addWeakReference(); + void removeWeakReference(); + unsigned int counter() const; +}; + +template<class T> class weak_ptr; + +template<class T> class shared_ptr { + friend class weak_ptr<T>; + + private: + shared_ptr_storage<T> *myStorage; + + shared_ptr_storage<T> *newStorage(T *t); + void attachStorage(shared_ptr_storage<T> *storage); + void detachStorage(); + + public: + shared_ptr(); + shared_ptr(T *t); + shared_ptr(const shared_ptr<T> &t); + shared_ptr(const weak_ptr<T> &t); + ~shared_ptr(); + + const shared_ptr<T> &operator = (T *t); + const shared_ptr<T> &operator = (const shared_ptr<T> &t); + const shared_ptr<T> &operator = (const weak_ptr<T> &t); + + T* operator -> () const; + T& operator * () const; + bool isNull() const; + void reset(); + bool operator == (const weak_ptr<T> &t) const; + bool operator != (const weak_ptr<T> &t) const; + bool operator < (const weak_ptr<T> &t) const; + bool operator > (const weak_ptr<T> &t) const; + bool operator <= (const weak_ptr<T> &t) const; + bool operator >= (const weak_ptr<T> &t) const; + bool operator == (const shared_ptr<T> &t) const; + bool operator != (const shared_ptr<T> &t) const; + bool operator < (const shared_ptr<T> &t) const; + bool operator > (const shared_ptr<T> &t) const; + bool operator <= (const shared_ptr<T> &t) const; + bool operator >= (const shared_ptr<T> &t) const; +}; + +template<class T> class weak_ptr { + friend class shared_ptr<T>; + private: + shared_ptr_storage<T> *myStorage; + + void attachStorage(shared_ptr_storage<T> *storage); + void detachStorage(); + + public: + weak_ptr(); + weak_ptr(const shared_ptr<T> &t); + weak_ptr(const weak_ptr<T> &t); + ~weak_ptr(); + + const weak_ptr<T> &operator = (const weak_ptr<T> &t); + const weak_ptr<T> &operator = (const shared_ptr<T> &t); + + T* operator -> () const; + T& operator * () const; + bool isNull() const; + void reset(); + + bool operator == (const weak_ptr<T> &t) const; + bool operator != (const weak_ptr<T> &t) const; + bool operator < (const weak_ptr<T> &t) const; + bool operator > (const weak_ptr<T> &t) const; + bool operator <= (const weak_ptr<T> &t) const; + bool operator >= (const weak_ptr<T> &t) const; + bool operator == (const shared_ptr<T> &t) const; + bool operator != (const shared_ptr<T> &t) const; + bool operator < (const shared_ptr<T> &t) const; + bool operator > (const shared_ptr<T> &t) const; + bool operator <= (const shared_ptr<T> &t) const; + bool operator >= (const shared_ptr<T> &t) const; +}; + +template<class T> +inline shared_ptr_storage<T>::shared_ptr_storage(T *pointer) { + myPointer = pointer; + myCounter = 0; + myWeakCounter = 0; +} +template<class T> +inline shared_ptr_storage<T>::~shared_ptr_storage() { +} +template<class T> +inline T* shared_ptr_storage<T>::pointer() const { + return myPointer; +} +template<class T> +inline T& shared_ptr_storage<T>::content() const { + return *myPointer; +} +template<class T> +inline void shared_ptr_storage<T>::addReference() { + ++myCounter; +} +template<class T> +inline void shared_ptr_storage<T>::removeReference() { + --myCounter; + if (myCounter == 0) { + T* ptr = myPointer; + myPointer = 0; + delete ptr; + } +} +template<class T> +inline void shared_ptr_storage<T>::addWeakReference() { + ++myWeakCounter; +} +template<class T> +inline void shared_ptr_storage<T>::removeWeakReference() { + --myWeakCounter; +} +template<class T> +inline unsigned int shared_ptr_storage<T>::counter() const { + return myCounter + myWeakCounter; +} + +template<class T> +inline shared_ptr_storage<T> *shared_ptr<T>::newStorage(T *t) { + return (t == 0) ? 0 : new shared_ptr_storage<T>(t); +} +template<class T> +inline void shared_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) { + myStorage = storage; + if (myStorage != 0) { + myStorage->addReference(); + } +} +template<class T> +inline void shared_ptr<T>::detachStorage() { + if (myStorage != 0) { + if (myStorage->counter() == 1) { + myStorage->removeReference(); + delete myStorage; + } else { + myStorage->removeReference(); + } + } +} + +template<class T> +inline shared_ptr<T>::shared_ptr() { + myStorage = 0; +} +template<class T> +inline shared_ptr<T>::shared_ptr(T *t) { + attachStorage(newStorage(t)); +} +template<class T> +inline shared_ptr<T>::shared_ptr(const shared_ptr<T> &t) { + attachStorage(t.myStorage); +} +template<class T> +inline shared_ptr<T>::shared_ptr(const weak_ptr<T> &t) { + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } +} +template<class T> +inline shared_ptr<T>::~shared_ptr() { + detachStorage(); +} +template<class T> +inline const shared_ptr<T> &shared_ptr<T>::operator = (T *t) { + detachStorage(); + attachStorage(newStorage(t)); + return *this; +} +template<class T> +inline const shared_ptr<T> &shared_ptr<T>::operator = (const shared_ptr<T> &t) { + if (&t != this) { + detachStorage(); + attachStorage(t.myStorage); + } + return *this; +} +template<class T> +inline const shared_ptr<T> &shared_ptr<T>::operator = (const weak_ptr<T> &t) { + detachStorage(); + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } + return *this; +} + +template<class T> +inline T* shared_ptr<T>::operator -> () const { + return (myStorage == 0) ? 0 : myStorage->pointer(); +} +template<class T> +inline T& shared_ptr<T>::operator * () const { + return myStorage->content(); +} +template<class T> +inline bool shared_ptr<T>::isNull() const { + return myStorage == 0; +} +template<class T> +inline void shared_ptr<T>::reset() { + detachStorage(); + attachStorage(0); +} +template<class T> +inline bool shared_ptr<T>::operator == (const weak_ptr<T> &t) const { + return operator -> () == t.operator -> (); +} +template<class T> +inline bool shared_ptr<T>::operator != (const weak_ptr<T> &t) const { + return !operator == (t); +} +template<class T> +inline bool shared_ptr<T>::operator < (const weak_ptr<T> &t) const { + return operator -> () < t.operator -> (); +} +template<class T> +inline bool shared_ptr<T>::operator > (const weak_ptr<T> &t) const { + return t.operator < (*this); +} +template<class T> +inline bool shared_ptr<T>::operator <= (const weak_ptr<T> &t) const { + return !t.operator < (*this); +} +template<class T> +inline bool shared_ptr<T>::operator >= (const weak_ptr<T> &t) const { + return !operator < (t); +} +template<class T> +inline bool shared_ptr<T>::operator == (const shared_ptr<T> &t) const { + return operator -> () == t.operator -> (); +} +template<class T> +inline bool shared_ptr<T>::operator != (const shared_ptr<T> &t) const { + return !operator == (t); +} +template<class T> +inline bool shared_ptr<T>::operator < (const shared_ptr<T> &t) const { + return operator -> () < t.operator -> (); +} +template<class T> +inline bool shared_ptr<T>::operator > (const shared_ptr<T> &t) const { + return t.operator < (*this); +} +template<class T> +inline bool shared_ptr<T>::operator <= (const shared_ptr<T> &t) const { + return !t.operator < (*this); +} +template<class T> +inline bool shared_ptr<T>::operator >= (const shared_ptr<T> &t) const { + return !operator < (t); +} + +template<class T> +inline void weak_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) { + myStorage = storage; + if (myStorage != 0) { + myStorage->addWeakReference(); + } +} +template<class T> +inline void weak_ptr<T>::detachStorage() { + if (myStorage != 0) { + myStorage->removeWeakReference(); + if (myStorage->counter() == 0) { + delete myStorage; + } + } +} + +template<class T> +inline weak_ptr<T>::weak_ptr() { + myStorage = 0; +} +template<class T> +inline weak_ptr<T>::weak_ptr(const shared_ptr<T> &t) { + attachStorage(t.myStorage); +} +template<class T> +inline weak_ptr<T>::weak_ptr(const weak_ptr<T> &t) { + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } +} +template<class T> +inline weak_ptr<T>::~weak_ptr() { + detachStorage(); +} + +template<class T> +inline const weak_ptr<T> &weak_ptr<T>::operator = (const weak_ptr<T> &t) { + if (&t != this) { + detachStorage(); + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } + } + return *this; +} +template<class T> +inline const weak_ptr<T> &weak_ptr<T>::operator = (const shared_ptr<T> &t) { + detachStorage(); + attachStorage(t.myStorage); + return *this; +} + +template<class T> +inline T* weak_ptr<T>::operator -> () const { + return (myStorage == 0) ? 0 : myStorage->pointer(); +} +template<class T> +inline T& weak_ptr<T>::operator * () const { + return myStorage->content(); +} +template<class T> +inline bool weak_ptr<T>::isNull() const { + return (myStorage == 0) || (myStorage->pointer() == 0); +} +template<class T> +inline void weak_ptr<T>::reset() { + detachStorage(); + attachStorage(0); +} +template<class T> +inline bool weak_ptr<T>::operator == (const weak_ptr<T> &t) const { + return operator -> () == t.operator -> (); +} +template<class T> +inline bool weak_ptr<T>::operator != (const weak_ptr<T> &t) const { + return !operator == (t); +} +template<class T> +inline bool weak_ptr<T>::operator < (const weak_ptr<T> &t) const { + return operator -> () < t.operator -> (); +} +template<class T> +inline bool weak_ptr<T>::operator > (const weak_ptr<T> &t) const { + return t.operator < (*this); +} +template<class T> +inline bool weak_ptr<T>::operator <= (const weak_ptr<T> &t) const { + return !t.operator < (*this); +} +template<class T> +inline bool weak_ptr<T>::operator >= (const weak_ptr<T> &t) const { + return !operator < (t); +} +template<class T> +inline bool weak_ptr<T>::operator == (const shared_ptr<T> &t) const { + return operator -> () == t.operator -> (); +} +template<class T> +inline bool weak_ptr<T>::operator != (const shared_ptr<T> &t) const { + return !operator == (t); +} +template<class T> +inline bool weak_ptr<T>::operator < (const shared_ptr<T> &t) const { + return operator -> () < t.operator -> (); +} +template<class T> +inline bool weak_ptr<T>::operator > (const shared_ptr<T> &t) const { + return t.operator < (*this); +} +template<class T> +inline bool weak_ptr<T>::operator <= (const shared_ptr<T> &t) const { + return !t.operator < (*this); +} +template<class T> +inline bool weak_ptr<T>::operator >= (const shared_ptr<T> &t) const { + return !operator < (t); +} + +#endif /* __SHARED_PTR_H__ */ diff --git a/zlibrary/core/src/application/ZLApplication.cpp b/zlibrary/core/src/application/ZLApplication.cpp index 3097bf0..472dc91 100644 --- a/zlibrary/core/src/application/ZLApplication.cpp +++ b/zlibrary/core/src/application/ZLApplication.cpp @@ -25,9 +25,9 @@ #include "ZLToolbar.h" #include "ZLMenu.h" #include "ZLPopupData.h" -#include "../view/ZLView.h" -#include "../view/ZLViewWidget.h" -#include "../view/ZLPaintContext.h" +#include "ZLView.h" +#include "ZLViewWidget.h" +#include "ZLPaintContext.h" const std::string ZLApplication::MouseScrollDownKey = "<MouseScrollDown>"; const std::string ZLApplication::MouseScrollUpKey = "<MouseScrollUp>"; diff --git a/zlibrary/core/src/application/ZLApplication.h b/zlibrary/core/src/application/ZLApplication.h deleted file mode 100644 index cdffa6c..0000000 --- a/zlibrary/core/src/application/ZLApplication.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLAPPLICATION_H__ -#define __ZLAPPLICATION_H__ - -#include <string> -#include <vector> -#include <map> -#include <set> - -#include <shared_ptr.h> -#include <ZLOptions.h> -#include <ZLTime.h> -#include <ZLResource.h> -#include <ZLMessage.h> -#include <ZLView.h> - -class ZLApplicationWindow; -class ZLViewWidget; -class ZLPaintContext; -class ZLKeyBindings; -class ZLToolbar; -class ZLPopupData; -class ZLMenubar; -class ZLFile; - -class ZLApplicationBase { - -protected: - ZLApplicationBase(const std::string &name); - ~ZLApplicationBase(); -}; - -class ZLApplication : public ZLApplicationBase { - -public: - static ZLApplication &Instance(); - static void deleteInstance(); - -private: - static ZLApplication *ourInstance; - -public: - static const std::string MouseScrollUpKey; - static const std::string MouseScrollDownKey; - static const std::string NoAction; - -public: - ZLIntegerOption RotationAngleOption; - ZLIntegerOption AngleStateOption; - - ZLBooleanOption KeyboardControlOption; - - ZLBooleanOption ConfigAutoSavingOption; - ZLIntegerRangeOption ConfigAutoSaveTimeoutOption; - - ZLIntegerRangeOption KeyDelayOption; - -public: - - class Action { - - public: - virtual ~Action(); - virtual bool isVisible() const; - virtual bool isEnabled() const; - void checkAndRun(); - virtual bool useKeyDelay() const; - - protected: - virtual void run() = 0; - }; - -protected: - class RotationAction : public Action { - - public: - bool isVisible() const; - void run(); - }; - friend class RotationAction; - -public: - class FullscreenAction : public Action { - - public: - void run(); - }; - friend class FullscreenAction; - - class PresentWindowHandler : public ZLMessageHandler { - - public: - void onMessageReceived(const std::vector<std::string> &arguments); - const std::string &lastCaller() const; - void resetLastCaller(); - - private: - std::string myLastCaller; - }; - -protected: - ZLApplication(const std::string &name); - - void addAction(const std::string &actionId, shared_ptr<Action> action); - void registerPopupData(const std::string &actionId, shared_ptr<ZLPopupData> popupData); - - void setView(shared_ptr<ZLView> view); - ZLView::Angle rotation() const; - - void setFullscreen(bool fullscreen); - bool isFullscreen() const; - -public: - virtual ~ZLApplication(); - virtual void initWindow(); - - shared_ptr<ZLView> currentView() const; - shared_ptr<ZLPaintContext> context(); - - void grabAllKeys(bool grab); - void trackStylus(bool track); - - void resetWindowCaption(); - void setHyperlinkCursor(bool hyperlink); - - shared_ptr<Action> action(const std::string &actionId) const; - bool isActionVisible(const std::string &actionId) const; - bool isActionEnabled(const std::string &actionId) const; - void doAction(const std::string &actionId); - - virtual shared_ptr<ZLKeyBindings> keyBindings(); - void doActionByKey(const std::string &key); - - void quit(); - virtual bool closeView(); - virtual void openFile(const ZLFile &file); - virtual bool canDragFiles(const std::vector<std::string> &filePaths) const; - virtual void dragFiles(const std::vector<std::string> &filePaths); - - virtual bool isViewFinal() const; - - virtual void refreshWindow(); - void presentWindow(); - - const std::string &lastCaller() const; - void resetLastCaller(); - - void setVisualParameter(const std::string &id, const std::string &value); - void setParameterValueList(const std::string &id, const std::vector<std::string> &values); - const std::string &visualParameter(const std::string &id); - -public: - virtual bool showAuthDialog(const std::string &siteName, std::string &userName, std::string &password, const ZLResourceKey &errorKey) = 0; - virtual void saveUserName(const std::string &siteName, std::string &userName) = 0; - -private: - void createToolbar(int index); - -// TODO: change access rights to private -public: - const ZLToolbar &toolbar(int index) const; - -private: - void createMenubar(); - const ZLMenubar &menubar() const; - -private: - shared_ptr<ZLViewWidget> myViewWidget; - shared_ptr<ZLView> myInitialView; - std::map<std::string,shared_ptr<Action> > myActionMap; - mutable shared_ptr<ZLToolbar> myToolbar; - mutable shared_ptr<ZLToolbar> myFullscreenToolbar; - mutable shared_ptr<ZLMenubar> myMenubar; - shared_ptr<ZLPaintContext> myContext; - shared_ptr <ZLApplicationWindow> myWindow; - ZLTime myLastKeyActionTime; - shared_ptr<ZLMessageHandler> myPresentWindowHandler; - -friend class ZLApplicationWindow; -friend class ZLMenuVisitor; -}; - -#endif /* __ZLAPPLICATION_H__ */ diff --git a/zlibrary/core/src/application/ZLApplicationActions.cpp b/zlibrary/core/src/application/ZLApplicationActions.cpp index bf161ad..f36bc4a 100644 --- a/zlibrary/core/src/application/ZLApplicationActions.cpp +++ b/zlibrary/core/src/application/ZLApplicationActions.cpp @@ -18,8 +18,8 @@ */ #include "ZLApplication.h" -#include "../view/ZLView.h" -#include "../view/ZLViewWidget.h" +#include "ZLView.h" +#include "ZLViewWidget.h" bool ZLApplication::RotationAction::isVisible() const { ZLApplication &application = ZLApplication::Instance(); diff --git a/zlibrary/core/src/application/ZLApplicationWindow.cpp b/zlibrary/core/src/application/ZLApplicationWindow.cpp index 0d1c0bf..3203b32 100644 --- a/zlibrary/core/src/application/ZLApplicationWindow.cpp +++ b/zlibrary/core/src/application/ZLApplicationWindow.cpp @@ -19,7 +19,7 @@ #include "ZLApplicationWindow.h" -#include "../view/ZLViewWidget.h" +#include "ZLViewWidget.h" ZLApplicationWindow *ZLApplicationWindow::ourInstance = 0; diff --git a/zlibrary/core/src/application/ZLKeyBindings.h b/zlibrary/core/src/application/ZLKeyBindings.h deleted file mode 100644 index 322baa4..0000000 --- a/zlibrary/core/src/application/ZLKeyBindings.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLKEYBINDINGS_H__ -#define __ZLKEYBINDINGS_H__ - -#include <map> -#include <string> - -class ZLKeyBindings { - -public: - ZLKeyBindings(const std::string &name); - ~ZLKeyBindings(); - - void bindKey(const std::string &key, const std::string &code); - const std::string &getBinding(const std::string &key); - -private: - void loadDefaultBindings(); - void loadCustomBindings(); - -public: - void saveCustomBindings(); - -private: - const std::string myName; - std::map<std::string,std::string> myBindingsMap; - bool myIsChanged; -}; - -#endif /* __KEYBINDINGS_H__ */ diff --git a/zlibrary/core/src/application/ZLPopupData.h b/zlibrary/core/src/application/ZLPopupData.h deleted file mode 100644 index 235826e..0000000 --- a/zlibrary/core/src/application/ZLPopupData.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLPOPUPDATA_H__ -#define __ZLPOPUPDATA_H__ - -#include <string> - -#include <ZLResource.h> - -class ZLPopupData { - -public: - virtual ~ZLPopupData(); - - virtual std::size_t id() const = 0; - virtual std::size_t count() const = 0; - virtual const std::string text(std::size_t index) = 0; - virtual void run(std::size_t index) = 0; - - static const ZLResource &resource(const std::string &actionId); -}; - -inline ZLPopupData::~ZLPopupData() { -} - -#endif /* __ZLPOPUPDATA_H__ */ diff --git a/zlibrary/core/src/application/ZLToolbar.cpp b/zlibrary/core/src/application/ZLToolbar.cpp index 8930db3..67d8059 100644 --- a/zlibrary/core/src/application/ZLToolbar.cpp +++ b/zlibrary/core/src/application/ZLToolbar.cpp @@ -28,7 +28,7 @@ #include "ZLToolbar.h" #include "ZLApplicationWindow.h" -#include <optionEntries/ZLStringInfoEntry.h> +#include <ZLStringInfoEntry.h> class ZLToolbarCreator : public ZLXMLReader { diff --git a/zlibrary/core/src/blockTreeView/ZLBlockTreeNode.h b/zlibrary/core/src/blockTreeView/ZLBlockTreeNode.h deleted file mode 100644 index 38b4a9e..0000000 --- a/zlibrary/core/src/blockTreeView/ZLBlockTreeNode.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLBLOCKTREENODE_H__ -#define __ZLBLOCKTREENODE_H__ - -#include <map> -#include <vector> - -#include <shared_ptr.h> - -#include <ZLTypeId.h> -#include <ZLRunnable.h> -#include <ZLPaintContext.h> - -class ZLBlockTreeView; - -class ZLBlockTreeNode : public ZLObjectWithRTTI { - -public: - typedef std::vector<ZLBlockTreeNode*> List; - -protected: - struct Rectangle { - const std::size_t Left; - const std::size_t Top; - const std::size_t Right; - const std::size_t Bottom; - - Rectangle(std::size_t left, std::size_t vOffset, std::size_t right, std::size_t bottom); - - bool contains(std::size_t x, std::size_t y) const; - bool operator < (const Rectangle &r) const; - }; - -public: - static const ZLTypeId TYPE_ID; - -protected: - ZLBlockTreeNode(ZLBlockTreeView &view); - ZLBlockTreeNode(ZLBlockTreeNode *parent, std::size_t atPosition = -1); - -public: - virtual ~ZLBlockTreeNode(); - void clear(); - -public: - ZLBlockTreeNode *parent() const; - ZLBlockTreeNode *previous() const; - ZLBlockTreeNode *next() const; - const List &children() const; - - void open(bool openNotClose); - bool isOpen() const; - -protected: - std::size_t level() const; - - ZLBlockTreeView &view(); - -public: - virtual void paint(ZLPaintContext &context, int vOffset) = 0; - virtual int height(ZLPaintContext &context) const = 0; - - void onStylusPress(std::size_t x, std::size_t y); - bool isOverHyperlink(std::size_t x, std::size_t y); - -protected: - void addHyperlink(std::size_t left, std::size_t top, std::size_t right, std::size_t bottom, shared_ptr<ZLRunnableWithKey> action); - void removeAllHyperlinks(); - -private: - ZLBlockTreeView &myView; - ZLBlockTreeNode *myParent; - std::size_t myChildIndex; - - List myChildren; - bool myIsOpen; - - typedef std::map<Rectangle,shared_ptr<ZLRunnableWithKey> > LinkMap; - LinkMap myHyperlinks; - -private: - ZLBlockTreeNode(const ZLBlockTreeNode&); - const ZLBlockTreeNode &operator = (const ZLBlockTreeNode&); -}; - -#endif /* __ZLBLOCKTREENODE_H__ */ diff --git a/zlibrary/core/src/blockTreeView/ZLBlockTreeView.h b/zlibrary/core/src/blockTreeView/ZLBlockTreeView.h deleted file mode 100644 index 95d5e9a..0000000 --- a/zlibrary/core/src/blockTreeView/ZLBlockTreeView.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLBLOCKTREEVIEW_H__ -#define __ZLBLOCKTREEVIEW_H__ - -#include <ZLView.h> - -#include <ZLBlockTreeNode.h> - -class ZLBlockTreeView : public ZLView { - -public: - class RootNode : public ZLBlockTreeNode { - - public: - static const ZLTypeId TYPE_ID; - - public: - RootNode(ZLBlockTreeView &view); - - private: - const ZLTypeId &typeId() const; - void paint(ZLPaintContext &context, int vOffset); - int height(ZLPaintContext &context) const; - }; - -public: - static const ZLTypeId TYPE_ID; - -protected: - ZLBlockTreeView(ZLPaintContext &context); - const ZLTypeId &typeId() const; - - RootNode &rootNode(); - void clear(); - -public: - ZLBlockTreeNode *firstVisibleNode() const; - void setFirstVisibleNode(ZLBlockTreeNode *node); - - enum VisibilityMode { - INVISIBLE, - VISIBLE, - VISIBLE_PARTIAL_AT_TOP, - VISIBLE_PARTIAL_AT_BOTTOM - }; - - VisibilityMode visibilityMode(ZLBlockTreeNode *node) const; - - void ensureVisible(ZLBlockTreeNode *node); - - enum ScrollingMode { - NONE, - PAGE, - ITEM, - }; - void scroll(ScrollingMode mode, bool back); - -protected: - void paint(); - -private: - bool onStylusPress(int x, int y); - bool onStylusMove(int x, int y); - - void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to); - void onScrollbarStep(Direction direction, int steps); - void onScrollbarPageStep(Direction direction, int steps); - -private: - ZLBlockTreeNode *findNode(int &y); - -private: - RootNode myRootNode; - ZLBlockTreeNode *myFirstVisibleNode; - std::size_t myNodePartToSkip; - bool myCanScrollForward; -}; - -#endif /* __ZLBLOCKTREEVIEW_H__ */ diff --git a/zlibrary/core/src/constants/ZLMimeType.h b/zlibrary/core/src/constants/ZLMimeType.h deleted file mode 100644 index 307dc6c..0000000 --- a/zlibrary/core/src/constants/ZLMimeType.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLMIMETYPE_H__ -#define __ZLMIMETYPE_H__ - -#include <string> -#include <shared_ptr.h> -#include <map> - -class ZLMimeType { - -private: - - ZLMimeType(std::string& name, std::map<std::string,std::string>& parameters); - -private: - - static std::map<std::string,shared_ptr<ZLMimeType> > ourSimpleTypesMap; - -public: - static shared_ptr<ZLMimeType> get(const char *text); - static shared_ptr<ZLMimeType> get(std::string text); - static bool isImage(shared_ptr<ZLMimeType> mimeType); - -private: - - const std::map<std::string,std::string> myParameters; - const std::string myName; - -public: - - const std::string& getName() const; - const std::string& getParameter(const std::string &key) const; - - bool weakEquals(const ZLMimeType& t) const; - bool operator ==(const ZLMimeType& t) const; - bool operator !=(const ZLMimeType& t) const; - - static const shared_ptr<ZLMimeType> APPLICATION_XML; - static const shared_ptr<ZLMimeType> APPLICATION_ZIP; - static const shared_ptr<ZLMimeType> APPLICATION_EPUB_ZIP; - static const shared_ptr<ZLMimeType> APPLICATION_FB2_ZIP; - static const shared_ptr<ZLMimeType> APPLICATION_MOBIPOCKET_EBOOK; - static const shared_ptr<ZLMimeType> APPLICATION_PDF; - static const shared_ptr<ZLMimeType> APPLICATION_CHM; - static const shared_ptr<ZLMimeType> APPLICATION_PALM_DB; - static const shared_ptr<ZLMimeType> APPLICATION_ATOM_XML; - static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML; - static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_BOOKS; - static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_AUTHORS; - static const shared_ptr<ZLMimeType> APPLICATION_LITRES_XML_GENRES; - static const shared_ptr<ZLMimeType> APPLICATION_OPENSEARCH_XML; - static const shared_ptr<ZLMimeType> APPLICATION_OR_XML; - - static const shared_ptr<ZLMimeType> APPLICATION_GZIP; - static const shared_ptr<ZLMimeType> APPLICATION_BZIP2; - static const shared_ptr<ZLMimeType> APPLICATION_TAR; - static const shared_ptr<ZLMimeType> APPLICATION_TAR_GZIP; - static const shared_ptr<ZLMimeType> APPLICATION_TAR_BZIP2; - static const shared_ptr<ZLMimeType> APPLICATION_TAR_7Z; - - static const shared_ptr<ZLMimeType> IMAGE_PNG; - static const shared_ptr<ZLMimeType> IMAGE_JPEG; - static const shared_ptr<ZLMimeType> IMAGE_SVG; - static const shared_ptr<ZLMimeType> IMAGE_PALM; - static const shared_ptr<ZLMimeType> IMAGE_AUTO; - - static const shared_ptr<ZLMimeType> TEXT_HTML; - static const shared_ptr<ZLMimeType> TEXT_PLAIN; - static const shared_ptr<ZLMimeType> TEXT_XML; - - static const shared_ptr<ZLMimeType> EMPTY; - -}; - -#endif /* __ZLMIMETYPE_H__ */ diff --git a/zlibrary/core/src/constants/ZLXMLNamespace.h b/zlibrary/core/src/constants/ZLXMLNamespace.h deleted file mode 100644 index 784e438..0000000 --- a/zlibrary/core/src/constants/ZLXMLNamespace.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLXMLNAMESPACE_H__ -#define __ZLXMLNAMESPACE_H__ - -#include <string> - -class ZLXMLNamespace { - -private: - ZLXMLNamespace(); - -public: - static const std::string DublinCore; - static const std::string DublinCoreLegacy; - static const std::string DublinCoreTerms; - static const std::string XLink; - static const std::string OpenPackagingFormat; - static const std::string Atom; - static const std::string OpenSearch; - static const std::string CalibreMetadata; - static const std::string Opds; - static const std::string DaisyNCX; - static const std::string FBReaderCatalogMetadata; -}; - -#endif /* __ZLXMLNAMESPACE_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLDialog.h b/zlibrary/core/src/dialogs/ZLDialog.h deleted file mode 100644 index 6bd29a5..0000000 --- a/zlibrary/core/src/dialogs/ZLDialog.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLDIALOG_H__ -#define __ZLDIALOG_H__ - -#include <string> -#include <ZLDialogContent.h> -#include <ZLResource.h> - -class ZLDialog { - -protected: - ZLDialog(); - -public: - virtual ~ZLDialog(); - - virtual void addButton(const ZLResourceKey &key, bool accept) = 0; - - void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option); - void addOption(const ZLResourceKey &key, ZLOptionEntry *option); - void addOption(const ZLResourceKey &key, ZLSimpleOption &option); - - const ZLResource &resource(const ZLResourceKey &key) const; - - // TODO: change return type to int (or std::string?) - virtual bool run() = 0; - void acceptValues(); - -protected: - ZLDialogContent *myTab; -}; - -#endif /* __ZLDIALOG_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLDialogContent.cpp b/zlibrary/core/src/dialogs/ZLDialogContent.cpp index 512ae17..c1b7392 100644 --- a/zlibrary/core/src/dialogs/ZLDialogContent.cpp +++ b/zlibrary/core/src/dialogs/ZLDialogContent.cpp @@ -17,7 +17,7 @@ * 02110-1301, USA. */ -#include <optionEntries/ZLSimpleOptionEntry.h> +#include <ZLSimpleOptionEntry.h> #include "ZLOptionView.h" #include "ZLDialogContent.h" diff --git a/zlibrary/core/src/dialogs/ZLDialogContent.h b/zlibrary/core/src/dialogs/ZLDialogContent.h deleted file mode 100644 index a39415d..0000000 --- a/zlibrary/core/src/dialogs/ZLDialogContent.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLDIALOGCONTENT_H__ -#define __ZLDIALOGCONTENT_H__ - -#include <string> -#include <vector> - -#include <ZLOptions.h> -#include <ZLResource.h> - -class ZLOptionEntry; -class ZLOptionView; - -class ZLDialogContent { - -protected: - ZLDialogContent(const ZLResource &resource); - -public: - virtual ~ZLDialogContent(); - - const std::string &key() const; - const std::string &displayName() const; - const std::string &value(const ZLResourceKey &key) const; - const ZLResource &resource(const ZLResourceKey &key) const; - - virtual void addOption(const std::string &name, const std::string &tooltip, ZLOptionEntry *option) = 0; - void addOption(const ZLResourceKey &key, ZLOptionEntry *option); - void addOption(const ZLResourceKey &key, ZLSimpleOption &option); - virtual void addOptions(const std::string &name0, const std::string &tooltip0, ZLOptionEntry *option0, - const std::string &name1, const std::string &tooltip1, ZLOptionEntry *option1) = 0; - void addOptions(const ZLResourceKey &key0, ZLOptionEntry *option0, - const ZLResourceKey &key1, ZLOptionEntry *option1); - void addOptions(const ZLResourceKey &key0, ZLSimpleOption &option0, - const ZLResourceKey &key1, ZLSimpleOption &option1); - - void accept(); - -protected: - void addView(ZLOptionView *view); - -private: - const ZLResource &myResource; - std::vector<ZLOptionView*> myViews; -}; - -#endif /* __ZLDIALOGCONTENT_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLDialogManager.h b/zlibrary/core/src/dialogs/ZLDialogManager.h deleted file mode 100644 index 8d84d0c..0000000 --- a/zlibrary/core/src/dialogs/ZLDialogManager.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLDIALOGMANAGER_H__ -#define __ZLDIALOGMANAGER_H__ - -#include <string> - -#include <shared_ptr.h> -#include <ZLRunnable.h> -#include <ZLResource.h> -#include <ZLOpenFileDialog.h> -#include <ZLTreeDialog.h> - -class ZLDialog; -class ZLOptionsDialog; -class ZLTreeHandler; -class ZLApplication; -class ZLImageData; -class ZLProgressDialog; - -class ZLDialogManager { - -public: - static const ZLResourceKey OK_BUTTON; - static const ZLResourceKey CANCEL_BUTTON; - static const ZLResourceKey YES_BUTTON; - static const ZLResourceKey NO_BUTTON; - static const ZLResourceKey APPLY_BUTTON; - - static const ZLResourceKey COLOR_KEY; - static const ZLResourceKey DIALOG_TITLE; - - static const std::string &dialogTitle(const ZLResourceKey &key); - static const std::string &dialogMessage(const ZLResourceKey &key); - static const std::string &buttonName(const ZLResourceKey &key); - static const std::string &waitMessageText(const ZLResourceKey &key); - -protected: - static const ZLResource &resource(); - -public: - static bool isInitialized(); - static ZLDialogManager &Instance(); - static void deleteInstance(); - -protected: - static ZLDialogManager *ourInstance; - -protected: - ZLDialogManager(); - virtual ~ZLDialogManager(); - -public: - virtual void createApplicationWindow(ZLApplication *application) const = 0; - - virtual shared_ptr<ZLDialog> createDialog(const ZLResourceKey &key) const = 0; - virtual shared_ptr<ZLOptionsDialog> createOptionsDialog(const ZLResourceKey &key, shared_ptr<ZLRunnable> applyAction = 0, bool showApplyButton = false) const = 0; - virtual shared_ptr<ZLOpenFileDialog> createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0; - virtual shared_ptr<ZLTreeDialog> createTreeDialog(const ZLResource &resource) const = 0; - - void informationBox(const ZLResourceKey &key) const; - void informationBox(const ZLResourceKey &key, const std::string &message) const; - virtual void informationBox(const std::string &title, const std::string &message) const = 0; - - void errorBox(const ZLResourceKey &key) const; - virtual void errorBox(const ZLResourceKey &key, const std::string &message) const = 0; - - int questionBox(const ZLResourceKey &key, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const; - virtual int questionBox(const ZLResourceKey &key, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2 = ZLResourceKey()) const = 0; - - virtual shared_ptr<ZLProgressDialog> createProgressDialog(const ZLResourceKey &key, bool network) const = 0; - - void wait(const ZLResourceKey &key, ZLRunnable &runnable) const; - - enum ClipboardType { - CLIPBOARD_MAIN, - CLIPBOARD_SELECTION - }; - virtual bool isClipboardSupported(ClipboardType type) const = 0; - virtual void setClipboardText(const std::string &text, ClipboardType type) const = 0; - virtual void setClipboardImage(const ZLImageData &imageData, ClipboardType type) const = 0; -}; - -#endif /* __ZLDIALOGMANAGER_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLOpenFileDialog.h b/zlibrary/core/src/dialogs/ZLOpenFileDialog.h deleted file mode 100644 index e20673d..0000000 --- a/zlibrary/core/src/dialogs/ZLOpenFileDialog.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLOPENFILEDIALOG_H__ -#define __ZLOPENFILEDIALOG_H__ - -#include <string> - -class ZLFile; - -class ZLOpenFileDialog { - -public: - class Filter { - - public: - virtual ~Filter(); - virtual bool accepts(const ZLFile &file) const = 0; - }; - -public: - virtual bool run() = 0; - virtual std::string filePath() const = 0; - virtual std::string directoryPath() const = 0; -}; - -#endif /* __ZLOPENFILEDIALOG_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLOptionEntry.h b/zlibrary/core/src/dialogs/ZLOptionEntry.h deleted file mode 100644 index fb3a319..0000000 --- a/zlibrary/core/src/dialogs/ZLOptionEntry.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLOPTIONENTRY_H__ -#define __ZLOPTIONENTRY_H__ - -#include <vector> -#include <string> - -#include <ZLOptions.h> - -class ZLOptionView; - -class ZLOptionEntry { - -public: - enum ZLOptionKind { - CHOICE, - BOOLEAN, - BOOLEAN3, - STRING, - PASSWORD, - SPIN, - COMBO, - COLOR, - KEY, - ORDER, - MULTILINE, - STATIC, - }; - -public: - ZLOptionEntry(); - virtual ~ZLOptionEntry(); - virtual ZLOptionKind kind() const = 0; - - void setView(ZLOptionView *view); - void resetView(); - - virtual void setVisible(bool visible); - bool isVisible() const; - - virtual void setActive(bool active); - bool isActive() const; - -private: - ZLOptionView *myView; - bool myIsVisible; - bool myIsActive; -}; - -class ZLChoiceOptionEntry : public ZLOptionEntry { - -protected: - ZLChoiceOptionEntry(); - -public: - ZLOptionKind kind() const; - - virtual const std::string &text(int index) const = 0; - virtual int choiceNumber() const = 0; - virtual int initialCheckedIndex() const = 0; - virtual void onAccept(int index) = 0; -}; - -class ZLTextOptionEntry : public ZLOptionEntry { - -public: - virtual const std::string &initialValue() const = 0; - void onAccept(const char *value); - virtual void onAccept(const std::string &value) = 0; - virtual bool useOnValueEdited() const; - void onValueEdited(const char *value); - virtual void onValueEdited(const std::string &value); -}; - -class ZLStringOptionEntry : public ZLTextOptionEntry { - -protected: - ZLStringOptionEntry(); - -public: - ZLOptionKind kind() const; -}; - -class ZLPasswordOptionEntry : public ZLTextOptionEntry { - -protected: - ZLPasswordOptionEntry(); - -public: - ZLOptionKind kind() const; -}; - -class ZLMultilineOptionEntry : public ZLTextOptionEntry { - -protected: - ZLMultilineOptionEntry(); - -public: - ZLOptionKind kind() const; -}; - -class ZLBooleanOptionEntry : public ZLOptionEntry { - -protected: - ZLBooleanOptionEntry(); - -public: - ZLOptionKind kind() const; - - virtual bool initialState() const = 0; - virtual void onStateChanged(bool state); - virtual void onAccept(bool state) = 0; -}; - -class ZLBoolean3OptionEntry : public ZLOptionEntry { - -protected: - ZLBoolean3OptionEntry(); - -public: - ZLOptionKind kind() const; - - virtual ZLBoolean3 initialState() const = 0; - virtual void onStateChanged(ZLBoolean3 state); - virtual void onAccept(ZLBoolean3 state) = 0; -}; - -class ZLSpinOptionEntry : public ZLOptionEntry { - -protected: - ZLSpinOptionEntry(); - -public: - ZLOptionKind kind() const; - - virtual int initialValue() const = 0; - virtual int minValue() const = 0; - virtual int maxValue() const = 0; - virtual int step() const = 0; - virtual void onAccept(int value) = 0; -}; - -class ZLComboOptionEntry : public ZLOptionEntry { - -protected: - ZLComboOptionEntry(bool editable = false); - -public: - ZLOptionKind kind() const; - - virtual const std::string &initialValue() const = 0; - virtual const std::vector<std::string> &values() const = 0; - virtual void onValueSelected(int index); - void onStringValueSelected(const char *value); - void onStringValueSelected(const std::string &value); - virtual bool useOnValueEdited() const; - void onValueEdited(const char *value); - virtual void onValueEdited(const std::string &value); - void onAccept(const char *value); - virtual void onAccept(const std::string &value) = 0; - - bool isEditable() const; - -private: - const bool myEditable; -}; - -class ZLColorOptionEntry : public ZLOptionEntry { - -protected: - ZLColorOptionEntry(); - -public: - ZLOptionKind kind() const; - - virtual const ZLColor initialColor() const = 0; - virtual const ZLColor color() const = 0; - virtual void onAccept(ZLColor color) = 0; - virtual void onReset(ZLColor color); -}; - -class ZLKeyOptionEntry : public ZLOptionEntry { - -public: - ZLKeyOptionEntry(); - void addActionName(const std::string &actionName); - const std::vector<std::string> &actionNames() const; - virtual void onAccept() = 0; - virtual int actionIndex(const std::string &key) = 0; - virtual void onValueChanged(const std::string &key, int index) = 0; - virtual void onKeySelected(const std::string &key) = 0; - -protected: - ZLOptionKind kind() const; - -private: - std::vector<std::string> myActionNames; -}; - -class ZLOrderOptionEntry : public ZLOptionEntry { - -public: - ZLOrderOptionEntry(); - std::vector<std::string> &values(); - -protected: - ZLOptionKind kind() const; - -private: - std::vector<std::string> myValues; -}; - -class ZLStaticTextOptionEntry : public ZLOptionEntry { - -public: - virtual ZLOptionKind kind() const; - - virtual const std::string &initialValue() const = 0; -}; - - -inline ZLOptionEntry::ZLOptionEntry() : myView(0), myIsVisible(true), myIsActive(true) {} -inline ZLOptionEntry::~ZLOptionEntry() {} -inline void ZLOptionEntry::setView(ZLOptionView *view) { myView = view; } -inline bool ZLOptionEntry::isVisible() const { return myIsVisible; } -inline bool ZLOptionEntry::isActive() const { return myIsActive; } - -inline ZLChoiceOptionEntry::ZLChoiceOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLChoiceOptionEntry::kind() const { return CHOICE; } - -inline bool ZLTextOptionEntry::useOnValueEdited() const { return false; } -inline void ZLTextOptionEntry::onValueEdited(const std::string&) {} - -inline ZLStringOptionEntry::ZLStringOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLStringOptionEntry::kind() const { return STRING; } - -inline ZLPasswordOptionEntry::ZLPasswordOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLPasswordOptionEntry::kind() const { return PASSWORD; } - -inline ZLMultilineOptionEntry::ZLMultilineOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLMultilineOptionEntry::kind() const { return MULTILINE; } - -inline ZLBooleanOptionEntry::ZLBooleanOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLBooleanOptionEntry::kind() const { return BOOLEAN; } -inline void ZLBooleanOptionEntry::onStateChanged(bool) {} - -inline ZLBoolean3OptionEntry::ZLBoolean3OptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLBoolean3OptionEntry::kind() const { return BOOLEAN3; } -inline void ZLBoolean3OptionEntry::onStateChanged(ZLBoolean3) {} - -inline ZLSpinOptionEntry::ZLSpinOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLSpinOptionEntry::kind() const { return SPIN; } - -inline ZLComboOptionEntry::ZLComboOptionEntry(bool editable) : myEditable(editable) {} -inline ZLOptionEntry::ZLOptionKind ZLComboOptionEntry::kind() const { return COMBO; } -inline void ZLComboOptionEntry::onValueSelected(int) {} -inline bool ZLComboOptionEntry::useOnValueEdited() const { return false; } -inline void ZLComboOptionEntry::onValueEdited(const std::string&) {} -inline bool ZLComboOptionEntry::isEditable() const { return myEditable; } - -inline ZLColorOptionEntry::ZLColorOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLColorOptionEntry::kind() const { return COLOR; } -inline void ZLColorOptionEntry::onReset(ZLColor) {} - -inline ZLKeyOptionEntry::ZLKeyOptionEntry() {} -inline void ZLKeyOptionEntry::addActionName(const std::string &actionName) { myActionNames.push_back(actionName); } -inline const std::vector<std::string> &ZLKeyOptionEntry::actionNames() const { return myActionNames; } -inline ZLOptionEntry::ZLOptionKind ZLKeyOptionEntry::kind() const { return KEY; } - -inline ZLOrderOptionEntry::ZLOrderOptionEntry() {} -inline ZLOptionEntry::ZLOptionKind ZLOrderOptionEntry::kind() const { return ORDER; } -inline std::vector<std::string> &ZLOrderOptionEntry::values() { return myValues; } - -inline ZLOptionEntry::ZLOptionKind ZLStaticTextOptionEntry::kind() const { return STATIC; } - -#endif /* __ZLOPTIONENTRY_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLOptionsDialog.h b/zlibrary/core/src/dialogs/ZLOptionsDialog.h deleted file mode 100644 index 0a72cdb..0000000 --- a/zlibrary/core/src/dialogs/ZLOptionsDialog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLOPTIONSDIALOG_H__ -#define __ZLOPTIONSDIALOG_H__ - -#include <vector> -#include <string> - -#include <shared_ptr.h> - -#include <ZLRunnable.h> -#include <ZLDialogContent.h> -#include <ZLOptions.h> -#include <ZLResource.h> - -class ZLOptionEntry; - -class ZLDialogContentBuilder; - -class ZLOptionsDialog { - -protected: - static void addPlatformDependentBuilder(shared_ptr<ZLDialogContentBuilder> builder); - -private: - static std::vector<shared_ptr<ZLDialogContentBuilder> > ourPlatformDependentBuilders; - -protected: - ZLOptionsDialog(const ZLResource &resource, shared_ptr<ZLRunnable> applyAction); - -public: - virtual ~ZLOptionsDialog(); - virtual ZLDialogContent &createTab(const ZLResourceKey &key) = 0; - void createPlatformDependentTabs(); - virtual bool run(); - -protected: - virtual const std::string &selectedTabKey() const = 0; - virtual void selectTab(const ZLResourceKey &key) = 0; - virtual bool runInternal() = 0; - - void accept(); - - const std::string &caption() const; - const ZLResource &tabResource(const ZLResourceKey &key) const; - -protected: - ZLStringOption TabOption; - -private: - const ZLResource &myResource; - -protected: - shared_ptr<ZLRunnable> myApplyAction; - std::vector<shared_ptr<ZLDialogContent> > myTabs; -}; - -#endif /* __ZLOPTIONSDIALOG_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLProgressDialog.h b/zlibrary/core/src/dialogs/ZLProgressDialog.h deleted file mode 100644 index be471a0..0000000 --- a/zlibrary/core/src/dialogs/ZLProgressDialog.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLPROGRESSDIALOG_H__ -#define __ZLPROGRESSDIALOG_H__ - -#include <ZLResource.h> -#include <ZLNetworkRequest.h> -#include <ZLRunnable.h> - -class ZLProgressDialog { - -private: - class ProgressListener; - -protected: - ZLProgressDialog(const ZLResourceKey &key); - -public: - virtual ~ZLProgressDialog(); - - shared_ptr<ZLNetworkRequest::Listener> listener(); - virtual void run(ZLRunnable &runnable) = 0; - virtual void setMessage(const std::string &message) = 0; - - const std::string &messageText() const; - std::string messageText(int percent) const; - -private: - const std::string myMessage; -}; - -#endif /* __ZLPROGRESSDIALOG_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLTreeDialog.h b/zlibrary/core/src/dialogs/ZLTreeDialog.h deleted file mode 100644 index 2bf5289..0000000 --- a/zlibrary/core/src/dialogs/ZLTreeDialog.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTREEDIALOG_H__ -#define __ZLTREEDIALOG_H__ - -#include <ZLTreeListener.h> -#include <ZLResource.h> -#include <ZLTreeSearcher.h> - -class ZLTreeDialog : public ZLTreeListener { - -protected: - ZLTreeDialog(const ZLResource &resource); - -public: - //TODO maybe run() should return an integer? - virtual void run(ZLTreeNode *rootNode) = 0; - -public: - void setSearcher(shared_ptr<ZLTreeSearcher> searcher); - - void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index); - void onNodeEndInsert(); - void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index); - void onNodeEndRemove(); - -protected: - const ZLResource &resource() const; - -protected: - shared_ptr<ZLTreeSearcher> mySearcher; - -private: - const ZLResource &myResource; -}; - -#endif /* __ZLTREEDIALOG_H__ */ diff --git a/zlibrary/core/src/encoding/ZLEncodingCollection.cpp b/zlibrary/core/src/encoding/ZLEncodingCollection.cpp index 041fd3c..ae29d28 100644 --- a/zlibrary/core/src/encoding/ZLEncodingCollection.cpp +++ b/zlibrary/core/src/encoding/ZLEncodingCollection.cpp @@ -23,7 +23,7 @@ #include <ZLUnicodeUtil.h> #include <ZLXMLReader.h> -#include "../options/ZLConfig.h" +#include "ZLConfig.h" #include "ZLEncodingConverter.h" #include "DummyEncodingConverter.h" #include "Utf8EncodingConverter.h" diff --git a/zlibrary/core/src/encoding/ZLEncodingConverter.h b/zlibrary/core/src/encoding/ZLEncodingConverter.h deleted file mode 100644 index 84a61de..0000000 --- a/zlibrary/core/src/encoding/ZLEncodingConverter.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLENCODINGCONVERTER_H__ -#define __ZLENCODINGCONVERTER_H__ - -#include <string> -#include <vector> -#include <map> - -#include <shared_ptr.h> - -class ZLEncodingConverter { - -public: - static const std::string ASCII; - static const std::string UTF8; - static const std::string UTF16; - static const std::string UTF16BE; - -protected: - ZLEncodingConverter(); - -public: - virtual ~ZLEncodingConverter(); - virtual void convert(std::string &dst, const char *srcStart, const char *srcEnd) = 0; - void convert(std::string &dst, const std::string &src); - virtual void reset() = 0; - virtual bool fillTable(int *map) = 0; - -private: - ZLEncodingConverter(const ZLEncodingConverter&); - ZLEncodingConverter &operator = (const ZLEncodingConverter&); -}; - -class ZLEncodingConverterInfo { - -public: - ZLEncodingConverterInfo(const std::string &name, const std::string ®ion); - void addAlias(const std::string &alias); - - const std::string &name() const; - const std::string &visibleName() const; - const std::vector<std::string> &aliases() const; - shared_ptr<ZLEncodingConverter> createConverter() const; - bool canCreateConverter() const; - -private: - const std::string myName; - const std::string myVisibleName; - std::vector<std::string> myAliases; - -private: - ZLEncodingConverterInfo(const ZLEncodingConverterInfo&); - ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&); -}; - -typedef shared_ptr<ZLEncodingConverterInfo> ZLEncodingConverterInfoPtr; - -class ZLEncodingSet { - -public: - ZLEncodingSet(const std::string &name); - void addInfo(ZLEncodingConverterInfoPtr info); - - const std::string &name() const; - const std::vector<ZLEncodingConverterInfoPtr> &infos() const; - -private: - const std::string myName; - std::vector<ZLEncodingConverterInfoPtr> myInfos; - -private: - ZLEncodingSet(const ZLEncodingSet&); - ZLEncodingSet &operator = (const ZLEncodingSet&); -}; - -class ZLEncodingConverterProvider; - -class ZLEncodingCollection { - -public: - static ZLEncodingCollection &Instance(); - static std::string encodingDescriptionPath(); - -private: - static ZLEncodingCollection *ourInstance; - -public: - const std::vector<shared_ptr<ZLEncodingSet> > &sets(); - ZLEncodingConverterInfoPtr info(const std::string &name); - ZLEncodingConverterInfoPtr info(int code); - shared_ptr<ZLEncodingConverter> defaultConverter(); - void registerProvider(shared_ptr<ZLEncodingConverterProvider> provider); - -private: - void addInfo(ZLEncodingConverterInfoPtr info); - const std::vector<shared_ptr<ZLEncodingConverterProvider> > &providers() const; - -private: - std::vector<shared_ptr<ZLEncodingSet> > mySets; - std::map<std::string,ZLEncodingConverterInfoPtr> myInfosByName; - std::vector<shared_ptr<ZLEncodingConverterProvider> > myProviders; - -private: - ZLEncodingCollection(); - ~ZLEncodingCollection(); - void init(); - -friend class ZLEncodingConverterInfo; -friend class ZLEncodingCollectionReader; -}; - -#endif /* __ZLENCODINGCONVERTER_H__ */ diff --git a/zlibrary/core/src/filesystem/ZLDir.h b/zlibrary/core/src/filesystem/ZLDir.h deleted file mode 100644 index d353391..0000000 --- a/zlibrary/core/src/filesystem/ZLDir.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLDIR_H__ -#define __ZLDIR_H__ - -#include <string> -#include <vector> - -#include <shared_ptr.h> - -class ZLDir { - -public: - static shared_ptr<ZLDir> root(); - -protected: - ZLDir(const std::string &path); - -public: - virtual ~ZLDir(); - const std::string &path() const; - std::string name() const; - std::string parentPath() const; - std::string itemPath(const std::string &name) const; - bool isRoot() const; - - virtual void collectSubDirs(std::vector<std::string> &names, bool includeSymlinks) = 0; - virtual void collectFiles(std::vector<std::string> &names, bool includeSymlinks) = 0; - -protected: - virtual std::string delimiter() const = 0; - -private: - std::string myPath; - -private: - ZLDir(const ZLDir&); - const ZLDir &operator = (const ZLDir&); -}; - -#endif /* __ZLDIR_H__ */ diff --git a/zlibrary/core/src/filesystem/ZLFSPluginManager.cpp b/zlibrary/core/src/filesystem/ZLFSPluginManager.cpp index e8201f7..3cc0185 100644 --- a/zlibrary/core/src/filesystem/ZLFSPluginManager.cpp +++ b/zlibrary/core/src/filesystem/ZLFSPluginManager.cpp @@ -22,10 +22,10 @@ #include "ZLFSPlugin.h" #include "ZLFSPluginManager.h" -#include "zip/ZLFSCompressorGzip.h" -#include "bzip2/ZLFSCompressorBzip2.h" -#include "zip/ZLFSArchiverZip.h" -#include "tar/ZLFSArchiverTar.h" +#include "ZLFSCompressorGzip.h" +#include "ZLFSCompressorBzip2.h" +#include "ZLFSArchiverZip.h" +#include "ZLFSArchiverTar.h" static const char ARCHIVERS_SEPARATOR = '.'; diff --git a/zlibrary/core/src/filesystem/ZLFile.h b/zlibrary/core/src/filesystem/ZLFile.h deleted file mode 100644 index 5dae04c..0000000 --- a/zlibrary/core/src/filesystem/ZLFile.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLFILE_H__ -#define __ZLFILE_H__ - -#include <string> -#include <map> - -#include <shared_ptr.h> -#include <ZLFileInfo.h> -#include <ZLMimeType.h> - -class ZLDir; -class ZLInputStream; -class ZLOutputStream; -class ZLFSCompressor; -class ZLFSArchiver; -class ZLFSPluginManager; - -class ZLFile { - friend class ZLFSPluginManager; - friend class ZLFSArchiver; - -public: - static const ZLFile NO_FILE; - -private: - static std::map<std::string,weak_ptr<ZLInputStream> > ourPlainStreamCache; - -public: - static std::string fileNameToUtf8(const std::string &fileName); - static std::string replaceIllegalCharacters(const std::string &fileName, char replaceWith); - -public: - static const std::string ZIP; // = "zip" - typedef std::string ArchiveType; //ArchiveType is a string like "tag.gz", that describes sequence of compressors/archivers need to be used - ArchiveType archiveType() const; -private: - void setArchiveType(const ArchiveType type); - void setCompressed(bool compressed); - void setArchived(bool archived); -private: - ZLFile(); - -public: - explicit ZLFile(const std::string &path, shared_ptr<ZLMimeType> mimeType = ZLMimeType::EMPTY); - ~ZLFile(); - - bool exists() const; - std::size_t size() const; - - void forceArchiveType(const std::string & type) const; - - bool isCompressed() const; - bool isDirectory() const; - bool isArchive() const; - - bool remove() const; - bool canRemove() const; - - const std::string &path() const; - const std::string &name(bool hideExtension) const; - const std::string &extension() const; - - shared_ptr<ZLMimeType> mimeType() const; - - std::string physicalFilePath() const; - std::string resolvedPath() const; - - shared_ptr<ZLInputStream> inputStream() const; - shared_ptr<ZLOutputStream> outputStream(bool writeThrough = false) const; - shared_ptr<ZLDir> directory(bool createUnexisting = false) const; - - bool operator == (const ZLFile &other) const; - bool operator != (const ZLFile &other) const; - bool operator < (const ZLFile &other) const; - -private: - void fillInfo() const; - shared_ptr<ZLInputStream> envelopeCompressedStream(shared_ptr<ZLInputStream> &base) const; - -private: - std::string myPath; - std::string myNameWithExtension; - std::string myNameWithoutExtension; - std::string myExtension; - mutable shared_ptr<ZLMimeType> myMimeType; - mutable bool myMimeTypeIsUpToDate; - mutable ArchiveType myArchiveType; - bool myIsCompressed; - bool myIsArchive; - mutable ZLFileInfo myInfo; - mutable bool myInfoIsFilled; -}; - -inline ZLFile::~ZLFile() {} - -inline bool ZLFile::isCompressed() const { return myIsCompressed; } -inline bool ZLFile::isArchive() const { return myIsArchive; } -inline ZLFile::ArchiveType ZLFile::archiveType() const { return myArchiveType; } -inline void ZLFile::setCompressed(bool compressed) { myIsCompressed = compressed; } -inline void ZLFile::setArchived(bool archived) { myIsArchive = archived; } - -inline const std::string &ZLFile::path() const { return myPath; } -inline const std::string &ZLFile::name(bool hideExtension) const { return hideExtension ? myNameWithoutExtension : myNameWithExtension; } -inline const std::string &ZLFile::extension() const { return myExtension; } - -inline bool ZLFile::operator == (const ZLFile &other) const { return myPath == other.myPath; } -inline bool ZLFile::operator != (const ZLFile &other) const { return myPath != other.myPath; } -inline bool ZLFile::operator < (const ZLFile &other) const { return myPath < other.myPath; } - -#endif /* __ZLFILE_H__ */ diff --git a/zlibrary/core/src/filesystem/ZLFileInfo.h b/zlibrary/core/src/filesystem/ZLFileInfo.h deleted file mode 100644 index 498c926..0000000 --- a/zlibrary/core/src/filesystem/ZLFileInfo.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLFILEINFO_H__ -#define __ZLFILEINFO_H__ - -struct ZLFileInfo { - bool Exists; - bool IsDirectory; - std::size_t Size; - - ZLFileInfo(); -}; - -inline ZLFileInfo::ZLFileInfo() : Exists(false), IsDirectory(false), Size(0) { -} - -#endif /* __ZLFILEINFO_H__ */ diff --git a/zlibrary/core/src/filesystem/ZLInputStream.h b/zlibrary/core/src/filesystem/ZLInputStream.h deleted file mode 100644 index 7ac09c7..0000000 --- a/zlibrary/core/src/filesystem/ZLInputStream.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLINPUTSTREAM_H__ -#define __ZLINPUTSTREAM_H__ - -#include <string> - -#include <shared_ptr.h> -#include <ZLUserData.h> - -class ZLInputStream : public ZLUserDataHolder { - -protected: - ZLInputStream(); - -public: - virtual ~ZLInputStream(); - virtual bool open() = 0; - virtual std::size_t read(char *buffer, std::size_t maxSize) = 0; - virtual void close() = 0; - - virtual void seek(int offset, bool absoluteOffset) = 0; - virtual std::size_t offset() const = 0; - virtual std::size_t sizeOfOpened() = 0; - -private: - // disable copying - ZLInputStream(const ZLInputStream&); - const ZLInputStream &operator = (const ZLInputStream&); -}; - -class ZLInputStreamDecorator : public ZLInputStream { - -public: - ZLInputStreamDecorator(shared_ptr<ZLInputStream> decoratee); - -private: - bool open(); - std::size_t read(char *buffer, std::size_t maxSize); - void close(); - - void seek(int offset, bool absoluteOffset); - std::size_t offset() const; - std::size_t sizeOfOpened(); - -private: - shared_ptr<ZLInputStream> myBaseStream; - std::size_t myBaseOffset; -}; - -inline ZLInputStream::ZLInputStream() {} -inline ZLInputStream::~ZLInputStream() {} - -#endif /* __ZLINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/filesystem/ZLOutputStream.h b/zlibrary/core/src/filesystem/ZLOutputStream.h deleted file mode 100644 index 63da97f..0000000 --- a/zlibrary/core/src/filesystem/ZLOutputStream.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLOUTPUTSTREAM_H__ -#define __ZLOUTPUTSTREAM_H__ - -#include <string> - -class ZLOutputStream { - -protected: - ZLOutputStream(); - -public: - virtual ~ZLOutputStream(); - virtual bool open() = 0; - virtual void write(const char *data, std::size_t len) = 0; - virtual void write(const std::string &str) = 0; - virtual void close() = 0; - -private: - ZLOutputStream(const ZLOutputStream&); - const ZLOutputStream &operator = (const ZLOutputStream&); -}; - -inline ZLOutputStream::ZLOutputStream() {} -inline ZLOutputStream::~ZLOutputStream() {} - -#endif /* __ZLOUTPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.cpp b/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.cpp index eadbca0..29f5045 100644 --- a/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.cpp +++ b/zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.cpp @@ -23,7 +23,7 @@ #include "ZLFSCompressorBzip2.h" #include "ZLBzip2InputStream.h" -#include "../ZLFSPluginManager.h" +#include "ZLFSPluginManager.h" ZLFSCompressorBzip2::ZLFSCompressorBzip2() { } diff --git a/zlibrary/core/src/filesystem/tar/ZLTar.cpp b/zlibrary/core/src/filesystem/tar/ZLTar.cpp index 74b4892..4bf6fc0 100644 --- a/zlibrary/core/src/filesystem/tar/ZLTar.cpp +++ b/zlibrary/core/src/filesystem/tar/ZLTar.cpp @@ -21,7 +21,7 @@ #include <cctype> #include "ZLTar.h" -#include "../ZLFile.h" +#include "ZLFile.h" struct ZLTarHeader { std::string Name; diff --git a/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.cpp b/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.cpp index f9ebd6b..daee617 100644 --- a/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.cpp +++ b/zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.cpp @@ -23,7 +23,7 @@ #include "ZLFSCompressorGzip.h" #include "ZLZip.h" -#include "../ZLFSPluginManager.h" +#include "ZLFSPluginManager.h" ZLFSCompressorGzip::ZLFSCompressorGzip() { } diff --git a/zlibrary/core/src/filesystem/zip/ZLZDecompressor.cpp b/zlibrary/core/src/filesystem/zip/ZLZDecompressor.cpp index 1e92ac7..90431eb 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZDecompressor.cpp +++ b/zlibrary/core/src/filesystem/zip/ZLZDecompressor.cpp @@ -21,7 +21,7 @@ #include <algorithm> -#include "../ZLInputStream.h" +#include "ZLInputStream.h" #include "ZLZDecompressor.h" const std::size_t IN_BUFFER_SIZE = 2048; diff --git a/zlibrary/core/src/filesystem/zip/ZLZDecompressor.h b/zlibrary/core/src/filesystem/zip/ZLZDecompressor.h deleted file mode 100644 index 3264bc3..0000000 --- a/zlibrary/core/src/filesystem/zip/ZLZDecompressor.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLZDECOMPRESSOR_H__ -#define __ZLZDECOMPRESSOR_H__ - -#include <zlib.h> - -#include <string> - -class ZLInputStream; - -class ZLZDecompressor { - -public: - ZLZDecompressor(std::size_t size); - ~ZLZDecompressor(); - - std::size_t decompress(ZLInputStream &stream, char *buffer, std::size_t maxSize); - -private: - z_stream *myZStream; - std::size_t myAvailableSize; - char *myInBuffer; - char *myOutBuffer; - std::string myBuffer; -}; - -#endif /* __ZLZDECOMPRESSOR_H__ */ diff --git a/zlibrary/core/src/filesystem/zip/ZLZipDir.cpp b/zlibrary/core/src/filesystem/zip/ZLZipDir.cpp index 421bd92..6a83a92 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZipDir.cpp +++ b/zlibrary/core/src/filesystem/zip/ZLZipDir.cpp @@ -19,7 +19,7 @@ #include "ZLZip.h" #include "ZLZipHeader.h" -#include "../ZLFile.h" +#include "ZLFile.h" void ZLZipDir::collectFiles(std::vector<std::string> &names, bool) { shared_ptr<ZLInputStream> stream = ZLFile(path()).inputStream(); diff --git a/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp b/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp index 8ba5e31..39a0e2a 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp +++ b/zlibrary/core/src/filesystem/zip/ZLZipHeader.cpp @@ -21,7 +21,7 @@ #include "ZLZipHeader.h" #include "ZLZDecompressor.h" -#include "../ZLInputStream.h" +#include "ZLInputStream.h" const int ZLZipHeader::SignatureCentralDirectory = 0x02014B50; const int ZLZipHeader::SignatureLocalFile = 0x04034B50; diff --git a/zlibrary/core/src/filesystem/zip/ZLZipInputStream.cpp b/zlibrary/core/src/filesystem/zip/ZLZipInputStream.cpp index 5fd64d8..9702045 100644 --- a/zlibrary/core/src/filesystem/zip/ZLZipInputStream.cpp +++ b/zlibrary/core/src/filesystem/zip/ZLZipInputStream.cpp @@ -22,7 +22,7 @@ #include "ZLZip.h" #include "ZLZipHeader.h" #include "ZLZDecompressor.h" -#include "../ZLFSManager.h" +#include "ZLFSManager.h" ZLZipInputStream::ZLZipInputStream(shared_ptr<ZLInputStream> &base, const std::string &baseName, const std::string &entryName) : myBaseStream(new ZLInputStreamDecorator(base)), myBaseName(baseName), myEntryName(entryName), myUncompressedSize(0) { } diff --git a/zlibrary/core/src/image/ZLBase64EncodedImage.h b/zlibrary/core/src/image/ZLBase64EncodedImage.h deleted file mode 100644 index 9e7a61e..0000000 --- a/zlibrary/core/src/image/ZLBase64EncodedImage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLBASE64ENCODEDIMAGE_H__ -#define __ZLBASE64ENCODEDIMAGE_H__ - -#include <vector> - -#include <ZLImage.h> - -class ZLBase64EncodedImage : public ZLSingleImage { - -public: - ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType); - ~ZLBase64EncodedImage(); - void addData(const std::string &text, std::size_t offset, std::size_t len); - void addData(const std::vector<std::string> &text); - const shared_ptr<std::string> stringData() const; - -private: - void decode() const; - -private: - mutable std::string myEncodedData; - mutable shared_ptr<std::string> myData; -}; - -inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr<ZLMimeType> mimeType) : ZLSingleImage(mimeType) {} -inline ZLBase64EncodedImage::~ZLBase64EncodedImage() {} - -#endif /* __ZLBASE64ENCODEDIMAGE_H__ */ diff --git a/zlibrary/core/src/image/ZLFileImage.h b/zlibrary/core/src/image/ZLFileImage.h deleted file mode 100644 index ff7ed86..0000000 --- a/zlibrary/core/src/image/ZLFileImage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLFILEIMAGE_H__ -#define __ZLFILEIMAGE_H__ - -#include <string> -#include <vector> - -#include <ZLFile.h> -#include <ZLImage.h> - -class ZLFileImage : public ZLSingleImage { - -public: - struct Block { - unsigned int offset; - unsigned int size; - - Block(unsigned int off, unsigned int s); - }; - typedef std::vector<Block> Blocks; - -public: - static const std::string ENCODING_NONE; - static const std::string ENCODING_HEX; - static const std::string ENCODING_BASE64; - -public: - ZLFileImage(const ZLFile &file, std::size_t offset, std::size_t size = 0, const std::string &encoding = ZLFileImage::ENCODING_NONE); - ZLFileImage(const ZLFile &file, const Blocks &blocks, const std::string &encoding = ZLFileImage::ENCODING_NONE); - const shared_ptr<std::string> stringData() const; - -protected: - //shared_ptr<ZLInputStream> inputStream() const; - -private: - const ZLFile myFile; - const std::string myEncoding; - Blocks myBlocks; -}; - -inline ZLFileImage::Block::Block(unsigned int off, unsigned int s) : offset(off), size(s) {} - -#endif /* __ZLFILEIMAGE_H__ */ diff --git a/zlibrary/core/src/image/ZLImage.h b/zlibrary/core/src/image/ZLImage.h deleted file mode 100644 index 15c88b9..0000000 --- a/zlibrary/core/src/image/ZLImage.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLIMAGE_H__ -#define __ZLIMAGE_H__ - -#include <string> - -#include <shared_ptr.h> - -#include <ZLMimeType.h> - -class ZLNetworkRequest; - -class ZLImage { - -protected: - ZLImage(); - -public: - virtual ~ZLImage(); - virtual bool isSingle() const = 0; - virtual shared_ptr<ZLNetworkRequest> synchronizationData() const; - virtual bool good() const = 0; -}; - -class ZLSingleImage : public ZLImage { - -protected: - ZLSingleImage(shared_ptr<ZLMimeType> mimeType); - virtual ~ZLSingleImage(); - -public: - bool isSingle() const { return true; } - shared_ptr<ZLMimeType> mimeType() const; - bool good() const; - virtual const shared_ptr<std::string> stringData() const = 0; - -private: - shared_ptr<ZLMimeType> myMimeType; -}; - -class ZLMultiImage : public ZLImage { - -protected: - ZLMultiImage(); - virtual ~ZLMultiImage(); - -public: - bool isSingle() const { return false; } - bool good() const; - virtual unsigned int rows() const = 0; - virtual unsigned int columns() const = 0; - virtual shared_ptr<const ZLImage> subImage(unsigned int row, unsigned int column) const = 0; -}; - -inline ZLImage::ZLImage() {} -inline ZLImage::~ZLImage() {} - -inline ZLSingleImage::ZLSingleImage(shared_ptr<ZLMimeType> mimeType) : myMimeType(mimeType) {} -inline ZLSingleImage::~ZLSingleImage() {} -inline shared_ptr<ZLMimeType> ZLSingleImage::mimeType() const { return myMimeType; } - -inline ZLMultiImage::ZLMultiImage() : ZLImage() {} -inline ZLMultiImage::~ZLMultiImage() {} - -#endif /* __ZLIMAGE_H__ */ diff --git a/zlibrary/core/src/image/ZLImageManager.h b/zlibrary/core/src/image/ZLImageManager.h deleted file mode 100644 index c845c2b..0000000 --- a/zlibrary/core/src/image/ZLImageManager.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLIMAGEMANAGER_H__ -#define __ZLIMAGEMANAGER_H__ - -#include <string> -#include <vector> - -#include <shared_ptr.h> - -class ZLImage; -class ZLMultiImage; - -class ZLImageData { - -protected: - ZLImageData() {} - -public: - virtual ~ZLImageData() {} - - virtual unsigned int width() const = 0; - virtual unsigned int height() const = 0; - - virtual void init(unsigned int width, unsigned int height) = 0; - virtual void setPosition(unsigned int x, unsigned int y) = 0; - virtual void moveX(int delta) = 0; - virtual void moveY(int delta) = 0; - virtual void setPixel(unsigned char r, unsigned char g, unsigned char b) = 0; - void setGrayPixel(unsigned char c); - - virtual void copyFrom(const ZLImageData &source, unsigned int targetX, unsigned int targetY) = 0; -}; - -class ZLImageManager { - -public: - static const ZLImageManager &Instance(); - static void deleteInstance(); - -protected: - static ZLImageManager *ourInstance; - -public: - shared_ptr<ZLImageData> imageData(const ZLImage &image) const; - -public: - virtual shared_ptr<const ZLImage> makeBatchImage(const std::vector<shared_ptr<const ZLImage> > &images, shared_ptr<const ZLImage> defaultImage) const = 0; - -protected: - ZLImageManager() {} - virtual ~ZLImageManager() {} - - virtual shared_ptr<ZLImageData> createData() const = 0; - virtual bool convertImageDirect(const std::string &stringData, ZLImageData &imageData) const = 0; - -private: - bool convertMultiImage(const ZLMultiImage &multiImage, ZLImageData &imageData) const; - bool convertFromPalmImageFormat(const std::string &imageString, ZLImageData &imageData) const; -}; - -inline void ZLImageData::setGrayPixel(unsigned char c) { setPixel(c, c, c); } - -inline const ZLImageManager &ZLImageManager::Instance() { return *ourInstance; } - -#endif /* __IMAGEMANAGER_H__ */ diff --git a/zlibrary/core/src/image/ZLNetworkImage.h b/zlibrary/core/src/image/ZLNetworkImage.h deleted file mode 100644 index 98a8223..0000000 --- a/zlibrary/core/src/image/ZLNetworkImage.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLNETWORKIMAGE_H__ -#define __ZLNETWORKIMAGE_H__ - -#include <ZLImage.h> - -class ZLFileImage; - -class ZLNetworkImage : public ZLSingleImage { - -public: - ZLNetworkImage(shared_ptr<ZLMimeType> mimeType, const std::string &url); - const shared_ptr<std::string> stringData() const; - -private: - shared_ptr<ZLNetworkRequest> synchronizationData() const; - -private: - const std::string myURL; - std::string myFileName; - mutable bool myIsSynchronized; - mutable shared_ptr<ZLFileImage> myCachedImage; -}; - -#endif /* __ZLNETWORKIMAGE_H__ */ diff --git a/zlibrary/core/src/image/ZLStreamImage.h b/zlibrary/core/src/image/ZLStreamImage.h deleted file mode 100644 index 95f03f8..0000000 --- a/zlibrary/core/src/image/ZLStreamImage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLSTREAMIMAGE_H__ -#define __ZLSTREAMIMAGE_H__ - -#include <string> - -#include <ZLImage.h> -#include <ZLInputStream.h> - -class ZLStreamImage : public ZLSingleImage { - -public: - ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size = 0); - const shared_ptr<std::string> stringData() const; - -private: - virtual shared_ptr<ZLInputStream> inputStream() const = 0; - -private: - std::size_t myOffset; - mutable std::size_t mySize; -}; - -inline ZLStreamImage::ZLStreamImage(shared_ptr<ZLMimeType> mimeType, std::size_t offset, std::size_t size) : ZLSingleImage(mimeType), myOffset(offset), mySize(size) {} - -#endif /* __ZLSTREAMIMAGE_H__ */ diff --git a/zlibrary/core/src/language/ZLLanguageDetector.h b/zlibrary/core/src/language/ZLLanguageDetector.h deleted file mode 100644 index 7f5d8dc..0000000 --- a/zlibrary/core/src/language/ZLLanguageDetector.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2007-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLLANGUAGEDETECTOR_H__ -#define __ZLLANGUAGEDETECTOR_H__ - -#include <vector> -#include <string> - -//#include <shared_ptr.h> - -class ZLStatisticsBasedMatcher; - -class ZLLanguageDetector { - -public: - struct LanguageInfo { - LanguageInfo(const std::string &language, const std::string &encoding); - const std::string Language; - const std::string Encoding; - }; - -public: - ZLLanguageDetector(); - ~ZLLanguageDetector(); - - shared_ptr<LanguageInfo> findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0); - shared_ptr<LanguageInfo> findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0); - -private: - typedef std::vector<shared_ptr<ZLStatisticsBasedMatcher> > SBVector; - SBVector myMatchers; -}; - -#endif /* __ZLLANGUAGEDETECTOR_H__ */ diff --git a/zlibrary/core/src/language/ZLLanguageList.h b/zlibrary/core/src/language/ZLLanguageList.h deleted file mode 100644 index 318c545..0000000 --- a/zlibrary/core/src/language/ZLLanguageList.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2007-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLLANGUAGELIST_H__ -#define __ZLLANGUAGELIST_H__ - -#include <vector> - -#include <ZLDir.h> - -class ZLLanguageList { - -public: - static std::string patternsDirectoryPath(); - static const std::vector<std::string> &languageCodes(); - static std::string languageName(const std::string &code); - -private: - static std::vector<std::string> ourLanguageCodes; - -private: - ZLLanguageList(); -}; - -#endif /* __ZLLANGUAGELIST_H__ */ diff --git a/zlibrary/core/src/library/ZLibrary.cpp b/zlibrary/core/src/library/ZLibrary.cpp index d407297..e2456ff 100644 --- a/zlibrary/core/src/library/ZLibrary.cpp +++ b/zlibrary/core/src/library/ZLibrary.cpp @@ -25,9 +25,9 @@ #include <ZLLogger.h> #include "ZLibrary.h" -#include "../filesystem/ZLFSManager.h" -#include "../options/ZLConfig.h" -#include "../network/ZLNetworkManager.h" +#include "ZLFSManager.h" +#include "ZLConfig.h" +#include "ZLNetworkManager.h" #include "config.h" diff --git a/zlibrary/core/src/library/ZLibrary.h b/zlibrary/core/src/library/ZLibrary.h deleted file mode 100644 index 9f4a62d..0000000 --- a/zlibrary/core/src/library/ZLibrary.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLIBRARY_H__ -#define __ZLIBRARY_H__ - -#include <string> - -class ZLApplication; -class ZLPaintContext; - -class ZLibrary { - -public: - static const std::string FileNameDelimiter; - static const std::string PathDelimiter; - static const std::string EndOfLine; - static std::string Language(); - static std::string Country(); - - static const std::string BaseDirectory; - static const std::string &ZLibraryDirectory(); - - static const std::string &ImageDirectory(); - static const std::string &ApplicationName(); - static const std::string &ApplicationImageDirectory(); - static const std::string &ApplicationDirectory(); - static const std::string &DefaultFilesPathPrefix(); - - static const std::string &ApplicationWritableDirectory(); - -public: - static bool init(int &argc, char **&argv); - static void parseArguments(int &argc, char **&argv); - static ZLPaintContext *createContext(); - static void run(ZLApplication *application); - static void shutdown(); - -private: - static void initLocale(); - -private: - static bool ourLocaleIsInitialized; - static std::string ourLanguage; - static std::string ourCountry; - static std::string ourZLibraryDirectory; - - static std::string ourImageDirectory; - static std::string ourApplicationImageDirectory; - static std::string ourApplicationName; - static std::string ourApplicationDirectory; - static std::string ourApplicationWritableDirectory; - static std::string ourDefaultFilesPathPrefix; - -private: - static std::string replaceRegExps(const std::string &pattern); - static void initApplication(const std::string &name); - -private: - ZLibrary(); - -friend class ZLApplicationBase; -}; - -inline const std::string &ZLibrary::ZLibraryDirectory() { return ourZLibraryDirectory; } -inline const std::string &ZLibrary::ApplicationName() { return ourApplicationName; } -inline const std::string &ZLibrary::ImageDirectory() { return ourImageDirectory; } -inline const std::string &ZLibrary::ApplicationImageDirectory() { return ourApplicationImageDirectory; } -inline const std::string &ZLibrary::ApplicationDirectory() { return ourApplicationDirectory; } -inline const std::string &ZLibrary::ApplicationWritableDirectory() { return ourApplicationWritableDirectory; } -inline const std::string &ZLibrary::DefaultFilesPathPrefix() { return ourDefaultFilesPathPrefix; } - -#endif /* __ZLIBRARY_H__ */ diff --git a/zlibrary/core/src/logger/ZLLogger.h b/zlibrary/core/src/logger/ZLLogger.h deleted file mode 100644 index 5484b91..0000000 --- a/zlibrary/core/src/logger/ZLLogger.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLLOGGER_H__ -#define __ZLLOGGER_H__ - -#include <string> -#include <set> - -class ZLLogger { - -public: - static const std::string DEFAULT_CLASS; - - static ZLLogger &Instance(); - -private: - static ZLLogger *ourInstance; - -private: - ZLLogger(); - -public: - void registerClass(const std::string &className); - void print(const std::string &className, const std::string &message) const; - void println(const std::string &className, const std::string &message) const; - -private: - std::set<std::string> myRegisteredClasses; -}; - -#endif /* __ZLLOGGER_H__ */ diff --git a/zlibrary/core/src/message/ZLMessage.h b/zlibrary/core/src/message/ZLMessage.h deleted file mode 100644 index 1b0bf8e..0000000 --- a/zlibrary/core/src/message/ZLMessage.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLMESSAGE_H__ -#define __ZLMESSAGE_H__ - -#include <vector> -#include <map> -#include <string> - -#include <shared_ptr.h> - -class ZLMessageOutputChannel; -class ZLMessageSender; - -class ZLMessageHandler; - -class ZLCommunicationManager { - -public: - static ZLCommunicationManager &Instance(); - static void deleteInstance(); - -protected: - static ZLCommunicationManager *ourInstance; - -public: - typedef std::map<std::string,std::string> Data; - -protected: - ZLCommunicationManager(); - virtual ~ZLCommunicationManager(); - void init(); - void onMessageReceived(const std::string &command, const std::vector<std::string> &arguments); - -public: - virtual shared_ptr<ZLMessageOutputChannel> createMessageOutputChannel(const std::string &protocol, const std::string &testFile) = 0; - virtual void addInputMessageDescription(const std::string &command, const std::string &protocol, const Data &data) = 0; - void registerHandler(const std::string &command, shared_ptr<ZLMessageHandler> receiver); - -private: - shared_ptr<ZLMessageHandler> handler(const std::string &command); - -private: - std::map<std::string,weak_ptr<ZLMessageHandler> > myRegisteredHandlers; - bool myInitialized; - -private: - ZLCommunicationManager(const ZLCommunicationManager&); - const ZLCommunicationManager &operator = (const ZLCommunicationManager&); -}; - -class ZLMessageOutputChannel { - -public: - virtual ~ZLMessageOutputChannel(); - - virtual shared_ptr<ZLMessageSender> createSender(const ZLCommunicationManager::Data &data) = 0; -}; - -class ZLMessageSender { - -public: - virtual ~ZLMessageSender(); - - virtual void sendStringMessage(const std::string &message) = 0; -}; - -class ZLMessageHandler { - -public: - virtual ~ZLMessageHandler(); - virtual void onMessageReceived(const std::vector<std::string> &arguments) = 0; -}; - -#endif /* __ZLMESSAGE_H__ */ diff --git a/zlibrary/core/src/network/ZLAsynchronousInputStream.h b/zlibrary/core/src/network/ZLAsynchronousInputStream.h deleted file mode 100644 index 371d703..0000000 --- a/zlibrary/core/src/network/ZLAsynchronousInputStream.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLASYNCHRONOUSINPUTSTREAM_H__ -#define __ZLASYNCHRONOUSINPUTSTREAM_H__ - -#include <string> - - -class ZLAsynchronousInputStream { - -public: - class Handler { - - public: - virtual ~Handler(); - virtual void initialize(const char *encoding) = 0; - virtual void shutdown() = 0; - virtual bool handleBuffer(const char *data, std::size_t len) = 0; - }; - -public: - ZLAsynchronousInputStream(const char *encoding = 0); - virtual ~ZLAsynchronousInputStream(); - - void setEof(); - void setBuffer(const char *data, std::size_t len); - bool eof() const; - bool initialized() const; - - bool processInput(Handler &handler); - -protected: - virtual bool processInputInternal(Handler &handler) = 0; - -protected: - const char *myData; - std::size_t myDataLen; - -private: - std::string myEncoding; - bool myInitialized; - bool myEof; - -private: - // disable copying - ZLAsynchronousInputStream(const ZLAsynchronousInputStream &); - const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &); -}; - -inline void ZLAsynchronousInputStream::setEof() { myEof = true; myData = 0; myDataLen = 0; } -inline void ZLAsynchronousInputStream::setBuffer(const char *data, std::size_t len) { myData = data; myDataLen = len; } -inline bool ZLAsynchronousInputStream::eof() const { return myEof; } -inline bool ZLAsynchronousInputStream::initialized() const { return myInitialized; } - -#endif /* __ZLASYNCHRONOUSINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/network/ZLNetworkManager.cpp b/zlibrary/core/src/network/ZLNetworkManager.cpp index 7836d95..5b97323 100644 --- a/zlibrary/core/src/network/ZLNetworkManager.cpp +++ b/zlibrary/core/src/network/ZLNetworkManager.cpp @@ -31,10 +31,10 @@ #include "ZLNetworkRequest.h" #include "ZLNetworkUtil.h" -#include "requests/ZLNetworkDownloadRequest.h" -#include "requests/ZLNetworkNoActionRequest.h" -#include "requests/ZLNetworkReadToStringRequest.h" -#include "requests/ZLNetworkXMLParserRequest.h" +#include "ZLNetworkDownloadRequest.h" +#include "ZLNetworkNoActionRequest.h" +#include "ZLNetworkReadToStringRequest.h" +#include "ZLNetworkXMLParserRequest.h" ZLNetworkManager *ZLNetworkManager::ourInstance = 0; diff --git a/zlibrary/core/src/network/ZLNetworkManager.h b/zlibrary/core/src/network/ZLNetworkManager.h deleted file mode 100644 index b2fb817..0000000 --- a/zlibrary/core/src/network/ZLNetworkManager.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLNETWORKMANAGER_H__ -#define __ZLNETWORKMANAGER_H__ - -#include <string> - -#include <shared_ptr.h> -#include <ZLOptions.h> - -#include <ZLNetworkRequest.h> -#include <ZLRunnable.h> - -class ZLNetworkData; -class ZLOutputStream; -class ZLXMLReader; - -class ZLNetworkManager { - -public: - static void deleteInstance(); - static ZLNetworkManager &Instance(); - - static std::string CacheDirectory(); - static std::string CookiesPath(); - -protected: - static ZLNetworkManager *ourInstance; - -public: - ZLIntegerRangeOption &ConnectTimeoutOption() const; - ZLIntegerRangeOption &TimeoutOption() const; - ZLBooleanOption &UseProxyOption() const; - ZLStringOption &ProxyHostOption() const; - ZLStringOption &ProxyPortOption() const; - -protected: - ZLNetworkManager(); - virtual ~ZLNetworkManager(); - -public: - virtual std::string perform(const ZLNetworkRequest::Vector &requests) const = 0; - virtual std::string performAsync(const ZLNetworkRequest::Vector &requests) const = 0; - std::string perform(shared_ptr<ZLNetworkRequest> request) const; - std::string performAsync(shared_ptr<ZLNetworkRequest> request) const; - -public: - virtual bool connect() const; - virtual void release() const; - - virtual bool providesProxyInfo() const; - -protected: - virtual bool useProxy() const; - virtual std::string proxyHost() const; - virtual std::string proxyPort() const; - -public: - // returns error message - std::string downloadFile(const std::string &url, const std::string &fileName, shared_ptr<ZLNetworkRequest::Listener> listener = 0) const; - -public: - shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, const std::string &fileName) const; - shared_ptr<ZLNetworkRequest> createDownloadRequest(const std::string &url, shared_ptr<ZLOutputStream> stream) const; - shared_ptr<ZLNetworkRequest> createNoActionRequest(const std::string &url) const; - shared_ptr<ZLNetworkRequest> createReadToStringRequest(const std::string &url, std::string &buffer) const; - shared_ptr<ZLNetworkRequest> createXMLParserRequest(const std::string &url, shared_ptr<ZLXMLReader> reader, shared_ptr<ZLRunnable> runnable = 0) const; - -public: - void setUserAgent(const std::string &userAgent); - const std::string &userAgent() const; - -private: - mutable shared_ptr<ZLIntegerRangeOption> myConnectTimeoutOption; - mutable shared_ptr<ZLIntegerRangeOption> myTimeoutOption; - mutable shared_ptr<ZLBooleanOption> myUseProxyOption; - mutable shared_ptr<ZLStringOption> myProxyHostOption; - mutable shared_ptr<ZLStringOption> myProxyPortOption; - - std::string myUserAgent; -}; - -inline void ZLNetworkManager::setUserAgent(const std::string &userAgent) { myUserAgent = userAgent; } -inline const std::string &ZLNetworkManager::userAgent() const { return myUserAgent; } - -#endif /* __ZLNETWORKMANAGER_H__ */ diff --git a/zlibrary/core/src/network/ZLNetworkRequest.h b/zlibrary/core/src/network/ZLNetworkRequest.h deleted file mode 100644 index 431355a..0000000 --- a/zlibrary/core/src/network/ZLNetworkRequest.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2010-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLNETWORKREQUEST_H__ -#define __ZLNETWORKREQUEST_H__ - -#include <string> -#include <vector> - -#include <shared_ptr.h> - -class ZLNetworkRequest { - -public: - typedef std::vector<shared_ptr<ZLNetworkRequest> > Vector; - -public: - class Listener { - - protected: - Listener(); - - public: - virtual ~Listener(); - virtual void finished(const std::string &error = std::string()) = 0; - virtual void showPercent(int ready, int full); - virtual void setUIStatus(bool enabled); - - friend class ZLNetworkRequest; - }; - -protected: - ZLNetworkRequest(const std::string &url); - -public: - virtual bool handleHeader(void *ptr, std::size_t size); - virtual bool handleContent(void *ptr, std::size_t size) = 0; - - virtual bool doBefore() = 0; - - // When error is empty return false MUST make request fail; when error is not empty return value MUST be ignored - virtual bool doAfter(const std::string &error) = 0; - -protected: - void setErrorMessage(const std::string &message); - -public: - const std::string &errorMessage() const; - - const std::string &url() const; - -public: // HTTP parameters - void setupAuthentication(const std::string &userName, const std::string &password); - const std::string &userName() const; - const std::string &password() const; - - void setRedirectionSupported(bool supported); - bool isRedirectionSupported() const; - - const std::vector<std::pair<std::string, std::string> > &postParameters() const; - void setPostParameters(const std::vector<std::pair<std::string, std::string> > ¶meters); - - -public: //listeners methods - bool hasListener() const; - void setListener(shared_ptr<Listener> listener); - void setPercent(int ready, int full); - void setUIStatus(bool enabled); - -protected: - void finished(const std::string &error); - shared_ptr<Listener> listener() const; - -private: - const std::string myURL; - std::string myErrorMessage; - - std::string myUserName; - std::string myPassword; - - bool myRedirectionSupported; - - std::vector<std::pair<std::string, std::string> > myPostParameters; - - shared_ptr<Listener> myListener; - -private: // disable copying - ZLNetworkRequest(const ZLNetworkRequest &); - const ZLNetworkRequest &operator = (const ZLNetworkRequest &); -}; - -inline void ZLNetworkRequest::setupAuthentication(const std::string &userName, const std::string &password) { - myUserName = userName; - myPassword = password; -} -inline const std::string &ZLNetworkRequest::userName() const { return myUserName; } -inline const std::string &ZLNetworkRequest::password() const { return myPassword; } -inline void ZLNetworkRequest::setRedirectionSupported(bool supported) { myRedirectionSupported = supported; } -inline bool ZLNetworkRequest::isRedirectionSupported() const { return myRedirectionSupported; } -inline const std::vector<std::pair<std::string, std::string> > &ZLNetworkRequest::postParameters() const { return myPostParameters; } - -inline shared_ptr<ZLNetworkRequest::Listener> ZLNetworkRequest::listener() const { return myListener; } - -#endif /* __ZLNETWORKREQUEST_H__ */ diff --git a/zlibrary/core/src/network/ZLNetworkUtil.h b/zlibrary/core/src/network/ZLNetworkUtil.h deleted file mode 100644 index 430044a..0000000 --- a/zlibrary/core/src/network/ZLNetworkUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLNETWORKUTIL_H__ -#define __ZLNETWORKUTIL_H__ - -#include <string> - -class ZLNetworkUtil { - -public: - static std::string htmlEncode(const std::string &stringToEncode); - static std::string hostFromUrl(const std::string &url); - static std::string url(const std::string &baseUrl, const std::string &relativePath); - - static std::string &appendParameter(std::string &url, const std::string &name, const std::string &value); - static bool hasParameter(const std::string &url, const std::string &name); - -private: - static bool isNonRelativeUrl(const std::string &url); - -private: - ZLNetworkUtil(); -}; - -#endif /* __ZLNETWORKUTIL_H__ */ diff --git a/zlibrary/core/src/network/ZLPlainAsynchronousInputStream.h b/zlibrary/core/src/network/ZLPlainAsynchronousInputStream.h deleted file mode 100644 index eb8d0a7..0000000 --- a/zlibrary/core/src/network/ZLPlainAsynchronousInputStream.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ -#define __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ - -#include <ZLAsynchronousInputStream.h> - - -class ZLPlainAsynchronousInputStream : public ZLAsynchronousInputStream { - -public: - ZLPlainAsynchronousInputStream(const char *encoding = 0); - -private: - bool processInputInternal(Handler &handler); - -private: - // disable copying - ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &); - const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &); -}; - -#endif /* __ZLPLAINASYNCHRONOUSINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.cpp b/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.cpp index f1446ee..59f75c3 100644 --- a/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.cpp +++ b/zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.cpp @@ -24,8 +24,8 @@ #include "ZLNetworkXMLParserRequest.h" -#include "../ZLPlainAsynchronousInputStream.h" -#include "../ZLGzipAsynchronousInputStream.h" +#include "ZLPlainAsynchronousInputStream.h" +#include "ZLGzipAsynchronousInputStream.h" static const std::string CONTENT_ENCODING = "content-encoding:"; diff --git a/zlibrary/core/src/options/ZLOptions.h b/zlibrary/core/src/options/ZLOptions.h deleted file mode 100644 index 80a6aec..0000000 --- a/zlibrary/core/src/options/ZLOptions.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLOPTIONS_H__ -#define __ZLOPTIONS_H__ - -#include <vector> -#include <string> - -#include <ZLColor.h> -#include <ZLBoolean3.h> - -class ZLCategoryKey { - -public: - static const ZLCategoryKey EMPTY; - static const ZLCategoryKey LOOK_AND_FEEL; - static const ZLCategoryKey CONFIG; - static const ZLCategoryKey STATE; - static const ZLCategoryKey SYSTEM; - static const ZLCategoryKey NETWORK; - -protected: - explicit ZLCategoryKey(const std::string &name); - -public: - bool operator == (const ZLCategoryKey &key) const; - bool operator != (const ZLCategoryKey &key) const; - - const std::string Name; -}; - -class ZLConfig; - -class ZLOption { - -private: - static ZLConfig *ourConfig; - -public: - static void createInstance(); - static void deleteInstance(); - -protected: - const std::string &getConfigValue(const std::string &defaultValue) const; - const std::string &getConfigValue() const; - const std::string &getDefaultConfigValue(const std::string &defaultValue) const; - const std::string &getDefaultConfigValue() const; - void setConfigValue(const std::string &value) const; - void unsetConfigValue() const; - -public: - static const std::string PLATFORM_GROUP; - static const std::string FULL_KEYBOARD_CONTROL; - static const std::string KEYBOARD_PRESENTED; - static const std::string MOUSE_PRESENTED; - static const std::string TOUCHSCREEN_PRESENTED; - static const std::string FINGER_TAP_DETECTABLE; - -public: - static void clearGroup(const std::string &group); - static void listOptionNames(const std::string &group, std::vector<std::string> &names); - static void listOptionGroups(std::vector<std::string> &groups); - static bool isAutoSavingSupported(); - static void startAutoSave(int seconds); - -protected: - ZLOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName); - -public: - virtual ~ZLOption(); - -private: - const ZLCategoryKey &myCategory; - std::string myGroupName; - std::string myOptionName; - -protected: - mutable bool myIsSynchronized; - -private: - ZLOption(const ZLOption&); - const ZLOption &operator = (const ZLOption&); -}; - -class ZLSimpleOption : public ZLOption { - -public: - enum Type { - TYPE_BOOLEAN, - TYPE_BOOLEAN3, - //TYPE_COLOR, - TYPE_STRING, - }; - -protected: - ZLSimpleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName); - -public: - virtual Type type() const = 0; -}; - -class ZLBooleanOption : public ZLSimpleOption { - -public: - ZLBooleanOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, bool defaultValue); - Type type() const; - - bool value() const; - void setValue(bool value); - -private: - mutable bool myValue; - const bool myDefaultValue; -}; - -class ZLBoolean3Option : public ZLSimpleOption { - -public: - ZLBoolean3Option(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLBoolean3 defaultValue); - Type type() const; - - ZLBoolean3 value() const; - void setValue(ZLBoolean3 value); - -private: - mutable ZLBoolean3 myValue; - const ZLBoolean3 myDefaultValue; -}; - -class ZLIntegerOption : public ZLOption { - -public: - ZLIntegerOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long defaultValue); - - long value() const; - void setValue(long value); - -private: - mutable long myValue; - const long myDefaultValue; -}; - -class ZLIntegerRangeOption : public ZLOption { - -public: - ZLIntegerRangeOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, long minValue, long maxValue, long defaultValue); - - long value() const; - void setValue(long value); - long minValue() const; - long maxValue() const; - -private: - mutable long myValue; - const long myMinValue; - const long myMaxValue; - const long myDefaultValue; -}; - -class ZLColorOption : public ZLOption { - -public: - ZLColorOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, ZLColor defaultValue); - - ZLColor value() const; - void setValue(ZLColor value); - -private: - mutable long myIntValue; - const long myDefaultIntValue; -}; - -class ZLDoubleOption : public ZLOption { - -public: - ZLDoubleOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, double defaultValue); - - double value() const; - void setValue(double value); - -private: - mutable double myValue; - const double myDefaultValue; -}; - -class ZLStringOption : public ZLSimpleOption { - -public: - ZLStringOption(const ZLCategoryKey &category, const std::string &group, const std::string &optionName, const std::string &defaultValue); - Type type() const; - - const std::string &value() const; - void setValue(const std::string &value); - -private: - mutable std::string myValue; - const std::string myDefaultValue; -}; - -#endif /* __ZLOPTIONS_H__ */ diff --git a/zlibrary/core/src/resources/ZLResource.h b/zlibrary/core/src/resources/ZLResource.h deleted file mode 100644 index ee088f2..0000000 --- a/zlibrary/core/src/resources/ZLResource.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLRESOURCE_H__ -#define __ZLRESOURCE_H__ - -#include <string> - -struct ZLResourceKey { - ZLResourceKey() {} - explicit ZLResourceKey(const std::string &name) : Name(name) {} - - std::string Name; -}; - -class ZLResource { - -public: - static const ZLResource &resource(const std::string &key); - static const ZLResource &resource(const ZLResourceKey &key); - -protected: - ZLResource(const std::string &name); - -public: - virtual ~ZLResource(); - const std::string &name() const; - virtual bool hasValue() const = 0; - virtual const std::string &value() const = 0; - virtual const std::string &value(int number) const = 0; - virtual const ZLResource &operator [] (const std::string &key) const = 0; - const ZLResource &operator [] (const ZLResourceKey &key) const; - -private: - const std::string myName; - -private: - // disable copying - ZLResource(const ZLResource&); - const ZLResource &operator = (const ZLResource&); -}; - -#endif /* __ZLRESOURCE_H__ */ diff --git a/zlibrary/core/src/runnable/ZLExecutionUtil.h b/zlibrary/core/src/runnable/ZLExecutionUtil.h deleted file mode 100644 index 83f08a6..0000000 --- a/zlibrary/core/src/runnable/ZLExecutionUtil.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLEXECUTIONUTIL_H__ -#define __ZLEXECUTIONUTIL_H__ - -#include <ZLUserData.h> -#include "ZLNetworkRequest.h" - -class ZLExecutionUtil { - //code for convenient async syntax createListener method: - public: - template <typename T, typename Method> - static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data, T object, Method method) { - data->addUserData(ourHandlerId, new HandlerHelper<T, Method>(object, method)); - return createListener(data); - } - template <typename T, typename Method> - static shared_ptr<ZLNetworkRequest::Listener> createListener(T object, Method method) { - return createListener(new ZLUserDataHolder, object, method); - } - template <typename T, typename Method> - static shared_ptr<ZLNetworkRequest::Listener> createListener(ZLUserData *scope, T object, Method method) { - shared_ptr<ZLUserDataHolder> scopeData = new ZLUserDataHolder; - scopeData->addUserData("scope", scope); - return createListener(scopeData, object, method); - } - - private: - typedef void (*Handler)(ZLUserDataHolder &data, const std::string &error); - - class AbstractHandlerHelper : public ZLUserData { - public: - virtual void handle(ZLUserDataHolder &data, const std::string &error) = 0; - }; - - template <typename T, typename Method> - class HandlerHelper : public AbstractHandlerHelper { - public: - HandlerHelper(T object, Method method) : myObject(object), myMethod(method) { - } - - void handle(ZLUserDataHolder &data, const std::string &error) { - (myObject->*myMethod)(data, error); - } - - private: - T myObject; - Method myMethod; - }; - static void handleHelper(ZLUserDataHolder &data, const std::string &error); - static shared_ptr<ZLNetworkRequest::Listener> createListener(shared_ptr<ZLUserDataHolder> data); - - static std::string ourHandlerId; - -friend class ZLExecutionHandler; -}; - - - -#endif /* __ZLEXECUTIONUTIL_H__ */ diff --git a/zlibrary/core/src/runnable/ZLRunnable.h b/zlibrary/core/src/runnable/ZLRunnable.h deleted file mode 100644 index 60914f1..0000000 --- a/zlibrary/core/src/runnable/ZLRunnable.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLRUNNABLE_H__ -#define __ZLRUNNABLE_H__ - -#include <string> - -class ZLResource; -struct ZLResourceKey; - -class ZLRunnable { - -public: - virtual ~ZLRunnable(); - virtual void run() = 0; -}; - -class ZLRunnableWithKey : public ZLRunnable { - -public: - virtual ZLResourceKey key() const = 0; - virtual std::string text(const ZLResource &resource) const; - virtual bool makesSense() const; -}; - -inline ZLRunnable::~ZLRunnable() {} - -#endif /* __ZLRUNNABLE_H__ */ diff --git a/zlibrary/core/src/time/ZLTime.h b/zlibrary/core/src/time/ZLTime.h deleted file mode 100644 index c06478f..0000000 --- a/zlibrary/core/src/time/ZLTime.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTIME_H__ -#define __ZLTIME_H__ - -class ZLTime { - -public: - ZLTime(); - ZLTime(long seconds, long milliseconds); - ~ZLTime(); - long millisecondsTo(const ZLTime &time) const; - long millisecondsFrom(const ZLTime &time) const; - - long inSeconds() const; - - short hours() const; - short minutes() const; - - short dayOfMonth() const; // from 1 to 31 - short month() const; // from 1 to 12 - short year() const; - -private: - long mySeconds; - long myMilliseconds; -}; - -#endif /* __ZLTIME_H__ */ diff --git a/zlibrary/core/src/time/ZLTimeManager.h b/zlibrary/core/src/time/ZLTimeManager.h deleted file mode 100644 index 639e420..0000000 --- a/zlibrary/core/src/time/ZLTimeManager.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTIMEMANAGER_H__ -#define __ZLTIMEMANAGER_H__ - -#include <map> - -#include <shared_ptr.h> -#include <ZLRunnable.h> - -class ZLTime; - -class ZLTimeManager { - -private: - class AutoRemovableTask; - -protected: - static ZLTimeManager *ourInstance; - -public: - static ZLTimeManager &Instance(); - static void deleteInstance(); - -protected: - ZLTimeManager(); - virtual ~ZLTimeManager(); - -public: - virtual void addTask(shared_ptr<ZLRunnable> task, int interval) = 0; - void addAutoRemovableTask(shared_ptr<ZLRunnable> task, int delay = 0); - void removeTask(shared_ptr<ZLRunnable> task); - -protected: - virtual void removeTaskInternal(shared_ptr<ZLRunnable> task) = 0; - - virtual ZLTime currentTime() const = 0; - virtual short hoursBySeconds(long seconds) const = 0; - virtual short minutesBySeconds(long seconds) const = 0; - - virtual short yearBySeconds(long seconds) const = 0; - virtual short monthBySeconds(long seconds) const = 0; - virtual short dayOfMonthBySeconds(long seconds) const = 0; - -protected: - typedef void (*DeleteFunc)(void*); - template <typename T> struct DeleteHelper { - static void func(T *object) { delete object; } - }; - - class DeleteTask : public ZLRunnable { - - public: - DeleteTask(void *object, DeleteFunc func) : myObject(object), myFunc(func) {} - private: - void run() { myFunc(myObject); } - - void *myObject; - DeleteFunc myFunc; - }; - -public: - template <typename T> static void deleteLater(shared_ptr<T> object, int delay = 0) { - deleteLater(new shared_ptr<T>(object), delay); - } - template <typename T> static void deleteLater(T *object, int delay = 0) { - DeleteFunc func = reinterpret_cast<DeleteFunc>(&DeleteHelper<T>::func); - ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay); - } - -private: - std::map<shared_ptr<ZLRunnable>,shared_ptr<ZLRunnable> > myAutoRemovableTasks; - -friend class ZLTime; -}; - -#endif /* __ZLTIMEMANAGER_H__ */ diff --git a/zlibrary/core/src/tree/ZLTreeActionNode.h b/zlibrary/core/src/tree/ZLTreeActionNode.h deleted file mode 100644 index 6212aed..0000000 --- a/zlibrary/core/src/tree/ZLTreeActionNode.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef ZLTREEACTIONNODE_H -#define ZLTREEACTIONNODE_H - -#include "ZLTreeTitledNode.h" - -class ZLTreeActionNode : public ZLTreeTitledNode { - -public: - static const ZLTypeId TYPE_ID; - const ZLTypeId &typeId() const; - -public: - // Return true if it is final action (dialog should be closed) - virtual bool activate() = 0; -}; - -#endif // ZLTREEACTIONNODE_H diff --git a/zlibrary/core/src/tree/ZLTreeListener.h b/zlibrary/core/src/tree/ZLTreeListener.h deleted file mode 100644 index e602015..0000000 --- a/zlibrary/core/src/tree/ZLTreeListener.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTREELISTENER_H__ -#define __ZLTREELISTENER_H__ - -#include "ZLTreeNode.h" - -//ZLTreeListener is used to get ability to node to notificate Tree Dialog about any changes - -class ZLTreeListener { - -public: - virtual void onExpandRequest(ZLTreeNode *node) = 0; - virtual void onCloseRequest() = 0; - // Parent has new or remove child at index - virtual void onNodeBeginInsert(ZLTreeNode *parent, std::size_t index) = 0; - virtual void onNodeEndInsert() = 0; - virtual void onNodeBeginRemove(ZLTreeNode *parent, std::size_t index) = 0; - virtual void onNodeEndRemove() = 0; - // This method should be called at every node state change except of adding/removing of children - virtual void onNodeUpdated(ZLTreeNode *node) = 0; - - virtual void onDownloadingStarted(ZLTreeNode *node) = 0; - virtual void onDownloadingStopped(ZLTreeNode *node) = 0; - - virtual void onSearchStarted(ZLTreeNode *node) = 0; - virtual void onSearchStopped(ZLTreeNode *node) = 0; - - virtual void onRefresh() = 0; -}; - -#endif /* __ZLTREELISTENER_H__ */ diff --git a/zlibrary/core/src/tree/ZLTreeNode.cpp b/zlibrary/core/src/tree/ZLTreeNode.cpp index 01034bd..b7f9b5c 100644 --- a/zlibrary/core/src/tree/ZLTreeNode.cpp +++ b/zlibrary/core/src/tree/ZLTreeNode.cpp @@ -20,7 +20,7 @@ #include <algorithm> #include "ZLTreeNode.h" #include "ZLTreeListener.h" -#include "../resources/ZLResource.h" +#include "ZLResource.h" //const ZLTypeId ZLTreeAction::TYPE_ID(ZLNetworkRequest::TYPE_ID); diff --git a/zlibrary/core/src/tree/ZLTreeNode.h b/zlibrary/core/src/tree/ZLTreeNode.h deleted file mode 100644 index 79c8b87..0000000 --- a/zlibrary/core/src/tree/ZLTreeNode.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTREENODE_H__ -#define __ZLTREENODE_H__ - -#include <map> -#include <vector> - -#include <shared_ptr.h> - -#include <ZLTypeId.h> -#include <ZLRunnable.h> -#include <ZLPaintContext.h> -#include <ZLNetworkRequest.h> - -// Nowadays I see hierarchy in this way: -// -// ZLTreeNode -// | -// +-ZLTreeTitledNode -- simple node, as shown below -// | | -// | +- ZLTreeActionNode -- node with some action on click, i.e. BookNode at local library -// | -// +-ZLTreePageNode -- usually the leaf of the tree, smth like page with ZLDialogContent -// and some actions, i.e. BookInfo page at network library - -class ZLTreeListener; - -//class ZLTreeAction : public ZLNetworkRequest { //using ZLRunnableWithKey instead -//public: -// static const ZLTypeId TYPE_ID; - -// ZLTreeAction(); -// ~ZLTreeAction(); - -// const ZLTypeId &typeId() const; - -// virtual void run() = 0; -// virtual ZLResourceKey key() const = 0; -// virtual std::string text(const ZLResource &resource) const; -// virtual bool makesSense() const; -//}; - -typedef ZLRunnableWithKey ZLTreeAction; - -class ZLTreeNode : public ZLObjectWithRTTI { - -public: - typedef std::vector<ZLTreeNode*> List; - -public: - static const ZLTypeId TYPE_ID; - const ZLTypeId &typeId() const; - -protected: - ZLTreeNode(ZLTreeNode *parent = 0, std::size_t position = -1); - -public: - virtual ~ZLTreeNode(); - void clear(); - -public: - ZLTreeNode *parent() const; - ZLTreeNode *previous() const; - ZLTreeNode *next() const; - const List &children() const; - std::size_t childIndex() const; - // Children should be requested from network only if we need them - virtual void requestChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0); - virtual void requestMoreChildren(shared_ptr<ZLNetworkRequest::Listener> listener = 0); - - virtual const ZLResource &resource() const; - void registerAction(shared_ptr<ZLTreeAction> action); - const std::vector<shared_ptr<ZLTreeAction> > &actions() const; - std::string actionText(const shared_ptr<ZLTreeAction> &action) const; - - void close() const; - void insert(ZLTreeNode *node, std::size_t index); - void append(ZLTreeNode *node); - void remove(ZLTreeNode *node); - void remove(std::size_t index); - void updated(); - - void notifyDownloadStarted(); - void notifyDownloadStopped(); - - void notifySearchStarted(); - void notifySearchStopped(); - -protected: - std::size_t level() const; - - virtual ZLTreeListener *listener() const; - -private: - ZLTreeNode *myParent; - std::size_t myChildIndex; - - List myChildren; - // Looks like we should also handle actions for menu on "Tap and hold" - std::vector<shared_ptr<ZLTreeAction> > myActions; - -private: - ZLTreeNode(const ZLTreeNode&); - const ZLTreeNode &operator = (const ZLTreeNode&); -}; - -#endif /* __ZLTREENODE_H__ */ diff --git a/zlibrary/core/src/tree/ZLTreePageNode.h b/zlibrary/core/src/tree/ZLTreePageNode.h deleted file mode 100644 index 8226ea1..0000000 --- a/zlibrary/core/src/tree/ZLTreePageNode.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef ZLTREEPAGENODE_H -#define ZLTREEPAGENODE_H - -#include "ZLTreeTitledNode.h" -#include <ZLDialogContent.h> - -class ZLTreePageInfo { -public: - - virtual bool isPageInfoLoaded() = 0; - virtual void loadAll(shared_ptr<ZLNetworkRequest::Listener> listener) = 0; - - virtual std::string title() const = 0; - virtual std::vector<std::string> authors() const = 0; - virtual std::vector<std::string> tags() const = 0; - virtual std::string summary() const = 0; - virtual shared_ptr<const ZLImage> image() const = 0; - - virtual const std::vector<shared_ptr<ZLTreeAction> > &actions() const = 0; - virtual std::string actionText(const shared_ptr<ZLTreeAction> &action) const = 0; - virtual const std::vector<shared_ptr<ZLTreeAction> > relatedActions() const = 0; -}; - -class ZLTreePageNode : public ZLTreeTitledNode { - -public: - ZLTreePageNode(ZLTreeNode *parent = 0, std::size_t position = -1); - static const ZLTypeId TYPE_ID; - const ZLTypeId &typeId() const; - - virtual shared_ptr<ZLTreePageInfo> getPageInfo() = 0; -}; - -#endif // ZLTREEPAGENODE_H diff --git a/zlibrary/core/src/tree/ZLTreeSearcher.h b/zlibrary/core/src/tree/ZLTreeSearcher.h deleted file mode 100644 index 747d9c5..0000000 --- a/zlibrary/core/src/tree/ZLTreeSearcher.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTREESEARCHER_H__ -#define __ZLTREESEARCHER_H__ - -#include <string> - -class ZLTreeSearcher { -public: - virtual void simpleSearch(const std::string &pattern) = 0; -}; - -#endif /* __ZLTREESEARCHER_H__ */ diff --git a/zlibrary/core/src/tree/ZLTreeTitledNode.h b/zlibrary/core/src/tree/ZLTreeTitledNode.h deleted file mode 100644 index a68a746..0000000 --- a/zlibrary/core/src/tree/ZLTreeTitledNode.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTREETITLEDNODE_H__ -#define __ZLTREETITLEDNODE_H__ - -#include "ZLTreeNode.h" -#include <ZLImage.h> - -class ZLTreeTitledNode : public ZLTreeNode { - -public: - static const ZLTypeId TYPE_ID; - const ZLTypeId &typeId() const; - - static const std::string ZLIMAGE_SCHEME; - static const std::string LOCALFILE_SCHEME; - static const std::string SCHEME_POSTFIX; - -public: - ZLTreeTitledNode(ZLTreeNode *parent = 0, std::size_t position = -1); - virtual ~ZLTreeTitledNode(); - - virtual std::string title() const = 0; - virtual std::string subtitle() const; - - // Url to image - //virtual std::string imageUrl() const; - // Or the image if there is no url - virtual shared_ptr<const ZLImage> image() const; -}; - -#endif /* __ZLTREETITLEDNODE_H__ */ diff --git a/zlibrary/core/src/typeId/ZLTypeId.h b/zlibrary/core/src/typeId/ZLTypeId.h deleted file mode 100644 index ed5679a..0000000 --- a/zlibrary/core/src/typeId/ZLTypeId.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2010-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLTYPEID_H__ -#define __ZLTYPEID_H__ - -class ZLTypeId { - -private: - ZLTypeId(); - -public: - explicit ZLTypeId(const ZLTypeId &base); - - bool operator == (const ZLTypeId &type) const; - bool operator != (const ZLTypeId &type) const; - bool isSubtypeOf(const ZLTypeId &type) const; - -private: - const ZLTypeId *myBase; - -friend class ZLObjectWithRTTI; -}; - -class ZLObjectWithRTTI { - -public: - static const ZLTypeId TYPE_ID; - -public: - virtual ~ZLObjectWithRTTI(); - bool isInstanceOf(const ZLTypeId &type, bool exact = false) const; - -protected: - virtual const ZLTypeId &typeId() const = 0; -}; - -template <typename T> -T zlobject_cast(ZLObjectWithRTTI *object) { - if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID)) - return 0; - return static_cast<T>(object); -} - -template <typename T> -T zlobject_cast(const ZLObjectWithRTTI *object) { - if (!object || !object->isInstanceOf(reinterpret_cast<T>(0)->TYPE_ID)) - return 0; - return static_cast<T>(object); -} - -inline bool ZLTypeId::operator == (const ZLTypeId &type) const { - return this == &type; -} - -inline bool ZLTypeId::operator != (const ZLTypeId &type) const { - return this != &type; -} - -inline ZLObjectWithRTTI::~ZLObjectWithRTTI() { -} - -#endif /* __ZLTYPEID_H__ */ diff --git a/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.h b/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.h index 4c9cae3..303fd7a 100644 --- a/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.h +++ b/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.h @@ -27,7 +27,7 @@ #include <tqcursor.h> #include <tqlineedit.h> -#include "../../../../core/src/desktop/application/ZLDesktopApplicationWindow.h" +#include "ZLDesktopApplicationWindow.h" class ZLTQtApplicationWindow : public TQMainWindow, public ZLDesktopApplicationWindow { TQ_OBJECT diff --git a/zlibrary/core/src/ui/dialogs/ZLTQtDialogContent.h b/zlibrary/core/src/ui/dialogs/ZLTQtDialogContent.h index 265c99a..6766402 100644 --- a/zlibrary/core/src/ui/dialogs/ZLTQtDialogContent.h +++ b/zlibrary/core/src/ui/dialogs/ZLTQtDialogContent.h @@ -20,7 +20,7 @@ #ifndef __ZLTQTDIALOGCONTENT_H__ #define __ZLTQTDIALOGCONTENT_H__ -#include "../../../../core/src/desktop/dialogs/ZLDesktopOptionsDialog.h" +#include "ZLDesktopOptionsDialog.h" class TQWidget; class TQGridLayout; diff --git a/zlibrary/core/src/ui/dialogs/ZLTQtOpenFileDialog.h b/zlibrary/core/src/ui/dialogs/ZLTQtOpenFileDialog.h index 144e4bd..3c86734 100644 --- a/zlibrary/core/src/ui/dialogs/ZLTQtOpenFileDialog.h +++ b/zlibrary/core/src/ui/dialogs/ZLTQtOpenFileDialog.h @@ -20,7 +20,7 @@ #ifndef __ZLTQTOPENFILEDIALOG_H__ #define __ZLTQTOPENFILEDIALOG_H__ -#include "../../../../core/src/desktop/dialogs/ZLDesktopOpenFileDialog.h" +#include "ZLDesktopOpenFileDialog.h" class TQFileDialog; diff --git a/zlibrary/core/src/ui/dialogs/ZLTQtOptionView.h b/zlibrary/core/src/ui/dialogs/ZLTQtOptionView.h index d0855aa..41a0e44 100644 --- a/zlibrary/core/src/ui/dialogs/ZLTQtOptionView.h +++ b/zlibrary/core/src/ui/dialogs/ZLTQtOptionView.h @@ -24,7 +24,7 @@ #include <ZLOptionsDialog.h> #include <ZLOptionEntry.h> -#include "../../../../core/src/dialogs/ZLOptionView.h" +#include "ZLOptionView.h" class ZLTQtDialogContent; diff --git a/zlibrary/core/src/ui/dialogs/ZLTQtOptionsDialog.h b/zlibrary/core/src/ui/dialogs/ZLTQtOptionsDialog.h index cec7154..4d2adb2 100644 --- a/zlibrary/core/src/ui/dialogs/ZLTQtOptionsDialog.h +++ b/zlibrary/core/src/ui/dialogs/ZLTQtOptionsDialog.h @@ -25,7 +25,7 @@ #include <tqwidget.h> #include <tqtabdialog.h> -#include "../../../../core/src/desktop/dialogs/ZLDesktopOptionsDialog.h" +#include "ZLDesktopOptionsDialog.h" class ZLTQtOptionsDialog : public TQTabDialog, public ZLDesktopOptionsDialog { TQ_OBJECT diff --git a/zlibrary/core/src/ui/filesystem/ZLTQtFSManager.h b/zlibrary/core/src/ui/filesystem/ZLTQtFSManager.h index fe872e2..75993ae 100644 --- a/zlibrary/core/src/ui/filesystem/ZLTQtFSManager.h +++ b/zlibrary/core/src/ui/filesystem/ZLTQtFSManager.h @@ -20,7 +20,7 @@ #ifndef __ZLTQTFSMANAGER_H__ #define __ZLTQTFSMANAGER_H__ -#include "../../../../core/src/unix/filesystem/ZLUnixFSManager.h" +#include "ZLUnixFSManager.h" class ZLTQtFSManager : public ZLUnixFSManager { diff --git a/zlibrary/core/src/ui/library/ZLibrary.cpp b/zlibrary/core/src/ui/library/ZLibrary.cpp index 54f031d..3d702e8 100644 --- a/zlibrary/core/src/ui/library/ZLibrary.cpp +++ b/zlibrary/core/src/ui/library/ZLibrary.cpp @@ -23,18 +23,18 @@ #include <ZLibrary.h> #include <ZLLanguageUtil.h> -#include "../../unix/library/ZLibraryImplementation.h" +#include "ZLibraryImplementation.h" #include "../filesystem/ZLTQtFSManager.h" #include "../dialogs/ZLTQtDialogManager.h" #include "../image/ZLTQtImageManager.h" #include "../time/ZLTQtTime.h" #include "../view/ZLTQtPaintContext.h" -#include "../../encoding/ZLEncodingConverter.h" -#include "../../unix/iconv/IConvEncodingConverter.h" -#include "../../unix/message/ZLUnixMessage.h" -#include "../../unix/xmlconfig/XMLConfig.h" -#include "../../util/ZLKeyUtil.h" +#include "ZLEncodingConverter.h" +#include "IConvEncodingConverter.h" +#include "ZLUnixMessage.h" +#include "XMLConfig.h" +#include "ZLKeyUtil.h" class ZLTQtLibraryImplementation : public ZLibraryImplementation { diff --git a/zlibrary/core/src/ui/time/ZLTQtTime.h b/zlibrary/core/src/ui/time/ZLTQtTime.h index 36519a2..3da4b04 100644 --- a/zlibrary/core/src/ui/time/ZLTQtTime.h +++ b/zlibrary/core/src/ui/time/ZLTQtTime.h @@ -24,7 +24,7 @@ #include <tqobject.h> -#include "../../../../core/src/unix/time/ZLUnixTime.h" +#include "ZLUnixTime.h" class ZLTQtTimeManager : public TQObject, public ZLUnixTimeManager { diff --git a/zlibrary/core/src/ui/util/ZLTQtKeyUtil.h b/zlibrary/core/src/ui/util/ZLTQtKeyUtil.h index 81f6031..aaa8c57 100644 --- a/zlibrary/core/src/ui/util/ZLTQtKeyUtil.h +++ b/zlibrary/core/src/ui/util/ZLTQtKeyUtil.h @@ -20,7 +20,7 @@ #ifndef __ZLTQTKEYUTIL_H__ #define __ZLTQTKEYUTIL_H__ -#include "../../../../core/src/util/ZLKeyUtil.h" +#include "ZLKeyUtil.h" class TQKeyEvent; diff --git a/zlibrary/core/src/ui/view/ZLTQtViewWidget.h b/zlibrary/core/src/ui/view/ZLTQtViewWidget.h index 65d72c9..3d9db8a 100644 --- a/zlibrary/core/src/ui/view/ZLTQtViewWidget.h +++ b/zlibrary/core/src/ui/view/ZLTQtViewWidget.h @@ -22,7 +22,7 @@ #include <tqwidget.h> -#include "../../../../core/src/view/ZLViewWidget.h" +#include "ZLViewWidget.h" #include <ZLApplication.h> class ZLTQtApplicationWindow; diff --git a/zlibrary/core/src/util/ZLBase64InputStream.h b/zlibrary/core/src/util/ZLBase64InputStream.h deleted file mode 100644 index 4a073d6..0000000 --- a/zlibrary/core/src/util/ZLBase64InputStream.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLBASE64INPUTSTREAM_H__ -#define __ZLBASE64INPUTSTREAM_H__ - -#include <ZLInputStream.h> - -class ZLBase64InputStream : public ZLInputStream { -public: - ZLBase64InputStream(shared_ptr<ZLInputStream> base); - ~ZLBase64InputStream(); - - bool open(); - int read(); - std::size_t read(char *buffer, std::size_t maxSize); - void close(); - - void seek(int offset, bool absoluteOffset); - std::size_t offset() const; - std::size_t sizeOfOpened(); - -private: - void fillDecodedBuffer(); - bool fillBuffer(); - static int decode(char b); - -private: - shared_ptr<ZLInputStream> myBaseStream; - int myDecoded0; - int myDecoded1; - int myDecoded2; - char* myBuffer; - int myBufferOffset; - int myBufferLength; -}; - -#endif /* __ZLBASE64INPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/util/ZLBoolean3.h b/zlibrary/core/src/util/ZLBoolean3.h deleted file mode 100644 index 7371c41..0000000 --- a/zlibrary/core/src/util/ZLBoolean3.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLBOOLEAN3_H__ -#define __ZLBOOLEAN3_H__ - -enum ZLBoolean3 { - B3_FALSE = 0, - B3_TRUE = 1, - B3_UNDEFINED = 2 -}; - -#endif /* __ZLBOOLEAN3_H__ */ diff --git a/zlibrary/core/src/util/ZLColor.h b/zlibrary/core/src/util/ZLColor.h deleted file mode 100644 index 59926a4..0000000 --- a/zlibrary/core/src/util/ZLColor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLCOLOR_H__ -#define __ZLCOLOR_H__ - -struct ZLColor { - unsigned char Red; - unsigned char Green; - unsigned char Blue; - - ZLColor(unsigned char r, unsigned char g, unsigned char b); - ZLColor(long longValue = 0); - long intValue(); - - bool operator == (const ZLColor &color) const; - bool operator != (const ZLColor &color) const; -}; - -inline ZLColor::ZLColor(unsigned char r, unsigned char g, unsigned char b) : Red(r), Green(g), Blue(b) {} -inline ZLColor::ZLColor(long longValue) : Red((unsigned char)(longValue >> 16)), Green((unsigned char)(longValue >> 8)), Blue((unsigned char)longValue) {} -inline long ZLColor::intValue() { return (((long)Red) << 16) + (((long)Green) << 8) + Blue; } -inline bool ZLColor::operator == (const ZLColor &color) const { return (Red == color.Red) && (Green == color.Green) && (Blue == color.Blue); } -inline bool ZLColor::operator != (const ZLColor &color) const { return !operator==(color); } - -#endif /* __ZLCOLOR_H__ */ diff --git a/zlibrary/core/src/util/ZLFileUtil.h b/zlibrary/core/src/util/ZLFileUtil.h deleted file mode 100644 index b76b68d..0000000 --- a/zlibrary/core/src/util/ZLFileUtil.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2010-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLFILEUTIL_H__ -#define __ZLFILEUTIL_H__ - -#include <string> - -class ZLFileUtil { - -public: - static std::string normalizeUnixPath(const std::string &path); - -private: - ZLFileUtil(); -}; - -#endif /* __ZLFILEUTIL_H__ */ diff --git a/zlibrary/core/src/util/ZLHexInputStream.h b/zlibrary/core/src/util/ZLHexInputStream.h deleted file mode 100644 index b846cdd..0000000 --- a/zlibrary/core/src/util/ZLHexInputStream.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLHEXINPUTSTREAM_H__ -#define __ZLHEXINPUTSTREAM_H__ - -#include <ZLInputStream.h> - -class ZLHexInputStream : public ZLInputStream { -public: - ZLHexInputStream(shared_ptr<ZLInputStream> base); - ~ZLHexInputStream(); - - bool open(); - int read(); - std::size_t read(char *buffer, std::size_t maxSize); - void close(); - - void seek(int offset, bool absoluteOffset); - std::size_t offset() const; - std::size_t sizeOfOpened(); - -private: - bool fillBuffer(); - static int decode(char b); - -private: - shared_ptr<ZLInputStream> myBaseStream; - char* myBuffer; - int myBufferOffset; - int myBufferLength; -}; - -#endif /* __ZLHEXINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/util/ZLLanguageUtil.h b/zlibrary/core/src/util/ZLLanguageUtil.h deleted file mode 100644 index a0f912c..0000000 --- a/zlibrary/core/src/util/ZLLanguageUtil.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLLANGUAGEUTIL_H__ -#define __ZLLANGUAGEUTIL_H__ - -#include <string> - -class ZLLanguageUtil { - -public: - static const std::string OtherLanguageCode; - -public: - static std::string languageByCode(unsigned char languageCode, unsigned char subLanguageCode); - static bool isRTLLanguage(const std::string &languageCode); - -private: - ZLLanguageUtil(); -}; - -#endif /* __ZLLANGUAGEUTIL_H__ */ diff --git a/zlibrary/core/src/util/ZLSearchUtil.h b/zlibrary/core/src/util/ZLSearchUtil.h deleted file mode 100644 index 797b7af..0000000 --- a/zlibrary/core/src/util/ZLSearchUtil.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLSEARCHUTIL_H__ -#define __ZLSEARCHUTIL_H__ - -#include <string> - -class ZLSearchPattern { - -public: - ZLSearchPattern(const std::string &pattern, bool ignoreCase); - ~ZLSearchPattern(); - int length() const; - -private: - bool ignoreCase() const; - const std::string &lowerCasePattern() const; - const std::string &upperCasePattern() const; - -private: - bool myIgnoreCase; - std::string myLowerCasePattern; - std::string myUpperCasePattern; - -friend class ZLSearchUtil; -}; - -class ZLSearchUtil { - -private: - ZLSearchUtil(); - -public: - static int find(const char *text, std::size_t length, const ZLSearchPattern &pattern, int pos = 0); -}; - -inline ZLSearchPattern::~ZLSearchPattern() {} -inline int ZLSearchPattern::length() const { return myLowerCasePattern.length(); } -inline bool ZLSearchPattern::ignoreCase() const { return myIgnoreCase; } -inline const std::string &ZLSearchPattern::lowerCasePattern() const { return myLowerCasePattern; } -inline const std::string &ZLSearchPattern::upperCasePattern() const { return myUpperCasePattern; } - -#endif /* __ZLSEARCHUTIL_H__ */ diff --git a/zlibrary/core/src/util/ZLSliceInputStream.h b/zlibrary/core/src/util/ZLSliceInputStream.h deleted file mode 100644 index 9333be8..0000000 --- a/zlibrary/core/src/util/ZLSliceInputStream.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2009-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLSLICEINPUTSTREAM_H__ -#define __ZLSLICEINPUTSTREAM_H__ - -#include <ZLInputStream.h> - -class ZLSliceInputStream : public ZLInputStream { -public: - ZLSliceInputStream(shared_ptr<ZLInputStream> base, std::size_t start, std::size_t length); - - bool open(); - std::size_t read(char *buffer, std::size_t maxSize); - void close(); - - void seek(int offset, bool absoluteOffset); - std::size_t offset() const; - std::size_t sizeOfOpened(); - -private: - shared_ptr<ZLInputStream> myBaseStream; - std::size_t myStart; - std::size_t myLength; -}; - -#endif /* __ZLSLICEINPUTSTREAM_H__ */ diff --git a/zlibrary/core/src/util/ZLStringUtil.h b/zlibrary/core/src/util/ZLStringUtil.h deleted file mode 100644 index 71dda00..0000000 --- a/zlibrary/core/src/util/ZLStringUtil.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLSTRINGUTIL_H__ -#define __ZLSTRINGUTIL_H__ - -#include <vector> -#include <string> - -class ZLStringUtil { - -private: - ZLStringUtil(); - -public: - static bool stringStartsWith(const std::string &str, const std::string &start); - static bool stringEndsWith(const std::string &str, const std::string &end); - - static bool isDigit(char c); - static bool isLatinLetter(char c); - - static void appendNumber(std::string &str, unsigned int n); - static void append(std::string &str, const std::vector<std::string> &buffer); - static void stripWhiteSpaces(std::string &str); - - static const std::string SPACE; - static std::vector<std::string> split(const std::string &str, const std::string &delimiter); - - static std::string printf(const std::string &format, const std::string &arg0); - static std::string printf(const std::string &format, unsigned int n); - - static std::string doubleToString(double value); - static double stringToDouble(const std::string &value, double defaultValue); - static int stringToInteger(const std::string &str, int defaultValue = 0); - - static std::string replaceAll(const std::string &str, const std::string& what, const std::string &to); - - template <typename T, typename F> - static std::string join(T iterable, F functor, std::string separator); - template <typename T> - static std::string join(T iterable, std::string separator); - - template <typename T> - struct self { - inline T operator()(const T &t) { - return t; - } - }; -}; - -template <typename T, typename F> -std::string ZLStringUtil::join(T iterable, F functor, std::string separator) { - std::string result; - for (typename T::const_iterator it=iterable.begin(); it != iterable.end(); ++it) { - if (it != iterable.begin()) { - result += separator; - } - result += functor(*it); - } - return result; -} - -template <typename T> -std::string ZLStringUtil::join(T iterable, std::string separator) { - return join(iterable, ZLStringUtil::self<typename T::value_type>(), separator); -} - -#endif /* __ZLSTRINGUTIL_H__ */ diff --git a/zlibrary/core/src/util/ZLUnicodeUtil.h b/zlibrary/core/src/util/ZLUnicodeUtil.h deleted file mode 100644 index 963e671..0000000 --- a/zlibrary/core/src/util/ZLUnicodeUtil.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLUNICODEUTIL_H__ -#define __ZLUNICODEUTIL_H__ - -#include <stdint.h> -#include <string> -#include <vector> - -class ZLUnicodeUtil { - -private: - ZLUnicodeUtil(); - -public: - typedef uint16_t Ucs2Char; - typedef std::vector<Ucs2Char> Ucs2String; - typedef uint32_t Ucs4Char; - typedef std::vector<Ucs4Char> Ucs4String; - - enum Breakable { - NO_BREAKABLE, - BREAKABLE_BEFORE, - BREAKABLE_AFTER - }; - - static bool isUtf8String(const char *str, int len); - static bool isUtf8String(const std::string &str); - static void cleanUtf8String(std::string &str); - static int utf8Length(const char *str, int len); - static int utf8Length(const std::string &str); - static int length(const char *str, int utf8Length); - static int length(const std::string &str, int utf8Length); - static void utf8ToUcs4(Ucs4String &to, const char *from, int length, int toLength = -1); - static void utf8ToUcs4(Ucs4String &to, const std::string &from, int toLength = -1); - static void utf8ToUcs2(Ucs2String &to, const char *from, int length, int toLength = -1); - static void utf8ToUcs2(Ucs2String &to, const std::string &from, int toLength = -1); - static std::size_t firstChar(Ucs4Char &ch, const char *utf8String); - static std::size_t firstChar(Ucs4Char &ch, const std::string &utf8String); - static std::size_t lastChar(Ucs4Char &ch, const char *utf8String); - static std::size_t lastChar(Ucs4Char &ch, const std::string &utf8String); - static void ucs4ToUtf8(std::string &to, const Ucs4String &from, int toLength = -1); - static int ucs4ToUtf8(char *to, Ucs4Char ch); - static void ucs2ToUtf8(std::string &to, const Ucs2String &from, int toLength = -1); - static int ucs2ToUtf8(char *to, Ucs2Char ch); - static bool isLetter(Ucs4Char ch); - static bool isSpace(Ucs4Char ch); - static bool isNBSpace(Ucs4Char ch); - static Breakable isBreakable(Ucs4Char ch); - - static Ucs4Char toLower(Ucs4Char ch); - static void toLower(Ucs4String &str); - static std::string toLower(const std::string &utf8String); - - static Ucs4Char toUpper(Ucs4Char ch); - static void toUpper(Ucs4String &str); - static std::string toUpper(const std::string &utf8String); - - static void utf8Trim(std::string &utf8String); -}; - -inline bool ZLUnicodeUtil::isNBSpace(Ucs4Char ch) { - return ch == 160; -} - -#endif /* __ZLUNICODEUTIL_H__ */ diff --git a/zlibrary/core/src/util/ZLUserData.h b/zlibrary/core/src/util/ZLUserData.h deleted file mode 100644 index db98346..0000000 --- a/zlibrary/core/src/util/ZLUserData.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLUSERDATA_H__ -#define __ZLUSERDATA_H__ - -#include <map> -#include <string> - -#include <shared_ptr.h> - -class ZLUserData { - -public: - virtual ~ZLUserData(); -}; - -class ZLUserDataHolder { - -public: - ZLUserDataHolder(); - ZLUserDataHolder(const ZLUserDataHolder &other); - virtual ~ZLUserDataHolder(); - - void addUserData(const std::string &key, shared_ptr<ZLUserData> data); - void removeUserData(const std::string &key); - shared_ptr<ZLUserData> getUserData(const std::string &key) const; - -private: - ZLUserDataHolder &operator =(const ZLUserDataHolder &other); - std::map<std::string,shared_ptr<ZLUserData> > myDataMap; -}; - -#endif /* __ZLUSERDATA_H__ */ diff --git a/zlibrary/core/src/util/allocator.h b/zlibrary/core/src/util/allocator.h deleted file mode 100644 index e756d98..0000000 --- a/zlibrary/core/src/util/allocator.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ALLOCATOR_H__ -#define __ALLOCATOR_H__ - -#include <vector> - -template<std::size_t ObjectSize, std::size_t PoolSize> class Allocator { - -public: - Allocator(); - ~Allocator(); - - void *allocate(); - void free(void *ptr); - -private: - void addPool(); - -private: - std::vector<void*> myPools; - void *myFirstUnused; - void *myLastUnused; -}; - -template<std::size_t ObjectSize, std::size_t PoolSize> -inline Allocator<ObjectSize,PoolSize>::Allocator() { - addPool(); -} - -template<std::size_t ObjectSize, std::size_t PoolSize> -inline Allocator<ObjectSize,PoolSize>::~Allocator() { - for (std::vector<void*>::const_iterator it = myPools.begin(); it != myPools.end(); ++it) { - delete[] (char*)*it; - } -} - -template<std::size_t ObjectSize, std::size_t PoolSize> -inline void Allocator<ObjectSize,PoolSize>::addPool() { - char *pool = new char[ObjectSize * PoolSize]; - myFirstUnused = (void*)pool; - myLastUnused = (void*)(pool + ObjectSize * (PoolSize - 1)); - for (std::size_t i = 0; i < PoolSize - 1; ++i) { - *(void**)(pool + ObjectSize * i) = pool + ObjectSize * (i + 1); - } - myPools.push_back(myFirstUnused); -} - -template<std::size_t ObjectSize, std::size_t PoolSize> -void *Allocator<ObjectSize,PoolSize>::allocate() { - void *ptr = myFirstUnused; - if (myFirstUnused == myLastUnused) { - addPool(); - } else { - myFirstUnused = *(void**)myFirstUnused; - } - return ptr; -} - -template<std::size_t ObjectSize, std::size_t PoolSize> -void Allocator<ObjectSize,PoolSize>::free(void *ptr) { - *(void**)myLastUnused = ptr; - myLastUnused = ptr; -} - -#endif /* __ALLOCATOR_H__ */ diff --git a/zlibrary/core/src/util/shared_ptr.h b/zlibrary/core/src/util/shared_ptr.h deleted file mode 100644 index 8a499c3..0000000 --- a/zlibrary/core/src/util/shared_ptr.h +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __SHARED_PTR_H__ -#define __SHARED_PTR_H__ - -template<class T> class shared_ptr_storage { - private: - unsigned int myCounter; - unsigned int myWeakCounter; - T* myPointer; - - public: - shared_ptr_storage(T *pointer); - ~shared_ptr_storage(); - - T* pointer() const; - T& content() const; - - void addReference(); - void removeReference(); - void addWeakReference(); - void removeWeakReference(); - unsigned int counter() const; -}; - -template<class T> class weak_ptr; - -template<class T> class shared_ptr { - friend class weak_ptr<T>; - - private: - shared_ptr_storage<T> *myStorage; - - shared_ptr_storage<T> *newStorage(T *t); - void attachStorage(shared_ptr_storage<T> *storage); - void detachStorage(); - - public: - shared_ptr(); - shared_ptr(T *t); - shared_ptr(const shared_ptr<T> &t); - shared_ptr(const weak_ptr<T> &t); - ~shared_ptr(); - - const shared_ptr<T> &operator = (T *t); - const shared_ptr<T> &operator = (const shared_ptr<T> &t); - const shared_ptr<T> &operator = (const weak_ptr<T> &t); - - T* operator -> () const; - T& operator * () const; - bool isNull() const; - void reset(); - bool operator == (const weak_ptr<T> &t) const; - bool operator != (const weak_ptr<T> &t) const; - bool operator < (const weak_ptr<T> &t) const; - bool operator > (const weak_ptr<T> &t) const; - bool operator <= (const weak_ptr<T> &t) const; - bool operator >= (const weak_ptr<T> &t) const; - bool operator == (const shared_ptr<T> &t) const; - bool operator != (const shared_ptr<T> &t) const; - bool operator < (const shared_ptr<T> &t) const; - bool operator > (const shared_ptr<T> &t) const; - bool operator <= (const shared_ptr<T> &t) const; - bool operator >= (const shared_ptr<T> &t) const; -}; - -template<class T> class weak_ptr { - friend class shared_ptr<T>; - private: - shared_ptr_storage<T> *myStorage; - - void attachStorage(shared_ptr_storage<T> *storage); - void detachStorage(); - - public: - weak_ptr(); - weak_ptr(const shared_ptr<T> &t); - weak_ptr(const weak_ptr<T> &t); - ~weak_ptr(); - - const weak_ptr<T> &operator = (const weak_ptr<T> &t); - const weak_ptr<T> &operator = (const shared_ptr<T> &t); - - T* operator -> () const; - T& operator * () const; - bool isNull() const; - void reset(); - - bool operator == (const weak_ptr<T> &t) const; - bool operator != (const weak_ptr<T> &t) const; - bool operator < (const weak_ptr<T> &t) const; - bool operator > (const weak_ptr<T> &t) const; - bool operator <= (const weak_ptr<T> &t) const; - bool operator >= (const weak_ptr<T> &t) const; - bool operator == (const shared_ptr<T> &t) const; - bool operator != (const shared_ptr<T> &t) const; - bool operator < (const shared_ptr<T> &t) const; - bool operator > (const shared_ptr<T> &t) const; - bool operator <= (const shared_ptr<T> &t) const; - bool operator >= (const shared_ptr<T> &t) const; -}; - -template<class T> -inline shared_ptr_storage<T>::shared_ptr_storage(T *pointer) { - myPointer = pointer; - myCounter = 0; - myWeakCounter = 0; -} -template<class T> -inline shared_ptr_storage<T>::~shared_ptr_storage() { -} -template<class T> -inline T* shared_ptr_storage<T>::pointer() const { - return myPointer; -} -template<class T> -inline T& shared_ptr_storage<T>::content() const { - return *myPointer; -} -template<class T> -inline void shared_ptr_storage<T>::addReference() { - ++myCounter; -} -template<class T> -inline void shared_ptr_storage<T>::removeReference() { - --myCounter; - if (myCounter == 0) { - T* ptr = myPointer; - myPointer = 0; - delete ptr; - } -} -template<class T> -inline void shared_ptr_storage<T>::addWeakReference() { - ++myWeakCounter; -} -template<class T> -inline void shared_ptr_storage<T>::removeWeakReference() { - --myWeakCounter; -} -template<class T> -inline unsigned int shared_ptr_storage<T>::counter() const { - return myCounter + myWeakCounter; -} - -template<class T> -inline shared_ptr_storage<T> *shared_ptr<T>::newStorage(T *t) { - return (t == 0) ? 0 : new shared_ptr_storage<T>(t); -} -template<class T> -inline void shared_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) { - myStorage = storage; - if (myStorage != 0) { - myStorage->addReference(); - } -} -template<class T> -inline void shared_ptr<T>::detachStorage() { - if (myStorage != 0) { - if (myStorage->counter() == 1) { - myStorage->removeReference(); - delete myStorage; - } else { - myStorage->removeReference(); - } - } -} - -template<class T> -inline shared_ptr<T>::shared_ptr() { - myStorage = 0; -} -template<class T> -inline shared_ptr<T>::shared_ptr(T *t) { - attachStorage(newStorage(t)); -} -template<class T> -inline shared_ptr<T>::shared_ptr(const shared_ptr<T> &t) { - attachStorage(t.myStorage); -} -template<class T> -inline shared_ptr<T>::shared_ptr(const weak_ptr<T> &t) { - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } -} -template<class T> -inline shared_ptr<T>::~shared_ptr() { - detachStorage(); -} -template<class T> -inline const shared_ptr<T> &shared_ptr<T>::operator = (T *t) { - detachStorage(); - attachStorage(newStorage(t)); - return *this; -} -template<class T> -inline const shared_ptr<T> &shared_ptr<T>::operator = (const shared_ptr<T> &t) { - if (&t != this) { - detachStorage(); - attachStorage(t.myStorage); - } - return *this; -} -template<class T> -inline const shared_ptr<T> &shared_ptr<T>::operator = (const weak_ptr<T> &t) { - detachStorage(); - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } - return *this; -} - -template<class T> -inline T* shared_ptr<T>::operator -> () const { - return (myStorage == 0) ? 0 : myStorage->pointer(); -} -template<class T> -inline T& shared_ptr<T>::operator * () const { - return myStorage->content(); -} -template<class T> -inline bool shared_ptr<T>::isNull() const { - return myStorage == 0; -} -template<class T> -inline void shared_ptr<T>::reset() { - detachStorage(); - attachStorage(0); -} -template<class T> -inline bool shared_ptr<T>::operator == (const weak_ptr<T> &t) const { - return operator -> () == t.operator -> (); -} -template<class T> -inline bool shared_ptr<T>::operator != (const weak_ptr<T> &t) const { - return !operator == (t); -} -template<class T> -inline bool shared_ptr<T>::operator < (const weak_ptr<T> &t) const { - return operator -> () < t.operator -> (); -} -template<class T> -inline bool shared_ptr<T>::operator > (const weak_ptr<T> &t) const { - return t.operator < (*this); -} -template<class T> -inline bool shared_ptr<T>::operator <= (const weak_ptr<T> &t) const { - return !t.operator < (*this); -} -template<class T> -inline bool shared_ptr<T>::operator >= (const weak_ptr<T> &t) const { - return !operator < (t); -} -template<class T> -inline bool shared_ptr<T>::operator == (const shared_ptr<T> &t) const { - return operator -> () == t.operator -> (); -} -template<class T> -inline bool shared_ptr<T>::operator != (const shared_ptr<T> &t) const { - return !operator == (t); -} -template<class T> -inline bool shared_ptr<T>::operator < (const shared_ptr<T> &t) const { - return operator -> () < t.operator -> (); -} -template<class T> -inline bool shared_ptr<T>::operator > (const shared_ptr<T> &t) const { - return t.operator < (*this); -} -template<class T> -inline bool shared_ptr<T>::operator <= (const shared_ptr<T> &t) const { - return !t.operator < (*this); -} -template<class T> -inline bool shared_ptr<T>::operator >= (const shared_ptr<T> &t) const { - return !operator < (t); -} - -template<class T> -inline void weak_ptr<T>::attachStorage(shared_ptr_storage<T> *storage) { - myStorage = storage; - if (myStorage != 0) { - myStorage->addWeakReference(); - } -} -template<class T> -inline void weak_ptr<T>::detachStorage() { - if (myStorage != 0) { - myStorage->removeWeakReference(); - if (myStorage->counter() == 0) { - delete myStorage; - } - } -} - -template<class T> -inline weak_ptr<T>::weak_ptr() { - myStorage = 0; -} -template<class T> -inline weak_ptr<T>::weak_ptr(const shared_ptr<T> &t) { - attachStorage(t.myStorage); -} -template<class T> -inline weak_ptr<T>::weak_ptr(const weak_ptr<T> &t) { - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } -} -template<class T> -inline weak_ptr<T>::~weak_ptr() { - detachStorage(); -} - -template<class T> -inline const weak_ptr<T> &weak_ptr<T>::operator = (const weak_ptr<T> &t) { - if (&t != this) { - detachStorage(); - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } - } - return *this; -} -template<class T> -inline const weak_ptr<T> &weak_ptr<T>::operator = (const shared_ptr<T> &t) { - detachStorage(); - attachStorage(t.myStorage); - return *this; -} - -template<class T> -inline T* weak_ptr<T>::operator -> () const { - return (myStorage == 0) ? 0 : myStorage->pointer(); -} -template<class T> -inline T& weak_ptr<T>::operator * () const { - return myStorage->content(); -} -template<class T> -inline bool weak_ptr<T>::isNull() const { - return (myStorage == 0) || (myStorage->pointer() == 0); -} -template<class T> -inline void weak_ptr<T>::reset() { - detachStorage(); - attachStorage(0); -} -template<class T> -inline bool weak_ptr<T>::operator == (const weak_ptr<T> &t) const { - return operator -> () == t.operator -> (); -} -template<class T> -inline bool weak_ptr<T>::operator != (const weak_ptr<T> &t) const { - return !operator == (t); -} -template<class T> -inline bool weak_ptr<T>::operator < (const weak_ptr<T> &t) const { - return operator -> () < t.operator -> (); -} -template<class T> -inline bool weak_ptr<T>::operator > (const weak_ptr<T> &t) const { - return t.operator < (*this); -} -template<class T> -inline bool weak_ptr<T>::operator <= (const weak_ptr<T> &t) const { - return !t.operator < (*this); -} -template<class T> -inline bool weak_ptr<T>::operator >= (const weak_ptr<T> &t) const { - return !operator < (t); -} -template<class T> -inline bool weak_ptr<T>::operator == (const shared_ptr<T> &t) const { - return operator -> () == t.operator -> (); -} -template<class T> -inline bool weak_ptr<T>::operator != (const shared_ptr<T> &t) const { - return !operator == (t); -} -template<class T> -inline bool weak_ptr<T>::operator < (const shared_ptr<T> &t) const { - return operator -> () < t.operator -> (); -} -template<class T> -inline bool weak_ptr<T>::operator > (const shared_ptr<T> &t) const { - return t.operator < (*this); -} -template<class T> -inline bool weak_ptr<T>::operator <= (const shared_ptr<T> &t) const { - return !t.operator < (*this); -} -template<class T> -inline bool weak_ptr<T>::operator >= (const shared_ptr<T> &t) const { - return !operator < (t); -} - -#endif /* __SHARED_PTR_H__ */ diff --git a/zlibrary/core/src/view/ZLMirroredPaintContext.h b/zlibrary/core/src/view/ZLMirroredPaintContext.h deleted file mode 100644 index ff7272d..0000000 --- a/zlibrary/core/src/view/ZLMirroredPaintContext.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLMIRROREDPAINTCONTEXT_H__ -#define __ZLMIRROREDPAINTCONTEXT_H__ - -#include <vector> -#include <string> - -#include <ZLColor.h> -#include <ZLPaintContext.h> - -class ZLMirroredPaintContext : public ZLPaintContext { - -public: - ZLMirroredPaintContext(ZLPaintContext &base); - -public: - int mirroredX(int x) const; - -private: - void clear(ZLColor color); - - void setFont(const std::string &family, int size, bool bold, bool italic); - void setColor(ZLColor color, LineStyle style); - void setFillColor(ZLColor color, FillStyle style); - - int width() const; - int height() const; - - int stringWidth(const char *str, int len, bool rtl) const; - int spaceWidth() const; - int stringHeight() const; - int descent() const; - void drawString(int x, int y, const char *str, int len, bool rtl); - - void drawImage(int x, int y, const ZLImageData &image); - void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type); - - void drawLine(int x0, int y0, int x1, int y1); - void fillRectangle(int x0, int y0, int x1, int y1); - void drawFilledCircle(int x, int y, int r); - - const std::string realFontFamilyName(std::string &fontFamily) const; - - void fillFamiliesList(std::vector<std::string> &families) const; - -private: - ZLPaintContext &myBase; -}; - -inline int ZLMirroredPaintContext::mirroredX(int x) const { - return myBase.width() - x - 1; -} - -#endif /* __ZLMIRROREDPAINTCONTEXT_H__ */ diff --git a/zlibrary/core/src/view/ZLPaintContext.h b/zlibrary/core/src/view/ZLPaintContext.h deleted file mode 100644 index 7597a33..0000000 --- a/zlibrary/core/src/view/ZLPaintContext.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLPAINTCONTEXT_H__ -#define __ZLPAINTCONTEXT_H__ - -#include <vector> -#include <string> - -#include <ZLColor.h> -#include <ZLImageManager.h> - -class ZLPaintContext { - -public: - enum LineStyle { - SOLID_LINE, - DASH_LINE, - }; - - enum FillStyle { - SOLID_FILL, - HALF_FILL, - }; - -protected: - ZLPaintContext(); - -public: - virtual ~ZLPaintContext(); - - virtual void clear(ZLColor color) = 0; - - virtual void setFont(const std::string &family, int size, bool bold, bool italic) = 0; - virtual void setColor(ZLColor color, LineStyle style = SOLID_LINE) = 0; - virtual void setFillColor(ZLColor color, FillStyle style = SOLID_FILL) = 0; - - virtual int width() const = 0; - virtual int height() const = 0; - - virtual int stringWidth(const char *str, int len, bool rtl) const = 0; - virtual int spaceWidth() const = 0; - virtual int stringHeight() const = 0; - virtual int descent() const = 0; - virtual void drawString(int x, int y, const char *str, int len, bool rtl) = 0; - - enum ScalingType { - SCALE_FIT_TO_SIZE, - SCALE_REDUCE_SIZE - }; - - int imageWidth(const ZLImageData &image) const; - int imageHeight(const ZLImageData &image) const; - int imageWidth(const ZLImageData &image, int width, int height, ScalingType type) const; - int imageHeight(const ZLImageData &image, int width, int height, ScalingType type) const; - virtual void drawImage(int x, int y, const ZLImageData &image) = 0; - virtual void drawImage(int x, int y, const ZLImageData &image, int width, int height, ScalingType type) = 0; - - virtual void drawLine(int x0, int y0, int x1, int y1) = 0; - virtual void fillRectangle(int x0, int y0, int x1, int y1) = 0; - virtual void drawFilledCircle(int x, int y, int r) = 0; - - const std::vector<std::string> &fontFamilies() const; - virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0; - -protected: - virtual void fillFamiliesList(std::vector<std::string> &families) const = 0; - -private: - mutable std::vector<std::string> myFamilies; - -private: - ZLPaintContext(const ZLPaintContext&); - const ZLPaintContext &operator = (const ZLPaintContext&); - -friend class ZLMirroredPaintContext; -}; - -inline int ZLPaintContext::imageWidth(const ZLImageData &image) const { return image.width(); } -inline int ZLPaintContext::imageHeight(const ZLImageData &image) const { return image.height(); } - -#endif /* __ZLPAINTCONTEXT_H__ */ diff --git a/zlibrary/core/src/view/ZLView.h b/zlibrary/core/src/view/ZLView.h deleted file mode 100644 index bc8e42b..0000000 --- a/zlibrary/core/src/view/ZLView.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLVIEW_H__ -#define __ZLVIEW_H__ - -#include <string> - -#include <shared_ptr.h> - -#include <ZLColor.h> -#include <ZLTypeId.h> - -class ZLViewWidget; -class ZLPaintContext; - -class ZLView : public ZLObjectWithRTTI { - -public: - enum Angle { - DEGREES0 = 0, - DEGREES90 = 90, - DEGREES180 = 180, - DEGREES270 = 270 - }; - - enum Direction { - VERTICAL, - HORIZONTAL - }; - -protected: - static const ZLTypeId TYPE_ID; - -public: - ZLView(ZLPaintContext &context); - virtual ~ZLView(); - - virtual const std::string &caption() const = 0; - virtual void paint() = 0; - ZLPaintContext &context() const; - - /* - * returns true iff stylus/finger event was processed - */ - virtual bool onStylusPress(int x, int y); - virtual bool onStylusRelease(int x, int y); - virtual bool onStylusMove(int x, int y); - virtual bool onStylusMovePressed(int x, int y); - virtual bool onFingerTap(int x, int y); - -protected: - const ZLTypeId &typeId() const; - - virtual ZLColor backgroundColor() const = 0; - - void setScrollbarEnabled(Direction direction, bool enabled); - void setScrollbarParameters(Direction direction, std::size_t full, std::size_t from, std::size_t to); - virtual void onScrollbarMoved(Direction direction, std::size_t full, std::size_t from, std::size_t to); - virtual void onScrollbarStep(Direction direction, int steps); - virtual void onScrollbarPageStep(Direction direction, int steps); - -private: - struct ScrollBarInfo { - ScrollBarInfo(); - - bool Enabled; - bool StandardLocation; - std::size_t Full; - std::size_t From; - std::size_t To; - }; - - void updateScrollbarState(); - void updateScrollbarPlacement(); - void updateScrollbarParameters(); - void updateScrollbarParameters(Direction direction, const ScrollBarInfo &info, bool invert); - -private: - ZLViewWidget *myViewWidget; - ZLPaintContext &myContext; - ScrollBarInfo myVerticalScrollbarInfo; - ScrollBarInfo myHorizontalScrollbarInfo; - -private: - ZLView(const ZLView&); - const ZLView &operator=(const ZLView&); - -friend class ZLViewWidget; -}; - -inline ZLPaintContext &ZLView::context() const { return myContext; } - -#endif /* __ZLVIEW_H__ */ diff --git a/zlibrary/core/src/xml/ZLXMLReader.cpp b/zlibrary/core/src/xml/ZLXMLReader.cpp index 9e73383..4a0ca36 100644 --- a/zlibrary/core/src/xml/ZLXMLReader.cpp +++ b/zlibrary/core/src/xml/ZLXMLReader.cpp @@ -21,16 +21,13 @@ #include <algorithm> +#include "ZLAsynchronousInputStream.h" #include <ZLFile.h> #include <ZLInputStream.h> #include <ZLStringUtil.h> #include <ZLUnicodeUtil.h> - -#include "ZLAsynchronousInputStream.h" - #include "ZLXMLReader.h" - -#include "expat/ZLXMLReaderInternal.h" +#include "ZLXMLReaderInternal.h" class ZLXMLReaderHandler : public ZLAsynchronousInputStream::Handler { diff --git a/zlibrary/core/src/xml/ZLXMLReader.h b/zlibrary/core/src/xml/ZLXMLReader.h deleted file mode 100644 index c3c4c41..0000000 --- a/zlibrary/core/src/xml/ZLXMLReader.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLXMLREADER_H__ -#define __ZLXMLREADER_H__ - -#include <string> -#include <vector> -#include <map> - -#include <shared_ptr.h> - -class ZLFile; -class ZLInputStream; -class ZLAsynchronousInputStream; -class ZLXMLReaderInternal; - -class ZLXMLReader { - -public: - class AttributeNamePredicate { - - public: - virtual ~AttributeNamePredicate(); - virtual bool accepts(const ZLXMLReader &reader, const char *name) const = 0; - }; - - class FixedAttributeNamePredicate : public AttributeNamePredicate { - - public: - FixedAttributeNamePredicate(const std::string &attributeName); - bool accepts(const ZLXMLReader &reader, const char *name) const; - - private: - const std::string myAttributeName; - }; - - class NamespaceAttributeNamePredicate : public AttributeNamePredicate { - - public: - NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name); - bool accepts(const ZLXMLReader &reader, const char *name) const; - - private: - const std::string myNamespaceName; - const std::string myAttributeName; - }; - -protected: - ZLXMLReader(const char *encoding = 0); - -public: - virtual ~ZLXMLReader(); - - bool readDocument(const ZLFile &file); - bool readDocument(shared_ptr<ZLInputStream> stream); - bool readDocument(shared_ptr<ZLAsynchronousInputStream> stream); - - const std::string &errorMessage() const; - - typedef std::map<std::string,std::string> nsMap; - const nsMap &namespaces() const; - - const char *attributeValue(const char **xmlattributes, const char *name); - const char *attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate); - static std::map<std::string,std::string> getAttributesMap(const char **xmlattributes); - -private: - void initialize(const char *encoding = 0); - void shutdown(); - bool readFromBuffer(const char *data, std::size_t len); - -protected: - virtual void startElementHandler(const char *tag, const char **attributes); - virtual void endElementHandler(const char *tag); - virtual void characterDataHandler(const char *text, std::size_t len); - virtual bool processNamespaces() const; - virtual const std::vector<std::string> &externalDTDs() const; - virtual void collectExternalEntities(std::map<std::string,std::string> &entityMap); - - bool testTag(const std::string &ns, const std::string &name, const std::string &tag) const; - bool isInterrupted() const; - std::size_t getCurrentPosition() const; - -protected: - void interrupt(); - void setErrorMessage(const std::string &message); - -private: - bool myInterrupted; - ZLXMLReaderInternal *myInternalReader; - char *myParserBuffer; - std::vector<shared_ptr<nsMap> > myNamespaces; - - std::string myErrorMessage; - -friend class ZLXMLReaderInternal; -friend class ZLXMLReaderHandler; -}; - -inline bool ZLXMLReader::isInterrupted() const { - return myInterrupted; -} - -inline void ZLXMLReader::interrupt() { - myInterrupted = true; -} - -#endif /* __ZLXMLREADER_H__ */ diff --git a/zlibrary/core/src/xml/ZLXMLWriter.h b/zlibrary/core/src/xml/ZLXMLWriter.h deleted file mode 100644 index 5966f1c..0000000 --- a/zlibrary/core/src/xml/ZLXMLWriter.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2004-2012 Geometer Plus <[email protected]> - * - * 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 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 Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef __ZLXMLWRITER_H__ -#define __ZLXMLWRITER_H__ - -#include <stack> -#include <vector> -#include <string> - -#include <ZLOutputStream.h> - -class ZLXMLWriter { - -private: - struct Attribute { - std::string Name; - std::string Value; - - Attribute(const std::string &name, const std::string &value); - ~Attribute(); - }; - - class Tag { - - public: - Tag(const std::string &name, bool single); - ~Tag(); - void addAttribute(const std::string &name, const std::string &value); - void addData(const std::string &data); - bool isSingle() const; - bool isDataEmpty() const; - - void writeStart(ZLOutputStream &stream) const; - void writeEnd(ZLOutputStream &stream) const; - - private: - std::string myName; - std::string myData; - bool mySingle; - std::vector<Attribute> myAttributes; - }; - -protected: - ZLXMLWriter(ZLOutputStream &stream); - virtual ~ZLXMLWriter(); - - void addTag(const std::string &name, bool single); - void addAttribute(const std::string &name, const std::string &value); - void addData(const std::string &data); - void closeTag(); - void closeAllTags(); - -private: - void flushTagStart(); - -private: - ZLOutputStream &myStream; - Tag *myCurrentTag; - std::stack<Tag*> myTags; -}; - -inline ZLXMLWriter::Attribute::Attribute(const std::string &name, const std::string &value) : Name(name), Value(value) {} -inline ZLXMLWriter::Attribute::~Attribute() {} - -inline bool ZLXMLWriter::Tag::isSingle() const { return mySingle; } -inline bool ZLXMLWriter::Tag::isDataEmpty() const { return myData.empty(); } -inline ZLXMLWriter::Tag::~Tag() {} - -inline ZLXMLWriter::~ZLXMLWriter() {} - -#endif /* __ZLXMLWRITER_H__ */ diff --git a/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp b/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp index 923e4d4..26af0fa 100644 --- a/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp +++ b/zlibrary/core/src/xml/expat/ZLXMLReaderInternal.cpp @@ -24,7 +24,7 @@ #include <ZLEncodingConverter.h> #include "ZLXMLReaderInternal.h" -#include "../ZLXMLReader.h" +#include "ZLXMLReader.h" void ZLXMLReaderInternal::fCharacterDataHandler(void *userData, const char *text, int len) { ZLXMLReader &reader = *(ZLXMLReader*)userData; diff --git a/zlibrary/text/src/area/ZLTextAreaStyle.cpp b/zlibrary/text/src/area/ZLTextAreaStyle.cpp index 5298840..46ecee8 100644 --- a/zlibrary/text/src/area/ZLTextAreaStyle.cpp +++ b/zlibrary/text/src/area/ZLTextAreaStyle.cpp @@ -28,7 +28,7 @@ #include "ZLTextAreaStyle.h" #include "ZLTextParagraphCursor.h" #include "ZLTextElement.h" -#include "../style/ZLTextDecoratedStyle.h" +#include "ZLTextDecoratedStyle.h" ZLTextArea::Style::Style(const ZLTextArea &area, shared_ptr<ZLTextStyle> style) : myArea(area) { myTextStyle = style; diff --git a/zlibrary/text/src/styleOptions/ZLTextStyleOptions.h b/zlibrary/text/src/styleOptions/ZLTextStyleOptions.h index aea6d4e..d07dd0f 100644 --- a/zlibrary/text/src/styleOptions/ZLTextStyleOptions.h +++ b/zlibrary/text/src/styleOptions/ZLTextStyleOptions.h @@ -24,7 +24,7 @@ #include <ZLResource.h> #include <ZLOptionEntry.h> -#include <optionEntries/ZLFontFamilyOptionEntry.h> +#include <ZLFontFamilyOptionEntry.h> class ZLPaintContext; diff --git a/zlibrary/text/src/view/ZLTextSelectionScroller.cpp b/zlibrary/text/src/view/ZLTextSelectionScroller.cpp index eef6cfa..bb38034 100644 --- a/zlibrary/text/src/view/ZLTextSelectionScroller.cpp +++ b/zlibrary/text/src/view/ZLTextSelectionScroller.cpp @@ -21,7 +21,7 @@ #include "ZLTextSelectionScroller.h" #include "ZLTextView.h" -#include "../area/ZLTextSelectionModel.h" +#include "ZLTextSelectionModel.h" ZLTextSelectionScroller::ZLTextSelectionScroller(ZLTextView &view) : myView(view), myDirection(DONT_SCROLL) { } diff --git a/zlibrary/text/src/view/ZLTextView.cpp b/zlibrary/text/src/view/ZLTextView.cpp index 8b6de0c..8b63fe1 100644 --- a/zlibrary/text/src/view/ZLTextView.cpp +++ b/zlibrary/text/src/view/ZLTextView.cpp @@ -28,11 +28,11 @@ #include "ZLTextView.h" #include "ZLTextSelectionScroller.h" #include "ZLTextPositionIndicator.h" -#include "../area/ZLTextSelectionModel.h" -#include "../area/ZLTextLineInfo.h" -#include "../area/ZLTextParagraphCursor.h" -#include "../area/ZLTextWord.h" -#include "../area/ZLTextAreaStyle.h" +#include "ZLTextSelectionModel.h" +#include "ZLTextLineInfo.h" +#include "ZLTextParagraphCursor.h" +#include "ZLTextWord.h" +#include "ZLTextAreaStyle.h" const ZLTypeId ZLTextView::TYPE_ID(ZLView::TYPE_ID); |