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 #include #include -#include +#include #include #include 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 #include -#include +#include #include #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 #include -#include +#include #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 #include -#include -#include +#include +#include #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 #include -#include -#include +#include +#include #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 #include -#include -#include +#include +#include #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 #include -#include -#include -#include +#include +#include +#include #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 -#include +#include #include #include 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 #include -#include -#include +#include +#include #include 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 #include -#include +#include #include #include 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 #include #include -#include -#include +#include +#include #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 -#include +#include #include 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 #include -#include -#include +#include +#include #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 #include -#include -#include +#include +#include #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 #include -#include -#include -#include +#include +#include +#include #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 @@ -6,6 +6,11 @@ _tde_internal_setup_path( "Base directory for zlibrary-tqt files which go to share" ) +_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 similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/AsciiEncoder.h rename to zlibrary/core/include/AsciiEncoder.h diff --git a/zlibrary/core/src/encoding/DummyEncodingConverter.h b/zlibrary/core/include/DummyEncodingConverter.h similarity index 100% rename from zlibrary/core/src/encoding/DummyEncodingConverter.h rename to zlibrary/core/include/DummyEncodingConverter.h diff --git a/zlibrary/core/src/encoding/EncodingCollectionReader.h b/zlibrary/core/include/EncodingCollectionReader.h similarity index 100% rename from zlibrary/core/src/encoding/EncodingCollectionReader.h rename to zlibrary/core/include/EncodingCollectionReader.h diff --git a/zlibrary/core/src/unix/iconv/IConvEncodingConverter.h b/zlibrary/core/include/IConvEncodingConverter.h similarity index 95% rename from zlibrary/core/src/unix/iconv/IConvEncodingConverter.h rename to 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 -#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 similarity index 100% rename from zlibrary/core/src/encoding/MyEncodingConverter.h rename to zlibrary/core/include/MyEncodingConverter.h diff --git a/zlibrary/core/src/encoding/Utf8EncodingConverter.h b/zlibrary/core/include/Utf8EncodingConverter.h similarity index 100% rename from zlibrary/core/src/encoding/Utf8EncodingConverter.h rename to zlibrary/core/include/Utf8EncodingConverter.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfig.h b/zlibrary/core/include/XMLConfig.h similarity index 99% rename from zlibrary/core/src/unix/xmlconfig/XMLConfig.h rename to 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 #include -#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 similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/XMLConfigDelta.h rename to zlibrary/core/include/XMLConfigDelta.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigDeltaWriter.h b/zlibrary/core/include/XMLConfigDeltaWriter.h similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/XMLConfigDeltaWriter.h rename to zlibrary/core/include/XMLConfigDeltaWriter.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigReader.h b/zlibrary/core/include/XMLConfigReader.h similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/XMLConfigReader.h rename to zlibrary/core/include/XMLConfigReader.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigValue.h b/zlibrary/core/include/XMLConfigValue.h similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/XMLConfigValue.h rename to zlibrary/core/include/XMLConfigValue.h diff --git a/zlibrary/core/src/unix/xmlconfig/XMLConfigWriter.h b/zlibrary/core/include/XMLConfigWriter.h similarity index 100% rename from zlibrary/core/src/unix/xmlconfig/XMLConfigWriter.h rename to zlibrary/core/include/XMLConfigWriter.h diff --git a/zlibrary/core/include/ZLApplication.h b/zlibrary/core/include/ZLApplication.h deleted file mode 120000 index 4648d93..0000000 --- a/zlibrary/core/include/ZLApplication.h +++ /dev/null @@ -1 +0,0 @@ -../src/application/ZLApplication.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLApplication.h b/zlibrary/core/include/ZLApplication.h new file mode 100644 index 0000000..cdffa6c --- /dev/null +++ b/zlibrary/core/include/ZLApplication.h @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +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 &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); + void registerPopupData(const std::string &actionId, shared_ptr popupData); + + void setView(shared_ptr view); + ZLView::Angle rotation() const; + + void setFullscreen(bool fullscreen); + bool isFullscreen() const; + +public: + virtual ~ZLApplication(); + virtual void initWindow(); + + shared_ptr currentView() const; + shared_ptr context(); + + void grabAllKeys(bool grab); + void trackStylus(bool track); + + void resetWindowCaption(); + void setHyperlinkCursor(bool hyperlink); + + shared_ptr 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 keyBindings(); + void doActionByKey(const std::string &key); + + void quit(); + virtual bool closeView(); + virtual void openFile(const ZLFile &file); + virtual bool canDragFiles(const std::vector &filePaths) const; + virtual void dragFiles(const std::vector &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 &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 myViewWidget; + shared_ptr myInitialView; + std::map > myActionMap; + mutable shared_ptr myToolbar; + mutable shared_ptr myFullscreenToolbar; + mutable shared_ptr myMenubar; + shared_ptr myContext; + shared_ptr myWindow; + ZLTime myLastKeyActionTime; + shared_ptr 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 similarity index 100% rename from zlibrary/core/src/application/ZLApplicationWindow.h rename to zlibrary/core/include/ZLApplicationWindow.h diff --git a/zlibrary/core/include/ZLAsynchronousInputStream.h b/zlibrary/core/include/ZLAsynchronousInputStream.h deleted file mode 120000 index 818ae7f..0000000 --- a/zlibrary/core/include/ZLAsynchronousInputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/network/ZLAsynchronousInputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLAsynchronousInputStream.h b/zlibrary/core/include/ZLAsynchronousInputStream.h new file mode 100644 index 0000000..371d703 --- /dev/null +++ b/zlibrary/core/include/ZLAsynchronousInputStream.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + + +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 deleted file mode 120000 index fad684e..0000000 --- a/zlibrary/core/include/ZLBase64EncodedImage.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLBase64EncodedImage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLBase64EncodedImage.h b/zlibrary/core/include/ZLBase64EncodedImage.h new file mode 100644 index 0000000..9e7a61e --- /dev/null +++ b/zlibrary/core/include/ZLBase64EncodedImage.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include + +class ZLBase64EncodedImage : public ZLSingleImage { + +public: + ZLBase64EncodedImage(shared_ptr mimeType); + ~ZLBase64EncodedImage(); + void addData(const std::string &text, std::size_t offset, std::size_t len); + void addData(const std::vector &text); + const shared_ptr stringData() const; + +private: + void decode() const; + +private: + mutable std::string myEncodedData; + mutable shared_ptr myData; +}; + +inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr mimeType) : ZLSingleImage(mimeType) {} +inline ZLBase64EncodedImage::~ZLBase64EncodedImage() {} + +#endif /* __ZLBASE64ENCODEDIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLBase64InputStream.h b/zlibrary/core/include/ZLBase64InputStream.h deleted file mode 120000 index f326dae..0000000 --- a/zlibrary/core/include/ZLBase64InputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLBase64InputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLBase64InputStream.h b/zlibrary/core/include/ZLBase64InputStream.h new file mode 100644 index 0000000..4a073d6 --- /dev/null +++ b/zlibrary/core/include/ZLBase64InputStream.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +class ZLBase64InputStream : public ZLInputStream { +public: + ZLBase64InputStream(shared_ptr 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 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 deleted file mode 120000 index de7022d..0000000 --- a/zlibrary/core/include/ZLBlockTreeNode.h +++ /dev/null @@ -1 +0,0 @@ -../src/blockTreeView/ZLBlockTreeNode.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLBlockTreeNode.h b/zlibrary/core/include/ZLBlockTreeNode.h new file mode 100644 index 0000000..38b4a9e --- /dev/null +++ b/zlibrary/core/include/ZLBlockTreeNode.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 +#include + +#include + +#include +#include +#include + +class ZLBlockTreeView; + +class ZLBlockTreeNode : public ZLObjectWithRTTI { + +public: + typedef std::vector 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 action); + void removeAllHyperlinks(); + +private: + ZLBlockTreeView &myView; + ZLBlockTreeNode *myParent; + std::size_t myChildIndex; + + List myChildren; + bool myIsOpen; + + typedef std::map > 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 deleted file mode 120000 index 5fc578c..0000000 --- a/zlibrary/core/include/ZLBlockTreeView.h +++ /dev/null @@ -1 +0,0 @@ -../src/blockTreeView/ZLBlockTreeView.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLBlockTreeView.h b/zlibrary/core/include/ZLBlockTreeView.h new file mode 100644 index 0000000..95d5e9a --- /dev/null +++ b/zlibrary/core/include/ZLBlockTreeView.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +#include + +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 deleted file mode 120000 index f75d4b1..0000000 --- a/zlibrary/core/include/ZLBoolean3.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLBoolean3.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLBoolean3.h b/zlibrary/core/include/ZLBoolean3.h new file mode 100644 index 0000000..7371c41 --- /dev/null +++ b/zlibrary/core/include/ZLBoolean3.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 similarity index 98% rename from zlibrary/core/src/filesystem/bzip2/ZLBzip2InputStream.h rename to 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 -#include "../ZLInputStream.h" +#include "ZLInputStream.h" class ZLFSCompressorBzip2; diff --git a/zlibrary/core/src/language/ZLCharSequence.h b/zlibrary/core/include/ZLCharSequence.h similarity index 100% rename from zlibrary/core/src/language/ZLCharSequence.h rename to zlibrary/core/include/ZLCharSequence.h diff --git a/zlibrary/core/include/ZLColor.h b/zlibrary/core/include/ZLColor.h deleted file mode 120000 index 7d199ce..0000000 --- a/zlibrary/core/include/ZLColor.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLColor.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLColor.h b/zlibrary/core/include/ZLColor.h new file mode 100644 index 0000000..59926a4 --- /dev/null +++ b/zlibrary/core/include/ZLColor.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 similarity index 100% rename from zlibrary/core/src/optionEntries/ZLColorOptionBuilder.h rename to zlibrary/core/include/ZLColorOptionBuilder.h diff --git a/zlibrary/core/src/options/ZLConfig.h b/zlibrary/core/include/ZLConfig.h similarity index 100% rename from zlibrary/core/src/options/ZLConfig.h rename to zlibrary/core/include/ZLConfig.h diff --git a/zlibrary/core/src/desktop/application/ZLDesktopApplicationWindow.h b/zlibrary/core/include/ZLDesktopApplicationWindow.h similarity index 96% rename from zlibrary/core/src/desktop/application/ZLDesktopApplicationWindow.h rename to 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 -#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 similarity index 100% rename from zlibrary/core/src/desktop/dialogs/ZLDesktopOpenFileDialog.h rename to zlibrary/core/include/ZLDesktopOpenFileDialog.h diff --git a/zlibrary/core/src/desktop/dialogs/ZLDesktopOptionsDialog.h b/zlibrary/core/include/ZLDesktopOptionsDialog.h similarity index 100% rename from zlibrary/core/src/desktop/dialogs/ZLDesktopOptionsDialog.h rename to zlibrary/core/include/ZLDesktopOptionsDialog.h diff --git a/zlibrary/core/include/ZLDialog.h b/zlibrary/core/include/ZLDialog.h deleted file mode 120000 index 7e9423b..0000000 --- a/zlibrary/core/include/ZLDialog.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLDialog.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLDialog.h b/zlibrary/core/include/ZLDialog.h new file mode 100644 index 0000000..6bd29a5 --- /dev/null +++ b/zlibrary/core/include/ZLDialog.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +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 deleted file mode 120000 index fcec7db..0000000 --- a/zlibrary/core/include/ZLDialogContent.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLDialogContent.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLDialogContent.h b/zlibrary/core/include/ZLDialogContent.h new file mode 100644 index 0000000..a39415d --- /dev/null +++ b/zlibrary/core/include/ZLDialogContent.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include + +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 myViews; +}; + +#endif /* __ZLDIALOGCONTENT_H__ */ diff --git a/zlibrary/core/src/dialogs/ZLDialogContentBuilder.h b/zlibrary/core/include/ZLDialogContentBuilder.h similarity index 100% rename from zlibrary/core/src/dialogs/ZLDialogContentBuilder.h rename to zlibrary/core/include/ZLDialogContentBuilder.h diff --git a/zlibrary/core/include/ZLDialogManager.h b/zlibrary/core/include/ZLDialogManager.h deleted file mode 120000 index 1bcf3cf..0000000 --- a/zlibrary/core/include/ZLDialogManager.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLDialogManager.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLDialogManager.h b/zlibrary/core/include/ZLDialogManager.h new file mode 100644 index 0000000..8d84d0c --- /dev/null +++ b/zlibrary/core/include/ZLDialogManager.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include +#include +#include +#include +#include + +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 createDialog(const ZLResourceKey &key) const = 0; + virtual shared_ptr createOptionsDialog(const ZLResourceKey &key, shared_ptr applyAction = 0, bool showApplyButton = false) const = 0; + virtual shared_ptr createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0; + virtual shared_ptr 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 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 deleted file mode 120000 index e7d4ad4..0000000 --- a/zlibrary/core/include/ZLDir.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/ZLDir.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLDir.h b/zlibrary/core/include/ZLDir.h new file mode 100644 index 0000000..d353391 --- /dev/null +++ b/zlibrary/core/include/ZLDir.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include + +class ZLDir { + +public: + static shared_ptr 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 &names, bool includeSymlinks) = 0; + virtual void collectFiles(std::vector &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 deleted file mode 120000 index 209f67a..0000000 --- a/zlibrary/core/include/ZLEncodingConverter.h +++ /dev/null @@ -1 +0,0 @@ -../src/encoding/ZLEncodingConverter.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLEncodingConverter.h b/zlibrary/core/include/ZLEncodingConverter.h new file mode 100644 index 0000000..84a61de --- /dev/null +++ b/zlibrary/core/include/ZLEncodingConverter.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +#include + +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 &aliases() const; + shared_ptr createConverter() const; + bool canCreateConverter() const; + +private: + const std::string myName; + const std::string myVisibleName; + std::vector myAliases; + +private: + ZLEncodingConverterInfo(const ZLEncodingConverterInfo&); + ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&); +}; + +typedef shared_ptr ZLEncodingConverterInfoPtr; + +class ZLEncodingSet { + +public: + ZLEncodingSet(const std::string &name); + void addInfo(ZLEncodingConverterInfoPtr info); + + const std::string &name() const; + const std::vector &infos() const; + +private: + const std::string myName; + std::vector 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 > &sets(); + ZLEncodingConverterInfoPtr info(const std::string &name); + ZLEncodingConverterInfoPtr info(int code); + shared_ptr defaultConverter(); + void registerProvider(shared_ptr provider); + +private: + void addInfo(ZLEncodingConverterInfoPtr info); + const std::vector > &providers() const; + +private: + std::vector > mySets; + std::map myInfosByName; + std::vector > 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 similarity index 100% rename from zlibrary/core/src/encoding/ZLEncodingConverterProvider.h rename to zlibrary/core/include/ZLEncodingConverterProvider.h diff --git a/zlibrary/core/include/ZLExecutionUtil.h b/zlibrary/core/include/ZLExecutionUtil.h deleted file mode 120000 index c6270c4..0000000 --- a/zlibrary/core/include/ZLExecutionUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/runnable/ZLExecutionUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLExecutionUtil.h b/zlibrary/core/include/ZLExecutionUtil.h new file mode 100644 index 0000000..83f08a6 --- /dev/null +++ b/zlibrary/core/include/ZLExecutionUtil.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include "ZLNetworkRequest.h" + +class ZLExecutionUtil { + //code for convenient async syntax createListener method: + public: + template + static shared_ptr createListener(shared_ptr data, T object, Method method) { + data->addUserData(ourHandlerId, new HandlerHelper(object, method)); + return createListener(data); + } + template + static shared_ptr createListener(T object, Method method) { + return createListener(new ZLUserDataHolder, object, method); + } + template + static shared_ptr createListener(ZLUserData *scope, T object, Method method) { + shared_ptr 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 + 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 createListener(shared_ptr 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 similarity index 98% rename from zlibrary/core/src/filesystem/tar/ZLFSArchiverTar.h rename to 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 similarity index 98% rename from zlibrary/core/src/filesystem/zip/ZLFSArchiverZip.h rename to 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 similarity index 97% rename from zlibrary/core/src/filesystem/bzip2/ZLFSCompressorBzip2.h rename to 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 similarity index 97% rename from zlibrary/core/src/filesystem/zip/ZLFSCompressorGzip.h rename to 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 similarity index 100% rename from zlibrary/core/src/filesystem/ZLFSDir.h rename to zlibrary/core/include/ZLFSDir.h diff --git a/zlibrary/core/src/filesystem/ZLFSManager.h b/zlibrary/core/include/ZLFSManager.h similarity index 100% rename from zlibrary/core/src/filesystem/ZLFSManager.h rename to zlibrary/core/include/ZLFSManager.h diff --git a/zlibrary/core/src/filesystem/ZLFSPlugin.h b/zlibrary/core/include/ZLFSPlugin.h similarity index 100% rename from zlibrary/core/src/filesystem/ZLFSPlugin.h rename to zlibrary/core/include/ZLFSPlugin.h diff --git a/zlibrary/core/src/filesystem/ZLFSPluginManager.h b/zlibrary/core/include/ZLFSPluginManager.h similarity index 100% rename from zlibrary/core/src/filesystem/ZLFSPluginManager.h rename to zlibrary/core/include/ZLFSPluginManager.h diff --git a/zlibrary/core/include/ZLFile.h b/zlibrary/core/include/ZLFile.h deleted file mode 120000 index 5cdccc7..0000000 --- a/zlibrary/core/include/ZLFile.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/ZLFile.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLFile.h b/zlibrary/core/include/ZLFile.h new file mode 100644 index 0000000..5dae04c --- /dev/null +++ b/zlibrary/core/include/ZLFile.h @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include +#include + +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 > 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 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 mimeType() const; + + std::string physicalFilePath() const; + std::string resolvedPath() const; + + shared_ptr inputStream() const; + shared_ptr outputStream(bool writeThrough = false) const; + shared_ptr 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 envelopeCompressedStream(shared_ptr &base) const; + +private: + std::string myPath; + std::string myNameWithExtension; + std::string myNameWithoutExtension; + std::string myExtension; + mutable shared_ptr 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 deleted file mode 120000 index ccd63ad..0000000 --- a/zlibrary/core/include/ZLFileImage.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLFileImage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLFileImage.h b/zlibrary/core/include/ZLFileImage.h new file mode 100644 index 0000000..ff7ed86 --- /dev/null +++ b/zlibrary/core/include/ZLFileImage.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include + +class ZLFileImage : public ZLSingleImage { + +public: + struct Block { + unsigned int offset; + unsigned int size; + + Block(unsigned int off, unsigned int s); + }; + typedef std::vector 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 stringData() const; + +protected: + //shared_ptr 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 deleted file mode 120000 index 2e46ebc..0000000 --- a/zlibrary/core/include/ZLFileInfo.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/ZLFileInfo.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLFileInfo.h b/zlibrary/core/include/ZLFileInfo.h new file mode 100644 index 0000000..498c926 --- /dev/null +++ b/zlibrary/core/include/ZLFileInfo.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 deleted file mode 120000 index 7466928..0000000 --- a/zlibrary/core/include/ZLFileUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLFileUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLFileUtil.h b/zlibrary/core/include/ZLFileUtil.h new file mode 100644 index 0000000..b76b68d --- /dev/null +++ b/zlibrary/core/include/ZLFileUtil.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010-2012 Geometer Plus + * + * 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 + +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 similarity index 100% rename from zlibrary/core/src/optionEntries/ZLFontFamilyOptionEntry.h rename to zlibrary/core/include/ZLFontFamilyOptionEntry.h diff --git a/zlibrary/core/src/network/ZLGzipAsynchronousInputStream.h b/zlibrary/core/include/ZLGzipAsynchronousInputStream.h similarity index 100% rename from zlibrary/core/src/network/ZLGzipAsynchronousInputStream.h rename to zlibrary/core/include/ZLGzipAsynchronousInputStream.h diff --git a/zlibrary/core/src/image/ZLHexEncodedImage.h b/zlibrary/core/include/ZLHexEncodedImage.h similarity index 100% rename from zlibrary/core/src/image/ZLHexEncodedImage.h rename to zlibrary/core/include/ZLHexEncodedImage.h diff --git a/zlibrary/core/include/ZLHexInputStream.h b/zlibrary/core/include/ZLHexInputStream.h deleted file mode 120000 index a519eb6..0000000 --- a/zlibrary/core/include/ZLHexInputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLHexInputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLHexInputStream.h b/zlibrary/core/include/ZLHexInputStream.h new file mode 100644 index 0000000..b846cdd --- /dev/null +++ b/zlibrary/core/include/ZLHexInputStream.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +class ZLHexInputStream : public ZLInputStream { +public: + ZLHexInputStream(shared_ptr 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 myBaseStream; + char* myBuffer; + int myBufferOffset; + int myBufferLength; +}; + +#endif /* __ZLHEXINPUTSTREAM_H__ */ diff --git a/zlibrary/core/include/ZLImage.h b/zlibrary/core/include/ZLImage.h deleted file mode 120000 index 3371017..0000000 --- a/zlibrary/core/include/ZLImage.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLImage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLImage.h b/zlibrary/core/include/ZLImage.h new file mode 100644 index 0000000..15c88b9 --- /dev/null +++ b/zlibrary/core/include/ZLImage.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include + +#include + +class ZLNetworkRequest; + +class ZLImage { + +protected: + ZLImage(); + +public: + virtual ~ZLImage(); + virtual bool isSingle() const = 0; + virtual shared_ptr synchronizationData() const; + virtual bool good() const = 0; +}; + +class ZLSingleImage : public ZLImage { + +protected: + ZLSingleImage(shared_ptr mimeType); + virtual ~ZLSingleImage(); + +public: + bool isSingle() const { return true; } + shared_ptr mimeType() const; + bool good() const; + virtual const shared_ptr stringData() const = 0; + +private: + shared_ptr 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 subImage(unsigned int row, unsigned int column) const = 0; +}; + +inline ZLImage::ZLImage() {} +inline ZLImage::~ZLImage() {} + +inline ZLSingleImage::ZLSingleImage(shared_ptr mimeType) : myMimeType(mimeType) {} +inline ZLSingleImage::~ZLSingleImage() {} +inline shared_ptr 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 deleted file mode 120000 index 62681ed..0000000 --- a/zlibrary/core/include/ZLImageManager.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLImageManager.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLImageManager.h b/zlibrary/core/include/ZLImageManager.h new file mode 100644 index 0000000..c845c2b --- /dev/null +++ b/zlibrary/core/include/ZLImageManager.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include + +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 imageData(const ZLImage &image) const; + +public: + virtual shared_ptr makeBatchImage(const std::vector > &images, shared_ptr defaultImage) const = 0; + +protected: + ZLImageManager() {} + virtual ~ZLImageManager() {} + + virtual shared_ptr 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 deleted file mode 120000 index 9ce442d..0000000 --- a/zlibrary/core/include/ZLInputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/ZLInputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLInputStream.h b/zlibrary/core/include/ZLInputStream.h new file mode 100644 index 0000000..7ac09c7 --- /dev/null +++ b/zlibrary/core/include/ZLInputStream.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include +#include + +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 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 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 deleted file mode 120000 index 34d8fef..0000000 --- a/zlibrary/core/include/ZLKeyBindings.h +++ /dev/null @@ -1 +0,0 @@ -../src/application/ZLKeyBindings.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLKeyBindings.h b/zlibrary/core/include/ZLKeyBindings.h new file mode 100644 index 0000000..322baa4 --- /dev/null +++ b/zlibrary/core/include/ZLKeyBindings.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +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 myBindingsMap; + bool myIsChanged; +}; + +#endif /* __KEYBINDINGS_H__ */ diff --git a/zlibrary/core/src/util/ZLKeyUtil.h b/zlibrary/core/include/ZLKeyUtil.h similarity index 100% rename from zlibrary/core/src/util/ZLKeyUtil.h rename to zlibrary/core/include/ZLKeyUtil.h diff --git a/zlibrary/core/include/ZLLanguageDetector.h b/zlibrary/core/include/ZLLanguageDetector.h deleted file mode 120000 index 4c51044..0000000 --- a/zlibrary/core/include/ZLLanguageDetector.h +++ /dev/null @@ -1 +0,0 @@ -../src/language/ZLLanguageDetector.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLLanguageDetector.h b/zlibrary/core/include/ZLLanguageDetector.h new file mode 100644 index 0000000..7f5d8dc --- /dev/null +++ b/zlibrary/core/include/ZLLanguageDetector.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2012 Geometer Plus + * + * 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 +#include + +//#include + +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 findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0); + shared_ptr findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0); + +private: + typedef std::vector > SBVector; + SBVector myMatchers; +}; + +#endif /* __ZLLANGUAGEDETECTOR_H__ */ diff --git a/zlibrary/core/include/ZLLanguageList.h b/zlibrary/core/include/ZLLanguageList.h deleted file mode 120000 index 2233797..0000000 --- a/zlibrary/core/include/ZLLanguageList.h +++ /dev/null @@ -1 +0,0 @@ -../src/language/ZLLanguageList.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLLanguageList.h b/zlibrary/core/include/ZLLanguageList.h new file mode 100644 index 0000000..318c545 --- /dev/null +++ b/zlibrary/core/include/ZLLanguageList.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2007-2012 Geometer Plus + * + * 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 + +#include + +class ZLLanguageList { + +public: + static std::string patternsDirectoryPath(); + static const std::vector &languageCodes(); + static std::string languageName(const std::string &code); + +private: + static std::vector ourLanguageCodes; + +private: + ZLLanguageList(); +}; + +#endif /* __ZLLANGUAGELIST_H__ */ diff --git a/zlibrary/core/src/language/ZLLanguageMatcher.h b/zlibrary/core/include/ZLLanguageMatcher.h similarity index 100% rename from zlibrary/core/src/language/ZLLanguageMatcher.h rename to zlibrary/core/include/ZLLanguageMatcher.h diff --git a/zlibrary/core/src/optionEntries/ZLLanguageOptionEntry.h b/zlibrary/core/include/ZLLanguageOptionEntry.h similarity index 100% rename from zlibrary/core/src/optionEntries/ZLLanguageOptionEntry.h rename to zlibrary/core/include/ZLLanguageOptionEntry.h diff --git a/zlibrary/core/include/ZLLanguageUtil.h b/zlibrary/core/include/ZLLanguageUtil.h deleted file mode 120000 index 1766657..0000000 --- a/zlibrary/core/include/ZLLanguageUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLLanguageUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLLanguageUtil.h b/zlibrary/core/include/ZLLanguageUtil.h new file mode 100644 index 0000000..a0f912c --- /dev/null +++ b/zlibrary/core/include/ZLLanguageUtil.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index 7ba1ad3..0000000 --- a/zlibrary/core/include/ZLLogger.h +++ /dev/null @@ -1 +0,0 @@ -../src/logger/ZLLogger.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLLogger.h b/zlibrary/core/include/ZLLogger.h new file mode 100644 index 0000000..5484b91 --- /dev/null +++ b/zlibrary/core/include/ZLLogger.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 +#include + +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 myRegisteredClasses; +}; + +#endif /* __ZLLOGGER_H__ */ diff --git a/zlibrary/core/src/application/ZLMenu.h b/zlibrary/core/include/ZLMenu.h similarity index 100% rename from zlibrary/core/src/application/ZLMenu.h rename to zlibrary/core/include/ZLMenu.h diff --git a/zlibrary/core/include/ZLMessage.h b/zlibrary/core/include/ZLMessage.h deleted file mode 120000 index 37065d3..0000000 --- a/zlibrary/core/include/ZLMessage.h +++ /dev/null @@ -1 +0,0 @@ -../src/message/ZLMessage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLMessage.h b/zlibrary/core/include/ZLMessage.h new file mode 100644 index 0000000..1b0bf8e --- /dev/null +++ b/zlibrary/core/include/ZLMessage.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +#include + +class ZLMessageOutputChannel; +class ZLMessageSender; + +class ZLMessageHandler; + +class ZLCommunicationManager { + +public: + static ZLCommunicationManager &Instance(); + static void deleteInstance(); + +protected: + static ZLCommunicationManager *ourInstance; + +public: + typedef std::map Data; + +protected: + ZLCommunicationManager(); + virtual ~ZLCommunicationManager(); + void init(); + void onMessageReceived(const std::string &command, const std::vector &arguments); + +public: + virtual shared_ptr 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 receiver); + +private: + shared_ptr handler(const std::string &command); + +private: + std::map > myRegisteredHandlers; + bool myInitialized; + +private: + ZLCommunicationManager(const ZLCommunicationManager&); + const ZLCommunicationManager &operator = (const ZLCommunicationManager&); +}; + +class ZLMessageOutputChannel { + +public: + virtual ~ZLMessageOutputChannel(); + + virtual shared_ptr 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 &arguments) = 0; +}; + +#endif /* __ZLMESSAGE_H__ */ diff --git a/zlibrary/core/include/ZLMimeType.h b/zlibrary/core/include/ZLMimeType.h deleted file mode 120000 index bf8cac0..0000000 --- a/zlibrary/core/include/ZLMimeType.h +++ /dev/null @@ -1 +0,0 @@ -../src/constants/ZLMimeType.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLMimeType.h b/zlibrary/core/include/ZLMimeType.h new file mode 100644 index 0000000..307dc6c --- /dev/null +++ b/zlibrary/core/include/ZLMimeType.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2010-2012 Geometer Plus + * + * 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 +#include +#include + +class ZLMimeType { + +private: + + ZLMimeType(std::string& name, std::map& parameters); + +private: + + static std::map > ourSimpleTypesMap; + +public: + static shared_ptr get(const char *text); + static shared_ptr get(std::string text); + static bool isImage(shared_ptr mimeType); + +private: + + const std::map 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 APPLICATION_XML; + static const shared_ptr APPLICATION_ZIP; + static const shared_ptr APPLICATION_EPUB_ZIP; + static const shared_ptr APPLICATION_FB2_ZIP; + static const shared_ptr APPLICATION_MOBIPOCKET_EBOOK; + static const shared_ptr APPLICATION_PDF; + static const shared_ptr APPLICATION_CHM; + static const shared_ptr APPLICATION_PALM_DB; + static const shared_ptr APPLICATION_ATOM_XML; + static const shared_ptr APPLICATION_LITRES_XML; + static const shared_ptr APPLICATION_LITRES_XML_BOOKS; + static const shared_ptr APPLICATION_LITRES_XML_AUTHORS; + static const shared_ptr APPLICATION_LITRES_XML_GENRES; + static const shared_ptr APPLICATION_OPENSEARCH_XML; + static const shared_ptr APPLICATION_OR_XML; + + static const shared_ptr APPLICATION_GZIP; + static const shared_ptr APPLICATION_BZIP2; + static const shared_ptr APPLICATION_TAR; + static const shared_ptr APPLICATION_TAR_GZIP; + static const shared_ptr APPLICATION_TAR_BZIP2; + static const shared_ptr APPLICATION_TAR_7Z; + + static const shared_ptr IMAGE_PNG; + static const shared_ptr IMAGE_JPEG; + static const shared_ptr IMAGE_SVG; + static const shared_ptr IMAGE_PALM; + static const shared_ptr IMAGE_AUTO; + + static const shared_ptr TEXT_HTML; + static const shared_ptr TEXT_PLAIN; + static const shared_ptr TEXT_XML; + + static const shared_ptr EMPTY; + +}; + +#endif /* __ZLMIMETYPE_H__ */ diff --git a/zlibrary/core/include/ZLMirroredPaintContext.h b/zlibrary/core/include/ZLMirroredPaintContext.h deleted file mode 120000 index 2c29c57..0000000 --- a/zlibrary/core/include/ZLMirroredPaintContext.h +++ /dev/null @@ -1 +0,0 @@ -../src/view/ZLMirroredPaintContext.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLMirroredPaintContext.h b/zlibrary/core/include/ZLMirroredPaintContext.h new file mode 100644 index 0000000..ff7272d --- /dev/null +++ b/zlibrary/core/include/ZLMirroredPaintContext.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include + +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 &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 similarity index 97% rename from zlibrary/core/src/network/requests/ZLNetworkDownloadRequest.h rename to 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 deleted file mode 120000 index 51c7cc4..0000000 --- a/zlibrary/core/include/ZLNetworkImage.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLNetworkImage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLNetworkImage.h b/zlibrary/core/include/ZLNetworkImage.h new file mode 100644 index 0000000..98a8223 --- /dev/null +++ b/zlibrary/core/include/ZLNetworkImage.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +class ZLFileImage; + +class ZLNetworkImage : public ZLSingleImage { + +public: + ZLNetworkImage(shared_ptr mimeType, const std::string &url); + const shared_ptr stringData() const; + +private: + shared_ptr synchronizationData() const; + +private: + const std::string myURL; + std::string myFileName; + mutable bool myIsSynchronized; + mutable shared_ptr myCachedImage; +}; + +#endif /* __ZLNETWORKIMAGE_H__ */ diff --git a/zlibrary/core/include/ZLNetworkManager.h b/zlibrary/core/include/ZLNetworkManager.h deleted file mode 120000 index 8e5cb56..0000000 --- a/zlibrary/core/include/ZLNetworkManager.h +++ /dev/null @@ -1 +0,0 @@ -../src/network/ZLNetworkManager.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLNetworkManager.h b/zlibrary/core/include/ZLNetworkManager.h new file mode 100644 index 0000000..b2fb817 --- /dev/null +++ b/zlibrary/core/include/ZLNetworkManager.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 + +#include +#include + +#include +#include + +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 request) const; + std::string performAsync(shared_ptr 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 listener = 0) const; + +public: + shared_ptr createDownloadRequest(const std::string &url, const std::string &fileName) const; + shared_ptr createDownloadRequest(const std::string &url, shared_ptr stream) const; + shared_ptr createNoActionRequest(const std::string &url) const; + shared_ptr createReadToStringRequest(const std::string &url, std::string &buffer) const; + shared_ptr createXMLParserRequest(const std::string &url, shared_ptr reader, shared_ptr runnable = 0) const; + +public: + void setUserAgent(const std::string &userAgent); + const std::string &userAgent() const; + +private: + mutable shared_ptr myConnectTimeoutOption; + mutable shared_ptr myTimeoutOption; + mutable shared_ptr myUseProxyOption; + mutable shared_ptr myProxyHostOption; + mutable shared_ptr 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 similarity index 97% rename from zlibrary/core/src/network/requests/ZLNetworkNoActionRequest.h rename to 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 similarity index 97% rename from zlibrary/core/src/network/requests/ZLNetworkReadToStringRequest.h rename to 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 deleted file mode 120000 index e029d68..0000000 --- a/zlibrary/core/include/ZLNetworkRequest.h +++ /dev/null @@ -1 +0,0 @@ -../src/network/ZLNetworkRequest.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLNetworkRequest.h b/zlibrary/core/include/ZLNetworkRequest.h new file mode 100644 index 0000000..431355a --- /dev/null +++ b/zlibrary/core/include/ZLNetworkRequest.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2010-2012 Geometer Plus + * + * 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 +#include + +#include + +class ZLNetworkRequest { + +public: + typedef std::vector > 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 > &postParameters() const; + void setPostParameters(const std::vector > ¶meters); + + +public: //listeners methods + bool hasListener() const; + void setListener(shared_ptr listener); + void setPercent(int ready, int full); + void setUIStatus(bool enabled); + +protected: + void finished(const std::string &error); + shared_ptr listener() const; + +private: + const std::string myURL; + std::string myErrorMessage; + + std::string myUserName; + std::string myPassword; + + bool myRedirectionSupported; + + std::vector > myPostParameters; + + shared_ptr 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 > &ZLNetworkRequest::postParameters() const { return myPostParameters; } + +inline shared_ptr ZLNetworkRequest::listener() const { return myListener; } + +#endif /* __ZLNETWORKREQUEST_H__ */ diff --git a/zlibrary/core/include/ZLNetworkUtil.h b/zlibrary/core/include/ZLNetworkUtil.h deleted file mode 120000 index 51d7ba6..0000000 --- a/zlibrary/core/include/ZLNetworkUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/network/ZLNetworkUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLNetworkUtil.h b/zlibrary/core/include/ZLNetworkUtil.h new file mode 100644 index 0000000..430044a --- /dev/null +++ b/zlibrary/core/include/ZLNetworkUtil.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 + +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 similarity index 97% rename from zlibrary/core/src/network/requests/ZLNetworkXMLParserRequest.h rename to 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 -#include "../ZLNetworkRequest.h" +#include "ZLNetworkRequest.h" class ZLXMLReader; class ZLAsynchronousInputStream; diff --git a/zlibrary/core/include/ZLOpenFileDialog.h b/zlibrary/core/include/ZLOpenFileDialog.h deleted file mode 120000 index 05fad51..0000000 --- a/zlibrary/core/include/ZLOpenFileDialog.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLOpenFileDialog.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLOpenFileDialog.h b/zlibrary/core/include/ZLOpenFileDialog.h new file mode 100644 index 0000000..e20673d --- /dev/null +++ b/zlibrary/core/include/ZLOpenFileDialog.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index 90231c9..0000000 --- a/zlibrary/core/include/ZLOptionEntry.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLOptionEntry.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLOptionEntry.h b/zlibrary/core/include/ZLOptionEntry.h new file mode 100644 index 0000000..fb3a319 --- /dev/null +++ b/zlibrary/core/include/ZLOptionEntry.h @@ -0,0 +1,294 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include + +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 &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 &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 myActionNames; +}; + +class ZLOrderOptionEntry : public ZLOptionEntry { + +public: + ZLOrderOptionEntry(); + std::vector &values(); + +protected: + ZLOptionKind kind() const; + +private: + std::vector 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 &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 &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 similarity index 100% rename from zlibrary/core/src/dialogs/ZLOptionView.h rename to zlibrary/core/include/ZLOptionView.h diff --git a/zlibrary/core/include/ZLOptions.h b/zlibrary/core/include/ZLOptions.h deleted file mode 120000 index 7a54134..0000000 --- a/zlibrary/core/include/ZLOptions.h +++ /dev/null @@ -1 +0,0 @@ -../src/options/ZLOptions.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLOptions.h b/zlibrary/core/include/ZLOptions.h new file mode 100644 index 0000000..80a6aec --- /dev/null +++ b/zlibrary/core/include/ZLOptions.h @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include + +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 &names); + static void listOptionGroups(std::vector &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 deleted file mode 120000 index 1e935fd..0000000 --- a/zlibrary/core/include/ZLOptionsDialog.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLOptionsDialog.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLOptionsDialog.h b/zlibrary/core/include/ZLOptionsDialog.h new file mode 100644 index 0000000..0a72cdb --- /dev/null +++ b/zlibrary/core/include/ZLOptionsDialog.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include + +#include +#include +#include +#include + +class ZLOptionEntry; + +class ZLDialogContentBuilder; + +class ZLOptionsDialog { + +protected: + static void addPlatformDependentBuilder(shared_ptr builder); + +private: + static std::vector > ourPlatformDependentBuilders; + +protected: + ZLOptionsDialog(const ZLResource &resource, shared_ptr 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 myApplyAction; + std::vector > myTabs; +}; + +#endif /* __ZLOPTIONSDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLOutputStream.h b/zlibrary/core/include/ZLOutputStream.h deleted file mode 120000 index 750bf94..0000000 --- a/zlibrary/core/include/ZLOutputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/ZLOutputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLOutputStream.h b/zlibrary/core/include/ZLOutputStream.h new file mode 100644 index 0000000..63da97f --- /dev/null +++ b/zlibrary/core/include/ZLOutputStream.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index a75b5c0..0000000 --- a/zlibrary/core/include/ZLPaintContext.h +++ /dev/null @@ -1 +0,0 @@ -../src/view/ZLPaintContext.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLPaintContext.h b/zlibrary/core/include/ZLPaintContext.h new file mode 100644 index 0000000..7597a33 --- /dev/null +++ b/zlibrary/core/include/ZLPaintContext.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +#include +#include + +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 &fontFamilies() const; + virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0; + +protected: + virtual void fillFamiliesList(std::vector &families) const = 0; + +private: + mutable std::vector 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 deleted file mode 120000 index ada7161..0000000 --- a/zlibrary/core/include/ZLPlainAsynchronousInputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/network/ZLPlainAsynchronousInputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLPlainAsynchronousInputStream.h b/zlibrary/core/include/ZLPlainAsynchronousInputStream.h new file mode 100644 index 0000000..eb8d0a7 --- /dev/null +++ b/zlibrary/core/include/ZLPlainAsynchronousInputStream.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + + +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 deleted file mode 120000 index 42d0e04..0000000 --- a/zlibrary/core/include/ZLPopupData.h +++ /dev/null @@ -1 +0,0 @@ -../src/application/ZLPopupData.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLPopupData.h b/zlibrary/core/include/ZLPopupData.h new file mode 100644 index 0000000..235826e --- /dev/null +++ b/zlibrary/core/include/ZLPopupData.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 + +#include + +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 deleted file mode 120000 index f5d7ec9..0000000 --- a/zlibrary/core/include/ZLProgressDialog.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLProgressDialog.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLProgressDialog.h b/zlibrary/core/include/ZLProgressDialog.h new file mode 100644 index 0000000..be471a0 --- /dev/null +++ b/zlibrary/core/include/ZLProgressDialog.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 +#include +#include + +class ZLProgressDialog { + +private: + class ProgressListener; + +protected: + ZLProgressDialog(const ZLResourceKey &key); + +public: + virtual ~ZLProgressDialog(); + + shared_ptr 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 deleted file mode 120000 index 5902f08..0000000 --- a/zlibrary/core/include/ZLResource.h +++ /dev/null @@ -1 +0,0 @@ -../src/resources/ZLResource.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLResource.h b/zlibrary/core/include/ZLResource.h new file mode 100644 index 0000000..ee088f2 --- /dev/null +++ b/zlibrary/core/include/ZLResource.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index 1b0ebff..0000000 --- a/zlibrary/core/include/ZLRunnable.h +++ /dev/null @@ -1 +0,0 @@ -../src/runnable/ZLRunnable.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLRunnable.h b/zlibrary/core/include/ZLRunnable.h new file mode 100644 index 0000000..60914f1 --- /dev/null +++ b/zlibrary/core/include/ZLRunnable.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index 453b73c..0000000 --- a/zlibrary/core/include/ZLSearchUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLSearchUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLSearchUtil.h b/zlibrary/core/include/ZLSearchUtil.h new file mode 100644 index 0000000..797b7af --- /dev/null +++ b/zlibrary/core/include/ZLSearchUtil.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 similarity index 100% rename from zlibrary/core/src/optionEntries/ZLSimpleKeyOptionEntry.h rename to zlibrary/core/include/ZLSimpleKeyOptionEntry.h diff --git a/zlibrary/core/src/optionEntries/ZLSimpleOptionEntry.h b/zlibrary/core/include/ZLSimpleOptionEntry.h similarity index 100% rename from zlibrary/core/src/optionEntries/ZLSimpleOptionEntry.h rename to zlibrary/core/include/ZLSimpleOptionEntry.h diff --git a/zlibrary/core/include/ZLSliceInputStream.h b/zlibrary/core/include/ZLSliceInputStream.h deleted file mode 120000 index 6e20e5e..0000000 --- a/zlibrary/core/include/ZLSliceInputStream.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLSliceInputStream.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLSliceInputStream.h b/zlibrary/core/include/ZLSliceInputStream.h new file mode 100644 index 0000000..9333be8 --- /dev/null +++ b/zlibrary/core/include/ZLSliceInputStream.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +class ZLSliceInputStream : public ZLInputStream { +public: + ZLSliceInputStream(shared_ptr 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 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 similarity index 100% rename from zlibrary/core/src/language/ZLStatistics.h rename to zlibrary/core/include/ZLStatistics.h diff --git a/zlibrary/core/src/language/ZLStatisticsGenerator.h b/zlibrary/core/include/ZLStatisticsGenerator.h similarity index 100% rename from zlibrary/core/src/language/ZLStatisticsGenerator.h rename to zlibrary/core/include/ZLStatisticsGenerator.h diff --git a/zlibrary/core/src/language/ZLStatisticsItem.h b/zlibrary/core/include/ZLStatisticsItem.h similarity index 100% rename from zlibrary/core/src/language/ZLStatisticsItem.h rename to zlibrary/core/include/ZLStatisticsItem.h diff --git a/zlibrary/core/src/language/ZLStatisticsXMLReader.h b/zlibrary/core/include/ZLStatisticsXMLReader.h similarity index 100% rename from zlibrary/core/src/language/ZLStatisticsXMLReader.h rename to zlibrary/core/include/ZLStatisticsXMLReader.h diff --git a/zlibrary/core/src/language/ZLStatisticsXMLWriter.h b/zlibrary/core/include/ZLStatisticsXMLWriter.h similarity index 100% rename from zlibrary/core/src/language/ZLStatisticsXMLWriter.h rename to zlibrary/core/include/ZLStatisticsXMLWriter.h diff --git a/zlibrary/core/include/ZLStreamImage.h b/zlibrary/core/include/ZLStreamImage.h deleted file mode 120000 index 9b2f7f6..0000000 --- a/zlibrary/core/include/ZLStreamImage.h +++ /dev/null @@ -1 +0,0 @@ -../src/image/ZLStreamImage.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLStreamImage.h b/zlibrary/core/include/ZLStreamImage.h new file mode 100644 index 0000000..95f03f8 --- /dev/null +++ b/zlibrary/core/include/ZLStreamImage.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include +#include + +class ZLStreamImage : public ZLSingleImage { + +public: + ZLStreamImage(shared_ptr mimeType, std::size_t offset, std::size_t size = 0); + const shared_ptr stringData() const; + +private: + virtual shared_ptr inputStream() const = 0; + +private: + std::size_t myOffset; + mutable std::size_t mySize; +}; + +inline ZLStreamImage::ZLStreamImage(shared_ptr 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 similarity index 100% rename from zlibrary/core/src/optionEntries/ZLStringEditOptionEntry.h rename to zlibrary/core/include/ZLStringEditOptionEntry.h diff --git a/zlibrary/core/src/optionEntries/ZLStringInfoEntry.h b/zlibrary/core/include/ZLStringInfoEntry.h similarity index 100% rename from zlibrary/core/src/optionEntries/ZLStringInfoEntry.h rename to zlibrary/core/include/ZLStringInfoEntry.h diff --git a/zlibrary/core/include/ZLStringUtil.h b/zlibrary/core/include/ZLStringUtil.h deleted file mode 120000 index 24f5e3e..0000000 --- a/zlibrary/core/include/ZLStringUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLStringUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLStringUtil.h b/zlibrary/core/include/ZLStringUtil.h new file mode 100644 index 0000000..71dda00 --- /dev/null +++ b/zlibrary/core/include/ZLStringUtil.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include + +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 &buffer); + static void stripWhiteSpaces(std::string &str); + + static const std::string SPACE; + static std::vector 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 + static std::string join(T iterable, F functor, std::string separator); + template + static std::string join(T iterable, std::string separator); + + template + struct self { + inline T operator()(const T &t) { + return t; + } + }; +}; + +template +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 +std::string ZLStringUtil::join(T iterable, std::string separator) { + return join(iterable, ZLStringUtil::self(), separator); +} + +#endif /* __ZLSTRINGUTIL_H__ */ diff --git a/zlibrary/core/src/filesystem/tar/ZLTar.h b/zlibrary/core/include/ZLTar.h similarity index 97% rename from zlibrary/core/src/filesystem/tar/ZLTar.h rename to 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 -#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 deleted file mode 120000 index cd6a73a..0000000 --- a/zlibrary/core/include/ZLTime.h +++ /dev/null @@ -1 +0,0 @@ -../src/time/ZLTime.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTime.h b/zlibrary/core/include/ZLTime.h new file mode 100644 index 0000000..c06478f --- /dev/null +++ b/zlibrary/core/include/ZLTime.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 deleted file mode 120000 index 801436b..0000000 --- a/zlibrary/core/include/ZLTimeManager.h +++ /dev/null @@ -1 +0,0 @@ -../src/time/ZLTimeManager.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTimeManager.h b/zlibrary/core/include/ZLTimeManager.h new file mode 100644 index 0000000..639e420 --- /dev/null +++ b/zlibrary/core/include/ZLTimeManager.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include +#include + +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 task, int interval) = 0; + void addAutoRemovableTask(shared_ptr task, int delay = 0); + void removeTask(shared_ptr task); + +protected: + virtual void removeTaskInternal(shared_ptr 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 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 static void deleteLater(shared_ptr object, int delay = 0) { + deleteLater(new shared_ptr(object), delay); + } + template static void deleteLater(T *object, int delay = 0) { + DeleteFunc func = reinterpret_cast(&DeleteHelper::func); + ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay); + } + +private: + std::map,shared_ptr > myAutoRemovableTasks; + +friend class ZLTime; +}; + +#endif /* __ZLTIMEMANAGER_H__ */ diff --git a/zlibrary/core/src/optionEntries/ZLToggleBooleanOptionEntry.h b/zlibrary/core/include/ZLToggleBooleanOptionEntry.h similarity index 96% rename from zlibrary/core/src/optionEntries/ZLToggleBooleanOptionEntry.h rename to 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 +#include class ZLToggleBooleanOptionEntry : public ZLSimpleBooleanOptionEntry { diff --git a/zlibrary/core/src/application/ZLToolbar.h b/zlibrary/core/include/ZLToolbar.h similarity index 100% rename from zlibrary/core/src/application/ZLToolbar.h rename to zlibrary/core/include/ZLToolbar.h diff --git a/zlibrary/core/include/ZLTreeActionNode.h b/zlibrary/core/include/ZLTreeActionNode.h deleted file mode 120000 index cf85954..0000000 --- a/zlibrary/core/include/ZLTreeActionNode.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreeActionNode.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeActionNode.h b/zlibrary/core/include/ZLTreeActionNode.h new file mode 100644 index 0000000..6212aed --- /dev/null +++ b/zlibrary/core/include/ZLTreeActionNode.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 deleted file mode 120000 index 90e109a..0000000 --- a/zlibrary/core/include/ZLTreeDialog.h +++ /dev/null @@ -1 +0,0 @@ -../src/dialogs/ZLTreeDialog.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeDialog.h b/zlibrary/core/include/ZLTreeDialog.h new file mode 100644 index 0000000..2bf5289 --- /dev/null +++ b/zlibrary/core/include/ZLTreeDialog.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +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 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 mySearcher; + +private: + const ZLResource &myResource; +}; + +#endif /* __ZLTREEDIALOG_H__ */ diff --git a/zlibrary/core/include/ZLTreeListener.h b/zlibrary/core/include/ZLTreeListener.h deleted file mode 120000 index 068e098..0000000 --- a/zlibrary/core/include/ZLTreeListener.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreeListener.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeListener.h b/zlibrary/core/include/ZLTreeListener.h new file mode 100644 index 0000000..e602015 --- /dev/null +++ b/zlibrary/core/include/ZLTreeListener.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 deleted file mode 120000 index 4dc2788..0000000 --- a/zlibrary/core/include/ZLTreeNode.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreeNode.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeNode.h b/zlibrary/core/include/ZLTreeNode.h new file mode 100644 index 0000000..79c8b87 --- /dev/null +++ b/zlibrary/core/include/ZLTreeNode.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 +#include + +#include + +#include +#include +#include +#include + +// 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 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 listener = 0); + virtual void requestMoreChildren(shared_ptr listener = 0); + + virtual const ZLResource &resource() const; + void registerAction(shared_ptr action); + const std::vector > &actions() const; + std::string actionText(const shared_ptr &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 > 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 deleted file mode 120000 index fd6531c..0000000 --- a/zlibrary/core/include/ZLTreePageNode.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreePageNode.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreePageNode.h b/zlibrary/core/include/ZLTreePageNode.h new file mode 100644 index 0000000..8226ea1 --- /dev/null +++ b/zlibrary/core/include/ZLTreePageNode.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +class ZLTreePageInfo { +public: + + virtual bool isPageInfoLoaded() = 0; + virtual void loadAll(shared_ptr listener) = 0; + + virtual std::string title() const = 0; + virtual std::vector authors() const = 0; + virtual std::vector tags() const = 0; + virtual std::string summary() const = 0; + virtual shared_ptr image() const = 0; + + virtual const std::vector > &actions() const = 0; + virtual std::string actionText(const shared_ptr &action) const = 0; + virtual const std::vector > 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 getPageInfo() = 0; +}; + +#endif // ZLTREEPAGENODE_H diff --git a/zlibrary/core/include/ZLTreeSearcher.h b/zlibrary/core/include/ZLTreeSearcher.h deleted file mode 120000 index 09d069d..0000000 --- a/zlibrary/core/include/ZLTreeSearcher.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreeSearcher.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeSearcher.h b/zlibrary/core/include/ZLTreeSearcher.h new file mode 100644 index 0000000..747d9c5 --- /dev/null +++ b/zlibrary/core/include/ZLTreeSearcher.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index 9636416..0000000 --- a/zlibrary/core/include/ZLTreeTitledNode.h +++ /dev/null @@ -1 +0,0 @@ -../src/tree/ZLTreeTitledNode.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTreeTitledNode.h b/zlibrary/core/include/ZLTreeTitledNode.h new file mode 100644 index 0000000..a68a746 --- /dev/null +++ b/zlibrary/core/include/ZLTreeTitledNode.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009-2012 Geometer Plus + * + * 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 + +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 image() const; +}; + +#endif /* __ZLTREETITLEDNODE_H__ */ diff --git a/zlibrary/core/include/ZLTypeId.h b/zlibrary/core/include/ZLTypeId.h deleted file mode 120000 index deebb9d..0000000 --- a/zlibrary/core/include/ZLTypeId.h +++ /dev/null @@ -1 +0,0 @@ -../src/typeId/ZLTypeId.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLTypeId.h b/zlibrary/core/include/ZLTypeId.h new file mode 100644 index 0000000..ed5679a --- /dev/null +++ b/zlibrary/core/include/ZLTypeId.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010-2012 Geometer Plus + * + * 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 +T zlobject_cast(ZLObjectWithRTTI *object) { + if (!object || !object->isInstanceOf(reinterpret_cast(0)->TYPE_ID)) + return 0; + return static_cast(object); +} + +template +T zlobject_cast(const ZLObjectWithRTTI *object) { + if (!object || !object->isInstanceOf(reinterpret_cast(0)->TYPE_ID)) + return 0; + return static_cast(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 deleted file mode 120000 index b39784a..0000000 --- a/zlibrary/core/include/ZLUnicodeUtil.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLUnicodeUtil.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLUnicodeUtil.h b/zlibrary/core/include/ZLUnicodeUtil.h new file mode 100644 index 0000000..963e671 --- /dev/null +++ b/zlibrary/core/include/ZLUnicodeUtil.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +class ZLUnicodeUtil { + +private: + ZLUnicodeUtil(); + +public: + typedef uint16_t Ucs2Char; + typedef std::vector Ucs2String; + typedef uint32_t Ucs4Char; + typedef std::vector 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 similarity index 96% rename from zlibrary/core/src/unix/filesystem/ZLUnixFSDir.h rename to 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 similarity index 97% rename from zlibrary/core/src/unix/filesystem/ZLUnixFSManager.h rename to 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 similarity index 100% rename from zlibrary/core/src/unix/filesystem/ZLUnixFileInputStream.h rename to zlibrary/core/include/ZLUnixFileInputStream.h diff --git a/zlibrary/core/src/unix/filesystem/ZLUnixFileOutputStream.h b/zlibrary/core/include/ZLUnixFileOutputStream.h similarity index 100% rename from zlibrary/core/src/unix/filesystem/ZLUnixFileOutputStream.h rename to zlibrary/core/include/ZLUnixFileOutputStream.h diff --git a/zlibrary/core/src/unix/message/ZLUnixMessage.h b/zlibrary/core/include/ZLUnixMessage.h similarity index 100% rename from zlibrary/core/src/unix/message/ZLUnixMessage.h rename to zlibrary/core/include/ZLUnixMessage.h diff --git a/zlibrary/core/src/unix/time/ZLUnixTime.h b/zlibrary/core/include/ZLUnixTime.h similarity index 100% rename from zlibrary/core/src/unix/time/ZLUnixTime.h rename to zlibrary/core/include/ZLUnixTime.h diff --git a/zlibrary/core/include/ZLUserData.h b/zlibrary/core/include/ZLUserData.h deleted file mode 120000 index 8a88707..0000000 --- a/zlibrary/core/include/ZLUserData.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/ZLUserData.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLUserData.h b/zlibrary/core/include/ZLUserData.h new file mode 100644 index 0000000..db98346 --- /dev/null +++ b/zlibrary/core/include/ZLUserData.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 +#include + +#include + +class ZLUserData { + +public: + virtual ~ZLUserData(); +}; + +class ZLUserDataHolder { + +public: + ZLUserDataHolder(); + ZLUserDataHolder(const ZLUserDataHolder &other); + virtual ~ZLUserDataHolder(); + + void addUserData(const std::string &key, shared_ptr data); + void removeUserData(const std::string &key); + shared_ptr getUserData(const std::string &key) const; + +private: + ZLUserDataHolder &operator =(const ZLUserDataHolder &other); + std::map > myDataMap; +}; + +#endif /* __ZLUSERDATA_H__ */ diff --git a/zlibrary/core/include/ZLView.h b/zlibrary/core/include/ZLView.h deleted file mode 120000 index 48f75fc..0000000 --- a/zlibrary/core/include/ZLView.h +++ /dev/null @@ -1 +0,0 @@ -../src/view/ZLView.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLView.h b/zlibrary/core/include/ZLView.h new file mode 100644 index 0000000..bc8e42b --- /dev/null +++ b/zlibrary/core/include/ZLView.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include + +#include +#include + +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 similarity index 100% rename from zlibrary/core/src/view/ZLViewWidget.h rename to zlibrary/core/include/ZLViewWidget.h diff --git a/zlibrary/core/include/ZLXMLNamespace.h b/zlibrary/core/include/ZLXMLNamespace.h deleted file mode 120000 index 0ce94d2..0000000 --- a/zlibrary/core/include/ZLXMLNamespace.h +++ /dev/null @@ -1 +0,0 @@ -../src/constants/ZLXMLNamespace.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLXMLNamespace.h b/zlibrary/core/include/ZLXMLNamespace.h new file mode 100644 index 0000000..784e438 --- /dev/null +++ b/zlibrary/core/include/ZLXMLNamespace.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2008-2012 Geometer Plus + * + * 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 + +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 deleted file mode 120000 index d35bb0e..0000000 --- a/zlibrary/core/include/ZLXMLReader.h +++ /dev/null @@ -1 +0,0 @@ -../src/xml/ZLXMLReader.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLXMLReader.h b/zlibrary/core/include/ZLXMLReader.h new file mode 100644 index 0000000..c3c4c41 --- /dev/null +++ b/zlibrary/core/include/ZLXMLReader.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +#include + +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 stream); + bool readDocument(shared_ptr stream); + + const std::string &errorMessage() const; + + typedef std::map 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 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 &externalDTDs() const; + virtual void collectExternalEntities(std::map &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 > 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 similarity index 100% rename from zlibrary/core/src/xml/expat/ZLXMLReaderInternal.h rename to zlibrary/core/include/ZLXMLReaderInternal.h diff --git a/zlibrary/core/include/ZLXMLWriter.h b/zlibrary/core/include/ZLXMLWriter.h deleted file mode 120000 index 071ffab..0000000 --- a/zlibrary/core/include/ZLXMLWriter.h +++ /dev/null @@ -1 +0,0 @@ -../src/xml/ZLXMLWriter.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLXMLWriter.h b/zlibrary/core/include/ZLXMLWriter.h new file mode 100644 index 0000000..5966f1c --- /dev/null +++ b/zlibrary/core/include/ZLXMLWriter.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 +#include +#include + +#include + +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 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 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 deleted file mode 120000 index 295ff9b..0000000 --- a/zlibrary/core/include/ZLZDecompressor.h +++ /dev/null @@ -1 +0,0 @@ -../src/filesystem/zip/ZLZDecompressor.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLZDecompressor.h b/zlibrary/core/include/ZLZDecompressor.h new file mode 100644 index 0000000..3264bc3 --- /dev/null +++ b/zlibrary/core/include/ZLZDecompressor.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +#include + +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 similarity index 98% rename from zlibrary/core/src/filesystem/zip/ZLZip.h rename to 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 -#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 similarity index 100% rename from zlibrary/core/src/filesystem/zip/ZLZipHeader.h rename to zlibrary/core/include/ZLZipHeader.h diff --git a/zlibrary/core/include/ZLibrary.h b/zlibrary/core/include/ZLibrary.h deleted file mode 120000 index 0e49f58..0000000 --- a/zlibrary/core/include/ZLibrary.h +++ /dev/null @@ -1 +0,0 @@ -../src/library/ZLibrary.h \ No newline at end of file diff --git a/zlibrary/core/include/ZLibrary.h b/zlibrary/core/include/ZLibrary.h new file mode 100644 index 0000000..9f4a62d --- /dev/null +++ b/zlibrary/core/include/ZLibrary.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +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 similarity index 100% rename from zlibrary/core/src/unix/library/ZLibraryImplementation.h rename to zlibrary/core/include/ZLibraryImplementation.h diff --git a/zlibrary/core/include/allocator.h b/zlibrary/core/include/allocator.h deleted file mode 120000 index 667a0fd..0000000 --- a/zlibrary/core/include/allocator.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/allocator.h \ No newline at end of file diff --git a/zlibrary/core/include/allocator.h b/zlibrary/core/include/allocator.h new file mode 100644 index 0000000..e756d98 --- /dev/null +++ b/zlibrary/core/include/allocator.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 + +template class Allocator { + +public: + Allocator(); + ~Allocator(); + + void *allocate(); + void free(void *ptr); + +private: + void addPool(); + +private: + std::vector myPools; + void *myFirstUnused; + void *myLastUnused; +}; + +template +inline Allocator::Allocator() { + addPool(); +} + +template +inline Allocator::~Allocator() { + for (std::vector::const_iterator it = myPools.begin(); it != myPools.end(); ++it) { + delete[] (char*)*it; + } +} + +template +inline void Allocator::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 +void *Allocator::allocate() { + void *ptr = myFirstUnused; + if (myFirstUnused == myLastUnused) { + addPool(); + } else { + myFirstUnused = *(void**)myFirstUnused; + } + return ptr; +} + +template +void Allocator::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 deleted file mode 120000 index 18dde07..0000000 --- a/zlibrary/core/include/shared_ptr.h +++ /dev/null @@ -1 +0,0 @@ -../src/util/shared_ptr.h \ No newline at end of file diff --git a/zlibrary/core/include/shared_ptr.h b/zlibrary/core/include/shared_ptr.h new file mode 100644 index 0000000..8a499c3 --- /dev/null +++ b/zlibrary/core/include/shared_ptr.h @@ -0,0 +1,424 @@ +/* + * Copyright (C) 2004-2012 Geometer Plus + * + * 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 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 weak_ptr; + +template class shared_ptr { + friend class weak_ptr; + + private: + shared_ptr_storage *myStorage; + + shared_ptr_storage *newStorage(T *t); + void attachStorage(shared_ptr_storage *storage); + void detachStorage(); + + public: + shared_ptr(); + shared_ptr(T *t); + shared_ptr(const shared_ptr &t); + shared_ptr(const weak_ptr &t); + ~shared_ptr(); + + const shared_ptr &operator = (T *t); + const shared_ptr &operator = (const shared_ptr &t); + const shared_ptr &operator = (const weak_ptr &t); + + T* operator -> () const; + T& operator * () const; + bool isNull() const; + void reset(); + bool operator == (const weak_ptr &t) const; + bool operator != (const weak_ptr &t) const; + bool operator < (const weak_ptr &t) const; + bool operator > (const weak_ptr &t) const; + bool operator <= (const weak_ptr &t) const; + bool operator >= (const weak_ptr &t) const; + bool operator == (const shared_ptr &t) const; + bool operator != (const shared_ptr &t) const; + bool operator < (const shared_ptr &t) const; + bool operator > (const shared_ptr &t) const; + bool operator <= (const shared_ptr &t) const; + bool operator >= (const shared_ptr &t) const; +}; + +template class weak_ptr { + friend class shared_ptr; + private: + shared_ptr_storage *myStorage; + + void attachStorage(shared_ptr_storage *storage); + void detachStorage(); + + public: + weak_ptr(); + weak_ptr(const shared_ptr &t); + weak_ptr(const weak_ptr &t); + ~weak_ptr(); + + const weak_ptr &operator = (const weak_ptr &t); + const weak_ptr &operator = (const shared_ptr &t); + + T* operator -> () const; + T& operator * () const; + bool isNull() const; + void reset(); + + bool operator == (const weak_ptr &t) const; + bool operator != (const weak_ptr &t) const; + bool operator < (const weak_ptr &t) const; + bool operator > (const weak_ptr &t) const; + bool operator <= (const weak_ptr &t) const; + bool operator >= (const weak_ptr &t) const; + bool operator == (const shared_ptr &t) const; + bool operator != (const shared_ptr &t) const; + bool operator < (const shared_ptr &t) const; + bool operator > (const shared_ptr &t) const; + bool operator <= (const shared_ptr &t) const; + bool operator >= (const shared_ptr &t) const; +}; + +template +inline shared_ptr_storage::shared_ptr_storage(T *pointer) { + myPointer = pointer; + myCounter = 0; + myWeakCounter = 0; +} +template +inline shared_ptr_storage::~shared_ptr_storage() { +} +template +inline T* shared_ptr_storage::pointer() const { + return myPointer; +} +template +inline T& shared_ptr_storage::content() const { + return *myPointer; +} +template +inline void shared_ptr_storage::addReference() { + ++myCounter; +} +template +inline void shared_ptr_storage::removeReference() { + --myCounter; + if (myCounter == 0) { + T* ptr = myPointer; + myPointer = 0; + delete ptr; + } +} +template +inline void shared_ptr_storage::addWeakReference() { + ++myWeakCounter; +} +template +inline void shared_ptr_storage::removeWeakReference() { + --myWeakCounter; +} +template +inline unsigned int shared_ptr_storage::counter() const { + return myCounter + myWeakCounter; +} + +template +inline shared_ptr_storage *shared_ptr::newStorage(T *t) { + return (t == 0) ? 0 : new shared_ptr_storage(t); +} +template +inline void shared_ptr::attachStorage(shared_ptr_storage *storage) { + myStorage = storage; + if (myStorage != 0) { + myStorage->addReference(); + } +} +template +inline void shared_ptr::detachStorage() { + if (myStorage != 0) { + if (myStorage->counter() == 1) { + myStorage->removeReference(); + delete myStorage; + } else { + myStorage->removeReference(); + } + } +} + +template +inline shared_ptr::shared_ptr() { + myStorage = 0; +} +template +inline shared_ptr::shared_ptr(T *t) { + attachStorage(newStorage(t)); +} +template +inline shared_ptr::shared_ptr(const shared_ptr &t) { + attachStorage(t.myStorage); +} +template +inline shared_ptr::shared_ptr(const weak_ptr &t) { + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } +} +template +inline shared_ptr::~shared_ptr() { + detachStorage(); +} +template +inline const shared_ptr &shared_ptr::operator = (T *t) { + detachStorage(); + attachStorage(newStorage(t)); + return *this; +} +template +inline const shared_ptr &shared_ptr::operator = (const shared_ptr &t) { + if (&t != this) { + detachStorage(); + attachStorage(t.myStorage); + } + return *this; +} +template +inline const shared_ptr &shared_ptr::operator = (const weak_ptr &t) { + detachStorage(); + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } + return *this; +} + +template +inline T* shared_ptr::operator -> () const { + return (myStorage == 0) ? 0 : myStorage->pointer(); +} +template +inline T& shared_ptr::operator * () const { + return myStorage->content(); +} +template +inline bool shared_ptr::isNull() const { + return myStorage == 0; +} +template +inline void shared_ptr::reset() { + detachStorage(); + attachStorage(0); +} +template +inline bool shared_ptr::operator == (const weak_ptr &t) const { + return operator -> () == t.operator -> (); +} +template +inline bool shared_ptr::operator != (const weak_ptr &t) const { + return !operator == (t); +} +template +inline bool shared_ptr::operator < (const weak_ptr &t) const { + return operator -> () < t.operator -> (); +} +template +inline bool shared_ptr::operator > (const weak_ptr &t) const { + return t.operator < (*this); +} +template +inline bool shared_ptr::operator <= (const weak_ptr &t) const { + return !t.operator < (*this); +} +template +inline bool shared_ptr::operator >= (const weak_ptr &t) const { + return !operator < (t); +} +template +inline bool shared_ptr::operator == (const shared_ptr &t) const { + return operator -> () == t.operator -> (); +} +template +inline bool shared_ptr::operator != (const shared_ptr &t) const { + return !operator == (t); +} +template +inline bool shared_ptr::operator < (const shared_ptr &t) const { + return operator -> () < t.operator -> (); +} +template +inline bool shared_ptr::operator > (const shared_ptr &t) const { + return t.operator < (*this); +} +template +inline bool shared_ptr::operator <= (const shared_ptr &t) const { + return !t.operator < (*this); +} +template +inline bool shared_ptr::operator >= (const shared_ptr &t) const { + return !operator < (t); +} + +template +inline void weak_ptr::attachStorage(shared_ptr_storage *storage) { + myStorage = storage; + if (myStorage != 0) { + myStorage->addWeakReference(); + } +} +template +inline void weak_ptr::detachStorage() { + if (myStorage != 0) { + myStorage->removeWeakReference(); + if (myStorage->counter() == 0) { + delete myStorage; + } + } +} + +template +inline weak_ptr::weak_ptr() { + myStorage = 0; +} +template +inline weak_ptr::weak_ptr(const shared_ptr &t) { + attachStorage(t.myStorage); +} +template +inline weak_ptr::weak_ptr(const weak_ptr &t) { + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } +} +template +inline weak_ptr::~weak_ptr() { + detachStorage(); +} + +template +inline const weak_ptr &weak_ptr::operator = (const weak_ptr &t) { + if (&t != this) { + detachStorage(); + if (!t.isNull()) { + attachStorage(t.myStorage); + } else { + attachStorage(0); + } + } + return *this; +} +template +inline const weak_ptr &weak_ptr::operator = (const shared_ptr &t) { + detachStorage(); + attachStorage(t.myStorage); + return *this; +} + +template +inline T* weak_ptr::operator -> () const { + return (myStorage == 0) ? 0 : myStorage->pointer(); +} +template +inline T& weak_ptr::operator * () const { + return myStorage->content(); +} +template +inline bool weak_ptr::isNull() const { + return (myStorage == 0) || (myStorage->pointer() == 0); +} +template +inline void weak_ptr::reset() { + detachStorage(); + attachStorage(0); +} +template +inline bool weak_ptr::operator == (const weak_ptr &t) const { + return operator -> () == t.operator -> (); +} +template +inline bool weak_ptr::operator != (const weak_ptr &t) const { + return !operator == (t); +} +template +inline bool weak_ptr::operator < (const weak_ptr &t) const { + return operator -> () < t.operator -> (); +} +template +inline bool weak_ptr::operator > (const weak_ptr &t) const { + return t.operator < (*this); +} +template +inline bool weak_ptr::operator <= (const weak_ptr &t) const { + return !t.operator < (*this); +} +template +inline bool weak_ptr::operator >= (const weak_ptr &t) const { + return !operator < (t); +} +template +inline bool weak_ptr::operator == (const shared_ptr &t) const { + return operator -> () == t.operator -> (); +} +template +inline bool weak_ptr::operator != (const shared_ptr &t) const { + return !operator == (t); +} +template +inline bool weak_ptr::operator < (const shared_ptr &t) const { + return operator -> () < t.operator -> (); +} +template +inline bool weak_ptr::operator > (const shared_ptr &t) const { + return t.operator < (*this); +} +template +inline bool weak_ptr::operator <= (const shared_ptr &t) const { + return !t.operator < (*this); +} +template +inline bool weak_ptr::operator >= (const shared_ptr &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 = ""; const std::string ZLApplication::MouseScrollUpKey = ""; 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 - * - * 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -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 &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); - void registerPopupData(const std::string &actionId, shared_ptr popupData); - - void setView(shared_ptr view); - ZLView::Angle rotation() const; - - void setFullscreen(bool fullscreen); - bool isFullscreen() const; - -public: - virtual ~ZLApplication(); - virtual void initWindow(); - - shared_ptr currentView() const; - shared_ptr context(); - - void grabAllKeys(bool grab); - void trackStylus(bool track); - - void resetWindowCaption(); - void setHyperlinkCursor(bool hyperlink); - - shared_ptr 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 keyBindings(); - void doActionByKey(const std::string &key); - - void quit(); - virtual bool closeView(); - virtual void openFile(const ZLFile &file); - virtual bool canDragFiles(const std::vector &filePaths) const; - virtual void dragFiles(const std::vector &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 &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 myViewWidget; - shared_ptr myInitialView; - std::map > myActionMap; - mutable shared_ptr myToolbar; - mutable shared_ptr myFullscreenToolbar; - mutable shared_ptr myMenubar; - shared_ptr myContext; - shared_ptr myWindow; - ZLTime myLastKeyActionTime; - shared_ptr 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 - * - * 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 -#include - -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 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 - * - * 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 - -#include - -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 +#include 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 - * - * 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 -#include - -#include - -#include -#include -#include - -class ZLBlockTreeView; - -class ZLBlockTreeNode : public ZLObjectWithRTTI { - -public: - typedef std::vector 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 action); - void removeAllHyperlinks(); - -private: - ZLBlockTreeView &myView; - ZLBlockTreeNode *myParent; - std::size_t myChildIndex; - - List myChildren; - bool myIsOpen; - - typedef std::map > 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 - * - * 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 - -#include - -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 - * - * 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 -#include -#include - -class ZLMimeType { - -private: - - ZLMimeType(std::string& name, std::map& parameters); - -private: - - static std::map > ourSimpleTypesMap; - -public: - static shared_ptr get(const char *text); - static shared_ptr get(std::string text); - static bool isImage(shared_ptr mimeType); - -private: - - const std::map 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 APPLICATION_XML; - static const shared_ptr APPLICATION_ZIP; - static const shared_ptr APPLICATION_EPUB_ZIP; - static const shared_ptr APPLICATION_FB2_ZIP; - static const shared_ptr APPLICATION_MOBIPOCKET_EBOOK; - static const shared_ptr APPLICATION_PDF; - static const shared_ptr APPLICATION_CHM; - static const shared_ptr APPLICATION_PALM_DB; - static const shared_ptr APPLICATION_ATOM_XML; - static const shared_ptr APPLICATION_LITRES_XML; - static const shared_ptr APPLICATION_LITRES_XML_BOOKS; - static const shared_ptr APPLICATION_LITRES_XML_AUTHORS; - static const shared_ptr APPLICATION_LITRES_XML_GENRES; - static const shared_ptr APPLICATION_OPENSEARCH_XML; - static const shared_ptr APPLICATION_OR_XML; - - static const shared_ptr APPLICATION_GZIP; - static const shared_ptr APPLICATION_BZIP2; - static const shared_ptr APPLICATION_TAR; - static const shared_ptr APPLICATION_TAR_GZIP; - static const shared_ptr APPLICATION_TAR_BZIP2; - static const shared_ptr APPLICATION_TAR_7Z; - - static const shared_ptr IMAGE_PNG; - static const shared_ptr IMAGE_JPEG; - static const shared_ptr IMAGE_SVG; - static const shared_ptr IMAGE_PALM; - static const shared_ptr IMAGE_AUTO; - - static const shared_ptr TEXT_HTML; - static const shared_ptr TEXT_PLAIN; - static const shared_ptr TEXT_XML; - - static const shared_ptr 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 - * - * 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 - -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 - * - * 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 -#include -#include - -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 +#include #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 - * - * 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 -#include - -#include -#include - -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 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 - * - * 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 - -#include -#include -#include -#include -#include - -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 createDialog(const ZLResourceKey &key) const = 0; - virtual shared_ptr createOptionsDialog(const ZLResourceKey &key, shared_ptr applyAction = 0, bool showApplyButton = false) const = 0; - virtual shared_ptr createOpenFileDialog(const ZLResourceKey &key, const std::string &directoryPath, const std::string &filePath, const ZLOpenFileDialog::Filter &filter) const = 0; - virtual shared_ptr 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 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 - * - * 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 - -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 - * - * 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 -#include - -#include - -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 &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 &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 myActionNames; -}; - -class ZLOrderOptionEntry : public ZLOptionEntry { - -public: - ZLOrderOptionEntry(); - std::vector &values(); - -protected: - ZLOptionKind kind() const; - -private: - std::vector 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 &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 &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 - * - * 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 -#include - -#include - -#include -#include -#include -#include - -class ZLOptionEntry; - -class ZLDialogContentBuilder; - -class ZLOptionsDialog { - -protected: - static void addPlatformDependentBuilder(shared_ptr builder); - -private: - static std::vector > ourPlatformDependentBuilders; - -protected: - ZLOptionsDialog(const ZLResource &resource, shared_ptr 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 myApplyAction; - std::vector > 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 - * - * 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 -#include -#include - -class ZLProgressDialog { - -private: - class ProgressListener; - -protected: - ZLProgressDialog(const ZLResourceKey &key); - -public: - virtual ~ZLProgressDialog(); - - shared_ptr 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 - * - * 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 -#include -#include - -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 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 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 #include -#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 - * - * 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 -#include -#include - -#include - -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 &aliases() const; - shared_ptr createConverter() const; - bool canCreateConverter() const; - -private: - const std::string myName; - const std::string myVisibleName; - std::vector myAliases; - -private: - ZLEncodingConverterInfo(const ZLEncodingConverterInfo&); - ZLEncodingConverterInfo &operator = (const ZLEncodingConverterInfo&); -}; - -typedef shared_ptr ZLEncodingConverterInfoPtr; - -class ZLEncodingSet { - -public: - ZLEncodingSet(const std::string &name); - void addInfo(ZLEncodingConverterInfoPtr info); - - const std::string &name() const; - const std::vector &infos() const; - -private: - const std::string myName; - std::vector 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 > &sets(); - ZLEncodingConverterInfoPtr info(const std::string &name); - ZLEncodingConverterInfoPtr info(int code); - shared_ptr defaultConverter(); - void registerProvider(shared_ptr provider); - -private: - void addInfo(ZLEncodingConverterInfoPtr info); - const std::vector > &providers() const; - -private: - std::vector > mySets; - std::map myInfosByName; - std::vector > 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 - * - * 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 -#include - -#include - -class ZLDir { - -public: - static shared_ptr 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 &names, bool includeSymlinks) = 0; - virtual void collectFiles(std::vector &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 - * - * 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 -#include - -#include -#include -#include - -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 > 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 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 mimeType() const; - - std::string physicalFilePath() const; - std::string resolvedPath() const; - - shared_ptr inputStream() const; - shared_ptr outputStream(bool writeThrough = false) const; - shared_ptr 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 envelopeCompressedStream(shared_ptr &base) const; - -private: - std::string myPath; - std::string myNameWithExtension; - std::string myNameWithoutExtension; - std::string myExtension; - mutable shared_ptr 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 - * - * 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 - * - * 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 - -#include -#include - -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 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 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 - * - * 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 - -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 #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 -#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 - * - * 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 - -#include - -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 &names, bool) { shared_ptr 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 &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 - * - * 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 - -#include - -class ZLBase64EncodedImage : public ZLSingleImage { - -public: - ZLBase64EncodedImage(shared_ptr mimeType); - ~ZLBase64EncodedImage(); - void addData(const std::string &text, std::size_t offset, std::size_t len); - void addData(const std::vector &text); - const shared_ptr stringData() const; - -private: - void decode() const; - -private: - mutable std::string myEncodedData; - mutable shared_ptr myData; -}; - -inline ZLBase64EncodedImage::ZLBase64EncodedImage(shared_ptr 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 - * - * 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 -#include - -#include -#include - -class ZLFileImage : public ZLSingleImage { - -public: - struct Block { - unsigned int offset; - unsigned int size; - - Block(unsigned int off, unsigned int s); - }; - typedef std::vector 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 stringData() const; - -protected: - //shared_ptr 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 - * - * 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 - -#include - -#include - -class ZLNetworkRequest; - -class ZLImage { - -protected: - ZLImage(); - -public: - virtual ~ZLImage(); - virtual bool isSingle() const = 0; - virtual shared_ptr synchronizationData() const; - virtual bool good() const = 0; -}; - -class ZLSingleImage : public ZLImage { - -protected: - ZLSingleImage(shared_ptr mimeType); - virtual ~ZLSingleImage(); - -public: - bool isSingle() const { return true; } - shared_ptr mimeType() const; - bool good() const; - virtual const shared_ptr stringData() const = 0; - -private: - shared_ptr 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 subImage(unsigned int row, unsigned int column) const = 0; -}; - -inline ZLImage::ZLImage() {} -inline ZLImage::~ZLImage() {} - -inline ZLSingleImage::ZLSingleImage(shared_ptr mimeType) : myMimeType(mimeType) {} -inline ZLSingleImage::~ZLSingleImage() {} -inline shared_ptr 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 - * - * 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 -#include - -#include - -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 imageData(const ZLImage &image) const; - -public: - virtual shared_ptr makeBatchImage(const std::vector > &images, shared_ptr defaultImage) const = 0; - -protected: - ZLImageManager() {} - virtual ~ZLImageManager() {} - - virtual shared_ptr 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 - * - * 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 - -class ZLFileImage; - -class ZLNetworkImage : public ZLSingleImage { - -public: - ZLNetworkImage(shared_ptr mimeType, const std::string &url); - const shared_ptr stringData() const; - -private: - shared_ptr synchronizationData() const; - -private: - const std::string myURL; - std::string myFileName; - mutable bool myIsSynchronized; - mutable shared_ptr 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 - * - * 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 - -#include -#include - -class ZLStreamImage : public ZLSingleImage { - -public: - ZLStreamImage(shared_ptr mimeType, std::size_t offset, std::size_t size = 0); - const shared_ptr stringData() const; - -private: - virtual shared_ptr inputStream() const = 0; - -private: - std::size_t myOffset; - mutable std::size_t mySize; -}; - -inline ZLStreamImage::ZLStreamImage(shared_ptr 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 - * - * 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 -#include - -//#include - -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 findInfo(const char *buffer, std::size_t length, int matchingCriterion = 0); - shared_ptr findInfoForEncoding(const std::string &encoding, const char *buffer, std::size_t length, int matchingCriterion = 0); - -private: - typedef std::vector > 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 - * - * 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 - -#include - -class ZLLanguageList { - -public: - static std::string patternsDirectoryPath(); - static const std::vector &languageCodes(); - static std::string languageName(const std::string &code); - -private: - static std::vector 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 #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 - * - * 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 - -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 - * - * 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 -#include - -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 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 - * - * 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 -#include -#include - -#include - -class ZLMessageOutputChannel; -class ZLMessageSender; - -class ZLMessageHandler; - -class ZLCommunicationManager { - -public: - static ZLCommunicationManager &Instance(); - static void deleteInstance(); - -protected: - static ZLCommunicationManager *ourInstance; - -public: - typedef std::map Data; - -protected: - ZLCommunicationManager(); - virtual ~ZLCommunicationManager(); - void init(); - void onMessageReceived(const std::string &command, const std::vector &arguments); - -public: - virtual shared_ptr 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 receiver); - -private: - shared_ptr handler(const std::string &command); - -private: - std::map > myRegisteredHandlers; - bool myInitialized; - -private: - ZLCommunicationManager(const ZLCommunicationManager&); - const ZLCommunicationManager &operator = (const ZLCommunicationManager&); -}; - -class ZLMessageOutputChannel { - -public: - virtual ~ZLMessageOutputChannel(); - - virtual shared_ptr 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 &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 - * - * 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 - - -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 - * - * 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 - -#include -#include - -#include -#include - -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 request) const; - std::string performAsync(shared_ptr 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 listener = 0) const; - -public: - shared_ptr createDownloadRequest(const std::string &url, const std::string &fileName) const; - shared_ptr createDownloadRequest(const std::string &url, shared_ptr stream) const; - shared_ptr createNoActionRequest(const std::string &url) const; - shared_ptr createReadToStringRequest(const std::string &url, std::string &buffer) const; - shared_ptr createXMLParserRequest(const std::string &url, shared_ptr reader, shared_ptr runnable = 0) const; - -public: - void setUserAgent(const std::string &userAgent); - const std::string &userAgent() const; - -private: - mutable shared_ptr myConnectTimeoutOption; - mutable shared_ptr myTimeoutOption; - mutable shared_ptr myUseProxyOption; - mutable shared_ptr myProxyHostOption; - mutable shared_ptr 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 - * - * 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 -#include - -#include - -class ZLNetworkRequest { - -public: - typedef std::vector > 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 > &postParameters() const; - void setPostParameters(const std::vector > ¶meters); - - -public: //listeners methods - bool hasListener() const; - void setListener(shared_ptr listener); - void setPercent(int ready, int full); - void setUIStatus(bool enabled); - -protected: - void finished(const std::string &error); - shared_ptr listener() const; - -private: - const std::string myURL; - std::string myErrorMessage; - - std::string myUserName; - std::string myPassword; - - bool myRedirectionSupported; - - std::vector > myPostParameters; - - shared_ptr 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 > &ZLNetworkRequest::postParameters() const { return myPostParameters; } - -inline shared_ptr 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 - * - * 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 - -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 - * - * 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 - - -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 - * - * 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 -#include - -#include -#include - -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 &names); - static void listOptionGroups(std::vector &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 - * - * 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 - -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 - * - * 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 -#include "ZLNetworkRequest.h" - -class ZLExecutionUtil { - //code for convenient async syntax createListener method: - public: - template - static shared_ptr createListener(shared_ptr data, T object, Method method) { - data->addUserData(ourHandlerId, new HandlerHelper(object, method)); - return createListener(data); - } - template - static shared_ptr createListener(T object, Method method) { - return createListener(new ZLUserDataHolder, object, method); - } - template - static shared_ptr createListener(ZLUserData *scope, T object, Method method) { - shared_ptr 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 - 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 createListener(shared_ptr 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 - * - * 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 - -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 - * - * 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 - * - * 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 - -#include -#include - -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 task, int interval) = 0; - void addAutoRemovableTask(shared_ptr task, int delay = 0); - void removeTask(shared_ptr task); - -protected: - virtual void removeTaskInternal(shared_ptr 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 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 static void deleteLater(shared_ptr object, int delay = 0) { - deleteLater(new shared_ptr(object), delay); - } - template static void deleteLater(T *object, int delay = 0) { - DeleteFunc func = reinterpret_cast(&DeleteHelper::func); - ZLTimeManager::Instance().addAutoRemovableTask(new DeleteTask(object, func), delay); - } - -private: - std::map,shared_ptr > 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 - * - * 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 - * - * 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 #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 - * - * 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 -#include - -#include - -#include -#include -#include -#include - -// 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 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 listener = 0); - virtual void requestMoreChildren(shared_ptr listener = 0); - - virtual const ZLResource &resource() const; - void registerAction(shared_ptr action); - const std::vector > &actions() const; - std::string actionText(const shared_ptr &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 > 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 - * - * 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 - -class ZLTreePageInfo { -public: - - virtual bool isPageInfoLoaded() = 0; - virtual void loadAll(shared_ptr listener) = 0; - - virtual std::string title() const = 0; - virtual std::vector authors() const = 0; - virtual std::vector tags() const = 0; - virtual std::string summary() const = 0; - virtual shared_ptr image() const = 0; - - virtual const std::vector > &actions() const = 0; - virtual std::string actionText(const shared_ptr &action) const = 0; - virtual const std::vector > 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 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 - * - * 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 - -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 - * - * 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 - -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 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 - * - * 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 -T zlobject_cast(ZLObjectWithRTTI *object) { - if (!object || !object->isInstanceOf(reinterpret_cast(0)->TYPE_ID)) - return 0; - return static_cast(object); -} - -template -T zlobject_cast(const ZLObjectWithRTTI *object) { - if (!object || !object->isInstanceOf(reinterpret_cast(0)->TYPE_ID)) - return 0; - return static_cast(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 #include -#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 #include -#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 #include -#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 #include -#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 -#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 -#include "../../../../core/src/view/ZLViewWidget.h" +#include "ZLViewWidget.h" #include 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 - * - * 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 - -class ZLBase64InputStream : public ZLInputStream { -public: - ZLBase64InputStream(shared_ptr 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 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 - * - * 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 - * - * 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 - * - * 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 - -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 - * - * 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 - -class ZLHexInputStream : public ZLInputStream { -public: - ZLHexInputStream(shared_ptr 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 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 - * - * 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 - -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 - * - * 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 - -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 - * - * 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 - -class ZLSliceInputStream : public ZLInputStream { -public: - ZLSliceInputStream(shared_ptr 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 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 - * - * 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 -#include - -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 &buffer); - static void stripWhiteSpaces(std::string &str); - - static const std::string SPACE; - static std::vector 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 - static std::string join(T iterable, F functor, std::string separator); - template - static std::string join(T iterable, std::string separator); - - template - struct self { - inline T operator()(const T &t) { - return t; - } - }; -}; - -template -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 -std::string ZLStringUtil::join(T iterable, std::string separator) { - return join(iterable, ZLStringUtil::self(), 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 - * - * 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 -#include -#include - -class ZLUnicodeUtil { - -private: - ZLUnicodeUtil(); - -public: - typedef uint16_t Ucs2Char; - typedef std::vector Ucs2String; - typedef uint32_t Ucs4Char; - typedef std::vector 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 - * - * 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 -#include - -#include - -class ZLUserData { - -public: - virtual ~ZLUserData(); -}; - -class ZLUserDataHolder { - -public: - ZLUserDataHolder(); - ZLUserDataHolder(const ZLUserDataHolder &other); - virtual ~ZLUserDataHolder(); - - void addUserData(const std::string &key, shared_ptr data); - void removeUserData(const std::string &key); - shared_ptr getUserData(const std::string &key) const; - -private: - ZLUserDataHolder &operator =(const ZLUserDataHolder &other); - std::map > 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 - * - * 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 - -template class Allocator { - -public: - Allocator(); - ~Allocator(); - - void *allocate(); - void free(void *ptr); - -private: - void addPool(); - -private: - std::vector myPools; - void *myFirstUnused; - void *myLastUnused; -}; - -template -inline Allocator::Allocator() { - addPool(); -} - -template -inline Allocator::~Allocator() { - for (std::vector::const_iterator it = myPools.begin(); it != myPools.end(); ++it) { - delete[] (char*)*it; - } -} - -template -inline void Allocator::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 -void *Allocator::allocate() { - void *ptr = myFirstUnused; - if (myFirstUnused == myLastUnused) { - addPool(); - } else { - myFirstUnused = *(void**)myFirstUnused; - } - return ptr; -} - -template -void Allocator::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 - * - * 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 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 weak_ptr; - -template class shared_ptr { - friend class weak_ptr; - - private: - shared_ptr_storage *myStorage; - - shared_ptr_storage *newStorage(T *t); - void attachStorage(shared_ptr_storage *storage); - void detachStorage(); - - public: - shared_ptr(); - shared_ptr(T *t); - shared_ptr(const shared_ptr &t); - shared_ptr(const weak_ptr &t); - ~shared_ptr(); - - const shared_ptr &operator = (T *t); - const shared_ptr &operator = (const shared_ptr &t); - const shared_ptr &operator = (const weak_ptr &t); - - T* operator -> () const; - T& operator * () const; - bool isNull() const; - void reset(); - bool operator == (const weak_ptr &t) const; - bool operator != (const weak_ptr &t) const; - bool operator < (const weak_ptr &t) const; - bool operator > (const weak_ptr &t) const; - bool operator <= (const weak_ptr &t) const; - bool operator >= (const weak_ptr &t) const; - bool operator == (const shared_ptr &t) const; - bool operator != (const shared_ptr &t) const; - bool operator < (const shared_ptr &t) const; - bool operator > (const shared_ptr &t) const; - bool operator <= (const shared_ptr &t) const; - bool operator >= (const shared_ptr &t) const; -}; - -template class weak_ptr { - friend class shared_ptr; - private: - shared_ptr_storage *myStorage; - - void attachStorage(shared_ptr_storage *storage); - void detachStorage(); - - public: - weak_ptr(); - weak_ptr(const shared_ptr &t); - weak_ptr(const weak_ptr &t); - ~weak_ptr(); - - const weak_ptr &operator = (const weak_ptr &t); - const weak_ptr &operator = (const shared_ptr &t); - - T* operator -> () const; - T& operator * () const; - bool isNull() const; - void reset(); - - bool operator == (const weak_ptr &t) const; - bool operator != (const weak_ptr &t) const; - bool operator < (const weak_ptr &t) const; - bool operator > (const weak_ptr &t) const; - bool operator <= (const weak_ptr &t) const; - bool operator >= (const weak_ptr &t) const; - bool operator == (const shared_ptr &t) const; - bool operator != (const shared_ptr &t) const; - bool operator < (const shared_ptr &t) const; - bool operator > (const shared_ptr &t) const; - bool operator <= (const shared_ptr &t) const; - bool operator >= (const shared_ptr &t) const; -}; - -template -inline shared_ptr_storage::shared_ptr_storage(T *pointer) { - myPointer = pointer; - myCounter = 0; - myWeakCounter = 0; -} -template -inline shared_ptr_storage::~shared_ptr_storage() { -} -template -inline T* shared_ptr_storage::pointer() const { - return myPointer; -} -template -inline T& shared_ptr_storage::content() const { - return *myPointer; -} -template -inline void shared_ptr_storage::addReference() { - ++myCounter; -} -template -inline void shared_ptr_storage::removeReference() { - --myCounter; - if (myCounter == 0) { - T* ptr = myPointer; - myPointer = 0; - delete ptr; - } -} -template -inline void shared_ptr_storage::addWeakReference() { - ++myWeakCounter; -} -template -inline void shared_ptr_storage::removeWeakReference() { - --myWeakCounter; -} -template -inline unsigned int shared_ptr_storage::counter() const { - return myCounter + myWeakCounter; -} - -template -inline shared_ptr_storage *shared_ptr::newStorage(T *t) { - return (t == 0) ? 0 : new shared_ptr_storage(t); -} -template -inline void shared_ptr::attachStorage(shared_ptr_storage *storage) { - myStorage = storage; - if (myStorage != 0) { - myStorage->addReference(); - } -} -template -inline void shared_ptr::detachStorage() { - if (myStorage != 0) { - if (myStorage->counter() == 1) { - myStorage->removeReference(); - delete myStorage; - } else { - myStorage->removeReference(); - } - } -} - -template -inline shared_ptr::shared_ptr() { - myStorage = 0; -} -template -inline shared_ptr::shared_ptr(T *t) { - attachStorage(newStorage(t)); -} -template -inline shared_ptr::shared_ptr(const shared_ptr &t) { - attachStorage(t.myStorage); -} -template -inline shared_ptr::shared_ptr(const weak_ptr &t) { - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } -} -template -inline shared_ptr::~shared_ptr() { - detachStorage(); -} -template -inline const shared_ptr &shared_ptr::operator = (T *t) { - detachStorage(); - attachStorage(newStorage(t)); - return *this; -} -template -inline const shared_ptr &shared_ptr::operator = (const shared_ptr &t) { - if (&t != this) { - detachStorage(); - attachStorage(t.myStorage); - } - return *this; -} -template -inline const shared_ptr &shared_ptr::operator = (const weak_ptr &t) { - detachStorage(); - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } - return *this; -} - -template -inline T* shared_ptr::operator -> () const { - return (myStorage == 0) ? 0 : myStorage->pointer(); -} -template -inline T& shared_ptr::operator * () const { - return myStorage->content(); -} -template -inline bool shared_ptr::isNull() const { - return myStorage == 0; -} -template -inline void shared_ptr::reset() { - detachStorage(); - attachStorage(0); -} -template -inline bool shared_ptr::operator == (const weak_ptr &t) const { - return operator -> () == t.operator -> (); -} -template -inline bool shared_ptr::operator != (const weak_ptr &t) const { - return !operator == (t); -} -template -inline bool shared_ptr::operator < (const weak_ptr &t) const { - return operator -> () < t.operator -> (); -} -template -inline bool shared_ptr::operator > (const weak_ptr &t) const { - return t.operator < (*this); -} -template -inline bool shared_ptr::operator <= (const weak_ptr &t) const { - return !t.operator < (*this); -} -template -inline bool shared_ptr::operator >= (const weak_ptr &t) const { - return !operator < (t); -} -template -inline bool shared_ptr::operator == (const shared_ptr &t) const { - return operator -> () == t.operator -> (); -} -template -inline bool shared_ptr::operator != (const shared_ptr &t) const { - return !operator == (t); -} -template -inline bool shared_ptr::operator < (const shared_ptr &t) const { - return operator -> () < t.operator -> (); -} -template -inline bool shared_ptr::operator > (const shared_ptr &t) const { - return t.operator < (*this); -} -template -inline bool shared_ptr::operator <= (const shared_ptr &t) const { - return !t.operator < (*this); -} -template -inline bool shared_ptr::operator >= (const shared_ptr &t) const { - return !operator < (t); -} - -template -inline void weak_ptr::attachStorage(shared_ptr_storage *storage) { - myStorage = storage; - if (myStorage != 0) { - myStorage->addWeakReference(); - } -} -template -inline void weak_ptr::detachStorage() { - if (myStorage != 0) { - myStorage->removeWeakReference(); - if (myStorage->counter() == 0) { - delete myStorage; - } - } -} - -template -inline weak_ptr::weak_ptr() { - myStorage = 0; -} -template -inline weak_ptr::weak_ptr(const shared_ptr &t) { - attachStorage(t.myStorage); -} -template -inline weak_ptr::weak_ptr(const weak_ptr &t) { - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } -} -template -inline weak_ptr::~weak_ptr() { - detachStorage(); -} - -template -inline const weak_ptr &weak_ptr::operator = (const weak_ptr &t) { - if (&t != this) { - detachStorage(); - if (!t.isNull()) { - attachStorage(t.myStorage); - } else { - attachStorage(0); - } - } - return *this; -} -template -inline const weak_ptr &weak_ptr::operator = (const shared_ptr &t) { - detachStorage(); - attachStorage(t.myStorage); - return *this; -} - -template -inline T* weak_ptr::operator -> () const { - return (myStorage == 0) ? 0 : myStorage->pointer(); -} -template -inline T& weak_ptr::operator * () const { - return myStorage->content(); -} -template -inline bool weak_ptr::isNull() const { - return (myStorage == 0) || (myStorage->pointer() == 0); -} -template -inline void weak_ptr::reset() { - detachStorage(); - attachStorage(0); -} -template -inline bool weak_ptr::operator == (const weak_ptr &t) const { - return operator -> () == t.operator -> (); -} -template -inline bool weak_ptr::operator != (const weak_ptr &t) const { - return !operator == (t); -} -template -inline bool weak_ptr::operator < (const weak_ptr &t) const { - return operator -> () < t.operator -> (); -} -template -inline bool weak_ptr::operator > (const weak_ptr &t) const { - return t.operator < (*this); -} -template -inline bool weak_ptr::operator <= (const weak_ptr &t) const { - return !t.operator < (*this); -} -template -inline bool weak_ptr::operator >= (const weak_ptr &t) const { - return !operator < (t); -} -template -inline bool weak_ptr::operator == (const shared_ptr &t) const { - return operator -> () == t.operator -> (); -} -template -inline bool weak_ptr::operator != (const shared_ptr &t) const { - return !operator == (t); -} -template -inline bool weak_ptr::operator < (const shared_ptr &t) const { - return operator -> () < t.operator -> (); -} -template -inline bool weak_ptr::operator > (const shared_ptr &t) const { - return t.operator < (*this); -} -template -inline bool weak_ptr::operator <= (const shared_ptr &t) const { - return !t.operator < (*this); -} -template -inline bool weak_ptr::operator >= (const shared_ptr &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 - * - * 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 -#include - -#include -#include - -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 &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 - * - * 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 -#include - -#include -#include - -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 &fontFamilies() const; - virtual const std::string realFontFamilyName(std::string &fontFamily) const = 0; - -protected: - virtual void fillFamiliesList(std::vector &families) const = 0; - -private: - mutable std::vector 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 - * - * 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 - -#include - -#include -#include - -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 +#include "ZLAsynchronousInputStream.h" #include #include #include #include - -#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 - * - * 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 -#include -#include - -#include - -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 stream); - bool readDocument(shared_ptr stream); - - const std::string &errorMessage() const; - - typedef std::map 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 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 &externalDTDs() const; - virtual void collectExternalEntities(std::map &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 > 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 - * - * 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 -#include -#include - -#include - -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 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 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 #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 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 #include -#include +#include 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);