* creating branch with HISA plug-in - due tu critical bug we need to remove for... svn/home_applet_plugin
authorstranger <dariusz.wiechecki@gmail.com>
Thu, 9 Aug 2007 13:07:21 +0000 (13:07 +0000)
committerstranger <dariusz.wiechecki@gmail.com>
Thu, 9 Aug 2007 13:07:21 +0000 (13:07 +0000)
git-svn-id: file:///svnroot/mdictionary/branches/home_applet_plugin@164 5bde0345-f819-0410-ac75-e5045f9217cc

251 files changed:
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
add_dict [new file with mode: 0755]
data/bookmarks/bdb/bm_trans.db [new file with mode: 0644]
data/bookmarks/bdb/bm_words.db [new file with mode: 0644]
data/bookmarks/sql/ws_bookmarks [new file with mode: 0644]
data/bookmarks/sql3/ws_bookmarks3 [new file with mode: 0644]
data/bookmarks/xdxf/ws_bookmarks.cache [new file with mode: 0644]
data/bookmarks/xdxf/ws_bookmarks.xdxf [new file with mode: 0644]
data/dictionaries/StarDictSampleDict/sample.dict.dz [new file with mode: 0644]
data/dictionaries/StarDictSampleDict/sample.idx [new file with mode: 0644]
data/dictionaries/StarDictSampleDict/sample.ifo [new file with mode: 0644]
data/dictionaries/XDXFSampleDict/dict.xdxf [new file with mode: 0644]
data/docs/whitestork/changelog [new file with mode: 0644]
data/docs/whitestork/changelog.Debian [new file with mode: 0644]
data/docs/whitestork/copyright [new file with mode: 0644]
data/docs/whitestorkdictionary/changelog [new file with mode: 0644]
data/docs/whitestorkdictionary/changelog.Debian [new file with mode: 0644]
data/docs/whitestorkdictionary/copyright [new file with mode: 0644]
data/docs/whitestorkgui/changelog [new file with mode: 0644]
data/docs/whitestorkgui/changelog.Debian [new file with mode: 0644]
data/docs/whitestorkgui/copyright [new file with mode: 0644]
data/docs/whitestorkplugins/changelog [new file with mode: 0644]
data/docs/whitestorkplugins/changelog.Debian [new file with mode: 0644]
data/docs/whitestorkplugins/copyright [new file with mode: 0644]
data/icons/engine_xdxf_icon.png [new file with mode: 0644]
data/icons/engine_xdxf_icon_2.png [new file with mode: 0644]
data/icons/qgn_indi_search_whitestork.png [new file with mode: 0644]
data/icons/whitestork.png [new file with mode: 0644]
data/icons/whitestork_icon.png [new file with mode: 0644]
data/icons/ws_top.png [new file with mode: 0644]
data/icons/ws_tra.png [new file with mode: 0644]
data/icons/ws_warning_icon.png [new file with mode: 0644]
data/locale/POTFILES.in [new file with mode: 0644]
data/locale/en_GB.po [new file with mode: 0644]
data/locale/es.po [new file with mode: 0644]
data/locale/pl_PL.po [new file with mode: 0644]
data/mis/whitestork-search.xml [new file with mode: 0644]
data/other/org.maemo.WhiteStorkGui.service [new file with mode: 0644]
data/other/org.maemo.WhiteStorkManager.service [new file with mode: 0644]
data/other/whitestork.desktop [new file with mode: 0644]
data/package_contents/whitestork/DEBIAN/control [new file with mode: 0644]
data/package_contents/whitestork/DEBIAN/postinst [new file with mode: 0755]
data/package_contents/whitestork/DEBIAN/postrm [new file with mode: 0755]
data/package_contents/whitestork/DEBIAN/preinst [new file with mode: 0755]
data/package_contents/whitestork/DEBIAN/prerm [new file with mode: 0755]
data/package_contents/whitestorkdictionary/DEBIAN/control [new file with mode: 0644]
data/package_contents/whitestorkdictionary/DEBIAN/postinst [new file with mode: 0755]
data/package_contents/whitestorkdictionary/DEBIAN/postrm [new file with mode: 0755]
data/package_contents/whitestorkdictionary/DEBIAN/preinst [new file with mode: 0755]
data/package_contents/whitestorkdictionary/DEBIAN/prerm [new file with mode: 0755]
data/package_contents/whitestorkgui/DEBIAN/control [new file with mode: 0644]
data/package_contents/whitestorkgui/DEBIAN/postinst [new file with mode: 0755]
data/package_contents/whitestorkgui/DEBIAN/postrm [new file with mode: 0755]
data/package_contents/whitestorkgui/DEBIAN/preinst [new file with mode: 0755]
data/package_contents/whitestorkgui/DEBIAN/prerm [new file with mode: 0755]
data/package_contents/whitestorkplugins/DEBIAN/control [new file with mode: 0644]
data/package_contents/whitestorkplugins/DEBIAN/postinst [new file with mode: 0755]
data/package_contents/whitestorkplugins/DEBIAN/postrm [new file with mode: 0755]
data/package_contents/whitestorkplugins/DEBIAN/preinst [new file with mode: 0755]
data/package_contents/whitestorkplugins/DEBIAN/prerm [new file with mode: 0755]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/files [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/whitestork.postinst [new file with mode: 0755]
debian/whitestork.prerm [new file with mode: 0755]
debian/whitestork.substvars [new file with mode: 0644]
debian/whitestork/DEBIAN/control [new file with mode: 0644]
debian/whitestork/DEBIAN/md5sums [new file with mode: 0644]
debian/whitestork/DEBIAN/postinst [new file with mode: 0755]
debian/whitestork/DEBIAN/prerm [new file with mode: 0755]
debian/whitestork/usr/bin/WhiteStorkManager [new file with mode: 0755]
debian/whitestork/usr/lib/WhiteStork/ws_bookmark.so [new file with mode: 0644]
debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_trans.db [new file with mode: 0644]
debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_words.db [new file with mode: 0644]
debian/whitestork/usr/share/dbus-1/services/org.maemo.WhiteStorkManager.service [new file with mode: 0644]
debian/whitestork/usr/share/doc/whitestork/changelog.Debian.gz [new file with mode: 0644]
debian/whitestork/usr/share/doc/whitestork/changelog.gz [new file with mode: 0644]
debian/whitestork/usr/share/doc/whitestork/copyright [new file with mode: 0644]
debian/whitestorkgui.postinst [new file with mode: 0755]
debian/whitestorkgui.prerm [new file with mode: 0755]
debian/whitestorkgui.substvars [new file with mode: 0644]
debian/whitestorkgui/DEBIAN/control [new file with mode: 0644]
debian/whitestorkgui/DEBIAN/md5sums [new file with mode: 0644]
debian/whitestorkgui/DEBIAN/postinst [new file with mode: 0755]
debian/whitestorkgui/DEBIAN/prerm [new file with mode: 0755]
debian/whitestorkgui/usr/bin/WhiteStork [new file with mode: 0755]
debian/whitestorkgui/usr/share/applications/hildon/whitestork.desktop [new file with mode: 0644]
debian/whitestorkgui/usr/share/dbus-1/services/org.maemo.WhiteStorkGui.service [new file with mode: 0644]
debian/whitestorkgui/usr/share/doc/whitestorkgui/changelog.Debian.gz [new file with mode: 0644]
debian/whitestorkgui/usr/share/doc/whitestorkgui/copyright [new file with mode: 0644]
debian/whitestorkgui/usr/share/locale/en_GB/LC_MESSAGES/whitestork.mo [new file with mode: 0644]
debian/whitestorkgui/usr/share/locale/es/LC_MESSAGES/whitestork.mo [new file with mode: 0644]
debian/whitestorkgui/usr/share/locale/pl_PL/LC_MESSAGES/whitestork.mo [new file with mode: 0644]
debian/whitestorkgui/usr/share/mis/whitestork-search.xml [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/qgn_indi_search_whitestork.png [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/whitestork.png [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/whitestork_icon.png [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/ws_top.png [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/ws_tra.png [new file with mode: 0644]
debian/whitestorkgui/usr/share/pixmaps/ws_warning_icon.png [new file with mode: 0644]
debian/whitestorkplugins.postinst [new file with mode: 0755]
debian/whitestorkplugins.substvars [new file with mode: 0644]
debian/whitestorkplugins/DEBIAN/control [new file with mode: 0644]
debian/whitestorkplugins/DEBIAN/md5sums [new file with mode: 0644]
debian/whitestorkplugins/DEBIAN/postinst [new file with mode: 0755]
debian/whitestorkplugins/usr/lib/WhiteStork/engine_stardict.so [new file with mode: 0644]
debian/whitestorkplugins/usr/lib/WhiteStork/engine_xdxf.so [new file with mode: 0644]
debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.dict.dz [new file with mode: 0644]
debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.idx [new file with mode: 0644]
debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.ifo [new file with mode: 0644]
debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/XDXFSampleDict/dict.xdxf [new file with mode: 0644]
debian/whitestorkplugins/usr/share/doc/whitestorkplugins/changelog.Debian.gz [new file with mode: 0644]
debian/whitestorkplugins/usr/share/doc/whitestorkplugins/copyright [new file with mode: 0644]
debian/whitestorkplugins/usr/share/pixmaps/engine_xdxf_icon.png [new file with mode: 0644]
generate_locale [new file with mode: 0755]
generate_repo [new file with mode: 0755]
include/dictionary_engine.h [new file with mode: 0644]
include/ws_dbus.h [new file with mode: 0644]
logs/clean.log [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/domain.mo [new file with mode: 0644]
po/en_GB.po [new file with mode: 0644]
po/pl_PL.po [new file with mode: 0644]
po/pl_Pl.po [new file with mode: 0644]
po/template.po [new file with mode: 0644]
po/whitestork.mo [new file with mode: 0644]
src/bookmarks/bdb/COPYING [new file with mode: 0755]
src/bookmarks/bdb/Makefile [new file with mode: 0755]
src/bookmarks/bdb/data/bm_trans.db [new file with mode: 0755]
src/bookmarks/bdb/data/bm_words.db [new file with mode: 0755]
src/bookmarks/bdb/include/.kateconfig [new file with mode: 0755]
src/bookmarks/bdb/include/engine_bookmark.h [new file with mode: 0755]
src/bookmarks/bdb/src/.kateconfig [new file with mode: 0755]
src/bookmarks/bdb/src/berkeleyRead.c [new file with mode: 0644]
src/bookmarks/bdb/src/engine_bookmark.c [new file with mode: 0755]
src/bookmarks/bdb/src/test.c [new file with mode: 0755]
src/bookmarks/bdb/src/testMakeDatabase.c [new file with mode: 0755]
src/bookmarks/sql/COPYING [new file with mode: 0644]
src/bookmarks/sql/Makefile [new file with mode: 0644]
src/bookmarks/sql/include/engine_bookmark.h [new file with mode: 0644]
src/bookmarks/sql/src/engine_bookmark.c [new file with mode: 0644]
src/bookmarks/sql/src/test.c [new file with mode: 0644]
src/bookmarks/sql/src/testMakeDatabase.c [new file with mode: 0644]
src/bookmarks/sql3/COPYING [new file with mode: 0644]
src/bookmarks/sql3/Makefile [new file with mode: 0644]
src/bookmarks/sql3/include/engine_bookmark.h [new file with mode: 0644]
src/bookmarks/sql3/src/engine_bookmark.c [new file with mode: 0644]
src/bookmarks/sql3/src/test.c [new file with mode: 0644]
src/bookmarks/sql3/src/testMakeDatabase.c [new file with mode: 0644]
src/bookmarks/xdxf/COPYING [new file with mode: 0644]
src/bookmarks/xdxf/Makefile [new file with mode: 0644]
src/bookmarks/xdxf/include/engine_bookmark.h [new file with mode: 0644]
src/bookmarks/xdxf/src/engine_bookmark.c [new file with mode: 0644]
src/bookmarks/xdxf/src/engine_bookmark_old.c [new file with mode: 0644]
src/bookmarks/xdxf/src/test.c [new file with mode: 0644]
src/bookmarks/xdxf/src/test1.c [new file with mode: 0644]
src/bookmarks/xdxf/src/test2.c [new file with mode: 0644]
src/bookmarks/xdxf/src/testMakeDatabase.c [new file with mode: 0644]
src/dbus_wrapper/COPYING [new file with mode: 0644]
src/dbus_wrapper/Doxyfile [new file with mode: 0644]
src/dbus_wrapper/Makefile [new file with mode: 0644]
src/dbus_wrapper/src/ws_dbus.c [new file with mode: 0644]
src/gui/include/pc-instances.h [new file with mode: 0644]
src/gui/include/ws_gui.h [new file with mode: 0644]
src/gui/include/ws_gui_callbacks.h [new file with mode: 0644]
src/gui/include/ws_gui_layout.h [new file with mode: 0644]
src/gui/makefile [new file with mode: 0644]
src/gui/src/pc-instances.c [new file with mode: 0644]
src/gui/src/ws_gui.c [new file with mode: 0644]
src/gui/src/ws_gui_callbacks.c [new file with mode: 0644]
src/gui/src/ws_gui_layout.c [new file with mode: 0644]
src/manager/COPYING [new file with mode: 0644]
src/manager/Makefile [new file with mode: 0644]
src/manager/commit [new file with mode: 0644]
src/manager/include/pc-instances.h [new file with mode: 0644]
src/manager/include/untar.h [new file with mode: 0644]
src/manager/include/ws_manager.h [new file with mode: 0644]
src/manager/include/ws_mng_bookmarks_utils.h [new file with mode: 0644]
src/manager/include/ws_mng_callbacks.h [new file with mode: 0644]
src/manager/include/ws_mng_dictionary_utils.h [new file with mode: 0644]
src/manager/include/ws_mng_gconf_utils.h [new file with mode: 0644]
src/manager/include/ws_mng_searching_threads.h [new file with mode: 0644]
src/manager/include/ws_mng_threads_utils.h [new file with mode: 0644]
src/manager/src/untar.c [new file with mode: 0644]
src/manager/src/whitestork.c [new file with mode: 0644]
src/manager/src/ws_manager.c [new file with mode: 0644]
src/manager/src/ws_mng_bookmarks_utils.c [new file with mode: 0644]
src/manager/src/ws_mng_callbacks.c [new file with mode: 0644]
src/manager/src/ws_mng_dictionary_utils.c [new file with mode: 0644]
src/manager/src/ws_mng_gconf_utils.c [new file with mode: 0644]
src/manager/src/ws_mng_searching_threads.c [new file with mode: 0644]
src/manager/src/ws_mng_threads_utils.c [new file with mode: 0644]
src/manager_copy/COPYING [new file with mode: 0644]
src/manager_copy/bin/WhiteStorkManager [new file with mode: 0755]
src/manager_copy/include/pc-instances.h [new file with mode: 0644]
src/manager_copy/include/untar.h [new file with mode: 0644]
src/manager_copy/include/ws_manager.h [new file with mode: 0644]
src/manager_copy/makefile [new file with mode: 0644]
src/manager_copy/src/pc-instances.c [new file with mode: 0644]
src/manager_copy/src/untar.c [new file with mode: 0644]
src/manager_copy/src/whitestork.c [new file with mode: 0644]
src/manager_copy/src/ws_manager.c [new file with mode: 0644]
src/plugins/stardict/COPYING [new file with mode: 0755]
src/plugins/stardict/Makefile [new file with mode: 0755]
src/plugins/stardict/doc/DICTFILE_FORMAT [new file with mode: 0755]
src/plugins/stardict/include/data.h [new file with mode: 0644]
src/plugins/stardict/include/defs.h [new file with mode: 0644]
src/plugins/stardict/include/dictP.h [new file with mode: 0644]
src/plugins/stardict/include/dictd.h [new file with mode: 0644]
src/plugins/stardict/include/dictzip.h [new file with mode: 0644]
src/plugins/stardict/include/engine API.h [new file with mode: 0755]
src/plugins/stardict/include/engine_stardict.h [new file with mode: 0755]
src/plugins/stardict/include/maa.h [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/data.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/debug.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/error.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/hash.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/log.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/memory.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/prime.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/stack.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/string.o [new file with mode: 0644]
src/plugins/stardict/precompiled/arm/xmalloc.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/data.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/debug.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/error.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/hash.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/log.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/memory.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/prime.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/stack.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/string.o [new file with mode: 0644]
src/plugins/stardict/precompiled/i686/xmalloc.o [new file with mode: 0644]
src/plugins/stardict/src/engine_stardict.c [new file with mode: 0755]
src/plugins/stardict/src/test.c [new file with mode: 0755]
src/plugins/stardict/test_dictsip/data.c [new file with mode: 0644]
src/plugins/stardict/test_dictsip/data.h [new file with mode: 0644]
src/plugins/stardict/test_dictsip/dictd.c [new file with mode: 0644]
src/plugins/stardict/test_dictsip/dictd.h [new file with mode: 0644]
src/plugins/stardict/test_dictsip/dictzip.c [new file with mode: 0644]
src/plugins/stardict/test_dictsip/dictzip.h [new file with mode: 0644]
src/plugins/xdxf/COPYING [new file with mode: 0644]
src/plugins/xdxf/Makefile [new file with mode: 0755]
src/plugins/xdxf/include/engine_xdxf.h [new file with mode: 0644]
src/plugins/xdxf/src/engine_xdxf.c [new file with mode: 0644]
src/plugins/xdxf/src/test.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..4c36e58
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,335 @@
+ARCH = `arch`
+REP_TAG = ../tags
+REP_BRANCH = branches
+
+DEB_REP_DIR = www
+
+#declaration of directory names
+BINARIES = bin
+SOURCE = src
+INCLUDE = include
+DATA = data
+PLUGINS = ${SOURCE}/plugins
+XDXF_PLUGIN = ${PLUGINS}/xdxf
+STARDICT_PLUGIN = ${PLUGINS}/stardict
+GUI = ${SOURCE}/gui
+MANAGER = ${SOURCE}/manager
+DBUS = ${SOURCE}/dbus_wrapper
+BOOKMARKS:=bdb
+BOOKMARKS_DIR = ${SOURCE}/bookmarks/${BOOKMARKS}
+DESTDIR = 
+
+ifeq (${BOOKMARKS}, sql)
+       SQLITE:=-DSQLITE=0
+endif
+
+ifeq (${BOOKMARKS}, sql3)
+       SQLITE:=-DSQLITE=3
+endif
+
+PACKAGES = packages
+
+#probably trash
+STARDICT = stardict
+APP_NAME = whitestork
+
+#versions
+MAJOR_VER = 1
+MINOR_VER = 0
+RELEASE_MAJOR_VER = 1
+RELEASE_MINOR_VER = 0
+RELEASE_PATCH_VER = 1
+PACK_VER = 0
+FRM_VER = 0.1
+
+# VERSION_FILE = ./${INCLUDE}/ws_version.h
+
+#package structure
+GUI_PACK_NAME = whitestorkgui
+MNG_PACK_NAME = whitestork
+PLUGINS_PACK_NAME = whitestorkplugins
+BOOKMARKS_PACK_NAME = whitestorkbookmarks
+META_PACK_NAME = whitestorkdictionary
+
+GUI_EXECUTABLE = ${BINARIES}/WhiteStork
+GUI_SERVICEFILE = org.maemo.WhiteStorkGui.service
+GUI_DIRS = ${DESTDIR}/usr/bin ${DESTDIR}/usr/share/applications/hildon ${DESTDIR}/usr/share/pixmaps ${DESTDIR}/usr/share/mis ${DESTDIR}/usr/share/dbus-1/services ${DESTDIR}/usr/share/locale  
+#${DESTDIR}/usr/share/doc/whitestorkgui
+GUI_DBUS = ${DATA}/other/${GUI_SERVICEFILE}
+GUI_ICONS = ${DATA}/icons/whitestork_icon.png ${DATA}/icons/whitestork.png ${DATA}/icons/ws_top.png ${DATA}/icons/ws_warning_icon.png ${DATA}/icons/qgn_indi_search_whitestork.png ${DATA}/icons/ws_tra.png
+GUI_LOCALE = ${DATA}/locale/out/
+GUI_DOC = ${DATA}/docs/${GUI_PACK_NAME}/
+GUI_OTHER = ${DATA}/other/whitestork.desktop
+GUI_MIS = ${DATA}/mis/whitestork-search.xml
+
+MNG_EXECUTABLE = ${BINARIES}/WhiteStorkManager 
+MNG_SERVICEFILE = org.maemo.WhiteStorkManager.service
+MNG_LIB = ${BINARIES}/ws_bookmark.so
+MNG_DIRS = ${DESTDIR}/usr/bin ${DESTDIR}/usr/lib/WhiteStork ${DESTDIR}/usr/share/dbus-1/services  ${DESTDIR}/usr/share/WhiteStork ${DESTDIR}/usr/share/doc/${MNG_PACK_NAME}
+MNG_DBUS = ${DATA}/other/${MNG_SERVICEFILE}
+MNG_OTHER = ${DATA}/dictionaries 
+MNG_DICT1 = ${DATA}/dictionaries/StarDictSampleDict/sample.dict.dz ${DATA}/dictionaries/StarDictSampleDict/sample.idx ${DATA}/dictionaries/StarDictSampleDict/sample.ifo ${DESTDIR}/usr/share/WhiteStork/dictionaries/StarDictSampleDict/
+MNG_DICT2 = ${DATA}/dictionaries/XDXFSampleDict/dict.xdxf ${DESTDIR}/usr/share/WhiteStork/dictionaries/XDXFSampleDict/
+MNG_DICT_DIRS = ${DESTDIR}/usr/share/WhiteStork/dictionaries/StarDictSampleDict/ ${DESTDIR}/usr/share/WhiteStork/dictionaries/XDXFSampleDict/
+MNG_BOOKMARKS = ${DATA}/bookmarks/${BOOKMARKS}/*
+MNG_DOC = ${DATA}/docs/${MNG_PACK_NAME}/
+
+PLUGINS_LIB = ${BINARIES}/engine_*.so
+PLUGINS_DIRS = ${DESTDIR}/usr/lib/WhiteStork ${DESTDIR}/usr/share/pixmaps
+#${DESTDIR}/usr/share/doc/${PLUGINS_PACK_NAME} 
+PLUGINS_ICONS = ${DATA}/icons/engine_xdxf_icon.png
+PLUGINS_DOC = ${DATA}/docs/${PLUGINS_PACK_NAME}/
+
+META_DIRS = ${PACKAGES}/${META_PACK_NAME}/usr/share/doc/${META_PACK_NAME}
+META_DOC = ${DATA}/docs/${META_PACK_NAME}/
+
+MAIL_ADDRESS = mdictionary-devel@garage.maemo.org
+LOCALEDIR=/usr/share/locale
+GETTEXT_PACKAGE=whitestork
+ALL_LINGUAS="en_GB"
+
+
+ifeq (${MAKECMDGOALS}, release-package)
+       APP_VER = ${RELEASE_MAJOR_VER}.${RELEASE_MINOR_VER}.${RELEASE_PATCH_VER}
+else
+       APP_VER = ${MAJOR_VER}.${MINOR_VER}.`svn info | grep "Revision:" | awk '{print $$2}'`
+endif
+
+FILES = ${DATA}/files_debbuild
+LOG_DIR = logs
+LOG_CLEAN = ${LOG_DIR}/clean.log
+LOG_BUILD = ${LOG_DIR}/build.log
+LOG_RUN = ${LOG_DIR}/run.log
+LOG_DEBS = ${LOG_DIR}/debs.log
+LOG_INST = ${LOG_DIR}/install.log
+
+first: build
+       @echo -e -n ""
+
+tag-version: clean
+               @install -d ${REP_TAG}/${APP_NAME}-${APP_VER}
+               @tar -czf ${REP_TAG}/${APP_NAME}-${APP_VER}/${APP_NAME}-${APP_VER}.tar.gz ../trunk/* --exclude .svn
+               @svn add ${REP_TAG}/${APP_NAME}-${APP_VER} 
+               @svn ci ${REP_TAG}/${APP_NAME}-${APP_VER} -m "Tagged new version: ${APP_NAME}-${APP_VER}"
+
+send-last:     debs
+               @tar -czf ${APP_NAME}-${APP_VER}.tar.gz *_${APP_VER}-${PACK_VER}_${ARCH}.deb
+               @echo -e -n "#!/bin/bash\n\
+                       mutt -x -a ~/debs.log -a ~/build.log -a ~/${APP_NAME}-${APP_VER}.tar.gz -s \"[WhiteStork]: daily build - version ${APP_NAME}-${APP_VER}\" ${MAIL_ADDRESS} <~/mail.content\n\
+                       rm -f ~/${APP_NAME}-${APP_VER}.tar.gz\n" > mail.script
+
+               @chmod +x mail.script
+
+               @echo -e -n "\
+                       This message was generated automatically , please do not reply.\n\
+                       Attachment: ${APP_NAME}-${APP_VER}.tar.gz - tarball with the newest Whitestork's packages.\n\
+                       Attachment: build.log - logs from building binaries.\n\
+                       Attachment: debs.log - logs from making *.deb packages.\n\n\
+                       Automatic Building Framework ver: ${FRM_VER}\nCopyright 2006 ComArch S.A.\n" > mail.content
+               @scp ${APP_NAME}-${APP_VER}.tar.gz krzsas@localhost:~/
+               @scp ${LOG_BUILD} krzsas@localhost:~/
+               @scp ${LOG_DEBS} krzsas@localhost:~/
+               @scp mail.script krzsas@localhost:~/
+               @scp mail.content krzsas@localhost:~/
+               @rm -f mail.script
+               @rm -f mail.content
+               @ssh krzsas@localhost  ./mail.script
+
+localization:
+               @echo -e -n "Generating locale...\n"
+               @echo -e -n "Generating locale...\n" > ${LOG_BUILD}
+               
+               @./generate_locale ${DATA}/locale/ ${GUI_LOCALE}
+               @echo -e -n "Locale generation successfully completed...\n"
+               @echo -e -n "Locale generation successfully completed...\n" > ${LOG_BUILD}
+
+build: pre-build  ${BINARIES}/ws_dbus.o ${BINARIES}/WhiteStork ${BINARIES}/WhiteStorkManager ${BINARIES}/ws_bookmark.so plugins
+               @echo -e -n "\nBuilding WhiteStork is finished.\n"
+
+pre-build:
+               @echo -e -n "Building WhiteStork... \n"
+               @echo -e -n "" > ${LOG_BUILD}
+
+plugins: ${BINARIES}/engine_xdxf.so ${BINARIES}/engine_stardict.so
+               
+
+${BINARIES}/WhiteStorkManager: 
+# update-version
+               @echo -e -n "**--> Compiling Manager...\n"
+               @echo -e -n "**--> Compiling Manager...\n" >> ${LOG_BUILD}
+               @make SQLITE=${SQLITE} -C ${MANAGER} >> ${LOG_BUILD}
+
+${BINARIES}/ws_dbus.o:
+               @echo -e -n "**--> Compiling D-BUS Wrapper... \n"
+               @echo -e -n "**--> Compiling D-BUS Wrapper... \n" >> ${LOG_BUILD}
+#              @cd ${DBUS} && make >> ../../${LOG_BUILD}
+               @make -C ${DBUS} >> ${LOG_BUILD}
+
+${BINARIES}/WhiteStork: 
+#update-version
+               @echo -e -n "**--> Compiling User Interface...\n"
+               @echo -e -n "**--> Compiling User Interface...\n" >> ${LOG_BUILD}
+#              @cd ${GUI} && make APP_VER=${APP_VER} >> ../../${LOG_BUILD}
+               @make APP_VER=${APP_VER} -C ${GUI} >> ${LOG_BUILD}
+
+${BINARIES}/engine_xdxf.so: 
+# update-version
+               @echo -e -n "**--> Compiling XDXF Engine...\n"
+               @echo -e -n "**--> Compiling XDXF Engine...\n" >> ${LOG_BUILD}
+#              @cd ${XDXF_PLUGIN} && make >> ../../../${LOG_BUILD}
+               @make -C ${XDXF_PLUGIN} >> ${LOG_BUILD}
+
+${BINARIES}/engine_stardict.so:  
+# update-version
+               @echo -e -n "**--> Compiling StarDict Engine...\n"
+               @echo -e -n "**--> Compiling StarDict Engine...\n" >> ${LOG_BUILD}
+#              @cd ${STARDICT_PLUGIN} && make >> ../../../${LOG_BUILD}
+               @make -C ${STARDICT_PLUGIN} >> ${LOG_BUILD}
+
+${BINARIES}/ws_bookmark.so: 
+# update-version
+               @echo -e -n "**--> Compiling Bookmarks...\n"
+               @echo -e -n "**--> Compiling Bookmarks...\n" >> ${LOG_BUILD}
+               @make -C ${BOOKMARKS_DIR} >> ${LOG_BUILD}
+               
+clean-logs:     
+               @echo -e -n "Cleaning all logs\n"
+               @rm -f ${LOG_DIR}/*.log
+
+clean: clean-logs
+               @-echo -e -n "Cleaning project directories\n"
+               @echo -e -n "" > ${LOG_CLEAN}
+               @-rm -f ${BINARIES}/* >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-rm -f *~ >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-rm -f *.deb >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-rm -rf ${PACKAGES}/*
+               @-make -C ${GUI} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-make -C ${DBUS} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-make -C ${XDXF_PLUGIN} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-make -C ${STARDICT_PLUGIN} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @-cd ${MANAGER} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
+               @-make -C ${MANAGER} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
+               @find src/bookmarks/ -mindepth 1 -maxdepth 1 -type d -not -name .svn -exec make -C {} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN} \;
+               @-rm -rf ${GUI_LOCALE}*
+               
+#              @-cd ${GUI} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
+#              @-cd ${DBUS} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
+#              @-cd ${XDXF_PLUGIN} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
+#              @-cd ${STARDICT_PLUGIN} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
+#              @-cd ${BOOKMARKS_DIR} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
+
+run: clean install entries run-dict clean-temp
+
+
+run-dict:
+               @run-standalone.sh WhiteStorkManager
+
+clean-temp:
+               @-fakeroot rm -rf /usr/share/WhiteStork
+               @-fakeroot rm -rf /usr/lib/WhiteStork
+               @-fakeroot rm -rf /usr/include/WhiteStork
+               @-fakeroot rm -f /etc/others-menu/extra_applications/0112_whitestorkgui.desktop
+               @-fakeroot rm -f /usr/share/applications/hildon/whitestorkgui.desktop 
+               @-fakeroot rm -f /usr/share/pixmaps/whitestork.png 
+               @-fakeroot rm -f /usr/share/pixmaps/whitestork_icon.png
+               @-fakeroot rm -f /usr/bin/WhiteStork
+               @-fakeroot rm -f /usr/bin/WhiteStorkManager
+               @-fakeroot rm -f /usr/share/applications/hildon/whitestorkgui.desktop 
+               @-fakeroot rm -f /usr/lib/WhiteStork/engine_xdxf.so
+               @-fakeroot rm -f /usr/lib/WhiteStork/engine_stardict.so
+
+#              gconftool-2 --recursive-unset /apps/maemo/WhiteStork
+
+install-manager: localization ${BINARIES}/ws_dbus.o  ${BINARIES}/ws_bookmark.so ${BINARIES}/WhiteStorkManager
+               @install -d ${MNG_DIRS}
+               @cp ${MNG_EXECUTABLE} ${DESTDIR}/usr/bin
+               @cp ${MNG_LIB} ${DESTDIR}/usr/lib/WhiteStork
+               @cp ${MNG_DBUS} ${DESTDIR}/usr/share/dbus-1/services
+               @find  ${MNG_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${MNG_PACK_NAME} \;
+               
+#              @install -d ${MNG_DICT_DIRS}
+#              @cp ${MNG_DICT1}
+#              @cp ${MNG_DICT2}
+               
+               @install -d ${DESTDIR}/usr/share/WhiteStork/dictionaries/bookmarks
+               @cp -rf ${MNG_BOOKMARKS} ${DESTDIR}/usr/share/WhiteStork/dictionaries/bookmarks
+               
+install-gui:   ${BINARIES}/ws_dbus.o ${BINARIES}/WhiteStork 
+               @install -d ${GUI_DIRS}
+               @cp ${GUI_EXECUTABLE} ${DESTDIR}/usr/bin
+               @cp ${GUI_ICONS} ${DESTDIR}/usr/share/pixmaps
+               @cp ${GUI_DBUS} ${DESTDIR}/usr/share/dbus-1/services
+               @cp ${GUI_OTHER} ${DESTDIR}/usr/share/applications/hildon
+               @cp ${GUI_MIS} ${DESTDIR}/usr/share/mis
+               @cp -a ${GUI_LOCALE}* ${DESTDIR}/usr/share/locale/              
+#              @find  ${GUI_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${GUI_PACK_NAME} \;
+
+install-plugins: plugins
+               @install -d ${PLUGINS_DIRS}
+               @cp ${PLUGINS_LIB} ${DESTDIR}/usr/lib/WhiteStork
+               @cp ${PLUGINS_ICONS} ${DESTDIR}/usr/share/pixmaps
+               @install -d ${MNG_DICT_DIRS}
+               @cp ${MNG_DICT1}
+               @cp ${MNG_DICT2}
+#              @find  ${PLUGINS_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${PLUGINS_PACK_NAME} \;
+
+install:       install-manager install-gui install-plugins
+               @echo -e "\n\nIf you are installing whitestork, please run 'make entries', before running the application ( not as root )\n\n"
+
+entries:       
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/name "Polish - English Sample Dictionary"
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/path "/usr/share/WhiteStork/dictionaries/StarDictSampleDict"
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/active true
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/optimized false
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/name "English - Polish Sample Dictionary"
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/path "/usr/share/WhiteStork/dictionaries/XDXFSampleDict"
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/active true
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/optimized false
+               
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/bookmarks/path "/usr/lib/WhiteStork/ws_bookmark.so"
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/name "Bookmarks"
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/path "/usr/share/WhiteStork/dictionaries/bookmarks"
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/active false
+               gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/optimized true
+               chmod -R 0777 /usr/share/WhiteStork/dictionaries
+               
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/xdxf/path "/usr/lib/WhiteStork/engine_xdxf.so"
+               gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/stardict/path "/usr/lib/WhiteStork/engine_stardict.so"
+               
+#              maemo-select-menu-location whitestork.desktop
+
+
+install_deb: clean-inst-log uninstall eng-deb-i mng-deb-i gui-deb-i
+               @echo -e -n "All packages have been installed/reinstalled.\n"
+
+clean-inst-log: 
+               @echo -n "" > ${LOG_INST}
+
+uninstall:
+               @-fakeroot dpkg --purge whitestork
+#              @-fakeroot dpkg --purge whitestorkdictionary
+
+display: access
+               @fakeroot su ${USER} -c 'af-sb-init.sh start'   
+
+display-s: access
+               @fakeroot su ${USER} -c 'af-sb-init.sh stop'
+
+display-r: access
+               @fakeroot su ${USER} -c 'af-sb-init.sh restart'
+
+access:
+               @fakeroot chmod 0777 /var/run
+
+release-package: clean debs meta-package
+               @echo "Release package generation successfully completed"
+
+snapshot: tag-version send-last
+
+repo:  release-package meta-package
+
+       @rm -rf ${DEB_REP_DIR}
+       @./generate_repo ${DEB_REP_DIR}
+       
+package: clean
+       dpkg-buildpackage -rfakeroot
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..9eb335c
--- /dev/null
+++ b/README
@@ -0,0 +1,48 @@
+WhiteStork Multilingual Dictionary ver. 0.1.0 ALPHA
+
+
+
+What is WhiteStork Multilingual Dictionary
+------------------------------------------
+WhiteStork is a multilingual dictionary enabling its users to use many dictionary formats. Our final goal is to use many search engines so that different file formats could be used. They will be in a form of dynamically loadable modules. For now however, we have limited the project to one engine for the XDXF format. The application consists of four modules: 
+- GUI - written using GTK+ Hildon, GPL License
+- Engine - XDXF format parser, GPL license
+- Manager - thread management and GUI starting, GPL license
+- D-BUS wrapper - communication between GUI and Manager, LGPL license. 
+
+Compilation
+-----------
+
+In order to compile this application go to the WhiteStork/trunk directory and run the following command:
+
+make clean && make
+
+However, it is important to put out, that this will only compile the program. You won't be able to run it. Read the Installation section for information on how to install WhiteStork on your system.
+
+Installation
+------------
+
+The first thing to do, is setting an environment variable called REP_LOCATION, to match the directory containing local svn repository. This should be done in the following way: 
+
+export REP_LOCATION = /local/svn/repository
+
+In order to install the program, issue the following command:
+
+make debs && make debs-i
+
+These lines, compile the source code, create a debian package and install it onto your system.
+
+Running
+-------
+
+After installation is successful, there should a WhiteStork entry in the Extras submenu. All you have to do now is start it. Please refer to the WhiteStork User Interface Specification for hints on how to use our dictionary. It is available under this URL: https://garage.maemo.org/docman/?group_id=58
+The package contains two dictionaries, so you can start using our app right away.
+
+Should there be any problems, please contact one of our developers via garage.maemo.org.
+
+
+Have fun using our application
+
+
+The WhiteStork Multilingual dictionary developer's
+
diff --git a/add_dict b/add_dict
new file mode 100755 (executable)
index 0000000..7f0ad71
--- /dev/null
+++ b/add_dict
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if [ -z $1 ]; then
+       echo -e "\n* AddDict utility - tool for adding dictionaries to GConf *\n"
+       echo -e "Usage:\n\n./add_dict <dictionary_file> <name_of_dictionary>\n"
+       
+else
+       if [ -z $2 ]; then
+               echo "Dictionary name wasn't specified. Run without parameters to get help."
+       else
+               if [ -e $1 ]; then
+                       gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/$2/name "$2"
+                       gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/$2/path "`pwd`/$1"
+                       gconftool-2 --type boolean --set /apps/maemo/WhiteStork/Dictionaries/$2/active false
+                       gconftool-2 --type boolean --set /apps/maemo/WhiteStork/Dictionaries/$2/optimized false
+                       gconftool-2 -R /apps/maemo/WhiteStork/Dictionaries/$2
+               else
+                       echo "Dictionary file couldn't be found. Run without parameters to get help."
+                       
+               fi
+               
+       fi
+fi
diff --git a/data/bookmarks/bdb/bm_trans.db b/data/bookmarks/bdb/bm_trans.db
new file mode 100644 (file)
index 0000000..7abe57a
Binary files /dev/null and b/data/bookmarks/bdb/bm_trans.db differ
diff --git a/data/bookmarks/bdb/bm_words.db b/data/bookmarks/bdb/bm_words.db
new file mode 100644 (file)
index 0000000..d7d2019
Binary files /dev/null and b/data/bookmarks/bdb/bm_words.db differ
diff --git a/data/bookmarks/sql/ws_bookmarks b/data/bookmarks/sql/ws_bookmarks
new file mode 100644 (file)
index 0000000..183c23b
Binary files /dev/null and b/data/bookmarks/sql/ws_bookmarks differ
diff --git a/data/bookmarks/sql3/ws_bookmarks3 b/data/bookmarks/sql3/ws_bookmarks3
new file mode 100644 (file)
index 0000000..21a9e50
Binary files /dev/null and b/data/bookmarks/sql3/ws_bookmarks3 differ
diff --git a/data/bookmarks/xdxf/ws_bookmarks.cache b/data/bookmarks/xdxf/ws_bookmarks.cache
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/data/bookmarks/xdxf/ws_bookmarks.xdxf b/data/bookmarks/xdxf/ws_bookmarks.xdxf
new file mode 100644 (file)
index 0000000..d34ed91
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE xdxf SYSTEM "http://xdxf.sourceforge.net/xdxf_lousy.dtd">
+<xdxf lang_from="NN" lang_to="NN" format="visual">
+<full_name>WhiteStork Bookmarks</full_name>
+<description>Version: 1.0</description>
+
+</xdxf>
\ No newline at end of file
diff --git a/data/dictionaries/StarDictSampleDict/sample.dict.dz b/data/dictionaries/StarDictSampleDict/sample.dict.dz
new file mode 100644 (file)
index 0000000..f6d5541
--- /dev/null
@@ -0,0 +1 @@
+Thank you very much.WhitestorkBe careful!I would like a ticket to...I would like to change dollars.I think I am lost.What town is this?What?traveller's checksJunefortyfourteenfourfour thousandfour hundredThursdayfourthCan I get there on foot?Is there a taxi standby nearby?Is there a currency exchange office nearby?Is there a sleeping car on the train?Do you have a map of the city?May we have an extra bed?Can I pay with my credit card?Could you help me?Could you show me this on the map, please?Do you speak English?Why?Good-bye.Good night.(Goodbye at night time)Good evening.Okay.seconda lot ofmuchtwotwo thousandtwentytwenty-onetwelvetwo hundredtwicetenthtenten percentten thousandninthnineteenninenine thousandninetynine hundreddayGood day.Good morning.todayThank you.Where is the nearest...Where is the nearest bank?Where is... ?Where?DecemberHow much do I owe you?How much is it per night?How much is the fare?How old are you?What is your name?How late it is?How do I get to this address?How far is it?How?Which line goes to...?oneelevena thirdautumnIt is two in the afternoon.It is 4:30 am.It is two o'clock.It is 6:15 pm.It is one o'clock.It is three in the afternoon.It is 3:40 am.It is three o'clock.It is one in the afternoon.tomorrowWhen does it leave?When does it arrive?When?fewblanketsupperWho?What time is it?AprilsummerdoctorleftJulyNovemberFebruaryMayMy name is...I have a reservation.MarchDo you have any vacancies?Can we switch rooms?Can you show me the room?on the cornerI do not speak Polish.I do not understand.No.SundaynightsdinnerOf course.eighteight thousandeightyeighteeneight hundredOctoberplatformfirstFridayfifthfifteenfivefive minutes agofive thousandfiftyfive hundreddouble bedroomHelp!MondayRepeat, please.halfnoonrightstraight aheadPlease tell me when to get off.The bill, please.Please call me a taxi.Please speak more slowly.Please.You are welcome.private bathExcuse me.Excuse me.I am sorry.bus stationtram stationmidnightlateronceKeep the change.roll of toilet paperI understand a little.bath towelssevenseven thousandseventyseventeenseven hundredAugustseventhSaturdaytrain stationsubway stationone hundredStop!Januarysixteensixsix thousandsixtysix hundredsixthYes.nowtracksomethirdthreethree thousandthirtythirteenthree hundredone thousandWatch out!earlieryesterdaymanyspringHello.soonSeptemberAll aboard.TuesdayzeroThat's right.Agreed.wintereightha quarterI am in a hurry.breakfastWednesday
\ No newline at end of file
diff --git a/data/dictionaries/StarDictSampleDict/sample.idx b/data/dictionaries/StarDictSampleDict/sample.idx
new file mode 100644 (file)
index 0000000..e140e95
Binary files /dev/null and b/data/dictionaries/StarDictSampleDict/sample.idx differ
diff --git a/data/dictionaries/StarDictSampleDict/sample.ifo b/data/dictionaries/StarDictSampleDict/sample.ifo
new file mode 100644 (file)
index 0000000..a37e79e
--- /dev/null
@@ -0,0 +1,6 @@
+StarDict's dict ifo file
+version=2.4.2
+wordcount=209
+idxfilesize=4539
+bookname=sample
+sametypesequence=m
diff --git a/data/dictionaries/XDXFSampleDict/dict.xdxf b/data/dictionaries/XDXFSampleDict/dict.xdxf
new file mode 100644 (file)
index 0000000..71717ee
--- /dev/null
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<xdxf lang_from="ENG" lang_to="POL" format="visual">\r
+       <full_name>English - Polish dictionary</full_name>\r
+       <description>Sample dictionary with some usefull expressions. Any suggestions? Please conntact marcin.biedron@comarch.pl. This file is part of WhiteStork application. Copyright 2007, ComArch S.A. All rights reserved.</description>\r
+       <ar><k>a lot of</k> - dużo</ar>\r
+       <ar><k>a quarter</k> - ćwiartka</ar>\r
+       <ar><k>a third</k> - jedna trzecia</ar>\r
+       <ar><k>Agreed.</k> - Zgoda.</ar>\r
+       <ar><k>All aboard.</k> - Wsiadać proszę.</ar>\r
+       <ar><k>April</k> - kwiecień</ar>\r
+       <ar><k>August</k> - sierpień</ar>\r
+       <ar><k>autumn</k> - jesień</ar>\r
+       <ar><k>bath towels</k> - ręczniki</ar>\r
+       <ar><k>Be careful!</k> - Bądź ostrożny!</ar>\r
+       <ar><k>blanket</k> - koc</ar>\r
+       <ar><k>breakfast</k> - śniadanie</ar>\r
+       <ar><k>bus station</k> - przystanek autobusowy</ar>\r
+       <ar><k>Can I get there on foot?</k> - Czy dojdę tam na pieszo?</ar>\r
+       <ar><k>Can I pay with my credit card?</k> - Czy można płacić kartą (kredytową)?</ar>\r
+       <ar><k>Can we switch rooms?</k> - Możemy zamienić pokoje?</ar>\r
+       <ar><k>Can you show me the room?</k> - Możesz pokazać mi pokój?</ar>\r
+       <ar><k>Could you help me?</k> - Czy mógłbyś mi pomóc?</ar>\r
+       <ar><k>Could you show me this on the map, please?</k> - Czy mógłbyś pokazać mi to miejsce na mapie?</ar>\r
+       <ar><k>day</k> - dzień</ar>\r
+       <ar><k>December</k> - grudzień</ar>\r
+       <ar><k>dinner</k> - obiad</ar>\r
+       <ar><k>Do you have a map of the city?</k> - Czy masz mapę miasta?</ar>\r
+       <ar><k>Do you have any vacancies?</k> - Masz wolne pokoje?</ar>\r
+       <ar><k>Do you speak English?</k> - Czy mówisz po angielsku?</ar>\r
+       <ar><k>doctor</k> - lekarz</ar>\r
+       <ar><k>double bed</k> - podwójne łóżko</ar>\r
+       <ar><k>earlier</k> - wcześniej</ar>\r
+       <ar><k>eight</k> - osiem</ar>\r
+       <ar><k>eight hundred</k> - osiemset</ar>\r
+       <ar><k>eight thousand</k> - osiem tysięcy</ar>\r
+       <ar><k>eighteen</k> - osiemnaście</ar>\r
+       <ar><k>eighth</k> - ósmy</ar>\r
+       <ar><k>eighty</k> - osiemdziesiąt</ar>\r
+       <ar><k>eleven</k> - jedenaście</ar>\r
+       <ar><k>Excuse me.</k> - Przepraszam.</ar>\r
+       <ar><k>Excuse me.</k> - Przepraszam.</ar>\r
+       <ar><k>February</k> - luty</ar>\r
+       <ar><k>few</k> - kilka</ar>\r
+       <ar><k>fifteen</k> - piętnaście</ar>\r
+       <ar><k>fifth</k> - piąty</ar>\r
+       <ar><k>fifty</k> - pięćdziesiąt</ar>\r
+       <ar><k>first</k> - pierwszy</ar>\r
+       <ar><k>five</k> - pięć</ar>\r
+       <ar><k>five hundred</k> - pięćset</ar>\r
+       <ar><k>five minutes ago</k> - pięć minut temu</ar>\r
+       <ar><k>five thousand</k> - pięć tysiące</ar>\r
+       <ar><k>forty</k> - czterdzieści</ar>\r
+       <ar><k>four</k> - cztery</ar>\r
+       <ar><k>four hundred</k> - czterysta</ar>\r
+       <ar><k>four thousand</k> - cztery tysiące</ar>\r
+       <ar><k>fourteen</k> - czternaście</ar>\r
+       <ar><k>fourth</k> - czwarty</ar>\r
+       <ar><k>Friday</k> - piątek</ar>\r
+       <ar><k>Good day.</k> - Dzień dobry.</ar>\r
+       <ar><k>Good evening.</k> - Dobry wieczór.</ar>\r
+       <ar><k>Good morning.</k> - Dzień dobry.</ar>\r
+       <ar><k>Good night.(Goodbye at night time)</k> - Dobranoc.</ar>\r
+       <ar><k>Good-bye.</k> - Do widzenia.</ar>\r
+       <ar><k>half</k> - połowa</ar>\r
+       <ar><k>Hello.</k> - Witam.</ar>\r
+       <ar><k>Help!</k> - Pomocy!</ar>\r
+       <ar><k>How do I get to this address?</k> - Jak się dostanę pod ten adres?</ar>\r
+       <ar><k>How far is it?</k> - Jak to daleko?</ar>\r
+       <ar><k>How late it is?</k> - Jak późno już jest?</ar>\r
+       <ar><k>How much do I owe you?</k> - Ile jestem winny?</ar>\r
+       <ar><k>How much is it per night?</k> - Ile kosztuje jedna noc?</ar>\r
+       <ar><k>How much is the fare?</k> - Ile kosztuje przejazd?</ar>\r
+       <ar><k>How old are you?</k> - Ile masz lat?</ar>\r
+       <ar><k>How?</k> - Jak?</ar>\r
+       <ar><k>I am in a hurry.</k> - Śpieszy mi się.</ar>\r
+       <ar><k>I am sorry.</k> - Przykro mi.</ar>\r
+       <ar><k>I do not speak Polish.</k> - Nie mówię po polsku.</ar>\r
+       <ar><k>I do not understand.</k> - Nie rozumiem.</ar>\r
+       <ar><k>I have a reservation.</k> - Mam rezerwację</ar>\r
+       <ar><k>I think I am lost.</k> - Chyba się zgubiłem.</ar>\r
+       <ar><k>I understand a little.</k> - Rozumiem trochę.</ar>\r
+       <ar><k>I would like a ticket to...</k> - Chciałbym bilet do...</ar>\r
+       <ar><k>I would like to change dollars.</k> - Chciałbym wymienić dolary.</ar>\r
+       <ar><k>Is there a currency exchange office nearby?</k> - Czy jest tam kantor wymiany walut?</ar>\r
+       <ar><k>Is there a sleeping car on the train?</k> - Czy jest tam wagon sypialny?</ar>\r
+       <ar><k>Is there a taxi standby nearby?</k> - Czy jest tam blisko postój taksówek?</ar>\r
+       <ar><k>It is 3:40 am.</k> - Jest trzecia czterdzieści.</ar>\r
+       <ar><k>It is 4:30 am.</k> - Jest czwarta czterdzieści.</ar>\r
+       <ar><k>It is 6:15 pm.</k> - Jest osiemnasta piętnaście.</ar>\r
+       <ar><k>It is one in the afternoon.</k> - Jest trzynasta.</ar>\r
+       <ar><k>It is one o'clock.</k> - Jest pierwsza.</ar>\r
+       <ar><k>It is three in the afternoon.</k> - Jest piętnasta.</ar>\r
+       <ar><k>It is three o'clock.</k> - Jest trzecia.</ar>\r
+       <ar><k>It is two in the afternoon.</k> - Jest czternasta.</ar>\r
+       <ar><k>It is two o'clock.</k> - Jest druga.</ar>\r
+       <ar><k>January</k> - styczeń</ar>\r
+       <ar><k>July</k> - lipiec</ar>\r
+       <ar><k>June</k> - czerwiec</ar>\r
+       <ar><k>Keep the change.</k> - Reszta dla ciebie.</ar>\r
+       <ar><k>later</k> - później</ar>\r
+       <ar><k>left</k> - lewo</ar>\r
+       <ar><k>many</k> - wiele</ar>\r
+       <ar><k>March</k> - marzec</ar>\r
+       <ar><k>May</k> - maj</ar>\r
+       <ar><k>May we have an extra bed?</k> - Czy możemy prosić dodatkowe łóżko?</ar>\r
+       <ar><k>midnight</k> - północ</ar>\r
+       <ar><k>Monday</k> - poniedziałek</ar>\r
+       <ar><k>much</k> - dużo</ar>\r
+       <ar><k>My name is...</k> - Mam na imię...</ar>\r
+       <ar><k>nights</k> - noce</ar>\r
+       <ar><k>nine</k> - dziewięć</ar>\r
+       <ar><k>nine hundred</k> - dziewięćset</ar>\r
+       <ar><k>nine thousand</k> - dziewięć tysięcy</ar>\r
+       <ar><k>nineteen</k> - dziewiętnaście</ar>\r
+       <ar><k>ninety</k> - dziewięćdziesiąt</ar>\r
+       <ar><k>ninth</k> - dziewiąty</ar>\r
+       <ar><k>No.</k> - Nie.</ar>\r
+       <ar><k>noon</k> - południe</ar>\r
+       <ar><k>November</k> - listopad</ar>\r
+       <ar><k>now</k> - teraz</ar>\r
+       <ar><k>October</k> - październik</ar>\r
+       <ar><k>Of course.</k> - Oczywiście.</ar>\r
+       <ar><k>Okay.</k> - Dobrze.</ar>\r
+       <ar><k>on the corner</k> - na rogu</ar>\r
+       <ar><k>once</k> - raz</ar>\r
+       <ar><k>one</k> - jeden</ar>\r
+       <ar><k>one hundred</k> - sto</ar>\r
+       <ar><k>one thousand</k> - tysiąc</ar>\r
+       <ar><k>platform</k> - peron</ar>\r
+       <ar><k>Please call me a taxi.</k> - Proszę wezwać mi taksówkę.</ar>\r
+       <ar><k>Please speak more slowly.</k> - Proszę, mów wolniej.</ar>\r
+       <ar><k>Please tell me when to get off.</k> - Proszę mi powiedzieć gdzie mam wysiąść.</ar>\r
+       <ar><k>Please.</k> - Proszę.</ar>\r
+       <ar><k>private bath</k> - prywata łazienka</ar>\r
+       <ar><k>Repeat, please.</k> - Powtórz proszę.</ar>\r
+       <ar><k>right</k> - prawo</ar>\r
+       <ar><k>roll of toilet paper</k> - rolka papieru toaletowego</ar>\r
+       <ar><k>room</k> - pokój</ar>\r
+       <ar><k>Saturday</k> - sobota</ar>\r
+       <ar><k>second</k> - drugi</ar>\r
+       <ar><k>September</k> - wrzesień</ar>\r
+       <ar><k>seven</k> - siedem</ar>\r
+       <ar><k>seven hundred</k> - siedemset</ar>\r
+       <ar><k>seven thousand</k> - siedem tysięcy</ar>\r
+       <ar><k>seventeen</k> - siedemnaście</ar>\r
+       <ar><k>seventh</k> - siódmy</ar>\r
+       <ar><k>seventy</k> - siedemdziesiąt</ar>\r
+       <ar><k>six</k> - sześć</ar>\r
+       <ar><k>six hundred</k> - sześćset</ar>\r
+       <ar><k>six thousand</k> - sześć tysięcy</ar>\r
+       <ar><k>sixteen</k> - szesnaście</ar>\r
+       <ar><k>sixth</k> - szósty</ar>\r
+       <ar><k>sixty</k> - sześćdziesiąt</ar>\r
+       <ar><k>some</k> - trochę</ar>\r
+       <ar><k>soon</k> - wkrótce</ar>\r
+       <ar><k>spring</k> - wiosna</ar>\r
+       <ar><k>Stop!</k> - Stop!</ar>\r
+       <ar><k>straight ahead</k> - prosto</ar>\r
+       <ar><k>subway station</k> - stacja metra</ar>\r
+       <ar><k>summer</k> - lato</ar>\r
+       <ar><k>Sunday</k> - niedziela</ar>\r
+       <ar><k>supper</k> - kolacja</ar>\r
+       <ar><k>ten</k> - dziesięć</ar>\r
+       <ar><k>ten percent</k> - dziesięć procent</ar>\r
+       <ar><k>ten thousand</k> - dziesięć tysięcy</ar>\r
+       <ar><k>tenth</k> - dziesiąty</ar>\r
+       <ar><k>Thank you very much.</k> - Bardzo dziękuję.</ar>\r
+       <ar><k>Thank you.</k> - Dziękuję.</ar>\r
+       <ar><k>That's right.</k> - Zgadza się.</ar>\r
+       <ar><k>The bill, please.</k> - Proszę o rachunek.</ar>\r
+       <ar><k>third</k> - trzeci</ar>\r
+       <ar><k>thirteen</k> - trzynaście</ar>\r
+       <ar><k>thirty</k> - trzydzieści</ar>\r
+       <ar><k>three</k> - trzy</ar>\r
+       <ar><k>three hundred</k> - trzysta</ar>\r
+       <ar><k>three thousand</k> - trzy tysiące</ar>\r
+       <ar><k>Thursday</k> - czwartek</ar>\r
+       <ar><k>today</k> - dzisiaj</ar>\r
+       <ar><k>tomorrow</k> - jutro</ar>\r
+       <ar><k>track</k> - tor</ar>\r
+       <ar><k>train station</k> - stacja kolejowa</ar>\r
+       <ar><k>tram station</k> - przystanek tramwajowy</ar>\r
+       <ar><k>traveller's checks</k> - czeki podróżne</ar>\r
+       <ar><k>Tuesday</k> - wtorek</ar>\r
+       <ar><k>twelve</k> - dwanaście</ar>\r
+       <ar><k>twenty</k> - dwadzieścia</ar>\r
+       <ar><k>twenty-one</k> - dwadzieścia jeden</ar>\r
+       <ar><k>twice</k> - dwukrotnie</ar>\r
+       <ar><k>two</k> - dwa</ar>\r
+       <ar><k>two hundred</k> - dwieście</ar>\r
+       <ar><k>two thousand</k> - dwa tysiące</ar>\r
+       <ar><k>Watch out!</k> - Uważaj!</ar>\r
+       <ar><k>Wednesday</k> - środa</ar>\r
+       <ar><k>What is your name?</k> - Jak masz na imię?</ar>\r
+       <ar><k>What time is it?</k> - Która godzina?</ar>\r
+       <ar><k>What town is this?</k> - Co to za miasto?</ar>\r
+       <ar><k>What?</k> - Co?</ar>\r
+       <ar><k>When does it arrive?</k> - Kiedy przyjeżdża?</ar>\r
+       <ar><k>When does it leave?</k> - Kiedy odjeżdża?</ar>\r
+       <ar><k>When?</k> - Kiedy?</ar>\r
+       <ar><k>Where is the nearest bank?</k> - Gdzie jest najbliższy bank?</ar>\r
+       <ar><k>Where is the nearest...</k> - Gdzie jest najbliższa...</ar>\r
+       <ar><k>Where is... ?</k> - Gdzie jest... ?</ar>\r
+       <ar><k>Where?</k> - Gdzie?</ar>\r
+       <ar><k>Which line goes to...?</k> - Jaka linia kursuje do...?</ar>\r
+       <ar><k>Whitestork</k> - Bocian</ar>\r
+       <ar><k>Who?</k> - Kto?</ar>\r
+       <ar><k>Why?</k> - Dlaczego?</ar>\r
+       <ar><k>winter</k> - zima</ar>\r
+       <ar><k>Yes.</k> - Tak.</ar>\r
+       <ar><k>yesterday</k> - wczoraj</ar>\r
+       <ar><k>You are welcome.</k> - Proszę.</ar>\r
+       <ar><k>zero</k> - zero</ar>\r
+</xdxf>
\ No newline at end of file
diff --git a/data/docs/whitestork/changelog b/data/docs/whitestork/changelog
new file mode 100644 (file)
index 0000000..607b5ab
--- /dev/null
@@ -0,0 +1,5 @@
+whitestork (0.1.0)
+
+  * Testing changelog.
+  * whitestork
+ -- author <email>  2006-09-07
diff --git a/data/docs/whitestork/changelog.Debian b/data/docs/whitestork/changelog.Debian
new file mode 100644 (file)
index 0000000..7bc6702
--- /dev/null
@@ -0,0 +1,2 @@
+whitestork Debian maintainer and upstream author are identical.
+Therefore see also normal changelog file for Debian changes.
\ No newline at end of file
diff --git a/data/docs/whitestork/copyright b/data/docs/whitestork/copyright
new file mode 100644 (file)
index 0000000..e455ce8
--- /dev/null
@@ -0,0 +1,3 @@
+whitestork
+
+All programs are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
\ No newline at end of file
diff --git a/data/docs/whitestorkdictionary/changelog b/data/docs/whitestorkdictionary/changelog
new file mode 100644 (file)
index 0000000..8b4e027
--- /dev/null
@@ -0,0 +1,5 @@
+enginexdxf (0.1.0)
+
+  * Testing changelog.
+  * enginexdxf
+ -- author <email>  2006-09-07
diff --git a/data/docs/whitestorkdictionary/changelog.Debian b/data/docs/whitestorkdictionary/changelog.Debian
new file mode 100644 (file)
index 0000000..8023d75
--- /dev/null
@@ -0,0 +1 @@
+See changelog.
\ No newline at end of file
diff --git a/data/docs/whitestorkdictionary/copyright b/data/docs/whitestorkdictionary/copyright
new file mode 100644 (file)
index 0000000..7b22cfd
--- /dev/null
@@ -0,0 +1,3 @@
+WhiteStork Dictionary
+
+All programs are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
\ No newline at end of file
diff --git a/data/docs/whitestorkgui/changelog b/data/docs/whitestorkgui/changelog
new file mode 100644 (file)
index 0000000..d5c3bfd
--- /dev/null
@@ -0,0 +1,5 @@
+whitestorkgui (0.1.0)
+
+  * Testing changelog.
+  * whitestorkgui
+ -- author <email>  2006-09-07
diff --git a/data/docs/whitestorkgui/changelog.Debian b/data/docs/whitestorkgui/changelog.Debian
new file mode 100644 (file)
index 0000000..cff7f1c
--- /dev/null
@@ -0,0 +1,2 @@
+whitestorkgui Debian maintainer and upstream author are identical.
+Therefore see also normal changelog file for Debian changes.
\ No newline at end of file
diff --git a/data/docs/whitestorkgui/copyright b/data/docs/whitestorkgui/copyright
new file mode 100644 (file)
index 0000000..2a3070b
--- /dev/null
@@ -0,0 +1,3 @@
+whitestorkgui
+
+All programs are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
\ No newline at end of file
diff --git a/data/docs/whitestorkplugins/changelog b/data/docs/whitestorkplugins/changelog
new file mode 100644 (file)
index 0000000..14929fd
--- /dev/null
@@ -0,0 +1,5 @@
+whitestorkplugins (0.6.0)
+
+  * Testing changelog.
+  * enginexdxf
+ -- author <email>  2006-09-07
diff --git a/data/docs/whitestorkplugins/changelog.Debian b/data/docs/whitestorkplugins/changelog.Debian
new file mode 100644 (file)
index 0000000..2834b45
--- /dev/null
@@ -0,0 +1,3 @@
+whitestorkplugins
+Debian maintainer and upstream author are identical.
+Therefore see also normal changelog file for Debian changes.
\ No newline at end of file
diff --git a/data/docs/whitestorkplugins/copyright b/data/docs/whitestorkplugins/copyright
new file mode 100644 (file)
index 0000000..8c97a75
--- /dev/null
@@ -0,0 +1,3 @@
+whitestorkplugins
+
+All programs are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
\ No newline at end of file
diff --git a/data/icons/engine_xdxf_icon.png b/data/icons/engine_xdxf_icon.png
new file mode 100644 (file)
index 0000000..b35c0cc
Binary files /dev/null and b/data/icons/engine_xdxf_icon.png differ
diff --git a/data/icons/engine_xdxf_icon_2.png b/data/icons/engine_xdxf_icon_2.png
new file mode 100644 (file)
index 0000000..ec8ca10
Binary files /dev/null and b/data/icons/engine_xdxf_icon_2.png differ
diff --git a/data/icons/qgn_indi_search_whitestork.png b/data/icons/qgn_indi_search_whitestork.png
new file mode 100644 (file)
index 0000000..482de9b
Binary files /dev/null and b/data/icons/qgn_indi_search_whitestork.png differ
diff --git a/data/icons/whitestork.png b/data/icons/whitestork.png
new file mode 100644 (file)
index 0000000..751eb6e
Binary files /dev/null and b/data/icons/whitestork.png differ
diff --git a/data/icons/whitestork_icon.png b/data/icons/whitestork_icon.png
new file mode 100644 (file)
index 0000000..2c3563b
Binary files /dev/null and b/data/icons/whitestork_icon.png differ
diff --git a/data/icons/ws_top.png b/data/icons/ws_top.png
new file mode 100644 (file)
index 0000000..26496e9
Binary files /dev/null and b/data/icons/ws_top.png differ
diff --git a/data/icons/ws_tra.png b/data/icons/ws_tra.png
new file mode 100644 (file)
index 0000000..0fb96bc
Binary files /dev/null and b/data/icons/ws_tra.png differ
diff --git a/data/icons/ws_warning_icon.png b/data/icons/ws_warning_icon.png
new file mode 100644 (file)
index 0000000..7e4f7b6
Binary files /dev/null and b/data/icons/ws_warning_icon.png differ
diff --git a/data/locale/POTFILES.in b/data/locale/POTFILES.in
new file mode 100644 (file)
index 0000000..08090ce
--- /dev/null
@@ -0,0 +1,5 @@
+# List of source files containing translatable strings.
+
+# Package source files
+../gui/src/ws_gui_layout.c
+../gui/src/ws_gui_callbacks.c
\ No newline at end of file
diff --git a/data/locale/en_GB.po b/data/locale/en_GB.po
new file mode 100644 (file)
index 0000000..ebf355e
--- /dev/null
@@ -0,0 +1,353 @@
+# Copyright (C) 2006
+# This file is distributed under the same license as the PACKAGE package.
+# Anna Gadomska <Anna.Gadomska@comarch.pl>, 2006.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-14 11:34+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Anna Gadomska <Anna.Gadomska@comarch.pl>\n"
+"Language-Team: polish <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui.c:49
+msgid "ws_check"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:42
+msgid "ws_ni_welcome"
+msgstr "Welcome to mDictionary!"
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr "Find"
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr "Dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr "Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr "Edit"
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr "View"
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr "Search"
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr "About..."
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr "Close"
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr "Load dictionary..."
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr "Select dictionaries..."
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr "Remove dictionaries..."
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr "Optimize dictionaries..."
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr "Open Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr "Close Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr "Add Bookmark..."
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr "Remove Bookmark..."
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr "Copy"
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr "Paste"
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr "Select All"
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr "Hide words list"
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr "Zoom in"
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr "Zoom out"
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr "Full screen"
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr "Find next"
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr "Find previous"
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr "Stop"
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr "Search"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_add_bookmark"
+msgstr "Add Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr "Copy"
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr "Paste"
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr "Select All"
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr "Edit"
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr "Zoom in"
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr "Zoom out"
+
+#: ../gui/src/ws_gui_layout.c:712 ../gui/src/ws_gui_layout.c:904
+msgid "ws_ti_choose_dictionaries_title"
+msgstr "Select dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:767 ../gui/src/ws_gui_layout.c:941
+#: ../gui/src/ws_gui_layout.c:1233 ../gui/src/ws_gui_layout.c:1427
+#: ../gui/src/ws_gui_layout.c:1488 ../gui/src/ws_gui_layout.c:1432
+msgid "ws_db_cancel"
+msgstr "Cancel"
+
+#: ../gui/src/ws_gui_layout.c:773 ../gui/src/ws_gui_layout.c:946
+#: ../gui/src/ws_gui_layout.c:1422 ../gui/src/ws_gui_layout.c:1483
+#: ../gui/src/ws_gui_layout.c:1427
+msgid "ws_db_ok"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:892
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr "There are no dictionaries to optimize."
+
+#: ../gui/src/ws_gui_layout.c:1022
+msgid "ws_ti_load_dictionary_title"
+msgstr "Load dictionary"
+
+#: ../gui/src/ws_gui_layout.c:1074
+msgid "ws_ni_dictionaries_activation_question"
+msgstr "Would you like to start using this dictionary now?"
+
+#: ../gui/src/ws_gui_layout.c:1106
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr "Would you like to optimize this dictionary?"
+
+#: ../gui/src/ws_gui_layout.c:1131
+msgid "ws_ni_dictionary_added"
+msgstr "New dictionary has been added."
+
+#: ../gui/src/ws_gui_callbacks.c:439
+msgid "ws_ni_dictionary_not_added"
+msgstr "Dictionary could not be added."
+
+#: ../gui/src/ws_gui_layout.c:1138
+msgid "ws_ni_dictionary_wrong_file"
+msgstr "Wrong dictionary file."
+
+#: ../gui/src/ws_gui_layout.c:1189
+msgid "ws_ti_remove_dictionaries_title"
+msgstr "Remove dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:1239
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr "Remove selected"
+
+#: ../gui/src/ws_gui_layout.c:1305
+msgid "ws_ti_about_title"
+msgstr "About"
+
+#: ../gui/src/ws_gui_layout.c:1339
+msgid "ws_ib_dictionary_removed"
+msgstr "Dictionary has been removed."
+
+#: ../gui/src/ws_gui_layout.c:1401
+msgid "ws_ti_add_bookmark"
+msgstr "Add Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:1413
+msgid "ws_ti_bookmarks_add_question"
+msgstr "Add to Bookmarks?"
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr "Bookmark has been added."
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr "Bookmark could not be added."
+
+#: ../gui/src/ws_gui_layout.c:1462
+msgid "ws_ti_remove_bookmark"
+msgstr "Remove Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:1474
+msgid "ws_ni_remove_bookmark_question"
+msgstr "Remove from Bookmarks?"
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr "Bookmark has been removed."
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr "Bookmark could not be removed."
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr "An error occured"
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr "There is no dictionary available."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr "Caching..."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_extracting"
+msgstr "Extracting..."
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr "Dictionary unavailable."
+
+#: ../gui/src/ws_gui_callbacks.c:289
+#: ../gui/src/ws_gui_layout.c:1534
+msgid "ws_ni_no_words_found"
+msgstr "No words found."
+
+#: ../gui/src/ws_gui_callbacks.c:867
+msgid "ws_ni_no_text_selected"
+msgstr "No text selected."
+
+#: ../gui/src/ws_gui_callbacks.c:970
+msgid "ws_ab_searching"
+msgstr "Searching..."
+
+#: ../gui/src/ws_gui_callbacks.c:987
+msgid "ws_ni_no_word_typed"
+msgstr "No word typed."
+
+#: ../gui/src/ws_gui_callbacks.c:1008
+msgid "ws_ni_search_aborted"
+msgstr "Search has been aborted."
+
+#: ../gui/src/ws_gui_callbacks.c:1412
+msgid "ws_ni_select_word_to_add"
+msgstr "Select word to add."
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+msgid "ws_ni_select_word_to_remove"
+msgstr "Select word to remove."
+
+#: ../gui/src/ws_gui_callbacks.c:1128
+msgid "ws_ib_max_zoom"
+msgstr "Max zoom level reached."
+
+#: ../gui/src/ws_gui_callbacks.c:1152
+msgid "ws_ib_min_zoom"
+msgstr "Min zoom level reached."
+
+#: ../gui/src/ws_gui_callbacks.c:1161
+msgid "ws_ib_zoom_in"
+msgstr "Zoom in"
+
+#: ../gui/src/ws_gui_callbacks.c:1134
+msgid "ws_ib_zoom_out"
+msgstr "Zoom out"
+
+#: ../gui/src/ws_gui_callbacks.c:1018
+msgid "ws_ib_fullscreen_on"
+msgstr "Fullscreen"
+
+#: ../gui/src/ws_gui_callbacks.c:1029
+msgid "ws_ib_fullscreen_off"
+msgstr "Fullscreen off"
+
+#: ../gui/src/ws_gui_callbacks.c:1124
+#: ../gui/src/ws_gui_callbacks.c:1157
+msgid "ws_ib_zoom_default"
+msgstr "Default Zoom"
+
+#: ../gui/src/ws_gui_callbacks.c:1069
+msgid "ws_ib_copied"
+msgstr "Copied."
+
+#: ../gui/src/ws_gui_callbacks.c:1096
+msgid "ws_ib_pasted"
+msgstr "Pasted."
+
+#: ../gui/src/ws_gui_callbacks.c:268
+msgid "ws_ni_bookmarks_unavailable"
+msgstr "Bookmarks could not be loaded. Please install libsqlite package."
+
+msgid "ws_ab_loading"
+msgstr "Loading translation..."
+
+#: ../gui/src/ws_gui_layout.c:156
+msgid "ws_ti_list_full"
+msgstr "Too many words"
+
+#: ../gui/src/ws_gui_layout.c:1780
+msgid "ws_ni_words_list_full"
+msgstr "Query was too wide, WhiteStork is not able to show all words matching it. Please, precise more your query."
diff --git a/data/locale/es.po b/data/locale/es.po
new file mode 100644 (file)
index 0000000..7e5d8fc
--- /dev/null
@@ -0,0 +1,354 @@
+# Copyright (C) 2006
+# This file is distributed under the same license as the PACKAGE package.
+# Anna Gadomska <Anna.Gadomska@comarch.pl>, 2006.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-14 11:34+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Anna Gadomska <Anna.Gadomska@comarch.pl>\n"
+"Language-Team: polish <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui.c:49
+msgid "ws_check"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:42
+msgid "ws_ni_welcome"
+msgstr "Bienvenido a mDictionary"
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr "Encontrar"
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr "Diccionarios"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr "Marcadores"
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr "Editar"
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr "Ver"
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr "Buscar"
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr "Acerca de..."
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr "Cerrar"
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr "Cargar diccionario..."
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr "Seleccionar diccionarios..."
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr "Eliminar diccionarios..."
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr "Optimizar diccionarios..."
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr "Abrir marcadores"
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr "Cerrar marcadores"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr "Añadir marcado..."
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr "Eliminar marcador..."
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr "Copiar"
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr "Pegar"
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr "Seleccionar todo"
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr "Ocultar la lista de palabras"
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr "Aumentar"
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr "Disminuir"
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr "Pantalla completa"
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr "Buscar siguiente"
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr "Buscar anterior"
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr "Detener"
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr "Buscar"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_add_bookmark"
+msgstr "Añadir marcado"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr "Copiar"
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr "Pegar"
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr "Seleccionar todo"
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr "Editar"
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr "Aumentar"
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr "Disminuir"
+
+#: ../gui/src/ws_gui_layout.c:712 ../gui/src/ws_gui_layout.c:904
+msgid "ws_ti_choose_dictionaries_title"
+msgstr "Elegir diccionarios"
+
+#: ../gui/src/ws_gui_layout.c:767 ../gui/src/ws_gui_layout.c:941
+#: ../gui/src/ws_gui_layout.c:1233 ../gui/src/ws_gui_layout.c:1427
+#: ../gui/src/ws_gui_layout.c:1488 ../gui/src/ws_gui_layout.c:1432
+msgid "ws_db_cancel"
+msgstr "Cancelar"
+
+#: ../gui/src/ws_gui_layout.c:773 ../gui/src/ws_gui_layout.c:946
+#: ../gui/src/ws_gui_layout.c:1422 ../gui/src/ws_gui_layout.c:1483
+#: ../gui/src/ws_gui_layout.c:1427
+msgid "ws_db_ok"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:892
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr "No hay ningún diccionario para optimizar."
+
+#: ../gui/src/ws_gui_layout.c:1022
+msgid "ws_ti_load_dictionary_title"
+msgstr "Cargar diccionario"
+
+#: ../gui/src/ws_gui_layout.c:1074
+msgid "ws_ni_dictionaries_activation_question"
+msgstr "¿Quiere comenzar a usar este diccionario?"
+
+#: ../gui/src/ws_gui_layout.c:1106
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr "¿Quiere optimizar este diccionario?"
+
+#: ../gui/src/ws_gui_layout.c:1131
+#: ../gui/src/ws_gui_callbacks.c:447
+msgid "ws_ni_dictionary_added"
+msgstr "Se ha añadido un diccionario nuevo."
+
+#: ../gui/src/ws_gui_callbacks.c:439
+msgid "ws_ni_dictionary_not_added"
+msgstr "No se ha añadido un diccionario nuevo."
+
+#: ../gui/src/ws_gui_layout.c:1138
+msgid "ws_ni_dictionary_wrong_file"
+msgstr "Archivo de diccionario incorrecto."
+
+#: ../gui/src/ws_gui_layout.c:1189
+msgid "ws_ti_remove_dictionaries_title"
+msgstr "Eliminar diccionarios"
+
+#: ../gui/src/ws_gui_layout.c:1239
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr "Eliminar la selección"
+
+#: ../gui/src/ws_gui_layout.c:1305
+msgid "ws_ti_about_title"
+msgstr "Acerca de"
+
+#: ../gui/src/ws_gui_layout.c:1339
+msgid "ws_ib_dictionary_removed"
+msgstr "El diccionario se ha eliminado."
+
+#: ../gui/src/ws_gui_layout.c:1401
+msgid "ws_ti_add_bookmark"
+msgstr "Añadir marcadr"
+
+#: ../gui/src/ws_gui_layout.c:1413
+msgid "ws_ti_bookmarks_add_question"
+msgstr "¿Añadir a los marcadores?"
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr "Se ha añadido el marcador."
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr "No se ha podido añadir el marcado."
+
+#: ../gui/src/ws_gui_layout.c:1462
+msgid "ws_ti_remove_bookmark"
+msgstr "Eliminar marcador"
+
+#: ../gui/src/ws_gui_layout.c:1474
+msgid "ws_ni_remove_bookmark_question"
+msgstr "¿Eliminar de los marcadores?"
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr "Se ha eliminado el marcador."
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr "No se ha podido eliminar el marcador."
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr "Ocurrió un error"
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr "No hay ningún diccionario disponibl."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr "Almacenando..."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_extracting"
+msgstr "Extracting..."
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr "Diccionario no disponible."
+
+#: ../gui/src/ws_gui_callbacks.c:289
+#: ../gui/src/ws_gui_layout.c:1534
+msgid "ws_ni_no_words_found"
+msgstr "No se ha encontrado ninguna palabra."
+
+#: ../gui/src/ws_gui_callbacks.c:867
+msgid "ws_ni_no_text_selected"
+msgstr "No se ha seleccionado ningún text."
+
+#: ../gui/src/ws_gui_callbacks.c:970
+msgid "ws_ab_searching"
+msgstr "Buscando..."
+
+#: ../gui/src/ws_gui_callbacks.c:987
+msgid "ws_ni_no_word_typed"
+msgstr "No se ha escrito ninguna palabra."
+
+#: ../gui/src/ws_gui_callbacks.c:1008
+msgid "ws_ni_search_aborted"
+msgstr "La búsqueda ha sido cancelada."
+
+#: ../gui/src/ws_gui_callbacks.c:1412
+msgid "ws_ni_select_word_to_add"
+msgstr "Seleccione la palabra a añadir."
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+msgid "ws_ni_select_word_to_remove"
+msgstr "Seleccione la palabra a eliminar."
+
+#: ../gui/src/ws_gui_callbacks.c:1128
+msgid "ws_ib_max_zoom"
+msgstr "Máximo nivel de zoo."
+
+#: ../gui/src/ws_gui_callbacks.c:1152
+msgid "ws_ib_min_zoom"
+msgstr "Mínimo nivel de zoo."
+
+#: ../gui/src/ws_gui_callbacks.c:1161
+msgid "ws_ib_zoom_in"
+msgstr "Aumentar"
+
+#: ../gui/src/ws_gui_callbacks.c:1134
+msgid "ws_ib_zoom_out"
+msgstr "Disminuir"
+
+#: ../gui/src/ws_gui_callbacks.c:1018
+msgid "ws_ib_fullscreen_on"
+msgstr "Pantalla completa"
+
+#: ../gui/src/ws_gui_callbacks.c:1029
+msgid "ws_ib_fullscreen_off"
+msgstr "Salir de pantalla completa"
+
+#: ../gui/src/ws_gui_callbacks.c:1124
+#: ../gui/src/ws_gui_callbacks.c:1157
+msgid "ws_ib_zoom_default"
+msgstr "Nivel de zoom por defecto"
+
+#: ../gui/src/ws_gui_callbacks.c:1069
+msgid "ws_ib_copied"
+msgstr "Copiado."
+
+#: ../gui/src/ws_gui_callbacks.c:1096
+msgid "ws_ib_pasted"
+msgstr "Pegado."
+
+#: ../gui/src/ws_gui_callbacks.c:268
+msgid "ws_ni_bookmarks_unavailable"
+msgstr "No se han podido cargar los marcadores. Instale el paquete libsqlite."
+
+msgid "ws_ab_loading"
+msgstr "ws_ab_loading"
+
+#: ../gui/src/ws_gui_layout.c:156
+msgid "ws_ti_list_full"
+msgstr "ws_ti_list_full"
+
+#: ../gui/src/ws_gui_layout.c:1780
+msgid "ws_ni_words_list_full"
+msgstr "ws_ni_words_list_full"
diff --git a/data/locale/pl_PL.po b/data/locale/pl_PL.po
new file mode 100644 (file)
index 0000000..b06d0e3
--- /dev/null
@@ -0,0 +1,348 @@
+# Copyright (C) 2006
+# This file is distributed under the same license as the PACKAGE package.
+# Anna Gadomska, <Anna.Gadomska@comarch.pl>, 2006.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-14 11:34+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Anna Gadomska <Anna.Gadomska@comarch.pl>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui.c:49
+msgid "ws_check"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:42
+msgid "ws_ni_welcome"
+msgstr "Witamy w mDictionary!"
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr "Słowniki"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr "Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr "Edycja"
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr "Widok"
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr "O programie..."
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr "Zamknij"
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr "Załaduj słownik..."
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr "Wybierz słowniki..."
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr "Usuń słowniki..."
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr "Optymalizuj słowniki..."
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr "Otwórz Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr "Zamknij Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr "Dodaj do Zakłade..."
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr "Usuń z Zakład..."
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr "Kopiuj"
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr "Wklej"
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr "Zaznacz wszystko"
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr "Ukryj listę słów"
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr "Powiększ"
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr "Pomniejsz"
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr "Pełny ekran"
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr "Znajdź następny"
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr "Znajdź poprzedni"
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr "Zatrzymaj"
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr "Kopiuj"
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr "Wklej"
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr "Zaznacz wszystko"
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr "Edycja"
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr "Powiększ"
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr "Pomniejsz"
+
+#: ../gui/src/ws_gui_layout.c:712 ../gui/src/ws_gui_layout.c:904
+msgid "ws_ti_choose_dictionaries_title"
+msgstr "Wybierz słowniki"
+
+#: ../gui/src/ws_gui_layout.c:767 ../gui/src/ws_gui_layout.c:941
+#: ../gui/src/ws_gui_layout.c:1233 ../gui/src/ws_gui_layout.c:1427
+#: ../gui/src/ws_gui_layout.c:1488
+msgid "ws_db_cancel"
+msgstr "Anuluj"
+
+#: ../gui/src/ws_gui_layout.c:773 ../gui/src/ws_gui_layout.c:946
+#: ../gui/src/ws_gui_layout.c:1422 ../gui/src/ws_gui_layout.c:1483
+msgid "ws_db_ok"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:892
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr "Brak słowników do zoptymalizowania."
+
+#: ../gui/src/ws_gui_layout.c:1022
+msgid "ws_ti_load_dictionary_title"
+msgstr "Załaduj słownik"
+
+#: ../gui/src/ws_gui_layout.c:1074
+msgid "ws_ni_dictionaries_activation_question"
+msgstr "Czy chcesz zacząć używać ten słownik już teraz?"
+
+#: ../gui/src/ws_gui_layout.c:1106
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr "Czy chcesz zoptymalizowac ten słownik teraz?"
+
+#: ../gui/src/ws_gui_layout.c:1131
+msgid "ws_ni_dictionary_added"
+msgstr "Nowy słownik został dodany."
+
+#: ../gui/src/ws_gui_callbacks.c:439
+msgid "ws_ni_dictionary_not_added"
+msgstr "Słownik nie mógł zostać dodany."
+
+#: ../gui/src/ws_gui_layout.c:1138
+msgid "ws_ni_dictionary_wrong_file"
+msgstr "Zły plik słownika."
+
+#: ../gui/src/ws_gui_layout.c:1189
+msgid "ws_ti_remove_dictionaries_title"
+msgstr "Usuń słowniki"
+
+#: ../gui/src/ws_gui_layout.c:1239
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr "Usuń zaznaczone"
+
+#: ../gui/src/ws_gui_layout.c:1305
+msgid "ws_ti_about_title"
+msgstr "O Programie"
+
+#: ../gui/src/ws_gui_layout.c:1401
+msgid "ws_ti_add_bookmark"
+msgstr "Dodaj do zakładk"
+
+#: ../gui/src/ws_gui_layout.c:1413
+msgid "ws_ti_bookmarks_add_question"
+msgstr "Dodać do zakładek?"
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr "Zakładka została dana."
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr "Zakładka nie mogła być dod."
+
+
+#: ../gui/src/ws_gui_layout.c:1462
+msgid "ws_ti_remove_bookmark"
+msgstr "Usuń zakładk"
+
+#: ../gui/src/ws_gui_layout.c:1474
+msgid "ws_ni_remove_bookmark_question"
+msgstr "Usunąć z zakładek?"
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr "Zakładkę usunieto."
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr "Zakładka nie mogła zostać usunięta."
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr "Wystąpił błąd."
+
+#: ../gui/src/ws_gui_callbacks.c:119
+msgid "response"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr "Brak dostępnych słowników."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr "Trwa optymalizacja..."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_extracting"
+msgstr "Trwa rozpakowywanie..."
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr "Słownik niedostępny."
+
+#: ../gui/src/ws_gui_callbacks.c:289
+msgid "ws_ni_no_words_found"
+msgstr "Nie znaleziono słów."
+
+#: ../gui/src/ws_gui_callbacks.c:867
+msgid "ws_ni_no_text_selected"
+msgstr "Zaznacz tekst."
+
+#: ../gui/src/ws_gui_callbacks.c:970
+msgid "ws_ab_searching"
+msgstr "Wyszukiwanie..."
+
+#: ../gui/src/ws_gui_callbacks.c:987
+msgid "ws_ni_no_word_typed"
+msgstr "Nie wpisano słowa."
+
+#: ../gui/src/ws_gui_callbacks.c:1008
+msgid "ws_ni_search_aborted"
+msgstr "Wyszukiwanie zostało przerwane."
+
+#: ../gui/src/ws_gui_callbacks.c:1412
+msgid "ws_ni_select_word_to_add"
+msgstr "Wybierz słowo do dodania."
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+msgid "ws_ni_select_word_to_remove"
+msgstr "Wybierz słowo do usunięcia."
+
+#: ../gui/src/ws_gui_callbacks.c:1128
+msgid "ws_ib_max_zoom"
+msgstr "Nie można bardziej powiększy."
+
+#: ../gui/src/ws_gui_callbacks.c:1152
+msgid "ws_ib_min_zoom"
+msgstr "Nie można bardziej pomniejszyć."
+
+#: ../gui/src/ws_gui_callbacks.c:1161
+msgid "ws_ib_zoom_in"
+msgstr "Powiększenie"
+
+#: ../gui/src/ws_gui_callbacks.c:1134
+msgid "ws_ib_zoom_out"
+msgstr "Pomniejszenie"
+
+#: ../gui/src/ws_gui_callbacks.c:1018
+msgid "ws_ib_fullscreen_on"
+msgstr "Pełen ekran włączony"
+
+#: ../gui/src/ws_gui_callbacks.c:1029
+msgid "ws_ib_fullscreen_off"
+msgstr "Pełen ekran wyłączony"
+
+#: ../gui/src/ws_gui_callbacks.c:1124
+#: ../gui/src/ws_gui_callbacks.c:1157
+msgid "ws_ib_zoom_default"
+msgstr "Domyślna wartość powiększenia"
+
+#: ../gui/src/ws_gui_callbacks.c:1069
+msgid "ws_ib_copied"
+msgstr "Skopiowano."
+
+#: ../gui/src/ws_gui_callbacks.c:1096
+msgid "ws_ib_pasted"
+msgstr "Wklejono."
+
+#: ../gui/src/ws_gui_callbacks.c:268
+msgid "ws_ni_bookmarks_unavailable"
+msgstr "Moduł Zakładek nie mógl być załadowany. Proszę doinstalować paczkę libsqlite."
+
+msgid "ws_ab_loading"
+msgstr "Wczytywanie tłumaczenia..."
+
+#: ../gui/src/ws_gui_layout.c:156
+msgid "ws_ti_list_full"
+msgstr "Za dużo wynikow"
+
+#: ../gui/src/ws_gui_layout.c:1780
+msgid "ws_ni_words_list_full"
+msgstr "Jeśli nie znalazłeś szukanego słowa sprecyzuj zapytanie."
diff --git a/data/mis/whitestork-search.xml b/data/mis/whitestork-search.xml
new file mode 100644 (file)
index 0000000..63abce4
--- /dev/null
@@ -0,0 +1,5 @@
+<search name="mDictionary"
+       icon="/usr/share/pixmaps/qgn_indi_search_whitestork.png"
+       action="mdict://"
+       user-input="p">
+</search>
\ No newline at end of file
diff --git a/data/other/org.maemo.WhiteStorkGui.service b/data/other/org.maemo.WhiteStorkGui.service
new file mode 100644 (file)
index 0000000..6eaf142
--- /dev/null
@@ -0,0 +1,4 @@
+# Sample service description file
+[D-BUS Service]
+Name=org.maemo.WhiteStorkGui
+Exec=/usr/bin/WhiteStork
diff --git a/data/other/org.maemo.WhiteStorkManager.service b/data/other/org.maemo.WhiteStorkManager.service
new file mode 100644 (file)
index 0000000..92c3155
--- /dev/null
@@ -0,0 +1,4 @@
+# Sample service description file
+[D-BUS Service]
+Name=org.maemo.WhiteStorkManager
+Exec=/usr/bin/WhiteStorkManager
diff --git a/data/other/whitestork.desktop b/data/other/whitestork.desktop
new file mode 100644 (file)
index 0000000..8870c02
--- /dev/null
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=WhiteStork Dictionary
+Comment=Multilingual dictionary
+Exec=/usr/bin/WhiteStork
+X-Osso-Service=org.maemo.WhiteStorkGui
+Icon=whitestork_icon
+Terminal=true
+Type=Application
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
+X-Window-Icon=whitestork_icon
+
+X-Osso-URI-Actions=mdict;
+
+[X-Osso-URI-Action Handler mdict]
+Method=search_home_applet
+Name=uri_link_open_link
+TranslationDomain=osso-uri
\ No newline at end of file
diff --git a/data/package_contents/whitestork/DEBIAN/control b/data/package_contents/whitestork/DEBIAN/control
new file mode 100644 (file)
index 0000000..02e7fda
--- /dev/null
@@ -0,0 +1,31 @@
+Package: whitestork
+Version:
+Section: user/office
+Priority: optional
+Architecture: all   
+Installed-Size:
+Depends: libexpat1 (>= 1.95.8)        
+Maintainer: ComArch S.A. <contact@comarch.com>
+Description: Multilingual dictionary.
+ WhiteStork Multilingual Dictionary is a very functional
+ application allowing the use of many dictionary engines.
+ You can either download them from our homepage at 
+ http://garage.maemo.org, or write your own, provided
+ that You stick to the API (also available on our homepage).
+ The graphical user interface of our application can also 
+ be replaced by a product of Your own programming skills.
+ Copyright 2006, ComArch S.A. 
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/data/package_contents/whitestork/DEBIAN/postinst b/data/package_contents/whitestork/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..b65f299
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/elements/name "Elements Database"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/elements/path "/usr/share/WhiteStork/dictionaries/elements"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/elements/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/elements/optimized true'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/us-en/name "American - English Dictionary"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/us-en/path "/usr/share/WhiteStork/dictionaries/us-en"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/us-en/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/us-en/optimized false'
+
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/bookmarks/path "/usr/lib/WhiteStork/ws_bookmark.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/name "Bookmarks"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/path "/usr/share/WhiteStork/dictionaries/bookmarks"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/active false'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/optimized true'
+chmod -R 0777 /usr/share/WhiteStork/dictionaries
+fi
\ No newline at end of file
diff --git a/data/package_contents/whitestork/DEBIAN/postrm b/data/package_contents/whitestork/DEBIAN/postrm
new file mode 100755 (executable)
index 0000000..36c6660
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Postremoving actions..."
diff --git a/data/package_contents/whitestork/DEBIAN/preinst b/data/package_contents/whitestork/DEBIAN/preinst
new file mode 100755 (executable)
index 0000000..302910b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Preinstallation actions..."
diff --git a/data/package_contents/whitestork/DEBIAN/prerm b/data/package_contents/whitestork/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..ef59312
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+#su $USER -c 'rm -rf /usr/share/WhiteStork'
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Dictionaries'
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines/bookmarks'
+fi
+
+# End automatically added section
diff --git a/data/package_contents/whitestorkdictionary/DEBIAN/control b/data/package_contents/whitestorkdictionary/DEBIAN/control
new file mode 100644 (file)
index 0000000..fd6060a
--- /dev/null
@@ -0,0 +1,12 @@
+Package: whitestorkdictionary                                                         
+Version:
+Section: user/office
+Priority: optional                                                           
+Architecture: all  
+Installed-Size:                                                           
+Depends: whitestorkgui (>= 0.1.0), whitestork (>= 0.1.0), whitestorkplugins (>= 0.1.0)       
+Maintainer: ComArch S.A. <contact@comarch.com>                              
+Description: metapackage binding all WhiteStork Dictionary's components
+ This package gathers all WhiteStork's components together, increasing
+ the ease of use of WhiteStork Multilingual Dictionary.
+ Copyright 2006, ComArch S.A. 
diff --git a/data/package_contents/whitestorkdictionary/DEBIAN/postinst b/data/package_contents/whitestorkdictionary/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..d7b09f0
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
diff --git a/data/package_contents/whitestorkdictionary/DEBIAN/postrm b/data/package_contents/whitestorkdictionary/DEBIAN/postrm
new file mode 100755 (executable)
index 0000000..36c6660
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Postremoving actions..."
diff --git a/data/package_contents/whitestorkdictionary/DEBIAN/preinst b/data/package_contents/whitestorkdictionary/DEBIAN/preinst
new file mode 100755 (executable)
index 0000000..302910b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Preinstallation actions..."
diff --git a/data/package_contents/whitestorkdictionary/DEBIAN/prerm b/data/package_contents/whitestorkdictionary/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..9bd24b7
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
diff --git a/data/package_contents/whitestorkgui/DEBIAN/control b/data/package_contents/whitestorkgui/DEBIAN/control
new file mode 100644 (file)
index 0000000..4e0ce7d
--- /dev/null
@@ -0,0 +1,27 @@
+Package: whitestorkgui                                                         
+Version:
+Section: user/office
+Priority: optional                                                           
+Architecture: all  
+Installed-Size: 
+Depends: libexpat1 (>= 1.95.8), whitestork (>= 0.1.0)        
+Maintainer: ComArch S.A. <contact@comarch.com>                              
+Description: GUI for whitestork.
+ This package contain an example of GUI for 
+ Whitestork - Multilingual Dictionary for 
+ Maemo platform.
+ Copyright 2006, ComArch S.A. 
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/data/package_contents/whitestorkgui/DEBIAN/postinst b/data/package_contents/whitestorkgui/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..3ad6118
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#echo $1 >> /home/krzsas/log.txt
+echo -e "Postinstalling actions..." 
+su $USER -c 'ln -s /usr/share/applications/hildon/whitestork.desktop /etc/others-menu/extra_applications/0112_whitestorkgui.desktop' ;
+#maemo-confirm-text /usr/share/doc/whitestorkgui/copyright
+
+#case $? in
+#0)su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/configuration/licence true';;
+  # maemo-select-menu-location whitestork.desktop
+#1)su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/configuration/licence false';;
+#esac
+maemo-select-menu-location whitestork.desktop
+
+exit 0
+
+# End automatically added section
diff --git a/data/package_contents/whitestorkgui/DEBIAN/postrm b/data/package_contents/whitestorkgui/DEBIAN/postrm
new file mode 100755 (executable)
index 0000000..75a3c55
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo -e "Postremoving actions..."
+su $USER -c 'rm -f /etc/others-menu/extra_applications/0112_whitestorkgui.desktop' ;
\ No newline at end of file
diff --git a/data/package_contents/whitestorkgui/DEBIAN/preinst b/data/package_contents/whitestorkgui/DEBIAN/preinst
new file mode 100755 (executable)
index 0000000..302910b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Preinstallation actions..."
diff --git a/data/package_contents/whitestorkgui/DEBIAN/prerm b/data/package_contents/whitestorkgui/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..46ce117
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+
+
+# End automatically added section
diff --git a/data/package_contents/whitestorkplugins/DEBIAN/control b/data/package_contents/whitestorkplugins/DEBIAN/control
new file mode 100644 (file)
index 0000000..63cb47b
--- /dev/null
@@ -0,0 +1,25 @@
+Package: whitestorkplugins
+Version:
+Section: user/office
+Priority: optional                                                           
+Architecture: all    
+Installed-Size:
+Depends: libexpat1 (>= 1.95.8)       
+Maintainer: ComArch S.A. <contact@comarch.com>                              
+Description: Parsing engines for WhiteStork Multilingual Dictionary
+ This package enables the use of XDXF and stardict dictionaries. Additional information about the XDXF format can be found here: xdxf.sourceforge.net.
+ Copyright 2006, ComArch S.A. 
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/data/package_contents/whitestorkplugins/DEBIAN/postinst b/data/package_contents/whitestorkplugins/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..43847fa
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/xdxf/path "/usr/lib/WhiteStork/engine_xdxf.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/stardict/path "/usr/lib/WhiteStork/engine_stardict.so"'
+
+fi
+# End automatically added section
diff --git a/data/package_contents/whitestorkplugins/DEBIAN/postrm b/data/package_contents/whitestorkplugins/DEBIAN/postrm
new file mode 100755 (executable)
index 0000000..36c6660
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Postremoving actions..."
diff --git a/data/package_contents/whitestorkplugins/DEBIAN/preinst b/data/package_contents/whitestorkplugins/DEBIAN/preinst
new file mode 100755 (executable)
index 0000000..302910b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo -e "Preinstallation actions..."
diff --git a/data/package_contents/whitestorkplugins/DEBIAN/prerm b/data/package_contents/whitestorkplugins/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..1edb424
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines'
+fi
+
+
+# End automatically added section
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..dbf5ee3
--- /dev/null
@@ -0,0 +1,20 @@
+whitestork (1.1.0-1) unstable; urgency=low
+
+  * plugin for home applet "Internet Search" - search in mDictionary
+  * change Copyright 2006 into Copyright 2006-2007 in copyrigth file
+  * some info banners have been claryfied
+  * cleaning translation after unsuccessful new search fixed
+
+ -- unknown <Dariusz.Wiechecki@comarch.com>  Tue, 24 Jul 2007 15:27:00 +0300
+
+whitestork (1.0.1-1) unstable; urgency=low
+
+  * Minor packaging update. No code changes.
+
+ -- unknown <Milosz.Wasilewski@comarch.com>  Sun, 29 Apr 2007 19:30:47 +0300
+
+whitestork (1.0.0-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- unknown <Krzysztof.Sasiak@comarch.com>  Thu, 29 Mar 2007 14:14:47 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..b8626c4
--- /dev/null
@@ -0,0 +1 @@
+4
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..9e7b4fc
--- /dev/null
@@ -0,0 +1,89 @@
+Source: whitestork
+Section: user/office
+Priority: extra
+Maintainer: Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com>
+Build-Depends: debhelper (>= 4), libdb1-dev, libosso-dev (>= 1.20-1), libgtk2.0-dev (>= 2.6.10), gtkhtml-dev (>= 3.9.1), hildon-libs-dev (>= 0.14.11), libart-2.0-dev (>= 2.3.17), hildon-fm-dev (>= 1.24), libbz2-dev (>=1.0.3)
+Standards-Version: 3.6.1
+
+Package: whitestorkgui
+Section: user/office
+Priority: optional
+Architecture: any
+Depends: ${shlibs:Depends}, whitestork (>= 1.1.0-1)
+Description: User interface for mDictionary
+ WhiteStork Multilingual Dictionary is a very functional
+ application allowing the use of many dictionary engines.
+ You can either download them from our homepage at 
+ http://garage.maemo.org, or write your own, provided
+ that You stick to the API (also available on our homepage).
+ The graphical user interface of our application can also 
+ be replaced by a product of Your own programming skills. 
+ This package contains all three whitestork modules that is:
+ gui, engines and plugins.
+ Copyright 2006, ComArch S.A. 
+XB-Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
+
+Package: whitestork
+Section: user/office
+Priority: optional
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Multilingual dictionary.
+ WhiteStork Multilingual Dictionary is a very functional
+ application allowing the use of many dictionary engines.
+ You can either download them from our homepage at 
+ http://garage.maemo.org, or write your own, provided
+ that You stick to the API (also available on our homepage).
+ The graphical user interface of our application can also 
+ be replaced by a product of Your own programming skills. 
+ This package contains all three whitestork modules that is:
+ gui, engines and plugins.
+ Copyright 2006, ComArch S.A. 
+XB-Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
+
+Package: whitestorkplugins
+Section: user/office
+Priority: optional
+Architecture: any
+Depends:  ${shlibs:Depends}, whitestork (>= 1.1.0-1)
+Description: Dictionary plugins for mDictionary
+XB-Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
\ No newline at end of file
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..83db946
--- /dev/null
@@ -0,0 +1,15 @@
+This package was debianized by Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com> on
+Thu, 29 Mar 2007 13:28:58 +0200.
+
+It was downloaded from https://garage.maemo.org
+
+Upstream Author: WhiteStork development team
+
+Copyright: Comarch 2006-2007
+
+License:
+
+All components are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
+
+The Debian packaging is (C) 2007, Krzysiek Sasiak <Krzysztof.Sasiak@comarch.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/files b/debian/files
new file mode 100644 (file)
index 0000000..3709a20
--- /dev/null
@@ -0,0 +1,3 @@
+whitestorkgui_1.1.0-1_armel.deb user/office optional
+whitestork_1.1.0-1_armel.deb user/office optional
+whitestorkplugins_1.1.0-1_armel.deb user/office optional
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..3fc742e
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+       INSTALL_PROGRAM += -s
+endif
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+
+       touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+       #/usr/bin/docbook-to-man debian/whitestork.sgml > whitestork.1
+
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) clean
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/whitestork.
+       $(MAKE) install-manager DESTDIR=$(CURDIR)/debian/whitestork
+       $(MAKE) install-gui DESTDIR=$(CURDIR)/debian/whitestorkgui
+       $(MAKE) install-plugins DESTDIR=$(CURDIR)/debian/whitestorkplugins
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+#      dh_installexamples
+#      dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+#      dh_installman
+#      dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_python
+#      dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/whitestork.postinst b/debian/whitestork.postinst
new file mode 100755 (executable)
index 0000000..6fb9e91
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Creating 'bookmarks' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/bookmarks/path "/usr/lib/WhiteStork/ws_bookmark.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/name "Bookmarks"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/path "/usr/share/WhiteStork/dictionaries/bookmarks"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/active false'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/optimized true'
+
+echo -e "Changing privilages" 
+chmod -R 0777 /usr/share/WhiteStork/dictionaries
+
+fi
diff --git a/debian/whitestork.prerm b/debian/whitestork.prerm
new file mode 100755 (executable)
index 0000000..6279e7f
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+#su $USER -c 'rm -rf /usr/share/WhiteStork'
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Dictionaries'
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines'
+fi
+
+# End automatically added section
diff --git a/debian/whitestork.substvars b/debian/whitestork.substvars
new file mode 100644 (file)
index 0000000..fb706ed
--- /dev/null
@@ -0,0 +1 @@
+shlibs:Depends=libbz2-1.0, libc6 (>= 2.3.5-1), libdb1, libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libosso1 (>= 1.20-1)
diff --git a/debian/whitestork/DEBIAN/control b/debian/whitestork/DEBIAN/control
new file mode 100644 (file)
index 0000000..8f4cbcc
--- /dev/null
@@ -0,0 +1,33 @@
+Package: whitestork
+Version: 1.1.0-1
+Section: user/office
+Priority: optional
+Architecture: armel
+Depends: libbz2-1.0, libc6 (>= 2.3.5-1), libdb1, libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libosso1 (>= 1.20-1)
+Installed-Size: 164
+Maintainer: Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com>
+Description: Multilingual dictionary.
+ WhiteStork Multilingual Dictionary is a very functional
+ application allowing the use of many dictionary engines.
+ You can either download them from our homepage at
+ http://garage.maemo.org, or write your own, provided
+ that You stick to the API (also available on our homepage).
+ The graphical user interface of our application can also
+ be replaced by a product of Your own programming skills.
+ This package contains all three whitestork modules that is:
+ gui, engines and plugins.
+ Copyright 2006, ComArch S.A.
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/debian/whitestork/DEBIAN/md5sums b/debian/whitestork/DEBIAN/md5sums
new file mode 100644 (file)
index 0000000..a1418c9
--- /dev/null
@@ -0,0 +1,8 @@
+5f067bdec12d9cce14eda5407d62d0bb  usr/lib/WhiteStork/ws_bookmark.so
+6a5e2f1d820c3e845371a0096b21f441  usr/bin/WhiteStorkManager
+9a2485023a17cefd2c2f671e88bfcd1e  usr/share/dbus-1/services/org.maemo.WhiteStorkManager.service
+de80b8431d0ebcfa6a57137f5714d468  usr/share/WhiteStork/dictionaries/bookmarks/bm_words.db
+038c56e7cf13042b989fc3410b936de0  usr/share/WhiteStork/dictionaries/bookmarks/bm_trans.db
+a31f5e3654fffd3a988ece3fe4804fed  usr/share/doc/whitestork/changelog.Debian.gz
+29b17cf44468f9ec3912a102c2b260f1  usr/share/doc/whitestork/copyright
+a83292b75daf61fd8fcda3a73cbd1e5f  usr/share/doc/whitestork/changelog.gz
diff --git a/debian/whitestork/DEBIAN/postinst b/debian/whitestork/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..6fb9e91
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Creating 'bookmarks' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/bookmarks/path "/usr/lib/WhiteStork/ws_bookmark.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/name "Bookmarks"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/path "/usr/share/WhiteStork/dictionaries/bookmarks"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/active false'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/bookmarks/optimized true'
+
+echo -e "Changing privilages" 
+chmod -R 0777 /usr/share/WhiteStork/dictionaries
+
+fi
diff --git a/debian/whitestork/DEBIAN/prerm b/debian/whitestork/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..6279e7f
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+#su $USER -c 'rm -rf /usr/share/WhiteStork'
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Dictionaries'
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines'
+fi
+
+# End automatically added section
diff --git a/debian/whitestork/usr/bin/WhiteStorkManager b/debian/whitestork/usr/bin/WhiteStorkManager
new file mode 100755 (executable)
index 0000000..04c8412
Binary files /dev/null and b/debian/whitestork/usr/bin/WhiteStorkManager differ
diff --git a/debian/whitestork/usr/lib/WhiteStork/ws_bookmark.so b/debian/whitestork/usr/lib/WhiteStork/ws_bookmark.so
new file mode 100644 (file)
index 0000000..d8bf981
Binary files /dev/null and b/debian/whitestork/usr/lib/WhiteStork/ws_bookmark.so differ
diff --git a/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_trans.db b/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_trans.db
new file mode 100644 (file)
index 0000000..7abe57a
Binary files /dev/null and b/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_trans.db differ
diff --git a/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_words.db b/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_words.db
new file mode 100644 (file)
index 0000000..d7d2019
Binary files /dev/null and b/debian/whitestork/usr/share/WhiteStork/dictionaries/bookmarks/bm_words.db differ
diff --git a/debian/whitestork/usr/share/dbus-1/services/org.maemo.WhiteStorkManager.service b/debian/whitestork/usr/share/dbus-1/services/org.maemo.WhiteStorkManager.service
new file mode 100644 (file)
index 0000000..92c3155
--- /dev/null
@@ -0,0 +1,4 @@
+# Sample service description file
+[D-BUS Service]
+Name=org.maemo.WhiteStorkManager
+Exec=/usr/bin/WhiteStorkManager
diff --git a/debian/whitestork/usr/share/doc/whitestork/changelog.Debian.gz b/debian/whitestork/usr/share/doc/whitestork/changelog.Debian.gz
new file mode 100644 (file)
index 0000000..3db3bb9
Binary files /dev/null and b/debian/whitestork/usr/share/doc/whitestork/changelog.Debian.gz differ
diff --git a/debian/whitestork/usr/share/doc/whitestork/changelog.gz b/debian/whitestork/usr/share/doc/whitestork/changelog.gz
new file mode 100644 (file)
index 0000000..f0230f3
Binary files /dev/null and b/debian/whitestork/usr/share/doc/whitestork/changelog.gz differ
diff --git a/debian/whitestork/usr/share/doc/whitestork/copyright b/debian/whitestork/usr/share/doc/whitestork/copyright
new file mode 100644 (file)
index 0000000..83db946
--- /dev/null
@@ -0,0 +1,15 @@
+This package was debianized by Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com> on
+Thu, 29 Mar 2007 13:28:58 +0200.
+
+It was downloaded from https://garage.maemo.org
+
+Upstream Author: WhiteStork development team
+
+Copyright: Comarch 2006-2007
+
+License:
+
+All components are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
+
+The Debian packaging is (C) 2007, Krzysiek Sasiak <Krzysztof.Sasiak@comarch.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/whitestorkgui.postinst b/debian/whitestorkgui.postinst
new file mode 100755 (executable)
index 0000000..02a0e3b
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Selecting menu location" 
+maemo-select-menu-location whitestork.desktop
+
+if [ -f /usr/share/applications/uri-action-defaults.list ]
+then
+   if [ -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list` ]
+   then
+      echo -e "Adding mdict URI action - uri-action-defaults.list"
+      echo -en "\nmdict=hildon-whitestork.desktop\n" >> /usr/share/applications/uri-action-defaults.list
+   fi
+   if [ -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache` ]
+   then
+      echo -e "Adding mdict URI action - schemeinfo.cache"
+      echo -en "\nmdict=hildon-whitestork.desktop\n" >> /usr/share/applications/schemeinfo.cache
+   fi
+fi
+
+fi
diff --git a/debian/whitestorkgui.prerm b/debian/whitestorkgui.prerm
new file mode 100755 (executable)
index 0000000..fab7fbb
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+#su $USER -c 'rm -rf /usr/share/WhiteStork'
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Dictionaries'
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines'
+
+   if [ -f /usr/share/applications/uri-action-defaults.list ]
+   then
+      if [ ! -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list` ]
+      then
+         echo -e "Removing mdict URI action - uri-action-defaults.list"
+         grep -v 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list > tmp
+         cat tmp > /usr/share/applications/uri-action-defaults.list
+      fi
+
+      if [ ! -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache` ]
+      then
+         echo -e "Removing mdict URI action - schemeinfo.cache"
+         grep -v 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache > tmp
+         cat tmp > /usr/share/applications/schemeinfo.cache
+         rm -fr tmp
+      fi
+   fi
+fi
+
+# End automatically added section
diff --git a/debian/whitestorkgui.substvars b/debian/whitestorkgui.substvars
new file mode 100644 (file)
index 0000000..5877695
--- /dev/null
@@ -0,0 +1 @@
+shlibs:Depends=gtkhtml0, hildon-fm1 (>= 1.14), hildon-libs0 (>= 0.14.11-1), libart-2.0-2 (>= 2.3.16), libatk1.0-0 (>= 1.9.0), libc6 (>= 2.3.5-1), libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libgtk2.0-0 (>= 2:2.6.10-1.osso8), libosso1 (>= 1.20-1), libpango1.0-0 (>= 1.8.1)
diff --git a/debian/whitestorkgui/DEBIAN/control b/debian/whitestorkgui/DEBIAN/control
new file mode 100644 (file)
index 0000000..3187c10
--- /dev/null
@@ -0,0 +1,34 @@
+Package: whitestorkgui
+Version: 1.1.0-1
+Section: user/office
+Priority: optional
+Architecture: armel
+Depends: gtkhtml0, hildon-fm1 (>= 1.14), hildon-libs0 (>= 0.14.11-1), libart-2.0-2 (>= 2.3.16), libatk1.0-0 (>= 1.9.0), libc6 (>= 2.3.5-1), libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libgtk2.0-0 (>= 2:2.6.10-1.osso8), libosso1 (>= 1.20-1), libpango1.0-0 (>= 1.8.1), whitestork (>= 1.1.0-1)
+Installed-Size: 232
+Maintainer: Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com>
+Source: whitestork
+Description: User interface for mDictionary
+ WhiteStork Multilingual Dictionary is a very functional
+ application allowing the use of many dictionary engines.
+ You can either download them from our homepage at
+ http://garage.maemo.org, or write your own, provided
+ that You stick to the API (also available on our homepage).
+ The graphical user interface of our application can also
+ be replaced by a product of Your own programming skills.
+ This package contains all three whitestork modules that is:
+ gui, engines and plugins.
+ Copyright 2006, ComArch S.A.
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/debian/whitestorkgui/DEBIAN/md5sums b/debian/whitestorkgui/DEBIAN/md5sums
new file mode 100644 (file)
index 0000000..ada6ed2
--- /dev/null
@@ -0,0 +1,15 @@
+e0da5879c3e3d8466356557c9091863a  usr/bin/WhiteStork
+b907dd078b0e37674a3027684a1b28e2  usr/share/locale/es/LC_MESSAGES/whitestork.mo
+5f0984cfa09f0b804724499fe68735ed  usr/share/locale/en_GB/LC_MESSAGES/whitestork.mo
+20844a479f271affde8494ff7598ed90  usr/share/locale/pl_PL/LC_MESSAGES/whitestork.mo
+e200a9473dfc5873b4f3d5b59b164d7f  usr/share/dbus-1/services/org.maemo.WhiteStorkGui.service
+4b6c65ac54436acc13b386f94e939fe4  usr/share/pixmaps/qgn_indi_search_whitestork.png
+fec80a81a69379cdb5c9d984ef5b0deb  usr/share/pixmaps/ws_tra.png
+800fc1180d1ffb33274849798bfd3a05  usr/share/pixmaps/ws_warning_icon.png
+c3179c526e679e87dd7a793f6cb00ca4  usr/share/pixmaps/ws_top.png
+641156ce47d1b30662f360464b4fc00a  usr/share/pixmaps/whitestork.png
+49537826f9623d12201bea3edec12946  usr/share/pixmaps/whitestork_icon.png
+7fa9c9cf33b8aacfe4265c26cad9cd71  usr/share/mis/whitestork-search.xml
+a31f5e3654fffd3a988ece3fe4804fed  usr/share/doc/whitestorkgui/changelog.Debian.gz
+29b17cf44468f9ec3912a102c2b260f1  usr/share/doc/whitestorkgui/copyright
+08b4422265f552fdbaf73a576e75a51a  usr/share/applications/hildon/whitestork.desktop
diff --git a/debian/whitestorkgui/DEBIAN/postinst b/debian/whitestorkgui/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..02a0e3b
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Selecting menu location" 
+maemo-select-menu-location whitestork.desktop
+
+if [ -f /usr/share/applications/uri-action-defaults.list ]
+then
+   if [ -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list` ]
+   then
+      echo -e "Adding mdict URI action - uri-action-defaults.list"
+      echo -en "\nmdict=hildon-whitestork.desktop\n" >> /usr/share/applications/uri-action-defaults.list
+   fi
+   if [ -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache` ]
+   then
+      echo -e "Adding mdict URI action - schemeinfo.cache"
+      echo -en "\nmdict=hildon-whitestork.desktop\n" >> /usr/share/applications/schemeinfo.cache
+   fi
+fi
+
+fi
diff --git a/debian/whitestorkgui/DEBIAN/prerm b/debian/whitestorkgui/DEBIAN/prerm
new file mode 100755 (executable)
index 0000000..fab7fbb
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+echo -e "Preremoving actions..."
+
+#su $USER -c 'rm -rf /usr/share/WhiteStork'
+
+if [ "$1" != "upgrade" ]
+then
+       echo -e -n "Removing gconf configuration..\n"
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Dictionaries'
+       su $USER -c 'gconftool-2 --recursive-unset /apps/maemo/WhiteStork/Engines'
+
+   if [ -f /usr/share/applications/uri-action-defaults.list ]
+   then
+      if [ ! -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list` ]
+      then
+         echo -e "Removing mdict URI action - uri-action-defaults.list"
+         grep -v 'mdict=hildon-whitestork.desktop' /usr/share/applications/uri-action-defaults.list > tmp
+         cat tmp > /usr/share/applications/uri-action-defaults.list
+      fi
+
+      if [ ! -z `grep 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache` ]
+      then
+         echo -e "Removing mdict URI action - schemeinfo.cache"
+         grep -v 'mdict=hildon-whitestork.desktop' /usr/share/applications/schemeinfo.cache > tmp
+         cat tmp > /usr/share/applications/schemeinfo.cache
+         rm -fr tmp
+      fi
+   fi
+fi
+
+# End automatically added section
diff --git a/debian/whitestorkgui/usr/bin/WhiteStork b/debian/whitestorkgui/usr/bin/WhiteStork
new file mode 100755 (executable)
index 0000000..79ca1ed
Binary files /dev/null and b/debian/whitestorkgui/usr/bin/WhiteStork differ
diff --git a/debian/whitestorkgui/usr/share/applications/hildon/whitestork.desktop b/debian/whitestorkgui/usr/share/applications/hildon/whitestork.desktop
new file mode 100644 (file)
index 0000000..8870c02
--- /dev/null
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=WhiteStork Dictionary
+Comment=Multilingual dictionary
+Exec=/usr/bin/WhiteStork
+X-Osso-Service=org.maemo.WhiteStorkGui
+Icon=whitestork_icon
+Terminal=true
+Type=Application
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
+X-Window-Icon=whitestork_icon
+
+X-Osso-URI-Actions=mdict;
+
+[X-Osso-URI-Action Handler mdict]
+Method=search_home_applet
+Name=uri_link_open_link
+TranslationDomain=osso-uri
\ No newline at end of file
diff --git a/debian/whitestorkgui/usr/share/dbus-1/services/org.maemo.WhiteStorkGui.service b/debian/whitestorkgui/usr/share/dbus-1/services/org.maemo.WhiteStorkGui.service
new file mode 100644 (file)
index 0000000..6eaf142
--- /dev/null
@@ -0,0 +1,4 @@
+# Sample service description file
+[D-BUS Service]
+Name=org.maemo.WhiteStorkGui
+Exec=/usr/bin/WhiteStork
diff --git a/debian/whitestorkgui/usr/share/doc/whitestorkgui/changelog.Debian.gz b/debian/whitestorkgui/usr/share/doc/whitestorkgui/changelog.Debian.gz
new file mode 100644 (file)
index 0000000..3db3bb9
Binary files /dev/null and b/debian/whitestorkgui/usr/share/doc/whitestorkgui/changelog.Debian.gz differ
diff --git a/debian/whitestorkgui/usr/share/doc/whitestorkgui/copyright b/debian/whitestorkgui/usr/share/doc/whitestorkgui/copyright
new file mode 100644 (file)
index 0000000..83db946
--- /dev/null
@@ -0,0 +1,15 @@
+This package was debianized by Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com> on
+Thu, 29 Mar 2007 13:28:58 +0200.
+
+It was downloaded from https://garage.maemo.org
+
+Upstream Author: WhiteStork development team
+
+Copyright: Comarch 2006-2007
+
+License:
+
+All components are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
+
+The Debian packaging is (C) 2007, Krzysiek Sasiak <Krzysztof.Sasiak@comarch.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/whitestorkgui/usr/share/locale/en_GB/LC_MESSAGES/whitestork.mo b/debian/whitestorkgui/usr/share/locale/en_GB/LC_MESSAGES/whitestork.mo
new file mode 100644 (file)
index 0000000..d3a086d
Binary files /dev/null and b/debian/whitestorkgui/usr/share/locale/en_GB/LC_MESSAGES/whitestork.mo differ
diff --git a/debian/whitestorkgui/usr/share/locale/es/LC_MESSAGES/whitestork.mo b/debian/whitestorkgui/usr/share/locale/es/LC_MESSAGES/whitestork.mo
new file mode 100644 (file)
index 0000000..823ba0a
Binary files /dev/null and b/debian/whitestorkgui/usr/share/locale/es/LC_MESSAGES/whitestork.mo differ
diff --git a/debian/whitestorkgui/usr/share/locale/pl_PL/LC_MESSAGES/whitestork.mo b/debian/whitestorkgui/usr/share/locale/pl_PL/LC_MESSAGES/whitestork.mo
new file mode 100644 (file)
index 0000000..fbe30a2
Binary files /dev/null and b/debian/whitestorkgui/usr/share/locale/pl_PL/LC_MESSAGES/whitestork.mo differ
diff --git a/debian/whitestorkgui/usr/share/mis/whitestork-search.xml b/debian/whitestorkgui/usr/share/mis/whitestork-search.xml
new file mode 100644 (file)
index 0000000..63abce4
--- /dev/null
@@ -0,0 +1,5 @@
+<search name="mDictionary"
+       icon="/usr/share/pixmaps/qgn_indi_search_whitestork.png"
+       action="mdict://"
+       user-input="p">
+</search>
\ No newline at end of file
diff --git a/debian/whitestorkgui/usr/share/pixmaps/qgn_indi_search_whitestork.png b/debian/whitestorkgui/usr/share/pixmaps/qgn_indi_search_whitestork.png
new file mode 100644 (file)
index 0000000..482de9b
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/qgn_indi_search_whitestork.png differ
diff --git a/debian/whitestorkgui/usr/share/pixmaps/whitestork.png b/debian/whitestorkgui/usr/share/pixmaps/whitestork.png
new file mode 100644 (file)
index 0000000..751eb6e
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/whitestork.png differ
diff --git a/debian/whitestorkgui/usr/share/pixmaps/whitestork_icon.png b/debian/whitestorkgui/usr/share/pixmaps/whitestork_icon.png
new file mode 100644 (file)
index 0000000..2c3563b
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/whitestork_icon.png differ
diff --git a/debian/whitestorkgui/usr/share/pixmaps/ws_top.png b/debian/whitestorkgui/usr/share/pixmaps/ws_top.png
new file mode 100644 (file)
index 0000000..26496e9
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/ws_top.png differ
diff --git a/debian/whitestorkgui/usr/share/pixmaps/ws_tra.png b/debian/whitestorkgui/usr/share/pixmaps/ws_tra.png
new file mode 100644 (file)
index 0000000..0fb96bc
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/ws_tra.png differ
diff --git a/debian/whitestorkgui/usr/share/pixmaps/ws_warning_icon.png b/debian/whitestorkgui/usr/share/pixmaps/ws_warning_icon.png
new file mode 100644 (file)
index 0000000..7e4f7b6
Binary files /dev/null and b/debian/whitestorkgui/usr/share/pixmaps/ws_warning_icon.png differ
diff --git a/debian/whitestorkplugins.postinst b/debian/whitestorkplugins.postinst
new file mode 100755 (executable)
index 0000000..4077edf
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Creating 'elements' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/name "Polish-English_Sample_Dictionary"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/path "/usr/share/WhiteStork/dictionaries/StarDictSampleDict"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/optimized false'
+echo -e "Creating 'Polish - English Sample Dictionary' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/name "English-Polish_Sample_Dictionary"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/path "/usr/share/WhiteStork/dictionaries/XDXFSampleDict"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/optimized false'
+
+echo -e "Adding gconf entries for search engines" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/xdxf/path "/usr/lib/WhiteStork/engine_xdxf.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/stardict/path "/usr/lib/WhiteStork/engine_stardict.so"'
+
+fi
diff --git a/debian/whitestorkplugins.substvars b/debian/whitestorkplugins.substvars
new file mode 100644 (file)
index 0000000..39f0b5a
--- /dev/null
@@ -0,0 +1 @@
+shlibs:Depends=libc6 (>= 2.3.5-1), libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libexpat1 (>= 1.95.8), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libosso-gnomevfs2-0, zlib1g (>= 1:1.2.1)
diff --git a/debian/whitestorkplugins/DEBIAN/control b/debian/whitestorkplugins/DEBIAN/control
new file mode 100644 (file)
index 0000000..0ae2b8a
--- /dev/null
@@ -0,0 +1,24 @@
+Package: whitestorkplugins
+Version: 1.1.0-1
+Section: user/office
+Priority: optional
+Architecture: armel
+Depends: libc6 (>= 2.3.5-1), libdbus-1-2 (>= 0.61), libdbus-glib-1-2 (>= 0.61), libexpat1 (>= 1.95.8), libgconf2-6 (>= 2.6.4.15), libglib2.0-0 (>= 2.8.6-1osso1), libosso-gnomevfs2-0, zlib1g (>= 1:1.2.1), whitestork (>= 1.1.0-1)
+Installed-Size: 204
+Maintainer: Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com>
+Source: whitestork
+Description: Dictionary plugins for mDictionary
+Maemo-Icon-26: 
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
+ WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1wEJDBUeRyfCHgAAAk5JREFUSMftlk9LVGEUxn937lzv
+ nROjZDOpYdg/E3XQoiCEsk1R0CosXPUJ2rVp0baP0Aco2rRxE0FhRFGRmzbRH9IW0SJBLFKpR67j
+ eFv4DkyTOtMoLaKzet/3POc8nHuf+7wX/rXwGqyLgHNuHUdRNJFKpeYlLa9X4NfZuAXYAWSjKOpK
+ kmQoSZK7wAhwC7ji+35zEASFIAi+FItFrTXRNiAPcAT25+AQwGHo7YQ+gD2wtxXaJ0GXff+8SqUs
+ MA58BHLAJUAAYRimfN9/Imm2kig9BFd7YdQ1TI/CvnIyB7RWgK+H4TXF8bibZAWYcSkBYwBxHI+Y
+ 2XB5v947SgO95c0p6M9DD0AHtN3JZCamFxdvA4XVIwQ0A+/ddC1Aj5ntljTWsHLMrNvMBty2GTgI
+ WBXmuJm1bVp1ZtYNDLhp5ipSeSAAnkua2Sp5Y2ZZ4IIj+wBMSiquh083QNAGDALHHEE38G4jkron
+ MrPTQNbhZ4BXVZAunGiAJeCRJNVNZGYF1+ChpJPAV+BFjZpgVbD8kPS0JpEjKUqarDjuAC669Sfg
+ fsUUv0Qmk9npeV6/pMe1iEZqfAtp4Kzr0bRGfiUMw3bf929KWkxvwpCXgXsbAXzfP1P209QGuFkz
+ y29C/k1AIOl7PWIYBmLgpaTSH5D0ONk/KF8dXh1FncBR9wjeAguSpqsw24F8LkkKyxDOed5rSW8a
+ dgYz63PGuasq9e3G0tLgiVLp2YEkWfBgasssqDqS1atjCojXIkr9rX+G/0QNR3oLe30G5p1j/BY/
+ AaknsXLnUsw8AAAAAElFTkSuQmCC
diff --git a/debian/whitestorkplugins/DEBIAN/md5sums b/debian/whitestorkplugins/DEBIAN/md5sums
new file mode 100644 (file)
index 0000000..0592362
--- /dev/null
@@ -0,0 +1,9 @@
+dea05c6e24388ba68bf00897dac9c7e8  usr/lib/WhiteStork/engine_stardict.so
+25d99de3c763409493df8b0a9e32188f  usr/lib/WhiteStork/engine_xdxf.so
+7c74be6da693ae5af69b58769d0c7c53  usr/share/pixmaps/engine_xdxf_icon.png
+d64b7c82ff46e12689515eac7b978f66  usr/share/WhiteStork/dictionaries/XDXFSampleDict/dict.xdxf
+e89a3c84ad2a8f1dee1fe72e08e89de2  usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.idx
+334e764704d44edcb5ce5c78e237feff  usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.dict.dz
+5b5d19617ab1378d73a72c1af032890b  usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.ifo
+a31f5e3654fffd3a988ece3fe4804fed  usr/share/doc/whitestorkplugins/changelog.Debian.gz
+29b17cf44468f9ec3912a102c2b260f1  usr/share/doc/whitestorkplugins/copyright
diff --git a/debian/whitestorkplugins/DEBIAN/postinst b/debian/whitestorkplugins/DEBIAN/postinst
new file mode 100755 (executable)
index 0000000..4077edf
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+echo -e "Postinstalling actions..." 
+
+if [ "$1" != "upgrade" ]
+then
+# End automatically added section
+echo -e "Creating 'elements' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/name "Polish-English_Sample_Dictionary"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/path "/usr/share/WhiteStork/dictionaries/StarDictSampleDict"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/StarDictSampleDict/optimized false'
+echo -e "Creating 'Polish - English Sample Dictionary' dictionary" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/name "English-Polish_Sample_Dictionary"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/path "/usr/share/WhiteStork/dictionaries/XDXFSampleDict"'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/active true'
+su $USER -c 'gconftool-2 --type bool --set /apps/maemo/WhiteStork/Dictionaries/XDXFSampleDict/optimized false'
+
+echo -e "Adding gconf entries for search engines" 
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/xdxf/path "/usr/lib/WhiteStork/engine_xdxf.so"'
+su $USER -c 'gconftool-2 --type string --set /apps/maemo/WhiteStork/Engines/stardict/path "/usr/lib/WhiteStork/engine_stardict.so"'
+
+fi
diff --git a/debian/whitestorkplugins/usr/lib/WhiteStork/engine_stardict.so b/debian/whitestorkplugins/usr/lib/WhiteStork/engine_stardict.so
new file mode 100644 (file)
index 0000000..78c6b05
Binary files /dev/null and b/debian/whitestorkplugins/usr/lib/WhiteStork/engine_stardict.so differ
diff --git a/debian/whitestorkplugins/usr/lib/WhiteStork/engine_xdxf.so b/debian/whitestorkplugins/usr/lib/WhiteStork/engine_xdxf.so
new file mode 100644 (file)
index 0000000..3c7039f
Binary files /dev/null and b/debian/whitestorkplugins/usr/lib/WhiteStork/engine_xdxf.so differ
diff --git a/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.dict.dz b/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.dict.dz
new file mode 100644 (file)
index 0000000..f6d5541
--- /dev/null
@@ -0,0 +1 @@
+Thank you very much.WhitestorkBe careful!I would like a ticket to...I would like to change dollars.I think I am lost.What town is this?What?traveller's checksJunefortyfourteenfourfour thousandfour hundredThursdayfourthCan I get there on foot?Is there a taxi standby nearby?Is there a currency exchange office nearby?Is there a sleeping car on the train?Do you have a map of the city?May we have an extra bed?Can I pay with my credit card?Could you help me?Could you show me this on the map, please?Do you speak English?Why?Good-bye.Good night.(Goodbye at night time)Good evening.Okay.seconda lot ofmuchtwotwo thousandtwentytwenty-onetwelvetwo hundredtwicetenthtenten percentten thousandninthnineteenninenine thousandninetynine hundreddayGood day.Good morning.todayThank you.Where is the nearest...Where is the nearest bank?Where is... ?Where?DecemberHow much do I owe you?How much is it per night?How much is the fare?How old are you?What is your name?How late it is?How do I get to this address?How far is it?How?Which line goes to...?oneelevena thirdautumnIt is two in the afternoon.It is 4:30 am.It is two o'clock.It is 6:15 pm.It is one o'clock.It is three in the afternoon.It is 3:40 am.It is three o'clock.It is one in the afternoon.tomorrowWhen does it leave?When does it arrive?When?fewblanketsupperWho?What time is it?AprilsummerdoctorleftJulyNovemberFebruaryMayMy name is...I have a reservation.MarchDo you have any vacancies?Can we switch rooms?Can you show me the room?on the cornerI do not speak Polish.I do not understand.No.SundaynightsdinnerOf course.eighteight thousandeightyeighteeneight hundredOctoberplatformfirstFridayfifthfifteenfivefive minutes agofive thousandfiftyfive hundreddouble bedroomHelp!MondayRepeat, please.halfnoonrightstraight aheadPlease tell me when to get off.The bill, please.Please call me a taxi.Please speak more slowly.Please.You are welcome.private bathExcuse me.Excuse me.I am sorry.bus stationtram stationmidnightlateronceKeep the change.roll of toilet paperI understand a little.bath towelssevenseven thousandseventyseventeenseven hundredAugustseventhSaturdaytrain stationsubway stationone hundredStop!Januarysixteensixsix thousandsixtysix hundredsixthYes.nowtracksomethirdthreethree thousandthirtythirteenthree hundredone thousandWatch out!earlieryesterdaymanyspringHello.soonSeptemberAll aboard.TuesdayzeroThat's right.Agreed.wintereightha quarterI am in a hurry.breakfastWednesday
\ No newline at end of file
diff --git a/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.idx b/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.idx
new file mode 100644 (file)
index 0000000..e140e95
Binary files /dev/null and b/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.idx differ
diff --git a/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.ifo b/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/StarDictSampleDict/sample.ifo
new file mode 100644 (file)
index 0000000..a37e79e
--- /dev/null
@@ -0,0 +1,6 @@
+StarDict's dict ifo file
+version=2.4.2
+wordcount=209
+idxfilesize=4539
+bookname=sample
+sametypesequence=m
diff --git a/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/XDXFSampleDict/dict.xdxf b/debian/whitestorkplugins/usr/share/WhiteStork/dictionaries/XDXFSampleDict/dict.xdxf
new file mode 100644 (file)
index 0000000..71717ee
--- /dev/null
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<xdxf lang_from="ENG" lang_to="POL" format="visual">\r
+       <full_name>English - Polish dictionary</full_name>\r
+       <description>Sample dictionary with some usefull expressions. Any suggestions? Please conntact marcin.biedron@comarch.pl. This file is part of WhiteStork application. Copyright 2007, ComArch S.A. All rights reserved.</description>\r
+       <ar><k>a lot of</k> - dużo</ar>\r
+       <ar><k>a quarter</k> - ćwiartka</ar>\r
+       <ar><k>a third</k> - jedna trzecia</ar>\r
+       <ar><k>Agreed.</k> - Zgoda.</ar>\r
+       <ar><k>All aboard.</k> - Wsiadać proszę.</ar>\r
+       <ar><k>April</k> - kwiecień</ar>\r
+       <ar><k>August</k> - sierpień</ar>\r
+       <ar><k>autumn</k> - jesień</ar>\r
+       <ar><k>bath towels</k> - ręczniki</ar>\r
+       <ar><k>Be careful!</k> - Bądź ostrożny!</ar>\r
+       <ar><k>blanket</k> - koc</ar>\r
+       <ar><k>breakfast</k> - śniadanie</ar>\r
+       <ar><k>bus station</k> - przystanek autobusowy</ar>\r
+       <ar><k>Can I get there on foot?</k> - Czy dojdę tam na pieszo?</ar>\r
+       <ar><k>Can I pay with my credit card?</k> - Czy można płacić kartą (kredytową)?</ar>\r
+       <ar><k>Can we switch rooms?</k> - Możemy zamienić pokoje?</ar>\r
+       <ar><k>Can you show me the room?</k> - Możesz pokazać mi pokój?</ar>\r
+       <ar><k>Could you help me?</k> - Czy mógłbyś mi pomóc?</ar>\r
+       <ar><k>Could you show me this on the map, please?</k> - Czy mógłbyś pokazać mi to miejsce na mapie?</ar>\r
+       <ar><k>day</k> - dzień</ar>\r
+       <ar><k>December</k> - grudzień</ar>\r
+       <ar><k>dinner</k> - obiad</ar>\r
+       <ar><k>Do you have a map of the city?</k> - Czy masz mapę miasta?</ar>\r
+       <ar><k>Do you have any vacancies?</k> - Masz wolne pokoje?</ar>\r
+       <ar><k>Do you speak English?</k> - Czy mówisz po angielsku?</ar>\r
+       <ar><k>doctor</k> - lekarz</ar>\r
+       <ar><k>double bed</k> - podwójne łóżko</ar>\r
+       <ar><k>earlier</k> - wcześniej</ar>\r
+       <ar><k>eight</k> - osiem</ar>\r
+       <ar><k>eight hundred</k> - osiemset</ar>\r
+       <ar><k>eight thousand</k> - osiem tysięcy</ar>\r
+       <ar><k>eighteen</k> - osiemnaście</ar>\r
+       <ar><k>eighth</k> - ósmy</ar>\r
+       <ar><k>eighty</k> - osiemdziesiąt</ar>\r
+       <ar><k>eleven</k> - jedenaście</ar>\r
+       <ar><k>Excuse me.</k> - Przepraszam.</ar>\r
+       <ar><k>Excuse me.</k> - Przepraszam.</ar>\r
+       <ar><k>February</k> - luty</ar>\r
+       <ar><k>few</k> - kilka</ar>\r
+       <ar><k>fifteen</k> - piętnaście</ar>\r
+       <ar><k>fifth</k> - piąty</ar>\r
+       <ar><k>fifty</k> - pięćdziesiąt</ar>\r
+       <ar><k>first</k> - pierwszy</ar>\r
+       <ar><k>five</k> - pięć</ar>\r
+       <ar><k>five hundred</k> - pięćset</ar>\r
+       <ar><k>five minutes ago</k> - pięć minut temu</ar>\r
+       <ar><k>five thousand</k> - pięć tysiące</ar>\r
+       <ar><k>forty</k> - czterdzieści</ar>\r
+       <ar><k>four</k> - cztery</ar>\r
+       <ar><k>four hundred</k> - czterysta</ar>\r
+       <ar><k>four thousand</k> - cztery tysiące</ar>\r
+       <ar><k>fourteen</k> - czternaście</ar>\r
+       <ar><k>fourth</k> - czwarty</ar>\r
+       <ar><k>Friday</k> - piątek</ar>\r
+       <ar><k>Good day.</k> - Dzień dobry.</ar>\r
+       <ar><k>Good evening.</k> - Dobry wieczór.</ar>\r
+       <ar><k>Good morning.</k> - Dzień dobry.</ar>\r
+       <ar><k>Good night.(Goodbye at night time)</k> - Dobranoc.</ar>\r
+       <ar><k>Good-bye.</k> - Do widzenia.</ar>\r
+       <ar><k>half</k> - połowa</ar>\r
+       <ar><k>Hello.</k> - Witam.</ar>\r
+       <ar><k>Help!</k> - Pomocy!</ar>\r
+       <ar><k>How do I get to this address?</k> - Jak się dostanę pod ten adres?</ar>\r
+       <ar><k>How far is it?</k> - Jak to daleko?</ar>\r
+       <ar><k>How late it is?</k> - Jak późno już jest?</ar>\r
+       <ar><k>How much do I owe you?</k> - Ile jestem winny?</ar>\r
+       <ar><k>How much is it per night?</k> - Ile kosztuje jedna noc?</ar>\r
+       <ar><k>How much is the fare?</k> - Ile kosztuje przejazd?</ar>\r
+       <ar><k>How old are you?</k> - Ile masz lat?</ar>\r
+       <ar><k>How?</k> - Jak?</ar>\r
+       <ar><k>I am in a hurry.</k> - Śpieszy mi się.</ar>\r
+       <ar><k>I am sorry.</k> - Przykro mi.</ar>\r
+       <ar><k>I do not speak Polish.</k> - Nie mówię po polsku.</ar>\r
+       <ar><k>I do not understand.</k> - Nie rozumiem.</ar>\r
+       <ar><k>I have a reservation.</k> - Mam rezerwację</ar>\r
+       <ar><k>I think I am lost.</k> - Chyba się zgubiłem.</ar>\r
+       <ar><k>I understand a little.</k> - Rozumiem trochę.</ar>\r
+       <ar><k>I would like a ticket to...</k> - Chciałbym bilet do...</ar>\r
+       <ar><k>I would like to change dollars.</k> - Chciałbym wymienić dolary.</ar>\r
+       <ar><k>Is there a currency exchange office nearby?</k> - Czy jest tam kantor wymiany walut?</ar>\r
+       <ar><k>Is there a sleeping car on the train?</k> - Czy jest tam wagon sypialny?</ar>\r
+       <ar><k>Is there a taxi standby nearby?</k> - Czy jest tam blisko postój taksówek?</ar>\r
+       <ar><k>It is 3:40 am.</k> - Jest trzecia czterdzieści.</ar>\r
+       <ar><k>It is 4:30 am.</k> - Jest czwarta czterdzieści.</ar>\r
+       <ar><k>It is 6:15 pm.</k> - Jest osiemnasta piętnaście.</ar>\r
+       <ar><k>It is one in the afternoon.</k> - Jest trzynasta.</ar>\r
+       <ar><k>It is one o'clock.</k> - Jest pierwsza.</ar>\r
+       <ar><k>It is three in the afternoon.</k> - Jest piętnasta.</ar>\r
+       <ar><k>It is three o'clock.</k> - Jest trzecia.</ar>\r
+       <ar><k>It is two in the afternoon.</k> - Jest czternasta.</ar>\r
+       <ar><k>It is two o'clock.</k> - Jest druga.</ar>\r
+       <ar><k>January</k> - styczeń</ar>\r
+       <ar><k>July</k> - lipiec</ar>\r
+       <ar><k>June</k> - czerwiec</ar>\r
+       <ar><k>Keep the change.</k> - Reszta dla ciebie.</ar>\r
+       <ar><k>later</k> - później</ar>\r
+       <ar><k>left</k> - lewo</ar>\r
+       <ar><k>many</k> - wiele</ar>\r
+       <ar><k>March</k> - marzec</ar>\r
+       <ar><k>May</k> - maj</ar>\r
+       <ar><k>May we have an extra bed?</k> - Czy możemy prosić dodatkowe łóżko?</ar>\r
+       <ar><k>midnight</k> - północ</ar>\r
+       <ar><k>Monday</k> - poniedziałek</ar>\r
+       <ar><k>much</k> - dużo</ar>\r
+       <ar><k>My name is...</k> - Mam na imię...</ar>\r
+       <ar><k>nights</k> - noce</ar>\r
+       <ar><k>nine</k> - dziewięć</ar>\r
+       <ar><k>nine hundred</k> - dziewięćset</ar>\r
+       <ar><k>nine thousand</k> - dziewięć tysięcy</ar>\r
+       <ar><k>nineteen</k> - dziewiętnaście</ar>\r
+       <ar><k>ninety</k> - dziewięćdziesiąt</ar>\r
+       <ar><k>ninth</k> - dziewiąty</ar>\r
+       <ar><k>No.</k> - Nie.</ar>\r
+       <ar><k>noon</k> - południe</ar>\r
+       <ar><k>November</k> - listopad</ar>\r
+       <ar><k>now</k> - teraz</ar>\r
+       <ar><k>October</k> - październik</ar>\r
+       <ar><k>Of course.</k> - Oczywiście.</ar>\r
+       <ar><k>Okay.</k> - Dobrze.</ar>\r
+       <ar><k>on the corner</k> - na rogu</ar>\r
+       <ar><k>once</k> - raz</ar>\r
+       <ar><k>one</k> - jeden</ar>\r
+       <ar><k>one hundred</k> - sto</ar>\r
+       <ar><k>one thousand</k> - tysiąc</ar>\r
+       <ar><k>platform</k> - peron</ar>\r
+       <ar><k>Please call me a taxi.</k> - Proszę wezwać mi taksówkę.</ar>\r
+       <ar><k>Please speak more slowly.</k> - Proszę, mów wolniej.</ar>\r
+       <ar><k>Please tell me when to get off.</k> - Proszę mi powiedzieć gdzie mam wysiąść.</ar>\r
+       <ar><k>Please.</k> - Proszę.</ar>\r
+       <ar><k>private bath</k> - prywata łazienka</ar>\r
+       <ar><k>Repeat, please.</k> - Powtórz proszę.</ar>\r
+       <ar><k>right</k> - prawo</ar>\r
+       <ar><k>roll of toilet paper</k> - rolka papieru toaletowego</ar>\r
+       <ar><k>room</k> - pokój</ar>\r
+       <ar><k>Saturday</k> - sobota</ar>\r
+       <ar><k>second</k> - drugi</ar>\r
+       <ar><k>September</k> - wrzesień</ar>\r
+       <ar><k>seven</k> - siedem</ar>\r
+       <ar><k>seven hundred</k> - siedemset</ar>\r
+       <ar><k>seven thousand</k> - siedem tysięcy</ar>\r
+       <ar><k>seventeen</k> - siedemnaście</ar>\r
+       <ar><k>seventh</k> - siódmy</ar>\r
+       <ar><k>seventy</k> - siedemdziesiąt</ar>\r
+       <ar><k>six</k> - sześć</ar>\r
+       <ar><k>six hundred</k> - sześćset</ar>\r
+       <ar><k>six thousand</k> - sześć tysięcy</ar>\r
+       <ar><k>sixteen</k> - szesnaście</ar>\r
+       <ar><k>sixth</k> - szósty</ar>\r
+       <ar><k>sixty</k> - sześćdziesiąt</ar>\r
+       <ar><k>some</k> - trochę</ar>\r
+       <ar><k>soon</k> - wkrótce</ar>\r
+       <ar><k>spring</k> - wiosna</ar>\r
+       <ar><k>Stop!</k> - Stop!</ar>\r
+       <ar><k>straight ahead</k> - prosto</ar>\r
+       <ar><k>subway station</k> - stacja metra</ar>\r
+       <ar><k>summer</k> - lato</ar>\r
+       <ar><k>Sunday</k> - niedziela</ar>\r
+       <ar><k>supper</k> - kolacja</ar>\r
+       <ar><k>ten</k> - dziesięć</ar>\r
+       <ar><k>ten percent</k> - dziesięć procent</ar>\r
+       <ar><k>ten thousand</k> - dziesięć tysięcy</ar>\r
+       <ar><k>tenth</k> - dziesiąty</ar>\r
+       <ar><k>Thank you very much.</k> - Bardzo dziękuję.</ar>\r
+       <ar><k>Thank you.</k> - Dziękuję.</ar>\r
+       <ar><k>That's right.</k> - Zgadza się.</ar>\r
+       <ar><k>The bill, please.</k> - Proszę o rachunek.</ar>\r
+       <ar><k>third</k> - trzeci</ar>\r
+       <ar><k>thirteen</k> - trzynaście</ar>\r
+       <ar><k>thirty</k> - trzydzieści</ar>\r
+       <ar><k>three</k> - trzy</ar>\r
+       <ar><k>three hundred</k> - trzysta</ar>\r
+       <ar><k>three thousand</k> - trzy tysiące</ar>\r
+       <ar><k>Thursday</k> - czwartek</ar>\r
+       <ar><k>today</k> - dzisiaj</ar>\r
+       <ar><k>tomorrow</k> - jutro</ar>\r
+       <ar><k>track</k> - tor</ar>\r
+       <ar><k>train station</k> - stacja kolejowa</ar>\r
+       <ar><k>tram station</k> - przystanek tramwajowy</ar>\r
+       <ar><k>traveller's checks</k> - czeki podróżne</ar>\r
+       <ar><k>Tuesday</k> - wtorek</ar>\r
+       <ar><k>twelve</k> - dwanaście</ar>\r
+       <ar><k>twenty</k> - dwadzieścia</ar>\r
+       <ar><k>twenty-one</k> - dwadzieścia jeden</ar>\r
+       <ar><k>twice</k> - dwukrotnie</ar>\r
+       <ar><k>two</k> - dwa</ar>\r
+       <ar><k>two hundred</k> - dwieście</ar>\r
+       <ar><k>two thousand</k> - dwa tysiące</ar>\r
+       <ar><k>Watch out!</k> - Uważaj!</ar>\r
+       <ar><k>Wednesday</k> - środa</ar>\r
+       <ar><k>What is your name?</k> - Jak masz na imię?</ar>\r
+       <ar><k>What time is it?</k> - Która godzina?</ar>\r
+       <ar><k>What town is this?</k> - Co to za miasto?</ar>\r
+       <ar><k>What?</k> - Co?</ar>\r
+       <ar><k>When does it arrive?</k> - Kiedy przyjeżdża?</ar>\r
+       <ar><k>When does it leave?</k> - Kiedy odjeżdża?</ar>\r
+       <ar><k>When?</k> - Kiedy?</ar>\r
+       <ar><k>Where is the nearest bank?</k> - Gdzie jest najbliższy bank?</ar>\r
+       <ar><k>Where is the nearest...</k> - Gdzie jest najbliższa...</ar>\r
+       <ar><k>Where is... ?</k> - Gdzie jest... ?</ar>\r
+       <ar><k>Where?</k> - Gdzie?</ar>\r
+       <ar><k>Which line goes to...?</k> - Jaka linia kursuje do...?</ar>\r
+       <ar><k>Whitestork</k> - Bocian</ar>\r
+       <ar><k>Who?</k> - Kto?</ar>\r
+       <ar><k>Why?</k> - Dlaczego?</ar>\r
+       <ar><k>winter</k> - zima</ar>\r
+       <ar><k>Yes.</k> - Tak.</ar>\r
+       <ar><k>yesterday</k> - wczoraj</ar>\r
+       <ar><k>You are welcome.</k> - Proszę.</ar>\r
+       <ar><k>zero</k> - zero</ar>\r
+</xdxf>
\ No newline at end of file
diff --git a/debian/whitestorkplugins/usr/share/doc/whitestorkplugins/changelog.Debian.gz b/debian/whitestorkplugins/usr/share/doc/whitestorkplugins/changelog.Debian.gz
new file mode 100644 (file)
index 0000000..3db3bb9
Binary files /dev/null and b/debian/whitestorkplugins/usr/share/doc/whitestorkplugins/changelog.Debian.gz differ
diff --git a/debian/whitestorkplugins/usr/share/doc/whitestorkplugins/copyright b/debian/whitestorkplugins/usr/share/doc/whitestorkplugins/copyright
new file mode 100644 (file)
index 0000000..83db946
--- /dev/null
@@ -0,0 +1,15 @@
+This package was debianized by Krzysztof Sasiak <Krzysztof.Sasiak@comarch.com> on
+Thu, 29 Mar 2007 13:28:58 +0200.
+
+It was downloaded from https://garage.maemo.org
+
+Upstream Author: WhiteStork development team
+
+Copyright: Comarch 2006-2007
+
+License:
+
+All components are either under the GPL or LGPL. The complete text of the GPL and LGPL licenses can be found in the /usr/share/common-licenses/GPL and /usr/share/common-licenses/LGPL files.
+
+The Debian packaging is (C) 2007, Krzysiek Sasiak <Krzysztof.Sasiak@comarch.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
diff --git a/debian/whitestorkplugins/usr/share/pixmaps/engine_xdxf_icon.png b/debian/whitestorkplugins/usr/share/pixmaps/engine_xdxf_icon.png
new file mode 100644 (file)
index 0000000..b35c0cc
Binary files /dev/null and b/debian/whitestorkplugins/usr/share/pixmaps/engine_xdxf_icon.png differ
diff --git a/generate_locale b/generate_locale
new file mode 100755 (executable)
index 0000000..5d7d51e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+echo -e -n "Generating locale...\n"
+for nazwa in `find $1 -name *.po -type f -printf "%f\n"`
+       do
+       tekst=${nazwa%.po}
+       install -d $2/$tekst/LC_MESSAGES/
+       msgfmt $1/$nazwa -o $2/$tekst/LC_MESSAGES/whitestork.mo
+       done
diff --git a/generate_repo b/generate_repo
new file mode 100755 (executable)
index 0000000..bdf5a3b
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+test=`arch | tr -d [:space:]`
+case $test in
+       i686) ARCH=i386;;
+       arm) ARCH=armel;;
+esac
+
+echo $ARCH
+install -d $1/dists/mistral/free/binary-$ARCH
+cp *.deb $1/dists/mistral/free/binary-$ARCH
+cd $1 && dpkg-scanpackages dists/mistral/free/binary-$ARCH /dev/null | gzip -9c > dists/mistral/free/binary-$ARCH/Packages.gz
diff --git a/include/dictionary_engine.h b/include/dictionary_engine.h
new file mode 100644 (file)
index 0000000..20ada28
--- /dev/null
@@ -0,0 +1,296 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef   _DICTIONARY_ENGINE_BASE
+#define   _DICTIONARY_ENGINE_BASE
+
+#ifdef    __cplusplus
+       extern "C" {
+#endif
+
+#ifndef NOLOGS
+       #include <glib/gstdio.h>
+       #define eg_debug g_debug
+       #define eg_warning g_warning
+       #define eg_error g_error
+       #define eg_critical g_critical
+#else
+       #define eg_debug(frm,...) while(FALSE)
+       #define eg_warning(frm,...) while(FALSE)
+       #define eg_error(frm,...) while(FALSE)
+       #define eg_critical(frm,...) while(FALSE)
+#endif
+
+#define eg_malloc(n)   g_try_malloc0(n)
+#define eg_free(n)     g_free(n); n = NULL
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// header with gnu library for C - most of types and functions needed it (all
+// started from g* and g_*().
+#include <glib.h>
+//------------------------------------------------------------------------------
+
+#define _GLOBAL_FUNCTIONS_NAME_  "engine_global_functions"
+#define _GLOBAL_FUNCTIONS_       engine_global_functions
+
+//______________________________________________________________________________
+// *****************************************************************************
+//******************************************************* GLOBAL MACROS SECTION:
+//------------------------------------------------------------------------------
+#define         dict_eng_module_check(module,location)   \
+                        ( (module).engine_check( (location) ) )
+//------------------------------------------------------------------------------
+#define         dict_eng_module_get_description(module)   \
+                        ( (module).engine_description() )
+//------------------------------------------------------------------------------
+#define         dict_eng_module_get_version(module)   \
+                        ( (module).engine_version() )
+//------------------------------------------------------------------------------
+#define         dict_eng_module_get_format(module)   \
+                        ( (module).engine_version() )
+//------------------------------------------------------------------------------
+#define         dict_eng_module_create(module,location,flags)   \
+        ( (module).engine_create(  (location), (flags), NULL, NULL, 0.01 ) )
+//------------------------------------------------------------------------------
+#define         dict_eng_module_create_ext(module,                      \
+                                           location,                    \
+                                           flags,                       \
+                                           progress_handler,            \
+                                           progress_data,               \
+                                           seed                         \
+                                           )  (                         \
+                       (module).engine_create( (location),              \
+                                               (flags),                 \
+                                               (progress_handler),      \
+                                               (progress_data),         \
+                                               (seed)                   \
+                                             ))
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** CONCRETE DICTIONARY MACROS SECTION:
+//------------------------------------------------------------------------------
+#define         dict_eng_set_progress_seed(engine, signal, val) (              \
+                        (engine) -> engine_set_progress_seed( (engine),        \
+                                                              (signal),        \
+                                                              (val)            \
+                                                            ))
+//------------------------------------------------------------------------------
+#define         dict_eng_set_auto_free(engine, state)  \
+                        (engine) -> engine_set_auto_free( (engine), (state) )
+//------------------------------------------------------------------------------
+#define         dict_eng_optimize(engine)  \
+                        ((engine) -> engine_optimize( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_is_optimized( engine )  \
+                        ((engine) -> engine_is_optimized( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_location(engine)    \
+                        ((engine) -> engine_location( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_last_status(engine)    \
+                        ((engine) -> engine_error( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_status_message(engine, error)     \
+                        ((engine) -> engine_error_message( (error) ))
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+#define         dict_eng_destroy(engine)    \
+                        ((engine) -> engine_close( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_search_word_list(engine,pattern,data)    \
+                        ((engine) -> engine_search_word_list( (engine),        \
+                                                              (pattern),       \
+                                                              (data)           \
+                                                            ))
+//------------------------------------------------------------------------------
+#define         dict_eng_search_word_translation(engine,word,data)    \
+                        ((engine) -> engine_search_word_translation( (engine), \
+                                                                     (word),   \
+                                                                     (data)    \
+                                                                   ))
+//------------------------------------------------------------------------------
+#define         dict_eng_search_word_translation_extended(engine,word)   \
+                ((engine) -> engine_search_word_translation_extended((engine), \
+                                                                     (pattern) \
+                                                                     ))
+//------------------------------------------------------------------------------
+#define         dict_eng_set_callback(engine,signal,c_handler,data)     \
+                        ((engine) -> engine_set_callback( (engine),     \
+                                                          (signal),     \
+                                                          (c_handler),  \
+                                                          (data)        \
+                                                        ))
+//------------------------------------------------------------------------------
+#define         dict_eng_add_word(engine,word,tran)    \
+                        ((engine) -> engine_add_word( (engine), \
+                                                       (word),   \
+                                                       (tran) \
+                                                     ))
+//------------------------------------------------------------------------------
+#define         dict_eng_remove_word(engine,word)    \
+                        ((engine) -> engine_remove_word( (engine), \
+                                                          (word)   \
+                                                        ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_lang_from(engine)    \
+                        ((engine) -> engine_get_lang_from( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_lang_to(engine)    \
+                        ((engine) -> engine_get_lang_to( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_title(engine)    \
+                        ((engine) -> engine_get_title( (engine) ))
+//------------------------------------------------------------------------------
+#define         dict_eng_get_icon_path(engine)    \
+                        ((engine) -> engine_get_icon_path( (engine) ))
+//------------------------------------------------------------------------------
+
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************ SIGNALS DEFINITION FOR CALLBACKS SECTION:
+//------------------------------------------------------------------------------
+#define ENGINE_WORD_LIST_SIGNAL                 "on_word_list_found"
+//------------------------------------------------------------------------------
+#define ENGINE_WORD_TRANSLATION_SIGNAL          "on_word_translation_found"
+//------------------------------------------------------------------------------
+#define ENGINE_PROGRESS_OPTIMIZING_SIGNAL       "on_progress_optimizing"
+//------------------------------------------------------------------------------
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************** DEFINITIONS OF ENUMS TYPES:
+//------------------------------------------------------------------------------
+typedef enum
+{
+        ENGINE_CREATE = 0, 
+        ENGINE_NO,
+        ENGINE_REFRESH 
+} EngineOptimizationFlag;
+//------------------------------------------------------------------------------
+typedef enum
+{
+        ENGINE_NO_ERROR = 0,
+        ENGINE_WRONG_FILE,
+        ENGINE_COULDNT_READ,
+       ENGINE_COULDNT_WRITE,
+       ENGINE_INTERNAL_ERROR,
+        ENGINE_NO_FILE,     
+        ENGINE_OUT_OF_MEMORY
+}
+EngineStatus;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************* DEFINITIONS OF CALLBACK'S TYPES:
+//------------------------------------------------------------------------------
+typedef void (*cb_word_list)(GArray* list,
+                             gchar* pattern,
+                             gpointer user_data,
+                             EngineStatus error);
+//------------------------------------------------------------------------------
+typedef void (*cb_word_translation)(gchar* translation,
+                                    gchar* word,
+                                    gpointer user_data,
+                                    EngineStatus error);
+//------------------------------------------------------------------------------
+typedef void (*cb_progress)(gdouble value,
+                            gpointer user_data,
+                            EngineStatus error);
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+struct _Engine;
+typedef struct _Engine Engine;
+
+struct _Engine
+{
+        // 0.1 API specification
+        void            (*engine_set_auto_free)(Engine* engine,
+                                                gboolean state);
+        gchar*          (*engine_location)(Engine* engine);       
+        gboolean        (*engine_is_optimized)(Engine* engine);
+        void            (*engine_optimize)(Engine* engine);
+        void            (*engine_search_word_list)(Engine* engine,
+                                                   gchar* pattern,
+                                                  gpointer data);
+        void            (*engine_search_word_translation)(Engine* engine,
+                                                          gchar* word,
+                                                         gpointer data);
+        void            (*engine_close)(Engine* engine);
+        // engine status
+        EngineStatus    (*engine_status)(Engine* engine);
+        gchar*          (*engine_error_message)(EngineStatus error);
+        // callbacks
+        gpointer        (*engine_set_callback)(Engine* engine, 
+                                               gchar* signal, 
+                                               gpointer c_handler, 
+                                               gpointer user_data);
+        void            (*engine_set_progress_seed)(Engine* engine,
+                                                    gchar* signal,
+                                                    gdouble seed);
+        // 0.2 API specification's functions
+        gboolean        (*engine_add_word)(Engine* engine,
+                                           gchar*  word,
+                                           gchar*  translation);
+        gboolean        (*engine_remove_word)(Engine* engine,
+                                              gchar*  word);        
+        gchar*          (*engine_get_lang_from)(Engine* engine);
+        gchar*          (*engine_get_lang_to)(Engine* engine);
+        gchar*          (*engine_get_title)(Engine* engine);
+        gchar*          (*engine_get_icon_path)(Engine* engine);
+
+        // dictionary independent data
+        gpointer engine_data;
+};
+//------------------------------------------------------------------------------
+typedef struct  {
+        gboolean (*engine_check)(gchar* location); 
+        gchar*   (*engine_description)(void);     
+        gchar*   (*engine_format)(void);
+        gchar*   (*engine_version)(void);
+        Engine*  (*engine_create)(gchar* location,
+                                   EngineOptimizationFlag flags,
+                                   cb_progress progress_handler,
+                                   gpointer progress_data,
+                                   gdouble seed);
+} 
+EngineModule;
+//------------------------------------------------------------------------------
+typedef EngineModule (*getting_additional)(void);
+//------------------------------------------------------------------------------
+extern EngineModule engine_global_functions(void);
+//------------------------------------------------------------------------------
+
+          
+#ifdef __cplusplus
+}                     
+#endif
+#endif /* _DICTIONARY_ENGINE_BASE */
diff --git a/include/ws_dbus.h b/include/ws_dbus.h
new file mode 100644 (file)
index 0000000..82d954d
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation;
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Copyright 2006 ComArch S.A.
+*/
+
+#ifndef _WS_DBUS
+#define _WS_DBUS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libosso.h>
+#include <dbus/dbus-protocol.h>
+#include <string.h>
+#include <dbus-1.0/dbus/dbus-protocol.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib-2.0/glib.h>
+
+/**\brief Callback function definition
+*
+*@param error - pointer to a GError structure. Currently not used
+*@param words - GArray of osso_rpc_t structures containing sent data
+*@param user_data - data passed by user while setting the callback 
+function with ::ws_dbus_set_cb
+*\sa ws_dbus_set_cb
+*/
+typedef void (* ws_dbus_cb) (GError *error, gpointer data, gpointer user_data); 
+
+/**\brief This structure contains data vital for DBUS communication.
+*
+* These are for example both the local and remote addresses of the applications 
+which are supposed to communicate. In this case they are the <I>GUI</I> and the 
+<I>MANAGER</I>
+* The fields shouldn't be modified directly. It should be done by ws_dbus_config
+ function
+*\sa ws_dbus_config
+*/
+
+typedef enum 
+{
+        WS_DBUS_TYPE_STRING = DBUS_TYPE_STRING,
+        WS_DBUS_TYPE_INT = DBUS_TYPE_INT32,
+        WS_DBUS_TYPE_UINT  = DBUS_TYPE_UINT32,
+        WS_DBUS_TYPE_BOOLEAN  = DBUS_TYPE_BOOLEAN,
+        WS_DBUS_TYPE_DOUBLE  = DBUS_TYPE_DOUBLE,
+        WS_DBUS_TYPE_INVALID  = DBUS_TYPE_INVALID,
+        WS_DBUS_TYPE_GARRAY = ((int) 'a'),
+        WS_DBUS_TYPE_SIGNAL = DBUS_TYPE_INT32
+} WSDBusDataType;
+
+struct _WSDBusData 
+{
+       osso_context_t * context; ///<a pointer needed by osso_initiallize
+
+       gchar *service; ///<owner service path
+       gchar *object; ///<owner object path
+       gchar *iface; ///<owner interface path
+
+       gchar *remote_service; ///<remote service path
+       gchar *remote_object; ///<remote object path
+       gchar *remote_iface; ///<remote interface path
+
+       gchar *name; ///<Program name
+       gchar *version; ///<Program version
+
+       GArray *method_data;
+       GArray *remote_method_data;
+};
+
+/**
+*\brief Informs whether the transmission succeeded or not
+*/
+typedef enum 
+{
+       WS_DBUS_STATUS_OK = 0, ///<Transmission succeeded
+       WS_DBUS_STATUS_ERROR ///<Transmission error
+} WSDBusStatus;
+
+/**\brief Specifies the possible kinds of event notifications that can be sent via DBus
+*/
+typedef enum 
+{
+       WS_DBUS_INFO_TERMINATE = 1, ///<GUI signal - terminate the application
+       WS_DBUS_INFO_STOP_SEARCH, ///<GUI signal - stop the current search
+       WS_DBUS_INFO_SEARCH_FINISHED, ///<Manager signal - informs the GUI, that there will be no more results returned
+       WS_DBUS_INFO_CACHING, ///<Manager signal - informs the GUI, that caching has started
+       WS_DBUS_INFO_CACHING_FINISHED, ///<Manager signal - informs the GUI, that caching has finished
+       WS_DBUS_INFO_CONFIG_CHANGED, ///<GUI signal - informs the Manager about changes in the GConf configuration
+       WS_DBUS_ERROR_INVALID_FILE_FORMAT, ///<Parser error - dictionary file has invalid format
+       WS_DBUS_ERROR_FILE_NOT_FOUND, ///<Parser error - dictionary file not found
+       WS_DBUS_ERROR_NO_PERMISSION, ///<Parser error - no permission to read the dictionary file
+       WS_DBUS_ERROR_UNKNOWN, ///<Parser error - unknown error
+       WS_DBUS_ERROR_OUT_OF_MEMORY, ///<Either the UI or the manager is out of memory
+       WS_DBUS_ERROR_ENGINE_NOT_FOUND, ///<Manager error - dictionary engine module, couldn't be located
+       //added by me
+       WS_DBUS_ERROR_DICTIONARY_NOT_LOAD, ///<Manager sigal - informs the GUI,that history record can not be found because dictionary is not activate
+        WS_DBUS_BOOKMARKS_ADDED_OK, ///<GUI signal - send if bookmark has been added succesfully
+        WS_DBUS_BOOKMARKS_REMOVED_OK, ///<GUI signal - send if bookmark has been removed succesfully
+       WS_DBUS_BOOKMARKS_ADDED_FAIL, ///<GUI signal - send if bookmark has not been added succesfully
+        WS_DBUS_BOOKMARKS_REMOVED_FAIL, ///<GUI signal - send if bookmark has not been removed succesfully
+       WS_DBUS_LOAD_BOOKMARK_FAILED, ///<GUI signal - blocks bookmarks
+       WS_DBUS_BOOKMARK_MODE_ON,
+       WS_DBUS_BOOKMARK_MODE_OFF,
+       WS_DBUS_EXTRACT_FILE,
+       WS_DBUS_EXTRACT_FILE_FINISHED,
+       WS_DBUS_WORDS_LIST_STARTED,
+       WS_DBUS_TRANSLATION_STARTED,
+       WS_DBUS_WORDS_LIST_FINISHED,
+       WS_DBUS_TRANSLATION_FINISHED,
+       WS_DBUS_WORDS_LIST_FULL
+
+} WSDBusNotify;
+
+
+/**
+*\brief This structure is used for specifying the field of WSDBusData structure one would like to modify.
+*
+*It is used in the ws_dbus_config function. Its main purpose is to clarify D-BUS
+ configuration.
+*/
+typedef enum 
+{
+       WS_DBUS_CONFIG_SERVICE = 1,
+       WS_DBUS_CONFIG_OBJECT,
+       WS_DBUS_CONFIG_IFACE,
+       WS_DBUS_CONFIG_REMOTE_SERVICE,
+       WS_DBUS_CONFIG_REMOTE_OBJECT,
+       WS_DBUS_CONFIG_REMOTE_IFACE
+} WSDBusConfig;
+
+typedef struct _WSDBusData WSDBusData;
+
+
+/**\brief First function to be called in every program using this wrapper library
+*
+*This function is used for allocating memory for the WSDBusData structure and 
+setting some basic parameters. 
+*@param name - name of the application
+*@param version - app's version
+*@return pointer to WSDBusData structure\n
+*\sa ::WSDBusData
+*/
+WSDBusData * ws_dbus_create (gchar *name, gchar *version);
+
+/**\brief This function is used for setting dbus service/client parameters.
+*
+*These include the addresses of both remote and local apps communicating
+*@param ws_dbus_data - pointer to a structure uniquely identifying 
+the application for DBus. The possible values of 
+*this parameter are listed here: ::WSDBusConfig
+*@param field - the name of the variable, this function is supposed to set. 
+*@param value - the value of the variable
+*@return WS_STATUS_OK - on success \n
+*WS_STATUS_ERROR - on error
+*\sa ::WSDBusConfig
+*/
+WSDBusStatus ws_dbus_config (WSDBusData * ws_dbus_data,
+                             WSDBusConfig field,
+                             gchar *value);
+
+/**
+*\brief Initialize D-BUS communication.
+*
+*It should be the called after <B>ws_dbus_create</B> and after setting all D-BUS
+ parameters with the <B>ws_dbus_config</B> function. 
+*The structure it returns is necessary to call out every function implemented in
+ this wrapper library.
+*@param ws_dbus_data - it's a structure containing the unique paths to objects 
+and interfaces to be registered in the DBus session daemon
+*@return WS_STATUS_OK - on success \n
+*WS_STATUS_ERROR - on error
+*\sa ::WSDBusConfig, ws_dbus_create, ws_dbus_config
+*/
+WSDBusStatus ws_dbus_connect (WSDBusData * ws_dbus_data);
+
+/**\brief Function deinitializing D-BUS wrapper library
+*
+*Before the program exits, all memory allocated by D-BUS should be freed.
+@param ws_dbus_data - pointer to a structure uniquely identifying the 
+application for DBus
+*@return WS_STATUS_OK - on success \n
+*WS_STATUS_ERROR - on error
+*/
+
+void ws_dbus_destroy (WSDBusData * ws_dbus_data);
+
+/**\brief This function is used for setting a callback function for some predefined signals. 
+*
+*Some of the signals should be used only by the <I>GUI</I>, others by the 
+<I>MANAGER</I>.
+*
+*@param ws_dbus_data - pointer to a structure uniquely identifying the 
+application for D-BUS
+*@param detailed_signal - string containing the signal name which will trigger 
+the function passed in 
+*the c_func parameter.
+*@param c_func - is a pointer to the signal handling function.
+*@param        user_data - is the data passed directly to the signal handling function
+*      
+*The predefined signal values for the GUI part are:
+*
+*      - <I>"return_words"</I> - used for receiving a list of words found by 
+the <I>MANAGER</I>
+*      - <I>"return_translations"</I> - used for receiving a list of 
+translations found by the <I>MANAGER</I>
+*      - <I>"signal"</I> - used for handling signals from the <I>MANAGER</I>. 
+In this case they are mainly error signals.
+*
+*The predefined signal values for the MANAGER part are:
+*
+*      - <I>"find_word"</I> - used for receiving the word a user is looking for
+*      - <I>"find_translation"</I> - used for receiving the word a user needs 
+to translate
+*      - <I>"signal"</I> - used for handling signals from the <I>GUI</I>. 
+In this case they are termination and stop search signals.
+*
+*@return WS_STATUS_OK - on success \n
+*WS_STATUS_ERROR - on error
+*\sa ::WSDBusConfig \n
+*#ws_dbus_cb
+*/
+
+WSDBusStatus ws_dbus_set_cb (WSDBusData * ws_dbus_data,
+                             gchar * detailed_signal,
+                             gpointer c_func,
+                             gpointer user_data);
+                             
+WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...);
+                               
+                                
+WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method, 
+                                  ...);
+
+void ws_dbus_multipleargs_test (WSDBusData * ws_dbus_data, gchar *method, ...);
+
+#define ws_dbus_notify(structure,arg)  ws_dbus_call_method(structure,"signal",WS_DBUS_TYPE_SIGNAL,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_client_find_word(structure,arg)        ws_dbus_call_method(structure,"find_word",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_client_find_translation(structure,arg) ws_dbus_call_method(structure,"find_translation",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_client_add_bookmark(structure,arg1,arg2)       ws_dbus_call_method(structure,"signal",WS_DBUS_TYPE_STRING,arg1,WS_DBUS_TYPE_STRING,arg2,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_client_remove_bookmark(structure,arg)  ws_dbus_call_method(structure,"remove_bookmark",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_client_extract_dictionary(structure,arg)               ws_dbus_call_method(structure,"extract_dictionary",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_server_return_extracted_dict(structure,arg)    ws_dbus_call_method(structure,"return_extracted_dict",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_server_return_words(structure,arg)     ws_dbus_call_method(structure,"return_words",WS_DBUS_TYPE_GARRAY,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_server_return_translations(structure,arg)      ws_dbus_call_method(structure,"return_translations",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
+
+#define ws_dbus_server_update_progressbar(structure,arg)       ws_dbus_call_method(structure,"update_progressbar",WS_DBUS_TYPE_DOUBLE,arg,WS_DBUS_TYPE_INVALID)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/logs/clean.log b/logs/clean.log
new file mode 100644 (file)
index 0000000..d64bdd5
--- /dev/null
@@ -0,0 +1,33 @@
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/gui'
+rm -f bin/*
+done
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/gui'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/dbus_wrapper'
+rm -rf bin/*
+rm -rf doc/*
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/dbus_wrapper'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/plugins/xdxf'
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/plugins/xdxf'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/plugins/stardict'
+Project 'StarDictEngine' directories has been cleaned.
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/plugins/stardict'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/manager'
+rm -f ./src/*.o ./bin/WhiteStorkManager ./src/*~ ./*~ 
+rm -f ./include/*~
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/manager'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/manager'
+rm -f ./src/*.o ./bin/WhiteStorkManager ./src/*~ ./*~ 
+rm -f ./include/*~
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/manager'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/bookmarks/sql'
+Project's 'BookmarkEngine' directories has been cleaned.
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/bookmarks/sql'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/bookmarks/sql3'
+Project's 'BookmarkEngine' directories has been cleaned.
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/bookmarks/sql3'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/bookmarks/bdb'
+Project 'BookmarkEngine' directories has been cleaned.
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/bookmarks/bdb'
+make[1]: Entering directory `/home/str/development/mdictionary/trunk/src/bookmarks/xdxf'
+Project's 'BookmarkEngine' directories has been cleaned.
+make[1]: Leaving directory `/home/str/development/mdictionary/trunk/src/bookmarks/xdxf'
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..08090ce
--- /dev/null
@@ -0,0 +1,5 @@
+# List of source files containing translatable strings.
+
+# Package source files
+../gui/src/ws_gui_layout.c
+../gui/src/ws_gui_callbacks.c
\ No newline at end of file
diff --git a/po/domain.mo b/po/domain.mo
new file mode 100644 (file)
index 0000000..dd44fee
Binary files /dev/null and b/po/domain.mo differ
diff --git a/po/en_GB.po b/po/en_GB.po
new file mode 100644 (file)
index 0000000..3986c6f
--- /dev/null
@@ -0,0 +1,313 @@
+# Copyright (C) 2006
+# This file is distributed under the same license as the PACKAGE package.
+# Anna Gadomska <Anna.Gadomska@comarch.pl>, 2006.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-14 11:34+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Anna Gadomska <Anna.Gadomska@comarch.pl>\n"
+"Language-Team: polish <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui_layout.c:42
+msgid "ws_ni_welcome"
+msgstr "Welcome to mDictionary!"
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr "Find"
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr "Dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr "Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr "Edit"
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr "View"
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr "Search"
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr "About ..."
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr "Close"
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr "Load dictionary"
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr "Select dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr "Remove dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr "Optimize dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr "Open Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr "Close Bookmarks"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr "Add Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr "Remove Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr "Copy"
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr "Paste"
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr "Select All"
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr "Hide words list"
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr "Zoom in"
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr "Zoom out"
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr "Full screen"
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr "Find next"
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr "Find previous"
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr "Stop"
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr "Search"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_add_bookmark"
+msgstr "Add Bookmark"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr "Copy"
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr "Paste"
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr "Select All"
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr "Edit"
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr "Zoom in"
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr "Zoom out"
+
+#: ../gui/src/ws_gui_layout.c:712 ../gui/src/ws_gui_layout.c:904
+msgid "ws_ti_choose_dictionaries_title"
+msgstr "Select dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:767 ../gui/src/ws_gui_layout.c:941
+#: ../gui/src/ws_gui_layout.c:1233 ../gui/src/ws_gui_layout.c:1427
+#: ../gui/src/ws_gui_layout.c:1488 ../gui/src/ws_gui_layout.c:1432
+msgid "ws_db_cancel"
+msgstr "Cancel"
+
+#: ../gui/src/ws_gui_layout.c:773 ../gui/src/ws_gui_layout.c:946
+#: ../gui/src/ws_gui_layout.c:1422 ../gui/src/ws_gui_layout.c:1483
+#: ../gui/src/ws_gui_layout.c:1427
+msgid "ws_db_ok"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:892
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr "There are no dictionaries to optimize."
+
+#: ../gui/src/ws_gui_layout.c:1022
+msgid "ws_ti_load_dictionary_title"
+msgstr "Load dictionary"
+
+#: ../gui/src/ws_gui_layout.c:1074
+msgid "ws_ni_dictionaries_activation_question"
+msgstr "Would you like to start using this dictionary now?"
+
+#: ../gui/src/ws_gui_layout.c:1106
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr "Would you like to optimize this dictionary?"
+
+#: ../gui/src/ws_gui_layout.c:1131
+msgid "ws_ni_dictionary_added"
+msgstr "New dictionary has been added."
+
+#: ../gui/src/ws_gui_layout.c:1138
+msgid "ws_ni_dictionary_wrong_file"
+msgstr "Wrong dictionary file."
+
+#: ../gui/src/ws_gui_layout.c:1189
+msgid "ws_ti_remove_dictionaries_title"
+msgstr "Remove dictionaries"
+
+#: ../gui/src/ws_gui_layout.c:1239
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr "remove selected"
+
+#: ../gui/src/ws_gui_layout.c:1305
+msgid "ws_ti_about_title"
+msgstr "About ..."
+
+#: ../gui/src/ws_gui_layout.c:1339
+msgid "ws_ib_dictionary_removed"
+msgstr "Dictionary has been removed"
+
+#: ../gui/src/ws_gui_layout.c:1401
+msgid "ws_ti_add_bookmark"
+msgstr "Add bookmark"
+
+#: ../gui/src/ws_gui_layout.c:1413
+msgid "ws_ti_bookmarks_add_question"
+msgstr "Add to bookmarks?"
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr "Bookmark has been added"
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr "Bookmark could not be added"
+
+#: ../gui/src/ws_gui_layout.c:1462
+msgid "ws_ti_remove_bookmark"
+msgstr "Remove bookmark"
+
+#: ../gui/src/ws_gui_layout.c:1474
+msgid "ws_ni_remove_bookmark_question"
+msgstr "Remove from bookmarks?"
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr "Bookmark has been removed"
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr "Bookmark could not be removed"
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr "An error occured"
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr "There is no dictionary available"
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr "Caching ..."
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr "Dictionary unavailable."
+
+#: ../gui/src/ws_gui_callbacks.c:289
+#: ../gui/src/ws_gui_layout.c:1534
+msgid "ws_ni_no_words_found"
+msgstr "No words found"
+
+#: ../gui/src/ws_gui_callbacks.c:867
+msgid "ws_ni_no_text_selected"
+msgstr "No text selected"
+
+#: ../gui/src/ws_gui_callbacks.c:970
+msgid "ws_ab_searching"
+msgstr "Searching ..."
+
+#: ../gui/src/ws_gui_callbacks.c:987
+msgid "ws_ni_no_word_typed"
+msgstr "No word typed."
+
+#: ../gui/src/ws_gui_callbacks.c:1008
+msgid "ws_ni_search_aborted"
+msgstr "Search has been aborted."
+
+#: ../gui/src/ws_gui_callbacks.c:1412
+msgid "ws_ni_select_word_to_add"
+msgstr "Select word to add."
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+msgid "ws_ni_select_word_to_remove"
+msgstr "Select word to remove."
+
+#: ../gui/src/ws_gui_callbacks.c:1128
+msgid "ws_ib_max_zoom"
+msgstr "Max zoom level reached"
+
+#: ../gui/src/ws_gui_callbacks.c:1152
+msgid "ws_ib_min_zoom"
+msgstr "Min zoom level reached"
+
+#: ../gui/src/ws_gui_callbacks.c:1161
+msgid "ws_ib_zoom_in"
+msgstr "Zooming in"
+
+#: ../gui/src/ws_gui_callbacks.c:1134
+msgid "ws_ib_zoom_out"
+msgstr "Zooming out"
+
+#: ../gui/src/ws_gui_callbacks.c:1018
+msgid "ws_ib_fullscreen_on"
+msgstr "Fullscreen mode on"
+
+#: ../gui/src/ws_gui_callbacks.c:1029
+msgid "ws_ib_fullscreen_off"
+msgstr "Fullscreen mode off"
\ No newline at end of file
diff --git a/po/pl_PL.po b/po/pl_PL.po
new file mode 100644 (file)
index 0000000..305a92a
--- /dev/null
@@ -0,0 +1,550 @@
+# Copyright (C) 2006
+# This file is distributed under the same license as the PACKAGE package.
+# Anna Gadomska, <Anna.Gadomska@comarch.pl>, 2006.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-14 11:34+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Anna Gadomska <Anna.Gadomska@comarch.pl>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui_layout.c:42
+msgid "ws_ni_welcome"
+msgstr "<font size=+2><center><br>Witamy w słowniku<br><b>WhiteStork</b><br>"
+       "</font><br><IMG SRC=file:/usr/share/pixmaps/whitestork.png></center>"
+
+#: ../gui/src/ws_gui_layout.c:45 ../gui/src/ws_gui_callbacks.c:143
+#: ../gui/src/ws_gui_callbacks.c:854 ../gui/src/ws_gui_callbacks.c:980
+msgid " "
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:63 ../gui/src/ws_gui_layout.c:1318
+msgid "WhiteStork"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:111 ../gui/src/ws_gui_layout.c:1328
+#: ../gui/src/ws_gui_layout.c:1335
+msgid "Tahoma 12"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:116
+msgid "url_requested"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr "Znajdz"
+
+#: ../gui/src/ws_gui_layout.c:212
+msgid "search"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:217
+msgid "toggled"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:222 ../gui/src/ws_gui_layout.c:227
+#: ../gui/src/ws_gui_layout.c:231
+msgid "clicked"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr "Slowniki"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr "Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr "Edycja"
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr "Widok"
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr "O programie ..."
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr "Zamknij"
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr "Załaduj słownik"
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr "Wybierz słowniki"
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr "Usuń słowniki"
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr "Optymalizuj słowniki"
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr "Otwórz Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr "Zamknij Zakładki"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr "Dodaj do Zakładek"
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr "Usuń z Zakładek"
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr "Kopiuj"
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr "Wklej"
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr "Zaznacz wszystko"
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr "Ukryj listę słów"
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr "Powiększ"
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr "Pomniejsz"
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr "Pełny ekran"
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr "Znajdź następny"
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr "Znajdź poprzedni"
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr "Zatrzymaj"
+
+#: ../gui/src/ws_gui_layout.c:410 ../gui/src/ws_gui_layout.c:415
+#: ../gui/src/ws_gui_layout.c:420 ../gui/src/ws_gui_layout.c:425
+#: ../gui/src/ws_gui_layout.c:429 ../gui/src/ws_gui_layout.c:434
+#: ../gui/src/ws_gui_layout.c:439 ../gui/src/ws_gui_layout.c:444
+#: ../gui/src/ws_gui_layout.c:449 ../gui/src/ws_gui_layout.c:454
+#: ../gui/src/ws_gui_layout.c:459 ../gui/src/ws_gui_layout.c:464
+#: ../gui/src/ws_gui_layout.c:469 ../gui/src/ws_gui_layout.c:474
+#: ../gui/src/ws_gui_layout.c:479 ../gui/src/ws_gui_layout.c:484
+#: ../gui/src/ws_gui_layout.c:489 ../gui/src/ws_gui_layout.c:494
+#: ../gui/src/ws_gui_layout.c:499 ../gui/src/ws_gui_layout.c:504
+#: ../gui/src/ws_gui_layout.c:509 ../gui/src/ws_gui_layout.c:515
+#: ../gui/src/ws_gui_layout.c:521 ../gui/src/ws_gui_layout.c:621
+#: ../gui/src/ws_gui_layout.c:626 ../gui/src/ws_gui_layout.c:631
+#: ../gui/src/ws_gui_layout.c:636 ../gui/src/ws_gui_layout.c:641
+#: ../gui/src/ws_gui_layout.c:645
+msgid "activate"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr "Kopiuj"
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr "Wklej"
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr "Zaznacz wszystko"
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr "Edycja"
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr "Powiększ"
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr "Pomniejsz"
+
+#: ../gui/src/ws_gui_layout.c:708 ../gui/src/ws_gui_layout.c:868
+#: ../gui/src/ws_gui_layout.c:1185
+msgid ""
+"\n"
+".::GUI::. /apps/WhiteStork/Dictionaries does not exist!!"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:712 ../gui/src/ws_gui_layout.c:904
+msgid "ws_ti_choose_dictionaries_title"
+msgstr "Wybierz słowniki"
+
+#: ../gui/src/ws_gui_layout.c:741 ../gui/src/ws_gui_layout.c:794
+#: ../gui/src/ws_gui_layout.c:811 ../gui/src/ws_gui_layout.c:1065
+msgid "/active"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:767 ../gui/src/ws_gui_layout.c:941
+#: ../gui/src/ws_gui_layout.c:1233 ../gui/src/ws_gui_layout.c:1427
+#: ../gui/src/ws_gui_layout.c:1488
+msgid "ws_db_cancel"
+msgstr "Anuluj"
+
+#: ../gui/src/ws_gui_layout.c:773 ../gui/src/ws_gui_layout.c:946
+#: ../gui/src/ws_gui_layout.c:1422 ../gui/src/ws_gui_layout.c:1483
+msgid "ws_db_ok"
+msgstr "OK"
+
+#: ../gui/src/ws_gui_layout.c:792 ../gui/src/ws_gui_layout.c:809
+#: ../gui/src/ws_gui_layout.c:966 ../gui/src/ws_gui_layout.c:986
+#: ../gui/src/ws_gui_layout.c:1055 ../gui/src/ws_gui_layout.c:1063
+#: ../gui/src/ws_gui_layout.c:1097 ../gui/src/ws_gui_layout.c:1257
+msgid "/"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:876 ../gui/src/ws_gui_layout.c:968
+#: ../gui/src/ws_gui_layout.c:988 ../gui/src/ws_gui_layout.c:1099
+msgid "/optimized"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:892
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr "Brak słowników do zoptymalizowania."
+
+#: ../gui/src/ws_gui_layout.c:1022
+msgid "ws_ti_load_dictionary_title"
+msgstr "Załaduj słownik"
+
+#: ../gui/src/ws_gui_layout.c:1051
+msgid ".xdxf"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1055
+msgid "/path"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1074
+msgid "ws_ni_dictionaries_activation_question"
+msgstr "Czy chcesz zacząć używać ten słownik już teraz?"
+
+#: ../gui/src/ws_gui_layout.c:1106
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1131
+msgid "ws_ni_dictionary_added"
+msgstr "Nowy słownik został dodany."
+
+#: ../gui/src/ws_gui_layout.c:1138
+msgid "ws_ni_dictionary_wrong_file"
+msgstr "Zły plik słownika."
+
+#: ../gui/src/ws_gui_layout.c:1189
+msgid "ws_ti_remove_dictionaries_title"
+msgstr "Usuń słowniki"
+
+#: ../gui/src/ws_gui_layout.c:1226
+msgid "bookmarks"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1239
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr "usuń zaznaczone"
+
+#: ../gui/src/ws_gui_layout.c:1305
+msgid "ws_ti_about_title"
+msgstr "O Programie ..."
+
+#: ../gui/src/ws_gui_layout.c:1315
+msgid "/usr/share/pixmaps/whitestork.png"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1319
+msgid "Tahoma 18"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1321
+msgid "__________"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1324
+msgid ""
+"Maemo Multilingual Dictionary\n"
+"ver. "
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1333
+msgid ""
+"Copyright 2006, ComArch S.A\n"
+"All rightsreserved"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1355
+msgid "Tahoma 10"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1363
+msgid ""
+"The following third party\n"
+"components may be\n"
+"included depending \n"
+"on your system configuration:\n"
+"\n"
+"D-BUS - License information:\n"
+"http://opensource.org/licenses/academic.php"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1401
+msgid "ws_ti_add_bookmark"
+msgstr "Dodaj do zakładek"
+
+#: ../gui/src/ws_gui_layout.c:1413
+msgid "ws_ti_bookmarks_add_question"
+msgstr "Dodać do zakładek?"
+
+#: ../gui/src/ws_gui_layout.c:1437
+msgid ""
+"\n"
+".::GUI::. Bookmark added, happy days! :D\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1444
+msgid ""
+"\n"
+".::GUI::. Sorry ;-("
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr "Zakładka została dodana"
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr "Zakładka nie mogła być dodana"
+
+
+#: ../gui/src/ws_gui_layout.c:1462
+msgid "ws_ti_remove_bookmark"
+msgstr "Usuń zakładkę"
+
+#: ../gui/src/ws_gui_layout.c:1474
+msgid "ws_ni_remove_bookmark_question"
+msgstr "Usunąć z zakładek?"
+
+#: ../gui/src/ws_gui_layout.c:1498
+msgid ""
+"\n"
+".::GUI::. Bookmark removed, well done! :D\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1504
+msgid ""
+"\n"
+".::GUI::. Sorry\n"
+msgstr ""
+
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr "Zakładkę usunieto."
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr "Zakładka nie mogła zostać usunięta"
+
+#: ../gui/src/ws_gui_callbacks.c:44
+#, c-format
+msgid "XDXF->%s() start counting time for function '%s()'.\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:74
+#, c-format
+msgid "XDXF->%s() function '%s()' was working for: %g [s] or %ld [us].\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr "Wystąpił błąd."
+
+#: ../gui/src/ws_gui_callbacks.c:119
+msgid "response"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr "Brak dostępnych słowników."
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr "Optymalizacja ..."
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr "Słownik niedostępny."
+
+#: ../gui/src/ws_gui_callbacks.c:289
+msgid "ws_ni_no_words_found"
+msgstr "Nie znaleziono słów."
+
+#: ../gui/src/ws_gui_callbacks.c:758
+msgid "Name"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:760
+msgid "text"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:857 ../gui/src/ws_gui_callbacks.c:909
+#: ../gui/src/ws_gui_callbacks.c:915 ../gui/src/ws_gui_callbacks.c:960
+msgid "prefix"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:867
+msgid "ws_ni_no_text_selected"
+msgstr "Zaznacz tekst."
+
+#: ../gui/src/ws_gui_callbacks.c:913
+msgid "\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:970
+msgid "ws_ab_searching"
+msgstr "Wyszukiwanie ..."
+
+#: ../gui/src/ws_gui_callbacks.c:987
+msgid "ws_ni_no_word_typed"
+msgstr "Nie wpisano słowa."
+
+#: ../gui/src/ws_gui_callbacks.c:1008
+msgid "ws_ni_search_aborted"
+msgstr "Wyszukiwanie zostało przerwane."
+
+#: ../gui/src/ws_gui_callbacks.c:1112
+msgid "file:"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1160
+msgid "button-press-event"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1268 ../gui/src/ws_gui_callbacks.c:1270
+#: ../gui/src/ws_gui_callbacks.c:1283
+msgid "<PATTERN_OPEN>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1277
+msgid ""
+"<html><head></head><body><center><table width=\"95%\"><tr><td><table "
+"border=1 width=100%><tr><th background=\"file:/usr/share/pixmaps/ws_top.png"
+"\"><img align=left src=\"file:/usr/share/pixmaps/engine_xdxf_icon.png"
+"\"><font color=\"#eeeeee\">"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1289 ../gui/src/ws_gui_callbacks.c:1291
+#: ../gui/src/ws_gui_callbacks.c:1299
+msgid "<PATTERN_CLOSED>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1297
+msgid "</font></th></tr></table>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1305 ../gui/src/ws_gui_callbacks.c:1307
+#: ../gui/src/ws_gui_callbacks.c:1316
+msgid "<TRANSLATION_OPEN>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1313
+msgid ""
+"<table border=1 width=100%><tr><td background=\"file:/usr/share/pixmaps/"
+"ws_tra.png\">"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1322 ../gui/src/ws_gui_callbacks.c:1324
+#: ../gui/src/ws_gui_callbacks.c:1332
+msgid "<TRANSLATION_CLOSED>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1330
+msgid "</td></tr></table></center><br>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1339
+msgid "</td></tr></table></body></html>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1341
+#, c-format
+msgid ".::GUI::. Zawartosc stringa to: \"%s\""
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1345
+#, c-format
+msgid ".::GUI::. Zawartosc RAW to: \"%s\""
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1362 ../gui/src/ws_gui_callbacks.c:1384
+msgid "/bookmarks"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1362 ../gui/src/ws_gui_callbacks.c:1384
+msgid "active"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1366
+msgid ""
+"\n"
+".::GUI::. Bookmark mode on\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1388
+msgid ""
+"\n"
+".::GUI::. Bookmark mode off\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1402 ../gui/src/ws_gui_callbacks.c:1426
+#, c-format
+msgid ".::GUI::. LAST_WORD: \"%s\""
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1412
+msgid "ws_ni_select_word_to_add"
+msgstr "Wybierz słowo do dodania."
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+msgid "ws_ni_select_word_to_remove"
+msgstr "Wybierz słowo do usunięcia."
diff --git a/po/pl_Pl.po b/po/pl_Pl.po
new file mode 100644 (file)
index 0000000..e937d8f
--- /dev/null
@@ -0,0 +1,288 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+
+msgid ""
+msgstr ""
+"Project-Id-Version: 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-10-20 12:32+0200\n"
+"PO-Revision-Date: 2006-10-21 12:50+0200\n"
+"Last-Translator: Ania Gadomska <gandzia@vp.pl>\n"
+"Language-Team: polish <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui_layout.c:57 ../gui/src/ws_gui_layout.c:1225
+msgid "WhiteStork"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:105 ../gui/src/ws_gui_layout.c:1232
+#: ../gui/src/ws_gui_layout.c:1238
+msgid "Tahoma 12"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:109
+msgid "url_requested"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:159
+msgid "Find: "
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:249
+msgid "Dictionaries"
+msgstr "Słowniki"
+
+#: ../gui/src/ws_gui_layout.c:251 ../gui/src/ws_gui_layout.c:529
+msgid "Edit"
+msgstr "Edycja"
+
+#: ../gui/src/ws_gui_layout.c:253
+msgid "View"
+msgstr "Widok"
+
+#: ../gui/src/ws_gui_layout.c:255 ../gui/src/ws_gui_layout.c:492
+msgid "Search"
+msgstr "Szukaj"
+
+#: ../gui/src/ws_gui_layout.c:257
+msgid "About..."
+msgstr "O programie..."
+
+#: ../gui/src/ws_gui_layout.c:259
+msgid "Close"
+msgstr "Zamknij"
+
+#: ../gui/src/ws_gui_layout.c:266 ../gui/src/ws_gui_layout.c:938
+msgid "Load dictionary"
+msgstr "Ładuj słowniki"
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "Select dictionaries ..."
+msgstr "Wybierz sowniki ..."
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "Remove dictionaries ..."
+msgstr "Usuń słowniki ..."
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "Optimize dictionaries ..."
+msgstr "Zopytmalizuj słwoniki ..."
+
+#: ../gui/src/ws_gui_layout.c:288 ../gui/src/ws_gui_layout.c:512
+msgid "Copy"
+msgstr "Kopiuj"
+
+#: ../gui/src/ws_gui_layout.c:290 ../gui/src/ws_gui_layout.c:517
+msgid "Paste"
+msgstr "Wklej"
+
+#: ../gui/src/ws_gui_layout.c:292 ../gui/src/ws_gui_layout.c:522
+msgid "Select All"
+msgstr "Zaznacz wszystko"
+
+#: ../gui/src/ws_gui_layout.c:301
+msgid "Hide words list"
+msgstr "Ukryj liste"
+
+#: ../gui/src/ws_gui_layout.c:303 ../gui/src/ws_gui_layout.c:537
+msgid "Zoom in"
+msgstr "Powiększ"
+
+#: ../gui/src/ws_gui_layout.c:305 ../gui/src/ws_gui_layout.c:542
+msgid "Zoom out"
+msgstr "Pomniejsz"
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "Full screen"
+msgstr "Pełen ekran"
+
+#: ../gui/src/ws_gui_layout.c:318
+msgid "Find"
+msgstr "Znajdź"
+
+#: ../gui/src/ws_gui_layout.c:320
+msgid "Find next"
+msgstr "Znajdź nastepne"
+
+#: ../gui/src/ws_gui_layout.c:322
+msgid "Find previous"
+msgstr "Znajdź poprzednie"
+
+#: ../gui/src/ws_gui_layout.c:324
+msgid "Stop"
+msgstr "Stop"
+
+#: ../gui/src/ws_gui_layout.c:639 ../gui/src/ws_gui_layout.c:790
+#: ../gui/src/ws_gui_layout.c:1100
+msgid ""
+"\n"
+".::GUI::. /apps/WhiteStork/Dictionaries does not exist!!"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:643 ../gui/src/ws_gui_layout.c:824
+msgid "Choose dictionaries"
+msgstr "Wybierz słowniki"
+
+#: ../gui/src/ws_gui_layout.c:692 ../gui/src/ws_gui_layout.c:859
+#: ../gui/src/ws_gui_layout.c:1143
+msgid "cancel"
+msgstr "anuluj"
+
+#: ../gui/src/ws_gui_layout.c:698 ../gui/src/ws_gui_layout.c:864
+msgid "ok"
+msgstr "ok"
+
+#: ../gui/src/ws_gui_layout.c:812
+msgid "There are no dictionaries to optimize"
+msgstr "Brak sowników do zoptymalizowania"
+
+#: ../gui/src/ws_gui_layout.c:990
+msgid "Would you like to activate this dictionary for use from now?"
+msgstr "Czy chcesz teraz aktywować słownik?"
+
+#: ../gui/src/ws_gui_layout.c:1021
+msgid ""
+"Would you like to optimize this dictionary to make it faster to search "
+"within?"
+msgstr "Czy chcesz zoptymalizować słownik teraz?"
+
+#: ../gui/src/ws_gui_layout.c:1045
+msgid "New dictionary has been added"
+msgstr "Nowy sownik został dodany"
+
+#: ../gui/src/ws_gui_layout.c:1052
+msgid "Wrong dictionary file"
+msgstr "Zły format sownika"
+
+#: ../gui/src/ws_gui_layout.c:1104
+msgid "Remove dictionaries"
+msgstr "Usuń słownik"
+
+#: ../gui/src/ws_gui_layout.c:1149
+msgid "remove selected"
+msgstr "Usuń zaznaczone"
+
+#: ../gui/src/ws_gui_layout.c:1212
+msgid "About"
+msgstr "O programie"
+
+#: ../gui/src/ws_gui_layout.c:1231
+msgid ""
+"Maemo Multilingual Dictionary\n"
+"ver. 0.5"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1237
+msgid ""
+"Copyright 2006, ComArch S.A\n"
+"All rights reserved"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1266
+msgid ""
+"The following third party\n"
+"components may be\n"
+"included depending \n"
+"on your system configuration:\n"
+"\n"
+"D-BUS - License information:\n"
+"http://opensource.org/licenses/academic.php"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1303
+msgid "Licence"
+msgstr "Licencja"
+
+#: ../gui/src/ws_gui_layout.c:1323
+msgid ""
+"Terms of use\n"
+"\n"
+"READ THE TERMS OF USE CAREFULLY BEFORE INSTALALTION OF THIS SOFTWARE. BY\n"
+"INSTALALTION OF THIS SOFTWARE, YOU AGREE TO THE FOLLOWING TERMS OF USE.\n"
+"\n"
+"1. LICENSE TO USE. ComArch grants you a non-exclusive and non-transferable\n"
+"license for the internal use only of the accompanying software and\n"
+"documentation and any error corrections provided by ComArch (collectively "
+"\"Software\"), by the one user.\n"
+"\n"
+"2. RESTRICTIONS. Software is confidential and copyrighted. Title to "
+"Software\n"
+"and all associated intellectual property rights is retained by ComArch\n"
+"and/or its licensors. Unless enforcement is prohibited by applicable law,\n"
+"you may not modify, decompile, or reverse engineer Software. You "
+"acknowledge\n"
+"that Software is not designed, licensed or intended for use in the design,\n"
+"construction, operation or maintenance of any nuclear facility. Sun ComArch\n"
+"disclaims any express or implied warranty of fitness for such uses. No\n"
+"right, title or interest in or to any trademark, service mark, logo or "
+"trade\n"
+"name of ComArch or its licensors is granted under this terms of use.\n"
+"\n"
+"3. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT TERMS OF USE,\n"
+"ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, "
+"INCLUDING\n"
+"ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE "
+"OR\n"
+"NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE "
+"DISCLAIMERS\n"
+"ARE HELD TO BE LEGALLY INVALID.\n"
+"\n"
+"4. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO "
+"EVENT\n"
+"WILL COMARCH OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR\n"
+"DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE\n"
+"DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT\n"
+"OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF COMARCH\n"
+"HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will\n"
+"ComArch's liability to you, whether in contract, tort (including\n"
+"negligence), or otherwise, exceed []. The foregoing limitations will apply\n"
+"even if the above stated warranty fails of its essential purpose.\n"
+"\n"
+"5. Termination. This license is effective until terminated. You may\n"
+"terminate this license at any time by destroying all\n"
+"copies of Software.\n"
+"This license will terminate immediately without notice from ComArch if you\n"
+"fail to comply with any provision of this license. Upon Termination, you\n"
+"must destroy all copies of Software.\n"
+"\n"
+"6. Export Regulations. All Software and technical data delivered under this\n"
+"terms of use are subject to Polish export control laws and may be subject "
+"to\n"
+"export or import regulations in other countries. You agree to comply\n"
+"strictly with all such laws and regulations and acknowledge that you have\n"
+"the responsibility to obtain such licenses to export, re-export, or import\n"
+"as may be required after delivery to you.\n"
+"\n"
+"7. Governing Law. Any action related to this license will be governed by\n"
+"Polish Law.\n"
+"\n"
+"8. Severability. If any provision of this terms of use is held to be\n"
+"unenforceable, this terms of use will remain in effect with the provision\n"
+"omitted, unless omission would frustrate the intent of the parties, in "
+"which\n"
+"case this terms of use will immediately terminate.\n"
+"\n"
+"9. Integration. This document is the entire  agreement between you and\n"
+"ComArch relating to its subject matter. It supersedes all prior or\n"
+"contemporaneous oral or written communications, proposals, representations\n"
+"and warranties and prevails over any conflicting or additional\n"
+"terms of any\n"
+"quote, order, acknowledgment, or other communication between the parties\n"
+"relating to its subject matter during the term of these terms of use. No\n"
+"modification of this Agreement will be binding, unless in writing and "
+"signed\n"
+"by an authorized representative of each party."
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1325
+msgid "Agree"
+msgstr "Zgadzam się"
+
+#: ../gui/src/ws_gui_layout.c:1330
+msgid "Disagree"
+msgstr "Nie zgadzam się"
diff --git a/po/template.po b/po/template.po
new file mode 100644 (file)
index 0000000..0cbf6ea
--- /dev/null
@@ -0,0 +1,534 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-28 11:49+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../gui/src/ws_gui_layout.c:43
+msgid "ws_ni_welcome"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:46 ../gui/src/ws_gui_callbacks.c:143
+#: ../gui/src/ws_gui_callbacks.c:855 ../gui/src/ws_gui_callbacks.c:981
+msgid " "
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:64 ../gui/src/ws_gui_layout.c:1324
+msgid "WhiteStork"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:112 ../gui/src/ws_gui_layout.c:1334
+#: ../gui/src/ws_gui_layout.c:1341
+msgid "Tahoma 12"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:117
+msgid "url_requested"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:174 ../gui/src/ws_gui_layout.c:351
+msgid "ws_me_search_find"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:212
+msgid "search"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:217
+msgid "toggled"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:222 ../gui/src/ws_gui_layout.c:227
+#: ../gui/src/ws_gui_layout.c:231
+msgid "clicked"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:266
+msgid "ws_me_dictionaries"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:268
+msgid "ws_me_bookmarks"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:270
+msgid "ws_me_edit"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:272
+msgid "ws_me_view"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:274
+msgid "ws_me_search"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:276
+msgid "ws_me_about"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:278
+msgid "ws_me_close"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:285
+msgid "ws_me_dictionaries_load"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:287
+msgid "ws_me_dictionaries_select"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:289
+msgid "ws_me_dictionaries_remove"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:291
+msgid "ws_me_dictionaries_optimize"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:303
+msgid "ws_me_bookmarks_open"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:305
+msgid "ws_me_bookmarks_close"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:307
+msgid "ws_me_bookmarks_add"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:309
+msgid "ws_me_bookmarks_remove"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:321
+msgid "ws_me_edit_copy"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:323
+msgid "ws_me_edit_paste"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:325
+msgid "ws_me_edit_select_all"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:334
+msgid "ws_me_view_hide_words_list"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:336
+msgid "ws_me_view_zoom_in"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:338
+msgid "ws_me_view_zoom_out"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:340
+msgid "ws_me_view_fullscreen"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:353
+msgid "ws_me_search_find_next"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:355
+msgid "ws_me_search_find_prev"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:357
+msgid "ws_me_search_stop"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:410 ../gui/src/ws_gui_layout.c:415
+#: ../gui/src/ws_gui_layout.c:420 ../gui/src/ws_gui_layout.c:425
+#: ../gui/src/ws_gui_layout.c:429 ../gui/src/ws_gui_layout.c:434
+#: ../gui/src/ws_gui_layout.c:439 ../gui/src/ws_gui_layout.c:444
+#: ../gui/src/ws_gui_layout.c:449 ../gui/src/ws_gui_layout.c:454
+#: ../gui/src/ws_gui_layout.c:459 ../gui/src/ws_gui_layout.c:464
+#: ../gui/src/ws_gui_layout.c:469 ../gui/src/ws_gui_layout.c:474
+#: ../gui/src/ws_gui_layout.c:479 ../gui/src/ws_gui_layout.c:484
+#: ../gui/src/ws_gui_layout.c:489 ../gui/src/ws_gui_layout.c:494
+#: ../gui/src/ws_gui_layout.c:499 ../gui/src/ws_gui_layout.c:504
+#: ../gui/src/ws_gui_layout.c:509 ../gui/src/ws_gui_layout.c:515
+#: ../gui/src/ws_gui_layout.c:521 ../gui/src/ws_gui_layout.c:621
+#: ../gui/src/ws_gui_layout.c:626 ../gui/src/ws_gui_layout.c:631
+#: ../gui/src/ws_gui_layout.c:636 ../gui/src/ws_gui_layout.c:641
+#: ../gui/src/ws_gui_layout.c:645
+msgid "activate"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:560
+msgid "ws_mp_search"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:580
+msgid "ws_mp_edit_copy"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:585
+msgid "ws_mp_edit_paste"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:590
+msgid "ws_mp_edit_select_all"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:597
+msgid "ws_mp_edit"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:605
+msgid "ws_mp_zoom_in"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:610
+msgid "ws_mp_zoom_out"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:708 ../gui/src/ws_gui_layout.c:869
+#: ../gui/src/ws_gui_layout.c:1188
+msgid ""
+"\n"
+".::GUI::. /apps/WhiteStork/Dictionaries does not exist!!"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:713 ../gui/src/ws_gui_layout.c:905
+msgid "ws_ti_choose_dictionaries_title"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:742 ../gui/src/ws_gui_layout.c:795
+#: ../gui/src/ws_gui_layout.c:812 ../gui/src/ws_gui_layout.c:1066
+#: ../gui/src/ws_gui_callbacks.c:1519 ../gui/src/ws_gui_callbacks.c:1555
+#: ../gui/src/ws_gui_callbacks.c:1601
+msgid "/active"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:768 ../gui/src/ws_gui_layout.c:942
+#: ../gui/src/ws_gui_layout.c:1237 ../gui/src/ws_gui_layout.c:1433
+#: ../gui/src/ws_gui_layout.c:1501
+msgid "ws_db_cancel"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:774 ../gui/src/ws_gui_layout.c:947
+#: ../gui/src/ws_gui_layout.c:1428 ../gui/src/ws_gui_layout.c:1496
+msgid "ws_db_ok"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:793 ../gui/src/ws_gui_layout.c:810
+#: ../gui/src/ws_gui_layout.c:967 ../gui/src/ws_gui_layout.c:987
+#: ../gui/src/ws_gui_layout.c:1056 ../gui/src/ws_gui_layout.c:1064
+#: ../gui/src/ws_gui_layout.c:1099 ../gui/src/ws_gui_layout.c:1262
+msgid "/"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:877 ../gui/src/ws_gui_layout.c:969
+#: ../gui/src/ws_gui_layout.c:989 ../gui/src/ws_gui_layout.c:1101
+msgid "/optimized"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:893
+msgid "ws_ni_no_dictionaries_to_optimize"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1023
+msgid "ws_ti_load_dictionary_title"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1052
+msgid ".xdxf"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1056
+msgid "/path"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1075
+msgid "ws_ni_dictionaries_activation_question"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1108
+msgid "ws_ni_dictionaries_optimalization_question"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1133
+msgid "ws_ni_dictionary_added"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1140
+msgid "ws_ni_dictionary_wrong_file"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1193
+msgid "ws_ti_remove_dictionaries_title"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1230 ../gui/src/ws_gui_callbacks.c:1522
+#: ../gui/src/ws_gui_callbacks.c:1558
+msgid "bookmarks"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1244
+msgid "ws_bd_remove_dictionaries_remove_selected"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1311
+msgid "ws_ti_about_title"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1321
+msgid "/usr/share/pixmaps/whitestork.png"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1325
+msgid "Tahoma 18"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1327
+msgid "__________"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1330
+msgid ""
+"Maemo Multilingual Dictionary\n"
+"ver. "
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1339
+msgid ""
+"Copyright 2006, ComArch S.A\n"
+"All rightsreserved"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1361
+msgid "Tahoma 10"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1369
+msgid ""
+"The following third party\n"
+"components may be\n"
+"included depending \n"
+"on your system configuration:\n"
+"\n"
+"D-BUS - License information:\n"
+"http://opensource.org/licenses/academic.php"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1407
+msgid "ws_ti_add_bookmark"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1419
+msgid "ws_ti_bookmarks_add_question"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1449
+msgid "ws_ni_bookmark_added"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1457
+msgid "ws_ni_bookmark_not_added"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1475
+msgid "ws_ti_remove_bookmark"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1487
+msgid "ws_ni_remove_bookmark_question"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1515
+msgid "ws_ni_bookmark_removed"
+msgstr ""
+
+#: ../gui/src/ws_gui_layout.c:1522
+msgid "ws_ni_bookmark_not_removed"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:44
+#, c-format
+msgid "XDXF->%s() start counting time for function '%s()'.\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:74
+#, c-format
+msgid "XDXF->%s() function '%s()' was working for: %g [s] or %ld [us].\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:114
+msgid "ws_ni_error_occured"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:119
+msgid "response"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:133
+msgid "ws_ni_no_dictionary_available"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:168
+msgid "ws_pb_caching"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:212
+msgid "ws_ni_dictionary_unavailable"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:289
+msgid "ws_ni_no_words_found"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:759
+msgid "Name"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:761
+msgid "text"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:858 ../gui/src/ws_gui_callbacks.c:910
+#: ../gui/src/ws_gui_callbacks.c:916 ../gui/src/ws_gui_callbacks.c:961
+msgid "prefix"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:868
+msgid "ws_ni_no_text_selected"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:914
+msgid "\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:971
+msgid "ws_ab_searching"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:988
+msgid "ws_ni_no_word_typed"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1009
+msgid "ws_ni_search_aborted"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1113
+msgid "file:"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1161
+msgid "button-press-event"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1269 ../gui/src/ws_gui_callbacks.c:1271
+#: ../gui/src/ws_gui_callbacks.c:1284
+msgid "<PATTERN_OPEN>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1278
+msgid ""
+"<html><head></head><body><center><table width=\"95%\"><tr><td><table "
+"border=1 width=100%><tr><th background=\"file:/usr/share/pixmaps/ws_top.png"
+"\"><img align=left src=\"file:/usr/share/pixmaps/engine_xdxf_icon.png"
+"\"><font color=\"#eeeeee\">"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1290 ../gui/src/ws_gui_callbacks.c:1292
+#: ../gui/src/ws_gui_callbacks.c:1300
+msgid "<PATTERN_CLOSED>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1298
+msgid "</font></th></tr></table>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1306 ../gui/src/ws_gui_callbacks.c:1308
+#: ../gui/src/ws_gui_callbacks.c:1317
+msgid "<TRANSLATION_OPEN>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1314
+msgid ""
+"<table border=1 width=100%><tr><td background=\"file:/usr/share/pixmaps/"
+"ws_tra.png\">"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1323 ../gui/src/ws_gui_callbacks.c:1325
+#: ../gui/src/ws_gui_callbacks.c:1333
+msgid "<TRANSLATION_CLOSED>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1331
+msgid "</td></tr></table></center><br>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1340
+msgid "</td></tr></table></body></html>"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1369
+msgid ""
+"\n"
+".::GUI::. Bookmark mode on\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1394
+msgid ""
+"\n"
+".::GUI::. Bookmark mode off\n"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1422
+msgid "ws_ni_select_word_to_add"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1436
+#, c-format
+msgid ".::GUI::. LAST_WORD: \"%s\""
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1446
+msgid "ws_ni_select_word_to_remove"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1521 ../gui/src/ws_gui_callbacks.c:1557
+#, c-format
+msgid ""
+"\n"
+"\n"
+"slownik (%d): %s - active: %d"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1530 ../gui/src/ws_gui_callbacks.c:1566
+#, c-format
+msgid ""
+"\n"
+"\n"
+"Po przestawieniu: slownik (%d): %s - active: %d"
+msgstr ""
+
+#: ../gui/src/ws_gui_callbacks.c:1603
+#, c-format
+msgid ""
+"\n"
+"\n"
+"slownik (%d): %s - \n"
+"active: %d"
+msgstr ""
diff --git a/po/whitestork.mo b/po/whitestork.mo
new file mode 100644 (file)
index 0000000..17b8b35
Binary files /dev/null and b/po/whitestork.mo differ
diff --git a/src/bookmarks/bdb/COPYING b/src/bookmarks/bdb/COPYING
new file mode 100755 (executable)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/bookmarks/bdb/Makefile b/src/bookmarks/bdb/Makefile
new file mode 100755 (executable)
index 0000000..497fc84
--- /dev/null
@@ -0,0 +1,71 @@
+COMPILER = gcc
+#DEBUG = -Wall -g -DNOLOGS
+DEBUG = -Wall -g
+SOURCES = ./src
+INCLUDE = ./include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0` -ldb1
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0` -I${INCLUDE} -I./.. -I../../../include
+BINARIES = bin
+FINAL = ws_bookmark.so
+
+first: clean ${FINAL} bdbprint
+
+show1:
+               ./bdbprint s data/bm_words.db
+       
+show2:
+               ./bdbprint b data/bm_trans.db
+               
+bdbprint: ${SOURCES}/berkeleyRead.c
+               @echo -en "Berkeley DB reader building ...\n"
+               gcc ${DEBUG} `pkg-config --cflags --libs glib-2.0` -ldb1 $< -o $@
+
+${FINAL}: bookmark.o ${SOURCES}/engine_bookmark.c
+               gcc ${DEBUG} -shared -fPIC ${FLAGS} ${LIBS} bookmark.o -o ${FINAL}
+               cp ${FINAL} ../../../bin
+
+bookmark.o: ${SOURCES}/engine_bookmark.c
+               gcc ${DEBUG} -c -fPIC -o bookmark.o ${SOURCES}/engine_bookmark.c ${FLAGS}
+               
+clean:
+               @-rm -f ${BINARIES}/*
+               @-rm -f ${SOURCES}/test
+               @-rm -f ${SOURCES}/*~
+               @-rm -f *~
+               @-rm -f ${INCLUDE}/*~
+               @-rm -f ${SOURCES}/${FINAL}
+               @-rm -f ${SOURCES}/testDatabase
+               @-rm -f ws_bookmark.so bookmark.o bdbprint
+               @echo -e -n "Project 'BookmarkEngine' directories has been cleaned.\n"
+
+
+       
+cleandata: bdbprint
+               @-rm -f ws_bookmarks-journal
+               @-rm -f ws_bookmarks
+               @-rm -f data/bm_words.db data/bm_trans.db
+               @./bdbprint s data/bm_words.db
+               @./bdbprint b data/bm_trans.db add 0 1
+
+
+data: ${SOURCES}/testMakeDatabase.c
+               @echo -e -n "Compiling testDatabase...\n"
+               @gcc ${DEBUG} -o ${SOURCES}/testDatabase ${SOURCES}/testMakeDatabase.c ${FLAGS} ${LIBS}
+
+datarun: data
+               @run-standalone.sh src/testDatabase     
+       
+test: test.o
+               @echo "Linking test program..."
+               @gcc ${LIBS} ${DEBUG} -o ${SOURCES}/test ${BINARIES}/test.o
+               @echo -e "Building test program finished.\n"
+
+test.o:
+               @echo "Compiling test program..."
+               @gcc ${FLAGS} ${DEBUG} -c -o ${BINARIES}/test.o ${SOURCES}/test.c
+
+check:
+               @echo "Running test program:"
+               @run-standalone.sh  ${SOURCES}/test     
+       
+       
\ No newline at end of file
diff --git a/src/bookmarks/bdb/data/bm_trans.db b/src/bookmarks/bdb/data/bm_trans.db
new file mode 100755 (executable)
index 0000000..7abe57a
Binary files /dev/null and b/src/bookmarks/bdb/data/bm_trans.db differ
diff --git a/src/bookmarks/bdb/data/bm_words.db b/src/bookmarks/bdb/data/bm_words.db
new file mode 100755 (executable)
index 0000000..d7d2019
Binary files /dev/null and b/src/bookmarks/bdb/data/bm_words.db differ
diff --git a/src/bookmarks/bdb/include/.kateconfig b/src/bookmarks/bdb/include/.kateconfig
new file mode 100755 (executable)
index 0000000..7f9ed54
--- /dev/null
@@ -0,0 +1 @@
+kate hl Sources/C;
\ No newline at end of file
diff --git a/src/bookmarks/bdb/include/engine_bookmark.h b/src/bookmarks/bdb/include/engine_bookmark.h
new file mode 100755 (executable)
index 0000000..a4c7ea2
--- /dev/null
@@ -0,0 +1,238 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY_ENGINE_BOOKMARK
+#define _DICTIONARY_ENGINE_BOOKMARK
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - only for timers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>     
+#include <unistd.h>   
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header wit engine API
+#include "dictionary_engine.h"
+//------------------------------------------------------------------------------
+// header wit sqlite 2.x API
+#include <db/db.h>
+//------------------------------------------------------------------------------
+#include <string.h>
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+static const gchar* DIC_ENG_VERSION = "0.2";
+static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
+static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' "
+                                          "bookmarks. Based on Berkeley DB 1.85";
+                           
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _BookData {
+        DB*            db_words;
+       DB*             db_trans;
+        BTREEINFO      info_words;
+       BTREEINFO       info_trans;
+       guint           freeID;
+
+
+
+        gchar*                  dict_path;
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _BookData        BookData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+//static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// convert string to proper path name (no filename, no "/" at the ned, file
+// exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// tells if file is in Bookark Berkeley DB format (file should exist)
+static gboolean        is_Bookmark_db_file(gchar* file); 
+//------------------------------------------------------------------------------
+// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+static double           bm_timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+// create and add new entry to databases
+static gboolean        bm_add_new_entry(gchar* word,
+                                        gchar* translation,
+                                        BookData* data);
+//------------------------------------------------------------------------------
+// load current minimal available free ID fortranslations
+static void bm_load_freeID(BookData* data);
+//------------------------------------------------------------------------------
+// save current minimal available free ID fortranslations
+static void bm_save_freeID(BookData* data);
+//------------------------------------------------------------------------------
+// save translation in database under id
+static gboolean bm_add_only_translation(BookData* data,
+                                       gchar* translation,
+                                       guint id);
+//------------------------------------------------------------------------------
+static gint bm_compare_key_trans(const DBT *a, const DBT *b);
+static gint bm_compare_key_words(const DBT *a, const DBT *b);
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+gboolean        bm_engine_add_word(Engine* engine,
+                                 gchar*  word,
+                                 gchar*  translation);
+//------------------------------------------------------------------------------
+gboolean        bm_engine_remove_word(Engine* engine,
+                                     gchar*  word);  
+//------------------------------------------------------------------------------      
+gchar*          bm_engine_get_lang_from(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_lang_to(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_title(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_icon_path(Engine* engine);
+
+
+
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        bm_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          bm_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          bm_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          bm_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         bm_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            bm_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          bm_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            bm_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        bm_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            bm_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        bm_engine_set_callback(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            bm_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            bm_engine_search_word_list(Engine* engine,
+                                           gchar* pattern,
+                                           gpointer data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            bm_engine_search_word_translation(Engine* engine,
+                                                  gchar* word,
+                                                  gpointer data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    bm_engine_status(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          bm_engine_status_message(EngineStatus error);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
diff --git a/src/bookmarks/bdb/src/.kateconfig b/src/bookmarks/bdb/src/.kateconfig
new file mode 100755 (executable)
index 0000000..7f9ed54
--- /dev/null
@@ -0,0 +1 @@
+kate hl Sources/C;
\ No newline at end of file
diff --git a/src/bookmarks/bdb/src/berkeleyRead.c b/src/bookmarks/bdb/src/berkeleyRead.c
new file mode 100644 (file)
index 0000000..5145db5
--- /dev/null
@@ -0,0 +1,504 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <db/db.h>
+#include <string.h>
+#include <glib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+
+typedef unsigned int uint;
+
+static int bm_compare_key_trans(const DBT *a, const DBT *b) {
+       uint* tmpa = (uint*)(a->data);
+       uint* tmpb = (uint*)(b->data);
+
+       if((*tmpa) == (*tmpb)) return 0;
+       if(*tmpa > *tmpb)  return 1;
+       else               return -1;
+}
+//------------------------------------------------------------------------------
+static int bm_compare_key_words(const DBT *a, const DBT *b) {
+       char* tmpa = g_utf8_casefold((char*)(a->data),-1);
+       char* tmpb = g_utf8_casefold((char*)(b->data),-1);
+       int result = g_utf8_collate(tmpa,tmpb);
+       g_free(tmpa);
+       g_free(tmpb);
+       return result;
+}
+
+//------------------------------------------------------------------------------
+int read_berkeley_in_string_mode(DB* dbp) {
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+
+       int result = dbp->seq(dbp, &key, &val, R_FIRST);
+       uint count = 1;
+       uint a = 0;
+       uint b = 0;
+       uint c = 0;
+       uint i = 0;
+       uint* t = NULL;
+       while(1 != result) {
+               if(-1 == result) {
+                       printf("---Error! While sequentiall reading database\n");
+                       return 10;
+               };
+               memcpy(&a, val.data, sizeof(uint));
+               t = (uint*)(val.data + sizeof(uint));
+               printf("%4d. word = %-30s [%-2d record(s)] => \n",count, (char*)(key.data), a);
+
+               for(i=0; i < a; ++i) {
+                       b = t[i*2];
+                       c = t[i*2 + 1];
+                       printf("\t%4u.%u. ID = %u [hash = %#x]\n",count,i+1,b,c);
+               }
+               
+               result = dbp->seq(dbp, &key, &val, R_NEXT);
+               ++count;
+       }
+       return 0;
+}
+//------------------------------------------------------------------------------
+int read_berkeley_in_binary_mode(DB* dbp) {
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+
+       uint count = 1;
+       uint a = 0;
+       char* s = NULL;
+       int result = dbp->seq(dbp, &key, &val, R_FIRST);
+       while(1 != result) {
+               if(-1 == result) {
+                       printf("---Error! While sequentiall reading database\n");
+                       return 10;
+               };
+               memcpy(&a, key.data, sizeof(uint));
+               s = (char*) (val.data);
+               if(a == 0) {
+                       uint b = 0;
+                       memcpy(&b , val.data, sizeof(uint));
+                       printf("%4u. ID = %-4u value(freeID)=%u\n",count,a,b);
+               }
+               else {
+                       printf("%4u. ID = %-4u string=\'%s\'\n",count,a,s);
+               }
+
+               result = dbp->seq(dbp, &key, &val, R_NEXT);
+               ++count;
+       }
+       return 0;
+}
+//------------------------------------------------------------------------------
+int berkeley_del_record(DB* dbp,char mode,char* id) {
+       uint a;
+       DBT key = { NULL , 0 };
+       if('s' == mode) {
+               printf("Delete key: %s...",id);
+               key.data = id;
+               key.size = strlen(id) + 1;
+       }
+       else if('b' == mode) {
+               if(1 != sscanf(id,"%u",&a)) {
+                       printf("ID has wrong format - it should be unsigned int!\n");
+                       return 25;
+               };
+               printf("Deleting record with id=%u\n",a);
+               key.size = sizeof(uint);
+               key.data = &a;
+       }
+       else {
+               printf("not supported mode for delete action!\n");
+               return 24;
+       };
+
+       int result = dbp->del(dbp,&key,0);
+       if(1 == result) {
+               printf("... there was no such an element!\n");
+       }
+       else if(-1 == result) {
+               printf("---Error while deleteing record!\n");
+               return 29;
+       }
+       else {
+               printf("... record deleted!\n");
+       }
+
+       return 0;
+}
+//------------------------------------------------------------------------------
+int berkeley_fnd_record(DB* dbp,char mode,char* id) {
+       uint a = 0;
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+       if('s' == mode) {
+               printf("Searching for key: %s...\n",id);
+               key.data = id;
+               key.size = strlen(id) + 1;
+       }
+       else if('b'== mode) {
+               if(1 != sscanf(id,"%u",&a)) {
+                       printf("ID has wrong format - it should be unsigned int!\n");
+                       return 35;
+               };
+               printf("Searching for record with id=%u\n",a);
+               key.size = sizeof(uint);
+               key.data = &a;
+       }
+       else {
+               printf("not supported mode for find action!\n");
+               return 30;
+       };
+
+       int result = dbp->get(dbp,&key,&val,0);
+       if(1 == result) {
+               printf("... there was no such a record\n");
+       }
+       else if(-1 == result) {
+               printf("---Error while searching for the record!\n");
+               return 29;
+       }
+       else {
+               uint* t = NULL;
+               uint b = 0, c = 0, i = 0;
+               char* s = NULL;
+               switch(mode) {
+                       case 's':
+// ------------------------------
+       memcpy(&a, val.data, sizeof(uint));
+       t = (uint*)(val.data + sizeof(uint));
+       printf("Element word = %-30s [%-2d record(s)] => \n", (char*)(key.data), a);
+
+       for(i=0; i < a; ++i) {
+               b = t[i*2];
+               c = t[i*2 + 1];
+               printf("\t%2u. ID = %u [hash = %#xu]\n",i+1,b,c);
+       }
+                       break;
+// ------------------------------
+                       case 'b':
+// ------------------------------
+       s = (char*) (val.data);
+       if(a == 0) {
+               memcpy(&b , val.data, sizeof(uint));
+               printf("Element ID = %-4u value(freeID)=%u\n",a,b);
+       }
+       else {
+               printf("Element ID = %-4u string=\'%s\'\n",a,s);
+       }
+                       break;
+// ------------------------------
+                       default:
+                               printf("Not supported mode!\n");
+                               return 30;
+               }
+       }
+       return 0;
+}
+//------------------------------------------------------------------------------
+int berkeley_fnd_pattern_record(DB* dbp,char mode,char* id) {
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+
+       if('s' == mode) {
+               int result = dbp->seq(dbp, &key, &val, R_FIRST);
+               uint count = 1;
+               uint a = 0;
+               uint b = 0;
+               uint c = 0;
+               uint i = 0;
+               uint* t = NULL;
+               char* tmp = g_utf8_casefold(id,-1);
+               uint len = strlen(tmp);
+       printf("dlugosc: %u\n",len);
+               char* tmp2 = NULL;
+               while(1 != result) {
+                       if(-1 == result) {
+                               printf("---Error! While sequentiall reading database\n");
+                               return 10;
+                       };
+                       tmp2 = g_utf8_casefold((char*)(key.data),len);
+                       if(0 == g_utf8_collate(tmp2,tmp) || len == 0) {
+                               memcpy(&a, val.data, sizeof(uint));
+                               t = (uint*)(val.data + sizeof(uint));
+                               printf("%4d. word = %-30s [%-2d record(s)] => \n",count, (char*)(key.data), a);
+               
+                               for(i=0; i < a; ++i) {
+                                       b = t[i*2];
+                                       c = t[i*2 + 1];
+                                       printf("\t%4u.%u. ID = %u [hash = %#xu]\n",count,i+1,b,c);
+                               }
+                       }
+                       result = dbp->seq(dbp, &key, &val, R_NEXT);
+                       ++count;
+               }
+               free(tmp);
+               return 0;
+       }
+       else {
+               printf("Searching for pattern is not supported in binary mode!");
+               return 65;
+       }
+}
+//------------------------------------------------------------------------------
+int berkeley_del_pattern_record(DB* dbp,char mode,char *id) {
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+
+       if('s' == mode) {
+               int result = dbp->seq(dbp, &key, &val, R_FIRST);
+               uint count = 0;
+               uint a = 0;
+               uint b = 0;
+               uint c = 0;
+               uint i = 0;
+               uint* t = NULL;
+               char* tmp = g_utf8_casefold(id,-1);
+               uint len = strlen(tmp);
+               char* tmp2 = NULL;
+               while(1 != result) {
+                       if(-1 == result) {
+                               printf("---Error! While sequentiall reading database\n");
+                               return 10;
+                       };
+                       tmp2 = g_utf8_casefold((char*)(key.data),len);
+                       if(0 == g_utf8_collate(tmp2,tmp) || len == 0) {
+                               // delete actual record
+
+                               memcpy(&a, val.data, sizeof(uint));
+                               t = (uint*)(val.data + sizeof(uint));
+                               printf("Deleting record %4d. word = %-30s [%-2d record(s)] => \n",count, (char*)(key.data), a);
+               
+                               for(i=0; i < a; ++i) {
+                                       b = t[i*2];
+                                       c = t[i*2 + 1];
+                                       printf("\t%4u.%u. ID = %u [hash = %#xu]\n",count,i+1,b,c);
+                               }
+                               int result = dbp->del(dbp,&key,0);
+                               if(1 == result) {
+                                       printf("---Error find element but could not delete it!\n");
+                               }
+                               else if(-1 == result) {
+                                       printf("---Error while deleteing record!\n");
+                                       return 29;
+                               }
+                               else {
+                                       printf("... record deleted!\n");
+                               }
+                               count++;
+                       }
+                       free(tmp2); tmp2 = NULL;
+                       result = dbp->seq(dbp, &key, &val, R_NEXT);
+               }
+               printf("%u record were deleted totaly.\n",count);
+               free(tmp);
+               return 0;
+       }
+       else {
+               printf("Searching for pattern is not supported in binary mode!");
+               return 65;
+       }
+}
+//------------------------------------------------------------------------------
+int berkeley_add_record(DB* dbp,char mode,char* id, char* value) {
+       DBT key = { NULL , 0 };
+       DBT val = { NULL , 0 };
+       
+       int result = 0;
+       uint a = 0, i = 0, error = 0, b = 0, c = 0;
+       uint* t = NULL;
+       char* tmp = malloc(200);
+       char* tmp_original = tmp;
+       if('s' == mode) {
+               printf("Adding record with key = %s...\n",id);
+               key.data = id;
+               key.size = strlen(id) + 1;
+               while(1) {
+               if(2 != sscanf(value,"%u%[ 0-9]",&a,tmp)) {
+                       result = 43;
+                       break;
+               }
+               val.size = sizeof(uint) * (a*2 + 1);
+               t = (uint*)malloc( val.size );
+               t[0] = a;
+               for(i=0; i< a; ++i) {
+                       if(2 != sscanf(tmp,"%u%[ 0-9]",&b,tmp)) {
+                               error = 1;
+                               break;
+                       };
+                       t[1+i*2] = b;
+                       int n = sscanf(tmp,"%u%[ 0-9]",&b,tmp);
+                       if(( (2 != n) && (i!=(a-1)) ) || ((1!=n) && (i==(a-1)))) {
+                               error = 1;
+                               break;
+                       };
+                       t[1+i*2+1] = b;
+               }
+               if(error) {
+                       printf("Wrong value for string database!\n");
+                       result = 44;
+                       break;
+               }
+               val.data = t;
+               break ;}
+       }
+       else if('b'== mode) {
+               if(1 != sscanf(id,"%u",&a)) {
+                       printf("ID has wrong format - it should be unsigned int!\n");
+                       return 45;
+               };
+               printf("Adding record with id=%u\n",a);
+               key.size = sizeof(uint);
+               key.data = &a;
+               if(0 == a) {
+                       if(1 != sscanf(value,"%u",&c)) {
+                               printf("Value has wrong format for record with ID=0 (freeID - unsinged int)\n");
+                               return 46;
+                       };      
+                       val.size = key.size;
+                       val.data = &c;
+               }
+               else {
+                       val.size = strlen(value) + 1;
+                       val.data = value;
+               }
+       }
+       else {
+               printf("---Not supported mode for add action!\n");
+               return 40;
+       };
+       
+       if(0 != result) {
+               if(t) free(t);
+               free(tmp_original);
+               return result;
+       }
+       
+       result = dbp->put(dbp, &key, &val, R_NOOVERWRITE);
+       if(1 == result) {
+               printf("Such a key already exist in database!\n");
+               result = 41;
+       }
+       else if(-1 == result) {
+               printf("---Error while adding new record!\n");
+               result =  49;
+       }
+       else {
+               printf("New record has been added.\n");
+               if(-1 == dbp->sync(dbp, 0)) {
+                       printf("---Error while saving data to file! Record could be lost.\n");
+                       result = 48;
+               }
+       }
+       if(t) free(t);
+       return result;
+}
+//------------------------------------------------------------------------------
+int main(int argc, char* argv[]) {
+       int help = 0, i = 0;
+       for(i=1;i<argc;++i) {
+               if((0 == strcmp("help",argv[i])) ||
+                  (0 == strcmp("--help",argv[i])) ||
+                  (0 == strcmp("-help",argv[i])) ||
+                  (0 == strcmp("-h",argv[i])) ||
+                  (0 == strcmp("/h",argv[i])) ||
+                  (0 == strcmp("/help",argv[i]))) {
+                       help = 1;
+                       break;
+               }
+       }
+       if((argc < 3) || help) {
+               printf("[Usage: bdbprint s|b file_name.db (action identifier_of_record (optional_value))]\n"
+                      "\tfile_name.db - database to open and print\n"
+                      "\t           s - open in string mode, every key is treated as a string\n"
+                      "\t           b - open in binary mode, every key is treated as a unsigned integer\n"
+                      "\t      action - optional action to do on the base\n"
+                      "\t\t       del - delete record with key=identifier_of_record\n"
+                      "\t\t       add - add new record with key=identifier_of_record\n"
+                      "\t\t       fnd - find record with key=identifier_of_record\n"
+                      "\t\t\t    optional_value - value for add action\n");
+               return 100;
+       };
+
+       char* filename = argv[2];
+       char* _mode = argv[1];
+       if((strlen(_mode) > 1) || ( ('s' != _mode[0]) && ('b' != _mode[0]) )) {
+               printf("Wrong mode! Mode could be only s or b [\'s\' , \'b\']!\n");
+               return 2;
+       }
+       char mode = _mode[0];
+
+       BTREEINFO info = {
+         0,                    /* permit duplicate keys? */
+         0,                    /* cache size; 0 - default size */
+         0,                    /* page size; 0 - default */
+         0,                    /* byte order; 0 - use host order */
+         0,                    /* min page number per page; 0 - default=2 */
+         bm_compare_key_words, /* comparision function */
+         NULL                  /* prefix comparision function */
+       };
+       if('b' == mode) {
+               info.compare = bm_compare_key_trans;
+       }
+       u_int32_t flags = O_CREAT | O_RDWR;
+       DB *dbp = dbopen(filename, flags, 0755, DB_BTREE, &info);
+       if(NULL == dbp) {
+               printf("Could not open database: %s!\n",filename);
+               return 1;
+       };
+
+       int result = 0;
+       if(argc == 3) {
+               printf("Printing database: \'%s\' in mode %s :\n", filename, _mode);
+               if('s' == mode) {
+                       result = read_berkeley_in_string_mode(dbp);
+               }
+               else if('b' == mode) {
+                       result = read_berkeley_in_binary_mode(dbp);
+               }
+       }
+       else if(argc > 3) {
+               printf("Do not print - only action... [mode=%s]\n",_mode);
+               if(argc < 5) {
+                       printf("Wrong number of parameters! probably You did not give id of record for action.\n");
+                       return 21;
+               };
+               char* action = argv[3];
+               if(strcmp(action,"del") == 0) {
+                       if('*' == argv[4][0]) {
+                               result = berkeley_del_pattern_record(dbp,mode,&(argv[4][1]));
+                       }
+                       else {
+                               result = berkeley_del_record(dbp,mode,argv[4]);
+                       }
+               }
+               else if(strcmp(action,"fnd") == 0) {
+                       if('*' == argv[4][0]) {
+                               result = berkeley_fnd_pattern_record(dbp,mode,argv[4]+1);
+                       }
+                       else {
+                               result = berkeley_fnd_record(dbp,mode,argv[4]);
+                       }
+               }
+               else if(strcmp(action,"add") == 0) {
+                       if(argc < 6) {
+                               printf("You did not give value for new record!\n");
+                               return 22;
+                       };
+                       result = berkeley_add_record(dbp,mode,argv[4],argv[5]);
+               }
+               else {
+                       printf("Not supported action: %s! The only good values are: add, del, fnd.\n",action);
+                       result = 20;
+               }
+       }
+
+       dbp->close(dbp);
+       return result;
+}
+//------------------------------------------------------------------------------
diff --git a/src/bookmarks/bdb/src/engine_bookmark.c b/src/bookmarks/bdb/src/engine_bookmark.c
new file mode 100755 (executable)
index 0000000..0777316
--- /dev/null
@@ -0,0 +1,1368 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include "engine_bookmark.h"
+//------------------------------------------------------------------------------
+
+#ifndef NOLOGS
+       #include <glib/gstdio.h>
+       #define LOGS g_debug
+#else
+       #define LOGS(frm,...) while(FALSE)
+#endif
+
+
+//------------------------------------------------------------------------------
+static gint bm_compare_key_trans(const DBT *a, const DBT *b) {
+       guint tmpa;// = (guint*)(a->data);
+       guint tmpb;// = (guint*)(b->data);
+       memcpy(&tmpa, a->data, sizeof(guint));
+       memcpy(&tmpb, b->data, sizeof(guint));
+
+       if(tmpa == tmpb) return 0;
+       if(tmpa  > tmpb) return 1;
+       else return -1;
+}
+//------------------------------------------------------------------------------
+static gint bm_compare_key_words(const DBT *a, const DBT *b) {
+       gchar* tmpa = g_utf8_casefold((gchar*)(a->data),-1);
+       gchar* tmpb = g_utf8_casefold((gchar*)(b->data),-1);
+       gint result = g_utf8_collate(tmpa,tmpb);
+       eg_free(tmpa);
+       eg_free(tmpb);
+       return result;
+}
+//------------------------------------------------------------------------------
+static void bm_save_freeID(BookData* data) {
+       LOGS("Saveing new freeID=%u...\n",data->freeID);
+       guint temp = 0;
+       DBT key = {     &temp       , sizeof(guint)};
+       DBT val = { &(data->freeID) , sizeof(guint) };
+
+       gint res = data->db_trans->del(data->db_trans, &key, 0);
+       if(-1 == res)
+       {
+               data->last_error = ENGINE_INTERNAL_ERROR;
+               LOGS("Error while trying to delete old freeID!\n");
+               return;
+       }
+       else {
+               LOGS("Old freeID=%u deleted successfully!\n",data->freeID-1);
+       }
+
+       res = data->db_trans->put(data->db_trans, &key, &val, R_NOOVERWRITE);
+       if(-1 == res || 1 == res)
+       {
+               data->last_error = ENGINE_INTERNAL_ERROR;
+               LOGS("Error while trying to write new value for freeID!\n");
+       }
+       else {
+               LOGS("New freeID=%u written successfully!\n",data->freeID);
+       }
+
+       res = data->db_trans->sync(data->db_trans, 0);
+       if(-1 == res || 1 == res)
+       {
+               data->last_error = ENGINE_INTERNAL_ERROR;
+               LOGS("Error while trying to write data to fuile!\n");
+       }
+       else {
+               LOGS("New data saved successfully to file!\n");
+       }       
+}
+//------------------------------------------------------------------------------
+static void bm_load_freeID(BookData* data) {
+       guint temp = 0;
+       DBT key = { &temp , sizeof(guint) };
+       DBT val = { NULL  , 0 };
+
+       gint res = data->db_trans->get(data->db_trans, &key, &val, 0);
+       if(-1 == res)
+       {
+               data->last_error = ENGINE_INTERNAL_ERROR;
+               LOGS("Bookmark/%s->%s() Error while getting access to trans "
+                    "database!",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__
+                   );
+       }
+       else if( 1 != res)
+       {
+               memcpy(&(data->freeID), val.data, sizeof(guint));
+               //data->freeID = *((guint*)(val.data));
+               LOGS("Bookmark/%s->%s() Available next free ID is equal = %d",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    data->freeID
+                   );
+       }
+       else
+       {
+               LOGS("Bookmark/%s->%s() Could not load the minimal, available"
+                    " ID for next record - translation!",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__
+                   );
+               data->freeID = 1;
+               data->last_error = ENGINE_INTERNAL_ERROR;
+       }
+}
+
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION FROM API 0.2 !!!
+//==============================================================================
+
+gboolean bm_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) {
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\ntranslation address: %p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word,
+             translation
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        g_assert(translation != NULL);
+
+        // start bm_timer for this function
+        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+       gboolean result = TRUE;
+       BookData* data = (BookData*)(engine->engine_data);
+       guint length = strlen(word) + 1;
+       DBT key = { word , length };
+       DBT val = { NULL , 0 };
+               
+
+       gint db_res = data->db_words->get(data->db_words, &key, &val, 0);
+       if ( 0 == db_res )
+       {
+       // there is already entry for this key - check if this translation is in
+       // database - check string hash equality
+               LOGS("Bookmark/%s->%s() updating entry for key: %s",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (gchar*)(key.data)
+                       );
+
+               guint hash = g_str_hash(translation);
+               guint* values = (guint*)(val.data);
+               guint  N = values[0];
+               memcpy(&N, values, sizeof(guint));
+               guint  i = N;
+               guint  tmp_hash = 0;
+               gboolean exist = FALSE;
+               ++values;
+               while(i--)
+               {
+                       memcpy(&tmp_hash, values + (i*2+1), sizeof(guint));
+                       if( tmp_hash == hash)
+                       {
+                               exist = TRUE;
+                               break;
+                       }
+               }
+               if(!exist)
+               {
+                       LOGS("Bookmark/%s->%s() Adding new translation to "
+                               "already exist word in dictionary.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__
+                               );
+                       values = (guint*)(val.data);
+                       guint* tmp = eg_malloc(val.size + sizeof(guint)*2);
+                       g_memmove(tmp, values, val.size);
+                       tmp[0]++;
+                       tmp[N*2+1] = data->freeID;
+                       tmp[N*2+2] = hash;
+                       val.data = tmp;
+                       val.size += 2*sizeof(guint);
+                       gint o = data->db_words->del(data->db_words,&key,0);
+                       if(0 != o)
+                       {
+                               LOGS("Bookmark/%s->%s() Error while removing!",
+                                    (gchar*)__FILE__,
+                                    (gchar*)__FUNCTION__
+                                   );                          
+                       }
+                       o = data->db_words->sync(data->db_words, 0);
+                       if(0 != o) {
+                               LOGS("Error while 1st synchronizing file with data!\n");
+                       }
+                       
+                       o = data->db_words->put(data->db_words,
+                                           &key,
+                                           &val,
+                                           R_NOOVERWRITE);
+                       if(0 != o) {
+                               LOGS("Error while putting new info about word!\n");
+                       }
+                       o = data->db_words->sync(data->db_words, 0);
+                       if(0 != o) {
+                               LOGS("Error while 2nd synchronizing file with data!\n");
+                       }
+                       bm_add_only_translation(data,translation,data->freeID);
+                       (data->freeID)++;
+                       bm_save_freeID(data);
+                       eg_free(tmp);
+               }
+               else
+               {
+                       LOGS("Bookmark/%s->%s() This translation already exist!",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__
+                               );
+               }
+       }
+       else if ( 1 == db_res )
+       {
+       // there is no such a key - word in database - create new entry
+               LOGS("Bookmark/%s->%s() adding new entry for key: %s",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (gchar*)(key.data)
+                       );
+               result = bm_add_new_entry(word,translation,data);
+       }
+       else {
+       // there was an error, while accessing to the database
+               LOGS("Bookmark/%s->%s() Error while trying to add new word: %s",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (gchar*)(key.data)
+                       );
+               data->last_error = ENGINE_COULDNT_READ;
+               result = FALSE;
+       }
+
+        bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+static gboolean bm_add_only_translation(BookData* data,
+                                       gchar* translation,
+                                       guint id)
+{
+       DBT key = { &id , sizeof(id) };
+       DBT val = { translation , strlen(translation) + 1 };
+       gint res = data->db_trans->put(data->db_trans,
+                                       &key,
+                                       &val,
+                                       R_NOOVERWRITE);
+       if(-1 == res) {
+               LOGS("Error while adding only translation!\n");
+               return FALSE;
+       }
+       res = data->db_trans->sync(data->db_trans, 0);
+       if(-1 == res) {
+               LOGS("Error while synchronizing file with data\n");
+               return FALSE;
+       }
+       return TRUE;
+}
+//------------------------------------------------------------------------------
+static gboolean bm_add_new_entry(gchar* word,gchar* translation,BookData* data)
+{
+       guint hash = g_str_hash(translation);
+       gboolean result = TRUE;
+
+       DBT new_key = { &(data->freeID) , sizeof(guint) };
+       DBT new_val = { translation , strlen(translation) + 1};
+       gint db_res = data->db_trans->put(data->db_trans,
+                                         &new_key,
+                                         &new_val,
+                                         R_NOOVERWRITE
+                                        );
+       if(-1 == db_res)
+       {
+               data->last_error = ENGINE_COULDNT_WRITE;
+               result = FALSE;
+       }
+       else
+       {
+               new_key.data = word;
+               new_key.size = strlen(word) + 1;
+
+               // { number of entries , id of the first entry , hash #1 }
+               guint temp[3] = { 1 , data->freeID, hash };
+               new_val.data = temp;
+               new_val.size = sizeof(guint) * 3;
+
+               db_res = data->db_words->put(data->db_words,
+                                            &new_key,
+                                            &new_val,
+                                            R_NOOVERWRITE
+                                           );
+               if(-1 == db_res)
+               {
+                       new_key.data = &(data->freeID);
+                       new_key.size =  sizeof(guint);
+                       data->db_trans->del(data->db_trans, &new_key, 0);
+                       result = FALSE;
+                       data->last_error = ENGINE_INTERNAL_ERROR;
+               }
+               else
+               {
+                       result = TRUE;
+                       (data->freeID)++;
+                       bm_save_freeID(data);
+               }
+       }
+       db_res = data->db_words->sync(data->db_words,0);
+       db_res |= data->db_trans->sync(data->db_trans,0);
+       if(0 == db_res)
+       {
+               LOGS("Bookmark/%s->%s() adding new bookmark successful.\n",
+                     (gchar*)__FILE__,(gchar*)__FUNCTION__);
+       }
+       else
+       {
+               LOGS("Bookmark/%s->%s() adding new bookmark failed.\n",
+                     (gchar*)__FILE__,(gchar*)__FUNCTION__);
+       }
+       return result;  
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_remove_word(Engine* engine,
+                             gchar*  word) {
+        gboolean result = TRUE;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\n",(gchar*)__FILE__,(gchar*)__FUNCTION__,engine,word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+        BookData* data = (BookData*)(engine->engine_data);
+
+       DBT key = { word , strlen(word) + 1 };
+       DBT val = { NULL , 0 };
+               
+       gint db_res = data->db_words->get(data->db_words, &key, &val, 0);
+       if ( 0 == db_res )
+       {
+               guint* t = (guint*)(val.data);
+               guint  N = t[0];
+               guint  id = 0;
+               memcpy(&N, t, sizeof(guint));
+               ++t;
+               guint  i = 0;
+               key.size = sizeof(guint);
+               key.data = &id;
+               while( i < N ) {
+                       memcpy(&id, t + i*2, sizeof(guint));
+                       db_res = data->db_trans->del(data->db_trans, &key, 0);
+                       if(0 != db_res) {
+                               LOGS("Error while removing translation # %u for word: %s",i+1,word);
+                       }
+                       ++i;
+               }
+       }
+       else if( -1 == db_res) {
+               LOGS("Bookmark/%s->%s() Error while removing word: %s!",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       word
+                       );
+               return FALSE;
+       }
+       else {
+               LOGS("Bookmark/%s->%s() Ther is no such a word!",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__
+                       );
+               return TRUE;
+       };
+
+       // all data from trnaslation database has been deleted - now delete
+       // record in words database.
+
+       DBT key_del = { word , strlen(word) + 1 };
+       db_res = data->db_words->del(data->db_words,&key_del,0);
+       if(-1 == db_res)
+       {
+               LOGS("Bookmark/%s->%s() Error while removing!\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__
+                       );                              
+       }
+       else if(1 == db_res)
+       {
+               LOGS("Bookmark/%s->%s() There is no such a word!\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__
+                       );
+       }
+       else if(0 == db_res)
+       {
+               LOGS("Bookmark/%s->%s() word deleted successfully!\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__
+                       );
+       }
+       db_res = data->db_words->sync(data->db_words, 0);
+
+       if((0 != db_res) || (NULL == data->db_words) || (NULL == data->db_trans)) {
+               LOGS("Error while 2nd synchronizing file with data!\n");
+       }
+
+
+        bm_timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() finished work.\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__
+               );
+        return result;
+}
+//------------------------------------------------------------------------------      
+gchar* bm_engine_get_lang_from(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_lang_to(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_title(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strconcat(g_get_user_name(),"s' bookmarks",NULL);
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_icon_path(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("/usr/share/pixmaps/ws_eng_bookmark_icon.png");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION TO WRITE (NOT IMPLEMENTED YET)
+//==============================================================================
+
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void bm_engine_search_word_translation(Engine* engine,
+                                       gchar* word,
+                                       gpointer cb_data)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:engine at adress=%p\n"
+             "-->PARAM:word=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start bm_timer for this function
+        bm_timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+
+       gchar* down_word = g_utf8_strdown(word,-1);
+       DBT search = { down_word , strlen(down_word) + 1 };
+       DBT info   = {    NULL   ,        0              };
+       DBT trans  = {    NULL   ,        0              };
+       gchar* tran = NULL;
+       gchar* tran_ = NULL;
+
+       gint tmp = data->db_words->get(data->db_words, &search, &info, 0);
+       if(0 == tmp)
+       {
+               // plugin found some information about this word
+               
+               guint* records = (guint*)(info.data);
+               guint count = records[0];
+               memcpy(&count, records, sizeof(guint));
+               //printf("Buffer (memcpy): %#x-%#x-%#x\n",count,records[1],records[2]);
+               ++records;
+               guint id = 0;
+               search.data = &id;
+               search.size = sizeof(guint);
+               
+               while(count-- > 0 && count < 100)
+               {
+                       //printf("--> LOOP:count = %#x\n",count);
+                       memcpy(search.data, records, sizeof(guint));
+                       records += 2;
+                       tmp = data->db_trans->get(data->db_trans, &search, &trans, 0);
+                       if(0 == tmp)
+                       {
+                               if(NULL == tran)
+                               {
+                                       tran = g_strdup(trans.data);
+                               }
+                               else
+                               {
+                                       tran_ = 
+                                       g_strconcat(tran,"<br />",trans.data,NULL);
+                                       g_free(tran);
+                                       tran = tran_;
+                                       tran_ = NULL;
+                               }
+                       }
+               }
+       };
+       g_free(down_word);
+        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        bm_timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+
+       if ( NULL == cb_data )
+       {
+               cb_data = data->cb_search_word_trans_data;
+       }
+        data->cb_search_word_trans(tran, word, cb_data, ENGINE_NO_ERROR);
+               
+        bm_timer(TIMER_STOP,"callback for returning word's translation END");
+//         if(data->auto_free) {
+//                 LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+//                      "AUTO_FREE=TRUE\n",
+//                      (gchar*)__FILE__,
+//                      (gchar*)__FUNCTION__
+//                     );
+//                 g_free(tran);
+//         }
+       g_free(tran);
+        tran = NULL;
+}
+
+//------------------------------------------------------------------------------
+void bm_engine_close(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_assert(engine != NULL);
+        
+        BookData* data = (BookData*)(engine->engine_data);
+        data->db_words->close(data->db_words);
+       data->db_trans->close(data->db_trans);
+        
+        LOGS("Bookmark/%s->%s() engine at adress=%p is deleted.\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+       g_free(data->dict_path); 
+       g_free(data);
+       data = NULL;
+        g_free(engine);
+        engine = NULL;
+}
+//------------------------------------------------------------------------------
+
+Engine* bm_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        LOGS("Bookmark/%s->%s() called.\n"
+             "-->PARAM:location=\'%s\'\n"
+             "-->PARAM:auto_cache=%d\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location,
+             (guint)auto_cache
+            );
+        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);        
+
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = bm_engine_location;
+        result->engine_is_optimized = bm_engine_is_optimized;
+        result->engine_optimize = bm_engine_optimize;
+        result->engine_search_word_list = bm_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        bm_engine_search_word_translation;        
+        result->engine_close = bm_engine_close;
+        result->engine_status = bm_engine_status;
+        result->engine_error_message = bm_engine_status_message;
+        result->engine_set_callback = bm_engine_set_callback;
+        result->engine_set_progress_seed = bm_engine_set_progress_seed;
+        result->engine_set_auto_free = bm_engine_set_auto_free;
+        // 0.2 API:
+        result->engine_add_word = bm_engine_add_word;
+        result->engine_remove_word = bm_engine_remove_word;
+        result->engine_get_lang_from = bm_engine_get_lang_from;
+        result->engine_get_lang_to = bm_engine_get_lang_to;
+        result->engine_get_title = bm_engine_get_title;
+        result->engine_get_icon_path = bm_engine_get_icon_path;
+
+
+        BookData* data = (BookData*)g_try_malloc(sizeof(BookData));
+        result->engine_data = (gpointer)data;
+
+        LOGS("Bookmark/%s->%s() opening file...\'%s\'.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+
+       u_int32_t flags = O_CREAT | O_RDWR;
+        gchar* tmp_w = g_strconcat(tmp,"/bm_words.db",NULL);
+       gchar* tmp_t = g_strconcat(tmp,"/bm_trans.db",NULL);
+
+       BTREEINFO inf = {
+         0,            /* permit duplicate keys? */
+         0,                    /* cache size; 0 - default size */
+         0,                    /* page size; 0 - default */
+         0,                    /* byte order; 0 - use host order */
+         0,                    /* min page number per page; 0 - default=2 */
+         bm_compare_key_words, /* comparision function */
+         NULL                  /* prefix comparision function */
+       };
+       data->info_words = inf;
+       inf.compare = bm_compare_key_trans;
+       data->info_trans = inf;
+
+        data->db_words = 
+               dbopen(tmp_w,       /* On-disk file that holds the database. */
+                      flags,       /* flags, like O_CREAT etc. */
+                      0755,        /* mode same as flags <hmmm> ? */
+                      DB_BTREE,    /* type */
+                      &(data->info_words)
+                     );
+        if(data->db_words == NULL)
+       {
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+       else {
+               data->db_trans = 
+                       dbopen(tmp_t,
+                       flags,
+                       0755,
+                       DB_BTREE,
+                       &(data->info_trans)
+                       );
+
+               if(data->db_trans == NULL)
+               {
+                       data->db_words->close(data->db_words);
+                       g_free(data);
+                       g_free(result);
+                       result = NULL;
+               }
+
+       }
+        g_free(tmp_w); tmp_w = NULL;
+       g_free(tmp_t); tmp_t = NULL;
+        if(result == NULL) {
+                LOGS("Bookmark/%s->%s() opening bookmark file failed.\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+        }
+        else {
+                LOGS("Bookmark/%s->%s()opening dictionary file successed.\n",
+                        (gchar*)__FILE__,
+                        (gchar*)__FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+
+               bm_load_freeID(data);
+
+        }
+        g_free(tmp); tmp = NULL;
+        
+        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned Engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             result
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+
+
+static gboolean is_Bookmark_db_file(gchar* file) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 file
+               );
+
+       u_int32_t flags = O_RDWR;
+       DB* dbp = dbopen(file,flags,0755,DB_BTREE,NULL);
+
+        if(NULL == dbp) 
+       {
+               LOGS("Could no open! Wrong database! Not a bookmark.\n");
+                return FALSE;
+        };
+       
+       DBT search = {"four",sizeof("four")};
+       DBT result = {NULL, 0};
+
+       int errCode = dbp->get(dbp,&search,&result,0);
+       dbp->close(dbp);
+       g_free(result.data);
+
+       if(-1 == errCode)
+       {
+                LOGS("Could not read! Wrong database! Not a bookmark.\n");
+                return FALSE;
+        };
+        return TRUE;
+}
+//------------------------------------------------------------------------------
+
+
+void bm_engine_optimize(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called for engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        LOGS("Unsupported optimization mechanizm for this engine!\n");
+        LOGS("Bookmark/%s->%s()'s work finished.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_check(gchar* location) 
+{        
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        gboolean result = TRUE;
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+       gchar* tmp2 = NULL;
+        
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                LOGS("Bookmark/%s->%s() location \'%s\' is not a proper "
+                     "path!\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     location
+                    );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/bm_words.db",NULL);
+               tmp2 = g_strconcat(filepath,"/bm_trans.db",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                LOGS("Bookmark/%s->%s() finnal file to check is: %s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     filepath
+                    );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR) || 
+                   !g_file_test(tmp2, G_FILE_TEST_IS_REGULAR) 
+                  ) {
+                        LOGS("Bookmark/%s->%s() file \'%s\' does not exists!\n",
+                             (gchar*)__FILE__,
+                             (gchar*)__FUNCTION__,
+                             filepath
+                            );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_Bookmark_db_file(filepath) & 
+                        is_Bookmark_db_file(tmp2);
+        };
+
+        g_free(filepath);  filepath = NULL;
+       g_free(tmp2);      tmp2 = NULL;
+        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+
+//------------------------------------------------------------------------------
+gboolean bm_engine_is_optimized(Engine* engine) 
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        g_assert(engine != NULL);                
+        gboolean result = FALSE;
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+void bm_engine_search_word_list(Engine* engine,
+                                gchar* pattern,
+                                gpointer cb_data)
+{
+        LOGS("Bookmark/%s->%s() called. Searching words list\n"
+             "-->PARAM:engine at adress=%p\n"
+             "-->PARAM:pattern=\"%s\"\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             pattern
+            );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        bm_timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        BookData* data = (BookData*)(engine->engine_data);
+        if(data->cb_search_word_list == NULL) {
+                LOGS("Bookmark/%s->%s() callback for Word List not set. "
+                     "Searching aborted.\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+                return;
+        };
+
+       GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*) );
+       guint a = G_MAXUINT32;
+       DBT search = { &a , sizeof(a) };
+       DBT reply  = { NULL , 0 };
+       gchar* down_word = NULL;
+       gchar *tmp;
+       
+       GPatternSpec* regex;
+       regex = g_pattern_spec_new (g_utf8_casefold(pattern,-1));
+
+       gint code = data->db_words->sync(data->db_words, 0);
+       code = data->db_words->seq(data->db_words, &search, &reply, R_FIRST);
+       
+/*
+       if((('*' == pattern[0]) && ('\0' == pattern[1])) || ('\0' == pattern[0]))
+       {
+               // especiall treat if user give only '*'
+               while(0 == code) {
+                       gchar* cos = g_strdup(search.data);
+                       g_array_append_val(result,cos);
+                       code = data->db_words->seq(data->db_words, &search, &reply, R_NEXT);
+                       // we are giving to the user all words from dictionary
+               }
+       }
+       else
+       {*/
+       while(0 == code) {
+               down_word = g_utf8_casefold((gchar*)(search.data),-1);
+               
+               if( 0 == g_pattern_match_string( regex, down_word ) )
+               {
+                       tmp = g_strdup(search.data);
+                       g_array_append_val(result, tmp );
+               };
+
+               //eg_free(reply.data);
+               eg_free(down_word);
+               code = data->db_words->seq(data->db_words, &search, &reply, R_NEXT);
+       }
+       
+        bm_timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+       g_pattern_spec_free (regex);
+
+
+        bm_timer(TIMER_START,"callback for returning words LIST START");
+        // calling callback for word translation
+
+       if ( NULL == cb_data )
+       {
+               cb_data = data->cb_search_word_list_data;
+       }
+        data->cb_search_word_list(result, pattern, cb_data, ENGINE_NO_ERROR);
+
+
+       /* if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+               len = 0;
+               while(NULL != (tmp = g_array_index(result,gchar*,len++)))
+               {
+                       g_free(tmp); tmp = NULL;
+               }
+               g_array_free(result, TRUE);
+        }*/
+       guint len = 0;
+       
+       while(NULL != (tmp = g_array_index(result,gchar*,len++)))
+       {
+               g_free(tmp); tmp = NULL;
+       }
+       g_array_free(result, TRUE);
+       bm_timer(TIMER_STOP,"callback for returning word LIST END");
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- COMPLETED FUNCTIONS
+//==============================================================================
+// global functions
+EngineModule engine_global_functions()
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       EngineModule result;        
+       result.engine_check             = bm_engine_check;
+       result.engine_description       = bm_engine_description;
+       result.engine_format            = bm_engine_format;
+       result.engine_version           = bm_engine_version;
+       result.engine_create            = bm_engine_create;
+       LOGS("Bookmark/%s->%s()returned EngineModule at adress=%p.\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+             &result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_status_message(error)
+gchar* bm_engine_status_message(EngineStatus error) 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       switch (error) {
+               case ENGINE_NO_ERROR:
+                       return "No error.";
+               case ENGINE_WRONG_FILE:
+                       return "File which You are trying to use is wrong type.";
+               case ENGINE_COULDNT_READ:
+                       return "Could not read from file.";
+               case ENGINE_NO_FILE:
+                       return "There is no such a file.";
+               case ENGINE_OUT_OF_MEMORY:
+                       return "There were no enough memory for this action.";
+               default:
+                       return "Wrong engine's status identifier!";
+       }
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_version(module)
+gchar* bm_engine_version() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_VERSION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+               result
+              );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_format(module)
+gchar* bm_engine_format() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_description(module)
+gchar* bm_engine_description() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_location(engine)
+gchar* bm_engine_location(Engine* engine)
+{
+       LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+       gchar* result;
+       if(data->auto_free) {
+               result = data->dict_path;
+       }
+       else {
+               result = g_strdup(data->dict_path);
+       }
+
+       LOGS("Bookmark/%s->%s() returned string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_auto_free(engine, state)
+void bm_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+            "-->PARAM:engine at adress=%p\n"
+            "-->PARAM:state=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine,
+            PRINT_STATE(state)
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       data->auto_free = state;
+       LOGS("Bookmark/%s->%s() Current auto_free is %s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            PRINT_STATE(data->auto_free)
+           );
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_last_status(engine)
+EngineStatus bm_engine_status(Engine* engine) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+               "-->PARAM:engine at adress=%p\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+              engine
+              );
+       BookData* data = (BookData*)(engine->engine_data);
+       LOGS("Bookmark/%s->%s() returned error code: %d\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            (gint)(data->last_error)
+           );
+       return data->last_error;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_progress_seed(engine, signal, val)
+void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               data->cb_progress_caching_seed = seed;
+               LOGS("Bookmark/%s->%s() sets new seed=%0.2f for for signal "
+                    "\"%s\".\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    seed,
+                    signal
+                   );        
+       } 
+       else {
+               LOGS("Bookmark/%s->%s() unsupported signalfor progress: %s.\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    signal
+                   );
+       };
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_callback(engine,signal,c_handler,data)
+gpointer bm_engine_set_callback(Engine* engine,
+                            gchar* signal,
+                            gpointer c_handler,
+                            gpointer user_data)
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       g_assert(engine != NULL);
+       g_assert(signal != NULL);
+       g_assert(c_handler != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               gpointer result = data->cb_progress_caching;
+               data->cb_progress_caching = c_handler;
+               data->cb_progress_caching_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+               gpointer result = data->cb_search_word_list;
+               data->cb_search_word_list = c_handler;
+               data->cb_search_word_list_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                        
+       }
+       else if(g_ascii_strcasecmp(signal,
+               ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                       gpointer result = data->cb_search_word_trans;
+                       data->cb_search_word_trans = c_handler;
+                       data->cb_search_word_trans_data = user_data;
+                       LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               signal
+                              );
+                       LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)c_handler
+                              );
+                       LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)user_data
+                              );
+                       return result;                        
+               }
+               else {
+                       g_warning("Bookmark/%s->%s() unsupported signal: %s.\n",
+                                 (gchar*)__FILE__,
+                                 (gchar*)__FUNCTION__,
+                                 signal
+                                );
+                       return NULL;
+               }
+}
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- HELPFULLY FUNCTIONS
+//==============================================================================
+
+//------------------------------------------------------------------------------
+static gchar* string_to_path(gchar** string) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        LOGS("Bookmark/%s->%s() returned string=\'%s\'\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static double bm_timer(gboolean start, gchar* message)
+{
+       static GArray* stack = NULL;
+       static gboolean first_run = TRUE;
+       static struct timeval actual_time;
+       static struct timeval last_time;
+       static struct timeval result;
+       static double seconds = 0.0;
+       if(first_run) {
+               first_run = FALSE;
+               stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+       };        
+
+       if (start) {
+               LOGS("Bookmark->%s() start bm_timer for function '%s()'.\n",
+                       (gchar*)__FUNCTION__,
+                       message
+                      );
+               g_array_prepend_val(stack, actual_time);
+               gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+               return -1.0;
+       }
+        // we just want to end some bm_timer - print some information about 
+        // working time;
+       else {          
+               gettimeofday(&actual_time,NULL);
+               last_time = g_array_index(stack, struct timeval, 0);
+               g_array_remove_index(stack, 0);
+
+               if (actual_time.tv_usec < last_time.tv_usec) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       (1000000 + 1);
+                       last_time.tv_usec -= 1000000 * nsec;
+                       last_time.tv_sec += nsec;
+               }
+               if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       1000000;
+                       last_time.tv_usec += 1000000 * nsec;
+                       last_time.tv_sec -= nsec;
+               }
+               result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+               result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+               seconds = (((double)(result.tv_usec)) / 1e6) +
+                               ((double)(result.tv_sec));
+
+               LOGS("Bookmark->%s() function \'%s()\' was working for: %g "
+                               "[s] or %ld [us].\n",
+               (gchar*)__FUNCTION__,
+               message,
+               seconds,
+               ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                      );
+                // stack is empty so we delete everything
+               if(stack->len == 0)   
+               {
+                       g_array_free(stack, TRUE);
+                       first_run = TRUE;
+               }
+       }
+       return seconds;
+}
+//------------------------------------------------------------------------------
diff --git a/src/bookmarks/bdb/src/test.c b/src/bookmarks/bdb/src/test.c
new file mode 100755 (executable)
index 0000000..7ca80f3
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+        printf("--------------------------------------------------\n");
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "BerkeleyDB Bookmark Engine test: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library) {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       //dict_eng_module_get_global_functions(library,get_functions);
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+
+       EngineModule module = get_functions();
+       gchar* desc = dict_eng_module_get_description(module);
+       g_free(desc);
+       printf("Module description: %s\n",desc);
+       Engine* bm;
+
+        gboolean is_compatible = dict_eng_module_check(module,"/home/lukasz/MyDocs/release/mdictionary/trunk/src/bookmarks/bdb/data");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }       
+
+        bm = dict_eng_module_create(module,
+            "/home/lukasz/MyDocs/release/mdictionary/trunk/src/bookmarks/bdb/data" ,
+             ENGINE_CREATE);
+       gchar* location = dict_eng_get_location(bm);
+       printf("Lokalizacja: %s\n",location);
+       g_free(location);
+       dict_eng_set_callback(bm,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(bm,
+                             ENGINE_WORD_TRANSLATION_SIGNAL ,
+                             print_translation,
+                             "Translation for word: \'%s\':\n");
+       
+       dict_eng_add_word(bm, "stranger", "translation number 1");
+       dict_eng_add_word(bm, "stranger", "translation number 2");
+       dict_eng_add_word(bm, "stranger", "translation number 3");
+       dict_eng_add_word(bm, "str", "translation number 1 shorter");
+       dict_eng_add_word(bm, "gandzia", "rulez forever!");
+       dict_eng_search_word_list(bm,"*");
+
+       //dict_eng_remove_word(bm, "stranger");
+       //dict_eng_search_word_list(bm,"*");
+
+       dict_eng_search_word_translation(bm,"stranger");
+
+       //dict_eng_remove_word(bm, "stranger");
+       //dict_eng_add_word(bm, "stranger", "author of the plugin you are using now!");
+       //dict_eng_add_word(bm, "stranger", "author of the plugin you are using now!");
+       //dict_eng_add_word(bm, "stranger", "He knows gandzia.");
+       //dict_eng_add_word(bm, "stranger", "He knows gandzia. 2 ");
+       //dict_eng_add_word(bm, "stranger", "He knows gandzia. 3");
+       //dict_eng_destroy(bm);
+       //dict_eng_add_word(bm, "gandzia", "super girl!");
+       //dict_eng_add_word(bm, "stranger", "He knows gandzia.");
+       //dict_eng_search_word_list(bm,"*");
+       //dict_eng_search_word_list(bm,"f");
+       //dict_eng_search_word_list(bm,"s");
+       //dict_eng_search_word_translation(sd,"1 word");
+       //dict_eng_destroy(bm);
+        //return 0;
+
+
+
+        dict_eng_remove_word(bm, "stranger");
+       dict_eng_remove_word(bm, "gandzia");
+       dict_eng_remove_word(bm, "lukas");
+        dict_eng_add_word(bm, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_add_word(bm, "gandzia", "rulez");
+        dict_eng_add_word(bm, "lukas", "pawlik");
+        dict_eng_remove_word(bm, "stranger");
+
+        dict_eng_search_word_translation(bm,"stranger");
+       
+        dict_eng_add_word(bm, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_search_word_translation(bm,"stranger");
+        dict_eng_search_word_list(bm,"gandzia");
+
+//         printf("Lang FROM:%s\n",dict_eng_get_lang_from(bm));
+//         printf("  Lang TO:%s\n",dict_eng_get_lang_to(bm));
+//         printf("    Title:%s\n",dict_eng_get_title(bm));
+//         printf("Icon path:%s\n",dict_eng_get_icon_path(bm));
+       
+       dict_eng_destroy(bm);
+       g_free(current_directory);
+       g_free(library_to_path);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/bookmarks/bdb/src/testMakeDatabase.c b/src/bookmarks/bdb/src/testMakeDatabase.c
new file mode 100755 (executable)
index 0000000..7ca65e1
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <sqlite.h>
+
+const guint records_number = 1000;
+
+// ----------------------------------------------------------------------------------
+sqlite* database_make(gchar* path) {
+        gchar* buffer = NULL;
+        sqlite* result = NULL;
+        // creatingh database
+        result = sqlite_open(path,
+                             0600,
+                             &buffer);
+        // check if everything was okey
+        if(!result) {
+                g_printf("Error while trying to create database:\n%s\n",buffer);
+                g_free(buffer); buffer = NULL;
+                return NULL;
+        };
+        // return pointer to database
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_table(sqlite* db) {
+        gint result = 0;
+        //gchar sql[] = "CREATE TABLE words(id INTEGER PRIMARY KEY, word TEXT UNIQUE);";
+        gchar sql2[] = "CREATE TABLE translations(id INTEGER PRIMARY KEY, word TEXT, translation TEXT);";
+        gchar* err = NULL;      
+/*
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'words\' table:\n%s\n",err);
+                return 1;
+        }
+*/
+        result = sqlite_exec(db, sql2, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'translations\' table:\n%s\n",err);
+                return 2;
+        }
+
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_record(sqlite* db, guint i) {
+        gint result = 0;
+        gchar* sql = NULL;
+        gchar* err = NULL;
+        gint last_id = 0;
+        gint word_count = 1;
+        gchar buffer[] = "                     ";
+        gchar last_char[] = "                      ";
+        gchar tran[] = "this is a translation number 10.000 for word 10.000 word <-----";
+        g_sprintf(buffer,"%d word",i);
+/*
+        sql = g_strconcat("INSERT INTO words VALUES(NULL,\'",buffer,"\');", NULL);        
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while trying to add new word %d:\n%s\n",i,err);
+                g_free(sql);
+                return 1;
+        }
+        g_free(sql);
+        last_id = sqlite_last_insert_rowid(db);
+        g_sprintf(last_char,"%d",last_id);
+*/
+        if(i == 5000) {
+                word_count = 5;
+                g_printf("Adding more records for word - test\n");
+        }
+        gint j;
+        for(j=0; j<word_count; ++j) {
+                g_sprintf(tran,"this is a translation number %d for word %i",j,i);
+                sql = g_strconcat("INSERT INTO translations VALUES(NULL,\'",buffer,"\',\'",tran,"\');", NULL); 
+                result = sqlite_exec(db, sql, NULL, NULL, &err); 
+                if(err || result!=0) {
+                        g_printf("Error while trying to add new word trans %d:\n %s \n",j,err);
+                        g_free(sql);
+                        return 1;
+                }
+                g_free(sql);             
+        }
+        
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint main(gint argc, gchar* argv[]) {
+        g_printf("Making new database with %d records...\n",records_number);
+        
+        // create database
+        sqlite* db = database_make("ws_bookmarks");
+        if(!db) return 1;
+
+        // create table for records
+        database_add_test_table(db);
+
+        // create testing records
+        guint i;
+        gint code = 0;
+        for(i=0; i<records_number; ++i) {
+                code = database_add_test_record(db, i);
+                // if there were some errors, do not continue
+                if(code != 0) break;
+                // give to the user some feedback about progress of proccess
+                if(!(i % 50)) {
+                        g_printf("%d / %d records already added to database\n",i,records_number);
+                }
+        }
+
+        // close database
+        sqlite_close(db);
+        return 0;
+}
+// ----------------------------------------------------------------------------------
diff --git a/src/bookmarks/sql/COPYING b/src/bookmarks/sql/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/bookmarks/sql/Makefile b/src/bookmarks/sql/Makefile
new file mode 100644 (file)
index 0000000..56bf4ff
--- /dev/null
@@ -0,0 +1,48 @@
+COMPILER = gcc
+DEBUG = -Wall -g
+SOURCES = ./src
+INCLUDE = include
+INCLUDE_ENGINE = ../../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0` -lsqlite
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0` -I${INCLUDE} -I${INCLUDE_ENGINE} ${DEBUG}
+BINARIES = bin
+FINAL = ../../../bin/ws_bookmark.so
+
+
+${FINAL}: ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c
+               @gcc -shared -fPIC ${FLAGS} ${LIBS} ${BINARIES}/bookmark.o -o ${FINAL} 
+       
+${BINARIES}/bookmark.o: ${SOURCES}/engine_bookmark.c
+               @gcc -c -fPIC -o ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c ${FLAGS}
+               
+clean:
+               @-rm -f ${BINARIES}/*
+               @-rm -f ${FINAL}
+               @echo -e -n "Project's 'BookmarkEngine' directories has been cleaned.\n"
+       
+cleandata:
+               @-rm -f ws_bookmarks-journal
+               @-rm -f ws_bookmarks
+
+
+data: ${SOURCES}/testMakeDatabase.c
+               @echo -e -n "Compiling testDatabase...\n"
+               @gcc -o ${SOURCES}/testDatabase ${SOURCES}/testMakeDatabase.c ${FLAGS} ${LIBS}
+
+datarun: data
+               @run-standalone.sh src/testDatabase     
+       
+test: test.o
+               @echo "Linking test program..."
+               @gcc ${LIBS} ${DEBUG} -o ${SOURCES}/test ${BINARIES}/test.o
+               @echo -e "Building test program finished.\n"
+
+test.o:
+               @echo "Compiling test program..."
+               @gcc ${FLAGS} ${DEBUG} -c -o ${BINARIES}/test.o ${SOURCES}/test.c
+
+check:
+               @echo "Running test program:"
+               @run-standalone.sh  ${SOURCES}/test     
+       
+       
\ No newline at end of file
diff --git a/src/bookmarks/sql/include/engine_bookmark.h b/src/bookmarks/sql/include/engine_bookmark.h
new file mode 100644 (file)
index 0000000..5884cb1
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY_ENGINE_BOOKMARK
+#define _DICTIONARY_ENGINE_BOOKMARK
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - only for timers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header wit engine API
+#include <dictionary_engine.h>
+//------------------------------------------------------------------------------
+// header wit sqlite 2.x API
+#include <sqlite.h>
+//------------------------------------------------------------------------------
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+static const gchar* DIC_ENG_VERSION = "0.1"; 
+static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
+static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' bookmarks.";
+                           
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _BookData {
+        sqlite*                 db;
+        
+        gchar*                  dict_path;
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _BookData        BookData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+//static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// convert string to proper path name (no filename, no "/" at the ned, file
+// exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// tells if file is in XDXF format (file should exist)
+//static gboolean         is_xdxf_file(gchar* file); 
+//------------------------------------------------------------------------------
+// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+static double           timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+gboolean        bm_engine_add_word(Engine* engine,
+                                 gchar*  word,
+                                 gchar*  translation);
+//------------------------------------------------------------------------------
+gboolean        bm_engine_remove_word(Engine* engine,
+                                     gchar*  word);  
+//------------------------------------------------------------------------------      
+gchar*          bm_engine_get_lang_from(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_lang_to(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_title(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_icon_path(Engine* engine);
+
+
+
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        bm_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          bm_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          bm_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          bm_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         bm_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            bm_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          bm_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            bm_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        bm_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            bm_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        bm_engine_set_callback(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            bm_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            bm_engine_search_word_list(Engine* engine, gchar* pattern);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            bm_engine_search_word_translation(Engine* engine, gchar* word);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    bm_engine_status(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          bm_engine_status_message(EngineStatus error);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
diff --git a/src/bookmarks/sql/src/engine_bookmark.c b/src/bookmarks/sql/src/engine_bookmark.c
new file mode 100644 (file)
index 0000000..05abb86
--- /dev/null
@@ -0,0 +1,1055 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_bookmark.h>
+//------------------------------------------------------------------------------
+
+#ifndef NOLOGS
+#include <glib/gstdio.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+#define LOGS g_debug
+
+/*inline void LOGS(gchar* frm, ...) {
+#ifndef NOLOGS
+       //g_printf(frm);
+#endif
+}*/
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION FROM API 0.2 !!!
+//==============================================================================
+int get_id(void* data,int n,char** argv,char** names) {
+        int len = strlen(&(argv[0][0]));
+        memcpy(data,&(argv[0][0]), len);
+        gchar* tmp = (gchar*)data;
+        tmp[len] = 0;
+        return 0;
+}
+
+gboolean bm_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) {
+        gint sql_res = 0;
+        gchar* err = NULL;
+        gboolean result = TRUE;
+        gchar* sql = NULL;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\ntranslation address: %p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word,
+             translation
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        g_assert(translation != NULL);
+
+        // start timer for this function
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+       BookData* data = (BookData*)(engine->engine_data);
+/*
+
+        gchar* tmp = g_utf8_strdown(word,-1);
+        sql = g_strconcat("INSERT INTO words VALUES(NULL,\'",tmp,"\');",NULL);
+        sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("This word exists already\nError description: %s\n",err);
+        }            
+        g_free(sql); sql = NULL;
+        const gchar* end;
+        sqlite_vm* query = NULL;
+
+        sql = g_strconcat("SELECT id FROM words WHERE word=\'",tmp,"\'",NULL);
+        gchar word_id[20];
+        sqlite_exec(
+                (data->db),
+                sql,
+                get_id,
+                word_id,
+                &err
+        );
+        LOGS("Founded id is equal: %s\n",word_id);
+*/
+        //sql = g_strconcat("INSERT INTO translations VALUES(NULL,\'",word,"\',\'",translation,"\');",NULL);
+       sql = sqlite_mprintf("INSERT INTO translations VALUES(NULL,\'%q\',\'%q\');", word, translation);
+
+        sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while adding translation for word %s\n"
+                    "Reason: %s",
+                    word,
+                    err
+                   );
+                result = FALSE;
+        } 
+        g_free(sql); sql = NULL;
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_remove_word(Engine* engine, gchar*  word) {
+        gint sql_res = 0;
+        gchar* err = NULL;
+        gboolean result = TRUE;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\n",(gchar*)__FILE__,(gchar*)__FUNCTION__,engine,word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+        BookData* data = (BookData*)(engine->engine_data);
+/*
+        gchar* tmp = g_utf8_strdown(word,-1);
+        gchar* sql = g_strconcat("DELETE FROM translations WHERE word_id = "
+                                 "(SELECT id FROM words WHERE word=\'",
+                                 tmp,
+                                 "\');",
+                                 NULL
+                                );
+        g_free(tmp); tmp = NULL;
+        sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while deleting \'%s\' word translation(s):\n%s\n",word,err);
+                g_free(sql); sql = NULL;
+                return FALSE;
+        }        
+        g_free(sql); sql = NULL;
+
+        gchar* sql = g_strconcat("DELETE FROM translations WHERE word LIKE \'",
+                                 word,
+                                 "\';",
+                                 NULL
+                                );
+*/
+       gchar* sql = sqlite_mprintf("DELETE FROM translations WHERE word LIKE "
+                                       "\'%q\';", word);
+       sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while deleting \'%s\' <-> reason:\n%s\n",word,err);
+                g_free(sql); sql = NULL;
+                return FALSE;
+        }
+        g_free(sql); sql = NULL;
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------      
+gchar* bm_engine_get_lang_from(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_lang_to(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_title(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strconcat(g_get_user_name(),"s' bookmarks",NULL);
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_icon_path(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("/usr/share/pixmaps/ws_eng_bookmark_icon.png");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION TO WRITE (NOT IMPLEMENTED YET)
+//==============================================================================
+
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void bm_engine_search_word_translation(Engine* engine, gchar* word)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:engine at adress=%p\n"
+             "-->PARAM:word=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start timer for this function
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       //gchar* tmp = g_utf8_strdown(word,-1);
+        sqlite_vm* query;
+        gchar* sql = NULL;
+        gchar* tran = NULL;
+
+/*
+        sql = g_strconcat("SELECT * FROM translations WHERE "
+                          "word_id=(SELECT id FROM words WHERE word=\'",
+                          tmp,
+                          "\');",
+                          NULL);
+*/
+
+        /*sql = g_strconcat("SELECT * FROM translations WHERE word LIKE \'",
+                          tmp,
+                          "\';",
+                          NULL);*/
+       sql = sqlite_mprintf("SELECT translation FROM translations WHERE word LIKE '%q';",
+                               word);
+
+        gint sql_res = 0;
+        const gchar* end;
+        gchar* err = NULL;
+        sql_res = sqlite_compile(data->db,  /* The open database */
+                                 (const gchar*)sql, /* SQL statement to be compiled */
+                                 &end,      /* OUT: uncompiled tail of zSql */
+                                 &query,    /* OUT: the virtual machine */
+                                 &err       /* OUT: Error message. */
+                                );
+        if(err || sql_res!=0) {
+                LOGS("Error while compiling query:\n%s\nreason:%s\n",sql,err);
+                sqlite_freemem(sql);/*g_free(sql);*/ sql = NULL;
+                return;
+        }
+
+        gint nCol = 0;
+        const gchar** values = NULL;
+        const gchar** head = NULL;
+        gint status = 0;
+        gboolean first = TRUE;
+        do { 
+                first = TRUE;
+                do {
+                        if(!first) sleep(1);
+                        first = FALSE;
+                        status = sqlite_step(query,
+                                        &nCol,
+                                        &values,
+                                        &head 
+                                        );
+                        if(status == SQLITE_ROW) {
+                               if (tran != NULL){
+                                       tran = g_strconcat(tran,"<BR><BR>", 
+                                               (gchar*)(&(values[0][0])), NULL);       
+                               }else{
+                                       tran = g_strdup_printf("%s <BR><BR>",
+                                               (gchar*)(&(values[0][0])));
+                               }
+                               LOGS("Translation found :\n\"%s\"\n",tran);
+                        }
+                } while((status == SQLITE_BUSY) && (status != SQLITE_ERROR));
+        } while((status == SQLITE_ROW) && (status != SQLITE_ERROR));
+        sqlite_finalize(query,&err);
+        sqlite_freemem(sql); sql = NULL;
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+
+        data->cb_search_word_trans(tran, word, data->cb_search_word_trans_data,
+                                        ENGINE_NO_ERROR);
+               
+        timer(TIMER_STOP,"callback for returning word's translation END");
+        if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                g_free(tran);
+        }
+        tran = NULL;
+}
+
+//------------------------------------------------------------------------------
+void bm_engine_close(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_assert(engine != NULL);
+        
+        BookData* data = (BookData*)(engine->engine_data);
+        sqlite_close(data->db);
+        
+        LOGS("Bookmark/%s->%s() engine at adress=%p is deleted.\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_free(engine);
+        engine = NULL;
+}
+//------------------------------------------------------------------------------
+
+Engine* bm_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        LOGS("Bookmark/%s->%s() called.\n"
+             "-->PARAM:location=\'%s\'\n"
+             "-->PARAM:auto_cache=%d\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location,
+             (guint)auto_cache
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);        
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = bm_engine_location;
+        result->engine_is_optimized = bm_engine_is_optimized;
+        result->engine_optimize = bm_engine_optimize;
+        result->engine_search_word_list = bm_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        bm_engine_search_word_translation;        
+        result->engine_close = bm_engine_close;
+        result->engine_status = bm_engine_status;
+        result->engine_error_message = bm_engine_status_message;
+        result->engine_set_callback = bm_engine_set_callback;
+        result->engine_set_progress_seed = bm_engine_set_progress_seed;
+        result->engine_set_auto_free = bm_engine_set_auto_free;
+        // 0.2 API:
+        result->engine_add_word = bm_engine_add_word;
+        result->engine_remove_word = bm_engine_remove_word;
+        result->engine_get_lang_from = bm_engine_get_lang_from;
+        result->engine_get_lang_to = bm_engine_get_lang_to;
+        result->engine_get_title = bm_engine_get_title;
+        result->engine_get_icon_path = bm_engine_get_icon_path;
+
+
+        BookData* data = (BookData*)g_try_malloc(sizeof(BookData));
+        result->engine_data = (gpointer)data;
+
+        LOGS("Bookmark/%s->%s() opening file...\'%s\'.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        gchar* tmp2 = g_strconcat(tmp,"/ws_bookmarks",NULL);
+        gchar* err;
+        data->db = sqlite_open(tmp2,0600,&err);
+        g_free(tmp2); tmp2 = NULL;
+        if(!(data->db)) {
+                LOGS("Bookmark/%s->%s() opening bookmark file failed.%s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     err
+                    );
+                g_free(err);
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+        else {
+                LOGS("Bookmark/%s->%s()opening dictionary file successed.\n",
+                        (gchar*)__FILE__,
+                        (gchar*)__FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+                // there is no cache mechanizm in bookmarks
+        }
+        g_free(tmp); tmp = NULL;
+        
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned Engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             result
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+
+
+static gboolean is_Bookmark_file(gchar* file) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 file
+               );
+        gchar* err;
+        sqlite* tmp = sqlite_open(file,0600,&err);
+        if(err || tmp==NULL) {
+                LOGS("Wrong file! Not a sqlite database.\n");
+                g_free(err); 
+                return FALSE;
+        }
+
+        gint result = 0;
+        gchar sql[] = "SELECT COUNT(word) FROM translations WHERE word=\'.\';";  
+
+        result = sqlite_exec(tmp, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                LOGS("Wrong database! Not a bookmark.\n");
+                g_free(err);
+               sqlite_close(tmp);
+                return FALSE;
+        }
+       sqlite_close(tmp);
+        return TRUE;
+}
+//------------------------------------------------------------------------------
+
+
+void bm_engine_optimize(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called for engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        LOGS("Unsupported optimization mechanizm for this engine!\n");
+        LOGS("Bookmark/%s->%s()'s work finished.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_check(gchar* location) 
+{        
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        gboolean result = TRUE;        
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                LOGS("Bookmark/%s->%s() location \'%s\' is not a proper "
+                     "path!\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     location
+                    );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/ws_bookmarks",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                LOGS("Bookmark/%s->%s() finnal file to check is: %s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     filepath
+                    );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR)) {
+                        LOGS("Bookmark/%s->%s() file \'%s\' does not exists!\n",
+                             (gchar*)__FILE__,
+                             (gchar*)__FUNCTION__,
+                             filepath
+                            );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_Bookmark_file(filepath);
+        };
+
+        g_free(filepath);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+
+//------------------------------------------------------------------------------
+gboolean bm_engine_is_optimized(Engine* engine) 
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        g_assert(engine != NULL);                
+        gboolean result = FALSE;
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+void bm_engine_search_word_list(Engine* engine, gchar* pattern)
+{
+        LOGS("Bookmark/%s->%s() called. Searching words list\n"
+             "-->PARAM:engine at adress=%p\n"
+             "-->PARAM:pattern=\"%s\"\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             pattern
+            );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        BookData* data = (BookData*)(engine->engine_data);
+        if(data->cb_search_word_list == NULL) {
+                LOGS("Bookmark/%s->%s() callback for Word List not set. "
+                     "Searching aborted.\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+                return;
+        };
+
+        gchar* tmp = g_utf8_strdown(pattern,-1);
+        sqlite_vm* query = NULL;
+        gchar* sql = NULL;
+        gchar* tran = NULL;
+
+       //LOGS("::::BOOKMARKS!!!!:::: tmp = %s, int(tmp) = %i", tmp, tmp[0]);
+
+
+       g_strstrip(tmp);
+       if ((int)(tmp[0]) == 42 && tmp[1] == '\0') //asterix?
+       {
+               sql = g_strconcat("SELECT DISTINCT word FROM translations;", NULL);
+       }
+       else
+       {
+                       sql = g_strconcat("SELECT word FROM translations WHERE "
+                          "word LIKE \'",tmp,"\%\';",NULL);
+       }
+        LOGS("QUERY: %s\n",sql);
+        gint sql_res = 0;
+        const gchar* end;
+        gchar* err = NULL;
+        sql_res = sqlite_compile(data->db,  /* The open database */
+                                 (const gchar*)sql,       /* SQL statement to be compiled */
+                                 &end,      /* OUT: uncompiled tail of zSql */
+                                 &query,    /* OUT: the virtual machine */
+                                 &err       /* OUT: Error message. */
+                                );
+        if(err || sql_res!=0) {
+                LOGS("Error while compiling query:\n%s\nreason:%s\n",sql,err);
+                g_free(sql); sql = NULL;
+                return;
+        };    
+        gint nCol = 0;
+        const gchar** values = NULL;
+        const gchar** head = NULL;
+        gint status = 0;
+        gboolean first = TRUE;
+        GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*) );
+        do { 
+                first = TRUE;
+                do {
+                        if(!first) sleep(1);
+                        first = FALSE;;
+                        status = sqlite_step(
+                                        query, 
+                                        &nCol,            
+                                        &values,  
+                                        &head 
+                                        );
+                        if(status == SQLITE_ERROR) {
+                                LOGS("Error while making next step\n");
+                                g_free(sql); sql = NULL;
+                                        return;
+                        };
+                        if(status == SQLITE_ROW) {
+                                LOGS("Fount new word: \"%s\"\n",&(values[0][0]));
+                                gchar* tmp = g_strdup((gchar*)&(values[0][0]));
+                                g_array_append_val(result, tmp );        
+                        }
+                } while((status == SQLITE_BUSY) && (status != SQLITE_ERROR));
+        } while((status == SQLITE_ROW) && (status != SQLITE_ERROR));
+        sqlite_finalize(query,&err);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+
+
+        timer(TIMER_START,"callback for returning words LIST START");
+        // calling callback for word translation
+
+        data->cb_search_word_list(result , pattern, data->cb_search_word_list_data, ENGINE_NO_ERROR);
+                
+        timer(TIMER_STOP,"callback for returning word LIST END");
+        if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                g_free(tran);
+        }
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- COMPLETED FUNCTIONS
+//==============================================================================
+// global functions
+EngineModule engine_global_functions()
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       EngineModule result;        
+       result.engine_check             = bm_engine_check;
+       result.engine_description       = bm_engine_description;
+       result.engine_format            = bm_engine_format;
+       result.engine_version           = bm_engine_version;
+       result.engine_create            = bm_engine_create;
+       LOGS("Bookmark/%s->%s()returned EngineModule at adress=%p.\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+             &result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_status_message(error)
+gchar* bm_engine_status_message(EngineStatus error) 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       switch (error) {
+               case ENGINE_NO_ERROR:
+                       return "No error.";
+               case ENGINE_WRONG_FILE:
+                       return "File which You are trying to use is wrong type.";
+               case ENGINE_COULDNT_READ:
+                       return "Could not read from file.";
+               case ENGINE_NO_FILE:
+                       return "There is no such a file.";
+               case ENGINE_OUT_OF_MEMORY:
+                       return "There were no enough memory for this action.";
+               default:
+                       return "Wrong engine's status identifier!";
+       }
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_version(module)
+gchar* bm_engine_version() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_VERSION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+               result
+              );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_format(module)
+gchar* bm_engine_format() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_description(module)
+gchar* bm_engine_description() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_location(engine)
+gchar* bm_engine_location(Engine* engine)
+{
+       LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       gchar* result;
+       if(data->auto_free) {
+               result = data->dict_path;
+       }
+       else {
+               result = g_strdup(data->dict_path);
+       }
+
+       LOGS("Bookmark/%s->%s() returned string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_auto_free(engine, state)
+void bm_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+            "-->PARAM:engine at adress=%p\n"
+            "-->PARAM:state=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine,
+            PRINT_STATE(state)
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       data->auto_free = state;
+       LOGS("Bookmark/%s->%s() Current auto_free is %s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            PRINT_STATE(data->auto_free)
+           );
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_last_status(engine)
+EngineStatus bm_engine_status(Engine* engine) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+               "-->PARAM:engine at adress=%p\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+              engine
+              );
+       BookData* data = (BookData*)(engine->engine_data);
+       LOGS("Bookmark/%s->%s() returned error code: %d\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            (gint)(data->last_error)
+           );        
+       return data->last_error;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_progress_seed(engine, signal, val)
+void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               data->cb_progress_caching_seed = seed;
+               LOGS("Bookmark/%s->%s() sets new seed=%0.2f for for signal "
+                    "\"%s\".\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    seed,
+                    signal
+                   );        
+       } 
+       else {
+               LOGS("Bookmark/%s->%s() unsupported signalfor progress: %s.\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    signal
+                   );
+       };
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_callback(engine,signal,c_handler,data)
+gpointer bm_engine_set_callback(Engine* engine,
+                            gchar* signal,
+                            gpointer c_handler,
+                            gpointer user_data)
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       g_assert(engine != NULL);
+       g_assert(signal != NULL);
+       g_assert(c_handler != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               gpointer result = data->cb_progress_caching;
+               data->cb_progress_caching = c_handler;
+               data->cb_progress_caching_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+               gpointer result = data->cb_search_word_list;
+               data->cb_search_word_list = c_handler;
+               data->cb_search_word_list_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                        
+       }
+       else if(g_ascii_strcasecmp(signal,
+               ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                       gpointer result = data->cb_search_word_trans;
+                       data->cb_search_word_trans = c_handler;
+                       data->cb_search_word_trans_data = user_data;
+                       LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               signal
+                              );
+                       LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)c_handler
+                              );
+                       LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)user_data
+                              );
+                       return result;                        
+               }
+               else {
+                       g_warning("Bookmark/%s->%s() unsupported signal: %s.\n",
+                                 (gchar*)__FILE__,
+                                 (gchar*)__FUNCTION__,
+                                 signal
+                                );
+                       return NULL;
+               }
+}
+
+
+
+
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- HELPFULLY FUNCTIONS
+//==============================================================================
+
+//------------------------------------------------------------------------------
+static gchar* string_to_path(gchar** string) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        LOGS("Bookmark/%s->%s() returned string=\'%s\'\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static double timer(gboolean start, gchar* message)
+{
+       static GArray* stack = NULL;
+       static gboolean first_run = TRUE;
+       static struct timeval actual_time;
+       static struct timeval last_time;
+       static struct timeval result;
+       static double seconds = 0.0;
+       if(first_run) {
+               first_run = FALSE;
+               stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+       };        
+
+       if (start) {
+               LOGS("Bookmark->%s() start timer for function '%s()'.\n",
+                       (gchar*)__FUNCTION__,
+                       message
+                      );
+               g_array_prepend_val(stack, actual_time);
+               gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+               return -1.0;
+       }
+        // we just want to end some timer - print some information about 
+        // working time;
+       else {          
+               gettimeofday(&actual_time,NULL);
+               last_time = g_array_index(stack, struct timeval, 0);
+               g_array_remove_index(stack, 0);
+
+               if (actual_time.tv_usec < last_time.tv_usec) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       (1000000 + 1);
+                       last_time.tv_usec -= 1000000 * nsec;
+                       last_time.tv_sec += nsec;
+               }
+               if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       1000000;
+                       last_time.tv_usec += 1000000 * nsec;
+                       last_time.tv_sec -= nsec;
+               }
+               result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+               result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+               seconds = (((double)(result.tv_usec)) / 1e6) +
+                               ((double)(result.tv_sec));
+
+               LOGS("Bookmark->%s() function \'%s()\' was working for: %g "
+                               "[s] or %ld [us].\n",
+               (gchar*)__FUNCTION__,
+               message,
+               seconds,
+               ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                      );
+                // stack is empty so we delete everything
+               if(stack->len == 0)   
+               {
+                       g_array_free(stack, TRUE);
+                       first_run = TRUE;
+               }
+       }
+       return seconds;
+}
+//------------------------------------------------------------------------------
+
+
+
diff --git a/src/bookmarks/sql/src/test.c b/src/bookmarks/sql/src/test.c
new file mode 100644 (file)
index 0000000..b89a9a7
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+        printf("--------------------------------------------------\n");
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "StarDictEngine test: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library) {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       //dict_eng_module_get_global_functions(library,get_functions);
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+
+       EngineModule module = get_functions();
+       printf("Module description: %s\n",dict_eng_module_get_description(module));
+       Engine* sd;
+
+        gboolean is_compatible = dict_eng_module_check(module,"/home/str/whitestork/engines/bookmark/ws_bookmarks");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+
+       //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
+
+       //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
+       //home/stranger/whitestork/engine0.2/
+//     xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
+//     dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
+//     dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
+
+/*     if(dict_eng_is_optimized(xdxf) == FALSE)
+       {
+               printf("Dictionary has no cache!\nCreating cache file....\n");
+               dict_eng_optimize(xdxf);
+       }
+       else {
+               printf("Dictionary has already cache file!\n");
+       }*/
+        sd = dict_eng_module_create(module,
+            "/home/str/whitestork/engines/bookmark/ws_bookmarks" ,
+             ENGINE_CREATE);
+       printf("Lokacja: %s\n",dict_eng_get_location(sd));
+
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_TRANSLATION_SIGNAL ,
+                             print_translation,
+                             "Translation for word\'%s\':\n");
+       
+       dict_eng_search_word_list(sd,"12");
+       //dict_eng_search_word_translation(sd,"1 word");
+        
+        dict_eng_remove_word(sd, "stranger");
+       dict_eng_remove_word(sd, "gandzia");
+       dict_eng_remove_word(sd, "lukas");
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_add_word(sd, "gandzia", "rulez");
+        dict_eng_add_word(sd, "lukas", "pawlik");
+        dict_eng_remove_word(sd, "stranger");
+
+        dict_eng_search_word_translation(sd,"stranger");
+       
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_search_word_translation(sd,"stranger");
+        dict_eng_search_word_list(sd,"gandzia");
+
+        printf("Lang FROM:%s\n",dict_eng_get_lang_from(sd));
+        printf("  Lang TO:%s\n",dict_eng_get_lang_to(sd));
+        printf("    Title:%s\n",dict_eng_get_title(sd));
+        printf("Icon path:%s\n",dict_eng_get_icon_path(sd));
+       
+       dict_eng_destroy(sd);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/bookmarks/sql/src/testMakeDatabase.c b/src/bookmarks/sql/src/testMakeDatabase.c
new file mode 100644 (file)
index 0000000..7ca65e1
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <sqlite.h>
+
+const guint records_number = 1000;
+
+// ----------------------------------------------------------------------------------
+sqlite* database_make(gchar* path) {
+        gchar* buffer = NULL;
+        sqlite* result = NULL;
+        // creatingh database
+        result = sqlite_open(path,
+                             0600,
+                             &buffer);
+        // check if everything was okey
+        if(!result) {
+                g_printf("Error while trying to create database:\n%s\n",buffer);
+                g_free(buffer); buffer = NULL;
+                return NULL;
+        };
+        // return pointer to database
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_table(sqlite* db) {
+        gint result = 0;
+        //gchar sql[] = "CREATE TABLE words(id INTEGER PRIMARY KEY, word TEXT UNIQUE);";
+        gchar sql2[] = "CREATE TABLE translations(id INTEGER PRIMARY KEY, word TEXT, translation TEXT);";
+        gchar* err = NULL;      
+/*
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'words\' table:\n%s\n",err);
+                return 1;
+        }
+*/
+        result = sqlite_exec(db, sql2, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'translations\' table:\n%s\n",err);
+                return 2;
+        }
+
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_record(sqlite* db, guint i) {
+        gint result = 0;
+        gchar* sql = NULL;
+        gchar* err = NULL;
+        gint last_id = 0;
+        gint word_count = 1;
+        gchar buffer[] = "                     ";
+        gchar last_char[] = "                      ";
+        gchar tran[] = "this is a translation number 10.000 for word 10.000 word <-----";
+        g_sprintf(buffer,"%d word",i);
+/*
+        sql = g_strconcat("INSERT INTO words VALUES(NULL,\'",buffer,"\');", NULL);        
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while trying to add new word %d:\n%s\n",i,err);
+                g_free(sql);
+                return 1;
+        }
+        g_free(sql);
+        last_id = sqlite_last_insert_rowid(db);
+        g_sprintf(last_char,"%d",last_id);
+*/
+        if(i == 5000) {
+                word_count = 5;
+                g_printf("Adding more records for word - test\n");
+        }
+        gint j;
+        for(j=0; j<word_count; ++j) {
+                g_sprintf(tran,"this is a translation number %d for word %i",j,i);
+                sql = g_strconcat("INSERT INTO translations VALUES(NULL,\'",buffer,"\',\'",tran,"\');", NULL); 
+                result = sqlite_exec(db, sql, NULL, NULL, &err); 
+                if(err || result!=0) {
+                        g_printf("Error while trying to add new word trans %d:\n %s \n",j,err);
+                        g_free(sql);
+                        return 1;
+                }
+                g_free(sql);             
+        }
+        
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint main(gint argc, gchar* argv[]) {
+        g_printf("Making new database with %d records...\n",records_number);
+        
+        // create database
+        sqlite* db = database_make("ws_bookmarks");
+        if(!db) return 1;
+
+        // create table for records
+        database_add_test_table(db);
+
+        // create testing records
+        guint i;
+        gint code = 0;
+        for(i=0; i<records_number; ++i) {
+                code = database_add_test_record(db, i);
+                // if there were some errors, do not continue
+                if(code != 0) break;
+                // give to the user some feedback about progress of proccess
+                if(!(i % 50)) {
+                        g_printf("%d / %d records already added to database\n",i,records_number);
+                }
+        }
+
+        // close database
+        sqlite_close(db);
+        return 0;
+}
+// ----------------------------------------------------------------------------------
diff --git a/src/bookmarks/sql3/COPYING b/src/bookmarks/sql3/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/bookmarks/sql3/Makefile b/src/bookmarks/sql3/Makefile
new file mode 100644 (file)
index 0000000..744e9f2
--- /dev/null
@@ -0,0 +1,48 @@
+COMPILER = gcc
+DEBUG = -Wall -g
+SOURCES = ./src
+INCLUDE = include
+INCLUDE_ENGINE = ../../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0` -lsqlite3
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0` -I${INCLUDE} -I${INCLUDE_ENGINE} ${DEBUG}
+BINARIES = bin
+FINAL = ../../../bin/ws_bookmark.so
+
+
+${FINAL}: ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c
+               @gcc -shared -fPIC ${FLAGS} ${LIBS} ${BINARIES}/bookmark.o -o ${FINAL} 
+       
+${BINARIES}/bookmark.o: ${SOURCES}/engine_bookmark.c
+               @gcc -c -fPIC -o ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c ${FLAGS}
+               
+clean:
+               @-rm -f ${BINARIES}/*
+               @-rm -f ${FINAL}
+               @echo -e -n "Project's 'BookmarkEngine' directories has been cleaned.\n"
+       
+cleandata:
+               @-rm -f ws_bookmarks-journal
+               @-rm -f ws_bookmarks
+
+
+data: ${SOURCES}/testMakeDatabase.c
+               @echo -e -n "Compiling testDatabase...\n"
+               @gcc -o ${SOURCES}/testDatabase ${SOURCES}/testMakeDatabase.c ${FLAGS} ${LIBS}
+
+datarun: data
+               @run-standalone.sh src/testDatabase     
+       
+test: test.o
+               @echo "Linking test program..."
+               @gcc ${LIBS} ${DEBUG} -o ${SOURCES}/test ${BINARIES}/test.o
+               @echo -e "Building test program finished.\n"
+
+test.o:
+               @echo "Compiling test program..."
+               @gcc ${FLAGS} ${DEBUG} -c -o ${BINARIES}/test.o ${SOURCES}/test.c
+
+check:
+               @echo "Running test program:"
+               @run-standalone.sh  ${SOURCES}/test     
+       
+       
\ No newline at end of file
diff --git a/src/bookmarks/sql3/include/engine_bookmark.h b/src/bookmarks/sql3/include/engine_bookmark.h
new file mode 100644 (file)
index 0000000..ecea43f
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY_ENGINE_BOOKMARK
+#define _DICTIONARY_ENGINE_BOOKMARK
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - only for timers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header wit engine API
+#include "dictionary_engine.h"
+//------------------------------------------------------------------------------
+// header wit sqlite 2.x API
+#include <sqlite3.h>
+//------------------------------------------------------------------------------
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+static const gchar* DIC_ENG_VERSION = "0.1"; 
+static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
+static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' bookmarks.";
+                           
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _BookData {
+        sqlite3*                 db;
+        
+        gchar*                  dict_path;
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _BookData        BookData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+//static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// convert string to proper path name (no filename, no "/" at the ned, file
+// exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// tells if file is in XDXF format (file should exist)
+//static gboolean         is_xdxf_file(gchar* file); 
+//------------------------------------------------------------------------------
+// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+static double           timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+gboolean        bm_engine_add_word(Engine* engine,
+                                 gchar*  word,
+                                 gchar*  translation);
+//------------------------------------------------------------------------------
+gboolean        bm_engine_remove_word(Engine* engine,
+                                     gchar*  word);  
+//------------------------------------------------------------------------------      
+gchar*          bm_engine_get_lang_from(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_lang_to(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_title(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          bm_engine_get_icon_path(Engine* engine);
+
+
+
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        bm_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          bm_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          bm_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          bm_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         bm_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            bm_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          bm_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            bm_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        bm_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            bm_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        bm_engine_set_callback(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            bm_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            bm_engine_search_word_list(Engine* engine, gchar* pattern);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            bm_engine_search_word_translation(Engine* engine, gchar* word);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    bm_engine_status(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          bm_engine_status_message(EngineStatus error);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
diff --git a/src/bookmarks/sql3/src/engine_bookmark.c b/src/bookmarks/sql3/src/engine_bookmark.c
new file mode 100644 (file)
index 0000000..c722cb7
--- /dev/null
@@ -0,0 +1,1020 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_bookmark.h>
+//------------------------------------------------------------------------------
+
+#ifndef NOLOGS
+#include <glib/gstdio.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+#define LOGS g_debug
+
+/*inline void LOGS(gchar* frm, ...) {
+#ifndef NOLOGS
+       //g_printf(frm);
+#endif
+}*/
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION FROM API 0.2 !!!
+//==============================================================================
+int get_id(void* data,int n,char** argv,char** names) {
+        int len = strlen(&(argv[0][0]));
+        memcpy(data,&(argv[0][0]), len);
+        gchar* tmp = (gchar*)data;
+        tmp[len] = 0;
+        return 0;
+}
+
+gboolean bm_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) {
+        gint sql_res = 0;
+        gchar* err = NULL;
+        gboolean result = TRUE;
+        gchar* sql = NULL;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\ntranslation address: %p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word,
+             translation
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        g_assert(translation != NULL);
+
+        // start timer for this function
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+       BookData* data = (BookData*)(engine->engine_data);
+       sql = sqlite3_mprintf(
+               "INSERT INTO translations VALUES(NULL, '%q', '%q');",
+               word, translation);
+        sql_res = sqlite3_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while adding translation for word %s \nreason:%s\n\n", word, err);
+                result = FALSE;
+        } 
+        sqlite3_free(sql); sql = NULL;
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_remove_word(Engine* engine, gchar*  word) {
+        gint sql_res = 0;
+        gchar* err = NULL;
+        gboolean result = TRUE;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\n",(gchar*)__FILE__,(gchar*)__FUNCTION__,engine,word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+        BookData* data = (BookData*)(engine->engine_data);
+       gchar* sql = sqlite3_mprintf(
+               "DELETE FROM translations WHERE word LIKE '%q';", 
+                               word);
+       sql_res = sqlite3_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while deleting \'%s\' <-> reason:\n%s\n",word,err);
+                sqlite3_free(sql); sql = NULL;
+                return FALSE;
+        }
+        sqlite3_free(sql); sql = NULL;
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------      
+gchar* bm_engine_get_lang_from(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_lang_to(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_title(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strconcat(g_get_user_name(),"s' bookmarks",NULL);
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_icon_path(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("/usr/share/pixmaps/ws_eng_bookmark_icon.png");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION TO WRITE (NOT IMPLEMENTED YET)
+//==============================================================================
+
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void bm_engine_search_word_translation(Engine* engine, gchar* word)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:engine at adress=%p\n"
+             "-->PARAM:word=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start timer for this function
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       gchar* tmp = g_utf8_strdown(word,-1);
+        //sqlite3_vm* query;
+        gchar* sql = NULL;
+        gchar* tran = NULL;
+       sqlite3_stmt *query;//ppStmt
+       const char *pzTail;
+/*
+        sql = g_strconcat("SELECT * FROM translations WHERE "
+                          "word_id=(SELECT id FROM words WHERE word=\'",
+                          tmp,
+                          "\');",
+                          NULL);
+*/
+
+        /*sql = g_strconcat("SELECT * FROM translations WHERE word LIKE \'",
+                          tmp,
+                          "\';",
+                          NULL);*/
+       
+               sql = sqlite3_mprintf(
+                       "SELECT * FROM translations WHERE word LIKE '%q';",
+                       tmp);   
+       
+        g_debug("Query text: %s", sql);
+       gint sql_res = 0;
+       // const gchar* end;
+       //gchar* err = NULL;
+       sql_res = sqlite3_prepare(
+                       data->db,/* Database handle */
+                       (const gchar *)sql,/* SQL statement, UTF-8 encoded */
+                       -1,/* Length of zSql in bytes. */
+                       &query,/* OUT: Statement handle */
+                       &pzTail/* OUT: Pointer to unused portion of zSql */
+                       );
+       if (sql_res != SQLITE_OK)
+       {
+                LOGS("Error while compiling query:\n%s\nreason: %d\n",sql, sql_res);
+                 sqlite3_free(sql); sql = NULL;
+                data->cb_search_word_trans(NULL, NULL, 
+                                       data->cb_search_word_trans_data,
+                                       ENGINE_NO_ERROR);
+                 return;
+       }
+        gint status = 0;
+        gboolean first = TRUE;
+        do { 
+                first = TRUE;
+                do {
+                        if(!first) sleep(1);
+                        first = FALSE;
+                        status = sqlite3_step(query);
+                        if(status == SQLITE_ROW) {
+                                if (tran != NULL){
+                                       tran = g_strconcat(tran,"<BR><BR>", 
+                                               sqlite3_column_text(query, 2),
+                                               NULL);  
+                               }else{
+                                       tran = g_strdup_printf("%s <BR><BR>",
+                                               sqlite3_column_text(query, 2));
+                               }
+                               LOGS("Translation found :\n\"%s\"\n",tran);
+                               
+                        }
+                } while((status == SQLITE_BUSY) && (status != SQLITE_ERROR));
+        } while((status == SQLITE_ROW) && (status != SQLITE_ERROR));
+        sqlite3_finalize(query);
+
+        
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+
+        data->cb_search_word_trans(tran, word, data->cb_search_word_trans_data,
+                ENGINE_NO_ERROR);
+       sqlite3_free(sql); sql = NULL;
+        timer(TIMER_STOP,"callback for returning word's translation END");
+        if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                g_free(tran);
+        }
+        tran = NULL;
+}
+
+//------------------------------------------------------------------------------
+void bm_engine_close(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_assert(engine != NULL);
+        
+        BookData* data = (BookData*)(engine->engine_data);
+        sqlite3_close(data->db);
+        
+        LOGS("Bookmark/%s->%s() engine at adress=%p is deleted.\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_free(engine);
+        engine = NULL;
+}
+//------------------------------------------------------------------------------
+
+Engine* bm_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        LOGS("Bookmark/%s->%s() called.\n"
+             "-->PARAM:location=\'%s\'\n"
+             "-->PARAM:auto_cache=%d\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location,
+             (guint)auto_cache
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);        
+
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = bm_engine_location;
+        result->engine_is_optimized = bm_engine_is_optimized;
+        result->engine_optimize = bm_engine_optimize;
+        result->engine_search_word_list = bm_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        bm_engine_search_word_translation;        
+        result->engine_close = bm_engine_close;
+        result->engine_status = bm_engine_status;
+        result->engine_error_message = bm_engine_status_message;
+        result->engine_set_callback = bm_engine_set_callback;
+        result->engine_set_progress_seed = bm_engine_set_progress_seed;
+        result->engine_set_auto_free = bm_engine_set_auto_free;
+        // 0.2 API:
+        result->engine_add_word = bm_engine_add_word;
+        result->engine_remove_word = bm_engine_remove_word;
+        result->engine_get_lang_from = bm_engine_get_lang_from;
+        result->engine_get_lang_to = bm_engine_get_lang_to;
+        result->engine_get_title = bm_engine_get_title;
+        result->engine_get_icon_path = bm_engine_get_icon_path;
+
+
+        BookData* data = (BookData*)g_try_malloc(sizeof(BookData));
+        result->engine_data = (gpointer)data;
+
+        LOGS("Bookmark/%s->%s() opening file...\'%s\'.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        gchar* tmp2 = g_strconcat(tmp,"/ws_bookmarks3",NULL);
+        //gchar* err;
+       gint res = sqlite3_open(tmp2,&data->db);
+        g_free(tmp2); tmp2 = NULL;
+        if(res != SQLITE_OK) {
+                LOGS("Bookmark/%s->%s() opening bookmark file failed.%s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     sqlite3_errmsg(data->db)
+                    );
+                //g_free(err);
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+        else {
+                LOGS("Bookmark/%s->%s()opening dictionary file successed.\n",
+                        (gchar*)__FILE__,
+                        (gchar*)__FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+                // there is no cache mechanizm in bookmarks
+        }
+        g_free(tmp); tmp = NULL;
+        
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned Engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             result
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+
+
+static gboolean is_Bookmark_file(gchar* file) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 file
+               );
+        gchar* err = NULL;
+        sqlite3* tmp = NULL;
+       gint result = sqlite3_open(file, &tmp);
+        if(result != SQLITE_OK) {
+                LOGS("Wrong file! Not a sqlite database.\n");
+                //g_free(err);
+               sqlite3_close(tmp);
+                return FALSE;
+        }
+
+        
+        gchar sql[] = "SELECT COUNT(word) FROM translations WHERE word=\'.\';";  
+        result = sqlite3_exec(tmp, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                LOGS("Wrong database! Not a bookmark.\n");
+                g_free(err);
+               sqlite3_close(tmp);
+                return FALSE;
+        }
+       sqlite3_close(tmp);
+        return TRUE;
+}
+//------------------------------------------------------------------------------
+
+
+void bm_engine_optimize(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called for engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        LOGS("Unsupported optimization mechanizm for this engine!\n");
+        LOGS("Bookmark/%s->%s()'s work finished.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_check(gchar* location) 
+{        
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        gboolean result = TRUE;        
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+        
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                LOGS("Bookmark/%s->%s() location \'%s\' is not a proper "
+                     "path!\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     location
+                    );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/ws_bookmarks3",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                LOGS("Bookmark/%s->%s() finnal file to check is: %s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     filepath
+                    );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR)) {
+                        LOGS("Bookmark/%s->%s() file \'%s\' does not exists!\n",
+                             (gchar*)__FILE__,
+                             (gchar*)__FUNCTION__,
+                             filepath
+                            );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_Bookmark_file(filepath);
+        };
+
+        g_free(filepath);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+
+//------------------------------------------------------------------------------
+gboolean bm_engine_is_optimized(Engine* engine) 
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        g_assert(engine != NULL);                
+        gboolean result = FALSE;
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+void bm_engine_search_word_list(Engine* engine, gchar* pattern)
+{
+        LOGS("Bookmark/%s->%s() called. Searching words list\n"
+             "-->PARAM:engine at adress=%p\n"
+             "-->PARAM:pattern=\"%s\"\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             pattern
+            );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        BookData* data = (BookData*)(engine->engine_data);
+        if(data->cb_search_word_list == NULL) {
+                LOGS("Bookmark/%s->%s() callback for Word List not set. "
+                     "Searching aborted.\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+                return;
+        };
+
+        gchar* tmp = g_utf8_strdown(pattern,-1);
+       sqlite3_stmt *query;//ppStmt
+       const char *pzTail;
+        gchar* sql = NULL;
+        gchar* tran = NULL;
+       g_strstrip(tmp);
+       if ((int)(tmp[0]) == 42 && tmp[1] == '\0') //asterix?
+       {
+               sql = sqlite3_mprintf("SELECT DISTINCT word FROM translations;");
+       }
+       else
+       {
+               sql = sqlite3_mprintf(
+               "SELECT DISTINCT word FROM translations WHERE word LIKE'%q%%';", tmp);
+       }
+        /*sql = g_strconcat("SELECT word FROM translations WHERE "
+                          "word LIKE \'",tmp,"\%\';",NULL);*/
+        LOGS("QUERY: %s\n",sql);
+        gint sql_res = 0;
+       sql_res = sqlite3_prepare(
+                       data->db,/* Database handle */
+                       (const gchar *)sql,/* SQL statement, UTF-8 encoded */
+                       -1,/* Length of zSql in bytes. */
+                       &query,/* OUT: Statement handle */
+                       &pzTail/* OUT: Pointer to unused portion of zSql */
+                       );
+       if (sql_res != SQLITE_OK)
+       {
+               LOGS("Error while compiling query:\n%s\nreason:%d\n",sql,
+                                                               sql_res);
+               sqlite3_free(sql); sql = NULL;
+                return;
+       }
+       gint status = 0;
+        gboolean first = TRUE;
+        GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*) );
+        do { 
+                first = TRUE;
+                do {
+                        if(!first) sleep(1);
+                        first = FALSE;;
+                        /*status = sqlite3_step(
+                                        query, 
+                                        &nCol,            
+                                        &values,  
+                                        &head 
+                                        );*/
+                       status = sqlite3_step(query);
+                        if(status == SQLITE_ERROR) {
+                                LOGS("Error while making next step\n");
+                                sqlite3_free(sql); sql = NULL;
+                               data->cb_search_word_list(NULL , NULL, 
+                               data->cb_search_word_list_data, ENGINE_NO_ERROR);
+                                return;
+                        };
+                        /*if(status == SQLITE_ROW) {
+                                LOGS("Fount new word: \"%s\"\n",&(values[0][0]));
+                                gchar* tmp = g_strdup((gchar*)&(values[0][0]));
+                                g_array_append_val(result, tmp );        
+                        }*/
+                       if(status == SQLITE_ROW) {
+                               gchar* tmp = g_strdup(
+                                               sqlite3_column_text(query, 0));
+                                LOGS("Found new word: \"%s\"\n", tmp);
+                                g_array_append_val(result, tmp);
+                        }
+                } while((status == SQLITE_BUSY) && (status != SQLITE_ERROR));
+        } while((status == SQLITE_ROW) && (status != SQLITE_ERROR));
+        sqlite3_finalize(query);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+
+
+        timer(TIMER_START,"callback for returning words LIST START");
+        // calling callback for word translation
+
+        data->cb_search_word_list(result , pattern, 
+                       data->cb_search_word_list_data, ENGINE_NO_ERROR);
+                
+        timer(TIMER_STOP,"callback for returning word LIST END");
+        if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                g_free(tran);
+        }
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- COMPLETED FUNCTIONS
+//==============================================================================
+// global functions
+EngineModule engine_global_functions()
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       EngineModule result;        
+       result.engine_check             = bm_engine_check;
+       result.engine_description       = bm_engine_description;
+       result.engine_format            = bm_engine_format;
+       result.engine_version           = bm_engine_version;
+       result.engine_create            = bm_engine_create;
+       LOGS("Bookmark/%s->%s()returned EngineModule at adress=%p.\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+             result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_status_message(error)
+gchar* bm_engine_status_message(EngineStatus error) 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       switch (error) {
+               case ENGINE_NO_ERROR:
+                       return "No error.";
+               case ENGINE_WRONG_FILE:
+                       return "File which You are trying to use is wrong type.";
+               case ENGINE_COULDNT_READ:
+                       return "Could not read from file.";
+               case ENGINE_NO_FILE:
+                       return "There is no such a file.";
+               case ENGINE_OUT_OF_MEMORY:
+                       return "There were no enough memory for this action.";
+               default:
+                       return "Wrong engine's status identifier!";
+       }
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_version(module)
+gchar* bm_engine_version() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_VERSION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+               result
+              );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_format(module)
+gchar* bm_engine_format() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_description(module)
+gchar* bm_engine_description() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_location(engine)
+gchar* bm_engine_location(Engine* engine)
+{
+       LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       gchar* result;
+       if(data->auto_free) {
+               result = data->dict_path;
+       }
+       else {
+               result = g_strdup(data->dict_path);
+       }
+
+       LOGS("Bookmark/%s->%s() returned string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_auto_free(engine, state)
+void bm_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+            "-->PARAM:engine at adress=%p\n"
+            "-->PARAM:state=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine,
+            PRINT_STATE(state)
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       data->auto_free = state;
+       LOGS("Bookmark/%s->%s() Current auto_free is %s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            PRINT_STATE(data->auto_free)
+           );
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_last_status(engine)
+EngineStatus bm_engine_status(Engine* engine) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+               "-->PARAM:engine at adress=%p\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+              engine
+              );
+       BookData* data = (BookData*)(engine->engine_data);
+       LOGS("Bookmark/%s->%s() returned error code: %d\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            (gint)(data->last_error)
+           );        
+       return data->last_error;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_progress_seed(engine, signal, val)
+void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               data->cb_progress_caching_seed = seed;
+               LOGS("Bookmark/%s->%s() sets new seed=%0.2f for for signal "
+                    "\"%s\".\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    seed,
+                    signal
+                   );        
+       } 
+       else {
+               LOGS("Bookmark/%s->%s() unsupported signalfor progress: %s.\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    signal
+                   );
+       };
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_callback(engine,signal,c_handler,data)
+gpointer bm_engine_set_callback(Engine* engine,
+                            gchar* signal,
+                            gpointer c_handler,
+                            gpointer user_data)
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       g_assert(engine != NULL);
+       g_assert(signal != NULL);
+       g_assert(c_handler != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               gpointer result = data->cb_progress_caching;
+               data->cb_progress_caching = c_handler;
+               data->cb_progress_caching_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+               gpointer result = data->cb_search_word_list;
+               data->cb_search_word_list = c_handler;
+               data->cb_search_word_list_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                        
+       }
+       else if(g_ascii_strcasecmp(signal,
+               ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                       gpointer result = data->cb_search_word_trans;
+                       data->cb_search_word_trans = c_handler;
+                       data->cb_search_word_trans_data = user_data;
+                       LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               signal
+                              );
+                       LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)c_handler
+                              );
+                       LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)user_data
+                              );
+                       return result;                        
+               }
+               else {
+                       g_warning("Bookmark/%s->%s() unsupported signal: %s.\n",
+                                 (gchar*)__FILE__,
+                                 (gchar*)__FUNCTION__,
+                                 signal
+                                );
+                       return NULL;
+               }
+}
+
+
+
+
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- HELPFULLY FUNCTIONS
+//==============================================================================
+
+//------------------------------------------------------------------------------
+static gchar* string_to_path(gchar** string) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        LOGS("Bookmark/%s->%s() returned string=\'%s\'\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static double timer(gboolean start, gchar* message)
+{
+       static GArray* stack = NULL;
+       static gboolean first_run = TRUE;
+       static struct timeval actual_time;
+       static struct timeval last_time;
+       static struct timeval result;
+       static double seconds = 0.0;
+       if(first_run) {
+               first_run = FALSE;
+               stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+       };        
+
+       if (start) {
+               LOGS("Bookmark->%s() start timer for function '%s()'.\n",
+                       (gchar*)__FUNCTION__,
+                       message
+                      );
+               g_array_prepend_val(stack, actual_time);
+               gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+               return -1.0;
+       }
+        // we just want to end some timer - print some information about 
+        // working time;
+       else {          
+               gettimeofday(&actual_time,NULL);
+               last_time = g_array_index(stack, struct timeval, 0);
+               g_array_remove_index(stack, 0);
+
+               if (actual_time.tv_usec < last_time.tv_usec) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       (1000000 + 1);
+                       last_time.tv_usec -= 1000000 * nsec;
+                       last_time.tv_sec += nsec;
+               }
+               if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       1000000;
+                       last_time.tv_usec += 1000000 * nsec;
+                       last_time.tv_sec -= nsec;
+               }
+               result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+               result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+               seconds = (((double)(result.tv_usec)) / 1e6) +
+                               ((double)(result.tv_sec));
+
+               LOGS("Bookmark->%s() function \'%s()\' was working for: %g "
+                               "[s] or %ld [us].\n",
+               (gchar*)__FUNCTION__,
+               message,
+               seconds,
+               ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                      );
+                // stack is empty so we delete everything
+               if(stack->len == 0)   
+               {
+                       g_array_free(stack, TRUE);
+                       first_run = TRUE;
+               }
+       }
+       return seconds;
+}
+//------------------------------------------------------------------------------
+
+
+
diff --git a/src/bookmarks/sql3/src/test.c b/src/bookmarks/sql3/src/test.c
new file mode 100644 (file)
index 0000000..b89a9a7
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+        printf("--------------------------------------------------\n");
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "StarDictEngine test: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library) {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       //dict_eng_module_get_global_functions(library,get_functions);
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+
+       EngineModule module = get_functions();
+       printf("Module description: %s\n",dict_eng_module_get_description(module));
+       Engine* sd;
+
+        gboolean is_compatible = dict_eng_module_check(module,"/home/str/whitestork/engines/bookmark/ws_bookmarks");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+
+       //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
+
+       //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
+       //home/stranger/whitestork/engine0.2/
+//     xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
+//     dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
+//     dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
+
+/*     if(dict_eng_is_optimized(xdxf) == FALSE)
+       {
+               printf("Dictionary has no cache!\nCreating cache file....\n");
+               dict_eng_optimize(xdxf);
+       }
+       else {
+               printf("Dictionary has already cache file!\n");
+       }*/
+        sd = dict_eng_module_create(module,
+            "/home/str/whitestork/engines/bookmark/ws_bookmarks" ,
+             ENGINE_CREATE);
+       printf("Lokacja: %s\n",dict_eng_get_location(sd));
+
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_TRANSLATION_SIGNAL ,
+                             print_translation,
+                             "Translation for word\'%s\':\n");
+       
+       dict_eng_search_word_list(sd,"12");
+       //dict_eng_search_word_translation(sd,"1 word");
+        
+        dict_eng_remove_word(sd, "stranger");
+       dict_eng_remove_word(sd, "gandzia");
+       dict_eng_remove_word(sd, "lukas");
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_add_word(sd, "gandzia", "rulez");
+        dict_eng_add_word(sd, "lukas", "pawlik");
+        dict_eng_remove_word(sd, "stranger");
+
+        dict_eng_search_word_translation(sd,"stranger");
+       
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_search_word_translation(sd,"stranger");
+        dict_eng_search_word_list(sd,"gandzia");
+
+        printf("Lang FROM:%s\n",dict_eng_get_lang_from(sd));
+        printf("  Lang TO:%s\n",dict_eng_get_lang_to(sd));
+        printf("    Title:%s\n",dict_eng_get_title(sd));
+        printf("Icon path:%s\n",dict_eng_get_icon_path(sd));
+       
+       dict_eng_destroy(sd);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/bookmarks/sql3/src/testMakeDatabase.c b/src/bookmarks/sql3/src/testMakeDatabase.c
new file mode 100644 (file)
index 0000000..7ca65e1
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <sqlite.h>
+
+const guint records_number = 1000;
+
+// ----------------------------------------------------------------------------------
+sqlite* database_make(gchar* path) {
+        gchar* buffer = NULL;
+        sqlite* result = NULL;
+        // creatingh database
+        result = sqlite_open(path,
+                             0600,
+                             &buffer);
+        // check if everything was okey
+        if(!result) {
+                g_printf("Error while trying to create database:\n%s\n",buffer);
+                g_free(buffer); buffer = NULL;
+                return NULL;
+        };
+        // return pointer to database
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_table(sqlite* db) {
+        gint result = 0;
+        //gchar sql[] = "CREATE TABLE words(id INTEGER PRIMARY KEY, word TEXT UNIQUE);";
+        gchar sql2[] = "CREATE TABLE translations(id INTEGER PRIMARY KEY, word TEXT, translation TEXT);";
+        gchar* err = NULL;      
+/*
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'words\' table:\n%s\n",err);
+                return 1;
+        }
+*/
+        result = sqlite_exec(db, sql2, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'translations\' table:\n%s\n",err);
+                return 2;
+        }
+
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_record(sqlite* db, guint i) {
+        gint result = 0;
+        gchar* sql = NULL;
+        gchar* err = NULL;
+        gint last_id = 0;
+        gint word_count = 1;
+        gchar buffer[] = "                     ";
+        gchar last_char[] = "                      ";
+        gchar tran[] = "this is a translation number 10.000 for word 10.000 word <-----";
+        g_sprintf(buffer,"%d word",i);
+/*
+        sql = g_strconcat("INSERT INTO words VALUES(NULL,\'",buffer,"\');", NULL);        
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while trying to add new word %d:\n%s\n",i,err);
+                g_free(sql);
+                return 1;
+        }
+        g_free(sql);
+        last_id = sqlite_last_insert_rowid(db);
+        g_sprintf(last_char,"%d",last_id);
+*/
+        if(i == 5000) {
+                word_count = 5;
+                g_printf("Adding more records for word - test\n");
+        }
+        gint j;
+        for(j=0; j<word_count; ++j) {
+                g_sprintf(tran,"this is a translation number %d for word %i",j,i);
+                sql = g_strconcat("INSERT INTO translations VALUES(NULL,\'",buffer,"\',\'",tran,"\');", NULL); 
+                result = sqlite_exec(db, sql, NULL, NULL, &err); 
+                if(err || result!=0) {
+                        g_printf("Error while trying to add new word trans %d:\n %s \n",j,err);
+                        g_free(sql);
+                        return 1;
+                }
+                g_free(sql);             
+        }
+        
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint main(gint argc, gchar* argv[]) {
+        g_printf("Making new database with %d records...\n",records_number);
+        
+        // create database
+        sqlite* db = database_make("ws_bookmarks");
+        if(!db) return 1;
+
+        // create table for records
+        database_add_test_table(db);
+
+        // create testing records
+        guint i;
+        gint code = 0;
+        for(i=0; i<records_number; ++i) {
+                code = database_add_test_record(db, i);
+                // if there were some errors, do not continue
+                if(code != 0) break;
+                // give to the user some feedback about progress of proccess
+                if(!(i % 50)) {
+                        g_printf("%d / %d records already added to database\n",i,records_number);
+                }
+        }
+
+        // close database
+        sqlite_close(db);
+        return 0;
+}
+// ----------------------------------------------------------------------------------
diff --git a/src/bookmarks/xdxf/COPYING b/src/bookmarks/xdxf/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/bookmarks/xdxf/Makefile b/src/bookmarks/xdxf/Makefile
new file mode 100644 (file)
index 0000000..aeb665e
--- /dev/null
@@ -0,0 +1,44 @@
+COMPILER = gcc
+DEBUG = -Wall -g
+SOURCES = ./src
+INCLUDE = include
+INCLUDE_ENGINE = ../../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0 gnome-vfs-2.0`
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0 gnome-vfs-2.0` -I${INCLUDE} -I${INCLUDE_ENGINE} ${DEBUG}
+BINARIES = bin
+FINAL = ../../../bin/ws_bookmark.so
+
+
+${FINAL}: ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c
+               @gcc -shared -fPIC ${FLAGS} ${LIBS} ${BINARIES}/bookmark.o -o ${FINAL} 
+       
+${BINARIES}/bookmark.o: ${SOURCES}/engine_bookmark.c
+               @gcc -c -fPIC -o ${BINARIES}/bookmark.o ${SOURCES}/engine_bookmark.c ${FLAGS}
+               
+clean:
+               @-rm -f ${BINARIES}/*
+               @-rm -f ${FINAL}
+               @echo -e -n "Project's 'BookmarkEngine' directories has been cleaned.\n"
+       
+cleandata:
+               @-rm -f ws_bookmarks-journal
+               @-rm -f ws_bookmarks
+
+
+data: ${SOURCES}/testMakeDatabase.c
+               @echo -e -n "Compiling testDatabase...\n"
+               @gcc -o ${SOURCES}/testDatabase ${SOURCES}/testMakeDatabase.c ${FLAGS} ${LIBS}
+
+datarun: data
+               @run-standalone.sh src/testDatabase     
+       
+test: 
+               @echo "Linking test program..."
+               @gcc ${LIBS} ${DEBUG}  ${SOURCES}/test.c -o ${BINARIES}/test ${FLAGS}
+               @echo -e "Building test program finished.\n"
+
+check:
+               @echo "Running test program:"
+               @run-standalone.sh  ${SOURCES}/test     
+       
+       
\ No newline at end of file
diff --git a/src/bookmarks/xdxf/include/engine_bookmark.h b/src/bookmarks/xdxf/include/engine_bookmark.h
new file mode 100644 (file)
index 0000000..285cc2a
--- /dev/null
@@ -0,0 +1,326 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY__XDXF
+#define _DICTIONARY_ENGINE_XDXF
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - onl for timers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>     
+#include <unistd.h>   
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header with gnome-vfs - recommended I/O API for maemo
+#include <libgnomevfs/gnome-vfs.h>
+//------------------------------------------------------------------------------
+// header with expat - XML Parser API
+#include <expat.h>
+//------------------------------------------------------------------------------
+// header wit engine API
+#include <dictionary_engine.h>
+//------------------------------------------------------------------------------
+#include <stdio.h>
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+static const gchar* DIC_ENG_VERSION = "0.1"; 
+static const gchar* DIC_ENG_FORMAT = "Users' Bookmarks";
+static const gchar* DIC_ENG_DESCRIPTION = "This module handles users' bookmarks.";
+//------------------------------------------------------------------------------
+// defines lenght of buffers for particular functions in engine which needs
+// big buffers
+#define DICT_CACHEING_BUFF_SIZE                 16*1024
+#define DICT_SEARCHING_WORD_LIST_BUFF_SIZE      16*1024
+#define DICT_SEARCHING_WORD_TRAN_BUFF_SIZE      16*1024
+//------------------------------------------------------------------------------
+// maximum length of word possible to find in any dictionary
+#define DICT_MAX_WORD_LENGTH   512
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Structure used while dict_eng_module_check() is working.
+ */
+struct _XDXFCheckingData {
+        gboolean        further;
+        gboolean        good;
+        guint                deep;
+};
+typedef struct _XDXFCheckingData        XDXFCheckingData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help parse xdxf file for searching words list.
+ */
+struct _XDXFWordsListData {
+        gchar* last_word;
+        gchar* pattern;
+        guint  pattern_len;
+        guint  last_word_length;
+        GArray* result;
+        guint  one_word;
+        gboolean cont;
+};
+typedef struct _XDXFWordsListData       XDXFWordsListData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help parse xdxf file for searching word's translation.
+ */
+struct _XDXFWordsTransData {
+        gchar* last_word;
+        gchar* word;
+        guint  word_len;
+        guint  last_word_length;
+        gchar* translation;
+        guint  one_word;
+        gboolean cont;
+        gulong last_start;
+        XML_Parser* parser;
+        gboolean found;
+        GnomeVFSHandle*        xdxf;
+};
+typedef struct _XDXFWordsTransData      XDXFWordsTransData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help make optimization possible
+ */
+struct _XDXFCacheData {
+        gchar* buffer;
+        long last_start;
+        long last_stop;
+        long last_length;
+        GnomeVFSHandle* cache;
+        XML_Parser parser;
+        int state;
+        long buffer_length;
+};
+typedef struct _XDXFCacheData           XDXFCacheData;
+//------------------------------------------------------------------------------
+/** \brief Internal data structure for representing part of file.
+ */
+struct _FilePart {
+        guint offset;
+        guint length;
+};
+typedef struct _FilePart        FilePart;
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _XDXFData {
+        GnomeVFSHandle*         xdxf;
+        GnomeVFSHandle*         cache;
+        gchar*                  dict_path;
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _XDXFData        XDXFData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//*************************************************** PARSING FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// while is_bm_file() is working
+static void     is_bm_file_start(void *data,
+                                   const char *el,
+                                   const char **attr);
+static void     is_bm_file_end(void *data,  const char *el);
+//------------------------------------------------------------------------------                                                 
+// while dict_eng_search_word_list() is working
+static void     search_word_list_start(void *data,
+                                       const char *el,
+                                       const char **attr); 
+static void     search_word_list_end(void *data, const char *el);
+static void     search_word_list_text(void *data, const XML_Char *txt, int len);
+//------------------------------------------------------------------------------
+// // while dict_eng_search_word_translation() is working
+static void     search_word_trans_start(void *data,
+                                        const char *el,
+                                        const char **attr);
+static void     search_word_trans_end(void *data, const char *el);                             
+static void     search_word_trans_text(void *data,
+                                       const XML_Char *txt,
+                                       int len);
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+//convert string to proper path name (no filename, no "/" at the ned, file exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// tells if file is in XDXF format (file should exist)
+static gboolean         is_bm_file(gchar* file); 
+//------------------------------------------------------------------------------
+// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+static double           timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+// return size of files
+static guint64          get_file_size(GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// return how many records (from cache file) are in current buffer a with length
+// length.
+static guint            get_max_length(gchar* a, guint length);
+//------------------------------------------------------------------------------
+// return translation of word using cache file
+static gchar* word_translation_cache(XDXFData* data, gchar* word);
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static gchar* word_translation_xdxf(XDXFData* data, gchar* word);
+//------------------------------------------------------------------------------
+
+// return translation of word using cache file
+static void word_list_cache(XDXFData* data, gchar* pattern, GArray* result);
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static void word_list_xdxf(XDXFData* data, gchar* pattern, GArray* result);
+//------------------------------------------------------------------------------
+
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        bm_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          bm_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          bm_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          bm_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         bm_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            bm_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          bm_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            bm_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        bm_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            bm_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        bm_engine_set_callbacks(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            bm_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            bm_engine_search_word_list(Engine* engine, gchar* pattern);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            bm_engine_search_word_translation(Engine* engine, gchar* word);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation_extended(engine,word)
+// function
+void            bm_engine_search_word_translation_extended(Engine* engine,
+                                                        gchar* word);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    bm_engine_error(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          bm_engine_error_message(EngineStatus error);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+// API 2.0
+gboolean       bm_engine_add_word(Engine* engine,
+                               gchar*  word,
+                               gchar*  translation);
+
+gboolean       bm_engine_remove_word(Engine* engine, gchar*  word);
+
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/bookmarks/xdxf/src/engine_bookmark.c b/src/bookmarks/xdxf/src/engine_bookmark.c
new file mode 100644 (file)
index 0000000..4800ab2
--- /dev/null
@@ -0,0 +1,1995 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_bookmark.h>
+#include <string.h>
+//------------------------------------------------------------------------------
+#define LOGS g_debug
+#define g_strlen(string) ( NULL == (string) ? 0 : strlen(string) )
+// searching word translation in cache file
+static void caching_expat_start(void *data, const char *el, const char **attr);
+static void caching_expat_end(void *data, const char *el);
+static void caching_expat_text(void *data, const XML_Char *txt, int len);
+static gchar* word_translation_cache(XDXFData* data, gchar* word)
+{
+        gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);
+        gchar b[DICT_SEARCHING_WORD_TRAN_BUFF_SIZE + 1];
+        GnomeVFSFileSize bytes_readed;
+
+        guint word_length = g_strlen(word);
+        guint record_length = 0;
+        guint trans_offset = 0;
+        guint already = 0;
+        guint64 readed = 0;
+        gchar* buffer = NULL;
+        gchar* trans = NULL;
+        guint file_size = get_file_size(data->cache);
+        if (file_size > 0){
+       while(TRUE) {
+                gnome_vfs_read(data->cache,
+                               b,
+                               DICT_SEARCHING_WORD_TRAN_BUFF_SIZE,
+                               &bytes_readed
+                              );
+                guint max_length = (guint)get_max_length(b,bytes_readed);
+                readed += max_length;
+                buffer = b;
+                already = 0;
+                while(already < max_length) {
+                        memcpy(&record_length, buffer, sizeof(guint));
+                        memcpy(&trans_offset,
+                                buffer+record_length-2*sizeof(guint),
+                                sizeof(guint)
+                              );
+                        buffer[record_length-sizeof(guint)*2] = '\0';
+                        if(((record_length - 3*sizeof(guint)) == word_length) &&
+                           (g_utf8_collate(word,buffer+sizeof(guint)) == 0)) {
+                                FilePart translation = {0,0};
+                                translation.offset = trans_offset;
+                                memcpy(&(translation.length),
+                                        buffer + record_length - sizeof(guint),
+                                        sizeof(guint)
+                                      );
+                                trans =read_file_part(&translation, data->xdxf);
+                                break;
+                        };
+                        already += record_length;
+                        buffer += record_length;
+                };
+
+                if( ( bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE ) || 
+                      ( readed > (file_size - 3) )) {
+                        break;
+                      };
+                      gnome_vfs_seek(data->cache,
+                                     GNOME_VFS_SEEK_CURRENT,
+                                     ((gint)max_length) - 
+                                          DICT_SEARCHING_WORD_TRAN_BUFF_SIZE
+                                    );
+        }
+       }
+        return trans;
+}
+//------------------------------------------------------------------------------
+// searching word translation in xdxf dictionary
+static gchar* word_translation_xdxf(XDXFData* data, gchar* word) {
+        guint word_length = strlen(word);
+        gchar* trans = NULL;
+        gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 0);
+        GnomeVFSResult vfs_result;
+        GnomeVFSFileSize bytes_readed = DICT_SEARCHING_WORD_TRAN_BUFF_SIZE;                
+        gchar buffer[DICT_SEARCHING_WORD_TRAN_BUFF_SIZE+1];                
+        guint64 file_size = get_file_size(data->xdxf);
+                //guint word_len = strlen(word); added by me
+                
+        XML_Parser parser = XML_ParserCreate(NULL);        
+        if (!parser) {
+                g_warning("%s->%s() Could not open initialize "
+                          "XML parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return NULL;
+        };
+
+        gchar tmp[DICT_MAX_WORD_LENGTH];
+        XDXFWordsTransData search_data = {tmp,
+                                          word,
+                                          word_length,
+                                          0,
+                                          NULL,
+                                          FALSE,
+                                          TRUE,
+                                          0,
+                                          &parser,
+                                          FALSE,
+                                          data->xdxf
+                                         };
+        XML_SetElementHandler(parser,
+                              search_word_trans_start,
+                              search_word_trans_end
+                             );
+        XML_SetCharacterDataHandler(parser, search_word_trans_text);
+                
+        XML_SetUserData(parser, &search_data);
+
+        //gdouble last_prog = 0;
+        while(TRUE) {
+                vfs_result = gnome_vfs_read(data->xdxf,
+                                            buffer,
+                                            DICT_SEARCHING_WORD_TRAN_BUFF_SIZE,
+                                            &bytes_readed
+                                           );
+                XML_Parse(parser,
+                          buffer,
+                          bytes_readed,
+                          bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE
+                         );
+                        
+                gdouble last_prog = 0.0;
+                if(data->cb_progress_word_trans != NULL) {
+                        GnomeVFSFileSize act_pos;
+                        gnome_vfs_tell(data->xdxf, &act_pos);
+                        gdouble progress = 
+                                ((gdouble)act_pos)/((gdouble)file_size);
+                        if((( (progress - last_prog)/
+                              (data->cb_progress_word_trans_seed) ) > 1.0) ||
+                            (progress >= 1.0)) {
+                                data->
+                                cb_progress_word_trans(progress,
+                                              data->cb_progress_word_trans_data,
+                                              ENGINE_NO_ERROR
+                                                      );
+                                last_prog = progress;
+                        };
+                }
+                if(bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE) {
+                        break;
+                }
+                if(search_data.cont == FALSE) {
+                        break;
+                }
+        }
+        XML_ParserFree(parser);
+        trans = search_data.translation; 
+        return trans;        
+}
+
+//------------------------------------------------------------------------------
+// get position of a word in order to add this word to bookmarks
+/*GnomeVFSFileSize*/
+static FilePart get_adding_position(XDXFData* data, 
+                       gchar* word)
+{
+        
+       
+       g_debug("%s<->", __FUNCTION__);
+       gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);
+        gchar b[DICT_SEARCHING_WORD_TRAN_BUFF_SIZE + 1];
+        GnomeVFSFileSize bytes_readed;
+
+        //guint word_length = g_strlen(word);
+        guint record_length = 0;
+        guint trans_offset = 0;
+        guint already = 0;
+        guint64 readed = 0;
+        gchar* buffer = NULL;
+        gchar* trans = NULL;
+       
+//     g_printf ("\n\ncache: %p\n", data->cache);
+       
+//     return 0;
+       gchar* down_word = g_utf8_strdown(word, -1);
+       guint file_size = get_file_size(data->cache);
+       if (file_size > 0){
+       while(TRUE) {
+                gnome_vfs_read(data->cache,
+                               b,
+                               DICT_SEARCHING_WORD_TRAN_BUFF_SIZE,
+                               &bytes_readed
+                              );
+                guint max_length = (guint)get_max_length(b,bytes_readed);
+                readed += max_length;
+                buffer = b;
+                already = 0;
+                while(already < max_length) {
+                        memcpy(&record_length, buffer, sizeof(guint));
+                        memcpy(&trans_offset,
+                                buffer+record_length-2*sizeof(guint),
+                                sizeof(guint)
+                              );
+                        buffer[record_length-sizeof(guint)*2] = '\0';
+                       gboolean test = 
+                               g_utf8_collate(buffer+sizeof(guint), down_word);
+                       g_debug("And here is the buffer content: %s\nCompare result of word %d which is %s", 
+                               buffer+sizeof(guint), test, down_word);
+                        if(/*((record_length - 3*sizeof(guint)) == word_length) &&*/
+                           test >= 0)
+                       {
+                                FilePart translation = {0,0};
+                                translation.offset = trans_offset;
+                                memcpy(&(translation.length),
+                                        buffer + record_length - sizeof(guint),
+                                        sizeof(guint)
+                                      );
+                                trans =read_file_part(&translation, data->xdxf);
+                               return translation/*translation.offset + translation.length*/;  
+       
+                        };
+                        already += record_length;
+                        buffer += record_length;
+                };
+
+                if( ( bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE ) || 
+                      ( readed > (file_size - 3) )) {
+                        break;
+                      };
+                      gnome_vfs_seek(data->cache,
+                                     GNOME_VFS_SEEK_CURRENT,
+                                     ((gint)max_length) - 
+                                          DICT_SEARCHING_WORD_TRAN_BUFF_SIZE
+                                    );
+        }
+       }
+       guint64 tmp_offset = get_file_size(data->xdxf) - g_strlen("</xdxf>");
+       //g_debug("TMP_OFFSET: %ld", tmp_offset);
+       FilePart translation = {tmp_offset,0};
+       return /*trans_offset*/translation;
+}
+
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void bm_engine_search_word_translation(Engine* engine, gchar* word)
+{
+        g_debug("%s->%s() called.\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:word=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 engine,
+                 word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start timer for this function
+        timer(TIMER_START, (gchar*)__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        // if callback is not set, we do not have to search word
+        if(data->cb_search_word_trans == NULL) {
+                g_warning("%s->%s() callback for Word Translation not set."
+                          " Searching aborted.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                // do not send any signal, just exit
+                return;                
+        };
+        
+        //guint word_length = strlen(word);
+        gchar* trans;
+
+        // dictionary is optimized
+        if(data->cache != NULL) {
+                trans = word_translation_cache(data, word);
+        // dictionary is not optimized right now
+        } else 
+        {        
+                trans = word_translation_xdxf(data, word);                
+        };
+
+        g_debug("%s->%s() found for word \'%s\' translation:\n\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                word,
+                trans
+               );
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+        data->cb_search_word_trans(trans,
+                                   word,
+                                   data->cb_search_word_trans_data,
+                                   ENGINE_NO_ERROR
+                                  );
+        timer(TIMER_STOP,"callback for returning word's translation END");
+        if(data->auto_free) {
+                g_debug("%s->%s() deleting all dynamic data because "
+                        "AUTO_FREE=TRUE\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                g_free(trans);
+        }
+        trans = NULL;
+       return;
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_remove_word(Engine* engine,
+                             gchar*  word)
+{
+       g_debug("%s <-> %s()", __FILE__, __FUNCTION__);
+       GnomeVFSResult vfs_result;
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+       GnomeVFSHandle* swap_xdxf;
+       vfs_result = 
+                gnome_vfs_create(&(swap_xdxf), "/media/mmc1/swap_xdxf.xdxf", 
+                       GNOME_VFS_OPEN_WRITE | 
+                       GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM, 
+                       FALSE, 0666);   
+        if(vfs_result != GNOME_VFS_OK)  {
+                g_warning("%s->%s() opening dictionary file failed"
+                                " due to reason: %s.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                gnome_vfs_result_to_string(vfs_result)
+                                );
+               return FALSE;
+       }
+        
+       FilePart position_part = get_adding_position (data, word);
+       //GnomeVFSFileSize position = position_part.offset /*+ position_part.length*/;
+       //guint64 file_size = get_file_size(data->cache);
+       gchar read_buffer[DICT_CACHEING_BUFF_SIZE + 1];
+       GnomeVFSFileSize read_size = DICT_CACHEING_BUFF_SIZE;
+       GnomeVFSFileSize read_bytes_size = DICT_CACHEING_BUFF_SIZE;
+       GnomeVFSFileSize bytes_written;
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                               position_part.offset + position_part.length);
+       /*Write form position to the end of the file*/
+//     GnomeVFSFileSize position = position_part.offset
+       
+       while(TRUE)
+       {
+               g_debug(":Working around in writing the tail:");
+               
+               gnome_vfs_read(data->xdxf/*GnomeVFSHandle */,
+                               read_buffer/*buffer*/,
+                                read_size/*GnomeVFSFileSize*/,
+                                &read_bytes_size/*GnomeVFSFileSize*/);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               vfs_result = gnome_vfs_write(swap_xdxf,
+                               read_buffer,
+                               read_bytes_size,
+                                &bytes_written);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               if (read_bytes_size < DICT_CACHEING_BUFF_SIZE) break;
+       }
+       
+       //g_printf (">>> %s %d %s<<<\n", word, position, data->dict_path);
+       //gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, position_part.offset);
+       
+       gnome_vfs_truncate_handle(data->xdxf, position_part.offset);
+       
+       read_bytes_size = DICT_CACHEING_BUFF_SIZE;
+       read_size = DICT_CACHEING_BUFF_SIZE + 1 ;
+       //bytes_written = DICT_CACHEING_BUFF_SIZE;
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, position_part.offset);
+       gnome_vfs_seek(swap_xdxf, GNOME_VFS_SEEK_START, 0);
+       while(TRUE)
+       {
+               g_debug(":Working around in writing back the tail:");
+               
+               gnome_vfs_read(swap_xdxf/*GnomeVFSHandle */,
+                               read_buffer/*buffer*/,
+                                read_size/*GnomeVFSFileSize*/,
+                                &read_bytes_size/*GnomeVFSFileSize*/);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               vfs_result = gnome_vfs_write(data->xdxf,
+                               read_buffer,
+                               read_bytes_size,
+                                &bytes_written);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+//             g_return_val_if_fail(vfs_result != GNOME_VFS_OK, FALSE);
+               if (read_bytes_size < DICT_CACHEING_BUFF_SIZE) break;
+       }
+       gnome_vfs_close(swap_xdxf); 
+       gnome_vfs_unlink("/media/mmc1/swap_xdxf.xdxf");
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                       0);
+       gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 
+                       0);
+       gnome_vfs_close(data->cache); 
+       gchar* cache_path = g_strconcat(data->dict_path, "/ws_bookmarks.cache", NULL);
+       gnome_vfs_unlink(cache_path);
+       bm_engine_optimize(engine);
+       g_free(cache_path);
+       return TRUE;
+}
+
+gboolean bm_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) 
+{
+       g_debug("%s -> %s()", __FILE__, __FUNCTION__);
+       
+        //guint word_length = strlen(word);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        GnomeVFSResult vfs_result;
+       GnomeVFSHandle* swap_xdxf;
+       vfs_result = 
+                gnome_vfs_create(&(swap_xdxf), "/media/mmc1/swap_xdxf.xdxf", 
+                       GNOME_VFS_OPEN_WRITE | 
+                       GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM, 
+                       FALSE, 0666);   
+        if(vfs_result != GNOME_VFS_OK)  {
+                g_warning("%s->%s() opening dictionary file failed"
+                                " due to reason: %s.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                gnome_vfs_result_to_string(vfs_result)
+                                );
+               return FALSE;
+       }
+       
+       
+//     guint64 file_size = get_file_size(data->xdxf);
+       FilePart position_part = get_adding_position(data, word);
+       GnomeVFSFileSize position = 
+                       position_part.offset/* + position_part.length*/;
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                               position);
+       gchar read_buffer[DICT_CACHEING_BUFF_SIZE + 1];
+       GnomeVFSFileSize read_size = DICT_CACHEING_BUFF_SIZE + 1 ;
+       GnomeVFSFileSize read_bytes_size = DICT_CACHEING_BUFF_SIZE;
+       GnomeVFSFileSize bytes_written;
+       /*Write form position to the end of the file*/
+       while(TRUE)
+       {
+               g_debug(":Working around in writing the tail:");
+               
+               vfs_result = gnome_vfs_read(data->xdxf/*GnomeVFSHandle */,
+                               read_buffer/*buffer*/,
+                                read_size/*GnomeVFSFileSize*/,
+                                &read_bytes_size/*GnomeVFSFileSize*/);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               //g_return_val_if_fail(vfs_result != GNOME_VFS_OK, FALSE);
+               vfs_result = gnome_vfs_write(swap_xdxf,
+                               read_buffer,
+                               read_bytes_size,
+                                &bytes_written);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               //g_return_val_if_fail(vfs_result != GNOME_VFS_OK, FALSE);
+               if (read_bytes_size < DICT_CACHEING_BUFF_SIZE) break;
+       }
+       /*End write*/
+       /*Write new entry*/
+       /*gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                       position);*/
+       gchar* buffer = NULL;
+       /*Testing if the adding word is in bookmark file*/
+       gchar* search_pattern = g_strconcat("<k>", word, "</k>", NULL);
+       //gint search_pattern_len = g_strlen(search_pattern);
+       gchar read_word[position_part.length + 1];
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                               position_part.offset);
+       gnome_vfs_read(data->xdxf/*GnomeVFSHandle */,
+                       read_word/*buffer*/,
+                        position_part.length/*GnomeVFSFileSize*/,
+                        &read_bytes_size/*GnomeVFSFileSize*/);
+       gchar* cmp_result = g_strrstr(read_word /*haystack*/,
+                                        search_pattern/*needle*/);
+       if (cmp_result != NULL)
+       {
+               
+               gchar** tmp = g_strsplit(translation,
+                                        "</k>",
+                                        2);
+               gchar* tmp2 = g_strndup(tmp[1], 
+                               g_strlen(tmp[1]) - g_strlen("</ar>"));
+               gchar* tmp3 = g_strndup(read_word, 
+                               g_strlen(read_word) - g_strlen("</ar>"));
+               buffer = g_strconcat(tmp3, tmp2, "</ar>", NULL);
+               g_strfreev(tmp);
+               g_free(tmp2);
+               g_free(tmp3);
+               gnome_vfs_seek(swap_xdxf, GNOME_VFS_SEEK_START, 
+                       position_part.length);
+       }else
+       {
+               buffer = g_strdup(translation); 
+               gnome_vfs_seek(swap_xdxf, GNOME_VFS_SEEK_START, 0);
+       }
+       /*End of testing*/
+       gnome_vfs_truncate_handle(data->xdxf, position_part.offset);
+               gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_END, 0);
+       GnomeVFSFileSize buffer_size = g_strlen(buffer);
+                       
+       gnome_vfs_write(data->xdxf,
+                               buffer,
+                       buffer_size,
+                        &bytes_written
+                        );
+       
+       read_bytes_size = DICT_CACHEING_BUFF_SIZE;
+       read_size = DICT_CACHEING_BUFF_SIZE + 1 ;
+       //bytes_written = DICT_CACHEING_BUFF_SIZE;
+       //gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 0);
+       while(TRUE)
+       {
+               
+               
+               vfs_result = gnome_vfs_read(swap_xdxf/*GnomeVFSHandle */,
+                               read_buffer/*buffer*/,
+                                read_size/*GnomeVFSFileSize*/,
+                                &read_bytes_size/*GnomeVFSFileSize*/);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               vfs_result = gnome_vfs_write(data->xdxf,
+                               read_buffer,
+                               read_bytes_size,
+                                &bytes_written);
+               //g_return_val_if_fail(vfs_result != GNOME_VFS_OK, FALSE);
+               g_debug("%s", gnome_vfs_result_to_string(vfs_result));
+               //g_debug("%d", bytes_written);
+               if (read_bytes_size < DICT_CACHEING_BUFF_SIZE) break;
+       }       
+       /*End write back*/
+       
+       gnome_vfs_close(swap_xdxf); 
+       gnome_vfs_unlink("/media/mmc1/swap_xdxf.xdxf");
+//     gnome_vfs_close(data->xdxf);
+//     gnome_vfs_open(data->xdxf, data->dict_path, GNOME_VFS_OPEN_READ);
+       gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 
+                       0);
+       gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 
+                       0);
+       gnome_vfs_close(data->cache); 
+       gchar* cache_path = g_strconcat(data->dict_path, "/ws_bookmarks.cache", NULL);
+       //gnome_vfs_unlink(cache_path);
+       bm_engine_optimize(engine);
+       g_free(cache_path);
+       return TRUE;
+}
+
+static void search_word_trans_start(void *data,
+                                    const char *el,
+                                    const char **attr
+                                   )
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if((loc_data->translation != NULL) || !(loc_data->cont)) {
+                return;
+        };
+
+        if(g_utf8_collate(el,"k") == 0) {
+                loc_data->one_word = 1;
+        } else if(g_utf8_collate(el,"ar") == 0) {
+                loc_data->last_start = 
+                                XML_GetCurrentByteIndex(*(loc_data->parser));
+        }
+}
+//------------------------------------------------------------------------------
+static void search_word_trans_end(void *data, const char *el)
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if((loc_data->translation != NULL) || !(loc_data->cont)) {
+                return;
+        };
+
+        if(g_utf8_collate(el,"k") == 0) {
+                loc_data->one_word = 0;
+
+                gint com = g_utf8_collate(loc_data->last_word, loc_data->word);
+                if(com > 0) {
+                        loc_data->cont = FALSE;
+                        return;
+                } else if((loc_data->last_word_length == loc_data->word_len) &&
+                          ( com == 0 )
+                         )  {
+                        loc_data->found = TRUE;
+                };       
+                // "clearing" buffer for next word        
+                loc_data->last_word_length = 0;
+        } 
+        else if((g_utf8_collate(el,"ar") == 0) && (loc_data->found)) {
+                loc_data->found = FALSE;
+                loc_data->cont = FALSE;
+                gulong last_stop = 
+                       (gulong)XML_GetCurrentByteIndex(*(loc_data->parser));
+                last_stop += strlen("</ar>");
+                FilePart fp = {loc_data->last_start,
+                               (last_stop - (loc_data->last_start))
+                              };
+                loc_data->translation = read_file_part(&fp, loc_data->xdxf);
+        }
+}
+//------------------------------------------------------------------------------
+static void search_word_trans_text(void *data, const XML_Char *txt, int len)
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if((loc_data->translation != NULL) || !(loc_data->cont))  {
+                return;
+        };
+
+        if(loc_data->one_word == 1) {
+                memcpy(&(loc_data->last_word[loc_data->last_word_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->last_word_length += (guint)len;
+                loc_data->last_word[loc_data->last_word_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+void bm_engine_search_word_translation_extended(Engine* engine, gchar* word)
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+                data->cb_progress_caching_seed = seed;
+                g_debug("%s->%s() sets new seed=%0.2f for for signal "
+                        "\"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        seed,
+                        signal
+                       );        
+        } 
+        else {
+                g_warning("%s->%s() unsupported signal"
+                          "for progress: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          signal
+                         );
+        };
+}
+//------------------------------------------------------------------------------
+gpointer bm_engine_set_callbacks(Engine* engine,
+                             gchar* signal,
+                             gpointer c_handler,
+                             gpointer user_data)
+{
+       g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        g_assert(engine != NULL);
+        g_assert(signal != NULL);
+        g_assert(c_handler != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+                gpointer result = data->cb_progress_caching;
+                data->cb_progress_caching = c_handler;
+                data->cb_progress_caching_data = user_data;
+                g_debug("%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;                
+        }
+        else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+                gpointer result = data->cb_search_word_list;
+                data->cb_search_word_list = c_handler;
+                data->cb_search_word_list_data = user_data;
+                g_debug("%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;                        
+        }
+        else if(g_ascii_strcasecmp(signal,
+                                   ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                gpointer result = data->cb_search_word_trans;
+                data->cb_search_word_trans = c_handler;
+                data->cb_search_word_trans_data = user_data;
+                g_debug("%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;                        
+        }
+        else {
+                g_warning("%s->%s() unsupported signal: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          signal
+                         );
+                return NULL;
+        }
+}
+//------------------------------------------------------------------------------
+void bm_engine_close(Engine* engine)
+{
+        g_debug("%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine);
+        if(engine == NULL) {
+                g_warning("%s->%s() Trying delete not existed engine.\n",
+                           __FILE__,
+                           __FUNCTION__
+                          );
+                return;        
+        }
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(data->cache != NULL) {
+                gnome_vfs_close(data->cache);
+        };
+        if(data->xdxf != NULL) {
+                gnome_vfs_close(data->xdxf);
+        };
+        
+        g_free(data->dict_path);
+        g_free(data);
+        g_free(engine);
+        g_debug("%s->%s() engine at adress=%p is deleted.\n",
+                __FILE__,
+                __FUNCTION__,
+                engine);
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_error_message(EngineStatus error) 
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        return "Error - not yet implemented.";
+}
+//------------------------------------------------------------------------------
+Engine* bm_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        g_debug("%s->%s() called.\n"
+                "-->PARAM:location=\'%s\'\n"
+                "-->PARAM:auto_cache=%d\n",
+                __FILE__,
+                __FUNCTION__,
+                location,
+                (guint)auto_cache
+               );
+        timer(TIMER_START,(gchar*)__FUNCTION__);        
+        GnomeVFSResult    open_result;
+
+        if(!gnome_vfs_initialized ()) {
+                gnome_vfs_init ();                       
+        };
+
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = bm_engine_location;
+        result->engine_is_optimized = bm_engine_is_optimized;
+        result->engine_optimize = bm_engine_optimize;
+        result->engine_search_word_list = bm_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        bm_engine_search_word_translation;
+
+        result->engine_close = bm_engine_close;
+        result->engine_status = bm_engine_error;
+        result->engine_error_message = bm_engine_error_message;
+        result->engine_set_callback = bm_engine_set_callbacks;
+        result->engine_set_progress_seed = bm_engine_set_progress_seed;
+        result->engine_set_auto_free = bm_engine_set_auto_free;
+       // API 0.2
+       result->engine_add_word = bm_engine_add_word;
+        result->engine_remove_word = bm_engine_remove_word;
+       
+        XDXFData* data = (XDXFData*)g_try_malloc(sizeof(XDXFData));
+        result->engine_data = (gpointer)data;
+       
+        
+        g_debug("%s->%s() opening file...\'%s\'.\n",
+                __FILE__,
+                __FUNCTION__,
+                location
+                );
+        gchar* tmp2 = g_strconcat(tmp,"/ws_bookmarks.xdxf",NULL);
+        open_result = 
+                gnome_vfs_open (&(data->xdxf), tmp2, GNOME_VFS_OPEN_READ | 
+                       GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_RANDOM);
+        g_free(tmp2); tmp2 = NULL;
+        
+        if(open_result != GNOME_VFS_OK)  {
+                g_warning("%s->%s() opening dictionary file failed"
+                                " due to reason: %s.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                gnome_vfs_result_to_string(open_result)
+                                );
+                result->engine_data = NULL;
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+        else {
+                g_debug("%s->%s() opening dictionary file successed.\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cache = NULL;
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+                if(auto_cache != ENGINE_NO) {
+                        if(auto_cache == ENGINE_REFRESH) {
+                                bm_engine_optimize(result);
+                        }
+                        else if(auto_cache == ENGINE_CREATE) {
+                               gchar* cache_path = g_strconcat(data->dict_path,
+                                                                "/ws_bookmarks.cache",
+                                                                NULL);
+                               open_result = 
+                                        gnome_vfs_open (&(data->cache),
+                                                        cache_path,
+                                                        GNOME_VFS_OPEN_READ
+                                                       );
+                                if(open_result != GNOME_VFS_OK) {
+                                        bm_engine_optimize(result);
+                                };
+                                g_free(cache_path); cache_path = NULL;
+                        }
+                };
+        }
+        g_free(tmp); tmp = NULL;
+        
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("%s->%s() returned Engine at adress=%p\n TO NAPEWNO TEN PLIK",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+EngineModule engine_global_functions()
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        EngineModule* result = g_try_new(EngineModule, 1);        
+                result->engine_check             = bm_engine_check;
+                result->engine_description       = bm_engine_description;
+                result->engine_format            = bm_engine_format;
+                result->engine_version           = bm_engine_version;
+                result->engine_create            = bm_engine_create;
+        g_debug("%s->%s() returned EngineModule at adress=%p.\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return *result;
+}
+//------------------------------------------------------------------------------
+static double timer(gboolean start, gchar* message)
+{
+        static GArray* stack = NULL;
+        static gboolean first_run = TRUE;
+        static struct timeval actual_time;
+        static struct timeval last_time;
+        static struct timeval result;
+        static double seconds = 0.0;
+        if(first_run) {
+                first_run = FALSE;
+                stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+        };        
+
+        if (start) {
+                g_debug("XDXF->%s() start counting time for function '%s()'.\n",
+                        __FUNCTION__,
+                        message
+                       );
+                g_array_prepend_val(stack, actual_time);
+                gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+                return -1.0;
+        }
+        // we just want to end some timer - print some information about 
+        // working time;
+        else {          
+                gettimeofday(&actual_time,NULL);
+                last_time = g_array_index(stack, struct timeval, 0);
+                g_array_remove_index(stack, 0);
+
+                if (actual_time.tv_usec < last_time.tv_usec) {
+                        int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                                                  (1000000 + 1);
+                        last_time.tv_usec -= 1000000 * nsec;
+                        last_time.tv_sec += nsec;
+                }
+                if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                        int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                                                        1000000;
+                        last_time.tv_usec += 1000000 * nsec;
+                        last_time.tv_sec -= nsec;
+                }
+                result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+                result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+                seconds = (((double)(result.tv_usec)) / 1e6) +
+                                                      ((double)(result.tv_sec));
+
+                g_debug("XDXF->%s() function \'%s()\' was working for: %g [s] "
+                        "or %ld [us].\n",
+                        __FUNCTION__,
+                        message,
+                        seconds,
+                        ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                       );
+                // stack is empty so we delete everything
+                if(stack->len == 0)   
+                {
+                        g_array_free(stack, TRUE);
+                        first_run = TRUE;
+                }
+        }
+        return seconds;
+}
+//------------------------------------------------------------------------------
+static gchar* read_file_part(FilePart* part, GnomeVFSHandle* file) 
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        timer(TIMER_START,(gchar*)__FUNCTION__);
+        gchar* result = NULL;
+        GnomeVFSResult    f_result;
+        GnomeVFSFileSize  bytes_read;
+        
+        f_result = gnome_vfs_seek(file, GNOME_VFS_SEEK_START, part->offset);        
+        if(f_result != GNOME_VFS_OK) {
+                g_warning("%s->%s() failed. Not possible to seek "
+                          "through file!\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return result;
+                
+        };
+        result = g_try_malloc((part->length + 1) * sizeof(gchar));
+        if(result == NULL) {
+                g_warning("%s->%s() failed. Not possible to allocate "
+                          "so big memmory chunk!\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return result;
+        };
+        f_result = gnome_vfs_read (file, result, part->length, &bytes_read);
+        if((f_result != GNOME_VFS_OK) ||
+                (((gulong)bytes_read) != part->length)) {
+                g_debug("%s->%s() failed. Not possible to read from "
+                        "file!\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                g_free(result); result = NULL;
+                return result;                
+        };
+        result[part->length] = '\0';
+
+        g_debug("%s->%s() returned string=\n\'%s\'.\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+/** Translate given string to proper full file path. Function works "in-situ". 
+* It means that string is translated and replaced by proper full file path if 
+* this file path exists, or this string is cleared and setted to NULL, if string
+* was representing wrong path. This function is static - to use only 
+* within this module.
+*
+* @param string :: <b><i>gchar**</i></b> - pointer to pointer to string 
+*       representing file path - it will be replaced by a proper filepath.
+*       It should be path to directory or file, ended with "/" or not, absolute 
+*       or not
+* @return <b><i>gchar*</i></b> - pointer to new full file path, it is the same
+*       as string[0] in fact and it is returned only for abillity of nesting of 
+* functions by pointer to string identyfying full file path
+*/
+static gchar* string_to_path(gchar** string) {
+        g_debug("%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        g_debug("%s->%s() returned string=\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static gboolean is_bm_file(gchar* file) {
+         g_debug("%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 file
+               );
+        gboolean                result = TRUE;
+        GnomeVFSHandle*         fd = NULL;
+        GnomeVFSResult          file_result;
+        GnomeVFSFileSize        bytes_read;
+
+        if(!gnome_vfs_initialized ()) {
+                gnome_vfs_init ();                       
+        };
+
+        file_result = gnome_vfs_open (&fd, file, GNOME_VFS_OPEN_READ);
+        if(file_result != GNOME_VFS_OK) {
+                g_warning("%s->%s() Could not open the file.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                return FALSE;
+        };
+
+        XML_Parser p = XML_ParserCreate(NULL);        
+        if (!p) {
+                g_warning("%s->%s() Could not open initialize "
+                          "XML parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                gnome_vfs_close(fd);
+                return FALSE;
+        };
+        XML_SetElementHandler(p, is_bm_file_start, is_bm_file_end);
+        XDXFCheckingData user_data = {TRUE, FALSE, 0};
+        XML_SetUserData(p, &user_data);
+        gchar buffer[DICT_CACHEING_BUFF_SIZE];        
+
+        guint loop_count = 0;
+        while(TRUE) {
+                file_result = gnome_vfs_read (fd,
+                                              buffer,
+                                              DICT_CACHEING_BUFF_SIZE,
+                                              &bytes_read
+                                             );
+                if  (file_result != GNOME_VFS_OK) {
+                        result = FALSE;
+                        g_warning("%s->%s() Could not read enought from"
+                                  " file.\n",
+                                  __FILE__,
+                                  __FUNCTION__
+                                 );
+                        break;
+                };               
+                if (! XML_Parse(p,
+                                buffer,
+                                (gulong)bytes_read,
+                                ((gulong)bytes_read) < DICT_CACHEING_BUFF_SIZE
+                               ) ) {
+                        result = FALSE;
+                        g_warning("%s->%s() Could not parse file.\n",
+                                  __FILE__,
+                                  __FUNCTION__
+                                 );
+                        break;
+                };
+                if (user_data.further == FALSE) {
+                        result = user_data.good;
+                        g_debug("%s->%s() statement: location is "
+                                "compatible with this module, is %s\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                PRINT_STATE(result)
+                               );
+                        break;
+                };
+                if (loop_count > 1) {
+                        result = FALSE;
+                        g_debug("%s->%s() Wrong file format.\n",
+                                __FILE__,
+                                __FUNCTION__
+                               );
+                        break;
+                };
+                loop_count++;
+        }
+
+        gnome_vfs_close(fd);
+        XML_ParserFree(p);
+        g_debug("%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+static void is_bm_file_start(void *data, const char *el, const char **attr) 
+{
+         XDXFCheckingData* user_data = (XDXFCheckingData*)data;
+        if (user_data->deep == 0) {
+                if (g_utf8_collate (el,"xdxf") != 0) {
+                        user_data->good = FALSE;                
+                }
+                else {
+                        user_data->good = TRUE;
+                }
+                user_data->further = FALSE;        
+        }
+        user_data->deep++;
+}
+//------------------------------------------------------------------------------
+static void is_bm_file_end(void *data, const char *el) 
+{
+        // clear as far as in this callback is nothing to do
+}
+//------------------------------------------------------------------------------
+EngineStatus bm_engine_error(Engine* engine) 
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        g_debug("%s->%s() returned error code: %d\n",
+                __FILE__,
+                __FUNCTION__,
+                (gint)(data->last_error)
+               );        
+        return data->last_error;
+}
+//------------------------------------------------------------------------------
+static void caching_expat_start(void *data, const char *el, const char **attr) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+        if(g_utf8_collate(el,"ar") == 0)  {
+                loc_data->last_start = 
+                                     XML_GetCurrentByteIndex(loc_data->parser);
+        }
+        else if(g_utf8_collate(el,"k") == 0) {
+                loc_data->state = 1;
+        }
+        else {
+                loc_data->state = 0;
+        }
+}
+//------------------------------------------------------------------------------
+static void caching_expat_end(void *data, const char *el) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+        loc_data->last_stop = XML_GetCurrentByteIndex(loc_data->parser);
+        
+        static guint record_length;
+        static guint start;
+        static guint length;
+        static guint buffer_length;
+
+        if((g_utf8_collate("k",el) == 0) &&
+                (loc_data->state == 1))  {
+                loc_data->state = 2;
+        }
+        else if((g_utf8_collate("ar",el) == 0) &&
+                        (loc_data->state == 2)) {
+                buffer_length = loc_data->buffer_length;
+                record_length = sizeof(guint)*3 + loc_data->buffer_length;
+                start = loc_data->last_start;
+                length = loc_data->last_stop + strlen("</ar>") - 
+                         loc_data->last_start;
+                
+                gboolean error_writting = FALSE;
+                GnomeVFSFileSize bytes_written;
+                GnomeVFSResult vfs_result;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &record_length,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             loc_data->buffer,
+                                             loc_data->buffer_length,
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &start,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &length,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                
+                loc_data->buffer[0] = '\0';
+                loc_data->buffer_length = 0;
+                loc_data->state = 0;
+        };
+}
+//------------------------------------------------------------------------------
+static void caching_expat_text(void *data, const XML_Char *txt, int len) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+
+        if(loc_data->state == 1) {
+                memcpy(&(loc_data->buffer[loc_data->buffer_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->buffer_length += (long)len;
+                loc_data->buffer[loc_data->buffer_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+static guint64 get_file_size(GnomeVFSHandle* file)
+{
+        guint64 result = 0;
+        guint64 old_pos = 0;
+        gnome_vfs_tell(file, &old_pos);
+
+        if( gnome_vfs_seek(file, GNOME_VFS_SEEK_END, 0) != GNOME_VFS_OK) {
+                return 0;
+        }
+
+        if( gnome_vfs_tell(file, &result) != GNOME_VFS_OK) {
+                result = 0;
+        }
+        
+        gnome_vfs_seek(file, GNOME_VFS_SEEK_START, old_pos);
+        return result;
+}
+//------------------------------------------------------------------------------
+/*
+static gboolean is_Bookmark_file(gchar* file) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 file
+               );
+       
+       GnomeVFSHandle *handle;
+       
+       GnomeVFSResult result = gnome_vfs_open (&handle, file, GNOME_VFS_OPEN_READ);
+                       
+        if(result != GNOME_VFS_OK) {
+                LOGS("File Access Error.\n");
+                return FALSE;
+        }
+
+        if( g_strrstr (file, "ws_bookmarks") == NULL) {
+                LOGS("Wrong file! Not a bookmarks' database.\n");
+                return FALSE;
+        }
+        return TRUE;
+}*/
+
+void bm_engine_optimize(Engine* engine)
+{
+        g_debug("%s->%s() called for engine at adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        timer(TIMER_START,(gchar*)__FUNCTION__);   
+        GnomeVFSResult vfs_result;
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+       g_debug("data->dict_path %s", data->dict_path);
+       gchar* cache_path = g_strconcat(data->dict_path,"/ws_bookmarks.cache",NULL);
+       vfs_result = gnome_vfs_create(&(data->cache),
+                                      cache_path,
+                                      GNOME_VFS_OPEN_WRITE,
+                                      FALSE,
+                                      0666
+                                     );
+       if(vfs_result != GNOME_VFS_OK)  {
+               data->cache = NULL;
+               g_warning("%s->%s().Could not create new cache file: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          cache_path
+                         );
+       }
+        else {
+                XDXFCacheData* c_data = 
+                            (XDXFCacheData*)g_try_malloc(sizeof(XDXFCacheData));
+                c_data->parser = XML_ParserCreate(NULL);
+               c_data->cache = data->cache;
+               c_data->buffer = 
+                    (gchar*)g_try_malloc(sizeof(gchar)*DICT_CACHEING_BUFF_SIZE);
+               c_data->buffer_length = 0;
+                c_data->last_start = 0;
+                c_data->last_stop = 0;
+                c_data->last_length = 0;
+                guint64 file_size = get_file_size(data->xdxf);
+//                 g_debug("%s->%s(): caching dictionaries size is %.2f kB "
+//                         "[%d bytes = %.2f MB].\n",
+//                         __FILE__,
+//                         __FUNCTION__,
+//                         ((gdouble)file_size)/1024.0,
+//                         file_size,
+//                         ((gdouble)file_size)/(1024.0*1024.0)
+//                        );
+
+                XML_SetUserData(c_data->parser, (gpointer)c_data);
+               XML_SetElementHandler(c_data->parser,
+                                      caching_expat_start,
+                                      caching_expat_end
+                                     );
+               XML_SetCharacterDataHandler(c_data->parser, caching_expat_text);
+                GnomeVFSFileSize bytes_readed = DICT_CACHEING_BUFF_SIZE;
+               gchar b[DICT_CACHEING_BUFF_SIZE + 1];
+               gdouble last_prog = 0;
+               while(TRUE) {
+                        vfs_result = gnome_vfs_read(data->xdxf,
+                                                    b,
+                                                    DICT_CACHEING_BUFF_SIZE,
+                                                    &bytes_readed
+                                                   );
+                       XML_Parse(c_data->parser,
+                                  b,
+                                  bytes_readed,
+                                  bytes_readed < DICT_CACHEING_BUFF_SIZE
+                                 );
+                        if(data->cb_progress_caching != NULL) {
+                                GnomeVFSFileSize act_pos;
+                                gnome_vfs_tell(data->xdxf, &act_pos);
+                                gdouble progress = ((gdouble)act_pos)/
+                                                           ((gdouble)file_size);
+                               if((( (progress - last_prog) /
+                                    (data->cb_progress_caching_seed) ) > 1.0) ||
+                                   (progress >= 1.0)) {
+                                        data->cb_progress_caching(
+                                                 progress,
+                                                 data->cb_progress_caching_data,
+                                                 ENGINE_NO_ERROR
+                                                                 );
+                                        last_prog = progress;
+                               };
+                        }
+                        if(bytes_readed < DICT_CACHEING_BUFF_SIZE) break;
+                }
+               g_free(c_data->buffer);
+                g_free(c_data);
+        }
+
+        vfs_result = gnome_vfs_close(data->cache);
+       vfs_result = gnome_vfs_open(&(data->cache),
+                                    cache_path,
+                                    GNOME_VFS_OPEN_READ
+                                   );
+       g_free(cache_path); cache_path = NULL;
+       timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("%s->%s()'s work finished.\n",__FILE__,__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_check(gchar* location) 
+{        
+        g_debug("%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                location
+               );
+        timer(TIMER_START,(gchar*)__FUNCTION__);
+        gboolean result = TRUE;        
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+        
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                g_warning("%s->%s() location \'%s\' is not a proper "
+                          "path!\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          location
+                         );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/ws_bookmarks.xdxf",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                g_debug("%s->%s() finnal file to check is: %s\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        filepath
+                       );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR)) {
+                        g_warning("%s->%s() file \'%s\' does not "
+                                  "exists!\n",
+                                  __FILE__,
+                                  __FUNCTION__,
+                                  filepath
+                                 );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_bm_file(filepath);
+        };
+
+        g_free(filepath);
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+
+
+//------------------------------------------------------------------------------
+static guint get_max_length(gchar* a, guint length) 
+{
+        gchar* b = a;
+        guint len = 0;
+        guint n = 0;
+        memcpy(&n,b,sizeof(guint));
+        while((len + n) <= (length - 4)) {
+                len += n;
+                b = b + n;
+                memcpy(&n,b,sizeof(guint));
+        }
+        return len;
+}
+//------------------------------------------------------------------------------                                                                                     // finished functions:
+void bm_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+        g_debug("%s->%s() called.\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:state=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                engine,
+                PRINT_STATE(state)
+               );
+        g_assert(engine != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        data->auto_free = state;
+        g_debug("%s->%s() Current auto_free is %s\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(data->auto_free)
+               );
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_version() 
+{
+        g_debug("%s->%s() called.\n",__FILE__,__FUNCTION__);
+        gchar* result = g_strdup(DIC_ENG_VERSION);
+        g_debug("%s->%s() return string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_format() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_description() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_is_optimized(Engine* engine) 
+{
+        g_debug("%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        g_assert(engine != NULL);                
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        gboolean result = (data->cache != NULL);
+        g_debug("%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_location(Engine* engine)
+{
+        g_debug("%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        g_assert(engine != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        gchar* result;
+        if(data->auto_free) {
+                result = data->dict_path;
+        }
+        else {
+                result = g_strdup(data->dict_path);
+        }
+
+        g_debug("%s->%s() returned string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+static void search_word_list_start(void *data,
+                                   const char *el,
+                                   const char **attr
+                                  )
+{
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+        if(g_utf8_collate(el,"k") == 0) {
+                loc_data->one_word = 1;
+        };
+}
+//------------------------------------------------------------------------------
+static void search_word_list_end(void *data, const char *el)
+{
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+        if(g_utf8_collate(el,"k") == 0) {
+                loc_data->one_word = 0;
+        }
+        else {
+                return;
+        }
+        static  gboolean any_found = FALSE;
+                        gboolean matched   = FALSE;
+
+        if(( loc_data->last_word_length >= loc_data->pattern_len ) &&
+           (g_ascii_strncasecmp(loc_data->last_word,
+                                loc_data->pattern,
+                                loc_data->pattern_len) == 0)) {
+                matched = TRUE;
+                any_found = TRUE;
+                gchar* new = g_strdup(loc_data->last_word);
+                g_array_append_val((loc_data->result), new);
+                g_debug("New Word for pattern \"%s\" found: %s\n",
+                        loc_data->pattern,
+                        new
+                       );
+        };
+        // "clearing" buffer for next word        
+        loc_data->last_word_length = 0;
+        // if we passed words matching -> ends
+        if(any_found && !matched) {
+                loc_data->cont = FALSE;
+        };
+        matched = FALSE;
+        any_found = FALSE;
+}
+//------------------------------------------------------------------------------
+static void search_word_list_text(void *data, const XML_Char *txt, int len) 
+{
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+
+        if(loc_data->one_word == 1) {
+                memcpy(&(loc_data->last_word[loc_data->last_word_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->last_word_length += (guint)len;
+                loc_data->last_word[loc_data->last_word_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+// return translation of word using cache file
+static void word_list_cache(XDXFData* data, gchar* pattern, GArray* result) {
+        gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);        
+//        GnomeVFSResult vfs_result;
+       GnomeVFSFileSize bytes_readed;
+        guint64 file_size = get_file_size(data->cache);
+       if (file_size > 0){
+       guint pattern_len;
+       gchar buffer[DICT_SEARCHING_WORD_LIST_BUFF_SIZE];
+        gchar* buf;
+       guint record_length = 0;
+        guint already = 0;
+        guint max_length = 0;
+       pattern_len = g_strlen(pattern);
+       g_strstrip(pattern);
+       if ((int)(pattern[0]) == 42 && pattern[1] == '\0') //asterix?
+       {
+               gchar pattern_copy[2] = "A\0";
+       
+                       pattern_len = g_strlen(pattern_copy);
+                       while (TRUE)
+               {
+               
+                       record_length = 0;
+                       already = 0;
+                       max_length = 0;
+       //gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);        
+       //
+                       while(TRUE)  {
+                               gnome_vfs_read(data->cache,
+                                               buffer,
+                                               DICT_SEARCHING_WORD_LIST_BUFF_SIZE,
+                                               &bytes_readed
+                                       );
+                        
+                       max_length = get_max_length(buffer, (guint)bytes_readed);
+                       already += max_length;
+                       buf = buffer;
+
+                       guint how_far = 0;
+                       while(how_far < max_length) {
+                               memcpy(&record_length, buf, sizeof(guint));
+                               if(
+                               ((record_length - 3*sizeof(guint)) >= pattern_len) &&
+                               (g_ascii_strncasecmp(buf + sizeof(guint),
+                                                 pattern_copy,
+                                                 pattern_len
+                                                ) == 0 ) ) {
+                                       gchar* new = 
+                                               g_strndup(buf + sizeof(guint),
+                                                       record_length - 
+                                                               3*sizeof(guint));
+                                       g_array_append_val(result, new);
+                                       g_debug(
+                                       "New Word for pattern \"%s\" found: "
+                                        "%s\n",
+                                        pattern_copy,
+                                        new
+                                       );
+                               };
+                               how_far += record_length;
+                               buf = buf + record_length;
+                        }
+                       if((bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE)|| 
+                               (already > (file_size -3))) {
+                               break;
+                       }
+                               gnome_vfs_seek(data->cache, 
+                                       GNOME_VFS_SEEK_CURRENT,
+                                       ((gint)max_length) - 
+                                             DICT_SEARCHING_WORD_LIST_BUFF_SIZE
+                                   );
+                       }
+                       pattern_copy[0] = (gchar)((gint) pattern_copy[0] + 1);
+                       
+                       g_debug("now this is pattern %d ", (gint) pattern_copy[0]);
+                       if ((gint) pattern_copy[0] > 90) break;
+                       gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);
+               }
+       }else
+       {
+               while(TRUE)  {
+                       gnome_vfs_read(data->cache,
+                                               buffer,
+                                               DICT_SEARCHING_WORD_LIST_BUFF_SIZE,
+                                               &bytes_readed
+                                       );
+                        
+                       max_length = get_max_length(buffer, (guint)bytes_readed);
+                       already += max_length;
+                       buf = buffer;
+
+                       guint how_far = 0;
+                       while(how_far < max_length) {
+                               memcpy(&record_length, buf, sizeof(guint));
+                               if(
+                               ((record_length - 3*sizeof(guint)) >= pattern_len) &&
+                               (g_ascii_strncasecmp(buf + sizeof(guint),
+                                                 pattern,
+                                                 pattern_len
+                                                ) == 0 ) ) {
+                                       gchar* new = 
+                                               g_strndup(buf + sizeof(guint),
+                                                       record_length - 
+                                                               3*sizeof(guint));
+                                       g_array_append_val(result, new);
+                                       g_debug(
+                                       "New Word for pattern \"%s\" found: "
+                                        "%s\n",
+                                        pattern,
+                                        new
+                                       );
+                               };
+                               how_far += record_length;
+                               buf = buf + record_length;
+                        }
+                       if((bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE)|| 
+                               (already > (file_size -3)) ) {
+               
+                               break;
+                       }
+                               gnome_vfs_seek(data->cache, 
+                                       GNOME_VFS_SEEK_CURRENT,
+                                       ((gint)max_length) - 
+                                             DICT_SEARCHING_WORD_LIST_BUFF_SIZE
+                                   );
+               }       
+       }
+       }
+       timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning words list START");                
+        data->cb_search_word_list(result,
+                                  pattern,
+                                  data->cb_search_word_list_data,
+                                  ENGINE_NO_ERROR
+                                 );
+        timer(TIMER_STOP,"callback for returning words list END");        
+}
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static void word_list_xdxf(XDXFData* data, gchar* pattern, GArray* result) {
+        gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 0);
+        GnomeVFSResult vfs_result;
+        GnomeVFSFileSize bytes_readed = DICT_SEARCHING_WORD_LIST_BUFF_SIZE;                
+        gchar buffer[DICT_SEARCHING_WORD_LIST_BUFF_SIZE+1];                
+        guint64 file_size = get_file_size(data->xdxf);
+       guint pattern_len;
+               
+        XML_Parser parser = XML_ParserCreate(NULL);        
+        if (!parser) {
+                g_warning("%s->%s() Could not open initialize XML "
+                          "parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return;
+        };
+       
+       
+       gchar tmp[DICT_MAX_WORD_LENGTH];
+        XML_SetElementHandler(parser,
+                              search_word_list_start,
+                              search_word_list_end
+                             );
+        XML_SetCharacterDataHandler(parser, search_word_list_text);
+        
+        // buffer for single word 
+        // pattern to search 
+        // length of pattern 
+        // actal length of readed word 
+        // array to append words 
+        // continuation of the same word 
+        // continue of searching?
+        XDXFWordsListData search_data = {tmp,
+                                         pattern,
+                                         pattern_len,
+                                         0,
+                                         result,
+                                         0,
+                                         TRUE
+                                        }; 
+        XML_SetUserData(parser, &search_data);
+
+        gdouble last_prog = 0;
+       
+       while(TRUE) {
+                vfs_result = gnome_vfs_read(data->xdxf,
+                                            buffer,
+                                            DICT_SEARCHING_WORD_LIST_BUFF_SIZE,
+                                            &bytes_readed
+                                           );
+                XML_Parse(parser,
+                          buffer,
+                          bytes_readed,
+                          bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE
+                         );
+                        
+                if(data->cb_progress_word_list != NULL) {
+                        GnomeVFSFileSize act_pos;
+                        gnome_vfs_tell(data->xdxf, &act_pos);
+                        gdouble progress = ((gdouble)act_pos)/
+                                                           ((gdouble)file_size);
+                        if((((progress - last_prog)/
+                            (data->cb_progress_word_list_seed)) > 1.0) ||
+                            (progress >= 1.0)) {
+                                data->cb_progress_word_list(
+                                               progress,
+                                               data->cb_progress_word_list_data,
+                                               ENGINE_NO_ERROR
+                                                           );
+                                last_prog = progress;
+                        };
+                }
+                if(bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE) {
+                        break;
+                }
+                if((search_data.cont) == FALSE) {
+                        g_debug("%s->%s() We found every words matching "
+                                "pattern \"%s\". Abort further searching.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                pattern
+                               );
+                        break;
+                }
+        }
+        
+       
+       
+       
+       XML_ParserFree(parser);
+       
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning words list START");
+        data->cb_search_word_list(result,
+                                  pattern,
+                                  data->cb_search_word_list_data,
+                                  ENGINE_NO_ERROR
+                                 );
+        timer(TIMER_STOP,"callback for returning words list END");        
+}
+//------------------------------------------------------------------------------
+void bm_engine_search_word_list(Engine* engine, gchar* pattern)
+{
+        g_debug("%s->%s() called. Searching words list\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:pattern=\"%s\"\n",
+                __FILE__,
+                __FUNCTION__,
+                engine,
+                pattern
+               );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        timer(TIMER_START,(gchar*)__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+       if(data->cb_search_word_list == NULL) {
+                g_warning("%s->%s() callback for Word List not set. "
+                          "Searching aborted.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return;
+        };
+       
+       
+        GArray* result = g_array_new(TRUE,FALSE,sizeof(gchar*));
+        // dictionary is optimized so search in cache file
+        if(data->cache != NULL) {        
+                word_list_cache(data, pattern, result);
+        }
+        // dictionary is not optimized so search directly fom XDXF file
+        else {          
+                word_list_xdxf(data, pattern, result);
+        };
+        
+        if(data->auto_free == TRUE)  {
+                g_debug("%s->%s() deleting all dynamic data because "
+                        "AUTO_FREE=TRUE\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                gchar* tmp;
+                guint i = 0;
+                while((tmp = g_array_index(result, gchar*, i)) != NULL) 
+                {
+                        g_free(tmp); tmp = NULL;
+                        i++;
+                }
+                g_array_free(result, TRUE);
+        };
+        g_debug("%s->%s() finished definately its work.\n",
+                __FILE__,
+                __FUNCTION__
+               );
+       return;
+}
diff --git a/src/bookmarks/xdxf/src/engine_bookmark_old.c b/src/bookmarks/xdxf/src/engine_bookmark_old.c
new file mode 100644 (file)
index 0000000..44e21dc
--- /dev/null
@@ -0,0 +1,975 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_bookmark.h>
+//------------------------------------------------------------------------------
+
+#ifndef NOLOGS
+#include <glib/gstdio.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+#define LOGS g_debug
+
+/*inline void LOGS(gchar* frm, ...) {
+#ifndef NOLOGS
+       //g_printf(frm);
+#endif
+}*/
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION FROM API 0.2 !!!
+//==============================================================================
+int get_id(void* data,int n,char** argv,char** names) {
+        int len = strlen(&(argv[0][0]));
+        memcpy(data,&(argv[0][0]), len);
+        gchar* tmp = (gchar*)data;
+        tmp[len] = 0;
+        return 0;
+}
+
+gboolean bm_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) {
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\ntranslation address: %p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             word,
+             translation
+            );
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        g_assert(translation != NULL);
+
+        // start timer for this function
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+       BookData* data = (BookData*)(engine->engine_data);
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_remove_word(Engine* engine, gchar*  word) {
+        gint sql_res = 0;
+        gchar* err = NULL;
+        gboolean result = TRUE;
+
+        LOGS("Bookmark/%s->%s() called. Param\nEngine at address: %p\n"
+             "word: %s\n",(gchar*)__FILE__,(gchar*)__FUNCTION__,engine,word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        timer(TIMER_START, (gchar*)(gchar*)__FUNCTION__);
+
+        BookData* data = (BookData*)(engine->engine_data);
+/*
+        gchar* tmp = g_utf8_strdown(word,-1);
+        gchar* sql = g_strconcat("DELETE FROM translations WHERE word_id = "
+                                 "(SELECT id FROM words WHERE word=\'",
+                                 tmp,
+                                 "\');",
+                                 NULL
+                                );
+        g_free(tmp); tmp = NULL;
+        sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while deleting \'%s\' word translation(s):\n%s\n",word,err);
+                g_free(sql); sql = NULL;
+                return FALSE;
+        }        
+        g_free(sql); sql = NULL;
+
+        gchar* sql = g_strconcat("DELETE FROM translations WHERE word LIKE \'",
+                                 word,
+                                 "\';",
+                                 NULL
+                                );
+*/
+       gchar* sql = sqlite_mprintf("DELETE FROM translations WHERE word LIKE "
+                                       "\'%q\';", word);
+       sql_res = sqlite_exec(data->db, sql, NULL, NULL, &err);
+        if(err || sql_res!=0) {
+                LOGS("Error while deleting \'%s\' <-> reason:\n%s\n",word,err);
+                g_free(sql); sql = NULL;
+                return FALSE;
+        }
+        g_free(sql); sql = NULL;
+
+        timer(TIMER_STOP, (gchar*)(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------      
+gchar* bm_engine_get_lang_from(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_lang_to(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("any");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_title(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strconcat(g_get_user_name(),"s' bookmarks",NULL);
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* bm_engine_get_icon_path(Engine* engine) {
+        LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+        gchar* result = g_strdup("/usr/share/pixmaps/ws_eng_bookmark_icon.png");
+        LOGS("Bookmark/%s->%s() return string=%s\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                result
+               );
+        return result;
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//-------------------------------------- FUNCTION TO WRITE (NOT IMPLEMENTED YET)
+//==============================================================================
+
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void bm_engine_search_word_translation(Engine* engine, gchar* word)
+{
+        g_debug("XDXF/%s->%s() called.\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:word=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 engine,
+                 word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start timer for this function
+        timer(TIMER_START, (gchar*)__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        // if callback is not set, we do not have to search word
+        if(data->cb_search_word_trans == NULL) {
+                g_warning("XDXF/%s->%s() callback for Word Translation not set."
+                          " Searching aborted.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                // do not send any signal, just exit
+                return;                
+        };
+        
+        guint word_length = strlen(word);
+        gchar* trans;
+
+        // dictionary is optimized
+        if(data->cache != NULL) {
+                trans = word_translation_cache(data, word);
+        // dictionary is not optimized right now
+        } else 
+        {        
+                trans = word_translation_xdxf(data, word);                
+        };
+
+        g_debug("XDXF/%s->%s() found for word \'%s\' translation:\n\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                word,
+                trans
+               );
+        timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+        data->cb_search_word_trans(trans,
+                                   word,
+                                   data->cb_search_word_trans_data,
+                                   ENGINE_NO_ERROR
+                                  );
+        timer(TIMER_STOP,"callback for returning word's translation END");
+        if(data->auto_free) {
+                g_debug("XDXF/%s->%s() deleting all dynamic data because "
+                        "AUTO_FREE=TRUE\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                g_free(trans);
+        }
+        trans = NULL;
+       return;
+}
+
+//------------------------------------------------------------------------------
+void bm_engine_close(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_assert(engine != NULL);
+        
+        BookData* data = (BookData*)(engine->engine_data);
+        sqlite_close(data->db);
+        
+        LOGS("Bookmark/%s->%s() engine at adress=%p is deleted.\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                engine);
+        g_free(engine);
+        engine = NULL;
+}
+//------------------------------------------------------------------------------
+
+Engine* bm_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        LOGS("Bookmark/%s->%s() called.\n"
+             "-->PARAM:location=\'%s\'\n"
+             "-->PARAM:auto_cache=%d\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location,
+             (guint)auto_cache
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);        
+
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = bm_engine_location;
+        result->engine_is_optimized = bm_engine_is_optimized;
+        result->engine_optimize = bm_engine_optimize;
+        result->engine_search_word_list = bm_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        bm_engine_search_word_translation;        
+        result->engine_close = bm_engine_close;
+        result->engine_status = bm_engine_status;
+        result->engine_error_message = bm_engine_status_message;
+        result->engine_set_callback = bm_engine_set_callback;
+        result->engine_set_progress_seed = bm_engine_set_progress_seed;
+        result->engine_set_auto_free = bm_engine_set_auto_free;
+        // 0.2 API:
+        result->engine_add_word = bm_engine_add_word;
+        result->engine_remove_word = bm_engine_remove_word;
+        result->engine_get_lang_from = bm_engine_get_lang_from;
+        result->engine_get_lang_to = bm_engine_get_lang_to;
+        result->engine_get_title = bm_engine_get_title;
+        result->engine_get_icon_path = bm_engine_get_icon_path;
+
+
+        BookData* data = (BookData*)g_try_malloc(sizeof(BookData));
+        result->engine_data = (gpointer)data;
+
+        LOGS("Bookmark/%s->%s() opening file...\'%s\'.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        gchar* tmp2 = g_strconcat(tmp,"/ws_bookmarks",NULL);
+        gchar* err;
+        data->db = sqlite_open(tmp2,0600,&err);
+        g_free(tmp2); tmp2 = NULL;
+        if(!(data->db)) {
+                LOGS("Bookmark/%s->%s() opening bookmark file failed.%s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     err
+                    );
+                g_free(err);
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+        else {
+                LOGS("Bookmark/%s->%s()opening dictionary file successed.\n",
+                        (gchar*)__FILE__,
+                        (gchar*)__FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+                // there is no cache mechanizm in bookmarks
+        }
+        g_free(tmp); tmp = NULL;
+        
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned Engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             result
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+
+
+static gboolean is_Bookmark_file(gchar* file) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 file
+               );
+        gchar* err;
+        sqlite* tmp = sqlite_open(file,0600,&err);
+        if(err || tmp==NULL) {
+                LOGS("Wrong file! Not a sqlite database.\n");
+                g_free(err); 
+                return FALSE;
+        }
+
+        gint result = 0;
+        gchar sql[] = "SELECT COUNT(word) FROM translations WHERE word=\'.\';";  
+
+        result = sqlite_exec(tmp, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                LOGS("Wrong database! Not a bookmark.\n");
+                g_free(err);
+               sqlite_close(tmp);
+                return FALSE;
+        }
+       sqlite_close(tmp);
+        return TRUE;
+}
+//------------------------------------------------------------------------------
+
+
+void bm_engine_optimize(Engine* engine)
+{
+        LOGS("Bookmark/%s->%s() called for engine at adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        LOGS("Unsupported optimization mechanizm for this engine!\n");
+        LOGS("Bookmark/%s->%s()'s work finished.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean bm_engine_check(gchar* location) 
+{        
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             location
+            );
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        gboolean result = TRUE;        
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+        
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                LOGS("Bookmark/%s->%s() location \'%s\' is not a proper "
+                     "path!\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     location
+                    );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/ws_bookmarks",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                LOGS("Bookmark/%s->%s() finnal file to check is: %s\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__,
+                     filepath
+                    );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR)) {
+                        LOGS("Bookmark/%s->%s() file \'%s\' does not exists!\n",
+                             (gchar*)__FILE__,
+                             (gchar*)__FUNCTION__,
+                             filepath
+                            );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_Bookmark_file(filepath);
+        };
+
+        g_free(filepath);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+
+//------------------------------------------------------------------------------
+gboolean bm_engine_is_optimized(Engine* engine) 
+{
+        LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine
+            );
+        g_assert(engine != NULL);                
+        gboolean result = FALSE;
+        LOGS("Bookmark/%s->%s() returned bool statement=%s.\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             PRINT_STATE(result)
+            );
+        return result;
+}
+//------------------------------------------------------------------------------
+
+void bm_engine_search_word_list(Engine* engine, gchar* pattern)
+{
+        LOGS("Bookmark/%s->%s() called. Searching words list\n"
+             "-->PARAM:engine at adress=%p\n"
+             "-->PARAM:pattern=\"%s\"\n",
+             (gchar*)__FILE__,
+             (gchar*)__FUNCTION__,
+             engine,
+             pattern
+            );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        timer(TIMER_START,(gchar*)(gchar*)__FUNCTION__);
+        BookData* data = (BookData*)(engine->engine_data);
+        if(data->cb_search_word_list == NULL) {
+                LOGS("Bookmark/%s->%s() callback for Word List not set. "
+                     "Searching aborted.\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+                return;
+        };
+
+        gchar* tmp = g_utf8_strdown(pattern,-1);
+        sqlite_vm* query = NULL;
+        gchar* sql = NULL;
+        gchar* tran = NULL;
+
+
+        sql = g_strconcat("SELECT word FROM translations WHERE "
+                          "word LIKE \'",tmp,"\%\';",NULL);
+        LOGS("QUERY: %s\n",sql);
+        gint sql_res = 0;
+        const gchar* end;
+        gchar* err = NULL;
+        sql_res = sqlite_compile(data->db,  /* The open database */
+                                 (const gchar*)sql,       /* SQL statement to be compiled */
+                                 &end,      /* OUT: uncompiled tail of zSql */
+                                 &query,    /* OUT: the virtual machine */
+                                 &err       /* OUT: Error message. */
+                                );
+        if(err || sql_res!=0) {
+                LOGS("Error while compiling query:\n%s\nreason:%s\n",sql,err);
+                g_free(sql); sql = NULL;
+                return;
+        };    
+        gint nCol = 0;
+        const gchar** values = NULL;
+        const gchar** head = NULL;
+        gint status = 0;
+        gboolean first = TRUE;
+        GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*) );
+        do { 
+                first = TRUE;
+                do {
+                        if(!first) sleep(1);
+                        first = FALSE;;
+                        status = sqlite_step(
+                                        query, 
+                                        &nCol,            
+                                        &values,  
+                                        &head 
+                                        );
+                        if(status == SQLITE_ERROR) {
+                                LOGS("Error while making next step\n");
+                                g_free(sql); sql = NULL;
+                                        return;
+                        };
+                        if(status == SQLITE_ROW) {
+                                LOGS("Fount new word: \"%s\"\n",&(values[0][0]));
+                                gchar* tmp = g_strdup((gchar*)&(values[0][0]));
+                                g_array_append_val(result, tmp );        
+                        }
+                } while((status == SQLITE_BUSY) && (status != SQLITE_ERROR));
+        } while((status == SQLITE_ROW) && (status != SQLITE_ERROR));
+        sqlite_finalize(query,&err);
+        timer(TIMER_STOP,(gchar*)(gchar*)__FUNCTION__);
+
+
+        timer(TIMER_START,"callback for returning words LIST START");
+        // calling callback for word translation
+
+        data->cb_search_word_list(result , pattern, data->cb_search_word_list_data, ENGINE_NO_ERROR);
+                
+        timer(TIMER_STOP,"callback for returning word LIST END");
+        if(data->auto_free) {
+                LOGS("Bookmark/%s->%s() deleting all dynamic data because "
+                     "AUTO_FREE=TRUE\n",
+                     (gchar*)__FILE__,
+                     (gchar*)__FUNCTION__
+                    );
+                g_free(tran);
+        }
+}
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- COMPLETED FUNCTIONS
+//==============================================================================
+// global functions
+EngineModule engine_global_functions()
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       EngineModule* result = g_try_new(EngineModule, 1);        
+       result->engine_check             = bm_engine_check;
+       result->engine_description       = bm_engine_description;
+       result->engine_format            = bm_engine_format;
+       result->engine_version           = bm_engine_version;
+       result->engine_create            = bm_engine_create;
+       LOGS("Bookmark/%s->%s()returned EngineModule at adress=%p.\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+             result
+           );
+       return *result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_status_message(error)
+gchar* bm_engine_status_message(EngineStatus error) 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       switch (error) {
+               case ENGINE_NO_ERROR:
+                       return "No error.";
+               case ENGINE_WRONG_FILE:
+                       return "File which You are trying to use is wrong type.";
+               case ENGINE_COULDNT_READ:
+                       return "Could not read from file.";
+               case ENGINE_NO_FILE:
+                       return "There is no such a file.";
+               case ENGINE_OUT_OF_MEMORY:
+                       return "There were no enough memory for this action.";
+               default:
+                       return "Wrong engine's status identifier!";
+       }
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_version(module)
+gchar* bm_engine_version() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_VERSION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+               result
+              );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_format(module)
+gchar* bm_engine_format() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_module_get_description(module)
+gchar* bm_engine_description() 
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       LOGS("Bookmark/%s->%s() return string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_location(engine)
+gchar* bm_engine_location(Engine* engine)
+{
+       LOGS("Bookmark/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       gchar* result;
+       if(data->auto_free) {
+               result = data->dict_path;
+       }
+       else {
+               result = g_strdup(data->dict_path);
+       }
+
+       LOGS("Bookmark/%s->%s() returned string=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            result
+           );
+       return result;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_auto_free(engine, state)
+void bm_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+            "-->PARAM:engine at adress=%p\n"
+            "-->PARAM:state=%s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            engine,
+            PRINT_STATE(state)
+           );
+       g_assert(engine != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+        
+       data->auto_free = state;
+       LOGS("Bookmark/%s->%s() Current auto_free is %s\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            PRINT_STATE(data->auto_free)
+           );
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_get_last_status(engine)
+EngineStatus bm_engine_status(Engine* engine) 
+{
+       LOGS("Bookmark/%s->%s() called.\n"
+               "-->PARAM:engine at adress=%p\n",
+               (gchar*)__FILE__,
+               (gchar*)__FUNCTION__,
+              engine
+              );
+       BookData* data = (BookData*)(engine->engine_data);
+       LOGS("Bookmark/%s->%s() returned error code: %d\n",
+            (gchar*)__FILE__,
+            (gchar*)__FUNCTION__,
+            (gint)(data->last_error)
+           );        
+       return data->last_error;
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_progress_seed(engine, signal, val)
+void bm_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               data->cb_progress_caching_seed = seed;
+               LOGS("Bookmark/%s->%s() sets new seed=%0.2f for for signal "
+                    "\"%s\".\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    seed,
+                    signal
+                   );        
+       } 
+       else {
+               LOGS("Bookmark/%s->%s() unsupported signalfor progress: %s.\n",
+                    (gchar*)__FILE__,
+                    (gchar*)__FUNCTION__,
+                    signal
+                   );
+       };
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_callback(engine,signal,c_handler,data)
+gpointer bm_engine_set_callback(Engine* engine,
+                            gchar* signal,
+                            gpointer c_handler,
+                            gpointer user_data)
+{
+       LOGS("Bookmark/%s->%s() called.\n",(gchar*)__FILE__,(gchar*)__FUNCTION__);
+       g_assert(engine != NULL);
+       g_assert(signal != NULL);
+       g_assert(c_handler != NULL);
+       BookData* data = (BookData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+               gpointer result = data->cb_progress_caching;
+               data->cb_progress_caching = c_handler;
+               data->cb_progress_caching_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+               gpointer result = data->cb_search_word_list;
+               data->cb_search_word_list = c_handler;
+               data->cb_search_word_list_data = user_data;
+               LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       signal
+                      );
+               LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)c_handler
+                      );
+               LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                       (gchar*)__FILE__,
+                       (gchar*)__FUNCTION__,
+                       (guint)user_data
+                      );
+               return result;                        
+       }
+       else if(g_ascii_strcasecmp(signal,
+               ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                       gpointer result = data->cb_search_word_trans;
+                       data->cb_search_word_trans = c_handler;
+                       data->cb_search_word_trans_data = user_data;
+                       LOGS("Bookmark/%s->%s() sets handler for signal \"%s\".\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               signal
+                              );
+                       LOGS("Bookmark/%s->%s() Function at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)c_handler
+                              );
+                       LOGS("Bookmark/%s->%s()     Data at adress =  %d.\n",
+                               (gchar*)__FILE__,
+                               (gchar*)__FUNCTION__,
+                               (guint)user_data
+                              );
+                       return result;                        
+               }
+               else {
+                       g_warning("Bookmark/%s->%s() unsupported signal: %s.\n",
+                                 (gchar*)__FILE__,
+                                 (gchar*)__FUNCTION__,
+                                 signal
+                                );
+                       return NULL;
+               }
+}
+
+
+
+
+
+
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//---------------------------------------------------------- HELPFULLY FUNCTIONS
+//==============================================================================
+
+//------------------------------------------------------------------------------
+static gchar* string_to_path(gchar** string) {
+        LOGS("Bookmark/%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 (gchar*)__FILE__,
+                 (gchar*)__FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        LOGS("Bookmark/%s->%s() returned string=\'%s\'\n",
+                (gchar*)__FILE__,
+                (gchar*)__FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static double timer(gboolean start, gchar* message)
+{
+       static GArray* stack = NULL;
+       static gboolean first_run = TRUE;
+       static struct timeval actual_time;
+       static struct timeval last_time;
+       static struct timeval result;
+       static double seconds = 0.0;
+       if(first_run) {
+               first_run = FALSE;
+               stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+       };        
+
+       if (start) {
+               LOGS("Bookmark->%s() start timer for function '%s()'.\n",
+                       (gchar*)__FUNCTION__,
+                       message
+                      );
+               g_array_prepend_val(stack, actual_time);
+               gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+               return -1.0;
+       }
+        // we just want to end some timer - print some information about 
+        // working time;
+       else {          
+               gettimeofday(&actual_time,NULL);
+               last_time = g_array_index(stack, struct timeval, 0);
+               g_array_remove_index(stack, 0);
+
+               if (actual_time.tv_usec < last_time.tv_usec) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       (1000000 + 1);
+                       last_time.tv_usec -= 1000000 * nsec;
+                       last_time.tv_sec += nsec;
+               }
+               if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       1000000;
+                       last_time.tv_usec += 1000000 * nsec;
+                       last_time.tv_sec -= nsec;
+               }
+               result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+               result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+               seconds = (((double)(result.tv_usec)) / 1e6) +
+                               ((double)(result.tv_sec));
+
+               LOGS("Bookmark->%s() function \'%s()\' was working for: %g "
+                               "[s] or %ld [us].\n",
+               (gchar*)__FUNCTION__,
+               message,
+               seconds,
+               ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                      );
+                // stack is empty so we delete everything
+               if(stack->len == 0)   
+               {
+                       g_array_free(stack, TRUE);
+                       first_run = TRUE;
+               }
+       }
+       return seconds;
+}
+//------------------------------------------------------------------------------
+
+
+
diff --git a/src/bookmarks/xdxf/src/test.c b/src/bookmarks/xdxf/src/test.c
new file mode 100644 (file)
index 0000000..b1b4abe
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+        printf("--------------------------------------------------\n");
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "StarDictEngine test: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library) {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       //dict_eng_module_get_global_functions(library,get_functions);
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+
+       EngineModule module = get_functions();
+       printf("Module description: %s\n",dict_eng_module_get_description(module));
+       Engine* sd;
+
+        gboolean is_compatible = dict_eng_module_check(module,"ws_bookmarks");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+
+       //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
+
+       //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
+       //home/stranger/whitestork/engine0.2/
+//     xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
+//     dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
+//     dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
+
+/*     if(dict_eng_is_optimized(xdxf) == FALSE)
+       {
+               printf("Dictionary has no cache!\nCreating cache file....\n");
+               dict_eng_optimize(xdxf);
+       }
+       else {
+               printf("Dictionary has already cache file!\n");
+       }*/
+        sd = dict_eng_module_create(module,
+            "ws_bookmarks" ,
+             ENGINE_CREATE);
+       printf("Lokacja: %s\n",dict_eng_get_location(sd));
+
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_TRANSLATION_SIGNAL ,
+                             print_translation,
+                             "Translation for word\'%s\':\n");
+       
+       dict_eng_search_word_list(sd,"12");
+       //dict_eng_search_word_translation(sd,"1 word");
+        
+//         dict_eng_remove_word(sd, "stranger");
+//     dict_eng_remove_word(sd, "gandzia");
+//     dict_eng_remove_word(sd, "lukas");
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_add_word(sd, "gandzia", "rulez");
+        dict_eng_add_word(sd, "lukas", "pawlik");
+//         dict_eng_remove_word(sd, "stranger");
+
+         dict_eng_search_word_translation(sd,"stranger");
+       
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_search_word_translation(sd,"stranger");
+        dict_eng_search_word_list(sd,"gandzia");
+
+        printf("Lang FROM:%s\n",dict_eng_get_lang_from(sd));
+        printf("  Lang TO:%s\n",dict_eng_get_lang_to(sd));
+        printf("    Title:%s\n",dict_eng_get_title(sd));
+        printf("Icon path:%s\n",dict_eng_get_icon_path(sd));
+       
+       dict_eng_destroy(sd);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/bookmarks/xdxf/src/test1.c b/src/bookmarks/xdxf/src/test1.c
new file mode 100644 (file)
index 0000000..b89a9a7
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+        printf("--------------------------------------------------\n");
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "StarDictEngine test: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/ws_bookmark.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library) {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       //dict_eng_module_get_global_functions(library,get_functions);
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+
+       EngineModule module = get_functions();
+       printf("Module description: %s\n",dict_eng_module_get_description(module));
+       Engine* sd;
+
+        gboolean is_compatible = dict_eng_module_check(module,"/home/str/whitestork/engines/bookmark/ws_bookmarks");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+
+       //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
+
+       //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
+       //home/stranger/whitestork/engine0.2/
+//     xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
+//     dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
+//     dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
+
+/*     if(dict_eng_is_optimized(xdxf) == FALSE)
+       {
+               printf("Dictionary has no cache!\nCreating cache file....\n");
+               dict_eng_optimize(xdxf);
+       }
+       else {
+               printf("Dictionary has already cache file!\n");
+       }*/
+        sd = dict_eng_module_create(module,
+            "/home/str/whitestork/engines/bookmark/ws_bookmarks" ,
+             ENGINE_CREATE);
+       printf("Lokacja: %s\n",dict_eng_get_location(sd));
+
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_TRANSLATION_SIGNAL ,
+                             print_translation,
+                             "Translation for word\'%s\':\n");
+       
+       dict_eng_search_word_list(sd,"12");
+       //dict_eng_search_word_translation(sd,"1 word");
+        
+        dict_eng_remove_word(sd, "stranger");
+       dict_eng_remove_word(sd, "gandzia");
+       dict_eng_remove_word(sd, "lukas");
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_add_word(sd, "gandzia", "rulez");
+        dict_eng_add_word(sd, "lukas", "pawlik");
+        dict_eng_remove_word(sd, "stranger");
+
+        dict_eng_search_word_translation(sd,"stranger");
+       
+        dict_eng_add_word(sd, "stranger", "autor pluginu tego wlasnie to jest!");
+        dict_eng_search_word_translation(sd,"stranger");
+        dict_eng_search_word_list(sd,"gandzia");
+
+        printf("Lang FROM:%s\n",dict_eng_get_lang_from(sd));
+        printf("  Lang TO:%s\n",dict_eng_get_lang_to(sd));
+        printf("    Title:%s\n",dict_eng_get_title(sd));
+        printf("Icon path:%s\n",dict_eng_get_icon_path(sd));
+       
+       dict_eng_destroy(sd);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/bookmarks/xdxf/src/test2.c b/src/bookmarks/xdxf/src/test2.c
new file mode 100644 (file)
index 0000000..6179a5a
--- /dev/null
@@ -0,0 +1,28 @@
+#include <libgnomevfs/gnome-vfs.h>
+
+int main (void)
+{
+       
+        if(!gnome_vfs_initialized ()) {
+                gnome_vfs_init ();                       
+        };
+       
+       gchar *buffer = "test";
+       GnomeVFSHandle *handle;
+       GnomeVFSResult result;
+       GnomeVFSFileSize ile;
+
+        result = gnome_vfs_open (&handle, "/home/krzsas/WhiteStork/trunk/src/bookmarks/src/ws_bookmarks", GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_RANDOM);
+       if (result == GNOME_VFS_OK)
+       {
+               gnome_vfs_seek (handle, GNOME_VFS_SEEK_END, 0);
+               gnome_vfs_write (handle, buffer, strlen(buffer), &ile);
+
+               g_printf ("Zapisano: %d\n", ile);
+//             gnome_vfs_close(handle);
+       }
+
+       else g_printf ("Blad %d: %s\n", result, gnome_vfs_result_to_string (result));
+
+       return 0;
+};
diff --git a/src/bookmarks/xdxf/src/testMakeDatabase.c b/src/bookmarks/xdxf/src/testMakeDatabase.c
new file mode 100644 (file)
index 0000000..7ca65e1
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <sqlite.h>
+
+const guint records_number = 1000;
+
+// ----------------------------------------------------------------------------------
+sqlite* database_make(gchar* path) {
+        gchar* buffer = NULL;
+        sqlite* result = NULL;
+        // creatingh database
+        result = sqlite_open(path,
+                             0600,
+                             &buffer);
+        // check if everything was okey
+        if(!result) {
+                g_printf("Error while trying to create database:\n%s\n",buffer);
+                g_free(buffer); buffer = NULL;
+                return NULL;
+        };
+        // return pointer to database
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_table(sqlite* db) {
+        gint result = 0;
+        //gchar sql[] = "CREATE TABLE words(id INTEGER PRIMARY KEY, word TEXT UNIQUE);";
+        gchar sql2[] = "CREATE TABLE translations(id INTEGER PRIMARY KEY, word TEXT, translation TEXT);";
+        gchar* err = NULL;      
+/*
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'words\' table:\n%s\n",err);
+                return 1;
+        }
+*/
+        result = sqlite_exec(db, sql2, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while creating \'translations\' table:\n%s\n",err);
+                return 2;
+        }
+
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint database_add_test_record(sqlite* db, guint i) {
+        gint result = 0;
+        gchar* sql = NULL;
+        gchar* err = NULL;
+        gint last_id = 0;
+        gint word_count = 1;
+        gchar buffer[] = "                     ";
+        gchar last_char[] = "                      ";
+        gchar tran[] = "this is a translation number 10.000 for word 10.000 word <-----";
+        g_sprintf(buffer,"%d word",i);
+/*
+        sql = g_strconcat("INSERT INTO words VALUES(NULL,\'",buffer,"\');", NULL);        
+        result = sqlite_exec(db, sql, NULL, NULL, &err);
+        if(err || result!=0) {
+                g_printf("Error while trying to add new word %d:\n%s\n",i,err);
+                g_free(sql);
+                return 1;
+        }
+        g_free(sql);
+        last_id = sqlite_last_insert_rowid(db);
+        g_sprintf(last_char,"%d",last_id);
+*/
+        if(i == 5000) {
+                word_count = 5;
+                g_printf("Adding more records for word - test\n");
+        }
+        gint j;
+        for(j=0; j<word_count; ++j) {
+                g_sprintf(tran,"this is a translation number %d for word %i",j,i);
+                sql = g_strconcat("INSERT INTO translations VALUES(NULL,\'",buffer,"\',\'",tran,"\');", NULL); 
+                result = sqlite_exec(db, sql, NULL, NULL, &err); 
+                if(err || result!=0) {
+                        g_printf("Error while trying to add new word trans %d:\n %s \n",j,err);
+                        g_free(sql);
+                        return 1;
+                }
+                g_free(sql);             
+        }
+        
+        return result;
+}
+// ----------------------------------------------------------------------------------
+gint main(gint argc, gchar* argv[]) {
+        g_printf("Making new database with %d records...\n",records_number);
+        
+        // create database
+        sqlite* db = database_make("ws_bookmarks");
+        if(!db) return 1;
+
+        // create table for records
+        database_add_test_table(db);
+
+        // create testing records
+        guint i;
+        gint code = 0;
+        for(i=0; i<records_number; ++i) {
+                code = database_add_test_record(db, i);
+                // if there were some errors, do not continue
+                if(code != 0) break;
+                // give to the user some feedback about progress of proccess
+                if(!(i % 50)) {
+                        g_printf("%d / %d records already added to database\n",i,records_number);
+                }
+        }
+
+        // close database
+        sqlite_close(db);
+        return 0;
+}
+// ----------------------------------------------------------------------------------
diff --git a/src/dbus_wrapper/COPYING b/src/dbus_wrapper/COPYING
new file mode 100644 (file)
index 0000000..5ab7695
--- /dev/null
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/src/dbus_wrapper/Doxyfile b/src/dbus_wrapper/Doxyfile
new file mode 100644 (file)
index 0000000..27787aa
--- /dev/null
@@ -0,0 +1,1237 @@
+# Doxyfile 1.4.6
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+PROJECT_NAME           = White Stork DBus Wrapper Module
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+PROJECT_NUMBER         = 0.1
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+OUTPUT_DIRECTORY       = doc/
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+CREATE_SUBDIRS         = NO
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 
+# Swedish, and Ukrainian.
+OUTPUT_LANGUAGE        = English
+# This tag can be used to specify the encoding used in the generated output. 
+# The encoding is not always determined by the language that is chosen, 
+# but also whether or not the output is meant for Windows or non-Windows users. 
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
+# forces the Windows encoding (this is the default for the Windows binary), 
+# whereas setting the tag to NO uses a Unix-style encoding (the default for 
+# all platforms other than Windows).
+USE_WINDOWS_ENCODING   = NO
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+BRIEF_MEMBER_DESC      = YES
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+REPEAT_BRIEF           = YES
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+ABBREVIATE_BRIEF       = 
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+ALWAYS_DETAILED_SEC    = NO
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+INLINE_INHERITED_MEMB  = NO
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+FULL_PATH_NAMES        = NO
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+STRIP_FROM_PATH        = 
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+STRIP_FROM_INC_PATH    = 
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+SHORT_NAMES            = NO
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explicit @brief command for a brief description.
+JAVADOC_AUTOBRIEF      = NO
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+MULTILINE_CPP_IS_BRIEF = NO
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+DETAILS_AT_TOP         = NO
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+INHERIT_DOCS           = YES
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+SEPARATE_MEMBER_PAGES  = NO
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+TAB_SIZE               = 8
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+ALIASES                = 
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+OPTIMIZE_OUTPUT_FOR_C  = YES
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+OPTIMIZE_OUTPUT_JAVA   = NO
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
+# include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+BUILTIN_STL_SUPPORT    = NO
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+DISTRIBUTE_GROUP_DOC   = NO
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+EXTRACT_ALL            = YES
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+EXTRACT_PRIVATE        = YES
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+EXTRACT_STATIC         = YES
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+EXTRACT_LOCAL_CLASSES  = YES
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+EXTRACT_LOCAL_METHODS  = NO
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+HIDE_UNDOC_MEMBERS     = NO
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+HIDE_UNDOC_CLASSES     = NO
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+HIDE_FRIEND_COMPOUNDS  = NO
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+HIDE_IN_BODY_DOCS      = NO
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+INTERNAL_DOCS          = NO
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+CASE_SENSE_NAMES       = YES
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+HIDE_SCOPE_NAMES       = NO
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+SHOW_INCLUDE_FILES     = YES
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+INLINE_INFO            = YES
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+SORT_MEMBER_DOCS       = YES
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+SORT_BRIEF_DOCS        = NO
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+SORT_BY_SCOPE_NAME     = NO
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+GENERATE_TODOLIST      = YES
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+GENERATE_TESTLIST      = YES
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+GENERATE_BUGLIST       = YES
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+GENERATE_DEPRECATEDLIST= YES
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+ENABLED_SECTIONS       = 
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+MAX_INITIALIZER_LINES  = 30
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+SHOW_USED_FILES        = YES
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+SHOW_DIRECTORIES       = NO
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from the 
+# version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+QUIET                  = NO
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+WARNINGS               = YES
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+WARN_IF_UNDOCUMENTED   = YES
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+WARN_IF_DOC_ERROR      = YES
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+WARN_NO_PARAMDOC       = NO
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+WARN_FORMAT            = "$file:$line: $text"
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+INPUT                  = ../../include/ws_dbus.h
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+FILE_PATTERNS          = 
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+RECURSIVE              = YES
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+EXCLUDE                = 
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+EXCLUDE_SYMLINKS       = NO
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+EXCLUDE_PATTERNS       = 
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+EXAMPLE_PATH           = 
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+EXAMPLE_PATTERNS       = 
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+EXAMPLE_RECURSIVE      = NO
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+IMAGE_PATH             = 
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+INPUT_FILTER           = 
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+FILTER_PATTERNS        = 
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+SOURCE_BROWSER         = YES
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+INLINE_SOURCES         = NO
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+STRIP_CODE_COMMENTS    = YES
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+REFERENCED_BY_RELATION = YES
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+REFERENCES_RELATION    = YES
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+USE_HTAGS              = NO
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+ALPHABETICAL_INDEX     = No
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+COLS_IN_ALPHA_INDEX    = 5
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+GENERATE_HTML          = YES
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+HTML_OUTPUT            = html
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+HTML_FILE_EXTENSION    = .html
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+HTML_HEADER            = 
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+HTML_FOOTER            = 
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+HTML_STYLESHEET        = 
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+HTML_ALIGN_MEMBERS     = YES
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+GENERATE_HTMLHELP      = NO
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+CHM_FILE               = 
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+HHC_LOCATION           = 
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+GENERATE_CHI           = NO
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+BINARY_TOC             = NO
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+TOC_EXPAND             = NO
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+DISABLE_INDEX          = NO
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+ENUM_VALUES_PER_LINE   = 1
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+GENERATE_TREEVIEW      = YES
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+GENERATE_LATEX         = YES
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+LATEX_OUTPUT           = latex
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+LATEX_CMD_NAME         = latex
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+MAKEINDEX_CMD_NAME     = makeindex
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+COMPACT_LATEX          = NO
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+PAPER_TYPE             = a4wide
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+EXTRA_PACKAGES         = 
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+LATEX_HEADER           = 
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+PDF_HYPERLINKS         = NO
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+USE_PDFLATEX           = NO
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+LATEX_BATCHMODE        = NO
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+GENERATE_RTF           = NO
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+RTF_OUTPUT             = rtf
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+COMPACT_RTF            = NO
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+RTF_HYPERLINKS         = NO
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+RTF_STYLESHEET_FILE    = 
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+GENERATE_MAN           = NO
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+MAN_OUTPUT             = man
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+MAN_EXTENSION          = .3
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+GENERATE_XML           = NO
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+XML_OUTPUT             = xml
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+XML_SCHEMA             = 
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+XML_DTD                = 
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+GENERATE_PERLMOD       = NO
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+PERLMOD_LATEX          = NO
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+PERLMOD_PRETTY         = YES
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+ENABLE_PREPROCESSING   = YES
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+MACRO_EXPANSION        = NO
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+EXPAND_ONLY_PREDEF     = NO
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+SEARCH_INCLUDES        = YES
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+INCLUDE_PATH           = 
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+INCLUDE_FILE_PATTERNS  = 
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+PREDEFINED             = 
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+EXPAND_AS_DEFINED      = 
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+TAGFILES               = 
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+GENERATE_TAGFILE       = 
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+ALLEXTERNALS           = NO
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+EXTERNAL_GROUPS        = YES
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+CLASS_DIAGRAMS         = YES
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+HIDE_UNDOC_RELATIONS   = YES
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+HAVE_DOT               = NO
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+CLASS_GRAPH            = YES
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+COLLABORATION_GRAPH    = YES
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+GROUP_GRAPHS           = YES
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+UML_LOOK               = NO
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+TEMPLATE_RELATIONS     = NO
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+INCLUDE_GRAPH          = YES
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+INCLUDED_BY_GRAPH      = YES
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+CALL_GRAPH             = NO
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+GRAPHICAL_HIERARCHY    = YES
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+DIRECTORY_GRAPH        = YES
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+DOT_IMAGE_FORMAT       = png
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+DOT_PATH               = 
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+DOTFILE_DIRS           = 
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+MAX_DOT_GRAPH_WIDTH    = 1024
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+MAX_DOT_GRAPH_HEIGHT   = 1024
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that a graph may be further truncated if the graph's 
+# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH 
+# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), 
+# the graph is not depth-constrained.
+MAX_DOT_GRAPH_DEPTH    = 0
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, which results in a white background. 
+# Warning: Depending on the platform used, enabling this option may lead to 
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to 
+# read).
+DOT_TRANSPARENT        = NO
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+DOT_MULTI_TARGETS      = NO
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+GENERATE_LEGEND        = YES
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+SEARCHENGINE           = NO
\ No newline at end of file
diff --git a/src/dbus_wrapper/Makefile b/src/dbus_wrapper/Makefile
new file mode 100644 (file)
index 0000000..ffc74ad
--- /dev/null
@@ -0,0 +1,21 @@
+CC=gcc
+LIBS=`pkg-config --libs glib-2.0 libosso`
+CFLAGS=`pkg-config --cflags glib-2.0 libosso`
+DEBUG = -g -Wall
+BINARY = bin
+MAIN_BINARY = ../../bin
+INCLUDE = ../../include
+SOURCE = src
+DOCS = doc
+
+all:           ${BINARY}/ws_dbus.o 
+                       @cp ${BINARY}/* ${MAIN_BINARY}
+
+docs:          
+               doxygen Doxyfile
+
+${BINARY}/ws_dbus.o:
+                       @${CC} ${DEBUG} -c ${SOURCE}/ws_dbus.c -o ${BINARY}/ws_dbus.o ${CFLAGS} -I${INCLUDE}
+clean:
+                       -rm -rf ${BINARY}/*
+                       -rm -rf ${DOCS}/*
diff --git a/src/dbus_wrapper/src/ws_dbus.c b/src/dbus_wrapper/src/ws_dbus.c
new file mode 100644 (file)
index 0000000..d9be50f
--- /dev/null
@@ -0,0 +1,891 @@
+/*
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation;
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Copyright 2006 ComArch S.A.
+*/
+
+#include <ws_dbus.h>
+
+
+struct _WSDBusMethodData
+{
+        GQuark id;
+        gchar *name;
+        gpointer handler;
+        gpointer user_data;
+        gchar* data_types;
+};
+
+
+typedef struct _WSDBusMethodData WSDBusMethodData;
+
+/*static WSDBusStatus ws_dbus_send_method_data (WSDBusData *ws_dbus_data);*/
+static gchar* ws_dbus_get_ptr2method (GArray *methods, gchar* name );
+static void ws_dbus_libosso_errors (osso_return_t result);
+static void ws_dbus_fill_message (DBusMessage *msg, void *data);
+
+static gchar* ws_dbus_get_ptr2method (GArray *methods, gchar* name)
+
+{
+        guint i;
+       gchar* temp;
+        
+       g_debug ("%d", methods->len);
+       
+       return NULL;
+       
+        for (i = 0; i < methods->len; i+=2)
+                
+        {
+                temp = g_array_index (methods, gchar *,i);
+                        
+                if (strcmp (name, temp) == 0) {
+                       temp = g_array_index (methods, gchar *,i+1);
+                       g_debug ("\nData types: %s\n", temp);
+                       return temp;
+                       }
+
+        };
+        
+        return NULL;
+};
+
+static void ws_dbus_libosso_errors (osso_return_t result)
+
+{
+        switch (result) 
+        {
+                case OSSO_OK: 
+                        g_debug ("All OK\n");
+                        break;
+                        
+                case OSSO_ERROR: 
+                        g_debug ("Ordinary Error\n");
+                        break;
+
+                case OSSO_INVALID: 
+                        g_debug ("At least one parameter is invalid\n");
+                        break;
+
+                case OSSO_RPC_ERROR: 
+                        g_debug ("Osso RPC method returned an error\n");
+                        break;
+
+                case OSSO_ERROR_NAME: 
+                        g_debug ("Error Name\n");
+                        break;
+
+                case OSSO_ERROR_NO_STATE: 
+                        g_debug ("No state file found to read\n");
+                        break;
+
+                case OSSO_ERROR_STATE_SIZE: 
+                        g_debug("The size of the given structure");
+                        g_debug(" is different from the saved size\n");
+                        break;
+        };
+};
+
+
+static WSDBusStatus ws_dbus_run_cb (WSDBusMethodData *method_data, gpointer data)
+
+{
+       g_debug ("%s: Running cb for method %s\n", __FUNCTION__, 
+               method_data->name);
+       
+       ws_dbus_cb cb;
+       osso_rpc_t osso_data;
+       
+       GArray *args = (GArray *) data;
+                       
+       cb = (ws_dbus_cb) method_data->handler;
+       g_debug ("cb pointer address %p\n", cb);
+       
+        if (cb != NULL) 
+        {
+               if (args->len == 0)
+               {
+                       osso_data.type = WS_DBUS_TYPE_STRING;
+                       osso_data.value.s = NULL;
+                       g_array_append_val (args, osso_data);
+               }
+                       
+                cb (NULL, data, method_data->user_data); 
+                return OSSO_OK;
+       }
+       
+        else
+        {
+                g_debug ("DBUS: No callback defined for this function\n");
+                return OSSO_ERROR;
+        };
+};
+
+static gint ws_dbus_cb_handler (const gchar * interface,
+                                const gchar * method,
+                                GArray * arguments,
+                                gpointer data,
+                                osso_rpc_t * retval)
+
+{
+        WSDBusMethodData *method_data;
+        GArray *dbus_method_data;
+        GQuark temp;
+        guint i;
+        dbus_method_data = (GArray *) data;
+        retval = NULL;
+        g_debug ("DBUS: Method:  %s\n", method);
+        temp = g_quark_try_string (method);
+        
+       if (temp != 0) 
+        
+       {
+               for (i=0; i < dbus_method_data->len; ++i)     
+               
+               {
+                       method_data = g_array_index (dbus_method_data, 
+                                       WSDBusMethodData *, i);
+                       
+                        if (method_data->id == temp) 
+                               
+                       {
+                               g_debug ("DBUS: Running callback for %s\n", 
+                                        method);
+                               ws_dbus_run_cb (method_data, arguments);
+                       };
+               
+               };
+               
+        }
+       
+        else 
+        
+       {
+                g_debug ("Error in function %s, couldn't find the signal %s\n",
+                        __FUNCTION__, method);
+                return OSSO_ERROR;
+        };
+       
+       return OSSO_OK;
+};
+
+static void ws_dbus_fill_message (DBusMessage *msg, void *data) 
+{
+
+        guint i;
+        osso_rpc_t *data_unit;
+        GArray *data_bundle;
+       gpointer buffer;
+
+        data_bundle = (GArray *) data;
+       
+       g_debug ("%s, number of fields: %d", __FUNCTION__, data_bundle->len);
+       
+       if (data_bundle->len > 255) 
+               g_debug ("DBUS: Number of fields in message exceeds 255\n");
+
+        for (i=0;((i<data_bundle->len) && (i<255));++i)
+        {
+               data_unit = g_array_index (data_bundle, osso_rpc_t *, i);
+               
+               g_debug ("%s, type: %c, value: ", __FUNCTION__, data_unit->type);
+               
+               switch (data_unit->type)
+               {
+                       case DBUS_TYPE_STRING:
+                               buffer = &data_unit->value.s;
+                               g_debug ("%s", data_unit->value.s);
+                               break;
+                               
+                       case DBUS_TYPE_INT32:
+                               buffer = &data_unit->value.i;
+                               g_debug ("%d", data_unit->value.i);
+                               break;
+                               
+                       case DBUS_TYPE_DOUBLE:
+                               buffer = &data_unit->value.d;
+                               g_debug ("%f", data_unit->value.d);
+                               break;
+                               
+                       case DBUS_TYPE_BOOLEAN:
+                               buffer = &data_unit->value.b;
+                               g_debug ("%d", data_unit->value.b);
+                               break;
+               };
+               
+                if (data_unit->value.s != NULL) {
+                       dbus_message_append_args (msg, 
+                                       data_unit->type, buffer,
+                                       DBUS_TYPE_INVALID);
+               }
+               
+               else 
+                       if (data_bundle->len > 1)
+                               g_debug ("One of the arguments is NULL, ommitting it");
+               
+        };
+       
+        g_debug ("DBUS: Added %d words\n", i);
+};
+
+void ws_dbus_add_remote_methods (GError *error, gpointer data, gpointer user_data)
+{
+       WSDBusData *ws_dbus_data = (WSDBusData *) user_data;
+       GArray *methods_list = (GArray *) data;
+       guint i=0;
+       
+       osso_rpc_t *temp;
+       
+       for (i = 0; i < methods_list->len; ++i)
+       {
+               temp = g_array_index (methods_list, osso_rpc_t *, i);
+               g_array_append_val (ws_dbus_data->remote_method_data, temp->value);                             
+       };
+       
+       return;
+};
+
+WSDBusData * ws_dbus_create (gchar *name, gchar *version)
+
+{
+        WSDBusData *temp;
+
+        temp = (gpointer) g_try_malloc (sizeof (WSDBusData));
+
+        g_debug ("\nDBUS: ");
+
+        if (temp == NULL)
+        {
+                g_debug ("Error in function %s - cannot allocate memory\n",
+                        __FUNCTION__);
+                g_assert_not_reached();
+        }
+
+        else g_debug ("Memory allocation successful\n");
+
+        temp->name = g_strconcat (name, NULL);
+        temp->version = g_strconcat (version, NULL);
+
+        temp->method_data = g_array_new (TRUE, TRUE, sizeof (WSDBusMethodData *));      
+       
+       //Adding callback for remote methods list       
+       //ws_dbus_add_method (temp, "method_data", WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_STRING);
+       //ws_dbus_set_cb (temp, "method_data", ws_dbus_add_remote_methods, NULL);
+    
+        return temp;
+};
+
+WSDBusStatus ws_dbus_config (WSDBusData * ws_dbus_data,
+                             WSDBusConfig field,
+                             gchar *value)
+
+{
+        if (ws_dbus_data == NULL) 
+        {
+                g_debug ("\nDBUS: Error in function %s - ws_dbus_data is NULL\n",
+                        __FUNCTION__);
+        };
+
+        switch (field) 
+        {
+                case WS_DBUS_CONFIG_SERVICE :
+                        ws_dbus_data->service = g_strconcat (value, NULL);
+                        break;
+                case WS_DBUS_CONFIG_OBJECT :
+                        ws_dbus_data->object = g_strconcat (value, NULL);
+                        break;
+                case WS_DBUS_CONFIG_IFACE :
+                        ws_dbus_data->iface = g_strconcat (value, NULL);
+                        break;
+                case WS_DBUS_CONFIG_REMOTE_SERVICE :
+                        ws_dbus_data->remote_service = g_strconcat (value, NULL);
+                        break;
+                case WS_DBUS_CONFIG_REMOTE_OBJECT :
+                        ws_dbus_data->remote_object = g_strconcat (value, NULL);
+                        break;
+                case WS_DBUS_CONFIG_REMOTE_IFACE :
+                        ws_dbus_data->remote_iface = g_strconcat (value, NULL);
+                        break;
+        };
+        
+        return WS_DBUS_STATUS_OK;
+};
+
+WSDBusStatus ws_dbus_connect (WSDBusData * ws_dbus_data)
+
+{
+        osso_return_t result;
+
+        ws_dbus_data->context = osso_initialize (ws_dbus_data->name,
+                                                 ws_dbus_data->version,
+                                                 FALSE,
+                                                 NULL);
+        osso_rpc_set_timeout (ws_dbus_data->context, 100);
+
+        result = osso_rpc_set_cb_f(ws_dbus_data->context, 
+                                ws_dbus_data->service, 
+                                ws_dbus_data->object, 
+                                ws_dbus_data->iface,
+                                ws_dbus_cb_handler, 
+                                ws_dbus_data->method_data);        
+
+       
+       g_debug ("\nWysy³anie danych metod\n");
+       //sends methods list to remote receiver
+       //ws_dbus_send_method_data (ws_dbus_data); 
+       
+        if (result == OSSO_OK) return WS_DBUS_STATUS_OK;
+        else return WS_DBUS_STATUS_ERROR;
+};
+
+void ws_dbus_destroy (WSDBusData * ws_dbus_data)
+
+{
+       guint i;
+       
+        if (ws_dbus_data == NULL) 
+        {
+            g_debug ("\nDBUS: Error in function %s - cannot free osso_context\n",
+                    __FUNCTION__);
+            g_free (ws_dbus_data);
+            g_assert_not_reached();
+        };
+        
+        g_debug ("\nDBUS deinitialization by %s:\n---------------------------\n",
+                ws_dbus_data->service);
+        osso_deinitialize (ws_dbus_data->context);
+        g_debug ("| Deinitializing osso context    |\n");
+        if (ws_dbus_data->method_data != NULL) 
+        {
+               for (i = 0; i < ws_dbus_data->method_data->len; ++i)
+               {
+                       WSDBusMethodData *temp = 
+                                       g_array_index(ws_dbus_data->method_data,
+                                       WSDBusMethodData *, i);
+                       g_free (temp->data_types);
+                       g_free (temp->name);
+                       
+                       g_free (temp);
+               };
+               
+                g_array_free (ws_dbus_data->method_data, TRUE);
+                g_debug ("| Freeing callback pointers list |\n");
+        };
+
+        g_free (ws_dbus_data->name);
+        g_free (ws_dbus_data->version);
+        g_free (ws_dbus_data->service);
+        g_free (ws_dbus_data->object);
+        g_free (ws_dbus_data->iface);
+
+        g_free (ws_dbus_data->remote_service);
+        g_free (ws_dbus_data->remote_object);
+        g_free (ws_dbus_data->remote_iface);
+       
+/*     if (ws_dbus_data->remote_method_data != NULL) 
+       {
+               for (i = 0; i < ws_dbus_data->remote_method_data->len; ++i)
+               {
+                       g_free (g_array_index(ws_dbus_data->remote_method_data,
+                               gchar*, i));
+               };
+               g_array_free (ws_dbus_data->remote_method_data, TRUE);
+       };*/
+
+        g_free (ws_dbus_data);
+        g_debug ("| Freeing WSDBusData structure   |\n----------------------\n");
+};
+
+
+WSDBusStatus ws_dbus_set_cb (WSDBusData * ws_dbus_data,
+                             gchar * method,
+                             gpointer c_func,
+                             gpointer user_data)
+
+{
+        WSDBusMethodData *method_data;
+        GQuark temp;
+        guint i;
+
+        temp = g_quark_try_string  (method);
+
+        if (temp == 0) 
+        {
+              g_debug ("DBUS:\"%s\"- method not defined or invalid method name\n",
+                      method);
+              return WS_DBUS_STATUS_ERROR;
+        }
+
+        else
+        {
+               
+                for (i = 0; i < ws_dbus_data->method_data->len; ++i)
+                {
+                        method_data = g_array_index (ws_dbus_data->method_data,
+                                                 WSDBusMethodData *,
+                                                 i);
+                        
+                        if (method_data->id == temp)
+        
+                        {
+                                method_data->handler = c_func;
+                                method_data->user_data = user_data;
+                                g_array_insert_val(ws_dbus_data->method_data,
+                                                   i,
+                                                   method_data);
+                                g_array_remove_index (ws_dbus_data->method_data,
+                                                      i+1);
+                        };
+
+                };
+        
+        };
+       
+//     ws_dbus_send_method_data (ws_dbus_data);
+
+        return WS_DBUS_STATUS_OK;
+};
+
+WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...)
+
+{
+        WSDBusMethodData *method_data;
+       WSDBusDataType data_type;
+        GQuark temp;
+       gchar *buffer;
+       va_list arglist;
+
+        temp = g_quark_try_string (method);
+
+        if (temp == 0) 
+        {       
+                method_data = g_try_malloc (sizeof (WSDBusMethodData));
+                
+                if (method_data != NULL)
+                {
+                       va_start (arglist, method);
+                       
+                        method_data->id = g_quark_from_string (method);
+                        method_data->name = g_strdup (method);
+       
+                       data_type = va_arg (arglist, WSDBusDataType);
+                       
+                       method_data->data_types = g_strdup("");
+                       
+                       while (data_type != WS_DBUS_TYPE_INVALID)
+                       {
+                               buffer = method_data->data_types;
+                               
+                               method_data->data_types = g_strdup_printf ("%s%c", 
+                                               method_data->data_types, 
+                                               (gchar) data_type );
+                                               
+                               g_free (buffer);
+                               
+                               data_type = va_arg (arglist, WSDBusDataType);
+                       };
+                       
+                       g_debug ("%d, %s, %s\n", method_data->id, method_data->name, method_data->data_types);
+                       
+                       va_end (arglist);
+                       
+                        g_array_append_val (ws_dbus_data->method_data, method_data);
+                }
+                
+                else g_debug ("DBUS: Failed to allocate memory for method data");
+                
+        }
+
+        else
+        {
+                g_debug ("DBUS:\"%s\"- method has already been registered\n",
+                      method);
+                
+                return WS_DBUS_STATUS_ERROR;
+        };
+
+        return WS_DBUS_STATUS_OK;
+};
+
+WSDBusStatus ws_dbus_add_garray (GArray *data_bundle, GArray *strings)
+
+{
+       osso_rpc_t *temp;
+       guint i;
+
+       if (strings != NULL)
+       {
+
+               for (i = 0; i < strings->len; ++i)
+               {
+                       temp = g_try_malloc (sizeof (osso_rpc_t));
+                       temp->type = WS_DBUS_TYPE_STRING;
+                       temp->value.s = g_array_index (strings, gchar *, i);
+                       g_debug ("%d, %s", temp->type, temp->value.s);
+                       g_array_append_val (data_bundle, temp);
+               };
+
+               return WS_DBUS_STATUS_OK;
+
+       }
+
+       else 
+       {
+               printf ("\n%s - Error - GArray is NULL", __FUNCTION__);
+               return WS_DBUS_STATUS_ERROR;
+       };
+       
+};
+
+WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method, ...)
+
+{
+       va_list arglist;
+       GArray *data_to_send;
+       osso_rpc_t *temp, *retval;
+        osso_return_t result;
+       GArray *temp_garray;
+       
+       data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+       
+       va_start (arglist, method);
+       
+       while (1)
+       {
+               temp = g_try_malloc (sizeof (osso_rpc_t));
+               
+               temp->type = va_arg (arglist, WSDBusDataType);
+               
+               g_debug ("Type: %c ", temp->type);
+               
+               if (temp->type == WS_DBUS_TYPE_INVALID) break;
+               
+               switch (temp->type)
+               {
+                       case WS_DBUS_TYPE_STRING:
+                               temp->value.s = va_arg (arglist, gchar *);
+                               g_debug ("Value: %s\n", temp->value.s);
+                               break;
+                       case WS_DBUS_TYPE_INT:
+                               temp->value.i = va_arg (arglist, gint);
+                               g_debug ("Value: %d\n", temp->value.i);
+                               break;
+                       case WS_DBUS_TYPE_UINT:
+                               temp->value.u = va_arg (arglist, guint);
+                               g_debug ("Value: %d\n", temp->value.u);
+                               break;
+                       case WS_DBUS_TYPE_DOUBLE:
+                               temp->value.d = va_arg (arglist, gdouble);
+                               g_debug ("Value: %f\n", temp->value.d);
+                               break;
+                       case WS_DBUS_TYPE_BOOLEAN:
+                               temp->value.b = va_arg (arglist, gboolean);
+                               g_debug ("Value: %d\n", temp->value.b);
+                               break;
+                       case WS_DBUS_TYPE_GARRAY:
+                               temp_garray = va_arg (arglist, GArray *);
+                               ws_dbus_add_garray (data_to_send, 
+                                                       temp_garray);
+                               g_debug ("Value: GArray of strings");
+                               break;
+               };
+               g_debug ("Type: %c %d", temp->type, temp->value.i);
+               
+               if (temp->type != WS_DBUS_TYPE_GARRAY) 
+                       g_array_append_val (data_to_send, temp);
+       };
+       
+       va_end (arglist);
+
+       g_debug ("%s, method %s, added %d arguments", __FUNCTION__, 
+                method, data_to_send->len);
+       
+       
+        retval = g_try_malloc (sizeof (osso_rpc_t));
+
+        if (retval == NULL) 
+        {
+                g_debug("DBUS: Error in function %s:",__FUNCTION__);
+                g_debug("Couldn't allocate memory for message's return value\n");
+        };
+
+        result = osso_rpc_run_with_argfill (ws_dbus_data->context, 
+                                            ws_dbus_data->remote_service, 
+                                            ws_dbus_data->remote_object, 
+                                            ws_dbus_data->remote_iface, 
+                                            method,
+                                            retval,
+                                            ws_dbus_fill_message,
+                                            data_to_send);
+       
+        g_debug ("\nDBUS: %s: ", __FUNCTION__);
+
+        ws_dbus_libosso_errors (result);
+       
+       guint i;
+       
+       for (i = 0; i < data_to_send->len; ++i)
+       {
+               g_free (g_array_index(data_to_send, osso_rpc_t*,i));
+       };
+       
+       g_array_free (data_to_send, TRUE);
+
+        if (result != OSSO_OK)
+        {
+                g_debug ("Error message: %s\n", retval->value.s);
+                osso_rpc_free_val (retval);
+                g_free (retval);
+                return WS_DBUS_STATUS_ERROR;
+        };
+
+        osso_rpc_free_val (retval);
+        g_free (retval);
+       return WS_DBUS_STATUS_OK;
+};
+
+WSDBusStatus ws_dbus_call_registered_method (WSDBusData * ws_dbus_data, gchar *method, ...)
+
+{
+       va_list arglist;
+       guint i;
+       GArray *data_to_send;
+       osso_rpc_t *temp;
+        osso_return_t result;
+        osso_rpc_t *retval;
+       
+       gchar* data_types = ws_dbus_get_ptr2method (
+                                               ws_dbus_data->remote_method_data,
+                                               method);
+       
+       g_debug ("\n%s\n", data_types);
+       
+       data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+       
+       va_start (arglist, method);
+       
+       for (i = 0; i < strlen (data_types); ++i)
+       {
+               temp = g_try_malloc (sizeof (osso_rpc_t));
+               
+               switch ((char) data_types[i])
+               {
+                       case WS_DBUS_TYPE_STRING:
+                                       temp->value.s = va_arg (arglist, gchar *);
+                                       break;
+                       case WS_DBUS_TYPE_INT:
+                                       temp->value.i = va_arg (arglist, gint);
+                                       break;
+                       case WS_DBUS_TYPE_UINT:
+                                       temp->value.u = va_arg (arglist, guint);
+                                       break;
+                       case WS_DBUS_TYPE_DOUBLE:
+                                       temp->value.d = va_arg (arglist, gdouble);
+                                       break;
+                       case WS_DBUS_TYPE_BOOLEAN:
+                                       temp->value.b = va_arg (arglist, gboolean);
+                                       break;
+               };
+               
+               g_array_append_val (data_to_send, temp);
+       };
+       
+       va_end (arglist);
+
+        retval = g_try_malloc (sizeof (osso_rpc_t));
+
+        if (retval == NULL) 
+        {
+                g_debug("DBUS: Error in function %s:",__FUNCTION__);
+                g_debug("Couldn't allocate memory for message's return value\n");
+        };
+
+        result = osso_rpc_run_with_argfill (ws_dbus_data->context, 
+                                            ws_dbus_data->remote_service, 
+                                            ws_dbus_data->remote_object, 
+                                            ws_dbus_data->remote_iface, 
+                                            method,
+                                            retval,
+                                            ws_dbus_fill_message,
+                                            data_to_send);
+        g_debug ("\nDBUS: %s: ", __FUNCTION__);
+
+        ws_dbus_libosso_errors (result);
+
+        if (result != OSSO_OK)
+        {
+                g_debug ("Error message: %s\n", retval->value.s);
+                osso_rpc_free_val (retval);
+                g_free (retval);
+                return WS_DBUS_STATUS_ERROR;
+        };
+
+        osso_rpc_free_val (retval);
+        g_free (retval);
+        return WS_DBUS_STATUS_OK;
+       
+       return WS_DBUS_STATUS_OK;
+};
+
+/*
+WSDBusStatus ws_dbus_run_method (WSDBusData * ws_dbus_data, gchar *method, ...)
+
+{
+       va_list arglist;
+       guint i;
+       GArray *data_to_send;
+       osso_rpc_t *temp;
+        osso_return_t result;
+        osso_rpc_t *retval;
+       
+       gchar* method_data = ws_dbus_get_ptr2method (
+                                               ws_dbus_data->method_data,
+                                               method);
+       
+       data_to_send = g_array_new (TRUE, TRUE, sizeof (osso_rpc_t *));
+       
+       va_start (arglist, method);
+       
+       g_debug ("%p\n\n%p\n\n", method_data, method_data->data_types);
+       
+       for (i = 0; i < strlen (method_data->data_types); ++i)
+       {
+               temp = g_try_malloc (sizeof (osso_rpc_t));
+               temp->type =  method_data->data_types[i];
+               
+               switch ((char) method_data->data_types[i])
+               {
+                       case WS_DBUS_TYPE_STRING:
+                               temp->value.s = va_arg (arglist, gchar *);
+                               break;
+                       case WS_DBUS_TYPE_INT:
+                               temp->value.i = va_arg (arglist, gint);
+                               break;
+                       case WS_DBUS_TYPE_SIGNAL:
+                       case WS_DBUS_TYPE_UINT:
+                               temp->value.u = va_arg (arglist, guint);
+                               break;
+                       case WS_DBUS_TYPE_DOUBLE:
+                               temp->value.d = va_arg (arglist, gdouble);
+                               break;
+                       case WS_DBUS_TYPE_BOOLEAN:
+                               temp->value.b = va_arg (arglist, gboolean);
+                               break;
+               };
+                               
+               g_array_append_val (data_to_send, temp);
+       };
+       
+       va_end (arglist);
+
+        retval = g_try_malloc (sizeof (osso_rpc_t));
+
+        if (retval == NULL) 
+        {
+                g_debug("DBUS: Error in function %s:",__FUNCTION__);
+                g_debug("Couldn't allocate memory for message's return value\n");
+        };
+
+        result = osso_rpc_run_with_argfill (ws_dbus_data->context, 
+                                            ws_dbus_data->remote_service, 
+                                            ws_dbus_data->remote_object, 
+                                            ws_dbus_data->remote_iface, 
+                                            method,
+                                            retval,
+                                            ws_dbus_fill_message,
+                                            data_to_send);
+        g_debug ("\nDBUS: %s: ", __FUNCTION__);
+
+        ws_dbus_libosso_errors (result);
+registered_
+        if (result != OSSO_OK)
+        {
+                g_debug ("Error message: %s\n", retval->value.s);
+                osso_rpc_free_val (retval);
+                g_free (retval);
+                return WS_DBUS_STATUS_ERROR;
+        };
+
+        osso_rpc_free_val (retval);
+        g_free (retval);
+        return WS_DBUS_STATUS_OK;
+       
+       return WS_DBUS_STATUS_OK;
+};
+*/
+
+
+/*static void ws_dbus_fill_method_data (DBusMessage *msg, void *data) 
+{
+
+        guint i;
+        WSDBusMethodData *buffer;
+        GArray *temp;
+
+        temp = (GArray *) data;
+
+        for (i=0;((i<temp->len) && (i<255));++i)
+        {
+                buffer = g_array_index (temp, WSDBusMethodData *, i);
+               
+               g_debug ("name: %s\ntypes: %s", buffer->name, buffer->data_types);
+               
+               return;
+               
+                dbus_message_append_args (msg, DBUS_TYPE_STRING, buffer->name, 
+                               DBUS_TYPE_STRING, buffer->data_types,
+                                DBUS_TYPE_INVALID);
+        };
+        g_debug ("DBUS: Added %d words\n", i);
+};
+
+WSDBusStatus ws_dbus_send_method_data (WSDBusData *ws_dbus_data)
+{
+        osso_return_t result;
+        osso_rpc_t *retval;
+
+        retval = g_try_malloc (sizeof (osso_rpc_t));
+
+        if (retval == NULL) 
+        {
+                g_debug("DBUS: Error in function %s:",__FUNCTION__);
+                g_debug(" Couldn't allocate memory for message's return value\n");
+        };
+        
+        result = osso_rpc_run_with_argfill (ws_dbus_data->context, 
+                                            ws_dbus_data->remote_service, 
+                                            ws_dbus_data->remote_object, 
+                                            ws_dbus_data->remote_iface, 
+                                            "method_data",
+                                            retval,
+                                            ws_dbus_fill_method_data,
+                                            ws_dbus_data->method_data);
+
+        g_debug ("\nDBUS: %s: ", __FUNCTION__);
+
+        ws_dbus_libosso_errors (result);
+
+        if (result != OSSO_OK)
+        {
+                g_debug ("Error message: %s\n", retval->value.s);
+                osso_rpc_free_val (retval);
+                g_free (retval);
+                return WS_DBUS_STATUS_ERROR;
+        };
+
+        osso_rpc_free_val (retval);
+        g_free (retval);
+        return WS_DBUS_STATUS_OK;
+};*/
diff --git a/src/gui/include/pc-instances.h b/src/gui/include/pc-instances.h
new file mode 100644 (file)
index 0000000..5cf6b7d
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _PC_INSTANCES_H_
+#define _PC_INSTANCES_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// stadards headers
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+// headers with unix types/functions - only for timers and files operations
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+//------------------------------------------------------------------------------
+/** \brief Get comandline by which process in /proc tree was invoked.
+ *
+ * @param process describes which process from /proc tree we want to check. It
+ * should be only concrete directory from /proc nothing else. e.g.: /proc/self,
+ * /proc/8321 etc. Something like /proc or /proc/self is not good.
+ * @return string containing comandline which has invoked process. If NULL there
+ * were some problems, possibly parameter were wrong or ther is no such
+ * a process.
+ */
+char* get_process_cmdline(char* process);
+
+//------------------------------------------------------------------------------
+/** \brief Cut from commandline only program file name.
+ *
+ * @param cmdline commandline which from which we want to remove options.
+ * @return string with only program file name, or NULL if there was any problem
+ */
+char* get_process_program_file(char* cmdline);
+
+//------------------------------------------------------------------------------
+/** \brief Get file name containing programm executing by current process.
+ *
+ * @return file name of program or NULL if there were some problems.
+ */
+char* get_current_process_program_file();
+
+//------------------------------------------------------------------------------
+/** \brief Check if there is another instance of current programm.
+ *
+ * @return integer telling how many processes were initiated with the same
+ * program as curent process. If it is 1, it means there is no other procces.
+ * If > 1 there is another instance.
+ */
+int is_already_running_this_application();
+
+
+
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+#endif /* _PC_INSTANCES_H_ */
diff --git a/src/gui/include/ws_gui.h b/src/gui/include/ws_gui.h
new file mode 100644 (file)
index 0000000..66c9607
--- /dev/null
@@ -0,0 +1,277 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_GUI
+#define _WS_GUI 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <hildon-widgets/hildon-program.h>
+#include <hildon-widgets/hildon-window.h>
+#include <hildon-widgets/hildon-banner.h>
+#include <hildon-widgets/hildon-find-toolbar.h>
+#include <hildon-fm/hildon-widgets/hildon-file-chooser-dialog.h>
+#include <hildon-widgets/hildon-caption.h>
+#include <gtk/gtkfilechooser.h>
+#include <gtk/gtkdialog.h>
+#include <gdk/gdkkeysyms.h>
+
+#include <hildon-widgets/gtk-infoprint.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <gtkhtml/gtkhtml.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/time.h>
+
+#include <ws_dbus.h>
+
+#include <gtkhtml/gtkhtml-stream.h>
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+
+#define ZOOM_MIN 1.000000
+#define ZOOM_MAX 2.000000
+#define ZOOM_STEP 0.100000
+#define ZOOM_DEFAULT 1.300000
+#define PRESS_TIME 1.0
+#define HISTORY_LEN 5
+#define SCROLL_STEP_H 50
+#define SCROLL_STEP_V 20
+#define GCONF_PATH "/apps/maemo/WhiteStork/Dictionaries"
+#define GCONF_CONF "/apps/maemo/WhiteStork/configuration"
+
+
+#include <libintl.h>
+#include <locale.h>
+
+#define _(String) gettext (String)
+#define WS_GUI_ABS(x) (((x)<0.0)?((-1)*(x)):(x))
+
+void html_engine_unselect_all(HTMLEngine   *e);
+void html_engine_block_selection (HTMLEngine   *e);
+gboolean html_engine_is_selection_active (HTMLEngine *e);
+
+typedef struct WSGuiAppData WSGuiApp;
+
+enum
+{
+  COL_WORD = 0,
+  NUM_COLS
+};
+
+
+/** \brief struct which manage layout of html (translation) area
+ *
+ * here are placed all components of application menu and popup menu
+ */
+struct HtmlLayout {
+gchar *bg_color;
+gchar *bg_image;
+gchar *bg_font_color;
+
+gchar *th_color;
+gchar *th_image;
+gchar *th_font_color;
+
+gchar *td_color;
+gchar *td_image;
+gchar *td_font_color;
+};
+
+/** \brief struct which contains components of menu
+ *
+ * here are placed all components of application menu and popup menu
+ */
+struct WSGuiMenu {
+       /*application menu*/
+       GtkWidget *ws_gui_main_menu; ///< application submenu
+       GtkWidget *ws_gui_menu_dictionaries; ///< dictionaries submenu (managing with the dictionary files)
+       GtkWidget *ws_gui_menu_load_dict; ///<menuitem in dictionaries submenu; load new dictionary file into application
+       GtkWidget *ws_gui_menu_select_dict; ///<menuitem in dictionaries submenu; allow to select which dictionaries are used
+       GtkWidget *ws_gui_menu_remove_dict; ///<menuitem in dictionaries submenu; remove dictionary files which are no longer used
+       GtkWidget *ws_gui_menu_optimize_dict; ///< menuitem used for optimizing dictionaries
+       
+       GtkWidget *ws_gui_menu_bookmarks; ///bookmarks submenu 
+       GtkWidget *ws_gui_menu_open_bookmark; ///menuitem, opens bookmark window
+       GtkWidget *ws_gui_menu_close_bookmark; ///menuitem, closes bookmark window
+       GtkWidget *ws_gui_menu_add_bookmark; ///menuitem used fot adding bookmarks
+       GtkWidget *ws_gui_menu_remove_bookmark; ///menuitem, allows for removing bookmarks
+       
+       GtkWidget *ws_gui_menu_edit; ///< edit submenu(connected with text editing)
+       GtkWidget *ws_gui_menu_copy; ///< menuitem in edit submenu; copy selected text to the clipboard
+       GtkWidget *ws_gui_menu_paste; ///< menuitem in edit submenu; paste content of the clipboard into find toolbar entry
+       GtkWidget *ws_gui_menu_select_all; ///< menuitem in edit submenu; select whole text in the translation (html) area 
+       GtkWidget *ws_gui_menu_view; ///< view submenu
+       GtkWidget *ws_gui_menu_hide_list; ///< menuitem which allows to hide/show words list
+       GtkWidget *ws_gui_menu_zoom_in; ///< menuitem which allows to zoom in text in the translation area
+       GtkWidget *ws_gui_menu_zoom_out; ///< menuitem which allows to zoom out text in the translation area
+       GtkWidget *ws_gui_menu_full_screen; ///< menuitem which allows to switch between fullscreen and normal mode
+       GtkWidget *ws_gui_menu_search; ///< search submenu (connected with searching)
+       GtkWidget *ws_gui_menu_find_word; ///< menuitem which allows to start searching
+       GtkWidget *ws_gui_menu_find_prev; ///< menuitem which allows to find previous word from the history
+       GtkWidget *ws_gui_menu_find_next; ///< menuitem which allows to find next word in the history 
+       GtkWidget *ws_gui_menu_stop; ///< menuitem which stops search
+       GtkWidget *ws_gui_menu_about; ///< menuitem which opens 'about application' dialog window
+       GtkWidget *ws_gui_menu_close; ///< menuitem which closes the application
+       
+       GtkWidget *ws_gui_submenu_0; ///< submenu which is necessaty to build dictionaries submenu
+       GtkWidget *ws_gui_submenu_1; ///< submenu which is necessary to build edit submenu
+       GtkWidget *ws_gui_submenu_2; ///< submenu which is necessary to build view submenu
+       GtkWidget *ws_gui_submenu_3; ///< submenu which is necessary to build search submenu
+       GtkWidget *ws_gui_submenu_4; ///< submenu which is necessary to build search submenu
+       GtkWidget *ws_gui_separator; ///< separator, it is used to provide nice layout
+       
+       /*ws_gui_menu popup*/
+       GtkWidget *ws_gui_popup_menu;  ///< popup menu
+       GtkWidget *ws_gui_popup_search;///< search option, allow to search selected text
+       GtkWidget *ws_gui_popup_bookmark;///< search option, allow to search selected text
+       GtkWidget *ws_gui_popup_edit; ///< edit submenu
+       GtkWidget *ws_gui_popup_submenu; ///< submenu (necessary to create edit submenu)
+       GtkWidget *ws_gui_popup_copy; ///< menuitem which allows to copy selected to the clipboard
+       GtkWidget *ws_gui_popup_paste; ///< menuitem which allows to paste content of the clipboard into find toolbar entry
+       GtkWidget *ws_gui_popup_select_all; ///<menuitem which allows to select whole text in translation area
+       GtkWidget *ws_gui_popup_zoom_in; ///< menuitem which allows to zoom in text in translation area
+       GtkWidget *ws_gui_popup_zoom_out; ///< menuitem which allows to zoom in text in translation area
+       
+       GtkWidget *ws_gui_separator1; ///< separator, it is used to provide nice layout
+       GtkWidget *ws_gui_separator2; ///< separator, it is used to provide nice layout
+};
+
+/** \brief struct which contains components of words list
+ *
+ * here are placed all components of words list (inside left scrollwindow)
+ */
+struct WSGuiList {
+       GtkWidget* ws_gui_list; ///< list which contains words
+       GtkWidget* ws_gui_list_item; ///< item in words list (each word)
+       GtkWidget* ws_gui_list_label; ///< label, necessary to place word in words list
+       
+       GtkObject* ws_gui_list_item_object; ///< object which stores data of selected item (from words list)
+       //gchar* ws_gui_list_item_data_string; ///< variable which stores translation of word (html content)
+
+       GtkListStore* ws_gui_store; ///< list necessary to present words list
+       GtkTreeIter ws_gui_iter; ///< variable necessary to present words list
+       GtkCellRenderer* ws_gui_renderer; ///< variable necessary to draw GtkTree 
+       GtkTreeModel* ws_gui_model; ///< model of GtkTree
+       GtkWidget* ws_gui_view; ///< variable responsible for view of GtkTree
+       GtkTreeSelection* ws_gui_selection; ///< variable necessary to read selection (from words list)
+};
+
+/** \brief struct which contains all components of application
+ *
+ * here are placed all components of main window, toolbar, structures responsible for menus and variables responsible for adjustments, words history, banners, message dialogs and everything what user can see and use
+ */
+struct WSGuiAppData {
+       HildonProgram *ws_gui_hildon_program; ///< handle to hildon program
+       HildonWindow *ws_gui_hildon_window; ///< handle to hildon window
+       gchar *welcome_note; ///< welcome note
+       GtkWidget *ws_gui_html; ///< translation (html) area 
+       GtkWidget *ws_gui_hpane; ///< pane; it allows to divide window into two separate panels
+       HildonFindToolbar *ws_gui_hildon_find_toolbar; ///< find toolbar (placed at the bottom of the window)
+       GtkToolItem *ws_gui_toobar_button_close; ///< close button at the find toolbar
+       GtkToolItem *ws_gui_toobar_button_back; ///< back button at the find toolbar (history navigator)
+       GtkToolItem *ws_gui_toobar_button_forward; ///< next button at the find toolbar (history navigator)
+       GtkToolItem *ws_gui_toobar_button_stop; ///< stop butoon at the find toolbar (allows to stop searching)
+       GtkToolItem *ws_gui_toobar_button_start; ///< stop butoon at the find toolbar (allows to stop searching)
+       GtkWidget *ws_gui_banner_list_searching; ///< banner, displays message that searching is in progress
+       GtkWidget *ws_gui_banner_caching; ///< banner, displays message that caching is in progress
+       GtkWidget *ws_gui_banner_translation_loading; ///< banner, displays message that translation is loading
+       gboolean caching_flag; ///< flag; used when caching is being performed
+       gboolean loading; 
+       gboolean stop_clicked; 
+       GtkWidget *ws_gui_banner_extracting;
+       GtkToolItem *ws_gui_toobar_button_hide; ///< button hide, allows to hide/show words list with button placed at find toolbar
+       GtkWidget *ws_gui_scrolledwindow_right; ///< right scrolledwindow (placed in right pane), necessary to provide scrollbars)
+       GtkWidget *ws_gui_scrolledwindow_left; ///< scrollwindow (placed in left pane), necessary to provide scrollbars)
+
+       GtkWidget *ws_gui_list_vbox;
+       GtkWidget *ws_gui_list_hbox;
+       GtkWidget *ws_gui_list_label;
+       GtkWidget *ws_gui_list_eventbox;
+       GtkWidget *ws_gui_list_image;
+
+       gchar *ws_gui_html_source; ///< string which contains html content (translation of word)
+       
+       GtkAdjustment* ws_gui_vadj; ///< vertical adjustment of left scrolledwindow (necessary to provide navigation (kardware keys) inside words list)
+       GtkAdjustment* ws_gui_hadj; ///< horizontal adjustment of left scrolledwindow (necessary to provide navigation (kardware keys) inside words list)
+       gdouble v_delta; ///< variable used for moving vertical scrollbar in words list
+       gdouble v_new_value; ///< variable used for moving vertical scrollbar in words list
+       gdouble h_delta; ///< variable used for moving horizontal scrollbar in words list
+       gdouble h_new_value; ///< variable used for moving horizontal scrollbar in words list
+       gdouble cur_vadj; ///< current vertical adjustment of vertical scrollbar in words list
+       gdouble prev_vadj; ///< previous vertical adjustment of vertical scrollbar in words list
+       gdouble cur_hadj; ///< current vertical adjustment of horizontal scrollbar in words list
+       gdouble prev_hadj; ///< previous vertical adjustment of horizontal scrollbar in words list
+       
+       GArray *ws_gui_history; ///< words history
+       GArray *ws_gui_history_list;
+       GArray *ws_gui_history_iter;
+       GArray *ws_gui_history_bookmarks;
+       gboolean history_flag;
+       gint ws_gui_history_cur_pos; ///< current position in words history array 
+       
+
+       struct WSGuiMenu *ws_gui_menu; ///< structure responsible for menus
+       struct WSGuiList *ws_gui_w_list; ///< structure responsible for words list
+       
+       gboolean ws_gui_banner_flag; ///< flag; used for notifing if searching is in progress and banner has to be displaying
+       gboolean ws_gui_full_screen_flag; ///< flag; used for informing if fullscreen mode is active
+       gboolean ws_gui_double_click; ///< flag; necessary to recognize double click
+       gboolean ws_gui_sel_flag; ///< flag; used to identify selected text
+       
+       WSDBusData *dbus_data; ///< DBUS declaration
+       
+       GtkWidget* ws_message_dialog; ///< message dialogs; used for informing user about errors
+       
+       GSList *directories; ///< list consist of directories previously read from gconf
+       GSList *directories_last; ///< list consist of directories previously read from gconf
+       GConfClient *client; ///< variable necessary to read from gconf
+       GtkClipboard *ws_gui_clipboard; ///< application clipboard (available outside the application as well)
+       GtkClipboard *ws_gui_clipboard_primary;
+       PangoFontDescription* p; ///< schema, which allows to format text on widgets
+       GtkWidget *licence_dialog; ///< variable necessary to create license dialog
+       GTimer *timer; ///< timer, counts how long user press button (stylus)
+       GArray *bookmarks_list; ///< array wchich contains bookmarked words
+       gboolean bookmark_on; ///< flag which switch beetween bookmark and normal mode
+       gchar *word_book; ///< word added to the bookmarks
+       gchar *translation_book; ///< translation of the word added to bookmarks
+       
+       gboolean bookmark_avail; ///< flag, denpends on availablity of bookmarks module
+       gboolean bookmark_mode; ///< flag, shows either bookmarks mode is on or off
+       gchar *last_word; ///< stores last choosen word on the words list (necessary for bookmarks)
+       GString *raw_translation; ///< stores current translation, if user wants to add it to bookmarks
+       gchar *last_searched;
+       gchar *last_searched_in_book;
+       gdouble zoom;
+       gboolean html_flag;
+
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gui/include/ws_gui_callbacks.h b/src/gui/include/ws_gui_callbacks.h
new file mode 100644 (file)
index 0000000..3610c42
--- /dev/null
@@ -0,0 +1,264 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_GUI_CALLBACKS
+#define _WS_GUI_CALLBACKS 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <ws_gui.h>
+
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>     
+#include <unistd.h>   
+
+#define TIMER_START TRUE
+#define TIMER_STOP  FALSE
+
+
+/* added by Dariusz Wiechecki - HISA */
+void ws_gui_search_home_handler(GError *error, GArray *word, gpointer user_data);
+
+/*do dbusa*/
+/** \brief handle dbus signals
+ *
+ */
+void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data);
+
+/** \brief handle signal from dbus and updates progress bar(in order to caching)
+ *
+ */
+void ws_dbus_progress_bar(GError *error, GArray *words, gpointer user_data);
+
+/** \brief clean words list
+ *
+ */
+void ws_gui_clear_list (GtkListStore* list);
+
+/** \brief handle dbus signal and transfer words to the words list
+ *
+ */
+void ws_gui_dbus_return_words (GError *error, 
+                              GArray *words, 
+                              gpointer user_data);
+
+/** \brief handle dbus signal and convert message into readable text 
+ *
+ */
+void ws_gui_dbus_return_translation (GError *error, 
+                                     GArray *words,
+                                     gpointer user_data);
+
+/** \brief handle dbus signal and load extracted dictionary 
+ *
+ */
+void ws_dbus_server_return_extracted_bzip(GError *error, 
+                                         GArray *words, 
+                                         gpointer user_data);
+
+/**  \brief is used to free memory, which was allocated
+*
+*/
+void ws_gui_free_memory(gpointer user_data);
+
+/**  \brief handle keys press signals (hardware keys in device)
+*
+*/
+gboolean hildon_key_press_listener (GtkWidget * widget,
+                                    GdkEventKey * keyevent,
+                                    gpointer user_data);
+
+/**  \brief allow to hide words list from menu
+*
+*/
+void ws_gui_words_list_hide_from_menu(GtkCheckMenuItem *checkmenuitem,
+                                      gpointer user_data);
+
+/**  \brief allow to hide words list from toolbar
+*
+*/
+void ws_gui_words_list_hide(GtkToggleButton *togglebutton, gpointer user_data);
+
+/**  \brief add word to the words history
+*
+*/
+void ws_gui_history_add(char *new_word, gpointer user_data);
+
+/**  \brief display translation of word stored in the history (if available)
+*
+*/
+void ws_gui_history_back(GtkButton *button, gpointer user_data);
+
+/**  \brief display translation of word stored in the history (if available)
+*
+*/
+void ws_gui_history_next(GtkButton *button, gpointer user_data);
+
+/** \brief check history and disable buttons or uncheck checkbuttons 
+ *
+ */
+void ws_gui_check_history(gpointer user_data);
+
+/** \brief creates model and view of words list
+ *
+ */
+GtkWidget * create_view_and_model (GArray *words_list, gpointer user_data);
+
+/** \brief creates words list and fill it with content
+ *
+ */
+GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data);
+
+/**  \brief switch view between full screen and normal mode 
+*
+*/
+void ws_gui_full_screen(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief search for selected text in a dictionary
+*
+*/
+void ws_gui_popup_search(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief allows to select whole text in translation (html) area
+*
+*/
+void ws_gui_html_select_all(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief allows to copy text from translation (html) area into clipboard
+*
+*/
+void ws_gui_html_copy(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief allows to paste text from the clipboard into find toolbar entry
+*
+*/
+void ws_gui_html_paste(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief magnify translation (html) area
+*
+*/
+void ws_gui_html_zoom_in(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief zoom out translation (html) area.
+*
+*/
+void ws_gui_html_zoom_out(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief start search (sends typed word to the engine)
+*
+*/
+void ws_gui_search(GtkWidget * widget, gpointer user_data);
+
+/**  \brief  abort search
+*
+*/
+void ws_gui_search_stop(GtkButton *button, gpointer user_data);
+
+/**  \brief used when user closes the application
+*
+*/
+void ws_gui_on_exit (GtkWidget *widget, GdkEvent *event, gpointer user_data);
+
+/**  \brief used when user closes the application from menu
+*
+*/
+void ws_gui_menu_quit(GtkMenuItem *menuitem, gpointer user_data);
+
+/**  \brief sets content of translation (html) area
+*
+*/
+void ws_gui_fill_html(char *html_context, gpointer user_data);
+
+/** \brief read current adjustment value
+ *
+ */
+void ws_gui_read_adjustment(gpointer user_data);
+
+/** \brief necessary to load images into translation (html) area
+ *
+ */
+void ws_gui_url_requested (GtkHTML *html, const char *url,
+                           GtkHTMLStream *stream);
+
+/** \brief handles button press event
+ *
+ */
+gboolean ws_gui_button_press (GtkWidget *widget,
+                              GdkEventButton *event,
+                              gpointer user_data);
+
+/** \brief handles button release event
+ *
+ */
+gboolean ws_gui_button_release (GtkWidget *widget,
+                                GdkEventButton *event,
+                                gpointer user_data);
+
+/** \brief shows popup when user clicks and holds
+ *
+ */
+guint ws_gui_show_popup(gpointer user_data);
+
+/** \brief checks clipboard content
+ *
+ */
+void ws_gui_check_clipboard (GtkWidget *widget, gpointer user_data);
+
+/** \brief checks dictionaries availablity
+ *
+ */
+void ws_gui_dict_availablity(GtkMenuItem *menuitem, gpointer user_data);
+
+/** \brief allows to format html content
+ *
+ */
+gchar * format_html (gchar * received_string, gpointer user_data);
+
+/** \brief sets sensitivity of Bookmarks menu items
+ *
+ */
+void ws_gui_set_bookmarks_sensitivity(gpointer user_data);
+
+/** \brief sets sensitivity of Bookmarks menu items due to selection made
+ *
+ */
+void ws_gui_set_bookmark_menu_items(GtkMenuItem *menuitem, gpointer user_data);
+
+/** \brief sets sensitivity of menu items due to dictionary mode 
+ *
+ */
+void ws_gui_read_active_dictionaries(gpointer user_data);
+
+void ws_gui_clear_array(GArray *history);
+
+void ws_gui_view_cursor_changed(GtkTreeView *treeview, gpointer user_data);
+
+void ws_gui_set_toolbar_avail(gpointer user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gui/include/ws_gui_layout.h b/src/gui/include/ws_gui_layout.h
new file mode 100644 (file)
index 0000000..41201a9
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_GUI_LAYOUT
+#define _WS_GUI_LAYOUT
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ws_gui.h>
+#include <ws_gui_callbacks.h>
+
+/**
+* \brief create main window
+*
+*/
+void ws_gui_create_window(gpointer user_data);
+
+/**
+* \brief create find toolbar
+*
+*/
+void ws_gui_create_find_toolbar(gpointer user_data);
+
+/**
+* \brief create application menu
+*
+*/
+void ws_gui_create_main_menu (gpointer user_data);
+
+/**
+* \brief create popup menu
+*
+*/
+void ws_gui_create_popup_menu (gpointer user_data);
+
+/** 
+ * \brief select dictionaries to use
+ *
+ */
+void ws_gui_dictionary_chooser(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief load new dictionary files
+ *
+ */
+void ws_gui_dictionary_loader(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief load dictionary file using given filename
+ *
+ */
+gboolean ws_gui_load_dict(gchar *filename, gpointer user_data);
+
+/** 
+ * \brief remove dictionary from application
+ *
+ */
+void ws_gui_dictionary_remover(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief optimize dictionaries
+ *
+ */
+void ws_gui_dictionary_optimizer(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief open bookmark window
+ *
+ */
+void ws_gui_dictionary_open_bookmark(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief close bookmark window
+ *
+ */
+void ws_gui_dictionary_close_bookmark(GtkMenuItem *menuitem, 
+                                     gpointer user_data);
+
+/** 
+ * \brief add bookmark to bookmarks database
+ *
+ */
+void ws_gui_dictionary_add_bookmark(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief remove bookmark from database
+ *
+ */
+void ws_gui_dictionary_remove_bookmark(GtkMenuItem *menuitem, 
+                                      gpointer user_data);
+
+/** 
+ * \brief display information about application
+ *
+ */
+void ws_gui_about_application(GtkMenuItem *menuitem, gpointer user_data);
+
+/** 
+ * \brief creates Add Bookmark dialog window
+ *
+ */
+void ws_gui_add_bookmark_dialog(gpointer user_data);
+
+/** 
+ * \brief creates Remove Bookmark dialog window
+ *
+ */
+void ws_gui_remove_bookmark_dialog(gpointer user_data);
+
+void ws_gui_list_full_dialog(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gui/makefile b/src/gui/makefile
new file mode 100644 (file)
index 0000000..9d75e82
--- /dev/null
@@ -0,0 +1,50 @@
+CC = gcc
+DEBUG = -g -Wall
+EXECUTABLE = WhiteStork
+INCLUDE_GUI = include
+INCLUDE_DBUS_WRAPPER = ../../include
+CFLAGS = `pkg-config --cflags gtk+-2.0 libgtkhtml-3.8 hildon-libs hildon-fm glib-2.0 libosso gconf-2.0` -I${INCLUDE_GUI} -I${INCLUDE_DBUS_WRAPPER}
+LIBS = `pkg-config --libs gtk+-2.0 libgtkhtml-3.8 hildon-libs hildon-fm glib-2.0 libosso gconf-2.0` 
+APP_VER = unofficialbuild
+
+SOURCES = src
+BINARIES = bin
+MAIN_BINARIES = ../../bin
+
+${EXECUTABLE}: ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${MAIN_BINARIES}/ws_dbus.o ${BINARIES}/pc-instances.o
+               @${CC} ${DEBUG}   -o ${BINARIES}/${EXECUTABLE} ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${BINARIES}/pc-instances.o ${MAIN_BINARIES}/ws_dbus.o ${LIBS} ${CFLAGS}
+               @cp ${BINARIES}/${EXECUTABLE} ${MAIN_BINARIES}
+
+${BINARIES}/ws_gui.o: ${SOURCES}/ws_gui.c ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               @${CC} ${DEBUG} -c ${SOURCES}/ws_gui.c -o ${BINARIES}/ws_gui.o ${CFLAGS}
+
+${BINARIES}/ws_gui_callbacks.o: ${SOURCES}/ws_gui_callbacks.c ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               @${CC} ${DEBUG} -c ${SOURCES}/ws_gui_callbacks.c -o ${BINARIES}/ws_gui_callbacks.o ${CFLAGS}
+
+${BINARIES}/ws_gui_layout.o: ${SOURCES}/ws_gui_layout.c ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               @${CC} ${DEBUG} -DWS_VERSION=\"${APP_VER}\" -c ${SOURCES}/ws_gui_layout.c -o ${BINARIES}/ws_gui_layout.o ${CFLAGS}
+
+${BINARIES}/pc-instances.o: ${SOURCES}/pc-instances.c ${INCLUDE_GUI}/pc-instances.h
+               @${CC} ${DEBUG} -c ${SOURCES}/pc-instances.c -o ${BINARIES}/pc-instances.o ${CFLAGS}
+
+${MAIN_BINARIES}/ws_dbus.o:
+               cd ../dbus_wrapper && make
+
+
+dyn:
+               ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o 
+               ${CC} ${DEBUG} -shared -fPIC -o ${EXECUTABLE}.so ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o dbus/ws_dbus.o ${LIBS} ${CFLAGS}
+
+${BINARIES}/wsl_gui.o: ${SOURCES}/ws_gui.c ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               ${CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui.c -o ${BINARIES}/wsl_gui.o ${CFLAGS}
+
+${BINARIES}/wsl_gui_callbacks.o: ${SOURCES}/ws_gui_callbacks.c ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               ${CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui_callbacks.c -o ${BINARIES}/wsl_gui_callbacks.o ${CFLAGS}
+
+${BINARIES}/wsl_gui_layout.o: ${SOURCES}/ws_gui_layout.c ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+               ${CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui_layout.c -o ${BINARIES}/wsl_gui_layout.o ${CFLAGS}
+
+
+clean:
+       rm -f ${BINARIES}/*
+       @echo "done"
diff --git a/src/gui/src/pc-instances.c b/src/gui/src/pc-instances.c
new file mode 100644 (file)
index 0000000..38a96c1
--- /dev/null
@@ -0,0 +1,169 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <pc-instances.h>
+
+//------------------------------------------------------------------------------
+/** \brief Get comandline by which process in /proc tree was invoked.
+ *
+ * @param process describes which process from /proc tree we want to check. It
+ * should be only concrete directory from /proc nothing else. e.g.: /proc/self,
+ * /proc/8321 etc. Something like /proc or /proc/self is not good.
+ * @return string containing comandline which has invoked process. If NULL there
+ * were some problems, possibly parameter were wrong or ther is no such
+ * a process.
+ */
+char* get_process_cmdline(char* process)
+{
+       // build final filename to read
+       const char* postfix = "/cmdline";
+       int arg_len = strlen(process);
+       char* tmp = (char*)malloc((size_t)(arg_len+9));
+       tmp[arg_len+8] = '\0';
+       sprintf(tmp,"%s%s",process,postfix);
+       //printf("Process to check: %s\n",tmp);
+
+       // open file to read
+       int file = open(tmp, O_RDONLY);
+       free(tmp); tmp = 0;
+       if(-1 == file)
+       {
+               return (char*)0;
+       }
+
+       int length = 512;       
+
+       // buffer for data from /proc/self/cmdline file
+       char* buffer = (char*)malloc(length + 1);
+
+       // read file to buffer
+       int readed = read(file, buffer, length);
+       close(file);
+       if(readed == length)
+       {
+               free(buffer);
+               return (char*)0;
+       }
+       buffer[length] = '\0';
+
+       //printf("%s() returned finaly: %s\n",__FUNCTION__,buffer);
+       return buffer;
+}
+//------------------------------------------------------------------------------
+/** \brief Cut from commandline only program file name.
+ *
+ * @param cmdline commandline which from which we want to remove options.
+ * @return string with only program file name, or NULL if there was any problem
+ */
+char* get_process_program_file(char* cmdline)
+{
+       int start = 0;
+       int stop  = 0;
+       // find first space in buffer (to remove optional options etc.)
+       while(cmdline[stop] && cmdline[stop] != ' ')
+       {
+               ++stop;
+       }
+       cmdline[stop] = '\0';
+
+       // find last "/" to remove directories 
+       start = stop;
+       while((start>0) && (cmdline[start] != '/'))
+       {
+               --start;
+       }
+       if(cmdline[start] == '/')
+       {
+               ++start;
+       }
+
+       // cut only needed fragment of buffer
+       if(start == stop)
+       {
+               return (char*)0;
+       }
+
+       char* result = (char*)malloc(stop - start + 1);
+       memcpy(result, cmdline + start, stop - start + 1);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get file name containing program executing by current process.
+ *
+ * @return file name of program or NULL if there were some problems.
+ */
+char* get_current_process_program_file()
+{
+       char* cmd = get_process_cmdline("/proc/self");
+       if(!cmd)
+       {
+               return (char*)0;
+       }
+       char* name = get_process_program_file(cmd);
+       free(cmd); cmd = 0;
+
+       return name;
+}
+//------------------------------------------------------------------------------
+/** \brief Check if there is another instance of current programm.
+ *
+ * @return integer telling how many processes were initiated with the same
+ * program as curent process. If it is 1, it means there is no other procces.
+ * If > 1 there is another instance.
+ */
+int is_already_running_this_application()
+{
+       char* app = get_current_process_program_file();
+       int   count = 0;
+
+       struct dirent* entry;
+       DIR*   dir = opendir("/proc");
+       struct stat st;
+
+       char   path[512];
+       sprintf(path,"%s","/proc/");
+       char*  tmp = path + 6;
+
+       while((entry = readdir(dir)) != NULL)
+       {
+               sprintf(tmp,"%s",entry->d_name);
+               lstat(path,&st);
+
+               if(S_ISDIR(st.st_mode))
+               {
+                       char* cmd = get_process_cmdline(path);
+                       if(!cmd) continue;
+                       char* name = get_process_program_file(cmd);
+                       free(cmd); cmd = 0;
+                       if(!name) continue;
+                       //printf("%s: next programm: %s\n",app,name);
+
+                       if(strcmp(app,name) == 0) 
+                       {
+                               ++count;
+                       }
+
+                       free(name); name = 0;
+               }
+       }
+       closedir(dir); dir = NULL;
+       free(app); app = 0;
+       return count;
+}
+//------------------------------------------------------------------------------
diff --git a/src/gui/src/ws_gui.c b/src/gui/src/ws_gui.c
new file mode 100644 (file)
index 0000000..11b1e6f
--- /dev/null
@@ -0,0 +1,185 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_gui.h>
+#include <ws_gui_callbacks.h>
+#include <ws_gui_layout.h>
+
+#include <pc-instances.h>
+
+//int ws_gui_init(int argc, char *argv[])
+int main(int argc, char *argv[])
+{      
+        gtk_init(&argc, &argv);
+
+       //localization
+       setlocale(LC_ALL, "");
+       bindtextdomain("whitestork", "/usr/share/locale");
+       bind_textdomain_codeset("whitestork", "UTF-8");
+        textdomain("whitestork");
+
+       if (strcmp(_("ws_check"), "ws_check") == 0)
+       {
+               setlocale(LC_ALL, "en_GB");
+               bindtextdomain("whitestork", "/usr/share/locale");
+               bind_textdomain_codeset("whitestork", "UTF-8");
+               textdomain("whitestork");
+       }
+
+
+        WSGuiApp *ws_gui_app;
+        ws_gui_app = (WSGuiApp*)g_malloc(sizeof(WSGuiApp)); 
+
+        //memory allocation
+        ws_gui_app->ws_gui_w_list = 
+                (struct WSGuiList*)g_malloc(sizeof(struct WSGuiList));
+        ws_gui_app->ws_gui_menu = 
+                (struct WSGuiMenu*)g_malloc(sizeof(struct WSGuiMenu));
+
+        //gonf
+        ws_gui_app->client = gconf_client_get_default();
+
+       ws_gui_create_window(ws_gui_app);
+        ws_gui_read_adjustment(ws_gui_app);
+
+
+        //dbus wrapper
+        ws_gui_app->dbus_data = ws_dbus_create ("WhiteStorkGui", "v1.0");
+
+        ws_dbus_config (ws_gui_app->dbus_data, 
+                        WS_DBUS_CONFIG_SERVICE,
+                        "org.maemo.WhiteStorkGui");
+        ws_dbus_config (ws_gui_app->dbus_data,
+                        WS_DBUS_CONFIG_OBJECT,
+                        "/org/maemo/WhiteStorkGui");
+        ws_dbus_config (ws_gui_app->dbus_data,
+                        WS_DBUS_CONFIG_IFACE,
+                        "org.maemo.WhiteStorkGui");
+        ws_dbus_config (ws_gui_app->dbus_data,
+                        WS_DBUS_CONFIG_REMOTE_SERVICE,
+                        "org.maemo.WhiteStorkManager");
+        ws_dbus_config (ws_gui_app->dbus_data,
+                        WS_DBUS_CONFIG_REMOTE_OBJECT,
+                        "/org/maemo/WhiteStorkManager");
+        ws_dbus_config (ws_gui_app->dbus_data,
+                        WS_DBUS_CONFIG_REMOTE_IFACE,
+                        "org.maemo.WhiteStorkManager");
+
+
+       ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "return_words",
+                       WS_DBUS_TYPE_GARRAY,
+                       WS_DBUS_TYPE_INVALID);
+                        
+       ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "return_translations",
+                       WS_DBUS_TYPE_STRING,
+                       WS_DBUS_TYPE_INVALID);
+
+       ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "return_extracted_dict",
+                       WS_DBUS_TYPE_STRING,
+                       WS_DBUS_TYPE_INVALID);
+
+       ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "update_progressbar",
+                       WS_DBUS_TYPE_DOUBLE,
+                       WS_DBUS_TYPE_INVALID);
+
+       ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "signal",
+                       WS_DBUS_TYPE_SIGNAL,
+                       WS_DBUS_TYPE_INVALID);
+
+        ws_dbus_add_method (ws_gui_app->dbus_data,
+                        "search_home_applet",
+                       WS_DBUS_TYPE_STRING,
+                       WS_DBUS_TYPE_INVALID);
+
+        ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "return_words",
+                        ws_gui_dbus_return_words,
+                        ws_gui_app);
+
+        ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "return_translations",
+                        ws_gui_dbus_return_translation,
+                        ws_gui_app);
+        ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "return_extracted_dict",
+                        ws_dbus_server_return_extracted_bzip,
+                        ws_gui_app);
+        ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "update_progressbar",
+                        ws_dbus_progress_bar,
+                        ws_gui_app);
+        ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "signal",
+                        ws_gui_signal_hander,
+                        ws_gui_app);
+       //hisa
+       ws_dbus_set_cb (ws_gui_app->dbus_data,
+                        "search_home_applet",
+                        ws_gui_search_home_handler,
+                        ws_gui_app);
+
+        ws_dbus_connect (ws_gui_app->dbus_data);
+
+        //setting the clipboard
+        ws_gui_app->ws_gui_clipboard = 
+                gtk_widget_get_clipboard (GTK_WIDGET(ws_gui_app->ws_gui_html),
+                                          GDK_SELECTION_CLIPBOARD);
+
+        //connecting the signals
+       g_signal_connect(G_OBJECT (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                         "cursor-changed",
+                         G_CALLBACK (ws_gui_view_cursor_changed), 
+                        ws_gui_app);
+
+
+        g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
+                        "key-press-event",
+                         G_CALLBACK(hildon_key_press_listener),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
+                         "button-press-event",
+                         G_CALLBACK(ws_gui_button_press),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
+                         "button-release-event",
+                         G_CALLBACK(ws_gui_button_release),
+                         ws_gui_app);
+       
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_list_eventbox),
+                         "button-press-event",
+                         G_CALLBACK(ws_gui_list_full_dialog),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
+                         "delete-event",
+                         G_CALLBACK(ws_gui_on_exit),
+                         ws_gui_app);
+
+        ws_dbus_notify(ws_gui_app->dbus_data,
+                       WS_DBUS_ERROR_UNKNOWN);
+
+        gtk_main();
+       
+        return 0;
+}
+
diff --git a/src/gui/src/ws_gui_callbacks.c b/src/gui/src/ws_gui_callbacks.c
new file mode 100644 (file)
index 0000000..162b6c4
--- /dev/null
@@ -0,0 +1,2354 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_gui_callbacks.h>
+#include <ws_gui.h>
+#include <ws_gui_layout.h>
+#include <ws_dbus.h>
+
+/** \brief show how much time did take a callback of another function
+ *
+ */
+static double timer(gboolean start, gchar* message)
+{
+        static GArray* stack = NULL;
+        static gboolean first_run = TRUE;
+        static struct timeval actual_time;
+        static struct timeval last_time;
+        static struct timeval result;
+        static double seconds = 0.0;
+        if(first_run)
+        {
+                first_run = FALSE;
+                stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+        };
+        // things to do on the beggining of function's work
+        if (start)
+        {
+                g_debug("XDXF->%s() start counting time for function '%s()'.\n",
+                        __FUNCTION__,message);
+                g_array_prepend_val(stack, actual_time);
+                gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+                return -1.0;
+        }
+        // we just want to end some timer - print some information 
+        //about working time;
+        else {
+                gettimeofday(&actual_time,NULL);
+                last_time = g_array_index(stack, struct timeval, 0);
+                g_array_remove_index(stack, 0);
+
+                if (actual_time.tv_usec < last_time.tv_usec) {
+                        int nsec = (last_time.tv_usec - 
+                                             actual_time.tv_usec) / 1000000 + 1;
+                        last_time.tv_usec -= 1000000 * nsec;
+                        last_time.tv_sec += nsec;
+                }
+                if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                        int nsec = (last_time.tv_usec -
+                                                 actual_time.tv_usec) / 1000000;
+                        last_time.tv_usec += 1000000 * nsec;
+                        last_time.tv_sec -= nsec;
+                }
+                result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+                result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+                seconds = (((double)(result.tv_usec)) / 1e6) + 
+                                                      ((double)(result.tv_sec));
+
+                g_debug("XDXF->%s() function \'%s()\' was working for: %g [s] "
+                       "or %ld [us].\n",
+                        __FUNCTION__,
+                        message,seconds,
+                        ((long)(result.tv_sec*1e6)+(result.tv_usec)));
+               // stack is empty so we delete everything
+               if(stack->len == 0) 
+               {
+                        g_array_free(stack, TRUE);
+                        first_run = TRUE;
+               }
+               return seconds;
+        }
+        return -2.0;
+}
+
+
+/**  this function handles signals from dbus; it is called 
+when there are any messages from other modules
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        osso_rpc_t osss_data;
+        osss_data = g_array_index (words, osso_rpc_t, 0);
+
+        switch(osss_data.value.i)
+        {
+                case WS_DBUS_ERROR_ENGINE_NOT_FOUND:
+                {
+                        ws_gui_app->ws_message_dialog = 
+                        gtk_message_dialog_new(
+                                   GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                   _("ws_ni_error_occured"));
+                        gtk_widget_show_all(ws_gui_app->ws_message_dialog);
+
+                        g_signal_connect_swapped(
+                                     GTK_OBJECT (ws_gui_app->ws_message_dialog),
+                                     "response",
+                                     G_CALLBACK (gtk_main_quit),
+                                     ws_gui_app);
+                        break;
+                }
+
+                case WS_DBUS_ERROR_FILE_NOT_FOUND:
+                {
+                        ws_gui_app->ws_message_dialog = 
+                                gtk_message_dialog_new(
+                                   GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                   _("ws_ni_no_dictionary_available"));
+
+                        gtk_widget_show_all(ws_gui_app->ws_message_dialog);
+
+                        GArray *tmp;
+                        tmp = g_array_new(TRUE, TRUE, sizeof(gchar*));
+                        gtk_list_store_clear(
+                                       ws_gui_app->ws_gui_w_list->ws_gui_store);
+                        ws_gui_app->ws_gui_w_list->ws_gui_model = 
+                                create_and_fill_model(tmp, ws_gui_app);
+                        ws_gui_fill_html(" ", ws_gui_app);
+                       ws_gui_app->html_flag = FALSE;
+
+                        gtk_widget_set_sensitive(
+                             GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                             FALSE);
+                        gtk_widget_set_sensitive(
+                        GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                        FALSE);
+
+                        if (gtk_dialog_run(
+                                GTK_DIALOG(ws_gui_app->ws_message_dialog)) 
+                                                            == GTK_RESPONSE_OK)
+                        {
+                                gtk_widget_destroy(
+                                                 ws_gui_app->ws_message_dialog);
+                        }
+                        break;
+                }
+
+                case WS_DBUS_INFO_CACHING:
+                {
+                        ws_gui_app->ws_gui_banner_caching =
+                                hildon_banner_show_progress(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_pb_caching"));
+                       ws_gui_app->caching_flag = TRUE;
+                       hildon_banner_set_fraction(
+                               HILDON_BANNER(ws_gui_app->ws_gui_banner_caching),
+                               0.0);
+                       gtk_widget_set_sensitive(
+                             GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                             FALSE);
+                       gtk_widget_set_sensitive(
+                        GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                        FALSE);
+                        gtk_widget_set_sensitive(
+                        GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                        FALSE);
+                      gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view),
+                       FALSE);
+
+                       break;
+                }
+
+                case WS_DBUS_INFO_CACHING_FINISHED:
+                {
+                      gtk_widget_destroy(
+                      GTK_WIDGET(ws_gui_app->ws_gui_banner_caching));
+                      ws_gui_app->caching_flag = FALSE;
+                      gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                      TRUE);
+                      gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                      TRUE);
+                     gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                      TRUE);
+                     gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view),
+                      TRUE);
+
+                      break;
+                }
+
+                case WS_DBUS_ERROR_DICTIONARY_NOT_LOAD:
+                {
+                        if (ws_gui_app->ws_gui_history_cur_pos >= 0 &&
+                               ws_gui_app->ws_gui_history_cur_pos <=HISTORY_LEN)
+                        { 
+                                g_array_remove_index(ws_gui_app->ws_gui_history,
+                                            ws_gui_app->ws_gui_history_cur_pos);
+                        }
+
+                        ws_gui_app->ws_message_dialog = gtk_message_dialog_new(
+                                   GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                  _("ws_ni_dictionary_unavailable"));
+                       gtk_widget_show_all(ws_gui_app->ws_message_dialog);
+                       if (gtk_dialog_run(
+                       GTK_DIALOG(ws_gui_app->ws_message_dialog)) 
+                                                            == GTK_RESPONSE_OK)
+                       {
+                              gtk_widget_destroy(ws_gui_app->ws_message_dialog);
+                       }
+                       break;
+                }
+               
+               case  WS_DBUS_BOOKMARKS_ADDED_OK:
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                        _("ws_ni_bookmark_added"));
+               break;
+               }
+
+               case WS_DBUS_BOOKMARKS_REMOVED_OK:
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                        _("ws_ni_bookmark_removed"));
+               break;
+               }
+       
+               case WS_DBUS_BOOKMARKS_ADDED_FAIL:
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                        _("ws_ni_bookmark_not_added"));
+               break;
+               }
+
+               case WS_DBUS_BOOKMARKS_REMOVED_FAIL:
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                        _("ws_ni_bookmark_not_removed"));
+               break;
+               }
+
+               case WS_DBUS_LOAD_BOOKMARK_FAILED:
+               {
+                    gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                     FALSE);
+                    ws_gui_app->bookmark_avail = FALSE;
+                               
+                       ws_gui_app->ws_message_dialog = 
+                        gtk_message_dialog_new(
+                                  GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                   _("ws_ni_bookmarks_unavailable"));
+
+                       if (gtk_dialog_run(
+                                GTK_DIALOG(ws_gui_app->ws_message_dialog)) 
+                                                            == GTK_RESPONSE_OK)
+                        {
+                                gtk_widget_destroy(
+                                                 ws_gui_app->ws_message_dialog);
+                        }
+
+                       
+                        break; 
+               }
+               case WS_DBUS_EXTRACT_FILE:
+                {
+                        ws_gui_app->ws_gui_banner_extracting =
+                               hildon_banner_show_animation(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_pb_extracting"));
+
+                       ws_gui_app->caching_flag = TRUE;
+                       
+                       gtk_widget_set_sensitive(
+                          GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                          FALSE);
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                        FALSE);
+
+                       break;
+                }
+
+                case WS_DBUS_EXTRACT_FILE_FINISHED:
+                {
+                       gtk_widget_destroy(
+                       GTK_WIDGET(ws_gui_app->ws_gui_banner_extracting));
+                       
+                       ws_gui_app->caching_flag = FALSE;
+                       
+                       gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ni_dictionary_added"));
+                       
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                       TRUE);
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       TRUE);
+
+                        break;
+                }
+
+               case  WS_DBUS_WORDS_LIST_FULL:
+               {
+
+                       gtk_widget_show(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+               break;
+               }
+
+               case  WS_DBUS_WORDS_LIST_FINISHED:
+               {
+                       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+               break;
+               }
+
+               case  WS_DBUS_TRANSLATION_FINISHED:
+               {
+                       gtk_widget_hide(ws_gui_app->ws_gui_banner_translation_loading);
+               break;
+               }
+
+               case  WS_DBUS_WORDS_LIST_STARTED:
+               {
+                       gtk_widget_show(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+               break;
+               }
+
+               case  WS_DBUS_TRANSLATION_STARTED:
+               {
+                       gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               break;
+               }
+
+        }
+}
+
+
+/* added by Dariusz Wiechecki - HISA */
+void ws_gui_search_home_handler(GError *error, GArray *word, gpointer user_data)
+{
+        g_debug("->%s", __FUNCTION__);
+        WSGuiApp *data = (WSGuiApp*) user_data;
+        osso_rpc_t* osso_data = NULL;
+
+        
+        //get the word passed by dbus 
+        osso_data = &g_array_index (word, osso_rpc_t, 0); 
+
+        //free memory used by last searched word
+        gchar* tmp = NULL;
+        tmp = g_strdup(osso_data->value.s + 11);
+       
+       g_object_set(G_OBJECT(data->ws_gui_hildon_find_toolbar),
+                    "prefix",
+                    tmp,
+                    NULL);
+       ws_gui_search(NULL, data);
+}
+
+/**  this function handles signals from dbus; it is called when progress bar
+ status has been changed
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_dbus_progress_bar(GError *error, GArray *words, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        osso_rpc_t osss_data;
+        osss_data = g_array_index (words, osso_rpc_t, 0);
+        double progress = osss_data.value.d;
+        if (ws_gui_app->caching_flag == TRUE)
+        {
+                hildon_banner_set_fraction(
+                               HILDON_BANNER(ws_gui_app->ws_gui_banner_caching),
+                               progress);
+        }
+}
+
+/** this function clean GtkListStore row by row
+ *
+ * @param list - GtkListStore to be remoeved
+ * @return
+ */
+void ws_gui_clear_list (GtkListStore* list) 
+{
+       GtkTreeIter iter;
+       gboolean tmp;
+       
+       tmp = gtk_tree_model_get_iter_first(
+                        GTK_TREE_MODEL(list),
+                        &iter);
+       
+       while (tmp == TRUE)
+       {
+               tmp = gtk_list_store_remove(list, &iter);
+               
+       }
+}
+
+
+/** this function handles signal from dbus and transfer recived 
+(found in a dictionary) words to the words list
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_gui_dbus_return_words (GError *error, GArray *words, gpointer user_data)
+{
+        timer(TIMER_START, (gchar*)__FUNCTION__);
+        guint i;
+        osso_rpc_t data;
+
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       g_signal_handlers_block_by_func(G_OBJECT 
+                       (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                       ws_gui_app);    
+
+
+        GArray *tmp;
+        tmp = g_array_new(TRUE, TRUE, sizeof(gchar*));
+        gchar *tmp_word;
+
+        for (i=0;i<words->len;++i)
+        {
+                data = g_array_index (words, osso_rpc_t, i);
+                tmp_word = g_strdup(data.value.s);
+                g_array_append_val(tmp, tmp_word);
+        }
+       
+       g_assert(ws_gui_app->ws_gui_banner_list_searching);
+        //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+
+       ws_gui_app->loading = FALSE;
+       ws_gui_set_toolbar_avail(ws_gui_app);
+
+       //ws_gui_app->ws_gui_banner_flag = FALSE;
+
+       //ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store);
+
+
+        ws_gui_app->ws_gui_w_list->ws_gui_model = 
+                                        create_and_fill_model(tmp, ws_gui_app);
+       
+       if (ws_gui_app->history_flag == TRUE)
+       {
+
+       GValue value = { 0, };
+       GtkTreeIter tmp_iter;
+       gchar *pattern;
+       gboolean keep_searching = TRUE;
+
+       if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(
+           ws_gui_app->ws_gui_w_list->ws_gui_model), &tmp_iter) == TRUE)
+       {
+
+               pattern = strdup(g_array_index(ws_gui_app->ws_gui_history,
+                                       gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos));
+               
+               gtk_tree_model_get_value(GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                               &tmp_iter, 
+                               COL_WORD, 
+                               &value);
+
+               if ((g_value_get_string (&value) != NULL) &&
+                               (strcmp(((gchar *)g_value_get_string (&value)), 
+                                pattern) == 0))
+               {
+                       gtk_tree_selection_select_iter(
+                               ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                               &tmp_iter);
+
+               }
+               else
+               {
+               while (gtk_tree_model_iter_next(GTK_TREE_MODEL
+                     (ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                     &tmp_iter) == TRUE && keep_searching == TRUE)
+               {
+                       gtk_tree_model_get_value(GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                               &tmp_iter, 
+                               COL_WORD, 
+                               &value);
+
+                       if ((g_value_get_string (&value) != NULL) &&
+                               (strcmp(((gchar *)g_value_get_string (&value)), 
+                               pattern) == 0))
+                               {
+                               gtk_tree_model_get_iter_from_string (
+                               GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model),
+                                &tmp_iter,
+                                g_array_index(
+                               ws_gui_app->ws_gui_history_iter,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos));
+
+                               gtk_tree_selection_select_iter(
+                               ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                               &tmp_iter);
+                                                               
+                               keep_searching = FALSE;
+                               }
+                       }
+               }
+       }
+       g_free(pattern);
+
+       ws_gui_app->history_flag = FALSE;
+       ws_dbus_client_find_translation(ws_gui_app->dbus_data, 
+                               g_array_index(ws_gui_app->ws_gui_history,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos));
+       
+       ws_gui_app->html_flag = TRUE;
+       g_value_unset (&value);
+       }
+       
+       
+       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Dlugosc tempa to: %d", tmp->len);
+       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "w tempie mamy: %s", tmp_word);
+        //if (&& ws_gui_app->stop_clicked != TRUE )
+       
+       if ((tmp->len == 0 || tmp_word == NULL) && ws_gui_app->stop_clicked != TRUE )
+        {
+                gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                              _("ws_ni_no_words_found"));
+               
+               //ws_gui_fill_html(" ", ws_gui_app);
+               //ws_gui_app->html_flag = FALSE;
+               g_free(ws_gui_app->last_word);
+               ws_gui_app->last_word = NULL;
+        }
+
+       g_signal_handlers_unblock_by_func(G_OBJECT(
+                                       ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);    
+       
+       for (i=0;i<tmp->len;++i)
+        {
+                g_free(g_array_index(tmp, gchar* , i));
+        }
+       g_array_free(tmp, TRUE);
+
+        timer(TIMER_STOP, (gchar*)__FUNCTION__);
+}
+
+/** this function handles signal from dbus and send recived data to 
+the translation area
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_gui_dbus_return_translation (GError *error,
+                                     GArray *words,
+                                     gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       gchar *html_content = NULL;
+        osso_rpc_t data;
+
+        data = g_array_index (words, osso_rpc_t, 0);
+
+       html_content = format_html(data.value.s, ws_gui_app);
+       ws_gui_fill_html(html_content, ws_gui_app);
+       g_free(html_content);
+       ws_gui_app->html_flag = TRUE;
+       
+       //gtk_widget_hide(ws_gui_app->ws_gui_banner_translation_loading);
+       ws_gui_app->loading = FALSE;
+       ws_gui_set_toolbar_avail(ws_gui_app);
+
+}
+
+/** this function handles signal from dbus and send recived data to 
+the translation area
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_dbus_server_return_extracted_bzip(GError *error,
+                                     GArray *words,
+                                     gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        osso_rpc_t data;
+
+        data = g_array_index (words, osso_rpc_t, 0);
+
+       if (data.value.s[0] == '\0')
+       {
+               gtk_infoprint(GTK_WINDOW(
+                                ws_gui_app->ws_gui_hildon_window),
+                                _("ws_ni_dictionary_not_added"));
+       }
+       else
+       {
+       if (ws_gui_load_dict(data.value.s, ws_gui_app) == TRUE)
+       {
+               
+       }
+       }
+}
+
+/**
+* this function allows to free allocated memory
+*
+* @param user_data - pointer to data structure
+*/
+void ws_gui_free_memory(gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       guint i = 0;
+       for (i = 0; i<ws_gui_app->ws_gui_history->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history, gchar *, i));
+       }
+        g_array_free(ws_gui_app->ws_gui_history, TRUE);
+
+       for (i = 0; i<ws_gui_app->ws_gui_history_list->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history_list, gchar *, i));
+       }
+       g_array_free(ws_gui_app->ws_gui_history_list, TRUE);
+
+       for (i = 0; i<ws_gui_app->ws_gui_history_iter->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history_iter, gchar *, i));
+       }
+       g_array_free(ws_gui_app->ws_gui_history_iter, TRUE);
+
+
+        pango_font_description_free(ws_gui_app->p);
+
+       g_string_free(ws_gui_app->raw_translation, TRUE);
+        g_free(ws_gui_app->last_word);
+       g_free(ws_gui_app->ws_gui_w_list);
+        g_free(ws_gui_app->ws_gui_menu);
+        g_free(ws_gui_app);
+}
+
+/** this function handle press signals (keyboard)
+ * 
+ * @param widget
+ * @param keyevent
+ * @param user_data - ponter to data structure
+ * @return TRUE to stop other handlers from being invoked for the event. 
+ FALSE to propagate the event further.
+ */
+gboolean hildon_key_press_listener (GtkWidget * widget,
+                                    GdkEventKey * keyevent,
+                                    gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        switch ((guint)(keyevent->keyval)) {
+                case HILDON_HARDKEY_UP: 
+                {
+                        gtk_container_set_focus_vadjustment(
+                          GTK_CONTAINER(ws_gui_app->ws_gui_scrolledwindow_left),
+                          gtk_scrolled_window_get_vadjustment(
+                          GTK_SCROLLED_WINDOW(
+                                      ws_gui_app->ws_gui_scrolledwindow_left)));
+                      ws_gui_app->v_new_value =
+                         gtk_adjustment_get_value(
+                           GTK_ADJUSTMENT(
+                                ws_gui_app->ws_gui_vadj)) - ws_gui_app->v_delta;
+                      if (ws_gui_app->v_new_value > 
+                         ws_gui_app->ws_gui_vadj->lower) 
+                      {
+                              gtk_adjustment_set_value(
+                                        GTK_ADJUSTMENT(ws_gui_app->ws_gui_vadj),
+                                        ws_gui_app->v_new_value);
+                      }
+                       
+                       break;
+                }
+
+                case HILDON_HARDKEY_DOWN: 
+                {
+                      gtk_container_set_focus_vadjustment(
+                          GTK_CONTAINER(ws_gui_app->ws_gui_scrolledwindow_left),
+                          gtk_scrolled_window_get_vadjustment(
+                          GTK_SCROLLED_WINDOW(
+                                      ws_gui_app->ws_gui_scrolledwindow_left)));
+                      ws_gui_app->v_new_value = gtk_adjustment_get_value(
+                                        GTK_ADJUSTMENT(ws_gui_app->ws_gui_vadj))
+                                        + ws_gui_app->v_delta;
+
+                      if (ws_gui_app->v_new_value < 
+                                     (ws_gui_app->ws_gui_vadj->upper - 
+                                            ws_gui_app->ws_gui_vadj->page_size)) 
+                      {
+                                gtk_adjustment_set_value(
+                                        GTK_ADJUSTMENT(ws_gui_app->ws_gui_vadj),
+                                        ws_gui_app->v_new_value);
+                      }
+                      break;
+                }
+
+                case HILDON_HARDKEY_LEFT:
+                {
+                      gtk_container_set_focus_hadjustment(
+                      GTK_CONTAINER(ws_gui_app->ws_gui_scrolledwindow_left),
+                      gtk_scrolled_window_get_hadjustment(
+                      GTK_SCROLLED_WINDOW(
+                                     ws_gui_app->ws_gui_scrolledwindow_left)));
+
+                      ws_gui_app->h_new_value = gtk_adjustment_get_value(
+                      GTK_ADJUSTMENT(ws_gui_app->ws_gui_hadj)) 
+                     - ws_gui_app->h_delta;
+
+                      if (ws_gui_app->h_new_value > 
+                         ws_gui_app->ws_gui_hadj->lower) 
+                      {
+                                gtk_adjustment_set_value(
+                                        GTK_ADJUSTMENT(ws_gui_app->ws_gui_hadj),
+                                        ws_gui_app->h_new_value);
+                      }
+                }
+                break;
+
+                case HILDON_HARDKEY_RIGHT: 
+                {
+                      gtk_container_set_focus_hadjustment(
+                       GTK_CONTAINER(ws_gui_app->ws_gui_scrolledwindow_left),
+                       gtk_scrolled_window_get_hadjustment(
+                       GTK_SCROLLED_WINDOW(
+                      ws_gui_app->ws_gui_scrolledwindow_left)));
+
+                      ws_gui_app->h_new_value = gtk_adjustment_get_value(
+                      GTK_ADJUSTMENT(ws_gui_app->ws_gui_hadj)) 
+                     + ws_gui_app->h_delta;
+
+                      if (ws_gui_app->h_new_value < 
+                                (ws_gui_app->ws_gui_hadj->upper - 
+                                        ws_gui_app->ws_gui_hadj->page_size)) 
+                      {
+                      gtk_adjustment_set_value(
+                                        GTK_ADJUSTMENT(ws_gui_app->ws_gui_hadj),
+                                        ws_gui_app->h_new_value);
+                      }
+                 }
+                 break;
+
+                 case HILDON_HARDKEY_SELECT: 
+                        ws_gui_search(NULL, ws_gui_app);
+                 break;
+
+                 case HILDON_HARDKEY_FULLSCREEN: 
+                      ws_gui_full_screen(NULL, ws_gui_app);
+                 break;
+
+                 case HILDON_HARDKEY_INCREASE: 
+                      ws_gui_html_zoom_in(NULL, ws_gui_app);
+                 break;
+
+                 case HILDON_HARDKEY_DECREASE:
+                      ws_gui_html_zoom_out(NULL, ws_gui_app);
+                 break;
+
+                 case HILDON_HARDKEY_ESC: 
+                      ws_gui_search_stop(NULL, ws_gui_app);
+                 break;
+
+                 default:
+                      return FALSE;
+                 break;
+        }
+        return TRUE;
+}
+
+/** this function allow to hide words list using menu item from application menu
+ *
+ * @param checkmenuitem - the object which received the signal
+ * @param user_data - user data set when the signal handler was connected
+ * @return
+ */
+void ws_gui_words_list_hide_from_menu(GtkCheckMenuItem *checkmenuitem,
+                                      gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+        if (gtk_check_menu_item_get_active(
+           GTK_CHECK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list)))
+        {
+                gtk_widget_hide(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_toggle_tool_button_set_active(
+                  GTK_TOGGLE_TOOL_BUTTON(ws_gui_app->ws_gui_toobar_button_hide),
+                  TRUE);
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                                ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list),
+                                TRUE);
+        }
+        else 
+        {
+                gtk_widget_show(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
+                                         ws_gui_app->ws_gui_toobar_button_hide),
+                                         FALSE);
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                                ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list),
+                                FALSE);
+        }
+}
+
+/** this function allow to hide words list using toggle button placed in 
+the find toolbar
+ *
+ * @param toolbar - the object which received the signal
+ * @param user_data - user data set when the signal handler was connected
+ * @return
+ */
+void ws_gui_words_list_hide(GtkToggleButton *togglebutton, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+
+        if (gtk_toggle_tool_button_get_active(
+                 GTK_TOGGLE_TOOL_BUTTON(ws_gui_app->ws_gui_toobar_button_hide)))
+        {
+                gtk_widget_hide(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
+                                         ws_gui_app->ws_gui_toobar_button_hide),
+                                         TRUE);
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                                ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list),
+                                TRUE);
+        }
+        else 
+        {
+                gtk_widget_show(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
+                                         ws_gui_app->ws_gui_toobar_button_hide),
+                                         FALSE);
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                                ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list),
+                                FALSE);
+        }
+}
+
+/** add word to the history
+ *
+ * @param new_word - word which is going to be append to the history array
+ * @param user_data - user data set when the signal handler was connected
+ * @return
+ */
+void ws_gui_history_add(char *new_word, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+
+       if (ws_gui_app->history_flag != TRUE)
+       {
+
+               guint i;
+               gchar *tmp_word;
+               gchar *tmp_last_searched;
+               gchar *tmp_iter = NULL;
+               gchar *previous_word = " ";
+       
+               if (ws_gui_app->ws_gui_history_cur_pos > -1 &&
+                   g_array_index(ws_gui_app->ws_gui_history, 
+                                 gchar*, 
+                                 ws_gui_app->ws_gui_history_cur_pos) != NULL)
+               {
+                       previous_word = NULL;
+                       previous_word = g_array_index(
+                                       ws_gui_app->ws_gui_history, 
+                                       gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos);
+               }
+       
+               i = ws_gui_app->ws_gui_history_cur_pos + 1;
+               gchar *tmp = g_array_index(ws_gui_app->ws_gui_history, 
+                                          gchar*, 
+                                          i);
+               //tmp_iter = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_model), &ws_gui_app->ws_gui_w_list->ws_gui_iter);
+       
+               if (previous_word != NULL && 
+                   strcmp(previous_word, new_word) != 0)
+               {
+                       while (tmp != NULL) 
+                       {
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history_list, 
+                               i);
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history_iter, 
+                               i);
+
+                               
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history, 
+                               i);
+                               
+                               tmp = g_array_index(
+                                     ws_gui_app->ws_gui_history, 
+                                     gchar*, 
+                                     i);
+                       }
+       
+               i = 0;
+               ws_gui_app->ws_gui_history_cur_pos ++;
+       
+               if (ws_gui_app->bookmark_mode == FALSE)
+               {
+                       tmp_last_searched = g_strdup(ws_gui_app->last_searched);
+               }
+               else
+               {
+               tmp_last_searched = g_strdup(ws_gui_app->last_searched_in_book);
+               }
+
+               g_array_append_val(ws_gui_app->ws_gui_history_list, 
+                                  tmp_last_searched);
+                               
+               tmp_word = g_strdup(new_word);
+               
+               g_array_append_val(ws_gui_app->ws_gui_history, tmp_word);
+               g_array_append_val(ws_gui_app->ws_gui_history_iter, tmp_iter);
+               
+       
+               if(ws_gui_app->ws_gui_history->len > HISTORY_LEN)
+               {
+                       g_array_remove_index(ws_gui_app->ws_gui_history, 0);
+                       g_array_remove_index(ws_gui_app->ws_gui_history_list, 
+                                       0);
+                       g_array_remove_index(ws_gui_app->ws_gui_history_iter, 
+                                       0);
+                       
+                       ws_gui_app->ws_gui_history_cur_pos--;
+               }
+       
+               i = 0;
+               
+               tmp = g_array_index(ws_gui_app->ws_gui_history, gchar*, i);
+               }
+               
+       }
+
+        ws_gui_check_history(ws_gui_app);
+}
+
+/** display previously choosen word (previous from the history array)
+     if avaible, sets current position in the history array
+ *
+ * @param button - button which recived a signal
+ * @param user_data - user data set when the signal handler was connected
+ * @return 
+ */
+void ws_gui_history_back(GtkButton *button, gpointer user_data) 
+{
+       WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       
+       ws_gui_app->history_flag = TRUE;
+
+        if (ws_gui_app->ws_gui_history_cur_pos > -1) 
+       {
+               ws_gui_app->ws_gui_history_cur_pos = 
+                                       ws_gui_app->ws_gui_history_cur_pos - 1;
+
+               
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                            "prefix",
+                            (g_array_index(ws_gui_app->ws_gui_history_list,
+                             gchar*, 
+                             ws_gui_app->ws_gui_history_cur_pos)),
+                            NULL);
+       
+               ws_dbus_client_find_word (ws_gui_app->dbus_data, 
+                                       g_strstrip(g_array_index(ws_gui_app->ws_gui_history_list,
+                                               gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos))
+                                       );
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+        }
+        else 
+        {
+               ws_gui_app->loading = FALSE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+        }
+
+        ws_gui_check_history(ws_gui_app);
+}
+
+/** display choosen word, next in the history array (if avaible), 
+sets current position in the history array
+ *
+ * @param button - button which recived a signal
+ * @param user_data - user data set when the signal handler was connected
+ * @return 
+ */
+void ws_gui_history_next(GtkButton *button, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       
+       ws_gui_app->history_flag = TRUE;
+
+        gchar *tmp = g_array_index(ws_gui_app->ws_gui_history,
+                                   gchar*,
+                                   ws_gui_app->ws_gui_history_cur_pos+1);
+
+        if ((ws_gui_app->ws_gui_history_cur_pos < HISTORY_LEN-1) 
+            && (tmp != NULL)) 
+        {
+                ws_gui_app->ws_gui_history_cur_pos =
+                         ws_gui_app->ws_gui_history_cur_pos + 1;
+
+
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                              "prefix",
+                              (g_array_index(ws_gui_app->ws_gui_history_list,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos)),
+                              NULL);
+       
+               
+               ws_dbus_client_find_word(ws_gui_app->dbus_data, 
+                                       g_strstrip(g_array_index(ws_gui_app->ws_gui_history_list,
+                                       gchar*, 
+                                               ws_gui_app->ws_gui_history_cur_pos))
+                                       );
+               
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+        }
+        else 
+        {
+                gtk_widget_set_sensitive(
+                           GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward),
+                           FALSE);
+                gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
+                     FALSE);
+        }
+
+        ws_gui_check_history(ws_gui_app);
+}
+
+/** check current position in the history array and sets sensitivity of buttons 
+/ menu items, depends on availablity of words in the history
+ *
+ * @param user_data - user data set when the signal handler was connected
+ * @return 
+ */
+void ws_gui_check_history(gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+
+        gchar *tmp = g_array_index(ws_gui_app->ws_gui_history,
+                                   gchar*,
+                                   ws_gui_app->ws_gui_history_cur_pos+1);
+
+        if ((ws_gui_app->ws_gui_history_cur_pos+1 < HISTORY_LEN) 
+            && (tmp != NULL))
+        {
+                gtk_widget_set_sensitive(
+                           GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward),
+                           TRUE);
+                gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
+                     TRUE);
+        }
+        else 
+        {
+                gtk_widget_set_sensitive(
+                           GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward),
+                           FALSE);
+                gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
+                     FALSE);
+        }
+
+        tmp = g_array_index(ws_gui_app->ws_gui_history,
+                            gchar*,
+                            ws_gui_app->ws_gui_history_cur_pos-1);
+        if ((ws_gui_app->ws_gui_history_cur_pos > 0) && (tmp != NULL))
+        {
+                gtk_widget_set_sensitive(
+                              GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_back),
+                              TRUE);
+                gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev),
+                     TRUE);
+       }
+       else
+       {
+                gtk_widget_set_sensitive (
+                        GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_back),
+                        FALSE);
+                gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev),
+                     FALSE);
+       }
+}
+
+/** create TreeView Model, which allows to display words list
+ *
+ * @param words_list - array with words(found in a dictionary), recived from 
+ * DBUS;
+ * @param user_data - user data set when the signal handler was connected
+ * @return 
+ */
+GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       g_signal_handlers_block_by_func(G_OBJECT (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);    
+
+        guint i = 0;
+        gchar *tmp = g_strdup(g_array_index(words_list, gchar*, i));
+
+       if (tmp != NULL)
+       {
+               ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       }
+
+       gboolean valid;
+        valid = gtk_tree_model_get_iter_first(
+                        GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_store),
+                        &ws_gui_app->ws_gui_w_list->ws_gui_iter);
+
+        /* Append a row and fill in some data */
+        while (tmp != NULL)
+        {
+                gtk_list_store_append (ws_gui_app->ws_gui_w_list->ws_gui_store,
+                                       &ws_gui_app->ws_gui_w_list->ws_gui_iter);
+
+                gtk_list_store_set (ws_gui_app->ws_gui_w_list->ws_gui_store,
+                              &ws_gui_app->ws_gui_w_list->ws_gui_iter, 
+                             COL_WORD, tmp,
+                              -1);
+                i=i+1;
+               g_free(tmp);
+               tmp = NULL;
+                tmp = g_strdup(g_array_index(words_list, gchar*, i));
+        };
+
+       g_free(tmp);
+       tmp = NULL;
+       tmp = g_strdup(g_array_index(words_list, gchar*, 0));
+
+               
+       if (ws_gui_app->history_flag == FALSE && tmp != NULL)
+       {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_dbus_client_find_translation(ws_gui_app->dbus_data, tmp);
+               ws_gui_history_add(tmp, ws_gui_app);
+
+               g_free(ws_gui_app->last_word);
+               ws_gui_app->last_word = NULL;
+               ws_gui_app->last_word = g_strdup (tmp);
+               ws_gui_app->history_flag = FALSE;
+       }
+
+       g_signal_handlers_unblock_by_func(G_OBJECT(
+                                       ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);
+
+       g_free(tmp);
+        return GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       
+}
+
+/** create TreeView and TreeModel using create_and_fill_model() function;
+ it is necessary to display found words in a words list;
+ *
+ * @param words_list - array with words(found in a dictionary), 
+ * recived from DBUS;
+ * @param user_data - user data set when the signal handler was connected
+ * @return 
+ */
+GtkWidget * create_view_and_model (GArray *words_list, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        ws_gui_app->ws_gui_w_list->ws_gui_view = gtk_tree_view_new ();
+
+        ws_gui_app->ws_gui_w_list->ws_gui_renderer=gtk_cell_renderer_text_new();
+        gtk_tree_view_insert_column_with_attributes(
+                         GTK_TREE_VIEW (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                         -1,
+                         "Name",
+                         ws_gui_app->ws_gui_w_list->ws_gui_renderer,
+                         "text",
+                         COL_WORD,
+                         NULL);
+        ws_gui_app->ws_gui_w_list->ws_gui_model = 
+                                create_and_fill_model(words_list, ws_gui_app);
+
+        gtk_tree_view_set_model(
+                         GTK_TREE_VIEW (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                         ws_gui_app->ws_gui_w_list->ws_gui_model);
+       g_object_unref (ws_gui_app->ws_gui_w_list->ws_gui_model);
+       
+        return ws_gui_app->ws_gui_w_list->ws_gui_view;
+}
+
+/** switch application between fun screen and normal mode
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_full_screen(GtkMenuItem *menuitem, gpointer user_data)
+{
+
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        if (ws_gui_app->ws_gui_full_screen_flag == FALSE) {
+
+                gtk_window_fullscreen(
+                                  GTK_WINDOW(ws_gui_app->ws_gui_hildon_window));
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                              ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen),
+                              TRUE);
+                ws_gui_app->ws_gui_full_screen_flag = TRUE;
+               gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_fullscreen_on"));
+        }
+        else 
+        {
+                gtk_window_unfullscreen(
+                                  GTK_WINDOW(ws_gui_app->ws_gui_hildon_window));
+                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                              ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen),
+                              FALSE);
+                ws_gui_app->ws_gui_full_screen_flag = FALSE;
+               gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_fullscreen_off"));
+        }
+}
+
+/** search for selected text in a dictionary
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_popup_search(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        gchar *temp;
+        ws_gui_app->ws_gui_clipboard_primary = 
+                gtk_widget_get_clipboard(ws_gui_app->ws_gui_html,
+                                         GDK_SELECTION_PRIMARY);
+        temp = gtk_clipboard_wait_for_text(
+                                         ws_gui_app->ws_gui_clipboard_primary);
+
+       g_strstrip(temp);
+        if (temp != NULL || strcmp(temp, " "))
+        {
+                g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                      "prefix",
+                                      temp,
+                                      NULL);
+                ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+        }
+        else
+        {
+                hildon_banner_show_information(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_ni_no_text_selected"));
+        }
+}
+
+/** select whole text in the translation (html) area
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_html_select_all(GtkMenuItem *menuitem, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        gtk_html_select_all(GTK_HTML(ws_gui_app->ws_gui_html));
+}
+
+/** copy selected text to the clipoard from context popup menu
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_html_copy(GtkMenuItem *menuitem, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+       gtk_html_copy(GTK_HTML(ws_gui_app->ws_gui_html));
+       gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_copied"));
+}
+
+/** paste copied text into toolbar entry
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_html_paste(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+
+        gchar *temp;
+        gchar *temp2;
+        temp = gtk_clipboard_wait_for_text(ws_gui_app->ws_gui_clipboard);
+        g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                     "prefix",
+                     &temp2,
+                     NULL);
+        temp = g_strconcat(temp2, temp, NULL);
+        temp = g_strdelimit(temp, "\n", ' ');
+        g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                     "prefix",
+                     temp,
+                     NULL);
+       gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_pasted"));
+}
+
+/** zoom in text in translation (html) area
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_html_zoom_in(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+       ws_gui_app->zoom = ws_gui_app->zoom + ZOOM_STEP;
+       if (ws_gui_app->zoom > ZOOM_MAX)
+       {
+               ws_gui_app->zoom = ws_gui_app->zoom - ZOOM_STEP;
+               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ib_max_zoom"));
+       }
+       else
+       {
+               gtk_html_set_magnification(GTK_HTML(ws_gui_app->ws_gui_html), 
+                                               ws_gui_app->zoom);
+
+               if ((WS_GUI_ABS(ws_gui_app->zoom - ZOOM_DEFAULT)) < 0.000001)
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_default"));
+               }
+               else
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_in"));
+               }
+       }
+}
+
+/** zoom out text in translation (html) area
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_html_zoom_out(GtkMenuItem *menuitem, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        ws_gui_app->zoom = ws_gui_app->zoom - ZOOM_STEP;
+       if (ws_gui_app->zoom < ZOOM_MIN)
+       {
+               ws_gui_app->zoom = ws_gui_app->zoom + ZOOM_STEP;
+               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ib_min_zoom"));
+       }
+       else
+       {
+               gtk_html_set_magnification(GTK_HTML(ws_gui_app->ws_gui_html), 
+                                               ws_gui_app->zoom);
+               
+               if ((WS_GUI_ABS(ws_gui_app->zoom - ZOOM_DEFAULT)) < 0.000001)
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_default"));
+               }
+               else
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_out"));
+               }
+       }
+}
+
+/** start searching, send typed word to DBUS and query for words
+ *
+ * @param widget - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_search(GtkWidget * widget, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+       
+       ws_gui_app->stop_clicked = FALSE;
+
+       // if (ws_gui_app->ws_gui_banner_flag == FALSE) 
+       //{
+       gchar* ws_gui_text = NULL;
+        g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                     "prefix",
+                     &ws_gui_text,
+                     NULL);
+
+       if (ws_gui_app->bookmark_mode == FALSE) 
+       {
+               g_free(ws_gui_app->last_searched);
+               ws_gui_app->last_searched = NULL;
+               ws_gui_app->last_searched = g_strdup(ws_gui_text);
+       }
+       else
+       {
+               g_free(ws_gui_app->last_searched_in_book);
+               ws_gui_app->last_searched_in_book = NULL;
+               ws_gui_app->last_searched_in_book = g_strdup(ws_gui_text);
+       }
+       
+       g_strstrip(ws_gui_text);
+               if (strlen(ws_gui_text) != 0) 
+               {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_list_searching);
+               
+                ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+
+              //  ws_gui_app->ws_gui_banner_flag = TRUE;
+                //ws_gui_fill_html(" ", ws_gui_app);
+               //ws_gui_app->html_flag = FALSE;
+                ws_dbus_client_find_word (ws_gui_app->dbus_data, ws_gui_text);
+               gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+               g_free(ws_gui_text);
+               }
+               else 
+               {
+                gtk_infoprint(
+                              GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                              _("ws_ni_no_word_typed"));
+        }
+       g_free(ws_gui_app->last_word);
+       ws_gui_app->last_word=NULL;
+       //}
+}
+
+/** stop search process
+ *
+ * @param button - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_search_stop(GtkButton *button, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       ws_gui_app->stop_clicked = TRUE;
+       // if (ws_gui_app->ws_gui_banner_flag == TRUE || ws_gui_app->loading == TRUE) 
+       if (ws_gui_app->loading == TRUE) 
+        {
+                //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+
+               ws_gui_app->loading = FALSE;
+               ws_gui_set_toolbar_avail(ws_gui_app);           
+
+               //ws_gui_app->ws_gui_banner_flag = FALSE;
+               
+                ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_STOP_SEARCH);
+                gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                              _("ws_ni_search_aborted"));
+        }
+}
+
+/** this function is called just before closing application; 
+it sends signal to DBUS and destroys it; 
+ *
+ * @param widget - object which recived the signal
+ * @param event - 
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_on_exit (GtkWidget *widget, GdkEvent *event, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);
+       g_timer_destroy(ws_gui_app->timer);
+        ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_TERMINATE);
+        ws_dbus_destroy (ws_gui_app->dbus_data);
+        ws_gui_free_memory(ws_gui_app);
+        gtk_main_quit();
+        exit (0);
+}
+
+/** this function is called just before closing application, 
+from application menu; it sends signal to DBUS and destroys it;
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_menu_quit(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);
+        g_timer_destroy(ws_gui_app->timer);
+        ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_TERMINATE);
+        ws_dbus_destroy (ws_gui_app->dbus_data);
+        ws_gui_free_memory(ws_gui_app);
+        gtk_main_quit();
+        exit (0);
+}
+
+/** fill translation area with text (html) recived from DBUS
+ *
+ * @param html_context - text which is going to be displayed; it should be html
+ * @param user_data - user data set when the function was called
+ * @return
+ */
+void ws_gui_fill_html(char *html_context, gpointer user_data) 
+{
+       WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        gtk_html_set_editable (GTK_HTML(ws_gui_app->ws_gui_html), FALSE);
+
+        gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html),
+                                  html_context,
+                                  -1);
+}
+
+/** read adjustment of left scrollwindow, which is necessary to navigate with 
+arrow keys inside words list
+ *
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_read_adjustment(gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       ws_gui_app->ws_gui_hadj = 
+                gtk_scrolled_window_get_hadjustment(
+                GTK_SCROLLED_WINDOW(
+               ws_gui_app->ws_gui_scrolledwindow_left));
+
+        ws_gui_app->h_delta = (ws_gui_app->ws_gui_hadj->upper -
+                                  ws_gui_app->ws_gui_hadj->lower)/SCROLL_STEP_H;
+
+        ws_gui_app->ws_gui_vadj = gtk_scrolled_window_get_vadjustment(
+        GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_left));
+
+        ws_gui_app->v_delta = (ws_gui_app->ws_gui_vadj->upper -
+                                  ws_gui_app->ws_gui_vadj->lower)/SCROLL_STEP_V;
+        ws_gui_app->v_new_value =
+           gtk_adjustment_get_value(GTK_ADJUSTMENT(ws_gui_app->ws_gui_vadj)) +
+                                                            ws_gui_app->v_delta;
+
+        gtk_container_set_focus_vadjustment(
+               GTK_CONTAINER(ws_gui_app->ws_gui_scrolledwindow_left), 
+               gtk_scrolled_window_get_vadjustment(
+                  GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_left)));
+
+}
+
+/** allows to display image in html area
+ *
+ * @param html - object which received a signal 
+ * @param url - url to the image
+ * @param stream - html stream 
+ * @return
+ */
+void ws_gui_url_requested (
+                         GtkHTML *html, 
+                         const char *url, 
+                         GtkHTMLStream *stream)
+{
+        int fd;
+
+        if (url && !strncmp (url, "file:", 5)) {
+                url += 5;
+                fd = open (url, O_RDONLY);
+                if (fd != -1) {
+                        gchar *buf;
+                        size_t size;
+                        buf = alloca (8192);
+                        while ((size = read (fd, buf, 8192)) > 0) {
+                                gtk_html_stream_write (stream, buf, size);
+                        }
+                       gtk_html_stream_close(stream, size == -1
+                                         ? GTK_HTML_STREAM_ERROR
+                                         : GTK_HTML_STREAM_OK);
+                       close (fd);
+
+                      return;
+                }
+        }
+
+        gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+}
+
+/** handles button press event and examines what kind of event was it 
+        suppose to be
+ *
+ * @param widget - object which received a signal
+ * @param event - type of event which has been performed
+ * @param user_data - user data set when the signal handler was connected 
+ * @return TRUE to stop other handlers from being invoked for the event. 
+ FALSE to propagate the event further
+ */
+gboolean ws_gui_button_press(GtkWidget *widget,
+                             GdkEventButton *event,
+                             gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        if (ws_gui_app->ws_gui_sel_flag == FALSE)
+        {
+                if (event->type == GDK_2BUTTON_PRESS) 
+                {
+                        ws_gui_app->ws_gui_double_click = TRUE;
+                        g_timer_stop(ws_gui_app->timer);
+                        g_timer_reset(ws_gui_app->timer);
+                        return FALSE;
+                }
+
+                g_signal_stop_emission_by_name(G_OBJECT(
+                                               ws_gui_app->ws_gui_html),
+                                               "button-press-event");
+                g_timer_start(ws_gui_app->timer);
+                gtk_timeout_add((guint)(PRESS_TIME*1000),
+                                (GtkFunction)(ws_gui_show_popup),
+                                ws_gui_app);
+                return FALSE;
+        }
+        else
+        {
+                ws_gui_app->ws_gui_sel_flag = FALSE;
+                return FALSE;
+        }
+
+}
+
+/** handles button release event and examines whether 'click' or 'tap and hold' 
+event it supposed to be
+ *
+ * @param widget - object which received a signal
+ * @param event - type of event which has been performed
+ * @param user_data - user data set when the signal handler was connected 
+ * @return TRUE to stop other handlers from being invoked for the event. 
+ FALSE to propagate the event further
+ */
+gboolean ws_gui_button_release (GtkWidget *widget,
+                                GdkEventButton *event,
+                                gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        gdouble tmp = g_timer_elapsed(ws_gui_app->timer, NULL);
+        g_timer_stop(ws_gui_app->timer);
+        g_timer_reset(ws_gui_app->timer);
+        if (ws_gui_app->ws_gui_double_click == TRUE)
+        {
+                ws_gui_app->ws_gui_double_click = FALSE;
+                return FALSE;
+        }
+        else if (tmp < PRESS_TIME)
+        {
+                struct _GtkHTML *tmp = (struct _GtkHTML *)
+                                        (ws_gui_app->ws_gui_html);
+                html_engine_unselect_all(tmp->engine);
+                return TRUE;
+        }
+                return FALSE;
+}
+
+/** displays popup menu if user holds a stylus more than PRESS_TIME seconds
+ *
+ * @param user_data - user data set when the signal handler was connected 
+ * @return 
+ */
+guint ws_gui_show_popup (gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        gdouble tmp = g_timer_elapsed(ws_gui_app->timer, NULL);
+       if (tmp > PRESS_TIME)
+        {
+                ws_gui_create_popup_menu(ws_gui_app);
+        }
+        return (guint)(FALSE);
+
+}
+
+/** checks clipboard content and sets sensitivity of widgets 
+ *
+ * @param widget - object which recived a signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return 
+ */
+void ws_gui_check_clipboard (GtkWidget *widget, gpointer user_data) 
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        if (gtk_clipboard_wait_for_text(ws_gui_app->ws_gui_clipboard) != NULL)
+        {
+                gtk_widget_set_sensitive(
+                         GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_paste),
+                         TRUE);
+        }
+        else
+        {
+                gtk_widget_set_sensitive(
+                         GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_paste),
+                         FALSE);
+        }
+
+       struct _GtkHTML *tmp = (struct _GtkHTML *)(ws_gui_app->ws_gui_html);
+
+       if (html_engine_is_selection_active(tmp->engine) == TRUE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_copy),
+                               TRUE);
+       }
+       else 
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_copy),
+                               FALSE);
+       }
+
+       if (ws_gui_app->html_flag == FALSE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_select_all),
+                       FALSE);
+       }
+       else
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_select_all),
+                       TRUE);
+       }       
+
+}
+
+/** gets received string (with translation), formats it and sends it to be 
+ * displayed
+ *
+ * @param received_string - content received from Manager
+ * @param user_data - user data set when the function has been called
+ * @return 
+ */
+gchar * format_html (gchar * received_string, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        GString *str_final;
+       GString *str_tmp;
+        str_final = g_string_new(received_string);
+       str_tmp = g_string_new(received_string);
+        gchar * tmp;
+       gchar * tmp2;
+       gchar * returned_value;
+       
+       ws_gui_app->raw_translation=g_string_erase(ws_gui_app->raw_translation, 
+                                                  0, 
+                                                 -1);
+
+        while (strstr(str_final->str, "<PATTERN_OPEN>") != NULL)
+        {
+                tmp = strstr(str_final->str, "<PATTERN_OPEN>");
+                str_final =  g_string_erase(str_final,
+                                           (long)(tmp - str_final->str),
+                                           14);
+                str_final =  g_string_insert(str_final,
+                 (long)(tmp - str_final->str),
+                 "<html><head></head><body><center><table width=\"95%\"><tr>"
+                "<td><table border=1 width=100%><tr>"
+                "<th background=\"file:/usr/share/pixmaps/ws_top.png\">"
+                "<img align=left src=\"file:/usr/share/pixmaps/"
+                "engine_xdxf_icon.png\"><font color=\"#eeeeee\">");
+               
+               tmp2 = strstr(str_tmp->str, "<PATTERN_OPEN>");
+               if (ws_gui_app->last_word != NULL)
+               {
+                       str_tmp =  g_string_erase(str_tmp,
+                                           (long)(tmp2 - str_tmp->str),
+                                           14 + strlen(ws_gui_app->last_word));
+               }
+       }
+
+        while (strstr(str_final->str, "<PATTERN_CLOSED>") != NULL)
+        {
+                tmp = strstr(str_final->str, "<PATTERN_CLOSED>");
+                str_final =  g_string_erase(str_final,
+                                            (long)(tmp - str_final->str),
+                                            16);
+                str_final =  g_string_insert(str_final,
+                                            (long)(tmp - str_final->str),
+                                            "</font></th></tr></table>");
+
+               tmp2 = strstr(str_tmp->str, "<PATTERN_CLOSED>");
+               str_tmp =  g_string_erase(str_tmp,
+                                          (long)(tmp2 - str_tmp->str),
+                                          16);
+        }
+
+        while (strstr(str_final->str, "<TRANSLATION_OPEN>") != NULL)
+        {
+                tmp = strstr(str_final->str, "<TRANSLATION_OPEN>");
+                str_final =  g_string_erase (str_final,
+                                             (long)(tmp - str_final->str),
+                                             18);
+                str_final =  g_string_insert (str_final,
+                (long)(tmp - str_final->str),
+                "<table border=1 width=100%><tr><td background=\"file:/usr/"
+               "share/pixmaps/ws_tra.png\">");
+
+               tmp2 = strstr(str_tmp->str, "<TRANSLATION_OPEN>");
+               str_tmp =  g_string_erase(str_tmp,
+                                           (long)(tmp2 - str_tmp->str),
+                                           18);
+       }
+
+        while (strstr(str_final->str, "<TRANSLATION_CLOSED>") != NULL)
+        {
+                tmp = strstr(str_final->str, "<TRANSLATION_CLOSED>");
+                str_final =  g_string_erase(str_final,
+                                            (long)(tmp - str_final->str),
+                                            20);
+                str_final =  g_string_insert(str_final,
+                                             (long)(tmp - str_final->str),
+                                             "</td></tr></table></center>");
+
+               tmp2 = strstr(str_tmp->str, "<TRANSLATION_CLOSED>");
+               str_tmp =  g_string_erase(str_tmp,
+                                          (long)(tmp2 - str_tmp->str),
+                                         20);
+       }
+
+        str_final = g_string_append(str_final,
+                                    "</td></tr></table></body></html>");
+
+       ws_gui_app->raw_translation = g_string_insert(
+                                               ws_gui_app->raw_translation,
+                                               0,
+                                               str_tmp->str);
+       
+       returned_value = g_strdup(str_final->str);
+       g_string_free(str_final, TRUE);
+       g_string_free(str_tmp, TRUE);
+       return returned_value;
+}
+
+/** open bookmarks database 
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_dictionary_open_bookmark(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       ws_gui_read_active_dictionaries(ws_gui_app);
+       
+       /*list has to be cleared if we're gonna use a completely different dict*/
+       ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       g_free(ws_gui_app->last_word);
+       ws_gui_app->last_word = NULL;
+
+       ws_gui_app->bookmark_mode = TRUE;
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);
+       g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                     "prefix",
+                                      "*",
+                                      NULL);
+       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_BOOKMARK_MODE_ON);
+       
+       if(ws_gui_app->ws_gui_history->len >= 0)
+       {
+       ws_gui_clear_array(ws_gui_app->ws_gui_history);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+       ws_gui_app->ws_gui_history_cur_pos = -1;
+       }
+       ws_gui_check_history(ws_gui_app);
+       
+       ws_gui_fill_html(" ", ws_gui_app);
+       ws_gui_app->html_flag = FALSE;
+       ws_dbus_client_find_word(ws_gui_app->dbus_data, "*");
+       gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+       ws_gui_search(NULL, ws_gui_app);
+       
+}
+
+/** closes bookmarks database 
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_dictionary_close_bookmark(GtkMenuItem *menuitem, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       ws_gui_read_active_dictionaries(ws_gui_app);
+       
+       g_free(ws_gui_app->last_word);
+       ws_gui_app->last_word = NULL;
+
+        ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);   
+       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_BOOKMARK_MODE_OFF);
+
+       if(ws_gui_app->ws_gui_history->len >= 0)
+       {
+       ws_gui_clear_array(ws_gui_app->ws_gui_history);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+       ws_gui_app->ws_gui_history_cur_pos = -1;
+       }
+       ws_gui_check_history(ws_gui_app);
+
+       ws_gui_fill_html(" ", ws_gui_app);
+       ws_gui_app->html_flag = FALSE;
+       g_strstrip(ws_gui_app->last_searched);
+       if (ws_gui_app->last_searched != NULL) 
+       {
+       g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                     "prefix",
+                                      ws_gui_app->last_searched,
+                                      NULL);
+       //ws_dbus_client_find_word(ws_gui_app->dbus_data, ws_gui_app->last_searched);
+       ws_gui_search(NULL, ws_gui_app);
+       }
+       else
+       {
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                    "prefix",
+                                      "\0",
+                                      NULL);
+               GArray *tmp;
+                tmp = g_array_new(TRUE, TRUE, sizeof(gchar*));
+                gtk_list_store_clear(ws_gui_app->ws_gui_w_list->ws_gui_store);
+                ws_gui_app->ws_gui_w_list->ws_gui_model = 
+                                       create_and_fill_model(tmp, ws_gui_app);
+               
+               ws_dbus_client_find_word(ws_gui_app->dbus_data, ws_gui_app->last_searched);
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               ws_gui_search(NULL, ws_gui_app);        
+       }
+}
+
+/** adds bookmark to bookmarks database 
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_dictionary_add_bookmark(GtkMenuItem *menuitem, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       if (ws_gui_app->last_word != NULL)
+       {
+               ws_gui_add_bookmark_dialog(ws_gui_app);
+       } 
+       else
+       {
+               gtk_infoprint(
+                              GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                              _("ws_ni_select_word_to_add"));
+       }
+}
+
+/** removes bookmark from bookmarks database 
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_dictionary_remove_bookmark(GtkMenuItem *menuitem, 
+                                      gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+               if (ws_gui_app->last_word != NULL)
+       {
+               ws_gui_remove_bookmark_dialog(ws_gui_app);
+
+               gchar *temp;
+               g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                      "prefix",
+                                      &temp,
+                                      NULL);
+               ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               
+       }
+       else
+       {
+               gtk_infoprint(
+                              GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                              _("ws_ni_select_word_to_remove"));
+       }
+       
+       
+}
+
+/** checks wheather dictionaries are available or not; according to the result
+ * dimmes proper menuitem 
+ *
+ * @param menuitem - object which recived the signal
+ * @param user_data - user data set when the signal handler was connected 
+ * @return
+ */
+void ws_gui_dict_availablity(GtkMenuItem *menuitem, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       if (gconf_client_dir_exists(ws_gui_app->client, 
+                                   GCONF_PATH, NULL) == TRUE)
+       {
+               ws_gui_app->directories = gconf_client_all_dirs(
+                                                       ws_gui_app->client,
+                                                       GCONF_PATH,
+                                                       NULL
+                                                       );
+               
+       
+               if(g_slist_length(ws_gui_app->directories) != 0)
+               {
+                       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict),
+                       TRUE);
+                       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict),
+                       TRUE);
+                       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_optimize_dict),
+                       TRUE);
+               }
+
+       }
+       else 
+       {
+       gtk_widget_set_sensitive(GTK_WIDGET
+                             (ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict),
+                             FALSE);
+       gtk_widget_set_sensitive(GTK_WIDGET
+                             (ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict),
+                             FALSE);
+       gtk_widget_set_sensitive(GTK_WIDGET
+                           (ws_gui_app->ws_gui_menu->ws_gui_menu_optimize_dict),
+                           FALSE);
+       }
+
+}
+
+/** sets sensitivity of menu items due to bookmark's mode
+ *
+ * @param user_data - user data set when the function was called 
+ * @return
+ */
+void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       int i;
+       gchar *string;
+       gchar *name;
+
+       if (ws_gui_app->bookmark_mode == TRUE)
+       {
+               g_slist_free(ws_gui_app->directories_last);
+               ws_gui_app->directories_last = NULL;
+               ws_gui_app->directories_last = g_slist_alloc();
+               g_slist_free(ws_gui_app->directories);
+               ws_gui_app->directories = g_slist_alloc();
+
+               ws_gui_app->directories = gconf_client_all_dirs(
+                                                       ws_gui_app->client, 
+                                                       GCONF_PATH, NULL);
+               
+       for (i=0; i<g_slist_length(ws_gui_app->directories); i++)
+        {
+               string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i);
+               name = g_path_get_basename(string);
+               string = g_strconcat(string, "/active", NULL);
+               
+               if (gconf_client_get_bool(ws_gui_app->client, string, NULL) == TRUE) 
+               {
+                       ws_gui_app->directories_last = 
+                               g_slist_append(ws_gui_app->directories_last, 
+                                              string);
+               }
+
+               if (strcmp(name, "bookmarks") == 0)
+               {
+                       gconf_client_set_bool(ws_gui_app->client, 
+                                             string, 
+                                             TRUE, 
+                                             NULL);
+               }
+               else
+               {
+                       gconf_client_set_bool(ws_gui_app->client, 
+                                             string, 
+                                             FALSE, 
+                                             NULL);
+               }
+       }
+
+       //setting sensitivity of components
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark),
+                FALSE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_close_bookmark),
+                TRUE);
+       gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark),
+               TRUE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
+                FALSE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries),
+                FALSE);
+       }
+       else 
+       {
+       gchar *bookmarks_path = g_strconcat(GCONF_PATH, "/bookmarks/active", NULL);
+       if (g_slist_length(ws_gui_app->directories_last) > 0)
+       {
+       gconf_client_set_bool(ws_gui_app->client, bookmarks_path, FALSE, NULL);
+       }
+       
+       for (i=0; i<g_slist_length(ws_gui_app->directories_last); i++)
+        {
+               string = (gchar*)g_slist_nth_data(ws_gui_app->directories_last, 
+                                                 i);
+               
+               if (string != NULL)
+               {
+               gconf_client_set_bool(ws_gui_app->client, 
+                               string, 
+                               TRUE, 
+                               NULL);
+               }
+       }
+
+       //setting sensitivity of components
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark),
+                TRUE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_close_bookmark),
+                FALSE);
+       gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark),
+               FALSE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
+                TRUE);
+       gtk_widget_set_sensitive(
+               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries),
+                TRUE);
+
+       g_free(bookmarks_path);
+       }
+
+}
+
+/** sets sensitivity of menu items due to user selection made
+ *
+ * @param user_data - user data set when the function was called 
+ * @return
+ */
+void ws_gui_set_bookmark_menu_items(GtkMenuItem *menuitem, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       if (ws_gui_app->bookmark_mode == TRUE && ws_gui_app->last_word != NULL)
+       {
+              gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark),
+               TRUE);
+       }
+       else
+       {
+              gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark),
+               FALSE);
+       }
+
+       if (ws_gui_app->last_word == NULL || 
+           (ws_gui_app->last_word[0] == '\0') ||
+           ws_gui_app->bookmark_mode == TRUE)
+       {
+              gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
+               FALSE);
+       }
+       else
+       {
+              gtk_widget_set_sensitive(
+              GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
+               TRUE);
+       }
+}
+/** reads gconf entries and sets variables with a proper data; it is necessary
+ * for changing the bookmarks mode
+ *
+ * @param user_data - user data set when the function was called
+ * @return
+ */
+void ws_gui_read_active_dictionaries(gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       
+       ws_gui_app->directories = gconf_client_all_dirs(ws_gui_app->client,
+                                             GCONF_PATH,
+                                             NULL);
+}
+
+void ws_gui_clear_array(GArray *history)
+{
+       if(history->len >= 0)
+       {
+               history = g_array_remove_range(history, 0, history->len);
+       }
+}
+
+void ws_gui_view_cursor_changed(GtkTreeView *treeview, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       gchar *string;
+       if (gtk_tree_selection_get_selected(ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                                       &ws_gui_app->ws_gui_w_list->ws_gui_model,
+                                       &ws_gui_app->ws_gui_w_list->ws_gui_iter))
+       {
+       gtk_tree_model_get(ws_gui_app->ws_gui_w_list->ws_gui_model,
+                                   &ws_gui_app->ws_gui_w_list->ws_gui_iter,
+                                   COL_WORD,
+                                   &string,
+                                  -1);
+       if (string != NULL)
+               {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+
+               ws_dbus_client_find_translation(ws_gui_app->dbus_data, string);
+               
+               
+               g_free(ws_gui_app->last_word);
+               ws_gui_app->last_word = NULL;
+               ws_gui_app->last_word = g_strdup (string);
+
+               if (ws_gui_app->history_flag == FALSE)
+               {
+                      ws_gui_history_add(string, ws_gui_app);
+               
+               }
+                g_free (string);
+               }
+               
+       }
+       
+       
+}
+
+void ws_gui_set_toolbar_avail(gpointer user_data) {
+       
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       if (ws_gui_app->loading == TRUE)
+       {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
+                       TRUE);
+       
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       FALSE);
+
+       }
+       else 
+       {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
+                       FALSE);
+       
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       TRUE);
+       }
+}
diff --git a/src/gui/src/ws_gui_layout.c b/src/gui/src/ws_gui_layout.c
new file mode 100644 (file)
index 0000000..54e29ce
--- /dev/null
@@ -0,0 +1,1789 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_gui_layout.h>
+#include <ws_gui.h>
+#include <ws_gui_callbacks.h>
+#include <ws_dbus.h>
+#include <libintl.h>
+
+
+/** this function creates main window and it components; moreover there are 
+ * signal connections;
+ *
+ * @param user_data - data set when the signal handler was connected 
+ */
+void ws_gui_create_window(gpointer user_data) 
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       ws_gui_app->welcome_note = g_strconcat("<br><br><center><font size=+3>", 
+                                  _("ws_ni_welcome"), "<br><IMG SRC=file:/usr/share/pixmaps/whitestork.png>", 
+                                  NULL);
+
+//     ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string = 
+//                                                  (ws_gui_app->welcome_note);
+
+        GArray *array_tmp = g_array_new (TRUE, TRUE, sizeof(gchar*));
+       ws_gui_app->raw_translation = g_string_new(" ");
+       ws_gui_app->last_searched = NULL;
+       ws_gui_app->last_searched_in_book = NULL;
+       ws_gui_app->last_word = NULL;
+
+        ws_gui_app->ws_gui_banner_flag = FALSE;
+        ws_gui_app->ws_gui_full_screen_flag = FALSE;
+        ws_gui_app->caching_flag = FALSE;
+        ws_gui_app->ws_gui_double_click = FALSE;
+        ws_gui_app->ws_gui_sel_flag = FALSE;
+       ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_app->bookmark_avail = TRUE;
+       ws_gui_app->html_flag = TRUE;
+       ws_gui_app->loading = FALSE;
+       ws_gui_app->stop_clicked = FALSE;
+
+       ws_gui_app->zoom = ZOOM_DEFAULT;
+
+        ws_gui_app->timer = g_timer_new();
+        g_timer_stop(ws_gui_app->timer);
+
+        ws_gui_app->ws_gui_history = g_array_new(TRUE, TRUE, sizeof(gchar*));
+       ws_gui_app->ws_gui_history_list = g_array_new(TRUE, TRUE, sizeof(gchar*));
+       ws_gui_app->ws_gui_history_iter = g_array_new(TRUE, TRUE, sizeof(gchar*));
+       ws_gui_app->history_flag = FALSE;
+        ws_gui_app->ws_gui_history_cur_pos = -1;
+       
+        ws_gui_app->ws_gui_hildon_program = 
+        HILDON_PROGRAM(hildon_program_get_instance());
+
+        g_set_application_name("WhiteStork");
+
+        ws_gui_app->ws_gui_hildon_window = HILDON_WINDOW(hildon_window_new());
+
+        hildon_program_add_window(ws_gui_app->ws_gui_hildon_program,
+                                  ws_gui_app->ws_gui_hildon_window);
+
+       ws_gui_create_main_menu(ws_gui_app);
+        ws_gui_create_find_toolbar(ws_gui_app);
+
+        ws_gui_app->ws_gui_hpane = gtk_hpaned_new();
+
+        ws_gui_app->ws_gui_scrolledwindow_left = 
+                gtk_scrolled_window_new (NULL, NULL);
+
+        gtk_scrolled_window_set_policy(
+                GTK_SCROLLED_WINDOW (ws_gui_app->ws_gui_scrolledwindow_left), 
+                GTK_POLICY_AUTOMATIC,
+                GTK_POLICY_AUTOMATIC);
+
+        gtk_paned_set_position(GTK_PANED(ws_gui_app->ws_gui_hpane), 100);
+
+        gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW
+                                       (ws_gui_app->ws_gui_scrolledwindow_left),
+                                       GTK_CORNER_TOP_LEFT);
+
+        ws_gui_app->ws_gui_scrolledwindow_right = 
+                gtk_scrolled_window_new (NULL, NULL);
+
+        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
+                                     (ws_gui_app->ws_gui_scrolledwindow_right), 
+                                     GTK_POLICY_NEVER,
+                                     GTK_POLICY_AUTOMATIC);
+
+        ws_gui_app->ws_gui_w_list->ws_gui_store = 
+                gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_UINT);
+
+        ws_gui_app->ws_gui_w_list->ws_gui_view = 
+                create_view_and_model(array_tmp, ws_gui_app);
+
+       g_array_free(array_tmp, TRUE);
+
+        gtk_widget_show_all(GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view));
+
+        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
+                                       (ws_gui_app->ws_gui_scrolledwindow_left), 
+                                        ws_gui_app->ws_gui_w_list->ws_gui_view);
+
+        ws_gui_app->ws_gui_html = gtk_html_new();
+
+        ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
+        gtk_widget_modify_font(GTK_WIDGET(
+                                       ws_gui_app->ws_gui_html),ws_gui_app->p);
+
+        g_signal_connect(GTK_OBJECT (ws_gui_app->ws_gui_html),
+                                 "url_requested",
+                                 G_CALLBACK(ws_gui_url_requested),
+                                 ws_gui_app);
+
+        gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html),
+                        ws_gui_app->welcome_note,
+                        -1);
+       
+       g_free(ws_gui_app->welcome_note);
+       ws_gui_app->welcome_note = NULL;
+
+       gtk_html_set_magnification(GTK_HTML(ws_gui_app->ws_gui_html), 
+                                  ws_gui_app->zoom);
+
+        gtk_html_set_editable(GTK_HTML(ws_gui_app->ws_gui_html), FALSE); 
+        gtk_html_allow_selection(GTK_HTML(ws_gui_app->ws_gui_html), TRUE);
+
+        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
+                                      (ws_gui_app->ws_gui_scrolledwindow_right),
+                                       ws_gui_app->ws_gui_html);
+
+       /*adding vbox & label - used for notifications */
+
+       ws_gui_app->ws_gui_list_image = gtk_image_new_from_file("/usr/share/pixmaps/ws_warning_icon.png");
+       ws_gui_app->ws_gui_list_eventbox = gtk_event_box_new ();
+       ws_gui_app->ws_gui_list_vbox = gtk_vbox_new(FALSE, 0);
+       ws_gui_app->ws_gui_list_hbox = gtk_hbox_new(FALSE, 5);
+       ws_gui_app->ws_gui_list_label = gtk_label_new(_("ws_ti_list_full"));
+
+       ws_gui_app->p = pango_font_description_from_string("Tahoma 10");
+        gtk_widget_modify_font(GTK_WIDGET(ws_gui_app->ws_gui_list_label), ws_gui_app->p);
+
+       /*HBox packing ....*/
+       gtk_box_pack_start(GTK_BOX(ws_gui_app->ws_gui_list_hbox),
+                          ws_gui_app->ws_gui_list_image,
+                          FALSE,
+                          FALSE,
+                          0);
+       
+       gtk_box_pack_start(GTK_BOX(ws_gui_app->ws_gui_list_hbox),
+                          ws_gui_app->ws_gui_list_label,
+                          FALSE,
+                          FALSE,
+                          0);
+       
+       // gtk_widget_set_size_request (ws_gui_app->ws_gui_list_label, 150, -1);
+
+       /*VBox packing ....*/
+       gtk_box_pack_start(GTK_BOX(ws_gui_app->ws_gui_list_vbox),
+                          ws_gui_app->ws_gui_scrolledwindow_left,
+                          TRUE,
+                          TRUE,
+                          0);
+
+       gtk_box_pack_start(GTK_BOX(ws_gui_app->ws_gui_list_vbox),
+                          ws_gui_app->ws_gui_list_eventbox,
+                          FALSE,
+                          FALSE,
+                          0);
+       
+       gtk_container_add (GTK_CONTAINER (ws_gui_app->ws_gui_list_eventbox), 
+                          ws_gui_app->ws_gui_list_hbox);
+       /************************************************/
+
+
+       gtk_paned_pack1(GTK_PANED(ws_gui_app->ws_gui_hpane),
+                       ws_gui_app->ws_gui_list_vbox,
+                       TRUE,
+                       TRUE);
+        gtk_paned_pack2(GTK_PANED(ws_gui_app->ws_gui_hpane),
+                       ws_gui_app->ws_gui_scrolledwindow_right,
+                       TRUE,
+                       TRUE);
+
+        gtk_container_add(GTK_CONTAINER(ws_gui_app->ws_gui_hildon_window), 
+                        ws_gui_app->ws_gui_hpane);
+
+        gtk_widget_show_all(GTK_WIDGET(ws_gui_app->ws_gui_hildon_window));
+
+       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+
+        ws_gui_app->ws_gui_w_list->ws_gui_selection = 
+                gtk_tree_view_get_selection (GTK_TREE_VIEW
+                (ws_gui_app->ws_gui_w_list->ws_gui_view));
+
+       gtk_tree_selection_set_mode(
+                                   ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                                     GTK_SELECTION_BROWSE);
+       
+       ws_gui_app->directories = g_slist_alloc();
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);
+
+       ws_gui_app->ws_gui_banner_list_searching = hildon_banner_show_animation(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_ab_searching"));
+
+       ws_gui_app->ws_gui_banner_translation_loading = hildon_banner_show_animation(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_ab_loading"));
+       
+       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       FALSE);
+
+       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_translation_loading));
+}
+
+/** this function creates a find toolbar and connects signals to the tollbars 
+ * components
+ *
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_create_find_toolbar(gpointer user_data)
+{
+       WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+       
+       GtkToolItem *space;
+       ws_gui_app->ws_gui_hildon_find_toolbar = 
+       HILDON_FIND_TOOLBAR(hildon_find_toolbar_new(_("ws_me_search_find")));
+       
+       ws_gui_app->ws_gui_toobar_button_hide =
+       gtk_toggle_tool_button_new_from_stock(GTK_STOCK_GOTO_FIRST);
+       ws_gui_app->ws_gui_toobar_button_back = 
+       gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
+       ws_gui_app->ws_gui_toobar_button_forward =
+       gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+       ws_gui_app->ws_gui_toobar_button_stop = 
+       gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
+       space = gtk_separator_tool_item_new(); 
+       
+       ws_gui_app->ws_gui_toobar_button_close = 
+               gtk_toolbar_get_nth_item(GTK_TOOLBAR(
+                                       ws_gui_app->ws_gui_hildon_find_toolbar),
+                                       4);
+
+       ws_gui_app->ws_gui_toobar_button_start = gtk_toolbar_get_nth_item(GTK_TOOLBAR(
+                                       ws_gui_app->ws_gui_hildon_find_toolbar),
+                                       2);
+
+       gtk_tool_item_set_visible_horizontal(
+                               ws_gui_app->ws_gui_toobar_button_close,
+                               FALSE);
+       
+       gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               ws_gui_app->ws_gui_toobar_button_hide,
+                               0);
+       gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               ws_gui_app->ws_gui_toobar_button_back,
+                               -1);
+       gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               ws_gui_app->ws_gui_toobar_button_forward,
+                               -1);
+       gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               space,
+                               -1);
+       gtk_toolbar_insert(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               ws_gui_app->ws_gui_toobar_button_stop,
+                               -1);
+       
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar), 
+                       "search",
+                       G_CALLBACK(ws_gui_search),
+                       ws_gui_app);
+       
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_hide), 
+                       "toggled",
+                       G_CALLBACK(ws_gui_words_list_hide),
+                       ws_gui_app);
+       
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_back), 
+                       "clicked",
+                       G_CALLBACK(ws_gui_history_back),
+                       ws_gui_app);
+       
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_forward), 
+                       "clicked",
+                       G_CALLBACK(ws_gui_history_next),
+                       ws_gui_app);
+       g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_toobar_button_stop), 
+                       "clicked",
+                       G_CALLBACK(ws_gui_search_stop),
+                       ws_gui_app);
+       
+       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_back),
+                       FALSE);
+       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward),
+                       FALSE);
+       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
+                       FALSE);
+       
+       hildon_find_toolbar_highlight_entry((HildonFindToolbar*)(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                             FALSE);
+       //gtk_toolbar_set_tooltips(GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar), TRUE);
+
+       hildon_window_add_toolbar(ws_gui_app->ws_gui_hildon_window,
+                       GTK_TOOLBAR(ws_gui_app->ws_gui_hildon_find_toolbar));
+}
+
+/** this function creates application menu and its items and connect signals to 
+ * them
+ *
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_create_main_menu (gpointer user_data) 
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        ws_gui_app->ws_gui_menu->ws_gui_submenu_0 = gtk_menu_new();
+        ws_gui_app->ws_gui_menu->ws_gui_submenu_1 = gtk_menu_new();
+        ws_gui_app->ws_gui_menu->ws_gui_submenu_2 = gtk_menu_new();
+        ws_gui_app->ws_gui_menu->ws_gui_submenu_3 = gtk_menu_new();
+       ws_gui_app->ws_gui_menu->ws_gui_submenu_4 = gtk_menu_new();
+        ws_gui_app->ws_gui_menu->ws_gui_main_menu = gtk_menu_new();
+
+        ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries =
+                gtk_menu_item_new_with_label(_("ws_me_dictionaries"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks =
+                gtk_menu_item_new_with_label(_("ws_me_bookmarks"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_edit = 
+                gtk_menu_item_new_with_label(_("ws_me_edit"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_view = 
+                gtk_menu_item_new_with_label(_("ws_me_view"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_search = 
+                gtk_menu_item_new_with_label(_("ws_me_search"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_about = 
+                gtk_menu_item_new_with_label(_("ws_me_about"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_close = 
+                gtk_menu_item_new_with_label(_("ws_me_close"));
+        ws_gui_app->ws_gui_menu->ws_gui_separator = 
+                gtk_separator_menu_item_new();
+        ws_gui_app->ws_gui_menu->ws_gui_separator1 = 
+                gtk_separator_menu_item_new();
+
+        ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict = 
+                gtk_menu_item_new_with_label(_("ws_me_dictionaries_load"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict = 
+                gtk_menu_item_new_with_label(_("ws_me_dictionaries_select"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict = 
+                gtk_menu_item_new_with_label(_("ws_me_dictionaries_remove"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_optimize_dict = 
+                gtk_menu_item_new_with_label(_("ws_me_dictionaries_optimize"));
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_0,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_optimize_dict);
+
+       ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark = 
+                gtk_menu_item_new_with_label(_("ws_me_bookmarks_open"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_close_bookmark = 
+                gtk_menu_item_new_with_label(_("ws_me_bookmarks_close"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark = 
+                gtk_menu_item_new_with_label(_("ws_me_bookmarks_add"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark = 
+                gtk_menu_item_new_with_label(_("ws_me_bookmarks_remove"));
+
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_4,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_4,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_close_bookmark);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_4,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_4,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark);
+
+       ws_gui_app->ws_gui_menu->ws_gui_menu_copy = 
+               gtk_menu_item_new_with_label(_("ws_me_edit_copy"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_paste = 
+               gtk_menu_item_new_with_label(_("ws_me_edit_paste"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_select_all = 
+               gtk_menu_item_new_with_label(_("ws_me_edit_select_all"));
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_copy);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_paste);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_1,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_select_all);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list = 
+           gtk_check_menu_item_new_with_label(_("ws_me_view_hide_words_list"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in = 
+               gtk_menu_item_new_with_label(_("ws_me_view_zoom_in"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out = 
+               gtk_menu_item_new_with_label(_("ws_me_view_zoom_out"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen = 
+               gtk_check_menu_item_new_with_label(_("ws_me_view_fullscreen"));
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out);
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_2,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_menu_find_word = 
+               gtk_menu_item_new_with_label(_("ws_me_search_find"));
+       ws_gui_app->ws_gui_menu->ws_gui_menu_find_next = 
+               gtk_menu_item_new_with_label(_("ws_me_search_find_next"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev = 
+               gtk_menu_item_new_with_label(_("ws_me_search_find_prev"));
+        ws_gui_app->ws_gui_menu->ws_gui_menu_stop = 
+               gtk_menu_item_new_with_label(_("ws_me_search_stop"));
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_find_word);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_find_next);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_submenu_3,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_stop);
+
+
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries);
+        gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                            (ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries),
+                             ws_gui_app->ws_gui_menu->ws_gui_submenu_0);
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks);
+        gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                            (ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                             ws_gui_app->ws_gui_menu->ws_gui_submenu_4);
+
+       gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                       ws_gui_app->ws_gui_menu->ws_gui_separator1);
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                       ws_gui_app->ws_gui_menu->ws_gui_menu_edit);
+        gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                                 (ws_gui_app->ws_gui_menu->ws_gui_menu_edit), 
+                                 ws_gui_app->ws_gui_menu->ws_gui_submenu_1);
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_view);
+        gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                                  (ws_gui_app->ws_gui_menu->ws_gui_menu_view), 
+                                  ws_gui_app->ws_gui_menu->ws_gui_submenu_2);
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_search);
+        gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                                  (ws_gui_app->ws_gui_menu->ws_gui_menu_search), 
+                                  ws_gui_app->ws_gui_menu->ws_gui_submenu_3);
+
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                        ws_gui_app->ws_gui_menu->ws_gui_separator);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_about);
+        gtk_menu_append(ws_gui_app->ws_gui_menu->ws_gui_main_menu,
+                        ws_gui_app->ws_gui_menu->ws_gui_menu_close);
+
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_load_dict),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_loader),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT(
+                         ws_gui_app->ws_gui_menu->ws_gui_menu_select_dict),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_chooser),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_remove_dict),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_remover),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_optimize_dict),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_optimizer), ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_open_bookmark), 
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_close_bookmark),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_close_bookmark), 
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_add_bookmark), 
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_remove_bookmark),
+                         "activate",
+                         G_CALLBACK(ws_gui_dictionary_remove_bookmark), 
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_copy),
+                         "activate", 
+                         GTK_SIGNAL_FUNC(ws_gui_html_copy),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_paste),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_html_paste),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_select_all),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_html_select_all),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                        (ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_words_list_hide_from_menu),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_in),
+                         "activate",
+                         G_CALLBACK(ws_gui_html_zoom_in),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_zoom_out),
+                         "activate",
+                         G_CALLBACK(ws_gui_html_zoom_out),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_full_screen),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_find_word),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_search),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_history_next),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_history_back),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_stop),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_search_stop),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_about), 
+                         "activate",
+                         G_CALLBACK(ws_gui_about_application),
+                         ws_gui_app);
+        g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_close),
+                         "activate", 
+                         G_CALLBACK(ws_gui_menu_quit),
+                         ws_gui_app);
+
+       g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_edit),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_check_clipboard),
+                         ws_gui_app);
+
+       g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_dict_availablity),
+                         ws_gui_app);
+       g_signal_connect(G_OBJECT
+                         (ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                         "activate",
+                         GTK_SIGNAL_FUNC(ws_gui_set_bookmark_menu_items),
+                         ws_gui_app);
+
+        hildon_window_set_menu(HILDON_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                               GTK_MENU(
+                                    ws_gui_app->ws_gui_menu->ws_gui_main_menu));
+
+        gtk_widget_set_sensitive(GTK_WIDGET
+                                 (ws_gui_app->ws_gui_menu->ws_gui_menu_stop),
+                                 FALSE);
+        gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
+                               FALSE);
+        gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev),
+                               FALSE);
+
+       
+       
+        gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_main_menu);
+}
+
+
+/** this function creates contex popup menu and its items and connect signals to 
+ * them
+ *
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_create_popup_menu (gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_menu = gtk_menu_new();
+       ws_gui_app->ws_gui_menu->ws_gui_popup_submenu = gtk_menu_new();
+       ws_gui_app->ws_gui_menu->ws_gui_separator = 
+                                               gtk_separator_menu_item_new();
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_search = 
+               gtk_menu_item_new_with_label(_("ws_mp_search"));
+       gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_search);
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       gtk_separator_menu_item_new());
+       ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark = 
+               gtk_menu_item_new_with_label(_("ws_mp_add_bookmark"));
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_copy = 
+               gtk_menu_item_new_with_label(_("ws_mp_edit_copy"));
+       gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_copy);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_paste = 
+               gtk_menu_item_new_with_label(_("ws_mp_edit_paste"));
+       gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_paste);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_select_all = 
+               gtk_menu_item_new_with_label(_("ws_mp_edit_select_all"));
+       gtk_menu_append((ws_gui_app->ws_gui_menu->ws_gui_popup_submenu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_select_all);
+       
+       gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_popup_submenu);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_edit = 
+                       gtk_menu_item_new_with_label (_("ws_mp_edit"));
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_edit);
+       
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_separator);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in = 
+               gtk_menu_item_new_with_label (_("ws_mp_zoom_in"));
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in);
+       
+       ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out =
+               gtk_menu_item_new_with_label (_("ws_mp_zoom_out"));
+       gtk_menu_append ((ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out);
+       
+       gtk_menu_item_set_submenu(GTK_MENU_ITEM
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_edit),
+                               ws_gui_app->ws_gui_menu->ws_gui_popup_submenu);
+
+       struct _GtkHTML *tmp = (struct _GtkHTML *)(ws_gui_app->ws_gui_html);
+
+       if (html_engine_is_selection_active(tmp->engine) == TRUE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_search),
+                               TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_copy),
+                               TRUE);
+       }
+       else 
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_search),
+                               FALSE);
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_copy),
+                               FALSE);
+       }
+       
+       if (ws_gui_app->html_flag == FALSE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_select_all),
+                               FALSE);
+       }
+       else
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_select_all),
+                               TRUE);
+       }       
+       
+       gtk_widget_show_all(ws_gui_app->ws_gui_menu->ws_gui_popup_menu);
+       
+       
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_search),
+                       "activate",
+                       G_CALLBACK(ws_gui_popup_search),
+                       ws_gui_app);
+       
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       "activate",
+                       G_CALLBACK(ws_gui_dictionary_add_bookmark),
+                       ws_gui_app);
+       
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_copy),
+                       "activate", 
+                       G_CALLBACK(ws_gui_html_copy),
+                       ws_gui_app);
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_paste),
+                       "activate",
+                       G_CALLBACK(ws_gui_html_paste),
+                       ws_gui_app);
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_select_all),
+                       "activate",
+                       G_CALLBACK(ws_gui_html_select_all),
+                       ws_gui_app);
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_in),
+                       "activate",
+                       G_CALLBACK(ws_gui_html_zoom_in), ws_gui_app);
+       g_signal_connect(G_OBJECT
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_zoom_out),
+                       "activate",
+                       G_CALLBACK(ws_gui_html_zoom_out),
+                       ws_gui_app);
+       
+       if (gtk_clipboard_wait_for_text(ws_gui_app->ws_gui_clipboard) != NULL)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_paste),
+                               TRUE);
+       }
+       else
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_popup_paste),
+                               FALSE);
+       }
+       
+       
+       if (ws_gui_app->bookmark_avail == FALSE)
+       {
+       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       FALSE);
+       }
+       
+       else
+       {
+       if (ws_gui_app->bookmark_mode == TRUE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       FALSE);
+       }
+       else
+       {
+               g_strstrip(ws_gui_app->last_word);
+               //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nlast_word: %s\n\n", ws_gui_app->last_word);
+               
+               if (ws_gui_app->last_word == NULL || 
+                   (ws_gui_app->last_word[0] == '\0'))
+               {
+                       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       FALSE);
+               }
+               else
+               {
+                       gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_popup_bookmark),
+                       TRUE);
+               }
+       }
+       }
+       gtk_menu_popup(GTK_MENU(ws_gui_app->ws_gui_menu->ws_gui_popup_menu),
+                       NULL,
+                       NULL,
+                       NULL,
+                       ws_gui_app,
+                       0,
+                       0);
+}
+
+/** this function creates dialog popup window and allows to select dictionaries
+ *  which user wants to use
+ *
+ * @param menuitem - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_dictionary_chooser(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+        GtkWidget *dialog1;
+        GtkWidget *dialog_vbox1;
+        GtkWidget *scrolledwindow1;
+        GtkWidget *viewport1;
+        GtkWidget *vbox1;
+
+        GtkWidget *checkbutton;
+        GtkWidget *cancel_button;
+        GtkWidget *ok_button;
+        guint i =0;
+        gchar* string;
+        gchar* path;
+        const gchar* name;
+        GArray *checkboxes;
+
+        checkboxes = g_array_new (TRUE, TRUE, sizeof(GtkWidget*));
+
+        if (gconf_client_dir_exists(ws_gui_app->client, 
+                                   GCONF_PATH, NULL) == TRUE)
+        {
+               ws_gui_app->directories = 
+                       gconf_client_all_dirs(ws_gui_app->client,
+                                             GCONF_PATH,
+                                             NULL);
+        }
+        else 
+        {
+               g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
+                  "\n.::GUI::. /apps/WhiteStork/Dictionaries does not exist!!");
+        }
+
+        dialog1 = gtk_dialog_new ();
+        gtk_window_set_title (GTK_WINDOW (dialog1), 
+                            (_("ws_ti_choose_dictionaries_title")));
+        gtk_window_set_type_hint (GTK_WINDOW (dialog1),
+                                  GDK_WINDOW_TYPE_HINT_DIALOG);
+        gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
+
+        dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+        gtk_widget_show (dialog_vbox1);
+
+        scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_show (scrolledwindow1);
+        gtk_box_pack_start (GTK_BOX (dialog_vbox1),
+                            scrolledwindow1,
+                            TRUE,
+                            TRUE,
+                            0);
+
+        viewport1 = gtk_viewport_new (NULL, NULL);
+        gtk_widget_show (viewport1);
+        gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
+
+        vbox1 = gtk_vbox_new (FALSE, 0);
+        gtk_widget_show (vbox1);
+        gtk_container_add (GTK_CONTAINER (viewport1), vbox1);
+
+        for (i=0; i< g_slist_length(ws_gui_app->directories);i++)
+        {
+               string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i); 
+               name = g_path_get_basename(string);
+               checkbutton = gtk_check_button_new_with_label(name);
+               path = g_strconcat(string, "/active", NULL);
+
+               if (gconf_client_get_bool(ws_gui_app->client, 
+                                        path, 
+                                        NULL) == TRUE)
+               {
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+                                                    checkbutton),
+                                                    TRUE);
+               }
+               else 
+               {
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+                                                    checkbutton),
+                                                    FALSE);
+               }
+
+                       g_array_append_val(checkboxes, checkbutton);
+                       gtk_box_pack_start (GTK_BOX (vbox1), 
+                                  checkbutton, 
+                                  FALSE, 
+                                  FALSE, 
+                                  0);
+               
+               if (strcmp(name, "bookmarks") == 0)
+               {
+                       if (ws_gui_app->bookmark_avail == FALSE) 
+                       {
+                       gtk_widget_set_sensitive(GTK_WIDGET(checkbutton),
+                                                FALSE);
+                       }
+               }
+
+               gtk_widget_show (checkbutton);
+               }
+
+       cancel_button = gtk_button_new_from_stock (_("ws_db_cancel"));
+       gtk_widget_show (cancel_button);
+       gtk_dialog_add_action_widget (GTK_DIALOG (dialog1),
+                                       cancel_button,
+                                       GTK_RESPONSE_CANCEL);
+       
+       ok_button = gtk_button_new_from_stock (_("ws_db_ok"));
+       gtk_widget_show (ok_button);
+       gtk_dialog_add_action_widget(GTK_DIALOG (dialog1),
+                                       ok_button,
+                                       GTK_RESPONSE_OK);
+       
+       i = gtk_dialog_run(GTK_DIALOG(dialog1));
+       
+       if (i == GTK_RESPONSE_OK) 
+       {
+               for(i=0;i<(checkboxes->len);i++)
+               {
+                       if (gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON(g_array_index(checkboxes,
+                                               GtkWidget *, i))) == TRUE)
+                       {
+                               name = gtk_button_get_label(GTK_BUTTON(
+                               g_array_index(checkboxes, GtkWidget *, i)));
+                               
+                               path=g_strconcat(GCONF_PATH,
+                                               "/",
+                                               name,
+                                               "/active",
+                                               NULL);
+                               gconf_client_set_bool(ws_gui_app->client,
+                                                       path,
+                                                       TRUE,
+                                                       NULL);
+                       }
+       
+                       if (gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON(g_array_index(checkboxes,
+                                               GtkWidget *, i))) == FALSE)
+                       {
+                               name = gtk_button_get_label(GTK_BUTTON(
+                               g_array_index(checkboxes, GtkWidget *, i)));
+                               
+                               path=g_strconcat(GCONF_PATH,
+                                               "/",
+                                               name,
+                                               "/active",
+                                               NULL);
+                               gconf_client_set_bool(ws_gui_app->client,
+                                                       path,
+                                                       FALSE,
+                                                       NULL);
+                       }
+               }
+       
+               ws_dbus_notify(ws_gui_app->dbus_data, 
+                               WS_DBUS_INFO_CONFIG_CHANGED);
+
+               if(ws_gui_app->ws_gui_history->len >= 0)
+               {
+               ws_gui_clear_array(ws_gui_app->ws_gui_history);
+               ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+               ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+               ws_gui_app->ws_gui_history_cur_pos = -1;
+               }
+               ws_gui_check_history(ws_gui_app);
+       
+               gtk_widget_destroy (dialog1);
+       }
+       else if (i == GTK_RESPONSE_CANCEL) 
+       {
+               gtk_widget_destroy (dialog1);
+       }
+       
+       g_slist_free(ws_gui_app->directories);
+}
+
+/** this function creates dialog popup window and allows optimize dictionaries
+ *
+ * @param menuitem - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_dictionary_optimizer(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        GtkWidget *dialog1;
+        GtkWidget *dialog_vbox1;
+        GtkWidget *scrolledwindow1;
+        GtkWidget *viewport1;
+        GtkWidget *vbox1;
+
+        GtkWidget *checkbutton;
+        GtkWidget *cancel_button;
+        GtkWidget *ok_button;
+        guint i =0;
+        gchar* string;
+        gchar* path;
+        const gchar* name;
+        GArray *checkboxes;
+
+        checkboxes = g_array_new (TRUE, TRUE, sizeof(GtkWidget*));
+
+        if (gconf_client_dir_exists(ws_gui_app->client, 
+                                   GCONF_PATH, 
+                                   NULL) == TRUE)
+        {
+                ws_gui_app->directories = 
+                    gconf_client_all_dirs(ws_gui_app->client, GCONF_PATH, NULL);
+        }
+        else 
+        {
+                g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
+                  "\n.::GUI::. /apps/WhiteStork/Dictionaries does not exist!!");
+        }
+
+        for (i=0; i< g_slist_length(ws_gui_app->directories);i++)
+        {
+                string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i); 
+                name = g_path_get_basename(string);
+
+                path = g_strconcat(string, "/optimized", NULL);
+                if (gconf_client_get_bool (ws_gui_app->client,
+                                          path, 
+                                          NULL) == FALSE)
+                {
+                        checkbutton = gtk_check_button_new_with_label(name);
+                        g_array_append_val(checkboxes, checkbutton);
+                }
+        }
+        if (checkboxes->len <= 0)
+        {
+                ws_gui_app->ws_message_dialog = gtk_message_dialog_new(
+                                   GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                   _("ws_ni_no_dictionaries_to_optimize"));
+               gtk_widget_show_all(ws_gui_app->ws_message_dialog);
+               if (gtk_dialog_run (GTK_DIALOG (
+                        ws_gui_app->ws_message_dialog)) == GTK_RESPONSE_OK)
+               {
+                        gtk_widget_destroy(ws_gui_app->ws_message_dialog);
+               }
+               }
+               else
+               {
+                dialog1 = gtk_dialog_new ();
+                gtk_window_set_title(GTK_WINDOW (dialog1),
+                                     (_("ws_ti_choose_dictionaries_title")));
+                gtk_window_set_type_hint(GTK_WINDOW (dialog1),
+                                         GDK_WINDOW_TYPE_HINT_DIALOG);
+                gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
+
+                dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+                gtk_widget_show (dialog_vbox1);
+
+                scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+                gtk_widget_show (scrolledwindow1);
+                gtk_box_pack_start(GTK_BOX (dialog_vbox1),
+                                   scrolledwindow1,
+                                   TRUE,
+                                   TRUE,
+                                   0);
+
+                viewport1 = gtk_viewport_new (NULL, NULL);
+                gtk_widget_show (viewport1);
+                gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
+
+                vbox1 = gtk_vbox_new (FALSE, 0);
+                gtk_widget_show (vbox1);
+                gtk_container_add (GTK_CONTAINER (viewport1), vbox1);
+                for (i=0; i<checkboxes->len; i++)
+                {
+                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+                                      g_array_index(checkboxes, GtkWidget*, i)),
+                                      FALSE);
+                        gtk_box_pack_start(GTK_BOX (vbox1),
+                                       g_array_index(checkboxes, GtkWidget*, i),
+                                       FALSE,
+                                       FALSE,
+                                       0);
+                        gtk_widget_show(g_array_index(checkboxes, 
+                                                     GtkWidget*, 
+                                                     i));
+                }
+                cancel_button = gtk_button_new_from_stock (_("ws_db_cancel"));
+                gtk_widget_show (cancel_button);
+                gtk_dialog_add_action_widget(GTK_DIALOG (dialog1),
+                                             cancel_button,
+                                             GTK_RESPONSE_CANCEL);
+                ok_button = gtk_button_new_from_stock (_("ws_db_ok"));
+                gtk_widget_show (ok_button);
+                gtk_dialog_add_action_widget(GTK_DIALOG (dialog1),
+                                             ok_button,
+                                             GTK_RESPONSE_OK);
+                i = gtk_dialog_run(GTK_DIALOG(dialog1));
+                if (i == GTK_RESPONSE_OK) 
+                {
+                        for(i=0;i<(checkboxes->len);i++)
+                        {
+                                if (gtk_toggle_button_get_active(
+                                    GTK_TOGGLE_BUTTON(
+                                        g_array_index(checkboxes,
+                                                GtkWidget *, i))) == TRUE)
+                                {
+                                        name = gtk_button_get_label(GTK_BUTTON(
+                                                g_array_index(checkboxes,
+                                                              GtkWidget *,
+                                                              i)));
+                                        path=g_strconcat(GCONF_PATH,
+                                                         "/",
+                                                         name,
+                                                         "/optimized",
+                                                         NULL);
+                                        gconf_client_set_bool(
+                                                            ws_gui_app->client,
+                                                             path,
+                                                             TRUE,
+                                                             NULL);
+                                }
+                                if (gtk_toggle_button_get_active(
+                                     GTK_TOGGLE_BUTTON(
+                                       g_array_index(checkboxes,
+                                                     GtkWidget *, i))) == FALSE)
+                                {
+                                        name = gtk_button_get_label(GTK_BUTTON
+                                                      (g_array_index(checkboxes,
+                                                                     GtkWidget*,
+                                                                     i)));
+                                        path=g_strconcat(GCONF_PATH,
+                                                         "/",
+                                                         name,
+                                                         "/optimized",
+                                                         NULL);
+                                        gconf_client_set_bool(
+                                                            ws_gui_app->client,
+                                                             path,
+                                                             FALSE,
+                                                             NULL);
+                                }
+                        }
+                        ws_dbus_notify(ws_gui_app->dbus_data,
+                                       WS_DBUS_INFO_CONFIG_CHANGED);
+                        gtk_widget_destroy (dialog1);
+                }
+                else if (i == GTK_RESPONSE_CANCEL) 
+                {
+                        gtk_widget_destroy (dialog1);
+                }
+        }
+        g_slist_free(ws_gui_app->directories);
+}
+
+/** this function creates dialog popup window which allows to load a new
+ *dictionary file into application
+ *
+ * @param menuitem - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_dictionary_loader(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        GtkWidget *dialog;
+  //      GtkWidget *dialog2;  
+
+       dialog = hildon_file_chooser_dialog_new(
+                               GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                               GTK_FILE_CHOOSER_ACTION_OPEN);
+       gtk_window_set_default_size(GTK_WINDOW (dialog), 200, 200);
+        gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(dialog), FALSE);
+
+       //gtk_widget_show(GTK_WIDGET(dialog));
+
+        if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+        { 
+                gchar *filename;
+                gchar *name;
+             //   gchar *path;
+                gint len;
+              //  gchar *filepath;
+
+                gchar* tmp;
+               
+                filename = gtk_file_chooser_get_filename(
+                                                     GTK_FILE_CHOOSER (dialog));
+                name = g_path_get_basename(filename);
+                len = strlen(filename) - strlen(name) -1;
+                tmp = g_strndup (filename, len);
+                               
+               
+                tmp = g_path_get_basename(tmp);
+               
+                if (g_str_has_suffix(name, ".xdxf") 
+                       || g_str_has_suffix(name, ".idx") 
+                       || g_str_has_suffix(name, ".ifo")
+                       || g_str_has_suffix(name, ".idx.gz")
+                       || g_str_has_suffix(name, ".dict")
+                       || g_str_has_suffix(name, ".dict.dz"))
+                {
+                       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n:::GUUUUIII GUIII::: check");
+                       if (ws_gui_load_dict(filename, ws_gui_app) == TRUE)
+                       {
+                               gtk_widget_destroy(dialog);
+                               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ni_dictionary_added"));
+                       } 
+                }
+               else if (g_str_has_suffix(name, ".bz2"))
+               {
+                       gtk_widget_destroy(dialog);     
+                       ws_dbus_client_extract_dictionary(ws_gui_app->dbus_data, filename);
+               }
+                else
+                {
+                        gtk_widget_destroy (dialog);
+                        gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ni_dictionary_wrong_file"));
+                }
+
+               }
+               else 
+               {
+               gtk_widget_destroy (dialog);
+               }
+
+}
+
+/** this function creates dialog popup window which allows to load dictionary
+ *
+ * @param filename - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+gboolean ws_gui_load_dict(gchar *filename, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       GtkWidget *dialog1;
+       GtkWidget *dialog2;
+       gchar *name = g_path_get_basename(filename);
+       gchar *path;
+       gint len;
+       gchar *filepath;
+
+       len = strlen(filename) - strlen(name) -1;
+       gchar *tmp = g_strndup (filename, len);;
+       tmp = g_path_get_basename(tmp);
+       
+       filepath = g_strndup (filename, len);
+        path = g_strconcat(GCONF_PATH, "/", tmp, "/path", NULL);
+        gconf_client_set_string(ws_gui_app->client,
+                               path,
+                                filepath,
+                                NULL);
+       g_free(path); 
+       path = NULL;
+       path = g_strconcat(GCONF_PATH,
+                               "/",
+                                tmp,
+                                "/active",
+                                NULL);
+       
+        dialog1 = gtk_message_dialog_new(GTK_WINDOW(
+                                         ws_gui_app->ws_gui_hildon_window),
+                                         GTK_DIALOG_DESTROY_WITH_PARENT,
+                                         GTK_MESSAGE_QUESTION,
+                                         GTK_BUTTONS_YES_NO,
+                                       _("ws_ni_dictionaries_activation_question"));
+
+        gtk_widget_show_all(GTK_WIDGET(dialog1));
+
+        if (gtk_dialog_run (GTK_DIALOG (dialog1)) == GTK_RESPONSE_YES)
+        {
+               gconf_client_set_bool(ws_gui_app->client,
+                                        path,
+                                        TRUE,
+                                        NULL);
+        }
+        else 
+        {
+               gconf_client_set_bool(ws_gui_app->client,
+                                        path,
+                                        FALSE,
+                                        NULL);
+        }
+       gtk_widget_destroy (dialog1);
+       g_free(path); 
+       path = NULL;
+
+       path = g_strconcat(GCONF_PATH, "/", tmp, "/optimized", NULL);
+
+       dialog2 = gtk_message_dialog_new(
+               GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+               GTK_DIALOG_DESTROY_WITH_PARENT,
+               GTK_MESSAGE_QUESTION,
+               GTK_BUTTONS_YES_NO,
+               _("ws_ni_dictionaries_optimalization_question"));
+
+       gtk_widget_show_all(GTK_WIDGET(dialog2));
+
+       if (gtk_dialog_run (GTK_DIALOG (dialog2)) == GTK_RESPONSE_YES)
+       {
+               gconf_client_set_bool(ws_gui_app->client,
+                                       path,
+                                       TRUE,
+                                       NULL);
+       }
+       else 
+       {
+               gconf_client_set_bool(ws_gui_app->client,
+                                       path,
+                                       FALSE,
+                                       NULL);
+       }
+       gtk_widget_destroy (dialog2);
+
+       if(ws_gui_app->ws_gui_history->len > 0)
+       {
+               ws_gui_clear_array(ws_gui_app->ws_gui_history);
+               ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+               ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+               ws_gui_app->ws_gui_history_cur_pos = -1;
+       }
+       ws_gui_check_history(ws_gui_app);
+
+       ws_dbus_notify(ws_gui_app->dbus_data,
+                               WS_DBUS_INFO_CONFIG_CHANGED);
+       
+       return TRUE;
+}
+
+/** this function creates dialog popup window which allows to remove dictionary
+ *  which is no longer used
+ *
+ * @param menuitem - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_dictionary_remover(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        GtkWidget *dialog1;
+        GtkWidget *dialog_vbox1;
+        GtkWidget *scrolledwindow1;
+       GtkWidget *viewport1;
+        GtkWidget *vbox1;
+        GtkWidget *checkbutton;
+        GtkWidget *cancel_button;
+        GtkWidget *ok_button;
+        guint i =0;
+        gchar* string;
+        gchar* path;
+        const gchar* name;
+        GArray *checkboxes;
+
+        checkboxes = g_array_new (TRUE, TRUE, sizeof(GtkWidget*));
+
+        if (gconf_client_dir_exists(ws_gui_app->client, GCONF_PATH, NULL) 
+                                                                       == TRUE)
+        {
+                ws_gui_app->directories = gconf_client_all_dirs(
+                                                             ws_gui_app->client,
+                                                             GCONF_PATH,
+                                                             NULL);
+        }
+        else 
+        {
+                g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
+                  "\n.::GUI::. /apps/WhiteStork/Dictionaries does not exist!!");
+        }
+
+        dialog1 = gtk_dialog_new ();
+        gtk_window_set_title (GTK_WINDOW (dialog1), 
+                            (_("ws_ti_remove_dictionaries_title")));
+        gtk_window_set_type_hint (GTK_WINDOW (dialog1),
+                                  GDK_WINDOW_TYPE_HINT_DIALOG);
+        gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
+
+        dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+        gtk_widget_show (dialog_vbox1);
+
+        scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_show (scrolledwindow1);
+        gtk_box_pack_start (GTK_BOX (dialog_vbox1),
+                            scrolledwindow1,
+                            TRUE,
+                            TRUE,
+                            0);
+
+        viewport1 = gtk_viewport_new (NULL, NULL);
+        gtk_widget_show (viewport1);
+        gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1);
+
+        vbox1 = gtk_vbox_new (FALSE, 0);
+        gtk_widget_show (vbox1);
+        gtk_container_add (GTK_CONTAINER (viewport1), vbox1);
+
+        for (i=0; i< g_slist_length(ws_gui_app->directories);i++)
+        {
+                string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i); 
+                name = g_path_get_basename(string);
+                checkbutton = gtk_check_button_new_with_label(name);
+
+                g_array_append_val(checkboxes, checkbutton);
+                gtk_box_pack_start (GTK_BOX (vbox1),
+                                    checkbutton,
+                                    FALSE,
+                                    FALSE,
+                                    0);
+               
+               if (strcmp(name, "bookmarks") == 0)
+               {
+                  gtk_widget_set_sensitive(GTK_WIDGET(checkbutton), FALSE);
+               }
+                gtk_widget_show (checkbutton);
+        }
+
+        cancel_button = gtk_button_new_from_stock (_("ws_db_cancel"));
+        gtk_widget_show (cancel_button);
+        gtk_dialog_add_action_widget (GTK_DIALOG (dialog1),
+                                      cancel_button,
+                                      GTK_RESPONSE_CANCEL);
+
+        ok_button = gtk_button_new_from_stock 
+                              (_("ws_bd_remove_dictionaries_remove_selected"));
+        gtk_widget_show (ok_button);
+        gtk_dialog_add_action_widget(GTK_DIALOG (dialog1),
+                                     ok_button,
+                                     GTK_RESPONSE_OK);
+
+        i = gtk_dialog_run(GTK_DIALOG(dialog1));
+
+        if (i == GTK_RESPONSE_OK) 
+        {
+                for(i=0;i<(checkboxes->len);i++)
+                {
+                        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+                            g_array_index(checkboxes, GtkWidget *, i))) == TRUE)
+                        {
+
+                                name = gtk_button_get_label(GTK_BUTTON(
+                                    g_array_index(checkboxes, GtkWidget *, i)));
+                                path=g_strconcat(GCONF_PATH, "/", name, NULL);
+                                gconf_client_recursive_unset(ws_gui_app->client,
+                                             path,
+                                             GCONF_UNSET_INCLUDING_SCHEMA_NAMES,
+                                             NULL);
+                        } 
+                 }
+
+               if(ws_gui_app->ws_gui_history->len >= 0)
+               {
+                       ws_gui_clear_array(ws_gui_app->ws_gui_history);
+                       ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+                       ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+                       ws_gui_app->ws_gui_history_cur_pos = -1;
+               }
+               ws_gui_check_history(ws_gui_app);               
+
+                ws_dbus_notify(ws_gui_app->dbus_data, 
+                              WS_DBUS_INFO_CONFIG_CHANGED);
+               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ib_dictionary_removed"));
+                gtk_widget_destroy (dialog1);
+        }
+        else if (i == GTK_RESPONSE_CANCEL) 
+        {
+                gtk_widget_destroy (dialog1);
+        }
+
+        g_slist_free(ws_gui_app->directories);
+}
+
+/** this function creates dialog popup window which displays information about
+ * application (about window)
+ *
+ * @param menuitem - the object which received the signal
+ * @param user_data - set when the signal handler was connected
+ */
+void ws_gui_about_application(GtkMenuItem *menuitem, gpointer user_data)
+{
+        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        gtk_widget_set_sensitive(GTK_WIDGET
+                                 (ws_gui_app->ws_gui_hildon_find_toolbar),
+                                 FALSE);
+
+        GtkWidget *about_dialog;
+        GtkWidget *dialog_vbox1;
+        GtkWidget *vbox1;
+        GtkWidget *image;
+        GtkWidget *label2;
+        GtkWidget *label3;
+        GtkWidget *label4;
+        GtkWidget *scrolledwindow;
+        GtkWidget *textview;
+        GtkWidget *button1;
+
+       const gchar *ws_version;
+
+        about_dialog = gtk_dialog_new ();
+        gtk_window_set_title (GTK_WINDOW (about_dialog), 
+                             _("ws_ti_about_title"));
+        gtk_window_set_default_size(GTK_WINDOW (about_dialog), 350, 200);
+
+        dialog_vbox1 = GTK_DIALOG (about_dialog)->vbox;
+        gtk_widget_show (dialog_vbox1);
+
+        vbox1 = gtk_vbox_new (FALSE, 0);
+        gtk_widget_show (vbox1);
+        gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
+
+        image = gtk_image_new_from_file ("/usr/share/pixmaps/whitestork.png");
+        gtk_box_pack_start (GTK_BOX (vbox1), image, TRUE, TRUE, 0);
+
+        label2 = gtk_label_new ("WhiteStork");
+        ws_gui_app->p = pango_font_description_from_string("Tahoma 18");
+        gtk_widget_modify_font(GTK_WIDGET(label2), ws_gui_app->p);
+        gtk_label_set_pattern (GTK_LABEL(label2), "__________");
+        gtk_box_pack_start (GTK_BOX (vbox1), label2, FALSE, FALSE, 5);
+
+       ws_version = g_strconcat("Maemo Multilingual Dictionary\nver. ",
+                               WS_VERSION, 
+                               NULL);
+        label3 = gtk_label_new_with_mnemonic (_(ws_version));
+        ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
+        gtk_widget_modify_font(GTK_WIDGET(label3), ws_gui_app->p);
+        gtk_box_pack_start (GTK_BOX (vbox1), label3, FALSE, FALSE, 5);
+        gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_CENTER);
+
+        label4 = gtk_label_new ("Copyright 2006, ComArch S.A\nAll rights " 
+                               "reserved");
+        ws_gui_app->p = pango_font_description_from_string("Tahoma 12");
+        gtk_widget_modify_font(GTK_WIDGET(label4), ws_gui_app->p);
+        gtk_box_pack_start (GTK_BOX (vbox1), label4, FALSE, FALSE, 5);
+        gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_CENTER);
+
+        scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
+                                             (scrolledwindow),
+                                             GTK_SHADOW_ETCHED_OUT);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
+                                        (scrolledwindow),
+                                        GTK_POLICY_AUTOMATIC,
+                                        GTK_POLICY_AUTOMATIC);
+        gtk_box_pack_start (GTK_BOX (vbox1),
+                            scrolledwindow,
+                            TRUE,
+                            TRUE,
+                            0);
+
+        textview = gtk_text_view_new ();
+        ws_gui_app->p = pango_font_description_from_string("Tahoma 10");
+        gtk_widget_modify_font(GTK_WIDGET(textview), ws_gui_app->p);
+        gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
+        gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textview), 10);
+        gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textview), 10);
+        gtk_container_add (GTK_CONTAINER (scrolledwindow), textview);
+        gtk_text_buffer_set_text(
+                        gtk_text_view_get_buffer(GTK_TEXT_VIEW (textview)),
+                        "The following third party\ncomponents may be\nincluded"
+                       " depending \non your system configuration:\n\nD-BUS "
+                       "- License information:\nhttp://opensource.org/"
+                       "licenses/academic.php",
+                        -1);
+
+        button1 = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+        gtk_dialog_add_action_widget(GTK_DIALOG(about_dialog),
+                                     button1,
+                                     GTK_RESPONSE_CLOSE);
+
+        gtk_widget_show_all (GTK_WIDGET(about_dialog));
+
+        if (gtk_dialog_run(GTK_DIALOG(about_dialog)) == GTK_RESPONSE_CLOSE)
+        {
+                gtk_widget_destroy(GTK_WIDGET(about_dialog));
+        }
+
+        gtk_widget_set_sensitive(
+                             GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                             TRUE);
+}
+
+void ws_gui_add_bookmark_dialog(gpointer user_data)
+{
+
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       GtkWidget *dialog1;
+       GtkWidget *dialog_vbox1;
+       GtkWidget *vbox1;
+       GtkWidget *hbox1;
+       GtkWidget *entry1;
+       GtkWidget *label;
+       GtkWidget *cancelbutton1;
+       GtkWidget *okbutton1;
+       
+       const gchar *book_word;
+       
+       dialog1 = gtk_dialog_new ();
+       gtk_window_set_title (GTK_WINDOW (dialog1), _("ws_ti_add_bookmark"));
+       gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
+       
+       dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+       gtk_widget_show (dialog_vbox1);
+       
+       vbox1 = gtk_vbox_new (FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 5);
+       
+       hbox1 = gtk_hbox_new (FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 5);
+       
+       label = gtk_label_new(_("ws_ti_bookmarks_add_question"));
+       gtk_box_pack_start (GTK_BOX (hbox1), label, TRUE, TRUE, 5);
+       
+       entry1 = gtk_entry_new ();
+       gtk_box_pack_start (GTK_BOX (vbox1), entry1, TRUE, TRUE, 5);
+       gtk_entry_set_text(GTK_ENTRY(entry1), ws_gui_app->last_word);
+       gtk_entry_set_alignment (GTK_ENTRY(entry1), 0.5);
+       gtk_entry_set_editable(GTK_ENTRY(entry1), TRUE);
+       
+       cancelbutton1 = gtk_button_new_from_stock (_("ws_db_ok"));
+       gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), 
+                                     cancelbutton1, 
+                                     GTK_RESPONSE_OK);
+       
+       okbutton1 = gtk_button_new_from_stock (_("ws_db_cancel"));
+       gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), 
+                                     okbutton1, 
+                                     GTK_RESPONSE_CANCEL);
+       
+       gtk_widget_show_all (dialog1);
+       
+       if (gtk_dialog_run(GTK_DIALOG(dialog1)) == GTK_RESPONSE_OK)
+       {
+               book_word = gtk_entry_get_text(GTK_ENTRY(entry1));
+               ws_dbus_client_add_bookmark(ws_gui_app->dbus_data, 
+                                    (gchar*)book_word, 
+                                    ws_gui_app->raw_translation->str);
+               gtk_widget_destroy(GTK_WIDGET(dialog1));
+               
+       }
+       else 
+       {
+               gtk_widget_destroy(GTK_WIDGET(dialog1));
+       }
+}
+
+void ws_gui_remove_bookmark_dialog(gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       GtkWidget *dialog1;
+       GtkWidget *dialog_vbox1;
+       GtkWidget *vbox1;
+       GtkWidget *hbox1;
+       GtkWidget *entry1;
+       GtkWidget *label;
+       GtkWidget *cancelbutton1;
+       GtkWidget *okbutton1;
+       
+       dialog1 = gtk_dialog_new ();
+       gtk_window_set_title (GTK_WINDOW (dialog1), _("ws_ti_remove_bookmark"));
+       gtk_window_set_default_size(GTK_WINDOW (dialog1), 300, 200);
+       
+       dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+       gtk_widget_show (dialog_vbox1);
+       
+       vbox1 = gtk_vbox_new (FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 5);
+       
+       hbox1 = gtk_hbox_new (FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 5);
+       
+       label = gtk_label_new(_("ws_ni_remove_bookmark_question"));
+       gtk_box_pack_start (GTK_BOX (hbox1), label, TRUE, TRUE, 5);
+       
+       entry1 = gtk_entry_new ();
+       gtk_box_pack_start (GTK_BOX (vbox1), entry1, TRUE, TRUE, 5);
+       gtk_entry_set_text(GTK_ENTRY(entry1), ws_gui_app->last_word);
+       gtk_entry_set_alignment (GTK_ENTRY(entry1), 0.5);
+       gtk_entry_set_editable(GTK_ENTRY(entry1), FALSE);
+       
+       cancelbutton1 = gtk_button_new_from_stock (_("ws_db_ok"));
+       gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), 
+                                     cancelbutton1, 
+                                     GTK_RESPONSE_OK);
+       
+       okbutton1 = gtk_button_new_from_stock (_("ws_db_cancel"));
+       gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), 
+                                     okbutton1, 
+                                     GTK_RESPONSE_CANCEL);
+       
+       gtk_widget_show_all (dialog1);
+       
+       if (gtk_dialog_run(GTK_DIALOG(dialog1)) == GTK_RESPONSE_OK)
+       {
+               gtk_widget_destroy(GTK_WIDGET(dialog1));
+               gchar* tmp;
+               
+               ws_dbus_client_remove_bookmark(ws_gui_app->dbus_data, 
+                                       ws_gui_app->last_word);
+
+               ws_gui_fill_html(" ", ws_gui_app);
+
+               g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               "prefix",
+                               &tmp,
+                               NULL);
+               
+               if (strlen(tmp) != 0)
+               {
+                       ws_dbus_client_find_word (ws_gui_app->dbus_data, tmp);
+               }
+               else 
+               {       
+                       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "strlen(tmp)=0");
+                       gtk_list_store_clear(
+                                      ws_gui_app->ws_gui_w_list->ws_gui_store);
+               }
+       }
+       else 
+       {
+               gtk_widget_destroy(GTK_WIDGET(dialog1));
+       }
+}
+
+void ws_gui_list_full_dialog(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
+       
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       ws_gui_app->ws_message_dialog =  gtk_message_dialog_new(
+                                 GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                  GTK_MESSAGE_INFO,
+                                  GTK_BUTTONS_OK,
+                                  _("ws_ni_words_list_full"));
+
+            if (gtk_dialog_run(
+                               GTK_DIALOG(ws_gui_app->ws_message_dialog)) 
+                                 == GTK_RESPONSE_OK)
+                       {
+                               gtk_widget_destroy(
+                                                ws_gui_app->ws_message_dialog);
+                       }
+}
diff --git a/src/manager/COPYING b/src/manager/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/manager/Makefile b/src/manager/Makefile
new file mode 100644 (file)
index 0000000..409f679
--- /dev/null
@@ -0,0 +1,36 @@
+CC = gcc
+DEBUG = -g -Wall
+INCLUDE = ./include
+SOURCE  = ./src
+BINARY  = ./bin
+INCLUDE_DBUS_WRAPPER = ../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0 libosso gconf-2.0 gthread-2.0` \
+       -lbz2
+SQLITE=-DSQLITE=0
+CFLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0 libosso gconf-2.0` \
+       -I${INCLUDE} -I${INCLUDE_DBUS_WRAPPER} ${SQLITE}
+MAIN_BINARIES = ../../bin
+EXECUTABLE = ${BINARY}/WhiteStorkManager
+
+
+SOURCES = ${SOURCE}/*.c
+OBJECTS = $(patsubst %.c,%.o,$(wildcard ${SOURCES})) ${MAIN_BINARIES}/ws_dbus.o
+
+${EXECUTABLE}: ${OBJECTS}
+               @echo Compiling with ${SQLITE} flag
+               ${CC} ${DEBUG} -o $@ ${OBJECTS} ${LIBS} ${CFLAGS}
+               @cp ${EXECUTABLE} ${MAIN_BINARIES}
+
+%.o: %.c
+               ${CC} -c -o $@ $< ${DEBUG} ${CFLAGS}
+
+${MAIN_BINARIES}/ws_dbus.o:
+               @cd ../dbus_wrapper && make
+
+.PHONY: clean
+clean:
+               rm -f ${SOURCE}/*.o ${EXECUTABLE} ${SOURCE}/*~ ./*~ 
+               rm -f ${INCLUDE}/*~
+.PHONY: run
+run:
+               run-standalone.sh ./${EXECUTABLE} &
diff --git a/src/manager/commit b/src/manager/commit
new file mode 100644 (file)
index 0000000..11a1e47
--- /dev/null
@@ -0,0 +1,2 @@
+ * spliting manager code into separate files
+ * adjust Makefile to new code structure (flexible)
diff --git a/src/manager/include/pc-instances.h b/src/manager/include/pc-instances.h
new file mode 100644 (file)
index 0000000..5cf6b7d
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _PC_INSTANCES_H_
+#define _PC_INSTANCES_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// stadards headers
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+// headers with unix types/functions - only for timers and files operations
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+//------------------------------------------------------------------------------
+/** \brief Get comandline by which process in /proc tree was invoked.
+ *
+ * @param process describes which process from /proc tree we want to check. It
+ * should be only concrete directory from /proc nothing else. e.g.: /proc/self,
+ * /proc/8321 etc. Something like /proc or /proc/self is not good.
+ * @return string containing comandline which has invoked process. If NULL there
+ * were some problems, possibly parameter were wrong or ther is no such
+ * a process.
+ */
+char* get_process_cmdline(char* process);
+
+//------------------------------------------------------------------------------
+/** \brief Cut from commandline only program file name.
+ *
+ * @param cmdline commandline which from which we want to remove options.
+ * @return string with only program file name, or NULL if there was any problem
+ */
+char* get_process_program_file(char* cmdline);
+
+//------------------------------------------------------------------------------
+/** \brief Get file name containing programm executing by current process.
+ *
+ * @return file name of program or NULL if there were some problems.
+ */
+char* get_current_process_program_file();
+
+//------------------------------------------------------------------------------
+/** \brief Check if there is another instance of current programm.
+ *
+ * @return integer telling how many processes were initiated with the same
+ * program as curent process. If it is 1, it means there is no other procces.
+ * If > 1 there is another instance.
+ */
+int is_already_running_this_application();
+
+
+
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+#endif /* _PC_INSTANCES_H_ */
diff --git a/src/manager/include/untar.h b/src/manager/include/untar.h
new file mode 100644 (file)
index 0000000..1eb8113
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _WS_UNTAR
+#define _WS_UNTAR
+
+#include <glib.h>
+/*
+Usage example:
+
+decompress_file ("comn_dictd04_wn.tar.bz2", "./"); 
+
+The above example extracts a given archive, to the current directory
+*/
+
+gint decompress_file(gchar *in_file, gchar **out_path);
+
+
+#endif /*_WS_UNTAR*/
diff --git a/src/manager/include/ws_manager.h b/src/manager/include/ws_manager.h
new file mode 100644 (file)
index 0000000..db3b90c
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER
+#define _WS_MANAGER
+
+#include <dictionary_engine.h>
+#include <glib-object.h>
+#include <gmodule.h>
+#include <ws_dbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if SQLITE==0
+       #define LIBRARY "/usr/lib/libsqlite.so.0"
+#elif SQLITE==3
+       #define LIBRARY "/usr/lib/libsqlite3.so.0"
+#endif
+
+#define g_strlen(string) ( NULL == (string) ? 0 : strlen(string) )
+
+
+struct _WSMngSearchData;
+typedef struct _WSMngSearchData WSMngSearchData;
+
+/**
+ * Creates new instance of WSMngSearchData structure
+ *@return new instance of WSMngSearchData structure
+ */
+WSMngSearchData* ws_manager_create();
+
+/** 
+* \brief Function used to initialize D-BUS
+*
+*@param data structure stores variables which are need to comunicate by D-BUS.
+*/
+void ws_mng_init_dbus (WSMngSearchData *data);
+
+/**
+* \brief Function used to initialize manager
+*
+* Fuction loads from modules pointers to functions used to service searching 
+in dictionaries and stores them in WSMngSearchData structure
+*@param data pointer to structure WSMngSearchData which stores variables needed 
+to service manager
+*/
+void ws_mng_init (WSMngSearchData *data);
+
+/**
+* \brief Function used to close dictionaries and modules
+*
+* @param data structure holds pointers to data which need to be freed 
+from memory
+*/
+void ws_mng_close (WSMngSearchData *data);
+
+/**
+ * Function used to run and initialize main loop.
+ *@param serach_data structure which contains all data of program
+ *@return TRUE if successfully run main loop, FALSE otherwise 
+ */
+gboolean ws_mng_start_main_loop(WSMngSearchData* serach_data);
+
+struct _WSMngSearchData
+{
+        GArray* dict; ///< pointer to GArray structure which stores pointers to fuction used to service dictionaries 
+        GArray* modules; ///< pointer to GArray structure which stores pointers to fuction used to service modules loading
+        gchar* word; ///< word which will be used to search a dictionaries
+        pthread_t p_thread; ///< a thread in which we serching word list
+       pthread_t p_thread_trans; ///< a thread in which are searching for translation of word
+        WSDBusData* dbus_data; ///< a pointer DBUS data
+        GMainLoop* loop; ///< pointer to main loop
+        //GModule* library; ///< library used to load modules
+        GArray* word_list; ///< searched word list
+        gchar* trans; ///< searched translation
+        gchar* last_search; ///< last searched word
+        gboolean search_in_history; ///< flag signalig when search in hisory is commieted
+        GArray* libraries; ///<tabele used for storing modules libraries
+       Engine* bookmark; ///<bookmark engine
+       /* added by Dariusz Wiechecki
+        * we are moving to GLib threads */
+       GStaticMutex* action_working;
+       GStaticMutex* thread_creation;
+
+       GStaticRecMutex* action_stop;
+
+       GArray* library_path;///<path to library
+       gboolean bookmark_mode;
+       GModule* bookmark_library;
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/manager/include/ws_mng_bookmarks_utils.h b/src/manager/include/ws_mng_bookmarks_utils.h
new file mode 100644 (file)
index 0000000..8211dd8
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_BOOKMARKS
+#define _WS_MANAGER_BOOKMARKS
+
+#include <ws_mng_searching_threads.h>
+#include <ws_mng_gconf_utils.h>
+#include <dictionary_engine.h>
+#include <ws_mng_callbacks.h>
+#include <ws_manager.h>
+
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+/**
+ * Function used to add bookmarks
+ * @param error error messages
+ * @param param word and translation of word to adding
+ * @param user_data structure holding nedded parameters
+ */
+void ws_mng_add_bookmark(GError *error, GArray* param, gpointer user_data);
+
+/**
+ * Function used to remove bookmarks
+ * @param error error messages
+ * @param param word and translation of word to remove
+ * @param user_data structure holding nedded parameters
+ */
+void ws_mng_remove_bookmark(GError *error, GArray* param, gpointer user_data);
+
+/**
+ * Function used to load bookmark module 
+ * @param data structure which holds the loaded module
+ */
+void ws_mng_load_bookmark(WSMngSearchData* data);
+
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/include/ws_mng_callbacks.h b/src/manager/include/ws_mng_callbacks.h
new file mode 100644 (file)
index 0000000..1cf467a
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_CALLBACKS
+#define _WS_MANAGER_CALLBACKS
+
+#include <ws_mng_searching_threads.h>
+#include <ws_mng_dictionary_utils.h>
+#include <ws_mng_threads_utils.h>
+#include <ws_mng_gconf_utils.h>
+#include <ws_manager.h>
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+void         ws_mng_progress_bar (double progress,
+                                  gpointer user_data,
+                                  EngineStatus error);
+
+void         ws_mng_on_search_word (GError *error,
+                                    GArray *word,
+                                    gpointer user_data);
+void         ws_mng_on_search_translation (GError *error,
+                                           GArray *word,
+                                           gpointer user_data);
+
+void         ws_mng_signal_handling (GError *error,
+                                     GArray *signal, 
+                                    gpointer user_data);
+
+
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/include/ws_mng_dictionary_utils.h b/src/manager/include/ws_mng_dictionary_utils.h
new file mode 100644 (file)
index 0000000..1bb1acf
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_DICTIONARY_UTILS
+#define _WS_MANAGER_DICTIONARY_UTILS
+
+#include <ws_mng_gconf_utils.h>
+#include <dictionary_engine.h>
+#include <ws_mng_callbacks.h>
+#include <ws_manager.h>
+#include <untar.h>
+
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+/** \brief Extracting compressed dictionary file
+ *
+ * @param error after excuting it contains error messages if any was
+ * @param param parameters given by D-Bus
+ * @param app_data manager data
+ */
+void ws_mng_extract_dictionary(GError *error, GArray* param, gpointer app_data);
+
+/**
+ * Function used to load dictionaries engines
+ * @param dict_directory path to dictionaries 
+ * @param data structure which contains all data of program
+*/
+void ws_mng_load_dict(GArray* dict_directory, WSMngSearchData* data);
+
+
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/include/ws_mng_gconf_utils.h b/src/manager/include/ws_mng_gconf_utils.h
new file mode 100644 (file)
index 0000000..aef8963
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_GCONF_UTILS
+#define _WS_MANAGER_GCONF_UTILS
+
+#include <gconf/gconf-client.h>
+#include <gconf/gconf.h>
+#include <ws_manager.h>
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+#define GCONF_KEY       "/apps/maemo/WhiteStork/Dictionaries"
+#define GCONF_LIB_PATH  "/apps/maemo/WhiteStork/Engines"
+
+/**
+ *Function used to get the dictionaries location read fron GConf
+ *@return path to dictionaries location
+ */ 
+GArray* ws_mng_read_gconf();
+
+/**
+ *Function used to get plugins location read from GConf
+ *@return libraries location
+ */
+GArray* ws_mng_get_engines_location();
+
+
+/**
+ *Function used to get bookmark library location
+ *@return path to bookmark location
+ */
+gchar* ws_mng_get_boomark_location();
+
+
+/**
+ *Function used to check if optimized flag in GConf is set
+ *@param dict path to dictionary file
+ *@return TRUE if dictionary is optimize, FALSE otherwise
+ */
+gboolean ws_mng_if_optimized(gchar* dict);
+
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/include/ws_mng_searching_threads.h b/src/manager/include/ws_mng_searching_threads.h
new file mode 100644 (file)
index 0000000..74e2a71
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_SEARCHING_THREADS
+#define _WS_MANAGER_SEARCHING_THREADS
+
+#include <ws_mng_threads_utils.h>
+#include <dictionary_engine.h>
+#include <ws_manager.h>
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+
+
+/** \brief Function executed by thread - search for word list
+ *
+ * @param search_data - pointer to search data structure
+ * @return - result of thread - always NULL
+ */
+gpointer     ws_mng_search_word          (gpointer search_data);
+
+/**
+ * \brief Used to return results of found words from threads 
+ *
+ * @param list word list found in dictionaries
+ * @param pattern a word which is being search for in dictionaries
+ * @param user_data data passed to function
+ * @param error engine status information
+ */
+void         ws_mng_on_found_word        (GArray* list,
+                                          gchar* pattern,
+                                          gpointer user_data,
+                                          EngineStatus error);
+
+/** \brief Function executed by thread - search for particular word
+ *
+ * @param search_data - pointer to search data structure
+ * @return - result of thread - always NULL
+ */
+gpointer     ws_mng_search_translation   (gpointer search_data);
+
+/**
+ * \brief Used to return results of transaltion from threads
+ *
+ *  @param translation translation of word found in dictionaries
+ * @param pattern a word which is being serch for in dictionaries
+ * @param user_data data passed to function
+ * @param error engine status information
+ */
+void         ws_mng_on_found_translation (gchar* translation,
+                                          gchar* pattern,
+                                          gpointer user_data,
+                                          EngineStatus error);
+
+/**
+ * \brief Function used to compare string. Used in sorting GArray object
+ *
+ * @param a first argument to compere
+ * @param b second argument to compere
+ * @return result of compare <0 if the second is greater than first 0 if the 
+ *       strings are the same >0 if the first string is greater than second  
+ */
+gint         ws_mng_compare_strings (gconstpointer a, gconstpointer b);
+
+void         ws_remove_multiple_words(WSMngSearchAtom* user_data);
+
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/include/ws_mng_threads_utils.h b/src/manager/include/ws_mng_threads_utils.h
new file mode 100644 (file)
index 0000000..e499ac1
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006-2007 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER_THREADS_UTILS
+#define _WS_MANAGER_THREADS_UTILS
+
+#include <ws_manager.h>
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+
+struct _WSMngSearchAtom {
+       WSMngSearchData *data;
+       gchar           *word;
+       GThread         *thread;
+
+        GArray          *word_list;
+        gchar           *trans;
+};
+typedef struct _WSMngSearchAtom WSMngSearchAtom;
+
+/* functions for critical sections and thread handling  */
+gboolean         try_lock_was_locked(WSMngSearchData* data, gchar* fun);
+gboolean         is_rec_locked(GStaticRecMutex* m);
+void             stop_if_needed(WSMngSearchAtom* data);
+void             free_search_atom(WSMngSearchAtom* data);
+WSMngSearchAtom *create_search_atom(WSMngSearchData* app_data, gchar* word);
+#ifdef __cplusplus
+       }
+#endif
+#endif
diff --git a/src/manager/src/untar.c b/src/manager/src/untar.c
new file mode 100644 (file)
index 0000000..165536f
--- /dev/null
@@ -0,0 +1,231 @@
+#include <untar.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <bzlib.h>
+#include <sys/stat.h>
+//#include <glib-2.0/glib.h>
+
+#define BLOCK_SIZE 512
+#define BUFFER_SIZE BLOCK_SIZE*32
+#define ASCII_NR(NR) (NR + 0x30)
+
+typedef struct _TarHeader
+{
+       gchar name[100];
+       gchar mode[8];
+       gchar uid[8];
+       gchar gid[8];
+       gchar size[12];
+       gchar mtime[12];
+       gchar chksum[8];
+       gchar typeflag;
+       gchar linkname[100];
+       gchar magic[6];
+       gchar version[2];
+       gchar uname[32];
+       gchar gname[32];
+       gchar devmajor[8];
+       gchar devminor[8];
+       gchar prefix[155];
+       gchar padding[12];
+       gchar *gnu_longname;
+       gchar *gnu_longlink;
+} TarHeader;
+
+typedef enum _RecordType
+{
+       File = ASCII_NR (0),
+       ARCHLINK = ASCII_NR (1),
+       SYMLINK = ASCII_NR (2),
+       CHARDEV = ASCII_NR (3),
+       BLOCKDEV = ASCII_NR (4),
+       Dir = ASCII_NR (5),
+       FIFO = ASCII_NR (6),
+       RESERVED = ASCII_NR (7)
+} RecordType;
+
+static gint unpack_file_contents(BZFILE *bz2_file, 
+                               TarHeader *header,
+                               gchar *out_name);
+
+
+static gint unpack_file_contents(BZFILE *bz2_file, 
+                               TarHeader *header,
+                               gchar *out_name)
+{
+       gchar* buffer;
+       guint i;
+       FILE *file_out;
+       gulong length;
+       guint result;
+       gint bzerror;
+       
+       file_out = fopen(out_name, "w");
+       
+       if (file_out == NULL) return -1;
+       
+       sscanf(header->size, "%12lo", &length);
+       g_debug("File size: %ld\n", length);
+       
+       for (i=0; i < (length / BLOCK_SIZE); ++i)
+       {
+               buffer = (gchar*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+               
+               result = BZ2_bzRead ( &bzerror, bz2_file, buffer, BLOCK_SIZE *
+                               sizeof (gchar));
+               
+               fwrite (buffer, BLOCK_SIZE * sizeof(gchar), 1, file_out);
+               g_free (buffer);
+       };
+               
+       i = length % BLOCK_SIZE;
+                               
+       if (i != 0)
+       {
+               buffer = (gchar*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+               
+               if (buffer == NULL)
+               {
+                       g_debug("Memory not allocated");
+                       return -100;
+               };
+               
+               result = BZ2_bzRead(&bzerror, bz2_file, buffer, 
+                               BLOCK_SIZE * sizeof(gchar));
+               
+               if (bzerror == BZ_OK)
+               {
+                       fwrite (buffer, i * sizeof(gchar), 1, file_out);
+               }
+               
+               else 
+               {
+                       g_debug("bzerror = %d", bzerror);
+                       return -100;
+               };
+               
+               g_free(buffer);
+               
+       };
+                               
+       fclose(file_out);
+       
+       return 0;
+};
+
+gint decompress_file (gchar *in_file, gchar **out_path)
+{
+       FILE *file;
+       BZFILE  *bz2_file;
+       guint result;
+       TarHeader* header;
+       gint bzerror;
+       gchar* dest_dir = NULL;
+       header = (TarHeader*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+       
+       if (header == NULL) g_debug("\nCould not allocate memory\n");
+       
+       file = fopen (in_file, "rb");
+       
+       if (file != NULL)
+
+       {
+               bz2_file = BZ2_bzReadOpen (&bzerror, file, 0, 0, NULL, 0);
+
+               if ( bzerror != BZ_OK ) 
+               {
+                       BZ2_bzReadClose ( &bzerror, bz2_file );
+                       g_debug("There was an error while reading the compressed file\n");
+               }
+               
+               bzerror = BZ_OK;
+               while (1) 
+               {
+                       
+                       result = BZ2_bzRead ( &bzerror, bz2_file, header, 
+                                              BLOCK_SIZE * sizeof (char));
+                       if ( bzerror == BZ_OK )
+                       {
+                               if (strlen (header->name) == 0)
+                               {
+                                       g_debug("\nFilename length is 0, exitting\n");
+                                       break;
+                               };
+                               
+                               g_debug("Name: %s\n", header->name);
+                               g_debug("Prefix: %s\n", header->prefix);
+                               
+
+                               gchar *temp = g_strconcat (*out_path,
+                                                       header->name, NULL);
+                               g_debug("Temp path %s\n", temp);
+                               switch (header->typeflag)
+                               {
+                                       case File:
+                                               g_debug("File\n");
+                                               unpack_file_contents (bz2_file, 
+                                                       header, temp);
+                                               break;
+                                               
+                                       case Dir:
+                                               
+                                               g_debug("Dir %s\n", temp);
+                                               if (mkdir (temp, S_IRUSR|
+                                                       S_IWUSR|S_IXUSR) != 0)
+                                               {
+                                                       g_debug("Couldn't create directory %s", 
+                                                              temp);
+                                                       g_free(header);
+                                                       BZ2_bzReadClose(&bzerror,
+                                                                       bz2_file);
+                                                       fclose(file);
+                                                       return -100;
+                                               };
+                                               break;
+                                               
+                                       default:
+                                               g_debug("Only files and dirs can be unpacked");
+                               }
+                               dest_dir = g_strdup(temp);
+                               g_debug("dest_dir %s \n", dest_dir);
+                               g_free (temp);
+                               
+                       }
+                               
+                       else if ( bzerror != BZ_STREAM_END )
+                       {
+                               g_debug("\nBZ2 READ_CLOSE(stream end) %d\n", bzerror);
+                               BZ2_bzReadClose ( &bzerror, bz2_file );
+                               break;
+                       }
+                       
+                       else 
+                       {
+                               g_debug("\nExitting, error nr %d\n", bzerror);
+                               BZ2_bzReadClose ( &bzerror, bz2_file );
+                               break;
+                       };
+                       
+               };
+               
+       }
+       else 
+       {
+               g_debug("There was an error while trying to read the archive file");
+               g_free(header); header = NULL;
+               fclose(file);
+               return -100;
+       };
+       if (dest_dir != NULL)
+       {
+               g_free(*out_path); *out_path = NULL;
+               *out_path = g_strdup(dest_dir);
+               g_free(dest_dir); dest_dir = NULL;
+       }
+       g_free(header); header = NULL;
+       fclose(file);
+       return 100;
+       
+       
+};
diff --git a/src/manager/src/whitestork.c b/src/manager/src/whitestork.c
new file mode 100644 (file)
index 0000000..c175569
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <glib.h>
+#include <stdlib.h>
+#include <ws_manager.h>
+//#include <gconf/gconf-client.h>
+//#include <gconf/gconf.h>
+
+int main (gint argc, gchar** argv)
+{
+       g_type_init();
+       
+       WSMngSearchData* search_data = ws_manager_create();
+       
+       ws_mng_init_dbus(search_data);
+       ws_mng_init(search_data);
+       
+       ws_mng_start_main_loop(search_data);
+       
+       ws_mng_close(search_data);
+       
+       //g_free(search_data);
+       
+       return 0;
+}
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/manager/src/ws_manager.c b/src/manager/src/ws_manager.c
new file mode 100644 (file)
index 0000000..317a893
--- /dev/null
@@ -0,0 +1,335 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_manager.h>
+
+#include <ws_mng_searching_threads.h>
+#include <ws_mng_dictionary_utils.h>
+#include <ws_mng_bookmarks_utils.h>
+#include <ws_mng_threads_utils.h>
+#include <ws_mng_gconf_utils.h>
+#include <ws_mng_callbacks.h>
+
+
+/**
+ * Public function, see ws_manager.h
+ */
+WSMngSearchData* ws_manager_create() {
+       g_debug("<--> %s", __FUNCTION__);
+       WSMngSearchData* tmp = g_try_new(WSMngSearchData, 1);
+
+       if (NULL == tmp)
+       {
+               g_debug("Not enough memory !");
+       }
+       return tmp;
+}
+
+/**
+ * Public function, see ws_manager.h
+ */
+gboolean ws_mng_start_main_loop(WSMngSearchData* search_data)
+{
+       g_debug("<--> %s", __FUNCTION__);
+       search_data->loop = g_main_loop_new (NULL, FALSE);
+       if (search_data->loop == NULL)
+       {
+               g_debug("Couldn't create new g_main_loop for Manager!");
+               return FALSE;
+       }
+       g_main_loop_run (search_data->loop);
+       return TRUE;
+}
+
+
+
+
+/**
+ *Public function, see ws_manager.h
+ */
+void ws_mng_init_dbus (WSMngSearchData *data)
+{
+        g_debug("->%s", __FUNCTION__);
+
+       /* create data structure needed to comunicate with dbus wrapper */
+       data->dbus_data = ws_dbus_create ("WhiteStorkManager", "v1.0"); 
+
+       /* set data used to comunicate with gui */
+       ws_dbus_config(data->dbus_data,
+                      WS_DBUS_CONFIG_SERVICE,
+                      "org.maemo.WhiteStorkManager");
+       ws_dbus_config(data->dbus_data,
+                       WS_DBUS_CONFIG_OBJECT,
+                       "/org/maemo/WhiteStorkManager");
+       ws_dbus_config(data->dbus_data,
+                       WS_DBUS_CONFIG_IFACE,
+                       "org.maemo.WhiteStorkManager");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_SERVICE,
+                       "org.maemo.WhiteStorkGui");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_OBJECT,
+                       "/org/maemo/WhiteStorkGui");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_IFACE,
+                       "org.maemo.WhiteStorkGui");
+
+
+       ws_dbus_add_method (data->dbus_data, "find_word", WS_DBUS_TYPE_STRING, 
+                           WS_DBUS_TYPE_INVALID);
+        
+       ws_dbus_add_method (data->dbus_data, "find_translation", 
+                           WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_INVALID);
+                       
+       ws_dbus_add_method (data->dbus_data, "signal", WS_DBUS_TYPE_SIGNAL, 
+                           WS_DBUS_TYPE_INVALID);
+                       
+       ws_dbus_add_method (data->dbus_data, "add_bookmark", 
+                           WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_STRING,  
+                           WS_DBUS_TYPE_INVALID);
+       ws_dbus_add_method (data->dbus_data, "remove_bookmark", 
+                           WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_INVALID);
+
+       ws_dbus_add_method (data->dbus_data, "extract_dictionary", 
+                           WS_DBUS_TYPE_STRING, WS_DBUS_TYPE_INVALID);
+                       
+       /* set callback for find word signal */
+       ws_dbus_set_cb(data->dbus_data, 
+                      "find_word", 
+                      ws_mng_on_search_word,
+                      data);
+
+       /* set callback for find translation signal */
+        ws_dbus_set_cb(data->dbus_data,
+                       "find_translation",
+                       ws_mng_on_search_translation,
+                       data);
+
+       /* set callback for close program signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "signal",
+                      ws_mng_signal_handling,
+                      data);
+
+        /* set callback for add bookmarks signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "add_bookmark",
+                      ws_mng_add_bookmark,
+                      data);
+
+       /* set callback for remove bookmarks signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "remove_bookmark",
+                      ws_mng_remove_bookmark,
+                      data);
+
+       /* set callback for extracting dictionary */
+       ws_dbus_set_cb(data->dbus_data,
+                      "extract_dictionary",
+                      ws_mng_extract_dictionary,
+                      data);
+
+       ws_dbus_connect(data->dbus_data);
+
+
+       g_debug("<-%s", __FUNCTION__);
+}
+
+
+/**
+ *Public fuction, see ws_manager.h
+ */
+void ws_mng_init (WSMngSearchData *data)
+{
+        g_debug("->%s", __FUNCTION__);
+        data->dict = g_array_new(TRUE, TRUE, sizeof(Engine *));
+        data->modules = g_array_new(TRUE, TRUE, sizeof(EngineModule));
+        data->libraries = g_array_new(TRUE, TRUE, sizeof(GModule*));
+       data->word_list = NULL;
+        data->last_search = NULL;
+        data->trans = NULL;
+        data->search_in_history = FALSE;
+       data->word = NULL;
+       data->bookmark = NULL;
+        data->bookmark_mode = FALSE;
+       /* added by Dariusz Wiechecki
+        * mutex initialization */
+       data->action_working = (GStaticMutex*)g_try_malloc(sizeof(GStaticMutex));
+       data->thread_creation = (GStaticMutex*)g_try_malloc(sizeof(GStaticMutex));
+       data->action_stop = (GStaticRecMutex*)g_try_malloc(sizeof(GStaticRecMutex));
+       g_assert(NULL != (data->action_working) );
+       g_assert(NULL != (data->action_stop) );
+       g_static_mutex_init (data->action_working);
+       g_static_mutex_init (data->thread_creation);
+       g_static_rec_mutex_init (data->action_stop);
+       /* initialize static stop_if_needed function mutex*/
+       stop_if_needed (NULL);
+       /* initialize GThread structure */
+       //data->action_thread = NULL;
+
+       #ifdef SQLITE
+       if (g_file_test(LIBRARY, 
+                       G_FILE_TEST_EXISTS) == FALSE)
+       {
+               ws_dbus_notify(data->dbus_data, WS_DBUS_LOAD_BOOKMARK_FAILED);
+       }
+       #endif
+       
+        GArray* dict_directory = ws_mng_read_gconf(); //paths to dictionaries
+        gint i = 0;
+
+       data->library_path = ws_mng_get_engines_location();
+        //load the engine function
+        for (i = 0; i < data->library_path->len; i++)
+        {
+                gchar* path= g_array_index(data->library_path, gchar*, i);
+                GModule* library = g_module_open(path, G_MODULE_BIND_LAZY);
+               g_array_append_val(data->libraries, library);
+               g_debug("%p library pinter %d iter", library, i);
+               //g_free(path);
+        }
+        //data->library = g_module_open(library_to_path, G_MODULE_BIND_LAZY); 
+       
+       for (i=0; i<data->libraries->len; i++)
+        {
+               getting_additional get_functions = NULL;
+               //get_functions = NULL;
+               //data->library
+               g_debug("%p", g_array_index(data->libraries, GModule*, i));
+                g_module_symbol(g_array_index(data->libraries, GModule*, i),
+                                "engine_global_functions",
+                                (gpointer)&get_functions);
+               g_debug("%d     %p", i, &get_functions);
+                if (get_functions == NULL) //check if function was loaded
+                {
+                        ws_dbus_notify(data->dbus_data,
+                                       WS_DBUS_ERROR_ENGINE_NOT_FOUND);
+                        for (i=0; i<dict_directory->len; i++)
+                        {
+                                g_free(g_array_index(dict_directory, gchar*, i));
+                        }
+                        g_array_free(dict_directory, TRUE);
+                        ws_mng_close(data);
+                        exit(0); //exit program
+                }
+               EngineModule module =  get_functions();
+               //tmp = (EngineModule*) g_memdup(&module, sizeof(EngineModule));
+               //module = (EngineModule**) &tmp;
+               g_array_append_val(data->modules, module);
+               
+        }
+       
+       ws_mng_load_bookmark(data);
+       if (dict_directory->len > 0)
+        {
+               ws_dbus_notify(data->dbus_data, WS_DBUS_INFO_CACHING); 
+               
+               ws_mng_load_dict(dict_directory, data);
+               guint i = 0;
+               g_debug("Trace bookmark engine %p", data->bookmark);
+               for (i=0; i<data->dict->len; i++)
+               {
+                       g_debug("dict engines at %p", 
+                       g_array_index(data->dict, Engine*, i));
+               }
+               ws_dbus_notify(data->dbus_data, 
+                               WS_DBUS_INFO_CACHING_FINISHED);
+        }
+        else
+        {
+               ws_dbus_notify(data->dbus_data,
+                               WS_DBUS_ERROR_FILE_NOT_FOUND);
+        }
+        for (i=0; i<dict_directory->len; i++)
+        {
+                g_free(g_array_index(dict_directory, gchar*, i));
+        }
+       g_array_free(dict_directory, TRUE);
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Public function, see ws_manager.h
+ */
+void ws_mng_close (WSMngSearchData *data)
+{
+        int i = 0;
+        g_debug("->%s", __FUNCTION__);
+
+        ws_dbus_destroy (data->dbus_data); // deinitialization of dbus
+        if (data->bookmark != NULL)
+       {
+               dict_eng_destroy(data->bookmark);
+       }
+       
+        for (i = 0; i < data->dict->len; i++) 
+        {
+                 //free memory taken by engine
+                dict_eng_destroy(g_array_index (data->dict, Engine*,i));
+        }
+       g_array_free(data->dict, TRUE);
+        
+        /*for (i=0; i<data->word_list->len; i++)
+        {
+                g_free(g_array_index(data->word_list, gchar*, i));
+        }
+       
+       g_array_free(data->word_list, TRUE);*/
+       
+        //free memory used by modules
+        //g_array_free(data->modules, TRUE); 
+        //free memory taken by dictionaries
+        g_free(data->last_search);
+       
+        g_free(data->loop); 
+       
+       g_static_mutex_free(data->thread_creation);
+       g_static_mutex_free(data->action_working);
+       g_static_rec_mutex_free(data->action_stop);
+       /*if (data->word != NULL) g_free(data->word);*/
+       
+        //if (data->trans != NULL) g_free(data->trans);
+       
+       for (i=0; i<data->library_path->len; i++)
+        {
+                g_free(g_array_index(data->library_path, gchar*, i));
+        }
+       g_array_free(data->library_path, TRUE); 
+       
+       g_array_free(data->modules, TRUE); data->modules = NULL;
+       
+       for (i=0; i< data->libraries->len; i++)
+        {
+                if (g_array_index(data->libraries, GModule*, i) != NULL)
+                {
+                           //close library
+                        g_module_close(g_array_index(data->libraries, 
+                                               GModule*, i));
+                }
+               
+        }
+       
+       g_array_free(data->libraries, TRUE);
+       
+       g_free(data);
+       
+        g_debug("<-%s", __FUNCTION__);
+}
+
+
diff --git a/src/manager/src/ws_mng_bookmarks_utils.c b/src/manager/src/ws_mng_bookmarks_utils.c
new file mode 100644 (file)
index 0000000..3a6e14a
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_bookmarks_utils.h>
+
+/**
+ *Function used to add bookmarks
+ *@param error error messages
+ *@param param word and translation of word to adding
+ *@param user_data structure holding nedded parameters
+ */
+void ws_mng_add_bookmark(GError *error, GArray* param, gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+       
+       WSMngSearchData* data = (WSMngSearchData *) user_data;
+        osso_rpc_t* osso_data = NULL;
+       osso_rpc_t* osso_data_trans = NULL;
+        gchar* word = NULL;
+       gchar* translation = NULL;
+        //get the word passed by dbus 
+        if (data->bookmark != NULL)
+       {
+               //g_debug("adding bookmarks...%p locataion", data->bookmark);
+               osso_data = &g_array_index (param, osso_rpc_t, 0); 
+               word = g_strdup(osso_data->value.s);
+               osso_data_trans = &g_array_index (param, osso_rpc_t, 1); 
+               translation = g_strdup(osso_data_trans->value.s);
+               //do not free translation and word
+               gboolean is_added = dict_eng_add_word(data->bookmark, 
+                                                       word, translation);
+               if (is_added == TRUE) 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_OK);
+               }
+               else 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               }
+               osso_rpc_free_val(osso_data);
+               g_free(translation);
+               g_free(word);
+       }
+       else
+       {
+               ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Function used to remove bookmarks 
+ *@param error error messages
+ *@param param word and translation of word to remove
+ *@param user_data structure holding nedded parameters
+ */
+void ws_mng_remove_bookmark(GError *error, GArray* param, gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+
+       WSMngSearchData* data = (WSMngSearchData *) user_data;
+        osso_rpc_t* osso_data = NULL;
+        gchar* word = NULL;
+       //get the word passed by dbus 
+        if (data->bookmark != NULL)
+       {
+               g_debug("removing bookmarks...");
+               osso_data = &g_array_index(param, osso_rpc_t, 0); 
+               word = g_strdup(osso_data->value.s);
+
+               gboolean is_remove  = dict_eng_remove_word(data->bookmark, word);
+               if (is_remove == TRUE) 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_REMOVED_OK);
+               }
+               else 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_REMOVED_FAIL);
+               }
+               
+               osso_rpc_free_val(osso_data);
+       }
+       else
+       {       
+               ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
+
+
+/**
+ *Function used to load bookmark module 
+ *@param data structure which holds the loaded module
+ */
+void ws_mng_load_bookmark(WSMngSearchData* data)
+{
+       g_debug("->%s", __FUNCTION__);
+       guint i = 0;
+       data->bookmark = NULL;
+       gchar* current_directory = ws_mng_get_boomark_location();
+       if (current_directory != NULL)
+       {
+       #ifdef SQLITE
+       if (g_file_test(LIBRARY, G_FILE_TEST_EXISTS))
+       {
+       #endif
+               for (i=0; i<data->modules->len; i++)
+               {
+                       if (dict_eng_module_check(
+                               g_array_index(data->modules, EngineModule, i),
+                                                   current_directory) == TRUE)
+                       {
+                               data->bookmark = 
+                                       dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                              EngineModule,
+                                                              i),
+                                               current_directory,
+                                               ENGINE_CREATE,
+                                               ws_mng_progress_bar,
+                                               data,
+                                               0.02);
+                               dict_eng_set_callback(data->bookmark,
+                                                      ENGINE_WORD_LIST_SIGNAL,
+                                                      ws_mng_on_found_word,
+                                                      data);
+                                //set callback for return translation
+                                dict_eng_set_callback(data->bookmark,
+                                                 ENGINE_WORD_TRANSLATION_SIGNAL,
+                                                 ws_mng_on_found_translation,
+                                                 data);
+                               
+                               break;
+                       }
+               }
+               
+       #ifdef SQLITE
+       }
+       #endif
+       g_free(current_directory);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
diff --git a/src/manager/src/ws_mng_callbacks.c b/src/manager/src/ws_mng_callbacks.c
new file mode 100644 (file)
index 0000000..9db25b2
--- /dev/null
@@ -0,0 +1,249 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_callbacks.h>
+
+/**
+ * Function used to send inforamtion about progress of caching XDXF file to UI
+ * @param progess how much file is cached
+ * @param user_data data needed to send information to UI
+ * @param error error messages
+ */
+void ws_mng_progress_bar(double progress,
+                                gpointer user_data,
+                                EngineStatus error
+                               )
+{
+       g_debug("<--> %s - progress=%f", __FUNCTION__, progress);
+       WSMngSearchData *data = (WSMngSearchData *) user_data;
+       ws_dbus_server_update_progressbar(data->dbus_data, progress);
+}
+
+
+
+/**
+* \brief Called when find word event occurs 
+*
+* @param word word to search
+* @param error error messages
+* @param user_data user data passed to function
+*/
+void ws_mng_on_search_word(GError *error,
+                           GArray *word,
+                           gpointer user_data
+                           )
+{
+       g_debug("[L-word] -> %s: reading parameters...", __FUNCTION__);
+       WSMngSearchData *search = (WSMngSearchData *) user_data;
+       osso_rpc_t* osso_data = NULL;
+
+       /* ---> CRITICAL SECTION for this function */
+       g_static_mutex_lock( search->thread_creation );
+
+       /* get the word passed by dbus */
+       osso_data = &g_array_index (word, osso_rpc_t, 0);
+       gchar* tmp = NULL;
+       if (( g_utf8_strchr(osso_data->value.s, -1, '*') == NULL ) && 
+           ( g_utf8_strchr(osso_data->value.s, -1, '?') == NULL ))
+       {
+               tmp = g_strconcat(osso_data->value.s, "*", NULL);
+       }
+       else
+       {
+               tmp = g_strdup(osso_data->value.s);
+       }
+
+       /* create and init searching data - separate for each thread */
+       WSMngSearchAtom* search_data = NULL;
+       search_data = create_search_atom(search, tmp);
+       g_free(tmp);
+       if (NULL == search_data)
+       {
+               return;
+       }
+
+       g_debug("[L-word] creating GThread object...");
+       search_data->thread = g_thread_create (ws_mng_search_word,
+                                              search_data,
+                                              TRUE,
+                                              NULL);
+       g_debug("[L-word] GThread object created. Exiting from CREATOR.");
+
+       g_static_mutex_unlock( search->thread_creation );
+       /* <--- end of CRITICAL SECTION for this function */
+
+       g_debug("[L-word] <-%s", __FUNCTION__);
+}
+
+/**
+* \brief Called when find translation event occurs
+*
+* @param word word to search
+* @param error error messages
+* @param user_data user data passed to function
+*/
+void ws_mng_on_search_translation (GError *error,
+                                   GArray *word,
+                                   gpointer user_data)
+{
+        g_debug("[L-tran] ->%s", __FUNCTION__);
+
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+
+       /* ---> CRITICAL SECTION for this function */
+       g_static_mutex_lock(data->thread_creation);
+
+        /* get the data sended by dbus */
+        osso_rpc_t *osso_data;
+        osso_data = &g_array_index (word, osso_rpc_t, 0);
+
+       /* create and init searching data - separate for each thread */
+       WSMngSearchAtom* search_data = NULL;
+       search_data = create_search_atom(data, osso_data->value.s);
+       if (NULL == search_data)
+       {
+               return;
+       }
+
+        g_debug("[L-tran] creating GThread object...");
+       search_data->thread = g_thread_create (ws_mng_search_translation,
+                                              search_data,
+                                              TRUE,
+                                              NULL);
+       g_debug("[L-tran] GThread object created. Exiting from CREATOR.");
+
+
+       g_static_mutex_unlock(data->thread_creation);
+       /* <--- end of CRITICAL SECTION for this function */
+
+       g_debug("[L-tran] <-%s", __FUNCTION__);
+}
+
+
+/**
+* \brief Function used for handling signals sent by user interface
+*
+* @param error error messages
+* @param signal type of signal
+* @param user_data data passed to function 
+*/
+void ws_mng_signal_handling(GError *error, GArray *signal, gpointer user_data)
+{
+        g_debug("->%s", __FUNCTION__);
+        osso_rpc_t osss_data;
+        osss_data = g_array_index (signal, osso_rpc_t, 0);
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+        gint i = 0;
+        switch(osss_data.value.i)
+        {
+                case WS_DBUS_INFO_TERMINATE:
+                       /* added by Dariusz Wiechecki
+                        * canceling GLib Threads */
+                       if (try_lock_was_locked(data,(gchar*)__FUNCTION__))
+                       {
+                               g_printf("[S] STOP ACTION! %s\n",__FUNCTION__);
+                               g_static_rec_mutex_lock(data->action_stop);
+                               g_static_mutex_lock(data->action_working);
+                       }
+                       g_static_rec_mutex_unlock(data->action_stop);
+                       ws_dbus_notify(data->dbus_data,
+                                      WS_DBUS_WORDS_LIST_FINISHED);
+                       ws_dbus_notify(data->dbus_data,
+                                      WS_DBUS_TRANSLATION_FINISHED);
+                       g_static_mutex_unlock(data->action_working);
+                        g_main_loop_quit (data->loop);
+               break;
+               case WS_DBUS_INFO_STOP_SEARCH:
+                       /* added by Dariusz Wiechecki
+                        * canceling GLib Threads */
+                       if (try_lock_was_locked(data,(gchar*)__FUNCTION__))
+                       {
+                               g_printf("[S] STOP ACTION! %s\n",__FUNCTION__);
+                               g_static_rec_mutex_lock(data->action_stop);
+                               g_static_mutex_lock(data->action_working);
+                       }
+                       g_static_rec_mutex_unlock(data->action_stop);
+                       ws_dbus_notify(data->dbus_data,
+                                      WS_DBUS_WORDS_LIST_FINISHED);
+                       ws_dbus_notify(data->dbus_data,
+                                      WS_DBUS_TRANSLATION_FINISHED);
+                       g_static_mutex_unlock(data->action_working);
+                break;
+
+                case WS_DBUS_INFO_CONFIG_CHANGED:
+                        ws_dbus_notify(data->dbus_data, WS_DBUS_INFO_CACHING); 
+                        
+                        for (i=0; i<data->dict->len; i++)
+                        {
+                                if (g_array_index(data->dict, Engine*,i) != NULL)
+                               {
+                                       dict_eng_destroy(
+                                               g_array_index(
+                                                       data->dict, Engine*,i
+                                                )
+                                                       );
+                               }
+                        }
+                        g_array_free(data->dict, TRUE);
+                        
+                        data->dict = g_array_new (TRUE, TRUE, sizeof(Engine*));;
+                        //paths to directories
+                        GArray* dir_array = ws_mng_read_gconf();
+                        //fill the table again with new dicnioraries
+                        ws_mng_load_dict(dir_array, data);
+                        //if there is no dictionary selected
+                        // signal this fact to gui
+                       if (data->dict->len <= 0)
+                        {
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_INFO_CACHING_FINISHED);
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_ERROR_FILE_NOT_FOUND); 
+                        }else
+                        {
+                                //if there was typed word search for word list
+                                if (data->last_search != NULL) 
+                                {
+                                        data->word_list = g_array_new(TRUE, TRUE,
+                                       sizeof(gchar*));//creating new word list
+
+                                        g_free(data->word); data->word = NULL;
+                                        data->word = g_strdup(data->last_search);
+                                }
+                                //signal end of dictionary load to gui
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_INFO_CACHING_FINISHED);
+                        }
+                        //free memory
+                        for (i=0; i<dir_array->len; i++)
+                        {
+                                g_free(g_array_index(dir_array, gchar*, i));
+                        }
+                        g_array_free(dir_array, TRUE);
+                break;
+               case WS_DBUS_BOOKMARK_MODE_ON:
+                       data->bookmark_mode = TRUE;
+               break;
+               
+               case WS_DBUS_BOOKMARK_MODE_OFF:
+                       data->bookmark_mode = FALSE;
+               break;
+        }
+        g_debug("<-%s", __FUNCTION__);
+}
diff --git a/src/manager/src/ws_mng_dictionary_utils.c b/src/manager/src/ws_mng_dictionary_utils.c
new file mode 100644 (file)
index 0000000..e39f078
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_dictionary_utils.h>
+
+void ws_mng_extract_dictionary(GError *error,
+                               GArray* param,
+                               gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+       WSMngSearchData *data = (WSMngSearchData *) user_data;
+        osso_rpc_t *osso_data;
+        //get the data sended by dbus
+        osso_data = &g_array_index (param, osso_rpc_t, 0); 
+        //get the path sended by dbus
+        gchar* path = g_strdup(osso_data->value.s);
+       gint result = -1;
+       
+       gchar* dest = NULL;
+       if (path != NULL)
+       {
+               gint count = 0;
+               gchar** tmp = g_strsplit(path,
+                                       "/",
+                                        0);
+               while(tmp[count++] != NULL);
+               dest = g_strndup(path, g_strlen(path)- g_strlen(tmp[count -2]));
+               g_strfreev(tmp);
+       }
+       if (dest != NULL)
+       {       ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE);
+               result = decompress_file(path, &dest);
+               ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE_FINISHED);
+       }
+       
+       if (result > 0) 
+       {
+               ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
+       }
+       else 
+       {       
+               dest = "";
+               ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
+       }
+       
+       g_free(path);
+       g_debug("<-%s", __FUNCTION__);
+}
+
+
+/**
+ *Function used to load dictionaries engines
+ *@param dict_directory path to dictionaries 
+ *@param data structure which contains all data of program
+*/
+void ws_mng_load_dict(GArray* dict_directory, WSMngSearchData* data)
+{
+
+        gint i = 0;
+        gint j = 0;
+        Engine* xdxf = NULL;
+        g_debug("->%s", __FUNCTION__);
+        for (i =0; i<dict_directory->len; i++)
+        {
+                gchar* current_directory = strdup(g_array_index(dict_directory,
+                                                                gchar*,
+                                                                i)
+                                                 );            
+                for (j=0; j<data->modules->len; j++)
+                {
+                       if (dict_eng_module_check(g_array_index(data->modules,
+                                                                 EngineModule,
+                                                                 j),
+                                                   current_directory) == TRUE)
+                        {               
+                               if(ws_mng_if_optimized(current_directory))
+                               {
+                                        xdxf = dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                              EngineModule,
+                                                              j),
+                                               current_directory,
+                                               ENGINE_CREATE,
+                                               ws_mng_progress_bar,
+                                               data,
+                                               0.02); //create engine module 
+                               }
+                               else
+                               {
+                                        xdxf = dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                             EngineModule,
+                                                             j),
+                                               current_directory,
+                                               ENGINE_NO, 
+                                              ws_mng_progress_bar,
+                                               data,
+                                               0.02); //create engine module 
+                               }
+                                //set callback for return words list function
+                                dict_eng_set_callback(xdxf,
+                                                      ENGINE_WORD_LIST_SIGNAL,
+                                                      ws_mng_on_found_word,
+                                                      data);
+                                //set callback for return translation
+                                dict_eng_set_callback(xdxf,
+                                                 ENGINE_WORD_TRANSLATION_SIGNAL,
+                                                 ws_mng_on_found_translation,
+                                                 data);
+                                //adding newly created engine to Garray
+                                g_array_append_val (data->dict, xdxf);
+                                g_free(current_directory);
+                        }
+                }
+        }
+        g_debug("<-%s", __FUNCTION__);
+}
+
+
diff --git a/src/manager/src/ws_mng_gconf_utils.c b/src/manager/src/ws_mng_gconf_utils.c
new file mode 100644 (file)
index 0000000..92d7371
--- /dev/null
@@ -0,0 +1,257 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_gconf_utils.h>
+
+
+/**
+ *Function used to get the dictionaries location read fron GConf
+ *@return path to dictionaries location
+ */ 
+GArray* ws_mng_read_gconf()
+{
+        //g_type_init();
+        g_debug("--%s", __FUNCTION__);
+        GConfClient* client = NULL;
+        GArray* path_to_dir = g_array_new(TRUE, TRUE, sizeof(gchar *));
+        gchar* path = NULL;
+        //gchar* key_value = NULL;
+        gboolean key_active = FALSE;
+        gint i = 0;
+        
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path", NULL);
+                gchar* new_acitve = g_strconcat(path, "/active", NULL);
+                key_active = gconf_client_get_bool(client, new_acitve, NULL);
+                if (key_active == TRUE)
+                {
+                        gchar* key_value = gconf_client_get_string(client,
+                                                               new_path,
+                                                               NULL);
+                       if (key_value != NULL){
+                               g_array_append_val(path_to_dir, key_value);
+                       }
+                }
+                g_free(new_path);
+                g_free(new_acitve);
+                
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+        return path_to_dir;
+}
+
+
+/**
+ *Function used to get plugins location read from GConf
+ *@return libraries location
+ */
+GArray* ws_mng_get_engines_location()
+{
+
+        //g_type_init();
+        g_debug("->%s", __FUNCTION__);
+        GConfClient* client = NULL;
+        GArray* path_to_dir = g_array_new(TRUE, TRUE, sizeof(gchar *));
+        gchar* path = NULL;
+        gint i = 0;
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_LIB_PATH, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path",NULL);
+                gchar* key_value = gconf_client_get_string(client,
+                                                           new_path,
+                                                           NULL);
+               gchar** tmp = g_strsplit(key_value,
+                                         "/",
+                                         -1);
+               guint i = 0;
+               gboolean bookmark_engin = FALSE;
+               while(tmp[i] != NULL)
+               {
+                       g_debug("Comapred string %s", tmp[i]);
+                       if (g_ascii_strcasecmp(tmp[i], "ws_bookmark.so") == 0)
+                       {
+                               bookmark_engin = TRUE;
+                               break;
+                       }
+                       i++;
+               }
+               g_strfreev(tmp);
+               #ifdef SQLITE
+               if (bookmark_engin)
+               {
+                       gboolean result = g_file_test(
+                                               LIBRARY,
+                                               G_FILE_TEST_EXISTS);
+                       if (result == FALSE)
+                       {
+                               g_debug("sqlite not installed !");
+                               g_free(new_path);
+                               continue;
+                       }
+               }
+               #endif
+               
+               if (key_value != NULL)
+               {
+                       g_debug("Added library path %s", key_value);
+                       g_array_append_val(path_to_dir, key_value);
+               }
+                g_free(new_path);
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+
+        return path_to_dir;
+}
+
+
+/**
+ *Function used to get bookmark library location
+ *@return path to bookmark location
+ */
+gchar* ws_mng_get_boomark_location()
+{
+       g_debug("->%s", __FUNCTION__);
+       //g_type_init();
+        GConfClient* client = NULL;
+        gchar* path = NULL;
+        guint i = 0;
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* name = g_strconcat(path, "/name",NULL);
+               gchar* new_path = g_strconcat(path, "/path",NULL);
+               gchar* key_value = gconf_client_get_string(
+                                                       client,
+                                                        name,
+                                                        NULL);
+               //g_debug("Try this: %s and the path is %s", key_value, path);
+               if (key_value != NULL)
+               {
+                       if (g_ascii_strcasecmp(key_value, "Bookmarks") == 0)
+                       {
+                               gchar* key_value_path = gconf_client_get_string(
+                                                                       client,
+                                                                       new_path,
+                                                                       NULL);
+                               
+                               if (key_value_path != NULL)
+                               {
+                                       g_free(key_value);
+                                       key_value = NULL;
+                                       g_free(new_path);
+                                       new_path = NULL;
+                                       g_free(name); name = NULL;      
+                                       for (i=0; i<g_slist_length(list); i++)
+                                       {
+                                               g_free(
+                                               g_slist_nth_data(list, i));
+                                       }
+                                       g_slist_free(list);
+                                       g_object_unref(client);
+                                       return key_value_path;
+                               }
+                       }
+               }
+               g_free(name); name = NULL;
+               g_free(key_value);
+               key_value = NULL;
+               g_free(new_path);
+               new_path = NULL;
+        }
+        
+       g_debug("<-%s", __FUNCTION__);
+        return NULL;
+}
+
+/**
+ *Function used to check if optimized flag in GConf is set
+ *@param dict path to dictionary file
+ *@return TRUE if dictionary is optimize, FALSE otherwise
+ */
+gboolean ws_mng_if_optimized(gchar* dict)
+{
+       g_debug("->%s", __FUNCTION__);
+
+       GConfClient* client;
+       gchar* path = NULL;
+        gboolean key_optimized = FALSE;
+       gboolean key_found = FALSE;
+        gint i = 0;
+
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                path = (gchar *) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path",NULL);
+                gchar* new_optimized = g_strconcat(path, "/optimized",NULL);
+                gchar* key_value = gconf_client_get_string(client,
+                                                           new_path,
+                                                           NULL
+                                                          );
+               if (g_ascii_strcasecmp(key_value, dict)==0)
+               {
+                       key_optimized = gconf_client_get_bool(client,
+                                                             new_optimized,
+                                                             NULL
+                                                             );
+                       key_found = TRUE;
+                }
+                g_free(new_path);
+                g_free(new_optimized);
+                g_free(key_value);
+               if ( TRUE == key_found )
+               {
+                       break;
+               }
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+
+       g_debug("<-%s", __FUNCTION__);
+       return key_optimized;
+}
+
+
diff --git a/src/manager/src/ws_mng_searching_threads.c b/src/manager/src/ws_mng_searching_threads.c
new file mode 100644 (file)
index 0000000..51c5a0a
--- /dev/null
@@ -0,0 +1,335 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_searching_threads.h>
+
+/**
+* \brief Function used to run search for word engine in threads
+* 
+* @param data required data for search word event
+* @return gpointer return value 
+*/
+gpointer ws_mng_search_word (gpointer user_data)
+{
+        g_debug("[T-word] %s: Entering thread...", __FUNCTION__);
+       WSMngSearchAtom *search_atom = (WSMngSearchAtom*)user_data;
+        WSMngSearchData *search = search_atom->data;
+
+       /* enter into CRITICAL SECTION */
+       if (try_lock_was_locked(search,(gchar*)__FUNCTION__))
+       {
+               g_printf("[T-word] STOP mutex is locked! Aborting others!");
+               g_static_rec_mutex_lock(search->action_stop);
+               g_static_mutex_lock(search->action_working);
+       }
+       g_static_rec_mutex_unlock(search->action_stop);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search_atom);
+
+       g_debug("[T-word] %s - from now this thread is \'singleton\' ",
+               __FUNCTION__
+              );
+       ws_dbus_notify(search->dbus_data, WS_DBUS_WORDS_LIST_STARTED);
+       /* creating new GArray for word list */
+       search_atom->word_list = g_array_new(TRUE, TRUE, sizeof(gchar*));
+
+       g_debug("[T-word] %s - start searching... ",__FUNCTION__);
+        if (search->bookmark_mode)
+       {       /* search only in user bookmarks */
+               dict_eng_search_word_list(search->bookmark,
+                                         search_atom->word,
+                                         search_atom);
+       }
+       else
+       {       /* search for word in each dictionary */
+               gint i = 0;
+               for (i = 0; i < search->dict->len; i++)
+               {
+                       if (NULL == g_array_index(search->dict, Engine *, i))
+                       {
+                               continue;
+                       }
+
+                       stop_if_needed(search_atom);
+                       Engine* dict = g_array_index(search->dict,Engine *,i);
+                       dict_eng_search_word_list(dict, search_atom->word, search_atom);
+               }
+       }
+       g_debug("[T-word] %s - searching finished.",__FUNCTION__);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search_atom);
+
+       /* sort and cleaning words list - only if there were more than one
+        * dictionary loaded */
+       if ((FALSE == search->bookmark_mode) || (1 < search->dict->len))
+       {
+               g_array_sort(search_atom->word_list, ws_mng_compare_strings);
+               ws_remove_multiple_words(search_atom);
+       }
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search_atom);
+
+       ws_dbus_server_return_words(search->dbus_data, search_atom->word_list);
+       ws_dbus_notify(search->dbus_data, WS_DBUS_WORDS_LIST_FINISHED);
+
+       /* free memory used by each word from word list */
+       gint i = 0;
+       for (; i < search_atom->word_list->len; i++)
+       {
+               g_free(g_array_index(search_atom->word_list,gchar* ,i));
+       }
+
+       /* free memory used by GArray */
+       g_array_free(search_atom->word_list, TRUE);
+       search_atom->word_list = NULL;
+
+       g_free(search_atom->word);
+       g_free(search_atom);
+       g_debug("[T-word] %s - leaving thread!", __FUNCTION__);
+       g_static_mutex_unlock(search->action_working);
+       return NULL;
+}
+
+/**
+* \brief Used to return results of found word from threads 
+*
+* @param list word list found in dictionaries
+* @param pattern a word which is being search for in dictionaries
+* @param user_data data passed to function
+* @param error engine status information
+*/
+void ws_mng_on_found_word(GArray* list,
+                          gchar* pattern,
+                          gpointer user_data,
+                          EngineStatus error)
+{
+        g_debug("[T-word-ret]-> %s", __FUNCTION__);
+
+        WSMngSearchAtom* search_atom = (WSMngSearchAtom*)user_data;
+       static gint i = 0;
+       for (i = 0; i < list->len; i++)
+       {
+               /* copy word found by search engine */
+               gchar* new_word = g_strdup(g_array_index(list, gchar*, i));
+               //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "new_word: %s", new_word);
+               g_array_append_val(search_atom->word_list, new_word); 
+               
+        }
+
+       g_debug("[T-word-ret]<- %s", __FUNCTION__);
+}
+
+/**
+* \brief Function used to run search for transaltion of word engine in threads
+* 
+* @param data required data for search translation
+* @return gpointer return value 
+*/
+gpointer ws_mng_search_translation (gpointer data)
+{
+        g_debug("[T-tran] %s: Entering thread...", __FUNCTION__);
+       WSMngSearchAtom* search_atom = (WSMngSearchAtom*)data;
+        WSMngSearchData* search = search_atom->data;
+
+       /* ---> CRITICAL SECTION for this function */
+       if (try_lock_was_locked(search,(gchar*)__FUNCTION__))
+       {
+               g_printf("[T-tran] STOP mutex is locked! Aborting others!");
+               g_static_rec_mutex_lock(search->action_stop);
+               g_static_mutex_lock(search->action_working);
+       }
+       g_static_rec_mutex_unlock(search->action_stop);
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search_atom);
+
+       g_debug("[T-tran] %s - from now this thread is \'singleton\' ",
+               __FUNCTION__
+              );
+       ws_dbus_notify(search->dbus_data, WS_DBUS_TRANSLATION_STARTED);
+
+       /* run search for translation for every dictionary */
+       if (search->bookmark_mode)
+       {
+               dict_eng_search_word_translation(search->bookmark,
+                                                search_atom->word,
+                                                search_atom);
+       }
+       else
+       {
+               gint i;
+               for (i = 0; i < search->dict->len; i++)
+               {
+                       stop_if_needed(search_atom);
+                       if (NULL == g_array_index(search->dict, Engine*, i) )
+                       {
+                               continue;
+                       }
+                       dict_eng_search_word_translation(
+                                       g_array_index(search->dict, Engine*, i),
+                                       search_atom->word,
+                                       search_atom);
+               }
+       }
+       g_debug("[T-tran] %s - searching finished.",__FUNCTION__);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search_atom);
+
+       /* send translation to gui */
+       ws_dbus_server_return_translations(search->dbus_data, search_atom->trans);
+       ws_dbus_notify(search->dbus_data, WS_DBUS_TRANSLATION_FINISHED);
+
+       g_free(search->trans);
+       search->trans = NULL;
+
+       g_debug("[T-word] %s - leaving thread!", __FUNCTION__);
+       g_static_mutex_unlock(search->action_working);
+       return NULL;
+}
+
+/**
+* \brief Used to return results of transaltion from threads
+*
+* @param translation translation of word found in dictionaries
+* @param pattern a word which is being serch for in dictionaries
+* @param user_data data passed to function
+* @param error engine status information
+*/
+void ws_mng_on_found_translation(gchar* translation,
+                                 gchar* pattern,
+                                 gpointer user_data,
+                                 EngineStatus error
+                                 )
+{
+        g_debug("->%s", __FUNCTION__);
+        WSMngSearchAtom* search_atom = (WSMngSearchAtom*)user_data;
+
+       /* we get already the first translation */
+       if ((NULL != translation) && (NULL == search_atom->trans))
+       {       /* concatenate tags and searched word and translation */
+               search_atom->trans = g_strconcat("<PATTERN_OPEN>",
+                                         pattern,
+                                         "<PATTERN_CLOSED><TRANSLATION_OPEN>",
+                                         translation,
+                                         "<TRANSLATION_CLOSED>",
+                                         NULL
+                                        );
+       }
+       else if (NULL != translation)
+       {       /* if there was stored translation *
+                * copy stored translation to temporary variable*/
+               gchar* tmp = g_strconcat(search_atom->trans,
+                                        "<TRANSLATION_OPEN>",
+                                        translation,
+                                        "<TRANSLATION_CLOSED>",
+                                        NULL);
+               /* free memory used by stored old translation */
+               gchar* loc_tmp = search_atom->trans;
+               search_atom->trans = tmp;
+               g_free(loc_tmp);
+               tmp = loc_tmp = NULL;
+       }
+
+       g_debug("<-%s", __FUNCTION__);
+}
+
+
+/**
+* \brief Function used to compare string. Used in sorting GArray object
+*
+*@param a first argument to compere
+*@param b second argument to compere
+*@return result of compare <0 if the second is greater than first 0 if the 
+        strings are the same >0 if the first string is greater than second  
+*/
+gint ws_mng_compare_strings (gconstpointer a, gconstpointer b)
+{
+       gchar** str1 = (gchar**)(a);
+       gchar** str2 = (gchar**)(b);
+
+       gchar* stra = g_utf8_strdown(str1[0], -1);
+       gchar* strb = g_utf8_strdown(str2[0], -1);
+
+       gint result = g_utf8_collate(stra, strb);
+
+       g_free(stra); 
+       g_free(strb);
+       return result;
+}
+
+void ws_remove_multiple_words(WSMngSearchAtom* user_data)
+{
+       WSMngSearchAtom* search = (WSMngSearchAtom*)user_data;
+       gint j = 0;
+       gint i = 0;
+       gint result = -1;
+       gint temp = 256;
+       gchar* tmp1 = NULL;
+       gchar* tmp2 = NULL;
+
+       if (search->word_list->len < 256) 
+       {
+               temp = search->word_list->len;
+       }
+       else
+       {
+               ws_dbus_notify(search->data->dbus_data, WS_DBUS_WORDS_LIST_FULL);
+       }
+
+       for (i = 0; i < temp-1; i++)
+       {
+               tmp1 = g_utf8_casefold(
+                               g_array_index(search->word_list,gchar*,i),
+                               -1
+                               );
+               for (j = i + 1; j < temp; j++)
+               {
+                       /* search if there is a word on word list */
+                       tmp2 = g_utf8_casefold(
+                               g_array_index(search->word_list,gchar*,j),
+                               -1
+                               );
+                               result = g_utf8_collate(tmp1,tmp2);
+                       g_free(tmp2);
+                       tmp2 = NULL;
+                       /* if there is a word on the word list 
+                        * remove that word */
+                       if (result == 0)
+                       {
+                               g_array_remove_index(search->word_list, j);
+                               --j;
+                               --temp;
+                               if (search->word_list->len >= 256){
+                                       temp = 256;
+                               }
+                       }
+                       else {
+                               /* there is no possiblity that further
+                                * will be the same word, check next word */
+                               break;
+                       }
+               }
+               g_free(tmp1);
+               tmp1 = NULL;
+       }
+}
+
diff --git a/src/manager/src/ws_mng_threads_utils.c b/src/manager/src/ws_mng_threads_utils.c
new file mode 100644 (file)
index 0000000..f8f1b44
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_mng_threads_utils.h>
+
+
+/* added by Dariusz Wiechecki 
+ * trying to lock mutext and tells if it was locked */
+gboolean try_lock_was_locked(WSMngSearchData* data, gchar* fun)
+{
+       gboolean res = !g_static_mutex_trylock(data->action_working);
+       if (res)
+       {
+               g_debug("[M-action] %s - FAILED - locked already!", fun);
+       }
+       else
+       {
+               g_debug("[M-action] %s - SUCCESS - locked!", fun);
+       }
+
+       return res;
+}
+
+/* added by Dariusz Wiechecki
+ * check if recursive mutex is already locked 
+ * must be call from critical section!!! */
+gboolean is_rec_locked(GStaticRecMutex* m)
+{
+       gboolean r = !g_static_rec_mutex_trylock(m);
+       if (FALSE == r)
+       {
+               g_static_rec_mutex_unlock(m);
+               g_debug("[M-stop] STOP mutex is UNLOCKED!");
+       }
+       else
+       {
+               g_debug("[M-stop] STOP mutex is LOCKED");
+       }
+       return r;
+}
+
+/* added by Dariusz Wiechecki
+ * stop current thread if there is such a need - newer thread is waiting */
+void stop_if_needed(WSMngSearchAtom* data)
+{
+       static GStaticMutex _loc;
+       static GStaticMutex* loc = NULL;
+       if(NULL == loc && NULL == data)
+       {
+               g_debug("Initializing static mutex. function:%s\n",__FUNCTION__);
+               g_static_mutex_init (loc);
+               loc = &_loc;
+               return;
+       }
+
+       WSMngSearchData* app_data = data->data;
+       /* critical section for calling is_rec_locked() function*/
+       g_static_mutex_lock(loc);
+       if ( is_rec_locked(app_data->action_stop) )
+       {
+               g_debug("[T-leaving] <---- Leaving thread (not finished).\n");
+               ws_dbus_notify(app_data->dbus_data, WS_DBUS_WORDS_LIST_FINISHED);
+               ws_dbus_notify(app_data->dbus_data, WS_DBUS_TRANSLATION_FINISHED);
+               free_search_atom(data);
+               g_static_mutex_unlock(app_data->action_working);
+               g_static_mutex_unlock(loc);
+               g_thread_exit (NULL);
+       }
+       g_static_mutex_unlock(loc);
+}
+
+void free_search_atom(WSMngSearchAtom* data)
+{
+       g_debug("[T-clear] Cleaning after thread\n");
+       g_assert(NULL != data);
+       if (NULL != data->word)
+       {
+               g_free(data->word);
+       }
+       if (NULL != data->trans)
+       {
+               g_free(data->trans);
+       }
+       if (NULL != data->word_list)
+       {
+               /* free memory used by each word from word list */
+               gint i = 0;
+               for (; i < data->word_list->len; i++)
+               {
+                       g_free(g_array_index(data->word_list,gchar* ,i));
+               }
+               /* free memory used by GArray */
+               g_array_free(data->word_list, TRUE);
+               data->word_list = NULL;
+       }
+       g_free(data);
+}
+
+WSMngSearchAtom *create_search_atom(WSMngSearchData* app_data, gchar* word)
+{
+       WSMngSearchAtom* search_data = NULL;
+       search_data = (WSMngSearchAtom*)g_try_malloc(sizeof(WSMngSearchAtom));
+       if (NULL == search_data)
+       {
+               g_debug("[L-*] allocatting memmory for data failed!");
+               return NULL;
+       }
+        /* get the word sended by dbus */
+        search_data->word = g_strdup(word);
+       search_data->data = app_data;
+       search_data->word_list = NULL;
+       search_data->trans = NULL;
+
+       return search_data;
+}
diff --git a/src/manager_copy/COPYING b/src/manager_copy/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/manager_copy/bin/WhiteStorkManager b/src/manager_copy/bin/WhiteStorkManager
new file mode 100755 (executable)
index 0000000..7eeb054
Binary files /dev/null and b/src/manager_copy/bin/WhiteStorkManager differ
diff --git a/src/manager_copy/include/pc-instances.h b/src/manager_copy/include/pc-instances.h
new file mode 100644 (file)
index 0000000..5cf6b7d
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _PC_INSTANCES_H_
+#define _PC_INSTANCES_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// stadards headers
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+// headers with unix types/functions - only for timers and files operations
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+//------------------------------------------------------------------------------
+/** \brief Get comandline by which process in /proc tree was invoked.
+ *
+ * @param process describes which process from /proc tree we want to check. It
+ * should be only concrete directory from /proc nothing else. e.g.: /proc/self,
+ * /proc/8321 etc. Something like /proc or /proc/self is not good.
+ * @return string containing comandline which has invoked process. If NULL there
+ * were some problems, possibly parameter were wrong or ther is no such
+ * a process.
+ */
+char* get_process_cmdline(char* process);
+
+//------------------------------------------------------------------------------
+/** \brief Cut from commandline only program file name.
+ *
+ * @param cmdline commandline which from which we want to remove options.
+ * @return string with only program file name, or NULL if there was any problem
+ */
+char* get_process_program_file(char* cmdline);
+
+//------------------------------------------------------------------------------
+/** \brief Get file name containing programm executing by current process.
+ *
+ * @return file name of program or NULL if there were some problems.
+ */
+char* get_current_process_program_file();
+
+//------------------------------------------------------------------------------
+/** \brief Check if there is another instance of current programm.
+ *
+ * @return integer telling how many processes were initiated with the same
+ * program as curent process. If it is 1, it means there is no other procces.
+ * If > 1 there is another instance.
+ */
+int is_already_running_this_application();
+
+
+
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+#endif /* _PC_INSTANCES_H_ */
diff --git a/src/manager_copy/include/untar.h b/src/manager_copy/include/untar.h
new file mode 100644 (file)
index 0000000..1eb8113
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _WS_UNTAR
+#define _WS_UNTAR
+
+#include <glib.h>
+/*
+Usage example:
+
+decompress_file ("comn_dictd04_wn.tar.bz2", "./"); 
+
+The above example extracts a given archive, to the current directory
+*/
+
+gint decompress_file(gchar *in_file, gchar **out_path);
+
+
+#endif /*_WS_UNTAR*/
diff --git a/src/manager_copy/include/ws_manager.h b/src/manager_copy/include/ws_manager.h
new file mode 100644 (file)
index 0000000..800c73e
--- /dev/null
@@ -0,0 +1,182 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _WS_MANAGER
+#define _WS_MANAGER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ws_dbus.h>
+#include <dictionary_engine.h>
+
+#include <gmodule.h>
+#include <glib/gstdio.h>
+#include <gconf/gconf-client.h>
+#include <gconf/gconf.h>
+#include <string.h>
+#include <untar.h>
+
+#define GCONF_KEY       "/apps/maemo/WhiteStork/Dictionaries"
+#define GCONF_LIB_PATH  "/apps/maemo/WhiteStork/Engines"
+
+#if SQLITE==0
+       #define LIBRARY "/usr/lib/libsqlite.so.0"
+#elif SQLITE==3
+       #define LIBRARY "/usr/lib/libsqlite3.so.0"
+#endif
+
+#define g_strlen(string) ( NULL == (string) ? 0 : strlen(string) )
+
+
+struct _WSMngSearchData;
+typedef struct _WSMngSearchData WSMngSearchData;
+
+/**
+ * Creates new instance of WSMngSearchData structure
+ *@return new instance of WSMngSearchData structure
+ */
+WSMngSearchData* ws_manager_create();
+
+/** 
+* \brief Function used to initialize D-BUS
+*
+*@param data structure stores variables which are need to comunicate by D-BUS.
+*/
+void ws_mng_init_dbus (WSMngSearchData *data);
+
+/**
+* \brief Function used to initialize manager
+*
+* Fuction loads from modules pointers to functions used to service searching 
+in dictionaries and stores them in WSMngSearchData structure
+*@param data pointer to structure WSMngSearchData which stores variables needed 
+to service manager
+*/
+void ws_mng_init (WSMngSearchData *data);
+
+/**
+* \brief Function used to close dictionaries and modules
+*
+* @param data structure holds pointers to data which need to be freed 
+from memory
+*/
+void ws_mng_close (WSMngSearchData *data);
+
+/**
+ * Function used to run and initialize main loop.
+ *@param serach_data structure which contains all data of program
+ *@return TRUE if successfully run main loop, FALSE otherwise 
+ */
+gboolean ws_mng_start_main_loop(WSMngSearchData* serach_data);
+
+struct _WSMngSearchData
+{
+        GArray* dict; ///< pointer to GArray structure which stores pointers to fuction used to service dictionaries 
+        GArray* modules; ///< pointer to GArray structure which stores pointers to fuction used to service modules loading
+        gchar* word; ///< word which will be used to search a dictionaries
+        pthread_t p_thread; ///< a thread in which we serching word list
+       pthread_t p_thread_trans; ///< a thread in which are searching for translation of word
+        WSDBusData* dbus_data; ///< a pointer DBUS data
+        GMainLoop* loop; ///< pointer to main loop
+        //GModule* library; ///< library used to load modules
+        GArray* word_list; ///< searched word list
+        gchar* trans; ///< searched translation
+        guint returned_results; ///< count of returned results
+       guint returned_trans_results;
+        gchar* last_search; ///< last searched word
+        gboolean search_in_history; ///< flag signalig when search in hisory is commieted
+        GArray* libraries; ///<tabele used for storing modules libraries
+       Engine* bookmark; ///<bookmark engine
+       /* added by Dariusz Wiechecki
+        * we are moving to GLib threads */
+       GStaticMutex* action_working;
+       GStaticMutex* thread_creation;
+
+       GStaticRecMutex* action_stop;
+
+       GArray* library_path;///<path to library
+       gboolean bookmark_mode;
+       GModule* bookmark_library;
+};
+
+struct _search_t {
+       WSMngSearchData *data;
+       gchar           *word;
+       GThread         *thread;
+};
+typedef struct _search_t search_t;
+
+/* functions for critical sections and thread handling  */
+gboolean     try_lock_was_locked(WSMngSearchData* data, gchar* fun);
+gboolean     is_rec_locked(GStaticRecMutex* m);
+void         stop_if_needed(WSMngSearchData* data);
+
+void         ws_mng_on_found_translation (gchar* translation,
+                                          gchar* pattern,
+                                          gpointer user_data,
+                                          EngineStatus error);
+
+void         ws_mng_progress_bar (double progress,
+                                  gpointer user_data,
+                                  EngineStatus error);
+
+gboolean     ws_mng_if_optimized (gchar* dict);
+
+
+void         ws_mng_on_search_word (GError *error,
+                                    GArray *word,
+                                    gpointer user_data);
+
+gpointer     ws_mng_search_word (gpointer user_data);
+
+gpointer     ws_mng_search_translation (gpointer data);
+void         ws_mng_add_bookmark (GError *error,
+                                  GArray* param,
+                                  gpointer user_data);
+void         ws_mng_remove_bookmark (GError *error,
+                                     GArray* param,
+                                     gpointer user_data);
+
+
+void         ws_mng_init (WSMngSearchData *data);
+GArray*      ws_mng_read_gconf ();
+void         ws_mng_init_dbus (WSMngSearchData *data);
+void         ws_mng_load_bookmark (WSMngSearchData* data);
+void         ws_mng_load_dict (GArray* dict_directory, WSMngSearchData* data);
+void         ws_mng_close (WSMngSearchData *data);
+
+void         ws_mng_signal_handling (GError *error,
+                                     GArray *signal, 
+                                    gpointer user_data);
+
+gchar*       ws_mng_get_boomark_location ();
+GArray*      ws_mng_get_engines_location ();
+
+void         ws_mng_extract_dictionary (GError *error,
+                                        GArray* param,
+                                        gpointer user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/manager_copy/makefile b/src/manager_copy/makefile
new file mode 100644 (file)
index 0000000..1a7518f
--- /dev/null
@@ -0,0 +1,35 @@
+CC = gcc
+DEBUG = -g -Wall 
+INCLUDE = ./include
+INCLUDE_DBUS_WRAPPER = ../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0 libosso gconf-2.0 gthread-2.0 ` -lpthread -lbz2
+SQLITE=-DSQLITE=0
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0 libosso gconf-2.0 ` -I${INCLUDE} -I${INCLUDE_DBUS_WRAPPER} ${SQLITE}
+SOURCE = src
+BINARY = bin
+MAIN_BINARIES = ../../bin
+
+EXECUTABLE = ${BINARY}/WhiteStorkManager
+
+all: ${BINARY}/ws_manager.o ${BINARY}/whitestork.o ${MAIN_BINARIES}/ws_dbus.o ${BINARY}/pc-instances.o ${BINARY}/untar.o
+               @echo Compiling with ${SQLITE} flag
+               @${CC} ${DEBUG} ${BINARY}/ws_manager.o ${BINARY}/whitestork.o ${MAIN_BINARIES}/ws_dbus.o ${BINARY}/pc-instances.o ${BINARY}/untar.o -o ${EXECUTABLE} ${LIBS} ${FLAGS}
+               @cp ${EXECUTABLE} ${MAIN_BINARIES}
+
+${BINARY}/pc-instances.o: ${SOURCE}/pc-instances.c
+               @${CC} ${DEBUG} -c ${SOURCE}/pc-instances.c -o ${BINARY}/pc-instances.o ${FLAGS}
+
+${BINARY}/whitestork.o: ${SOURCE}/whitestork.c
+               @${CC} ${DEBUG} -c ${SOURCE}/whitestork.c -o ${BINARY}/whitestork.o ${FLAGS}
+
+${BINARY}/ws_manager.o: ${SOURCE}/ws_manager.c
+               @${CC} ${DEBUG} -c ${SOURCE}/ws_manager.c -o ${BINARY}/ws_manager.o ${FLAGS}
+${BINARY}/untar.o: ${SOURCE}/untar.c
+               @${CC} ${DEBUG} -c ${SOURCE}/untar.c -o ${BINARY}/untar.o ${FLAGS} 
+
+${MAIN_BINARIES}/ws_dbus.o:
+               @cd ../dbus_wrapper && make
+clean:
+               rm -f ${BINARY}/*.o ${EXECUTABLE}
+run:
+               run-standalone.sh ./${EXECUTABLE} &
diff --git a/src/manager_copy/src/pc-instances.c b/src/manager_copy/src/pc-instances.c
new file mode 100644 (file)
index 0000000..38a96c1
--- /dev/null
@@ -0,0 +1,169 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <pc-instances.h>
+
+//------------------------------------------------------------------------------
+/** \brief Get comandline by which process in /proc tree was invoked.
+ *
+ * @param process describes which process from /proc tree we want to check. It
+ * should be only concrete directory from /proc nothing else. e.g.: /proc/self,
+ * /proc/8321 etc. Something like /proc or /proc/self is not good.
+ * @return string containing comandline which has invoked process. If NULL there
+ * were some problems, possibly parameter were wrong or ther is no such
+ * a process.
+ */
+char* get_process_cmdline(char* process)
+{
+       // build final filename to read
+       const char* postfix = "/cmdline";
+       int arg_len = strlen(process);
+       char* tmp = (char*)malloc((size_t)(arg_len+9));
+       tmp[arg_len+8] = '\0';
+       sprintf(tmp,"%s%s",process,postfix);
+       //printf("Process to check: %s\n",tmp);
+
+       // open file to read
+       int file = open(tmp, O_RDONLY);
+       free(tmp); tmp = 0;
+       if(-1 == file)
+       {
+               return (char*)0;
+       }
+
+       int length = 512;       
+
+       // buffer for data from /proc/self/cmdline file
+       char* buffer = (char*)malloc(length + 1);
+
+       // read file to buffer
+       int readed = read(file, buffer, length);
+       close(file);
+       if(readed == length)
+       {
+               free(buffer);
+               return (char*)0;
+       }
+       buffer[length] = '\0';
+
+       //printf("%s() returned finaly: %s\n",__FUNCTION__,buffer);
+       return buffer;
+}
+//------------------------------------------------------------------------------
+/** \brief Cut from commandline only program file name.
+ *
+ * @param cmdline commandline which from which we want to remove options.
+ * @return string with only program file name, or NULL if there was any problem
+ */
+char* get_process_program_file(char* cmdline)
+{
+       int start = 0;
+       int stop  = 0;
+       // find first space in buffer (to remove optional options etc.)
+       while(cmdline[stop] && cmdline[stop] != ' ')
+       {
+               ++stop;
+       }
+       cmdline[stop] = '\0';
+
+       // find last "/" to remove directories 
+       start = stop;
+       while((start>0) && (cmdline[start] != '/'))
+       {
+               --start;
+       }
+       if(cmdline[start] == '/')
+       {
+               ++start;
+       }
+
+       // cut only needed fragment of buffer
+       if(start == stop)
+       {
+               return (char*)0;
+       }
+
+       char* result = (char*)malloc(stop - start + 1);
+       memcpy(result, cmdline + start, stop - start + 1);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get file name containing program executing by current process.
+ *
+ * @return file name of program or NULL if there were some problems.
+ */
+char* get_current_process_program_file()
+{
+       char* cmd = get_process_cmdline("/proc/self");
+       if(!cmd)
+       {
+               return (char*)0;
+       }
+       char* name = get_process_program_file(cmd);
+       free(cmd); cmd = 0;
+
+       return name;
+}
+//------------------------------------------------------------------------------
+/** \brief Check if there is another instance of current programm.
+ *
+ * @return integer telling how many processes were initiated with the same
+ * program as curent process. If it is 1, it means there is no other procces.
+ * If > 1 there is another instance.
+ */
+int is_already_running_this_application()
+{
+       char* app = get_current_process_program_file();
+       int   count = 0;
+
+       struct dirent* entry;
+       DIR*   dir = opendir("/proc");
+       struct stat st;
+
+       char   path[512];
+       sprintf(path,"%s","/proc/");
+       char*  tmp = path + 6;
+
+       while((entry = readdir(dir)) != NULL)
+       {
+               sprintf(tmp,"%s",entry->d_name);
+               lstat(path,&st);
+
+               if(S_ISDIR(st.st_mode))
+               {
+                       char* cmd = get_process_cmdline(path);
+                       if(!cmd) continue;
+                       char* name = get_process_program_file(cmd);
+                       free(cmd); cmd = 0;
+                       if(!name) continue;
+                       //printf("%s: next programm: %s\n",app,name);
+
+                       if(strcmp(app,name) == 0) 
+                       {
+                               ++count;
+                       }
+
+                       free(name); name = 0;
+               }
+       }
+       closedir(dir); dir = NULL;
+       free(app); app = 0;
+       return count;
+}
+//------------------------------------------------------------------------------
diff --git a/src/manager_copy/src/untar.c b/src/manager_copy/src/untar.c
new file mode 100644 (file)
index 0000000..d0f1059
--- /dev/null
@@ -0,0 +1,229 @@
+#include <untar.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <bzlib.h>
+#include <sys/stat.h>
+//#include <glib-2.0/glib.h>
+
+#define BLOCK_SIZE 512
+#define BUFFER_SIZE BLOCK_SIZE*32
+#define ASCII_NR(NR) (NR + 0x30)
+
+typedef struct _TarHeader
+{
+       gchar name[100];
+       gchar mode[8];
+       gchar uid[8];
+       gchar gid[8];
+       gchar size[12];
+       gchar mtime[12];
+       gchar chksum[8];
+       gchar typeflag;
+       gchar linkname[100];
+       gchar magic[6];
+       gchar version[2];
+       gchar uname[32];
+       gchar gname[32];
+       gchar devmajor[8];
+       gchar devminor[8];
+       gchar prefix[155];
+       gchar padding[12];
+       gchar *gnu_longname;
+       gchar *gnu_longlink;
+} TarHeader;
+
+typedef enum _RecordType
+{
+       File = ASCII_NR (0),
+       ARCHLINK = ASCII_NR (1),
+       SYMLINK = ASCII_NR (2),
+       CHARDEV = ASCII_NR (3),
+       BLOCKDEV = ASCII_NR (4),
+       Dir = ASCII_NR (5),
+       FIFO = ASCII_NR (6),
+       RESERVED = ASCII_NR (7)
+} RecordType;
+
+static gint unpack_file_contents(BZFILE *bz2_file, 
+                               TarHeader *header,
+                               gchar *out_name);
+
+
+static gint unpack_file_contents(BZFILE *bz2_file, 
+                               TarHeader *header,
+                               gchar *out_name)
+{
+       gchar* buffer;
+       guint i;
+       FILE *file_out;
+       gulong length;
+       guint result;
+       gint bzerror;
+       
+       file_out = fopen(out_name, "w");
+       
+       if (file_out == NULL) return -1;
+       
+       sscanf(header->size, "%12lo", &length);
+       g_debug("File size: %ld\n", length);
+       
+       for (i=0; i < (length / BLOCK_SIZE); ++i)
+       {
+               buffer = (gchar*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+               
+               result = BZ2_bzRead ( &bzerror, bz2_file, buffer, BLOCK_SIZE *
+                               sizeof (gchar));
+               
+               fwrite (buffer, BLOCK_SIZE * sizeof(gchar), 1, file_out);
+               g_free (buffer);
+       };
+               
+       i = length % BLOCK_SIZE;
+                               
+       if (i != 0)
+       {
+               buffer = (gchar*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+               
+               if (buffer == NULL)
+               {
+                       g_debug("Memory not allocated");
+                       return -100;
+               };
+               
+               result = BZ2_bzRead(&bzerror, bz2_file, buffer, 
+                               BLOCK_SIZE * sizeof(gchar));
+               
+               if (bzerror == BZ_OK)
+               {
+                       fwrite (buffer, i * sizeof(gchar), 1, file_out);
+               }
+               
+               else 
+               {
+                       g_debug("bzerror = %d", bzerror);
+                       return -100;
+               };
+               
+               g_free(buffer);
+               
+       };
+                               
+       fclose(file_out);
+       
+       return 0;
+};
+
+gint decompress_file (gchar *in_file, gchar **out_path)
+{
+       FILE *file;
+       BZFILE  *bz2_file;
+       guint result;
+       TarHeader* header;
+       gint bzerror;
+       gchar* dest_dir = NULL;
+       header = (TarHeader*) g_try_malloc (BLOCK_SIZE * sizeof(gchar));
+       
+       if (header == NULL) g_debug("\nCould not allocate memory\n");
+       
+       file = fopen (in_file, "rb");
+       
+       if (file != NULL)
+
+       {
+               bz2_file = BZ2_bzReadOpen (&bzerror, file, 0, 0, NULL, 0);
+
+               if ( bzerror != BZ_OK ) 
+               {
+                       BZ2_bzReadClose ( &bzerror, bz2_file );
+                       g_debug("There was an error while reading the compressed file\n");
+               }
+               
+               bzerror = BZ_OK;
+               while (1) 
+               {
+                       
+                       result = BZ2_bzRead ( &bzerror, bz2_file, header, 
+                                              BLOCK_SIZE * sizeof (char));
+                       if ( bzerror == BZ_OK )
+                       {
+                               if (strlen (header->name) == 0)
+                               {
+                                       g_debug("\nFilename length is 0, exitting\n");
+                                       break;
+                               };
+                               
+                               g_debug("Name: %s\n", header->name);
+                               g_debug("Prefix: %s\n", header->prefix);
+                               
+
+                               gchar *temp = g_strconcat (*out_path,
+                                                       header->name, NULL);
+                               g_debug("Temp path %s\n", temp);
+                               switch (header->typeflag)
+                               {
+                                       case File:
+                                               g_debug("File\n");
+                                               unpack_file_contents (bz2_file, 
+                                                       header, temp);
+                                               break;
+                                               
+                                       case Dir:
+                                               
+                                               g_debug("Dir %s\n", temp);
+                                               if (mkdir (temp, S_IRUSR|
+                                                       S_IWUSR|S_IXUSR) != 0)
+                                               {
+                                                       g_debug("Couldn't create directory %s", 
+                                                              temp);
+                                                       g_free(header);
+                                                       BZ2_bzReadClose(&bzerror,
+                                                                       bz2_file);
+                                                       fclose(file);
+                                                       return -100;
+                                               };
+                                               break;
+                                               
+                                       default:
+                                               g_debug("Only files and dirs can be unpacked");
+                               }
+                               dest_dir = g_strdup(temp);
+                               g_debug("dest_dir %s \n", dest_dir);
+                               g_free (temp);
+                               
+                       }
+                               
+                       else if ( bzerror != BZ_STREAM_END )
+                       {
+                               g_debug("\nBZ2 READ_CLOSE(stream end) %d\n", bzerror);
+                               BZ2_bzReadClose ( &bzerror, bz2_file );
+                               break;
+                       }
+                       
+                       else 
+                       {
+                               g_debug("\nExitting, error nr %d\n", bzerror);
+                               BZ2_bzReadClose ( &bzerror, bz2_file );
+                               break;
+                       };
+                       
+               };
+               
+       }
+       else 
+       {
+               g_debug("There was an error while trying to read the archive file");
+               g_free(header); header = NULL;
+               fclose(file);
+               return -100;
+       };
+       if (dest_dir != NULL)
+       {
+               g_free(*out_path); *out_path = NULL;
+               *out_path = g_strdup(dest_dir);
+               g_free(dest_dir); dest_dir = NULL;
+       }
+       g_free(header); header = NULL;
+       fclose(file);
+       return 100;
+};
diff --git a/src/manager_copy/src/whitestork.c b/src/manager_copy/src/whitestork.c
new file mode 100644 (file)
index 0000000..121d76f
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+
+#include <glib.h>
+#include <stdlib.h>
+#include <ws_manager.h>
+#include <gconf/gconf-client.h>
+#include <gconf/gconf.h>
+
+int main (gint argc, gchar** argv)
+{
+       /* initialize GType to be able to use GType and GObject */
+       g_type_init();
+
+       /* initiliza GLib thread support... 
+        *  ...only if they are not initialized yet*/
+       if (FALSE == g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       /* allocate memmory for application data */
+       WSMngSearchData* search_data = ws_manager_create();
+       if (NULL == search_data)
+       {
+               g_debug("Not enough memmory to allocate search_data!");
+               return 1;
+       }
+
+       /* init D-Bus and setup services */
+       ws_mng_init_dbus(search_data);
+
+       /* loading current configuration: engines, dictionaries etc. */
+       ws_mng_init(search_data);
+
+       /* module ready to work */
+       ws_mng_start_main_loop(search_data);
+
+       /* free any resources in use and close application */
+       ws_mng_close(search_data);
+       return 0;
+}
+
diff --git a/src/manager_copy/src/ws_manager.c b/src/manager_copy/src/ws_manager.c
new file mode 100644 (file)
index 0000000..d87a423
--- /dev/null
@@ -0,0 +1,1376 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <ws_manager.h>
+
+
+/* added by Dariusz Wiechecki 
+ * trying to lock mutext and tells if it was locked */
+gboolean try_lock_was_locked(WSMngSearchData* data, gchar* fun)
+{
+       gboolean res = !g_static_mutex_trylock(data->action_working);
+       if (res)
+       {
+               g_debug("[M-action] %s - FAILED - locked already!", fun);
+       }
+       else
+       {
+               g_debug("[M-action] %s - SUCCESS - locked!", fun);
+       }
+
+       return res;
+}
+
+/* added by Dariusz Wiechecki
+ * check if recursive mutex is already locked 
+ * must be call from critical section!!! */
+gboolean is_rec_locked(GStaticRecMutex* m)
+{
+       gboolean r = !g_static_rec_mutex_trylock(m);
+       if (FALSE == r)
+       {
+               g_static_rec_mutex_unlock(m);
+               g_debug("[M-stop] STOP mutex is UNLOCKED!");
+       }
+       else
+       {
+               g_debug("[M-stop] STOP mutex is LOCKED");
+       }
+       return r;
+}
+
+/* added by Dariusz Wiechecki
+ * stop current thread if there is such a need - newer thread is waiting */
+void stop_if_needed(WSMngSearchData* data)
+{
+       static GStaticMutex _loc;
+       static GStaticMutex* loc = NULL;
+       if(NULL == loc && NULL == data)
+       {
+               g_debug("Initializing static mutex. function:%s\n",__FUNCTION__);
+               g_static_mutex_init (loc);
+               loc = &_loc;
+               return;
+       }
+
+       /* critical section for calling is_rec_locked() function*/
+       g_static_mutex_lock(loc);
+       if ( is_rec_locked(data->action_stop) )
+       {
+               g_debug("~~~ <---- Leaving thread (not finished).\n");
+               /* TODO clean after this thread!!!! */
+               g_static_mutex_unlock(data->action_working);
+               g_static_mutex_unlock(loc);
+               g_thread_exit (NULL);
+       }
+       g_static_mutex_unlock(loc);
+}
+
+
+/**
+ * Public function, see ws_manager.h
+ */
+WSMngSearchData* ws_manager_create()
+{
+       g_debug("%s<->", __FUNCTION__);
+       WSMngSearchData* result = g_try_new(WSMngSearchData, 1);
+
+       if (NULL == result)
+       {
+               g_debug("Not enough memory !");
+       }
+       return result;
+}
+
+/**
+ * Public function, see ws_manager.h
+ */
+gboolean ws_mng_start_main_loop(WSMngSearchData* search_data)
+{
+       g_debug("%s <-->", __FUNCTION__);
+       search_data->loop = g_main_loop_new (NULL, FALSE);
+       if (search_data->loop == NULL)
+       {
+               g_debug("Couldn't create new g_main_loop for Manager!");
+               return FALSE;
+       }
+       g_main_loop_run (search_data->loop);
+       return TRUE;
+}
+
+/**
+* \brief Used to return results of transaltion from threads
+*
+* @param translation translation of word found in dictionaries
+* @param pattern a word which is being serch for in dictionaries
+* @param user_data data passed to function
+* @param error engine status information
+*/
+void ws_mng_on_found_translation(gchar* translation,
+                                 gchar* pattern,
+                                 gpointer user_data,
+                                 EngineStatus error
+                                 )
+{
+        g_debug("->%s", __FUNCTION__);
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+
+       /* if user want to stop searching */
+       stop_if_needed(data);
+
+       /* we get already the first translation */
+       if ((NULL != translation) && (NULL == data->trans))
+       {       /* concatenate tags and searched word and translation */
+               data->trans = g_strconcat("<PATTERN_OPEN>",
+                                         pattern,
+                                         "<PATTERN_CLOSED><TRANSLATION_OPEN>",
+                                         translation,
+                                         "<TRANSLATION_CLOSED>",
+                                         NULL
+                                        );
+       }
+       else if (NULL != translation)
+       {       /* if there was stored translation *
+                * copy stored translation to temporary variable*/
+               gchar* tmp = g_strconcat(data->trans,
+                                        "<TRANSLATION_OPEN>",
+                                        translation,
+                                        "<TRANSLATION_CLOSED>",
+                                        NULL);
+               /* free memory used by stored old translation */
+               gchar* loc_tmp = data->trans;
+               data->trans = tmp;
+               g_free(loc_tmp);
+               tmp = loc_tmp = NULL;
+       }
+
+       /* if user want to stop searching */
+       stop_if_needed(data);
+
+        g_debug("<-%s", __FUNCTION__);
+}
+/* -------------------------------------------------------------------------- */
+/**
+ * Function used to send inforamtion about progress of caching XDXF file to UI
+ * @param progess how much file is cached
+ * @param user_data data needed to send information to UI
+ * @param error error messages
+ */
+void ws_mng_progress_bar(double progress,
+                                gpointer user_data,
+                                EngineStatus error
+                               )
+{
+        g_debug("<-> %s; progress=%f", __FUNCTION__, progress);
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+        /* return progress of caching to user interface */
+        ws_dbus_server_update_progressbar(data->dbus_data, progress); 
+
+}
+
+/**
+ *Function used to check if optimized flag in GConf is set
+ *@param dict path to dictionary file
+ *@return TRUE if dictionary is optimize, FALSE otherwise
+*/
+gboolean ws_mng_if_optimized(gchar* dict)
+{
+       g_debug("->%s", __FUNCTION__);
+
+       GConfClient* client;
+       gchar* path = NULL;
+        gboolean key_optimized = FALSE;
+       gboolean key_found = FALSE;
+        gint i = 0;
+
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                path = (gchar *) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path",NULL);
+                gchar* new_optimized = g_strconcat(path, "/optimized",NULL);
+                gchar* key_value = gconf_client_get_string(client,
+                                                           new_path,
+                                                           NULL
+                                                          );
+               if (g_ascii_strcasecmp(key_value, dict)==0)
+               {
+                       key_optimized = gconf_client_get_bool(client,
+                                                             new_optimized,
+                                                             NULL
+                                                             );
+                       key_found = TRUE;
+                }
+                g_free(new_path);
+                g_free(new_optimized);
+                g_free(key_value);
+               if ( TRUE == key_found )
+               {
+                       break;
+               }
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+
+       g_debug("<-%s", __FUNCTION__);
+        return key_optimized;
+}
+
+
+
+/* ------------------------------------------------------------------------ */
+/**
+* \brief Called when find word event occurs 
+*
+* @param word word to search
+* @param error error messages
+* @param user_data user data passed to function
+*/
+void ws_mng_on_search_word(GError *error,
+                           GArray *word,
+                           gpointer user_data
+                           )
+{
+       g_debug("[L-word] -> %s: reading parameters...", __FUNCTION__);
+       WSMngSearchData *search = (WSMngSearchData *) user_data;
+       osso_rpc_t* osso_data = NULL;
+
+       /* ---> CRITICAL SECTION for this function */
+       g_static_mutex_lock( search->thread_creation );
+
+       /* get the word passed by dbus */
+       osso_data = &g_array_index (word, osso_rpc_t, 0);
+       search_t* tmp = (search_t*)g_try_malloc( sizeof(search_t) );
+       tmp->word = g_strdup(osso_data->value.s);
+               tmp->data = search;
+               tmp->thread = NULL;
+
+       g_debug("[L-word] creating GThread object...");
+       tmp->thread = g_thread_create (ws_mng_search_word, tmp, TRUE, NULL);
+       g_debug("[L-word] GThread object created. Exiting from CREATOR.");
+
+       g_static_mutex_unlock( search->thread_creation );
+       /* <--- end of CRITICAL SECTION for this function */
+
+       g_debug("[L-word] <-%s", __FUNCTION__);
+}
+/* ------------------------------------------------------------------------ */
+void ws_remove_multiple_words(WSMngSearchData* user_data)
+{
+       WSMngSearchData* search = (WSMngSearchData*)user_data;
+       gint j = 0;
+       gint i = 0;
+       gint result = -1;
+       gint temp = 256;
+       gchar* tmp1 = NULL;
+       gchar* tmp2 = NULL;
+
+       if (search->word_list->len < 256) 
+       {
+               temp = search->word_list->len;
+       }
+
+       for (i = 0; i < temp-1; i++)
+       {
+               tmp1 = g_utf8_casefold(
+                               g_array_index(search->word_list,gchar*,i),
+                               -1
+                               );
+               for (j = i + 1; j < temp; j++)
+               {
+                       /* search if there is a word on word list */
+                       tmp2 = g_utf8_casefold(
+                               g_array_index(search->word_list,gchar*,j),
+                               -1
+                               );
+                               result = g_utf8_collate(tmp1,tmp2);
+                       g_free(tmp2);
+                       tmp2 = NULL;
+                       /* if there is a word on the word list 
+                        * remove that word */
+                       if (result == 0)
+                       {
+                               g_array_remove_index(search->word_list, j);
+                               --j;
+                               --temp;
+                               if (search->word_list->len >= 256){
+                                       temp = 256;
+                               }
+                       }
+                       else {
+                               /* there is no possiblity that further
+                                * will be the same word, check next word */
+                               break;
+                       }
+               }
+               g_free(tmp1);
+               tmp1 = NULL;
+       }
+}
+/* ------------------------------------------------------------------------ */
+/**
+* \brief Function used to compare string. Used in sorting GArray object
+*
+*@param a first argument to compere
+*@param b second argument to compere
+*@return result of compare <0 if the second is greater than first 0 if the 
+        strings are the same >0 if the first string is greater than second  
+*/
+gint ws_mng_compare_strings (gconstpointer a, gconstpointer b)
+{
+       gchar** str1 = (gchar**)(a);
+       gchar** str2 = (gchar**)(b);
+
+       gchar* stra = g_utf8_strdown(str1[0], -1);
+       gchar* strb = g_utf8_strdown(str2[0], -1);
+
+       gint result = g_utf8_collate(stra, strb);
+
+       g_free(stra); 
+       g_free(strb);
+       return result;
+}
+/* ------------------------------------------------------------------------ */
+/**
+* \brief Function used to run search for word engine in threads
+* 
+* @param data required data for search word event
+* @return gpointer return value 
+*/
+gpointer ws_mng_search_word (gpointer user_data)
+{
+        g_debug("[T-word] %s: Entering thread...", __FUNCTION__);
+       search_t* data = (search_t*)user_data;
+        WSMngSearchData *search = data->data;
+
+       /* enter into CRITICAL SECTION */
+       if (try_lock_was_locked(search,(gchar*)__FUNCTION__))
+       {
+               g_printf("[T-word] STOP mutex is locked! Aborting others!");
+               g_static_rec_mutex_lock(search->action_stop);
+               g_static_mutex_lock(search->action_working);
+       }
+       g_static_rec_mutex_unlock(search->action_stop);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search);
+
+       g_debug("[T-word] %s - from now this thread is \'singleton\' ",
+               __FUNCTION__
+              );
+
+       /* creating new GArray for word list */
+       search->word_list = g_array_new(TRUE, TRUE, sizeof(gchar*));
+
+       g_debug("[T-word] %s - start searching... ",__FUNCTION__);
+        if (search->bookmark_mode)
+       {       /* search only in user bookmarks */
+               dict_eng_search_word_list(search->bookmark,
+                                         data->word);
+       }
+       else
+       {       /* search for word in each dictionary */
+               gint i = 0;
+               for (i = 0; i < search->dict->len; i++)
+               {
+                       if (NULL == g_array_index(search->dict, Engine *, i))
+                       {
+                               continue;
+                       }
+
+                       stop_if_needed(search);
+                       Engine* dict = g_array_index(search->dict,Engine *,i);
+                       dict_eng_search_word_list(dict, data->word);
+               }
+       }
+       g_debug("[T-word] %s - searching finished.",__FUNCTION__);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search);
+
+       /* sort and cleaning words list - only if there were more than one
+        * dictionary loaded */
+       if ((FALSE == search->bookmark_mode) || (1 < search->dict->len))
+       {
+               g_array_sort(search->word_list, ws_mng_compare_strings);
+               ws_remove_multiple_words(search);
+       }
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search);
+
+       ws_dbus_server_return_words(search->dbus_data, search->word_list);
+
+       /* free memory used by each word from word list */
+       gint i = 0;
+       for (; i < search->word_list->len; i++)
+       {
+               g_free(g_array_index(search->word_list,gchar* ,i));
+       }
+
+       /* free memory used by GArray */
+       g_array_free(search->word_list, TRUE);
+       search->word_list = NULL;
+
+       g_free(data->word);
+       g_free(data);
+       g_debug("[T-word] %s - leaving thread!", __FUNCTION__);
+       g_static_mutex_unlock(search->action_working);
+       return NULL;
+}
+
+/**
+* \brief Used to return results of found word from threads 
+*
+* @param list word list found in dictionaries
+* @param pattern a word which is being search for in dictionaries
+* @param user_data data passed to function
+* @param error engine status information
+*/
+void ws_mng_on_found_word(GArray* list,
+                          gchar* pattern,
+                          gpointer user_data,
+                          EngineStatus error)
+{
+        g_debug("[T-word-ret]-> %s", __FUNCTION__);
+
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+       static gint i = 0;
+       for (i = 0; i < list->len; i++)
+       {
+               /* copy word found by search engine */
+               gchar* new_word = g_strdup(g_array_index(list, gchar*, i));
+               g_array_append_val(data->word_list, new_word); 
+               
+        }
+
+       g_debug("[T-word-ret]<- %s", __FUNCTION__);
+}
+
+
+
+/**
+* \brief Called when find translation event occurs
+*
+* @param word word to search
+* @param error error messages
+* @param user_data user data passed to function
+*/
+void ws_mng_on_search_translation (GError *error, GArray *word,
+                                   gpointer user_data)
+{
+        g_debug("[L-tran] ->%s", __FUNCTION__);
+
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+
+       /* ---> CRITICAL SECTION for this function */
+       g_static_mutex_lock(data->thread_creation);
+
+        osso_rpc_t *osso_data;
+        /* get the data sended by dbus */
+        osso_data = &g_array_index (word, osso_rpc_t, 0); 
+        /* get the word sended by dbus */
+        data->word = g_strdup(osso_data->value.s);
+
+        g_debug("[L-tran] creating GThread object...");
+       g_thread_create (ws_mng_search_translation, data, TRUE, NULL);
+       g_debug("[L-tran] GThread object created. Exiting from CREATOR.");
+
+
+       g_static_mutex_unlock(data->thread_creation);
+       /* <--- end of CRITICAL SECTION for this function */
+
+       g_debug("[L-tran] <-%s", __FUNCTION__);
+}
+
+/* -------------------------------------------------------------------------- */
+/**
+* \brief Function used to run search for transaltion of word engine in threads
+* 
+* @param data required data for search translation
+* @return gpointer return value 
+*/
+gpointer ws_mng_search_translation (gpointer data)
+{
+        g_debug("[T-tran] %s: Entering thread...", __FUNCTION__);
+        WSMngSearchData *search = (WSMngSearchData *) data;
+
+       /* ---> CRITICAL SECTION for this function */
+       if (try_lock_was_locked(search,(gchar*)__FUNCTION__))
+       {
+               g_printf("[T-tran] STOP mutex is locked! Aborting others!");
+               g_static_rec_mutex_lock(search->action_stop);
+               g_static_mutex_lock(search->action_working);
+       }
+       g_static_rec_mutex_unlock(search->action_stop);
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search);
+
+       g_debug("[T-tran] %s - from now this thread is \'singleton\' ",
+               __FUNCTION__
+              );
+
+       /* run search for translation for every dictionary */
+       if (search->bookmark_mode)
+       {
+               dict_eng_search_word_translation(search->bookmark,
+                                                search->word);
+       }
+       else
+       {
+               gint i;
+               for (i = 0; i < search->dict->len; i++)
+               {
+                       stop_if_needed(search);
+                       if (NULL == g_array_index(search->dict, Engine*, i) )
+                       {
+                               continue;
+                       }
+                       dict_eng_search_word_translation(
+                                       g_array_index(search->dict, Engine*, i),
+                                       search->word
+                                      );
+               }
+       }
+       g_debug("[T-tran] %s - searching finished.",__FUNCTION__);
+
+       /* if another thread was run after this one - exit */
+       stop_if_needed(search);
+
+       /* send translation to gui */
+       ws_dbus_server_return_translations(search->dbus_data, search->trans);
+
+       g_free(search->trans);
+       search->trans = NULL;
+
+       g_debug("[T-word] %s - leaving thread!", __FUNCTION__);
+       g_static_mutex_unlock(search->action_working);
+       return NULL;
+}
+
+
+/**
+ *Function used to load dictionaries engines
+ *@param dict_directory path to dictionaries 
+ *@param data structure which contains all data of program
+*/
+void ws_mng_load_dict(GArray* dict_directory, WSMngSearchData* data)
+{
+
+        gint i = 0;
+        gint j = 0;
+        Engine* xdxf = NULL;
+        g_debug("->%s", __FUNCTION__);
+        for (i =0; i<dict_directory->len; i++)
+        {
+                gchar* current_directory = strdup(g_array_index(dict_directory,
+                                                                gchar*,
+                                                                i)
+                                                 );            
+                for (j=0; j<data->modules->len; j++)
+                {
+                       if (dict_eng_module_check(g_array_index(data->modules,
+                                                                 EngineModule,
+                                                                 j),
+                                                   current_directory) == TRUE)
+                        {               
+                               if(ws_mng_if_optimized(current_directory))
+                               {
+                                        xdxf = dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                              EngineModule,
+                                                              j),
+                                               current_directory,
+                                               ENGINE_CREATE,
+                                               ws_mng_progress_bar,
+                                               data,
+                                               0.02); //create engine module 
+                               }
+                               else
+                               {
+                                        xdxf = dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                             EngineModule,
+                                                             j),
+                                               current_directory,
+                                               ENGINE_NO, 
+                                              ws_mng_progress_bar,
+                                               data,
+                                               0.02); //create engine module 
+                               }
+                                //set callback for return words list function
+                                dict_eng_set_callback(xdxf,
+                                                      ENGINE_WORD_LIST_SIGNAL,
+                                                      ws_mng_on_found_word,
+                                                      data);
+                                //set callback for return translation
+                                dict_eng_set_callback(xdxf,
+                                                 ENGINE_WORD_TRANSLATION_SIGNAL,
+                                                 ws_mng_on_found_translation,
+                                                 data);
+                                //adding newly created engine to Garray
+                                g_array_append_val (data->dict, xdxf);
+                                g_free(current_directory);
+                        }
+                }
+        }
+        g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Function used to get the dictionaries location read fron GConf
+ *@return path to dictionaries location
+ */ 
+GArray* ws_mng_read_gconf()
+{
+        //g_type_init();
+        g_debug("--%s", __FUNCTION__);
+        GConfClient* client = NULL;
+        GArray* path_to_dir = g_array_new(TRUE, TRUE, sizeof(gchar *));
+        gchar* path = NULL;
+        //gchar* key_value = NULL;
+        gboolean key_active = FALSE;
+        gint i = 0;
+        
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path", NULL);
+                gchar* new_acitve = g_strconcat(path, "/active", NULL);
+                key_active = gconf_client_get_bool(client, new_acitve, NULL);
+                if (key_active == TRUE)
+                {
+                        gchar* key_value = gconf_client_get_string(client,
+                                                               new_path,
+                                                               NULL);
+                       if (key_value != NULL){
+                               g_array_append_val(path_to_dir, key_value);
+                       }
+                }
+                g_free(new_path);
+                g_free(new_acitve);
+                
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+        return path_to_dir;
+}
+
+/**
+* \brief Function used for handling signals sent by user interface
+*
+* @param error error messages
+* @param signal type of signal
+* @param user_data data passed to function 
+*/
+void ws_mng_signal_handling(GError *error, GArray *signal, 
+                               gpointer user_data)
+{
+        g_debug("->%s", __FUNCTION__);
+        osso_rpc_t osss_data;
+        osss_data = g_array_index (signal, osso_rpc_t, 0);
+        WSMngSearchData *data = (WSMngSearchData *) user_data;
+        gint i = 0;
+        switch(osss_data.value.i)
+        {
+                case WS_DBUS_INFO_TERMINATE:
+
+                        g_main_loop_quit (data->loop);
+               break;
+               case WS_DBUS_INFO_STOP_SEARCH:
+                       /* added by Dariusz Wiechecki
+                        * canceling GLib Threads */
+                       if (try_lock_was_locked(data,(gchar*)__FUNCTION__))
+                       {
+                               g_printf("~~~STOP ACTION! %s\n",__FUNCTION__);
+                               g_static_rec_mutex_lock(data->action_stop);
+                               g_static_mutex_lock(data->action_working);
+                       }
+                       g_static_rec_mutex_unlock(data->action_stop);
+                       g_static_mutex_unlock(data->action_working);
+                break;
+
+                case WS_DBUS_INFO_CONFIG_CHANGED:
+                        ws_dbus_notify(data->dbus_data, WS_DBUS_INFO_CACHING); 
+                        
+                        for (i=0; i<data->dict->len; i++)
+                        {
+                                if (g_array_index(data->dict, Engine*,i) != NULL)
+                               {
+                                       dict_eng_destroy(
+                                               g_array_index(
+                                                       data->dict, Engine*,i
+                                                )
+                                                       );
+                               }
+                        }
+                        g_array_free(data->dict, TRUE);
+                        
+                        data->dict = g_array_new (TRUE, TRUE, sizeof(Engine*));;
+                        //paths to directories
+                        GArray* dir_array = ws_mng_read_gconf();
+                        //fill the table again with new dicnioraries
+                        ws_mng_load_dict(dir_array, data);
+                        //if there is no dictionary selected
+                        // signal this fact to gui
+                       if (data->dict->len <= 0)
+                        {
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_INFO_CACHING_FINISHED);
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_ERROR_FILE_NOT_FOUND); 
+                        }else
+                        {
+                                data->returned_results = data->dict->len;
+                               data->returned_trans_results = data->dict->len;
+                                //if there was typed word search for word list
+                                if (data->last_search != NULL) 
+                                {
+//                                         for (i=0; i<data->word_list->len; i++)
+//                                         {
+//                                                 g_free(
+//                                                   g_array_index(data->word_list,
+//                                                                 gchar* ,
+//                                                                 i));
+//                                         }
+//                                         //free the old words list
+//                                         g_array_free(data->word_list, TRUE);
+                                        
+                                        data->word_list = g_array_new(TRUE, TRUE,
+                                       sizeof(gchar*));//creating new word list
+                                        
+                                        g_free(data->word); data->word = NULL;
+                                        data->word = g_strdup(data->last_search);
+                                        //create searching thread
+                                        /*pthread_create (&data->p_thread, 
+                                                        NULL, 
+                                                        ws_mng_search_word,
+                                                        data);*/
+                                }
+                                //signal end of dictionary load to gui
+                                ws_dbus_notify(data->dbus_data,
+                                               WS_DBUS_INFO_CACHING_FINISHED);
+                        }
+                        //free memory
+                        for (i=0; i<dir_array->len; i++)
+                        {
+                                g_free(g_array_index(dir_array, gchar*, i));
+                        }
+                        g_array_free(dir_array, TRUE);
+                break;
+               case WS_DBUS_BOOKMARK_MODE_ON:
+                       data->bookmark_mode = TRUE;
+               break;
+               
+               case WS_DBUS_BOOKMARK_MODE_OFF:
+                       data->bookmark_mode = FALSE;
+               break;
+
+        }
+        g_debug("<-%s", __FUNCTION__);
+}
+/**
+ *Function used to add bookmarks
+ *@param error error messages
+ *@param param word and translation of word to adding
+ *@param user_data structure holding nedded parameters
+ */
+void ws_mng_add_bookmark(GError *error, GArray* param,
+                         gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+       
+       WSMngSearchData* data = (WSMngSearchData *) user_data;
+        osso_rpc_t* osso_data = NULL;
+       osso_rpc_t* osso_data_trans = NULL;
+        gchar* word = NULL;
+       gchar* translation = NULL;
+        //get the word passed by dbus 
+        if (data->bookmark != NULL)
+       {
+               //g_debug("adding bookmarks...%p locataion", data->bookmark);
+               osso_data = &g_array_index (param, osso_rpc_t, 0); 
+               word = g_strdup(osso_data->value.s);
+               osso_data_trans = &g_array_index (param, osso_rpc_t, 1); 
+               translation = g_strdup(osso_data_trans->value.s);
+               //do not free translation and word
+               gboolean is_added = dict_eng_add_word(data->bookmark, 
+                                                       word, translation);
+               if (is_added == TRUE) 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_OK);
+               }
+               else 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               }
+               osso_rpc_free_val(osso_data);
+               g_free(translation);
+               g_free(word);
+       }
+       else
+       {
+               ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Function used to remove bookmarks 
+ *@param error error messages
+ *@param param word and translation of word to adding
+ *@param user_data structure holding nedded parameters
+ */
+void ws_mng_remove_bookmark(GError *error, GArray* param,
+                         gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+        
+       WSMngSearchData* data = (WSMngSearchData *) user_data;
+        osso_rpc_t* osso_data = NULL;
+        gchar* word = NULL;
+       //get the word passed by dbus 
+        if (data->bookmark != NULL)
+       {
+               g_debug("removing bookmarks...");
+               osso_data = &g_array_index(param, osso_rpc_t, 0); 
+               word = g_strdup(osso_data->value.s);
+
+               gboolean is_remove  = dict_eng_remove_word(data->bookmark, word);
+               if (is_remove == TRUE) 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_REMOVED_OK);
+               }
+               else 
+               {
+                       ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_REMOVED_FAIL);
+               }
+               
+               osso_rpc_free_val(osso_data);
+       }
+       else
+       {       
+               ws_dbus_notify(data->dbus_data, 
+                                      WS_DBUS_BOOKMARKS_ADDED_FAIL);
+               g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Public function, see ws_manager.h
+ */
+void ws_mng_init_dbus (WSMngSearchData *data)
+{
+        g_debug("->%s", __FUNCTION__);
+
+       /* create data structure needed to comunicate with dbus wrapper */
+       data->dbus_data = ws_dbus_create ("WhiteStorkManager", "v1.0"); 
+
+       /* set data used to comunicate with gui */
+       ws_dbus_config(data->dbus_data,
+                      WS_DBUS_CONFIG_SERVICE,
+                      "org.maemo.WhiteStorkManager");
+       ws_dbus_config(data->dbus_data,
+                       WS_DBUS_CONFIG_OBJECT,
+                       "/org/maemo/WhiteStorkManager");
+       ws_dbus_config(data->dbus_data,
+                       WS_DBUS_CONFIG_IFACE,
+                       "org.maemo.WhiteStorkManager");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_SERVICE,
+                       "org.maemo.WhiteStorkGui");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_OBJECT,
+                       "/org/maemo/WhiteStorkGui");
+       ws_dbus_config(data->dbus_data, 
+                       WS_DBUS_CONFIG_REMOTE_IFACE,
+                       "org.maemo.WhiteStorkGui");
+
+       ws_dbus_connect(data->dbus_data);
+
+       /* set callback for find word signal */
+       ws_dbus_set_cb(data->dbus_data, 
+                      "find_word", 
+                      ws_mng_on_search_word,
+                      data);
+
+       /* set callback for find translation signal */
+        ws_dbus_set_cb(data->dbus_data,
+                       "find_translation",
+                       ws_mng_on_search_translation,
+                       data);
+
+       /* set callback for close program signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "signal",
+                      ws_mng_signal_handling,
+                      data);
+
+        /* set callback for add bookmarks signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "add_bookmark",
+                      ws_mng_add_bookmark,
+                      data);
+
+       /* set callback for remove bookmarks signal */
+       ws_dbus_set_cb(data->dbus_data,
+                      "remove_bookmark",
+                      ws_mng_remove_bookmark,
+                      data);
+
+       /* set callback for extracting dictionary */
+       ws_dbus_set_cb(data->dbus_data,
+                      "extract_dictionary",
+                      ws_mng_extract_dictionary,
+                      data);
+
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Function used to get plugins location read from GConf
+ *@return libraries location
+ */
+GArray* ws_mng_get_engines_location()
+{
+
+        //g_type_init();
+        g_debug("->%s", __FUNCTION__);
+        GConfClient* client = NULL;
+        GArray* path_to_dir = g_array_new(TRUE, TRUE, sizeof(gchar *));
+        gchar* path = NULL;
+        gint i = 0;
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_LIB_PATH, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* new_path = g_strconcat(path, "/path",NULL);
+                gchar* key_value = gconf_client_get_string(client,
+                                                           new_path,
+                                                           NULL);
+               gchar** tmp = g_strsplit(key_value,
+                                         "/",
+                                         -1);
+               guint i = 0;
+               gboolean bookmark_engin = FALSE;
+               while(tmp[i] != NULL)
+               {
+                       g_debug("Comapred string %s", tmp[i]);
+                       if (g_ascii_strcasecmp(tmp[i], "ws_bookmark.so") == 0)
+                       {
+                               bookmark_engin = TRUE;
+                               break;
+                       }
+                       i++;
+               }
+               g_strfreev(tmp);
+               #ifdef SQLITE
+               if (bookmark_engin)
+               {
+                       gboolean result = g_file_test(
+                                               LIBRARY,
+                                               G_FILE_TEST_EXISTS);
+                       if (result == FALSE)
+                       {
+                               g_debug("sqlite not installed !");
+                               g_free(new_path);
+                               continue;
+                       }
+               }
+               #endif
+               
+               if (key_value != NULL)
+               {
+                       g_debug("Added library path %s", key_value);
+                       g_array_append_val(path_to_dir, key_value);
+               }
+                g_free(new_path);
+        }
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                g_free(g_slist_nth_data(list, i));
+        }
+        g_slist_free(list);
+        g_object_unref (client);
+
+        return path_to_dir;
+}
+
+/**
+ *Function used to get bookmark library location
+ *@return path to bookmark location
+ */
+gchar* ws_mng_get_boomark_location()
+{
+       g_debug("->%s", __FUNCTION__);
+       //g_type_init();
+        GConfClient* client = NULL;
+        gchar* path = NULL;
+        guint i = 0;
+        client = gconf_client_get_default();
+        GSList* list = gconf_client_all_dirs(client, GCONF_KEY, NULL);
+        for (i=0; i<g_slist_length(list); i++)
+        {
+                //path = g_strdup((gchar *) g_slist_nth_data(list, i));
+                path = (gchar* ) g_slist_nth_data(list, i);
+                gchar* name = g_strconcat(path, "/name",NULL);
+               gchar* new_path = g_strconcat(path, "/path",NULL);
+               gchar* key_value = gconf_client_get_string(
+                                                       client,
+                                                        name,
+                                                        NULL);
+               //g_debug("Try this: %s and the path is %s", key_value, path);
+               if (key_value != NULL)
+               {
+                       if (g_ascii_strcasecmp(key_value, "Bookmarks") == 0)
+                       {
+                               gchar* key_value_path = gconf_client_get_string(
+                                                                       client,
+                                                                       new_path,
+                                                                       NULL);
+                               
+                               if (key_value_path != NULL)
+                               {
+                                       g_free(key_value);
+                                       key_value = NULL;
+                                       g_free(new_path);
+                                       new_path = NULL;
+                                       g_free(name); name = NULL;      
+                                       for (i=0; i<g_slist_length(list); i++)
+                                       {
+                                               g_free(
+                                               g_slist_nth_data(list, i));
+                                       }
+                                       g_slist_free(list);
+                                       g_object_unref(client);
+                                       return key_value_path;
+                               }
+                       }
+               }
+               g_free(name); name = NULL;
+               g_free(key_value);
+               key_value = NULL;
+               g_free(new_path);
+               new_path = NULL;
+        }
+        
+       g_debug("<-%s", __FUNCTION__);
+        return NULL;
+}
+/**
+ *Function used to load bookmark module 
+ *@param data structure which holds the loaded module
+ */
+void ws_mng_load_bookmark(WSMngSearchData* data)
+{
+       g_debug("->%s", __FUNCTION__);
+       guint i = 0;
+       data->bookmark = NULL;
+       gchar* current_directory = ws_mng_get_boomark_location();
+       if (current_directory != NULL)
+       {
+       #ifdef SQLITE
+       if (g_file_test(LIBRARY, G_FILE_TEST_EXISTS))
+       {
+       #endif
+               for (i=0; i<data->modules->len; i++)
+               {
+                       if (dict_eng_module_check(
+                               g_array_index(data->modules, EngineModule, i),
+                                                   current_directory) == TRUE)
+                       {
+                               data->bookmark = 
+                                       dict_eng_module_create_ext(
+                                                g_array_index(data->modules,
+                                                              EngineModule,
+                                                              i),
+                                               current_directory,
+                                               ENGINE_CREATE,
+                                               ws_mng_progress_bar,
+                                               data,
+                                               0.02);
+                               dict_eng_set_callback(data->bookmark,
+                                                      ENGINE_WORD_LIST_SIGNAL,
+                                                      ws_mng_on_found_word,
+                                                      data);
+                                //set callback for return translation
+                                dict_eng_set_callback(data->bookmark,
+                                                 ENGINE_WORD_TRANSLATION_SIGNAL,
+                                                 ws_mng_on_found_translation,
+                                                 data);
+                               
+                               break;
+                       }
+               }
+               
+       #ifdef SQLITE
+       }
+       #endif
+       g_free(current_directory);
+       }
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Public fuction, see ws_manager.h
+ */
+void ws_mng_init (WSMngSearchData *data)
+{
+        g_debug("->%s", __FUNCTION__);
+        data->dict = g_array_new(TRUE, TRUE, sizeof(Engine *));
+        data->modules = g_array_new(TRUE, TRUE, sizeof(EngineModule));
+        data->libraries = g_array_new(TRUE, TRUE, sizeof(GModule*));
+       data->word_list = NULL;
+        data->last_search = NULL;
+        data->trans = NULL;
+        data->search_in_history = FALSE;
+       data->word = NULL;
+       data->bookmark = NULL;
+        data->bookmark_mode = FALSE;
+       /* added by Dariusz Wiechecki
+        * mutex initialization */
+       data->action_working = (GStaticMutex*)g_try_malloc(sizeof(GStaticMutex));
+       data->thread_creation = (GStaticMutex*)g_try_malloc(sizeof(GStaticMutex));
+       data->action_stop = (GStaticRecMutex*)g_try_malloc(sizeof(GStaticRecMutex));
+       g_assert(NULL != (data->action_working) );
+       g_assert(NULL != (data->action_stop) );
+       g_static_mutex_init (data->action_working);
+       g_static_mutex_init (data->thread_creation);
+       g_static_rec_mutex_init (data->action_stop);
+       /* initialize static stop_if_needed function mutex*/
+       stop_if_needed (NULL);
+       /* initialize GThread structure */
+       //data->action_thread = NULL;
+
+       #ifdef SQLITE
+       if (g_file_test(LIBRARY, 
+                       G_FILE_TEST_EXISTS) == FALSE)
+       {
+               ws_dbus_notify(data->dbus_data, WS_DBUS_LOAD_BOOKMARK_FAILED);
+       }
+       #endif
+       
+        GArray* dict_directory = ws_mng_read_gconf(); //paths to dictionaries
+        gint i = 0;
+
+       data->returned_results = dict_directory->len;
+       data->returned_trans_results = dict_directory->len;
+       data->library_path = ws_mng_get_engines_location();
+        //load the engine function
+        for (i = 0; i < data->library_path->len; i++)
+        {
+                gchar* path= g_array_index(data->library_path, gchar*, i);
+                GModule* library = g_module_open(path, G_MODULE_BIND_LAZY);
+               g_array_append_val(data->libraries, library);
+               g_debug("%p library pinter %d iter", library, i);
+               //g_free(path);
+        }
+        //data->library = g_module_open(library_to_path, G_MODULE_BIND_LAZY); 
+       
+       for (i=0; i<data->libraries->len; i++)
+        {
+               getting_additional get_functions = NULL;
+               //get_functions = NULL;
+               //data->library
+               g_debug("%p", g_array_index(data->libraries, GModule*, i));
+                g_module_symbol(g_array_index(data->libraries, GModule*, i),
+                                "engine_global_functions",
+                                (gpointer)&get_functions);
+               g_debug("%d     %p", i, &get_functions);
+                if (get_functions == NULL) //check if function was loaded
+                {
+                        ws_dbus_notify(data->dbus_data,
+                                       WS_DBUS_ERROR_ENGINE_NOT_FOUND);
+                        for (i=0; i<dict_directory->len; i++)
+                        {
+                                g_free(g_array_index(dict_directory, gchar*, i));
+                        }
+                        g_array_free(dict_directory, TRUE);
+                        ws_mng_close(data);
+                        exit(0); //exit program
+                }
+               EngineModule module =  get_functions();
+               //tmp = (EngineModule*) g_memdup(&module, sizeof(EngineModule));
+               //module = (EngineModule**) &tmp;
+               g_array_append_val(data->modules, module);
+               
+        }
+       
+       ws_mng_load_bookmark(data);
+       if (dict_directory->len > 0)
+        {
+               ws_dbus_notify(data->dbus_data, WS_DBUS_INFO_CACHING); 
+               
+               ws_mng_load_dict(dict_directory, data);
+               guint i = 0;
+               g_debug("Trace bookmark engine %p", data->bookmark);
+               for (i=0; i<data->dict->len; i++)
+               {
+                       g_debug("dict engines at %p", 
+                       g_array_index(data->dict, Engine*, i));
+               }
+               ws_dbus_notify(data->dbus_data, 
+                               WS_DBUS_INFO_CACHING_FINISHED);
+        }
+        else
+        {
+               ws_dbus_notify(data->dbus_data,
+                               WS_DBUS_ERROR_FILE_NOT_FOUND);
+        }
+        for (i=0; i<dict_directory->len; i++)
+        {
+                g_free(g_array_index(dict_directory, gchar*, i));
+        }
+       g_array_free(dict_directory, TRUE);
+       g_debug("<-%s", __FUNCTION__);
+}
+
+/**
+ *Public function, see ws_manager.h
+ */
+void ws_mng_close (WSMngSearchData *data)
+{
+        int i = 0;
+        g_debug("->%s", __FUNCTION__);
+
+        ws_dbus_destroy (data->dbus_data); // deinitialization of dbus
+        if (data->bookmark != NULL)
+       {
+               dict_eng_destroy(data->bookmark);
+       }
+       
+        for (i = 0; i < data->dict->len; i++) 
+        {
+                 //free memory taken by engine
+                dict_eng_destroy(g_array_index (data->dict, Engine*,i));
+        }
+       g_array_free(data->dict, TRUE);
+        
+        /*for (i=0; i<data->word_list->len; i++)
+        {
+                g_free(g_array_index(data->word_list, gchar*, i));
+        }
+       
+       g_array_free(data->word_list, TRUE);*/
+       
+        //free memory used by modules
+        //g_array_free(data->modules, TRUE); 
+        //free memory taken by dictionaries
+        g_free(data->last_search);
+       
+        g_free(data->loop); 
+       
+       g_free(data->thread_creation);
+       g_free(data->action_working);
+       g_free(data->action_stop);
+       /*if (data->word != NULL) g_free(data->word);*/
+       
+        //if (data->trans != NULL) g_free(data->trans);
+       
+       for (i=0; i<data->library_path->len; i++)
+        {
+                g_free(g_array_index(data->library_path, gchar*, i));
+        }
+       g_array_free(data->library_path, TRUE); 
+       
+       g_array_free(data->modules, TRUE); data->modules = NULL;
+       
+       for (i=0; i< data->libraries->len; i++)
+        {
+                if (g_array_index(data->libraries, GModule*, i) != NULL)
+                {
+                           //close library
+                        g_module_close(g_array_index(data->libraries, 
+                                               GModule*, i));
+                }
+               
+        }
+       
+       g_array_free(data->libraries, TRUE);
+       
+       g_free(data);
+       
+        g_debug("<-%s", __FUNCTION__);
+}
+
+void ws_mng_extract_dictionary(GError *error,
+                               GArray* param,
+                               gpointer user_data)
+{
+       g_debug("->%s", __FUNCTION__);
+       WSMngSearchData *data = (WSMngSearchData *) user_data;
+        osso_rpc_t *osso_data;
+        //get the data sended by dbus
+        osso_data = &g_array_index (param, osso_rpc_t, 0); 
+        //get the path sended by dbus
+        gchar* path = g_strdup(osso_data->value.s);
+       gint result = -1;
+       
+       gchar* dest = NULL;
+       if (path != NULL)
+       {
+               gint count = 0;
+               gchar** tmp = g_strsplit(path,
+                                       "/",
+                                        0);
+               while(tmp[count++] != NULL);
+               dest = g_strndup(path, g_strlen(path)- g_strlen(tmp[count -2]));
+               g_strfreev(tmp);
+       }
+       if (dest != NULL)
+       {       ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE);
+               result = decompress_file(path, &dest);
+               ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE_FINISHED);
+       }
+       
+       if (result > 0) 
+       {
+               ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
+       }
+       else 
+       {       
+               dest = "";
+               ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
+       }
+       
+       g_free(path);
+       g_debug("<-%s", __FUNCTION__);
+}
+
diff --git a/src/plugins/stardict/COPYING b/src/plugins/stardict/COPYING
new file mode 100755 (executable)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/plugins/stardict/Makefile b/src/plugins/stardict/Makefile
new file mode 100755 (executable)
index 0000000..092074a
--- /dev/null
@@ -0,0 +1,56 @@
+COMPILER = gcc
+DEBUG = -Wall -g
+INCLUDE = ./include
+ENGINE_INCLUDE = ../../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0 gnome-vfs-2.0` -lz
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0 gnome-vfs-2.0` -I${INCLUDE} -I${ENGINE_INCLUDE}
+SOURCES = ./src
+MAIN_BINARIES = ../../../bin
+BINARIES = ./bin
+PRECOMPILED = ./precompiled
+
+first-target: library
+
+build: library
+
+all: clean library test check
+
+clean:
+               @-rm -f ${BINARIES}/*
+               @-rm -f ${SOURCES}/*~
+               @-rm -f *~
+               @-rm -f ${INCLUDE}/*~
+               @-rm -f ${SOURCES}/engine_stardict.so
+               @echo -e -n "Project 'StarDictEngine' directories has been cleaned.\n"
+       
+test:  ${SOURCES}/test.c
+               @${COMPILER} ${LIBS} ${FLAGS} ${DEBUG} -o ${BINARIES}/test ${SOURCES}/test.c
+               @echo -e -n "Building test program for 'StarDictEngine' finished.\n"
+               
+check: test
+               @run-standalone.sh ${BINARIES}/test
+
+
+library: ${BINARIES}/engine_stardict.o                 
+               @${COMPILER} ${DEBUG} -shared -fPIC ${FLAGS} ${LIBS} ${BINARIES}/engine_stardict.o \
+               ${PRECOMPILED}/`arch`/*.o -o ${BINARIES}/engine_stardict.so
+               @cp ${BINARIES}/engine_stardict.so ${MAIN_BINARIES}
+               @echo -e -n "'StarDictEngine' build finished.\n"
+                       
+${BINARIES}/engine_stardict.o: ${SOURCES}/engine_stardict.c
+               @${COMPILER} ${DEBUG} ${FLAGS} -c -fPIC ${SOURCES}/engine_stardict.c -o ${BINARIES}/engine_stardict.o
+       
+       
+final: clean
+               @${COMPILER} -DNOLOGS -Wall -O3 ${FLAGS} -c -fPIC ${SOURCES}/engine_stardict.c -o ${BINARIES}/engine_stardict.o
+               @${COMPILER} -DNOLOGS -Wall -g -shared -fPIC ${FLAGS} ${LIBS} ${BINARIES}/engine_stardict.o \
+               ${SOURCES}/`arch`/*.o -o ${BINARIES}/engine_stardict.so
+               @cp ${BINARIES}/engine_stardict.so ../bin
+               @echo -e -n "'StarDictEngine' build finished. (Final version - optimized)\n"
+       
+       
+       
+       
+       
+       
+       
\ No newline at end of file
diff --git a/src/plugins/stardict/doc/DICTFILE_FORMAT b/src/plugins/stardict/doc/DICTFILE_FORMAT
new file mode 100755 (executable)
index 0000000..17f84fc
--- /dev/null
@@ -0,0 +1,465 @@
+Format for StarDict dictionary files
+------------------------------------
+
+StarDict homepage: http://stardict.sourceforge.net
+
+{0}. Number and Byte-order Conventions
+When you record the numbers that identify sizes, offsets, etc., you
+should use 32-bit numbers, such as you might represent with a glong.
+
+In order to make StarDict work on different platforms, these numbers
+must be in network byte order.  You can ensure the correct byte order
+by using the g_htonl() function when creating dictionary files.
+Conversely, you should use g_ntohl() when reading dictionary files.
+
+Strings should be encoded in UTF-8.
+
+
+{1}. Files
+Every dictionary consists of these files:
+(1). somedict.ifo
+(2). somedict.idx or somedict.idx.gz
+(3). somedict.dict or somedict.dict.dz
+(4). somedict.syn (optional)
+
+You can use gzip -9 to compress the .idx file. If the .idx file are not 
+compressed, the loading can be fast and save memory when using, compress it 
+will make the .idx file load into memory and make the quering become faster 
+when using.
+
+You can use dictzip to compress the .dict file.
+"dictzip" uses the same compression algorithm and file format as does gzip, 
+but provides a table that can be used to randomly access compressed blocks 
+in the file.  The use of 50-64kB blocks for compression typically degrades 
+compression by less than 10%, while maintaining acceptable random access 
+capabilities for all data in the file.  As an added benefit, files 
+compressed with dictzip can be decompressed with gunzip.
+For more information about dictzip, refer to DICT project, please see:
+http://www.dict.org
+
+When you create a dictionary, you should use .idx and .dict.dz in normal 
+case.
+
+Stardict will search for the .ifo file, then open the .idx or 
+.idx.gz file and the .dict.dz or .dict file which is in the same directory and 
+has the same base name.
+
+
+
+{2}. The ".ifo" file's format.
+The .ifo file has the following format:
+
+StarDict's dict ifo file
+version=2.4.2
+[options]
+
+Note that the current "version" string must be "2.4.2".  If it's not,
+then StarDict will refuse to read the file.
+
+[options]
+---------
+In the example above, [options] expands to any of the following lines
+specifying information about the dictionary.  Each option is a keyword
+followed by an equal sign, then the value of that option, then a
+newline.  The options may be appear in any order.
+
+Note that the dictionary must have at least a bookname, a wordcount and a 
+idxfilesize, or the load will fail.  All other information is optional.  All 
+strings should be encoded in UTF-8.
+
+Available options:
+
+bookname=      // required
+wordcount=     // required
+synwordcount=  // required if ".syn" file exists.
+idxfilesize=   // required
+author=
+email=
+website=
+description=
+date=
+sametypesequence= // very important.
+
+
+wordcount is the count of word entries in .idx file, it must be right.
+
+idxfilesize is the size(in bytes) of the .idx file, even the .idx is compressed 
+to a .idx.gz file, this entry must record the original .idx file's size, and it 
+must be right too. The .gz file don't contain its original size information, 
+but knowing the original size can speed up the extraction to memory, as you 
+don't need to call realloc() for many times.
+
+
+The "sametypesequence" option is described in further detail below.
+
+***
+sametypesequence
+
+You should first familiarize yourself with the .dict file format
+described in the next section so that you can understand what effect
+this option has on the .dict file.
+
+If the sametypesequence option is set, it tells StarDict that each
+word's data in the .dict file will have the same sequence of datatypes.
+In this case, we expect a .dict file that's been optimized in two
+ways: the type identifiers should be omitted, and the size marker for
+the last data entry of each word should be omitted.
+
+Let's consider some concrete examples of the sametypesequence option.
+
+Suppose that a dictionary records many .wav files, and so sets:
+        sametypesequence=W
+In this case, each word's entry in the .dict file consists solely of a
+wav file.  In the .dict file, you would leave out the 'W' character
+before each entry, and you would also omit the 32-bit integer at the
+front of each .wav entry that would normally give the entry's length.
+You can do this since the length is known from the information in the
+idx file.
+
+As another example, suppose a dictionary contains phonetic information
+and a meaning for each word.  The sametypesequence option for this
+dictionary would be:
+        sametypesequence=tm
+Once again, you can omit the 't' and 'm' characters before each data
+entry in the .dict file.  In addition, you should omit the terminating
+'\0' for the 'm' entry for each word in the .dict file, as the length
+of the meaning string can be inferred from the length of the phonetic
+string (still indicated by a terminating '\0') and the length of the
+entire word entry (listed in the .idx file).
+
+So for cases where the last data entry for each word normally requires
+a terminating '\0' character, you should omit this character in the
+dict file.  And for cases where the last data entry for each word
+normally requires an initial 32-bit number giving the length of the
+field (such as WAV and PNG entries), you must omit this number in the
+dictionary.
+
+Every dictionary should try to use the sametypesequence feature to
+save disk space.
+***
+
+
+{3}. The ".idx" file's format.
+The .idx file is just a word list.
+
+The word list is a sorted list of word entries.
+
+Each entry in the word list contains three fields, one after the other:
+     word_str;  // a utf-8 string terminated by '\0'.
+     word_data_offset;  // word data's offset in .dict file
+     word_data_size;  // word data's total size in .dict file     
+
+word_str gives the string representing this word.  It's the string
+that is "looked up" by the StarDict.
+
+Two or more entries may have the same "word_str" with different 
+word_data_offset and word_data_size. This may be useful for some 
+dictionaries. But this feature is only well supported by 
+StarDict-2.4.8 and newer.
+
+The length of "word_str" should be less than 256. In other words, 
+(strlen(word) < 256).
+
+word_data_offset and word_data_size should both be 32-bit unsigned numbers 
+in network byte order.
+
+It is possible the different word_str have the same word_data_offset and 
+word_data_size, so multiple word index point to the same definition.
+But this is not recommended, for mutiple words have the same definition, 
+you may create a ".syn" file for them, see section 4 below.
+
+The word list must be sorted by calling stardict_strcmp() on the "word_str" 
+fields.  If the word list order is wrong, StarDict will fail to function 
+correctly!
+
+============
+gint stardict_strcmp(const gchar *s1, const gchar *s2)
+{
+       gint a;
+       a = g_ascii_strcasecmp(s1, s2);
+       if (a == 0)
+               return strcmp(s1, s2);
+       else
+               return a;
+}
+============
+g_ascii_strcasecmp() is a glib function:
+Unlike the BSD strcasecmp() function, this only recognizes standard 
+ASCII letters and ignores the locale, treating all non-ASCII characters 
+as if they are not letters.
+
+stardict_strcmp() works fine with English characters, but the other
+locale characters' sorting is not so good, in this case, you can enable 
+the collation feature, see section 6.
+
+
+{4}. The ",syn" file's format.
+This file is optional, and you should notice tree dictionary needn't this file.
+Only StarDict-2.4.8 and newer support this file.
+
+The .syn file contains information for synonyms, that means, when you input a 
+synonym, StarDict will search another word that related to it.
+
+The format is simple. Each item contain one string and a number.
+synonym_word;  // a utf-8 string terminated by '\0'.
+original_word_index; // original word's index in .idx file.
+Then other items without separation.
+When you input synonym_word, StarDict will search original_word;
+
+The length of "synonym_word" should be less than 256. In other 
+words, (strlen(word) < 256).
+original_word_index is a 32-bit unsigned number in network byte order.
+Two or more items may have the same "synonym_word" with different 
+original_word_index.
+The items must be sorted by stardict_strcmp() with synonym_word.
+
+
+{5}. The offset cache file's format.
+StarDict-2.4.8 start to support cache files, this feature can speed up 
+loading and save memory as mmap() the cache file. The cache file names 
+are .idx.oft and .syn.oft, the format is:
+First a utf-8 string terminated by '\0', then many 32-bit numbers as 
+the wordoffset index, this index is sparse, and "ENTR_PER_PAGE=32", 
+they are not stored in network byte order.
+The string must begin with:
+=====
+StarDict's oft file
+version=2.4.8
+=====
+Then a line like this:
+url=/usr/share/stardict/dic/stardict-somedict-2.4.2/somedict.idx
+This line should have a ending '\n'.
+
+StarDict will try to create the .oft file at the same directory of 
+the .ifo file first, if failed, then try to create it at 
+~/.cache/stardict/, ~/.cache is get by g_get_user_cache_dir(). 
+If two or more dictionaries have the same file name, StarDict will 
+create somedict.idx.oft, somedict(2).idx.oft, somedict(3).idx.oft, 
+etc. for them respectively, each with different "url=" in the 
+beginning string.
+
+
+{6}. The collation file's format.
+StarDict-2.4.8 start to support collation, that sort the word 
+list by collate function. It will create collation file which 
+names .idx.clt and .syn.clt, the format is a little like offset 
+cache file:
+First a utf-8 string terminated by '\0', then many 32-bit numbers as
+the index that sorted by the collate function, they are not stored 
+in network byte order.
+The string must begin with:
+=====
+StarDict's clt file
+version=2.4.8
+=====
+Then two lines like this:
+url=/usr/share/stardict/dic/stardict-somedict-2.4.2/somedict.idx
+func=0
+The second line should have a ending '\n' too.
+
+StarDict support these collate functions currently:
+typedef enum {
+       UTF8_GENERAL_CI = 0,
+       UTF8_UNICODE_CI,
+       UTF8_BIN,
+       UTF8_CZECH_CI,
+       UTF8_DANISH_CI,
+       UTF8_ESPERANTO_CI,
+       UTF8_ESTONIAN_CI,
+       UTF8_HUNGARIAN_CI,
+       UTF8_ICELANDIC_CI,
+       UTF8_LATVIAN_CI,
+       UTF8_LITHUANIAN_CI,
+       UTF8_PERSIAN_CI,
+       UTF8_POLISH_CI,
+       UTF8_ROMAN_CI,
+       UTF8_ROMANIAN_CI,
+       UTF8_SLOVAK_CI,
+       UTF8_SLOVENIAN_CI,
+       UTF8_SPANISH_CI,
+       UTF8_SPANISH2_CI,
+       UTF8_SWEDISH_CI,
+       UTF8_TURKISH_CI,
+} CollateFunctions;
+These UTF8_*_CI functions comes from MySQL in fact.
+
+The file's locate path just like the .oft file.
+
+Notice, for "somedict.idx.gz" file, the corresponding collation 
+file is somedict.idx.clt, but not somedict.idx.gz.clt, the 
+"url=" is somedict.idx, not somedict.idx.gz. So after you gzip 
+the .idx file, StarDict needn't create the .clt file again.
+
+
+{7}. The ".dict" file's format.
+The .dict file is a pure data sequence, as the offset and size of each
+word is recorded in the corresponding .idx file.
+
+If the "sametypesequence" option is not used in the .ifo file, then
+the .dict file has fields in the following order:
+==============
+word_1_data_1_type; // a single char identifying the data type
+word_1_data_1_data; // the data
+word_1_data_2_type;
+word_1_data_2_data;
+...... // the number of data entries for each word is determined by
+       // word_data_size in .idx file
+word_2_data_1_type;
+word_2_data_1_data;
+......
+==============
+It's important to note that each field in each word indicates its
+own length, as described below.  The number of possible fields per
+word is also not fixed, and is determined by simply reading data until
+you've read word_data_size bytes for that word.
+
+
+Suppose the "sametypesequence" option is used in the .idx file, and
+the option is set like this:
+sametypesequence=tm
+Then the .dict file will look like this:
+==============
+word_1_data_1_data
+word_1_data_2_data
+word_2_data_1_data
+word_2_data_2_data
+......
+==============
+The first data entry for each word will have a terminating '\0', but
+the second entry will not have a terminating '\0'.  The omissions of
+the type chars and of the last field's size information are the
+optimizations required by the "sametypesequence" option described
+above.
+
+
+Type identifiers
+----------------
+Here are the single-character type identifiers that may be used with
+the "sametypesequence" option in the .idx file, or may appear in the
+dict file itself if the "sametypesequence" option is not used.
+
+Lower-case characters signify that a field's size is determined by a
+terminating '\0', while upper-case characters indicate that the data
+begins with a 32-bit unsigned integer that gives the length of the data
+field.
+
+'m'
+Word's pure text meaning.
+The data should be a utf-8 string ending with '\0'.
+
+'l'
+Word's pure text meaning.
+The data is NOT a utf-8 string, but is instead a string in locale
+encoding, ending with '\0'.  Sometimes using this type will save disk
+space, but its use is discouraged.
+
+'g'
+A utf-8 string which is marked up with the Pango text markup language.
+For more information about this markup language, See the "Pango
+Reference Manual."
+You might have it installed locally at:
+file:///usr/share/gtk-doc/html/pango/PangoMarkupFormat.html
+
+'t'
+English phonetic string.
+The data should be a utf-8 string ending with '\0'.
+
+Here are some utf-8 phonetic characters:
+θʃŋʧðʒæıʌʊɒɛəɑɜɔˌˈːˑṃṇḷ
+æɑɒʌәєŋvθðʃʒɚːɡˏˊˋ
+
+'x'
+A utf-8 string which is marked up with the xdxf language.
+See http://xdxf.sf.net
+
+'y'
+Chinese YinBiao or Japanese KANA.
+The data should be a utf-8 string ending with '\0'.
+
+'k'
+KingSoft PowerWord's data. The data is a utf-8 string ending with '\0'.
+It is in XML format.
+
+'w'
+MediaWiki markup language.
+See http://meta.wikimedia.org/wiki/Help:Editing#The_wiki_markup
+
+'W'
+wav file.
+The data begins with a network byte-ordered guint32 to identify the wav
+file's size, immediately followed by the file's content.
+
+'P'
+png file.
+The data begins with a network byte-ordered guint32 to identify the png
+file's size, immediately followed by the file's content.
+
+'X'
+this type identifier is reserved for experimental extensions.
+
+
+{8}. Tree Dictionary
+The tree dictionary support is used for information viewing, etc.
+
+A tree dictionary contains three file: sometreedict.ifo, sometreedict.tdx.gz 
+and sometreedict.dict.dz.
+
+It is better to compress the .tdx file, as it is always load into memory.
+
+The .ifo file has the following format:
+
+StarDict's treedict ifo file
+version=2.4.2
+[options]
+
+Available options:
+
+bookname=      // required
+tdxfilesize=   // required
+wordcount=
+author=
+email=
+website=
+description=
+date=
+sametypesequence=
+
+wordcount is only used for info view in the dict manage dialog, so it is not 
+important in tree dictionary.
+
+The .tdx file is just the word list.
+-----------
+The word list is a tree list of word entries.
+
+Each entry in the word list contains four fields, one after the other:
+     word_str;  // a utf-8 string terminated by '\0'.
+     word_data_offset;  // word data's offset in .dict file
+     word_data_size;  // word data's total size in .dict file. it can be 0.
+     word_subentry_count; //have many sub word this entry has, 0 means none.
+
+Subentry is immidiately followed by its parent entry. This make the order is 
+just as when a tree list with all its nodes extended, then sort from top to 
+bottom.
+
+word_data_offset, word_data_size and word_subentry_count should be 32-bit
+unsigned numbers in network byte order.
+
+The .dict file's format is the same as the normal dictionary.
+
+
+
+{9}. More information.
+You can read "src/lib.cpp", "src/dictmanagedlg.cpp" and
+"src/tools/*.cpp" for more information.
+
+After you have build a dictionary, you can use "stardict_verify" to verify the 
+dictionary files. You can find it at "src/tools/".
+
+If you have any questions, email me. :)
+
+Thanks to Will Robinson <wsr23@stanford.edu> for cleaning up this file's
+English.
+
+Hu Zheng <huzheng_001@163.com>
+http://forlinux.yeah.net
+2006.6.15
diff --git a/src/plugins/stardict/include/data.h b/src/plugins/stardict/include/data.h
new file mode 100644 (file)
index 0000000..fdb4ec9
--- /dev/null
@@ -0,0 +1,57 @@
+/* data.h -- 
+ * Created: Sat Mar 15 18:04:25 2003 by Aleksey Cheusov <vle@gmx.net>
+ * Copyright 1994-2003 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: data.h,v 1.1 2003/03/19 16:43:15 cheusov Exp $
+ */
+
+#ifndef _DATA_H_
+#define _DATA_H_
+
+//#include "dictP.h"
+#include "defs.h"
+
+/* initialize .data file */
+extern dictData *dict_data_open (
+   const char *filename, int computeCRC);
+/* */
+extern void dict_data_close (
+   dictData *data);
+
+//extern void     dict_data_print_header( FILE *str, dictData *data );
+extern int      dict_data_zip(
+   const char *inFilename, const char *outFilename,
+   const char *preFilter, const char *postFilter );
+#ifdef ORIGINAL_DICTZIP
+extern char *dict_data_obtain (
+   const dictDatabase *db,
+   const dictWord *dw);
+#endif
+extern char *dict_data_read_ (
+   dictData *data,
+   unsigned long start, unsigned long end,
+   const char *preFilter,
+   const char *postFilter );
+#ifdef ORIGINAL_DICTZIP
+extern int   dict_data_filter(
+   char *buffer, int *len, int maxLength,
+   const char *filter );
+
+extern int        mmap_mode;
+#endif
+
+#endif /* _DATA_H_ */
diff --git a/src/plugins/stardict/include/defs.h b/src/plugins/stardict/include/defs.h
new file mode 100644 (file)
index 0000000..e93a603
--- /dev/null
@@ -0,0 +1,279 @@
+/* defs.h -- 
+ * Created: Sat Mar 15 17:27:23 2003 by Aleksey Cheusov <vle@gmx.net>
+ * Copyright 1994-2003 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: defs.h,v 1.11 2005/03/29 17:55:50 cheusov Exp $
+ */
+
+#ifndef _DEFS_H_
+#define _DEFS_H_
+
+//#include "dictP.h"
+//#include "dictdplugin.h"
+
+#include <zlib.h>
+//#include <maa.h>
+
+                               /* Configurable things */
+
+#define DICT_DEFAULT_SERVICE     "2628"        /* Also in dict.h */
+#define DICTD_CONFIG_NAME        "dictd.conf"
+#define DICT_QUEUE_DEPTH         10
+#define DICT_DEFAULT_DELAY       600 /* 10 minute timeout */
+#define DICT_DAEMON_LIMIT        100 /* maximum simultaneous daemons */
+#define DICT_PERSISTENT_PRESTART 3 /* not implemented */
+#define DICT_PERSISTENT_LIMIT    5 /* not implemented */
+
+#define DICT_ENTRY_PREFIX        "00-database"
+#define DICT_ENTRY_PREFIX_LEN    sizeof(DICT_ENTRY_PREFIX)-1
+#define DICT_SHORT_ENTRY_NAME    DICT_ENTRY_PREFIX"-short"
+#define DICT_LONG_ENTRY_NAME     DICT_ENTRY_PREFIX"-long"
+#define DICT_INFO_ENTRY_NAME     DICT_ENTRY_PREFIX"-info"
+
+#define DICT_FLAG_UTF8           DICT_ENTRY_PREFIX"-utf8"
+#define DICT_FLAG_8BIT_NEW       DICT_ENTRY_PREFIX"-8bit-new"
+#define DICT_FLAG_8BIT_OLD       DICT_ENTRY_PREFIX"-8bit"
+#define DICT_FLAG_ALLCHARS       DICT_ENTRY_PREFIX"-allchars"
+#define DICT_FLAG_VIRTUAL        DICT_ENTRY_PREFIX"-virtual"
+#define DICT_FLAG_ALPHABET       DICT_ENTRY_PREFIX"-alphabet"
+#define DICT_FLAG_DEFAULT_STRAT  DICT_ENTRY_PREFIX"-default-strategy"
+#define DICT_FLAG_MIME_HEADER    DICT_ENTRY_PREFIX"-mime-header"
+
+#define DICT_ENTRY_PLUGIN        DICT_ENTRY_PREFIX"-plugin"
+#define DICT_ENTRY_PLUGIN_DATA   DICT_ENTRY_PREFIX"-plugin-data"
+
+#define DICT_PLUGINFUN_OPEN      "dictdb_open"
+#define DICT_PLUGINFUN_ERROR     "dictdb_error"
+#define DICT_PLUGINFUN_FREE      "dictdb_free"
+#define DICT_PLUGINFUN_SEARCH    "dictdb_search"
+#define DICT_PLUGINFUN_CLOSE     "dictdb_close"
+#define DICT_PLUGINFUN_SET       "dictdb_set"
+
+                               /* End of configurable things */
+
+#define BUFFERSIZE 10240
+
+#define DBG_VERBOSE     (0<<30|1<< 0) /* Verbose                            */
+#define DBG_ZIP         (0<<30|1<< 1) /* Zip                                */
+#define DBG_UNZIP       (0<<30|1<< 2) /* Unzip                              */
+#define DBG_SEARCH      (0<<30|1<< 3) /* Search                             */
+#define DBG_SCAN        (0<<30|1<< 4) /* Config file scan                   */
+#define DBG_PARSE       (0<<30|1<< 5) /* Config file parse                  */
+#define DBG_INIT        (0<<30|1<< 6) /* Database initialization            */
+#define DBG_PORT        (0<<30|1<< 7) /* Log port number for connections    */
+#define DBG_LEV         (0<<30|1<< 8) /* Levenshtein matching               */
+#define DBG_AUTH        (0<<30|1<< 9) /* Debug authentication               */
+#define DBG_NODETACH    (0<<30|1<<10) /* Don't detach as a background proc. */
+#define DBG_NOFORK      (0<<30|1<<11) /* Don't fork (single threaded)       */
+#define DBG_ALT         (0<<30|1<<12) /* altcompare()                      */
+
+#define LOG_SERVER      (0<<30|1<< 0) /* Log server diagnostics             */
+#define LOG_CONNECT     (0<<30|1<< 1) /* Log connection information         */
+#define LOG_STATS       (0<<30|1<< 2) /* Log termination information        */
+#define LOG_COMMAND     (0<<30|1<< 3) /* Log commands                       */
+#define LOG_FOUND       (0<<30|1<< 4) /* Log words found                    */
+#define LOG_NOTFOUND    (0<<30|1<< 5) /* Log words not found                */
+#define LOG_CLIENT      (0<<30|1<< 6) /* Log client                         */
+#define LOG_HOST        (0<<30|1<< 7) /* Log remote host name               */
+#define LOG_TIMESTAMP   (0<<30|1<< 8) /* Log with timestamps                */
+#define LOG_MIN         (0<<30|1<< 9) /* Log a few minimal things           */
+#define LOG_AUTH        (0<<30|1<<10) /* Log authentication denials         */
+
+#define DICT_LOG_TERM    0
+#define DICT_LOG_DEFINE  1
+#define DICT_LOG_MATCH   2
+#define DICT_LOG_NOMATCH 3
+#define DICT_LOG_CLIENT  4
+#define DICT_LOG_TRACE   5
+#define DICT_LOG_COMMAND 6
+#define DICT_LOG_AUTH    7
+#define DICT_LOG_CONNECT 8
+
+#define DICT_UNKNOWN    0
+#define DICT_TEXT       1
+#define DICT_GZIP       2
+#define DICT_DZIP       3
+
+#define DICT_CACHE_SIZE 5
+
+typedef struct dictCache {
+   int           chunk;
+   char          *inBuffer;
+   int           stamp;
+   int           count;
+} dictCache;
+
+typedef struct dictData {
+   int           fd;           /* file descriptor */
+   const char    *start;       /* start of mmap'd area */
+   const char    *end;         /* end of mmap'd area */
+   unsigned long size;         /* size of mmap */
+   
+   int           type;
+   const char    *filename;
+   z_stream      zStream;
+   int           initialized;
+
+   int           headerLength;
+   int           method;
+   int           flags;
+   time_t        mtime;
+   int           extraFlags;
+   int           os;
+   int           version;
+   int           chunkLength;
+   int           chunkCount;
+   int           *chunks;
+   unsigned long *offsets;     /* Sum-scan of chunks. */
+   const char    *origFilename;
+   const char    *comment;
+   unsigned long crc;
+   unsigned long length;
+   unsigned long compressedLength;
+   dictCache     cache[DICT_CACHE_SIZE];
+} dictData;
+
+typedef struct dictPlugin {
+   void *      data;
+
+#ifdef USE_PLUGIN
+/*   lt_dlhandle handle;
+
+   dictdb_open_type   dictdb_open;
+   dictdb_set_type    dictdb_set;
+   dictdb_search_type dictdb_search;
+   dictdb_free_type   dictdb_free;
+   dictdb_error_type  dictdb_error;
+   dictdb_close_type  dictdb_close;
+
+   char dictdb_free_called; *//* 1 after dictdb_free call */
+#endif
+} dictPlugin;
+
+typedef struct dictIndex {
+   int           fd;            /* file descriptor */
+   const char    *start;        /* start of mmap'd area */
+   const char    *end;          /* end of mmap'd area */
+   unsigned long size;          /* size of mmap */
+   const char    *optStart[UCHAR_MAX+2]; /* Optimized starting points */
+   unsigned long headwords;     /* computed number of headwords */
+
+   int    flag_utf8;         /* not zero if it has 00-database-utf8 entry*/
+   int    flag_8bit;         /* not zero if it has 00-database-8bit-new entry*/
+   int    flag_allchars;     /* not zero if it has 00-database-allchars entry*/
+
+   const int     *isspacealnum;
+} dictIndex;
+
+#ifdef ORIGINAL_DICTZIP
+
+typedef struct dictDatabase {
+   const char *databaseName;
+   const char *databaseShort;
+   const char *databaseInfo;
+   const char *dataFilename;
+   const char *indexFilename;
+   const char *indexsuffixFilename;
+   const char *indexwordFilename;
+   const char *filter;
+   const char *prefilter;
+   const char *postfilter;
+   lst_List   acl;
+   int        available;       /* if user has authenticated for database */
+
+   dictData   *data;
+   dictIndex  *index;
+   dictIndex  *index_suffix;
+   dictIndex  *index_word;
+
+   int        *strategy_disabled; /* disable_strategy keyword*/
+
+   lst_List   *virtual_db_list;
+
+   char *alphabet;
+
+   int invisible;    /* non-zero for invisible databases */
+
+   int exit_db;      /* non-zero for dictionary_exit entry */
+   int virtual_db;   /* non-zero for virtual databases */
+   int plugin_db;    /* non-zero for plugin entry */
+   int normal_db;    /* non-zero for normal database */
+   int mime_db;      /* non-zero for MIME database */
+
+   int default_strategy;    /* default search strategy for `.' */
+
+   const char *mime_header; /* MIME header for OPTION MIME command */
+
+   /* database_virtual members */
+   const char *database_list;  /* comma-separated list of database names */
+
+   /* database_plugin members */
+   const char *pluginFilename;
+   const char *plugin_data;    /* data for initializing plugin */
+   dictPlugin *plugin;
+
+   /* database_mime members */
+   const char *mime_mimeDbname;
+   const char *mime_nomimeDbname;
+
+   struct dictDatabase *mime_mimeDB;
+   struct dictDatabase *mime_nomimeDB;
+} dictDatabase;
+
+#define DICT_DENY     0
+#define DICT_ALLOW    1
+#define DICT_AUTHONLY 2
+#define DICT_USER     3
+#define DICT_GROUP    4                /* Not implemented */
+#define DICT_MATCH    5         /* For IP matching routines */
+#define DICT_NOMATCH  6         /* For IP matching routines */
+
+typedef struct dictAccess {
+   int        type;            /* deny, allow, accessonly, user, group */
+   const char *spec;
+} dictAccess;
+
+typedef struct dictConfig {
+   lst_List      acl;          /* type dictAccess */
+   lst_List      dbl;          /* type dictDatabase */
+   hsh_HashTable usl;          /* username/shared-secret list */
+   const char    *site;
+} dictConfig;
+
+typedef struct dictWord {
+   const dictDatabase  *database;
+   const dictDatabase  *database_visible;
+
+   char    *word;
+
+   unsigned long start;
+   unsigned long end;
+
+/* Used by plugins */
+   const char    *def;
+   int            def_size;
+} dictWord;
+
+typedef struct dictToken {
+   const char   *string;
+   int          integer;
+   src_Type     src;
+} dictToken;
+
+#endif
+
+#endif /* _DEFS_H_ */
diff --git a/src/plugins/stardict/include/dictP.h b/src/plugins/stardict/include/dictP.h
new file mode 100644 (file)
index 0000000..6a3a3c4
--- /dev/null
@@ -0,0 +1,343 @@
+
+/* dictP.h -- 
+ * Created: Fri Mar  7 10:54:05 1997 by faith@dict.org
+ * Revised: Fri Dec 22 06:06:33 2000 by faith@dict.org
+ * Copyright 1997, 1999, 2000 Rickard E. Faith (faith@dict.org)
+ * This program comes with ABSOLUTELY NO WARRANTY.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ * $Id: dictP.h,v 1.22 2005/09/05 18:00:02 cheusov Exp $
+ * 
+ */
+
+#ifndef _DICTP_H_
+#define _DICTP_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if  defined(__INTERIX) || defined(__OPENNT)
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE
+#endif /* _ALL_SOURCE */
+#endif /* __OPENNT */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <sys/wait.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#if defined(HAVE_WCTYPE_H) && defined(SYSTEM_UTF8_FUNCS)
+#include <wctype.h>
+#endif
+
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#ifndef __GNUC__
+#define __FUNCTION__ __FILE__
+#endif
+
+/* AIX requires this to be the first thing in the file.  */
+#if defined(__svr4__) && defined(__sgi__) && !HAVE_ALLOCA_H /* IRIX */
+# undef HAVE_ALLOCA_H
+# define HAVE_ALLOCA_H 1
+#endif
+
+#ifndef HAVE_ALLOCA
+#if HAVE_ALLOCA_H
+# include <alloca.h>
+#else
+# ifdef _AIX
+# pragma alloca
+# else
+#  ifndef alloca /* predefined by HP cc +Olibcalls */
+#  if !defined(__svr4__) && !defined(__sgi__)  /* not on IRIX */
+    char *alloca ();
+#  endif
+#  endif
+# endif
+#endif
+#endif
+
+/* Get string functions */
+#if STDC_HEADERS
+# include <string.h>
+#else
+# if HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+# if !HAVE_STRCHR
+#  define strchr index
+#  define strrchr rindex
+# endif
+# if !HAVE_MEMCPY
+#  define memcpy(d, s, n) bcopy ((s), (d), (n))
+#  define memmove(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#if HAVE_SIZE_T
+#include <stddef.h>
+#else
+typedef unsigned int size_t;
+#endif
+
+#if !HAVE_STRDUP
+extern char *strdup( const char * );
+#endif
+
+#if !HAVE_STRTOL
+extern long strtol( const char *, char **, int );
+#endif
+
+#if !HAVE_STRTOUL
+extern unsigned long int strtoul( const char *, char **, int );
+#endif
+
+#if !HAVE_SNPRINTF
+extern int snprintf(char *str, size_t size, const char *format, ...);
+#endif
+
+#if !HAVE_VSNPRINTF
+#include <stdarg.h>
+extern int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif
+
+#if !HAVE_INET_ATON
+#define inet_aton(a,b) (b)->s_addr = inet_addr(a)
+#endif
+
+#if HAVE_WINT_T
+#include <wchar.h>
+#else
+typedef unsigned int wint_t;
+#endif
+
+#if !HAVE_ISWALNUM
+extern int iswalnum__ (wint_t wc);
+#else
+#define iswalnum__ iswalnum
+#endif
+
+#if !HAVE_ISWSPACE
+extern int iswspace__ (wint_t wc);
+#else
+#define iswspace__ iswspace
+#endif
+
+#if !HAVE_TOWLOWER
+extern wint_t towlower__ (wint_t wc);
+#else
+#define towlower__ towlower
+#endif
+
+#if HAVE_WCHAR_T
+#include <stddef.h>
+#else
+typedef unsigned int wchar_t;
+#endif
+
+#if HAVE_DECL_CODESET
+#include <langinfo.h>
+#else
+extern const char * nl_langinfo (int ITEM);
+#define CODESET 1234
+#endif
+
+#ifndef SYSTEM_UTF8_FUNCS
+#define MB_CUR_MAX__ 6
+#else
+#define MB_CUR_MAX__ MB_CUR_MAX
+#endif
+
+#if HAVE_MBSTATE_T
+#include <wchar.h>
+#else
+typedef char mbstate_t;
+#endif
+
+#if !HAVE_STRLCPY
+extern size_t strlcpy (char *s, const char * wc, size_t size);
+#endif
+
+#if !HAVE_STRLCAT
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#if !HAVE_WCRTOMB
+extern size_t wcrtomb__ (char *s, wchar_t wc, mbstate_t *ps);
+#else
+#define wcrtomb__ wcrtomb
+#endif
+
+#if !HAVE_WCTOMB
+extern int wctomb__ (char *s, wchar_t wc);
+#else
+#define wctomb__ wctomb
+#endif
+
+#if !HAVE_MBRLEN
+extern size_t mbrlen__ (const char *s, size_t n, mbstate_t *ps);
+#else
+#define mbrlen__ mbrlen
+#endif
+
+#if !HAVE_MBRTOWC
+extern size_t mbrtowc__ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+#else
+#define mbrtowc__ mbrtowc
+#endif
+
+#if !HAVE_MBSTOWCS
+extern size_t mbstowcs__ (wchar_t *dest, const char *src, size_t n);
+#else
+#define mbstowcs__ mbstowcs
+#endif
+
+#if !HAVE_SETENV
+extern int setenv(const char *name, const char *value, int overwrite);
+#endif
+
+#if !HAVE_MBTOWC
+extern int mbtowc__ (wchar_t *pwc, const char *s, size_t n);
+#else
+#define mbtowc__ mbtowc
+#endif
+
+#if !HAVE_WCWIDTH
+#define wcwidth__(x) (1)
+#endif
+
+#if !HAVE_INITGROUPS
+#define initgroups(a,b)
+#endif
+
+#if defined(HAVE_WAITPID) && !defined(HAVE_WAIT3)
+#define wait3(status,options,rusage) \
+        waitpid(-1, (status),(options))
+#endif
+
+#if USE_PLUGIN
+# if HAVE_DLFCN_H
+#  include <dlfcn.h>
+   typedef void *  lt_dlhandle;
+#  define lt_dlsym dlsym
+#  define lt_dlopen(filename) dlopen(filename, RTLD_NOW)
+#  define lt_dlclose dlclose
+#  define lt_dlerror dlerror
+# else
+#  include <ltdl.h>
+# endif
+#endif
+
+/* Get time functions */
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+/* Include some standard header files. */
+#include <stdio.h>
+#if HAVE_UNISTD_H
+# include <sys/types.h>
+# include <unistd.h>
+# include <stdlib.h>
+#endif
+
+/* Always use local (libmaa) getopt */
+#include <getopt.h>
+
+/* We actually need a few non-ANSI C things... */
+#if defined(__STRICT_ANSI__)
+extern char     *strdup( const char * );
+extern int      fileno( FILE *stream );
+extern FILE     *fdopen( int fildes, const char *mode );
+extern void     bcopy( const void *src, void *dest, int n );
+extern long int random( void );
+extern void     srandom( unsigned int );
+#endif
+
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+/* Provide assert() */
+#include <assert.h>
+
+/* Provide stdarg support */
+#include <stdarg.h>
+
+/* Provide networking stuff */
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+/* Provide mmap stuff */
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+#endif
+
+/* System dependent declarations: Many brain damaged systems don't provide
+declarations for standard library calls.  We provide them here for
+situations that we know about. */
+#include "decl.h"
+
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+/* Handle getopt correctly */
+#if HAVE_GETOPT_H
+# include <getopt.h>
+#else
+#if !HAVE_GETOPT_LONG
+int getopt_long(int argc, char * const argv[],
+                  const char *optstring,
+                  const struct option *longopts, int *longindex);
+extern int  optind;
+extern char *optarg;
+#endif
+#endif
+
+                               /* Local stuff */
+#ifndef max
+#define max(a,b) ((a)>(b)?(a):(b))
+#endif
+
+#define HAVE_UTF8 1
+
+#endif /* _DICTP_H_ */
diff --git a/src/plugins/stardict/include/dictd.h b/src/plugins/stardict/include/dictd.h
new file mode 100644 (file)
index 0000000..0e68b9c
--- /dev/null
@@ -0,0 +1,127 @@
+/* dictd.h -- Header file for dict program
+ * Created: Fri Dec  2 20:01:18 1994 by faith@dict
+ * Revised: Mon Apr 22 15:47:26 2002 by faith@dict.org
+ * Copyright 1994-2000, 2002 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DICTD_H_
+#define _DICTD_H_
+
+#include "dictP.h"
+#include "maa.h"
+#include "codes.h"
+#include "defs.h"
+
+#include "net.h"
+#include <errno.h>
+
+#include <netdb.h>
+#include <signal.h>
+/*
+#ifdef __osf__
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <sys/wait.h>
+#include <grp.h>
+#include <arpa/inet.h>
+*/
+
+extern const char *daemon_service;
+extern int client_delay;
+extern int depth;
+extern int _dict_daemon_limit;
+extern int _dict_markTime;
+extern const char *logFile;
+extern const char *pidFile;
+extern int logOptions;
+extern const char *bind_to;
+extern int useSyslog;
+extern const char *logFile;
+
+extern int daemon_service_set;
+extern int logFile_set;
+extern int pidFile_set;
+extern int _dict_markTime_set;
+extern int client_delay_set;
+extern int depth_set;
+extern int _dict_daemon_limit_set;
+extern int syslog_facility_set;
+extern int locale_set;
+extern int default_strategy_set;
+extern int bind_to_set;
+
+
+
+
+extern void       dict_disable_strat (dictDatabase *db, const char* strat);
+
+extern void       dict_dump_list( lst_List list );
+extern void       dict_destroy_list( lst_List list );
+
+extern int        dict_destroy_datum( const void *datum );
+
+#ifdef USE_PLUGIN
+extern int        dict_plugin_open (dictDatabase *db);
+extern void       dict_plugin_close (dictDatabase *db);
+#endif
+
+/* dictd.c */
+
+extern void set_minimal (void);
+
+extern void       dict_initsetproctitle( int argc, char **argv, char **envp );
+extern void       dict_setproctitle( const char *format, ... );
+extern const char *dict_format_time( double t );
+extern const char *dict_get_hostname( void );
+extern const char *dict_get_banner( int shortFlag );
+
+extern dictConfig *DictConfig;  /* GLOBAL VARIABLE */
+extern int        _dict_comparisons; /* GLOBAL VARIABLE */
+extern int        _dict_forks; /* GLOBAL VARIABLE */
+extern const char *locale;
+
+extern const char *locale;
+extern       int   inetd;    /* 1 if --inetd is applied, 0 otherwise */
+
+/*
+  If the filename doesn't start with / or .,
+  it is prepended with DICT_DIR
+*/
+extern const char *postprocess_dict_filename (const char *fn);
+/*
+  If the filename doesn't start with / or .,
+  it is prepended with PLUGIN_DIR
+*/
+extern const char *postprocess_plugin_filename (const char *fn);
+
+/* daemon.c */
+
+extern int  dict_daemon( int s, struct sockaddr_in *csin, char ***argv0,
+                        int delay_, int error );
+extern int  dict_inetd( char ***argv0, int delay_, int error );
+extern void daemon_terminate( int sig, const char *name );
+
+/* */
+extern int        utf8_mode;
+
+                               /* dmalloc must be last */
+#ifdef DMALLOC_FUNC_CHECK
+# include "dmalloc.h"
+#endif
+
+#endif
diff --git a/src/plugins/stardict/include/dictzip.h b/src/plugins/stardict/include/dictzip.h
new file mode 100644 (file)
index 0000000..163cc26
--- /dev/null
@@ -0,0 +1,120 @@
+/* dictzip.h -- Header file for dict program
+ * Created: Fri Dec  2 20:01:18 1994 by faith@dict.org
+ * Revised: Fri Dec 22 06:06:31 2000 by faith@dict.org
+ * Copyright 1994, 1995, 1996, 1997, 2000 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DICTZIP_H_
+#define _DICTZIP_H_
+
+//#include "maa.h"
+#include <zlib.h>
+//#include "dictd.h"
+
+                               /* End of configurable things */
+
+#define BUFFERSIZE 10240
+#define DBG_VERBOSE     (0<<30|1<< 0) /* Verbose                           */
+#define DBG_ZIP         (0<<30|1<< 1) /* Zip                               */
+#define DBG_UNZIP       (0<<30|1<< 2) /* Unzip                             */
+#define DBG_SEARCH      (0<<30|1<< 3) /* Search                            */
+#define DBG_SCAN        (0<<30|1<< 4) /* Config file scan                  */
+#define DBG_PARSE       (0<<30|1<< 5) /* Config file parse                 */
+#define DBG_INIT        (0<<30|1<< 6) /* Database initialization           */
+
+#define HEADER_CRC 0           /* Conflicts with gzip 1.2.4               */
+
+/* Use of the FEXTRA fields.  The FEXTRA area can be 0xffff bytes long, 2
+   bytes of which are used for the subfield ID, and 2 bytes of which are
+   used for the subfield length.  This leaves 0xfffb bytes (0x7ffd 2-byte
+   entries or 0x3ffe 4-byte entries).  Given that the zip output buffer must
+   be 10% + 12 bytes larger than the input buffer, we can store 58969 bytes
+   per entry, or about 1.8GB if the 2-byte entries are used.  If this
+   becomes a limiting factor, another format version can be selected and
+   defined for 4-byte entries. */
+
+
+                               /* Output buffer must be greater than or
+                                   equal to 110% of input buffer size, plus
+                                   12 bytes. */
+#define OUT_BUFFER_SIZE 0xffffL
+
+#define IN_BUFFER_SIZE ((unsigned long)((double)(OUT_BUFFER_SIZE - 12) * 0.89))
+
+#define PREFILTER_IN_BUFFER_SIZE (IN_BUFFER_SIZE * 0.89)
+
+
+/* For gzip-compatible header, as defined in RFC 1952 */
+
+                               /* Magic for GZIP (rfc1952)                */
+#define GZ_MAGIC1     0x1f     /* First magic byte                        */
+#define GZ_MAGIC2     0x8b     /* Second magic byte                       */
+
+                               /* FLaGs (bitmapped), from rfc1952         */
+#define GZ_FTEXT      0x01     /* Set for ASCII text                      */
+#define GZ_FHCRC      0x02     /* Header CRC16                            */
+#define GZ_FEXTRA     0x04     /* Optional field (random access index)    */
+#define GZ_FNAME      0x08     /* Original name                           */
+#define GZ_COMMENT    0x10     /* Zero-terminated, human-readable comment */
+#define GZ_MAX           2     /* Maximum compression                     */
+#define GZ_FAST          4     /* Fasted compression                      */
+
+                               /* These are from rfc1952                  */
+#define GZ_OS_FAT        0     /* FAT filesystem (MS-DOS, OS/2, NT/Win32) */
+#define GZ_OS_AMIGA      1     /* Amiga                                   */
+#define GZ_OS_VMS        2     /* VMS (or OpenVMS)                        */
+#define GZ_OS_UNIX       3      /* Unix                                    */
+#define GZ_OS_VMCMS      4      /* VM/CMS                                  */
+#define GZ_OS_ATARI      5      /* Atari TOS                               */
+#define GZ_OS_HPFS       6      /* HPFS filesystem (OS/2, NT)              */
+#define GZ_OS_MAC        7      /* Macintosh                               */
+#define GZ_OS_Z          8      /* Z-System                                */
+#define GZ_OS_CPM        9      /* CP/M                                    */
+#define GZ_OS_TOPS20    10      /* TOPS-20                                 */
+#define GZ_OS_NTFS      11      /* NTFS filesystem (NT)                    */
+#define GZ_OS_QDOS      12      /* QDOS                                    */
+#define GZ_OS_ACORN     13      /* Acorn RISCOS                            */
+#define GZ_OS_UNKNOWN  255      /* unknown                                 */
+
+#define GZ_RND_S1       'R'    /* First magic for random access format    */
+#define GZ_RND_S2       'A'    /* Second magic for random access format   */
+
+#define GZ_ID1           0     /* GZ_MAGIC1                               */
+#define GZ_ID2           1     /* GZ_MAGIC2                               */
+#define GZ_CM            2     /* Compression Method (Z_DEFALTED)         */
+#define GZ_FLG          3      /* FLaGs (see above)                       */
+#define GZ_MTIME         4     /* Modification TIME                       */
+#define GZ_XFL           8     /* eXtra FLags (GZ_MAX or GZ_FAST)         */
+#define GZ_OS            9     /* Operating System                        */
+#define GZ_XLEN         10     /* eXtra LENgth (16bit)                    */
+#define GZ_FEXTRA_START 12     /* Start of extra fields                   */
+#define GZ_SI1          12     /* Subfield ID1                            */
+#define GZ_SI2          13      /* Subfield ID2                            */
+#define GZ_SUBLEN       14     /* Subfield length (16bit)                 */
+#define GZ_VERSION      16      /* Version for subfield format             */
+#define GZ_CHUNKLEN     18     /* Chunk length (16bit)                    */
+#define GZ_CHUNKCNT     20     /* Number of chunks (16bit)                */
+#define GZ_RNDDATA      22     /* Random access data (16bit)              */
+
+#define DICT_UNKNOWN    0
+#define DICT_TEXT       1
+#define DICT_GZIP       2
+#define DICT_DZIP       3
+
+
+#endif
diff --git a/src/plugins/stardict/include/engine API.h b/src/plugins/stardict/include/engine API.h
new file mode 100755 (executable)
index 0000000..86b40da
--- /dev/null
@@ -0,0 +1,898 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef   _DICTIONARY_ENGINE_BASE
+#define   _DICTIONARY_ENGINE_BASE
+
+#ifdef    __cplusplus
+       extern "C" {
+#endif
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// header with gnu library for C - most of types and functions needed it (all
+// started from g* and g_*().
+#include <glib.h>
+//------------------------------------------------------------------------------
+
+#define _GLOBAL_FUNCTIONS_NAME_ "engine_global_functions"
+
+//______________________________________________________________________________
+// *****************************************************************************
+//******************************************************* GLOBAL MACROS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Checks if module is peaceable with concrete location.
+ *
+ * If user of engine module want to know if concrete module can handle concrete 
+ * location, he can call <i>dict_eng_module_check()</i>and check the result 
+ * of this function.
+ *
+ * @param module :: <b>EngineModule</b> - module engine which will be testing
+ * @param location :: <b>gchar*</b> - location on wich engine will be testing
+ * @return <i><b>gboolean</b></i> :: tells if location <i>location</i> can be 
+ * handled by module <i>module</i>
+ */
+#define         dict_eng_module_check(module,location)   \
+                        ( (module).engine_check( (location) ) )
+//------------------------------------------------------------------------------
+/** \brief Get short description of engine module.
+ *
+ * If there is need to present to the user of end programm some information 
+ * about enigne he is using, we can call dict_eng_module_get_description() and
+ * print/show the result of this call.
+ *
+ * @param module :: <b>EngineModule</b>- module engine which description we want
+ * @return <i><b>gchar*</b></i> :: there is string, decribing module engine 
+ * <i>module</i>, in this pointer. User should NOT free this pointer as it 
+ * points to static table of chars
+ */
+#define         dict_eng_module_get_description(module)   \
+                        ( (module).engine_description() )
+//------------------------------------------------------------------------------
+/** \brief Get version of engine module.
+ *
+ * Sometimes it could be useful to get know what version of engine module we are
+ *  using. We can call this function to retrieve these informations from module.
+ * Note that version information could be also placed in description of module, 
+ * but here user will get only string representing version, what could be needed
+ * in some situation (e.g.: if end-user will have two the same module, then 
+ * programm has to decide which should be used, or ask user).
+ *
+ * @param module :: <b>EngineModule</b> - module engine which implementation 
+ * version we want
+ * @return <i><b>gchar*</b></i> :: pointer to string representing module 
+ * <i>module</i>version. User should NOT free this pointer as it points to 
+ * static table of chars
+ */
+#define         dict_eng_module_get_version(module)   \
+                        ( (module).engine_version() )
+//------------------------------------------------------------------------------
+/** \brief Get format on which working engnine module.
+ *
+ * If we want to know on what dictionary format works current engine module, we 
+ * can call this function. As a result we will retrieve string telling us what 
+ * format-based is concrete engine module (e.g. XDXF, WordNet etc.).
+ *
+ * @param module :: <b>EngineModule</b> - engine module which dictionary format
+ * we want to get
+ * @return <i><b>gchar*</b></i> :: string representing format of dictionary on 
+ * which module <i>module</i> can works. User should NOT free this pointer as 
+ * it points to static table of chars
+ */
+#define         dict_eng_module_get_format(module)   \
+                        ( (module).engine_version() )
+//------------------------------------------------------------------------------
+/** \brief Open concrete dictionary.
+ *
+ * This functions opens location (this could mean: filename, URL, any other way 
+ * to specify concrete localization of dictionary database). To be more sure 
+ * that this function will be sucefull, user can call before 
+ * dict_eng_module_check() to check if this module can handle dictionary under 
+ * passed location. But this do not warrant that calling 
+ * dict_eng_module_create() will not fail. User should check the result of 
+ * function to be sure that everything was ok.
+ *
+ * @param module :: <b>EngineModule</b> - engine module which should be used to 
+ * open location <i>location</i>
+ * @param location :: <b>gchar*</b> - location of dictionary database (file, 
+ * directory, URL etc.)
+ * @param flags :: <b>EngineOptimizationFlag</b> - flags defines how program 
+ * shoud automaticlly use optimization methods for opened dictionary
+ * @return <i><b>Engine*</b></i> :: pointer to new enigne structure; After use, 
+ * if this structure will not be needed anymore, user should call 
+ * dict_eng_destroy() to free memory
+ * \sa EngineOptimizationFlag :|: dict_eng_module_check() :|: EngineModule :|: 
+ * Engine
+*/
+#define         dict_eng_module_create(module,location,flags)   \
+        ( (module).engine_create(  (location), (flags), NULL, NULL, 0.01 ) )
+//------------------------------------------------------------------------------
+/** \brief Open concrete dictionary - define handler for signal of progress
+ *
+ * This functions is similiar to dict_eng_module_create(module,location,flags).
+ * In addition to it, this function get additional parameters, defining how
+ * engine should "inform" the user about progress of eventuall caching proccess.
+ *
+ * @param module :: <b>EngineModule</b> - engine module which should be used to 
+ * open location <i>location</i>
+ * @param location :: <b>gchar*</b> - location of dictionary database (file, 
+ * directory, URL etc.)
+ * @param flags :: <b>EngineOptimizationFlag</b> - flags defines how program 
+ * shoud automaticlly use optimization methods for opened dictionary
+ * @param progress_handler :: <b>cb_progress</b> - handler which will be called 
+ * from time to time, to give to the user any response about caching progress
+ * @param progress_data :: <b>gpointer</b> - pointer to data which will be given
+ * as a user_data argument for progress_data function during its calling
+ * @param seed :: <b>gdouble</b> - defines after how big step (in percentage)
+ * in progress of caching, engine send new signal - call progress_handler with
+ * actual value of progress
+ * @return <i><b>Engine*</b></i> :: pointer to new enigne structure; After use, 
+ * if this structure will not be needed anymore, user should call 
+ * dict_eng_destroy() to free memory
+ * \sa EngineOptimizationFlag :|: dict_eng_module_check() :|: EngineModule :|: 
+ * Engine :|: cb_progress
+ */
+#define         dict_eng_module_create_ext(module,                      \
+                                           location,                    \
+                                           flags,                       \
+                                           progress_handler,            \
+                                           progress_data,               \
+                                           seed                         \
+                                           )  (                         \
+                       (module).engine_create( (location),              \
+                                               (flags),                 \
+                                               (progress_handler),      \
+                                               (progress_data),         \
+                                               (seed)                   \
+                                             ))
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** CONCRETE DICTIONARY MACROS SECTION:
+//------------------------------------------------------------------------------
+#define         dict_eng_set_progress_seed(engine, signal, val) (              \
+                        (engine) -> engine_set_progress_seed( (engine),        \
+                                                              (signal),        \
+                                                              (val)            \
+                                                            ))
+//------------------------------------------------------------------------------
+
+#define         dict_eng_set_auto_free(engine, state) ( \
+                        (engine) -> engine_set_auto_free( (engine), (state) )
+//------------------------------------------------------------------------------
+/** \brief Activate optimization mechanizms for concrete engine.
+ *
+ * Every engine could have some optimization methods. By calling this function 
+ * we enabled this option. For the user of engine it is not important what kind
+ * of optimization is used in current engine, how does it work etc. It should 
+ * be opaque for engine's users.
+ *  
+ * @param engine :: <b>Engine*</b> - pointer to engine which should optimized
+ * @return <i><b>void</b></i> :: nothing. This function only take a chance to 
+ * make engine working faster, but it is not said that every step 
+ * will be succesful. But even if not - engine has to work properly.
+ * \sa dict_eng_module_create() :|: dict_eng_is_optimized() :|: Engine
+ */
+#define         dict_eng_optimize(engine)  \
+                        ((engine) -> engine_optimize( (engine) ))
+//------------------------------------------------------------------------------
+/** \brief Checks if current engine has activated optimization.
+ *
+ * User can call this function to get know if concrete engine has enabled 
+ * optimization. Optimization can be activated by calling dict_eng_optimize() 
+ * or passing ENGINE_CREATE or ENGINE_REFRESH flags to dict_eng_module_create()
+ * while opening concrete dictionary. 
+ *  
+ * @param engine :: <b>Engine*</b> - pointer to engine which should be checked 
+ * if is optimized now
+ * @return <i><b>gboolean</b></i> :: nothing. This function only take a chance 
+ * to make engine working faster, but it is not said that every step 
+ * will be succesful
+ * \sa dict_eng_optimize() :|: Engine :|: EngineOptimizationFlag
+ */
+#define         dict_eng_is_optimized( engine )  \
+                        ((engine) -> engine_is_optimized( (engine) ))
+//------------------------------------------------------------------------------
+/** \brief To get know from what location was created current dictionary.
+ *
+ * If user of engine want to get know from what locatione exactly was created 
+ * concrete engine, he could call this function. It returns string, most likely 
+ * the same as the one passed earlier to dict_eng_module_create() function 
+ * as a <i>location</i> argument.
+ *  
+ * @param engine :: <b>Engine*</b> - dictionary from which we want to get 
+ * location 
+ * @return <i><b>gchar*</b></i> :: pointer to chars, from which concrete 
+ * dictionary was created
+ * \sa dict_eng_module_create()
+ */
+#define         dict_eng_get_location(engine)    \
+                        ((engine) -> engine_location( (engine) ))
+//------------------------------------------------------------------------------
+/** \brief Tells if last operation was sucesfull.
+ *
+ * If user want to be sure that everything was ok, during last operation 
+ * (it has finished with success), he has to check if dict_eng_get_last_status()
+ * is equal to ENGINE_NO_ERROR. If not, he can also find the reason 
+ * why operation failed.
+ * @param engine :: <b>Engine*</b> - dictionary which last operation's returned 
+ * code we want to get
+ * @return <i><b>EngineStatus</b></i> :: finish code of last operation
+ * \sa EngineStatus :|: dict_eng_state_message()
+ */
+#define         dict_eng_get_last_status(engine)    \
+                        ((engine) -> engine_error( (engine) ))
+//------------------------------------------------------------------------------
+/** \brief Translate pure state code to meaningfull message.
+ *
+ * If there was a error during engine was working, we can present to the user 
+ * the reason for this error in meaningfull form.
+ *
+ * @param error :: <b>EngineState</b> - code which we want to translate
+ * @return <i><b>gchar*</b></i> :: message describing concrete error code
+ * \sa EngineStatus :|: dict_eng_state_message()
+ */
+#define         dict_eng_state_message(error)     \
+                        ((engine) -> engine_error_message( (error) ))
+//------------------------------------------------------------------------------
+/** \brief Destroy gently and completly current dictionary.
+ *
+ * When user do not need anymore concrete dictionary, he must destroy it to 
+ * free memory allocated by this dictionary. It will close avery opened file 
+ * descriptor, free any additional memory block allocated while engine was 
+ * working etc. User are not allowed to call free() on dictionary without 
+ * calling before dict_eng_destroy().
+ *  
+ * @param engine :: <b>Engine*</b> - pointer to dictionary which is not
+ * needed anymore
+ * @return <i><b>void</b></i> :: nothing. This function should work properly,
+ * and free any resources which arelady are in use by current dictionary.
+ * \sa dict_eng_module_create() :|: Engine
+ */
+#define         dict_eng_destroy(engine)    \
+                        ((engine) -> engine_close( (engine) ))
+//------------------------------------------------------------------------------
+/** \brief Start searching for words list.
+ *
+ * This function starts searching for words list. User should set before 
+ * callback for ENGINE_WORD_LIST_SIGNAL, to be able to retrieve words list, 
+ * because this function do not return any value.
+ *  
+ * @param engine :: <b>Engine*</b> - pointer to dictionary in which we 
+ * are looking for words matching to pattern
+ * @param pattern :: <b>gchar*</b> - string representing pattern to which 
+ * returned word should be matching
+ * @return <i><b>void</b></i> :: nothing. Result of searching can be retrieved 
+ * by callback for signal ENGINE_WORD_LIST_SIGNAL
+ * \sa dict_eng_search_word_translation() :|: 
+ * dict_eng_search_word_translation_extended() :|: dict_eng_set_callback() :|: 
+ * ENGINE_WORD_LIST_SIGNAL
+ */
+#define         dict_eng_search_word_list(engine,pattern)    \
+                        ((engine) -> engine_search_word_list( (engine),        \
+                                                              (pattern)        \
+                                                            ))
+//------------------------------------------------------------------------------
+/** \brief Start searching for word translation in dictionary.
+ *
+ * Start searching for translation of word. To be able to retrieve translation 
+ * user should use callback for ENGINE_WORD_TRANSLATION_SIGNAL signal.
+ *  
+ * @param engine :: <b>Engine*</b> - dictionary in which we want find word's 
+ * translation
+ * @param word :: <b>gchar*</b> - string representing word which translation 
+ * we are looking for
+ * @return <i><b>void</b></i> :: nothing. Result of searching can be retrieved 
+ * by callback for signal ENGINE_WORD_TRANSLATION_SIGNAL
+ * \sa dict_eng_search_word_list() :|: 
+ * dict_eng_search_word_translation_extended() :|: dict_eng_set_callback() :|: 
+ * ENGINE_WORD_TRANSLATION_SIGNAL
+ */
+#define         dict_eng_search_word_translation(engine,word)    \
+                        ((engine) -> engine_search_word_translation( (engine), \
+                                                                     (word)    \
+                                                                   ))
+//------------------------------------------------------------------------------
+/** \brief Start searching for extended word translation in dictionary.
+ *
+ * Start searching for extended  translation of word. To be able to retrieve 
+ * translation user should use callback for ENGINE_WORD_TRANSLATION_SIGNAL 
+ * signal. Extended means that retrieved translation's string could be some more
+ * than plain text (e.g. HTML, Image, etc.). User of engine should know what 
+ * kind of data will retrieve ofter calling this method.
+ *
+ * \todo This option are in projecting phase. In the future callback for 
+ * ENGINE_WORD_TRANSLATION_SIGNAL should take parameter <i>gpointer</i> than 
+ * <i>gchar*</i> to make possible for user of engine to retrieve data different 
+ * than gchar*. There shold be also some additional function letting know user 
+ * what kind of data he will retrieve.
+ *  
+ * @param engine :: <b>Engine*</b> - dictionary in which we want find word's 
+ * translation
+ * @param word :: <b>gchar*</b> - string representing word which translation 
+ * we are looking for
+ * @return <i><b>void</b></i> :: nothing. Result of searching can be retrieved 
+ * by callback for signal ENGINE_WORD_TRANSLATION_SIGNAL
+ * \sa dict_eng_search_word_list() :|: dict_eng_search_word_translation() :|: 
+ * dict_eng_set_callback() :|: ENGINE_WORD_TRANSLATION_SIGNAL
+ */
+#define         dict_eng_search_word_translation_extended(engine,word)   \
+                ((engine) -> engine_search_word_translation_extended((engine), \
+                                                                     (pattern) \
+                                                                     ))
+//------------------------------------------------------------------------------
+/** \brief Setting any callback for current dictionary.
+ *
+ * As long as functions which search for words list or translation do not 
+ * return any value, user has to set callback which will be called after 
+ * searching end. This make easy calling these functions from other proccess, 
+ * threads etc. This function sets callbacks for every signal.
+ *  
+ * @param engine :: <b>Engine*</b> - dictionary for which we want set some
+ * callback
+ * @param signal :: <b>gchar*</b> - string representing for what signal we want
+ * to set callback
+ * @param c_handler :: <b>gpointer</b> - pointer to function which will be 
+ * called after signal <i>signal</i> will occured
+ * @param data :: <b>gpointer</b> - pointer to user data, which will be always 
+ * passed to callback <i>c_handler</i> for signal <i>signal</i>
+ * as a last argument
+ * @return <i><b>gpointer</b></i> :: pointer to previous callback; if this 
+ * callbacks was not set yet, it returns NULL
+ * \sa cb_word_list :|: cb_word_translation :|:  ENGINE_WORD_LIST_SIGNAL :|: 
+ * ENGINE_WORD_TRANSLATION_SIGNAL
+ */
+#define         dict_eng_set_callback(engine,signal,c_handler,data)     \
+                        ((engine) -> engine_set_callback( (engine),     \
+                                                          (signal),     \
+                                                          (c_handler),  \
+                                                          (data)        \
+                                                        ))
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************ SIGNALS DEFINITION FOR CALLBACKS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Signal definition for callback called when word list was found.
+ *
+ * ENGINE_WORD_LIST_SIGNAL defines name for signal passed to 
+ * dict_eng_set_callback() function as a signal parameter. Function set 
+ * to handle this signal should be called from dict_eng_search_word_list() only
+ * and have cb_word_list type.
+ * <b>NOTE:</b> programmers must not use value of ENGINE_WORD_LIST_SIGNAL 
+ * directly!
+ * \sa cb_word_list :|: dict_eng_set_callback() :|: dict_eng_search_word_list() 
+ * :|: ENGINE_WORD_TRANSLATION_SIGNAL
+ */
+#define ENGINE_WORD_LIST_SIGNAL         "on_word_list_found"
+//------------------------------------------------------------------------------
+/** \brief Signal definition for callback called when word trans. was found.
+ *
+ * ENGINE_WORD_TRANSLATION_SIGNAL defines name for signal passed to 
+ * dict_eng_set_callback() function as a signal parameter. Function set 
+ * to handle this signal should be called from 
+ * dict_eng_search_word_translation() and  
+ * dict_eng_search_word_translation_extended() only and have cb_word_translation.
+ * <b>NOTE:</b> programmers must not use value of ENGINE_WORD_LIST_SIGNAL 
+ * directly!
+ * \sa cb_word_translation :|: dict_eng_set_callback() :|: 
+ * dict_eng_search_word_translation() :|: ENGINE_WORD_LIST_SIGNAL
+ */
+#define ENGINE_WORD_TRANSLATION_SIGNAL  "on_word_translation_found"
+//------------------------------------------------------------------------------
+#define ENGINE_PROGRESS_OPTIMIZING_SIGNAL "on_progress_optimizing"
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************** DEFINITIONS OF ENUMS TYPES:
+//------------------------------------------------------------------------------
+/** \brief Codes of flags used to auto optimizing dictionary file.
+ * 
+ * - Enum type for flags used as a flags parameter for dict_eng_module_create() 
+ * function.
+ */
+typedef enum
+{
+        /**
+         * :: flags says thatoptimization (any methodsof optimalization) should 
+         * be enabled. If optimization methods needs to make some files and 
+         * these files exists, enigne will just use it (do not refresh).
+         */
+        ENGINE_CREATE = 0, 
+        /**
+         * :: flags says that for this particular dictionary programm should 
+         * disable optimization.
+         */
+        ENGINE_NO,
+        /**
+         * :: the same flags as ENGINE_CREATE, but tells 
+         * dict_eng_module_create() function that even if file (or any 
+         * resources) for optimizatione methods exists, they should be 
+         * recreated/refreshed.
+         */
+        ENGINE_REFRESH 
+} EngineOptimizationFlag;
+//------------------------------------------------------------------------------
+/** \brief Codes of possible errors which can occured while engine is working.
+ * 
+ * - Enum type for errors' codes. One of this code is always in last error 
+ * variable (variable 'last error' is invisible for programmers - they should 
+ * use function engine_error() and optionally engine_error_message() to get know
+ * what kind of error occured).
+ */
+typedef enum
+{
+        /**
+         * :: there was no error - last action successed
+         */
+        ENGINE_NO_ERROR = 0,
+        /**
+         * :: file, which engine tried to read, has wrong format or 
+         * it is corrupted.
+         */
+        ENGINE_WRONG_FILE,
+        /**
+         * :: user do not have permission to read/open file, which engine tried
+         * to open/read.
+         */
+        ENGINE_COULDNT_READ,
+        /**
+         * :: file, on which engine tried to operate, do not exist
+         */
+        ENGINE_NO_FILE,     
+        /**
+         * :: while engine was working, "Out Of Memory" error occured
+         */
+        ENGINE_OUT_OF_MEMORY
+}
+EngineStatus;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************* DEFINITIONS OF CALLBACK'S TYPES:
+//------------------------------------------------------------------------------
+/** \brief Type of callback functions for retrieving word list.
+ * 
+ * Function which is set by dict_eng_set_callback() to signal 
+ * ENGINE_WORD_LIST_SIGNAL should be exactly this type.
+ *
+ * @param list :: <b>GArray*</b> - there will be all found words in this array
+ * @param pattern :: <b>gchar*</b> - pattern to which we have been looking for 
+ *      word lists
+ * @param error :: <b>EngineStatus</b> - error code; if everything was ok it is 
+ *      ENGINE_NO_ERROR
+ * @param user_data :: <b>gpointer</b> - data set by user to be passing to each 
+ *      callback for ENGINE_WORD_LIST_SIGNAL signal
+ */
+typedef void (*cb_word_list)(GArray* list,
+                             gchar* pattern,
+                             gpointer user_data,
+                             EngineStatus error);
+//------------------------------------------------------------------------------
+/** \brief Type of callback functions for retrieving word's translation.
+ * 
+ * Function which is set by dict_eng_set_callback() to signal 
+ * ENGINE_WORD_TRANSLATION_SIGNAL should be exactly this type.
+ *
+ * @param translation :: <b>gchar*</b> - translation of word <i>word</i>
+ * @param word :: <b>gchar*</b> - word which translation we already retrieved
+ * @param error :: <b>EngineStatus</b> - error code; if everything was ok it is 
+ *      ENGINE_NO_ERROR
+ * @param user_data :: <b>gpointer</b> - data set by user to be passing to each 
+ *      callback for ENGINE_WORD_TRANSLATION_SIGNAL signal
+ */
+typedef void (*cb_word_translation)(gchar* translation,
+                                    gchar* word,
+                                    gpointer user_data,
+                                    EngineStatus error);
+//------------------------------------------------------------------------------
+/** \brief Type of callback functions for updating progress bar.
+ * 
+ * Function which is set by dict_eng_set_callback() to signal 
+ * ENGINE_PROGRESS_OPTIMIZING_SIGNAL should be exactly this type.
+ *
+ * @param value :: <b>double</b> - current progres of process [0.0 - 1.0]
+ * @param user_data :: <b>gpointer</b> - data set by user to be passing to each 
+ *      callback for ENGINE_PROGRESS_OPTIMIZING_SIGNAL signal
+ * @param error :: <b>EngineStatus</b> - error code; if everything is ok it has 
+ *      ENGINE_NO_ERROR value
+ */
+typedef void (*cb_progress)(gdouble value,
+                            gpointer user_data,
+                            EngineStatus error);
+//------------------------------------------------------------------------------
+
+           
+//______________________________________________________________________________
+// *****************************************************************************
+//**************************************** DEFINITIONS OF BASIC FUNCTIONS TYPES:
+//------------------------------------------------------------------------------
+typedef struct _Engine Engine;
+/** \brief Type of function getting some chars from engine.
+ *
+ * Function of this type should be used for functions which intention is to get 
+ * some string from concrete dictionary.
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @return <i><b>gchar*</b></i> :: chars which represents some information 
+ *      depends on concrete functions (e.g engine path etc.)
+ */
+typedef gchar*   (*getting_char)(Engine* engine);
+//------------------------------------------------------------------------------
+/** \brief Type of function getting boolean statement from engine.
+ *
+ * Function of this type should be used for functions which intention is to get 
+ * boolean statement from concrete dictionary (e.g. to get know if engine has 
+ * cache file - is optimized). 
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions
+ *      has to work
+ * @return <i><b>gboolean</b></i> :: gboolean statement which gives programmers 
+ *      some information about state of dictionary/engine
+ */
+typedef gboolean (*getting_bool)(Engine* engine);
+//------------------------------------------------------------------------------
+/** \brief Type of function which hasn't got to return any value.
+ *
+ * Function of this type should be used for functions which intention is only 
+ * to do something on concrete dictionary (e.g. to make cache file etc).
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @return nothing. Functions of this type should only perform some action - 
+ *      there is no result
+ */
+typedef void     (*doing_only)(Engine* engine);
+//------------------------------------------------------------------------------
+/** \brief Type of function which can find words list from dictionary.
+ * 
+ * Function of this type should be used as a function for searching words list 
+ * matching to pattern.
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @param pattern :: <i>gchar*</i> - pointer to chars which describes pattern 
+ *      for searching words
+ * @return nothing. This function do not return anything - result should be 
+ *      retrieve by callbacks 
+ */
+typedef void     (*searching_word_list)(Engine* engine, gchar* pattern); 
+//------------------------------------------------------------------------------
+/** \brief Type of function which can find word's translation from dictionary.
+ * 
+ * Functions of this type should be used as a function for searching word 
+ * translation in concrete dictionary.
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @param word :: <i>gchar*</i> - pointer to chars which tells what word's 
+ *      translation we are looking for
+ * @return nothing. This function do not return anything - result should be 
+ *      retrieve by callback
+ */
+typedef void     (*searching_word_translation)(Engine* engine, gchar* word);
+//------------------------------------------------------------------------------
+/** \brief Type of function which can trans. error code to descriptive message.
+ * 
+ * Functions of this type should be used as <i>translator</i> from error code 
+ * to meaningful message.
+ *
+ * @param error :: <i>EngineStatus</i> - error to which we want get description
+ * @return <i><b>gchar*</b></i> :: chars which describes us what kind of error 
+ * occured (e.g. "Dictionary file has wrong file format or it is corrupted.")
+ */
+typedef gchar*   (*error_to_message)(EngineStatus error);
+//------------------------------------------------------------------------------
+/** \brief Type of function which should be used to set callbacks for signals.
+ * 
+ * Functions of this type should be used as a <i>setter</i> for new callback 
+ * functions
+ *
+ * @param engine :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @param signal  :: <i>gchars*</i> - pointer to chars which tell us what kind 
+ *      of event should new_functions handle (e.g. "word_list_found", 
+ *      "translation_found" etc.)
+ * @param c_handler :: <i>gpointer</i> - new callback function
+ * @param user_data :: <i>gpointer</i> - pointer do structure, which should be 
+ *      passed as a last argument when calling new mounted callback
+ * @return <i><b>gpointer</b></i> :: gpointer to previous callback. If NULL 
+ *      there could be some error so programmers should check by engine_error() 
+ *      function if there was some (if NULL and engine_error() return 
+ *      ENGINE_NO_ERROR that means that this callback was unused before).
+ * \sa ENGINE_WORD_LIST_SIGNAL :|: ENGINE_WORD_TRANSLATION_SIGNAL :|: 
+ * dict_eng_set_callback() :|: cb_word_list :|: cb_word_translation
+ */
+typedef gpointer (*setting_callbacks)(Engine* engine, 
+                                      gchar* signal, 
+                                      gpointer c_handler, 
+                                      gpointer user_data);
+//------------------------------------------------------------------------------
+/** \brief Type of function which can get some int value from dictionary.
+ * 
+ * Functions of this type should be used if programmer want to get some int 
+ * value from dictionary.
+ *
+ * @param enigne :: <i>Engine*</i> - pointer to engine on which this functions 
+ *      has to work
+ * @return <i><b>gint</b></i> :: int value which user wanted to get from 
+ *      dictionary
+ */
+typedef gint (*getting_int)(Engine* engine);
+//------------------------------------------------------------------------------
+typedef EngineStatus (*getting_status)(Engine* engine);
+//------------------------------------------------------------------------------
+typedef void (*setting_progress_seed)(Engine* engine,
+                                      gchar* signal,
+                                      gdouble seed);
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//*********************************** DEFINITIONS OF ADDITIONAL FUNCTIONS TYPES:
+//------------------------------------------------------------------------------
+/** \brief Additional functions type.
+ * 
+ * Functions of this type should be used to check if dictionary in location 
+ * could be handled by this engine.
+ *
+ * @param location :: <i>gchar*</i> - chars which describe location of 
+ *      dictionary to check
+ * @return <i><b>gboolean</i></b> :: statement telling us if this module could
+ *      or could not handle dictionary under location.
+ */
+typedef gboolean (*checking_compatibiliti)(gchar* location);
+//------------------------------------------------------------------------------
+/** \brief Additional functions type.
+ * 
+ * Functions of this type should be used to get some descriptions from 
+ * engine/module. Information retrievs by this kind of functions are global for
+ * module (e.g: description of handles fromat, description of module etc.).
+ *
+ * @return <i><b>gchar*</i></b> :: chars which we wanted
+ */
+typedef gchar*   (*getting_chars_engine)(void);
+//------------------------------------------------------------------------------
+/** \brief Additional functions type.
+ * 
+ * Functions of this type should be used to opening dictionary. 
+ * @param location :: <i>gchar*</i> - chars which describe where is the 
+ *      dictionary which we want to open
+ * @param flags :: <i>EngineOptimizationFlag</i> - flags to initialize/use 
+ *      optimization methods for opening dictionary.
+ * @return <i><b>gpointer</i></b> ::pointer to opened Engine. If NULL there was
+ *      some error - programmers should check error type by calling 
+ *      engine_error() function.
+ */
+typedef Engine*  (*creating_engine)(gchar* location,
+                                    EngineOptimizationFlag flags,
+                                    cb_progress progress_handler,
+                                    gpointer progress_data,
+                                    gdouble seed);
+//------------------------------------------------------------------------------
+/** \brief General dictionary structure.
+ *  
+ * This structure contains every data which are needed to make dictionary 
+ * working. Data of dictionary are invisible for user of finnal module. User can
+ * operate on dictionary with functions to which there are pointers in this 
+ * structure also. engine_data is for module programmer use only. Programmer of 
+ * module can put there any data he want. He should not give end user any 
+ * information about engine_data structure.
+ */
+struct _Engine
+{
+        void (*engine_set_auto_free)(Engine* engine, gboolean state);
+
+
+        /** \brief Getting location of dictionary.
+        *
+        * User can use this function if want to get location of concrete 
+        * dictionary.
+        * \sa getting_char
+        */
+        getting_char           engine_location;
+
+        /** \brief Getting information if this dictionary is cached.
+        *
+        * User can use this function if want to know is dictionary cached 
+        * actually.
+        * \sa getting_bool
+        */
+        getting_bool           engine_is_optimized;
+
+        /** \brief Making cache file for dictionary.
+        *
+        * User can use this function if want to make cache file for concrete 
+        * dictionary.
+        * \sa doing_only
+        */
+        doing_only                engine_optimize;
+
+        /** \brief Searching word list.
+        *
+        * User call this function to start searching for word list.
+        * \sa searching_word_list
+        */
+        searching_word_list        engine_search_word_list;
+
+        /** \brief Searching word's translation.
+        *
+        * User call this function to start searching for word's translation.
+        * \sa searching_word_translation
+        */
+        searching_word_translation   engine_search_word_translation;
+
+        /** \brief Searching word's translation (preformatted HTML).
+        *
+        * User call this function to start searching for word's translation. 
+        * It differs from engine_search_word_translation that it returns 
+        * preformatted string (HTML format).
+        * \sa searching_word_translation
+        */
+        searching_word_translation   engine_search_word_translation_extended;        
+
+        /** \brief Close dictionary.
+        *
+        * User call this if work with dictionary is finished and there is no 
+        * need to keep this further working.
+        * \sa doing_only
+        */
+        doing_only                engine_close;
+
+        /** \brief Functions return laste error which occured in dictionary.
+        *
+        * Programmer should use this function after each action to check if 
+        * there was not any errors.
+        * \sa getting_int
+        */
+        getting_status                  engine_error;
+
+        /** \brief <i>Tranlsate</i> error code to meaningful message.
+        *
+        * Programmer can call this function if want to get meaningful message 
+        * describes concrete error code
+        * \sa error_to_message
+        */
+        error_to_message            engine_error_message;
+
+        /** \brief Function to setting any callback for this dictionary.
+        * 
+        * This function can be used to set some callback function for concrete 
+        * dictionary. Programmer should always set callback "word_list_found" 
+        * and "word_translation_found". Developers of new modules should also 
+        * define for what kind of event end user will be able to set callback.
+        */
+        setting_callbacks     engine_set_callback;
+
+
+        setting_progress_seed   engine_set_progress_seed;
+
+        /** \brief Module's private data area. Used only by module programmer.
+        * 
+        * Here module programmer should keep their own data (e.g. some data for 
+        * searching optimalization etc.). Programmer whose only using module, 
+        * should not use engine_data at all.
+        */
+        gpointer engine_data;
+};
+//------------------------------------------------------------------------------
+/** \brief Structure that has pointers to helpfull functions for programmer.
+ *
+ * There are pointers to some functions in this structure. Programmer whom using 
+ * module could use it to get some useful informationa about module (e.g: format
+ * handled by module, it's version etc.). The most important functions are: \n
+ * engine_check() - to check if this module can handle concrete location \n
+ * engine_open() - to open location
+ */
+typedef struct  {
+        
+        /** \brief Function to check compatibility beetwen module and location.
+        *    
+        * Helps programmer to check if this concrete module was designed to work
+        * with dictionary under location passed as a argument to this function. 
+        * \sa checking_compatibiliti
+        */
+        checking_compatibiliti          engine_check;      
+
+        /** \brief Function to get some short description of module/engine.
+         *      
+         * This function returns short description of module, to make possible 
+         * displaying for end user what kind of module he is using.
+         * \sa getting_chars_engine
+         */  
+        getting_chars_engine       engine_description;
+
+        /** \brief Function to get module's format.
+        *    
+        * This function returns format of dictionaries which this module handles
+        * \sa getting_chars_engine
+        */
+        getting_chars_engine       engine_format;
+
+        /** \brief Function to get version of module.
+        *    
+        *  This functions return version of this module/engine.
+        * \sa getting_chars_engine
+        */
+        getting_chars_engine       engine_version;
+
+        /** \brief Function to open/create new dictionary.
+        *    
+        * This functions allow programmer to open/create module from concrete 
+        * location.
+        * \sa creating_engine
+        */
+        creating_engine                 engine_create;
+} 
+EngineModule;
+//------------------------------------------------------------------------------
+/** \brief Additional functions type.
+ * 
+ * There should be in each module exactly one function of this type named: 
+ * engine_global_functions. This function makes easier to load dynamically 
+ * module. For doing this then you need only to mapped only this one function
+ * and the rest will be avaiable from returned structure EngineModule.
+ *
+ * @return  <i><b>EngineModule</b></i> :: structure EngineModule from which you 
+ *      can call next functions
+ * \sa engine_global_functions()
+ */
+typedef EngineModule (*getting_additional)(void);
+//------------------------------------------------------------------------------
+/** \brief Function that helps programmer to load basic functions from module. 
+ *
+ * This function helps programmers to dynamically load module to their 
+ * programms. Only this function needed to be mapped from *.so file. Rest of 
+ * function are in returned structure EngineModule. User of module could mapped 
+ * himslef others functions from concrete modules, but it is not recommended as 
+ * far as developers of module could, in fact, give different names for 
+ * functions. In structure EngineModule names will be always the same. \n
+ * NOTE for module developer: this function should be always defined in your
+ * code, to help next programmers whose will be using yours module in theirs own
+ * programms.
+ * 
+ * @return <i><b>EngineModule</b></i> :: Structure EngineModule which members 
+ *      are functions for basic operations for this module
+ */
+extern EngineModule engine_global_functions(void);
+//------------------------------------------------------------------------------
+#define dict_eng_get_global_functions(library, variable) \
+       g_module_symbol ( (library), \
+                         _GLOBAL_FUNCTIONS_NAME_, \
+                         (gpointer)&(variable) \
+                       )
+          
+#ifdef __cplusplus
+}                     
+#endif     // END OF:    extern "C" {
+
+#endif     // END OF:    _DICTIONARY_ENGINE_BASE
diff --git a/src/plugins/stardict/include/engine_stardict.h b/src/plugins/stardict/include/engine_stardict.h
new file mode 100755 (executable)
index 0000000..fe68b17
--- /dev/null
@@ -0,0 +1,324 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY_ENGINE_STARDICT
+#define _DICTIONARY_ENGINE_STARDICT
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+#ifndef NOLOGS
+       #define sd_timer timer
+#else
+       #define sd_timer(flag,name) while(FALSE)
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - only for timers and files operations
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <unistd.h>
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header with gnome-vfs - recommended I/O API for maemo
+#include <libgnomevfs/gnome-vfs.h>
+//------------------------------------------------------------------------------
+// header with engine API
+#include <dictionary_engine.h>
+//------------------------------------------------------------------------------
+// header with standard gzip support library
+#include <zlib.h>
+//------------------------------------------------------------------------------
+// header with dict zip support library
+//#include "dictzip.h"
+#include <data.h>
+//#include "defs.h"
+//------------------------------------------------------------------------------
+// headero for ntohl conversion - network byte order to local host order
+#include <netinet/in.h>
+//------------------------------------------------------------------------------
+// header to g_memmove only
+#include <string.h>
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+
+#define WORD_LIST_BUFFER_LENGTH 16*1024
+
+#define _MIN(a,b)      ((a)<(b))?(a):(b)
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+static const gchar* DIC_ENG_VERSION = "0.1"; 
+static const gchar* DIC_ENG_FORMAT = "StarDict";
+static const gchar* DIC_ENG_DESCRIPTION = "This module operates on StarDict dictionaries. Version 0.1.";
+
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+#define ICON_PATH "/usr/share/pixmaps/stardict_icon.png"
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/** \brief Internal data structure for representing part of file.
+ */
+struct _FilePart {
+        guint offset;
+        guint length;
+};
+typedef struct _FilePart        FilePart;
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _SDData {
+        GnomeVFSHandle*         dictionary;
+        GnomeVFSHandle*         index;
+
+        gchar*                  dict_path;
+       gchar*                  ifo_file_name;
+       gchar*                  idx_file_name;
+       gboolean                idx_compressed;
+       gchar*                  dic_file_name;
+       gboolean                dic_compressed;
+       gchar*                  lang_from;
+       gchar*                  lang_to;
+       gchar*                  title;
+       gint                    word_count;
+       gint                    idx_file_length;
+       gchar*                  types;
+       gchar*                  icon;
+
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+       /* wrapper functions to access idx and dict files without checking
+        * it they are compressed or not - we decide about this while creating
+        * engine i function sd_engine_create()*/
+       gpointer        (*sd_open_idx)(gchar* filename);
+       //gpointer      (*sd_open_dic)(gchar* filename);
+       gint            (*sd_read_idx)(gpointer f, gchar* buffer, gint l);
+       //gint          (*sd_read_dic)(gpointer f, gchar* buffer, gint l);
+       glong           (*sd_seek_idx)(gpointer f, glong l, gchar from);
+       //glong         (*sd_seek_dic)(gpointer f, glong l, gchar from);
+       void            (*sd_close_idx)(gpointer f);
+       //void          (*sd_close_dic)(gpointer f);
+       gchar*          (*sd_read_dic_part)(FilePart* part, gchar* file);
+       gpointer        idx_file;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _SDData        SDData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+//static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// convert string to proper path name (no filename, no "/" at the ned, file
+// exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// fill out filenames of dictionary from directory in data->dict_path
+gboolean               sd_read_files_names(SDData* data);
+//------------------------------------------------------------------------------
+// fill out few information from IFO file
+gboolean               sd_parse_ifo_file(SDData* data);
+//------------------------------------------------------------------------------
+// parse concrete record from *.ifo files - used by sd_parse_ifo_file() function
+void                   sd_parse_record(SDData* data,gchar* key, gchar* value);
+//------------------------------------------------------------------------------
+// start/stop timers -  return -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+static double           timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+// find proper FilePart structure for concrete word in dictionary
+FilePart*              sd_find_file_part(SDData* data, gchar* word);
+//------------------------------------------------------------------------------
+// parse whole article to proper word translation
+gchar*                 sd_parse_stardict_article(gchar* buf,
+                                               gchar* type,
+                                               guint length
+                                               );
+//------------------------------------------------------------------------------
+// find and return only one, next field from buffer and update length variable
+gchar*                 sd_get_buffer_from_article(gchar** buffer,
+                                               guint* length
+                                               );
+//------------------------------------------------------------------------------
+// return size of files
+//static guint64          get_file_size(GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// these are wrapper functions to acces different type of files: standard or
+// compressed with gzip for *.idx or dictzip for *.dict files.
+
+#define _FILES_WRAPPER_BEG 'b'
+#define _FILES_WRAPPER_CUR 'c'
+#define _FILES_WRAPPER_END 'e'
+
+// standard
+static gpointer                sd_open(gchar* filename);
+static gint            sd_read(gpointer f, gchar* buffer, gint l);
+static glong           sd_seek(gpointer f, glong l, gchar from);
+static void            sd_close(gpointer f);
+// gzipped
+static gpointer                sd_open_z(gchar* filename);
+static gint            sd_read_z(gpointer f, gchar* buffer, gint l);
+static glong           sd_seek_z(gpointer f, glong l, gchar from);
+static void            sd_close_z(gpointer f);
+// files *.dict[.dz]
+//------------------------------------------------------------------------------
+// read concrete file part from dictionary - *.dict* file
+static gchar*          sd_read_file_part_dz(FilePart* part, gchar* file);
+static gchar*          sd_read_file_part(FilePart* part, gchar* file);
+//------------------------------------------------------------------------------
+
+
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+gboolean        sd_engine_add_word(Engine* engine,
+                                 gchar*  word,
+                                 gchar*  translation);
+//------------------------------------------------------------------------------
+gboolean        sd_engine_remove_word(Engine* engine,
+                                     gchar*  word);  
+//------------------------------------------------------------------------------      
+gchar*          sd_engine_get_lang_from(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          sd_engine_get_lang_to(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          sd_engine_get_title(Engine* engine);
+//------------------------------------------------------------------------------
+gchar*          sd_engine_get_icon_path(Engine* engine);
+//------------------------------------------------------------------------------
+
+
+
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        sd_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          sd_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          sd_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          sd_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         sd_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            sd_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          sd_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            sd_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        sd_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            sd_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        sd_engine_set_callback(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            sd_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            sd_engine_search_word_list(Engine* engine,
+                                           gchar* pattern,
+                                           gpointer cb_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            sd_engine_search_word_translation(Engine* engine,
+                                                  gchar* word,
+                                                  gpointer cb_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    sd_engine_status(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          sd_engine_status_message(EngineStatus status);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* #ifndef _DICTIONARY_ENGINE_STARDICT */
diff --git a/src/plugins/stardict/include/maa.h b/src/plugins/stardict/include/maa.h
new file mode 100644 (file)
index 0000000..447b55f
--- /dev/null
@@ -0,0 +1,603 @@
+/* maa.h -- Header file for visible libmaa functions
+ * Created: Sun Nov 19 13:21:21 1995 by faith@dict.org
+ * Revised: Sat Mar 30 11:54:49 2002 by faith@dict.org
+ * Copyright 1994-1998, 2002 Rickard E. Faith (faith@dict.org)
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ * $Id: maa.h,v 1.42 2004/10/12 10:23:38 cheusov Exp $
+ */
+
+#ifndef _MAA_H_
+#define _MAA_H_
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#ifndef __GNUC__
+#define __inline__
+#define __attribute__(x)
+#endif
+
+                               /* If MAA_MAGIC is non-zero, important
+                                   structures will be tagged with a magic
+                                   number which will be checked for
+                                   integrity at each access.  This uses up
+                                   more memory, and is slightly slower, but
+                                   helps debugging quite a bit. */
+#ifndef MAA_MAGIC
+#define MAA_MAGIC 1
+#endif
+
+#if MAA_MAGIC
+#define HSH_MAGIC               0x01020304
+#define HSH_MAGIC_FREED         0x10203040
+#define SET_MAGIC               0x02030405
+#define SET_MAGIC_FREED         0x20304050
+#define LST_MAGIC               0x03040506
+#define LST_MAGIC_FREED         0x30405060
+#define MEM_STRINGS_MAGIC       0x23232323
+#define MEM_STRINGS_MAGIC_FREED 0x32323232
+#define MEM_OBJECTS_MAGIC       0x42424242
+#define MEM_OBJECTS_MAGIC_FREED 0x24242424
+#define ARG_MAGIC               0xfeedbead
+#define ARG_MAGIC_FREED         0xefdeebda
+#define PR_MAGIC                0x0bad7734
+#define PR_MAGIC_FREED          0xb0da7743
+#define SL_LIST_MAGIC           0xabcdef01
+#define SL_LIST_MAGIC_FREED     0xbadcfe10
+#define SL_ENTRY_MAGIC          0xacadfeed
+#define SL_ENTRY_MAGIC_FREED    0xcadaefde
+#endif
+
+/* version.c */
+
+extern const char *maa_revision_string;
+
+
+/* maa.c */
+
+#define MAA_MEMORY (3<<30|1<<29) /* Print memory usage statistics at exit */
+#define MAA_TIME   (3<<30|1<<28) /* Print timer information at exit       */
+#define MAA_PR     (3<<30|1<<27) /* Debug process routines                */
+#define MAA_SL     (3<<30|1<<26) /* Debug skip list routines              */
+#define MAA_PARSE  (3<<30|1<<25) /* Debug parsing                         */
+#define MAA_SRC    (3<<30|1<<24) /* Source library                        */
+
+extern void       maa_init( const char *programName );
+extern void       maa_shutdown( void );
+extern int        maa_version_major( void );
+extern int        maa_version_minor( void );
+extern const char *maa_version( void );
+
+/* xmalloc.c */
+
+#ifndef DMALLOC_FUNC_CHECK
+extern __inline__ void *xmalloc( unsigned int size );
+extern __inline__ void *xcalloc( unsigned int num, unsigned int size );
+extern __inline__ void *xrealloc( void *pt, unsigned int size );
+extern __inline__ void xfree( void *pt );
+extern __inline__ char *xstrdup( const char *s );
+#endif
+
+
+/* bit.c */
+extern __inline__ void bit_set( unsigned long *flags, int bit );
+extern __inline__ void bit_clr( unsigned long *flags, int bit );
+extern __inline__ int  bit_tst( unsigned long *flags, int bit );
+extern __inline__ int  bit_cnt( unsigned long *flags );
+
+/* prime.c */
+
+extern int           prm_is_prime( unsigned int value );
+extern unsigned long prm_next_prime( unsigned int start );
+
+/* hash.c */
+
+typedef void *hsh_HashTable;
+typedef void *hsh_Position;
+
+typedef struct hsh_Stats {
+   unsigned long size;          /* Size of table */
+   unsigned long resizings;     /* Number of resizings */
+   unsigned long entries;       /* Total entries in table */
+   unsigned long buckets_used;  /* Number of hash buckets in use */
+   unsigned long singletons;    /* Number of length one lists */
+   unsigned long maximum_length; /* Maximum list length */
+
+   unsigned long retrievals;    /* Total number of retrievals */
+   unsigned long hits;          /* Number of retrievals from top of a list */
+   unsigned long misses;        /* Number of unsuccessful retrievals */
+} *hsh_Stats;
+
+extern hsh_HashTable hsh_create( unsigned long (*hash)( const void * ),
+                                int (*compare)( const void *,
+                                                const void * ) );
+extern void          hsh_destroy( hsh_HashTable table );
+extern int           hsh_insert( hsh_HashTable table,
+                                const void *key,
+                                const void *datum );
+extern int           hsh_delete( hsh_HashTable table, const void *key );
+extern const void    *hsh_retrieve( hsh_HashTable table, const void *key );
+extern int           hsh_iterate( hsh_HashTable table,
+                                 int (*iterator)( const void *key,
+                                                  const void *datum ) );
+extern int           hsh_iterate_arg( hsh_HashTable table,
+                                     int (*iterator)( const void *key,
+                                                      const void *datum,
+                                                      void *arg ),
+                                     void *arg );
+extern hsh_Stats     hsh_get_stats( hsh_HashTable table );
+extern void          hsh_print_stats( hsh_HashTable table, FILE *stream );
+extern unsigned long hsh_string_hash( const void *key );
+extern unsigned long hsh_pointer_hash( const void *key );
+extern int           hsh_string_compare( const void *key1, const void *key2 );
+extern int           hsh_pointer_compare( const void *key1, const void *key2 );
+extern void          hsh_key_strings(hsh_HashTable);
+
+extern hsh_Position  hsh_init_position( hsh_HashTable table );
+extern hsh_Position  hsh_next_position( hsh_HashTable table,
+                                       hsh_Position position );
+extern void          *hsh_get_position( hsh_Position position, void **key );
+extern int           hsh_readonly( hsh_HashTable table, int flag );
+
+#define HSH_POSITION_INIT(P,T)  ((P)=hsh_init_position(T))
+#define HSH_POSITION_NEXT(P,T)  ((P)=hsh_next_position(T,P))
+#define HSH_POSITION_OK(P)      (P)
+#define HSH_POSITION_GET(P,K,D) ((D)=hsh_get_position(P,&K))
+
+/* iterate over all (key, datum) pairs, (K,D), in hash table T */
+#define HSH_ITERATE(T,P,K,D)                                                 \
+   for (HSH_POSITION_INIT((P),(T));                                          \
+       HSH_POSITION_OK(P) && (HSH_POSITION_GET((P),(K),(D)),1);             \
+       HSH_POSITION_NEXT((P),(T)))
+
+/* If the HSH_ITERATE loop is exited before all elements in the table are
+   seen, then HSH_ITERATE_END should be called.  Calling this function
+   after complete loops does no harm. */
+#define HSH_ITERATE_END(T) hsh_readonly(T,0)
+
+   
+/* set.c */
+
+typedef void *set_Set;
+typedef void *set_Position;
+
+typedef struct set_Stats{
+   unsigned long size;          /* Size of table */
+   unsigned long resizings;     /* Number of resizings */
+   unsigned long entries;       /* Total entries in table */
+   unsigned long buckets_used;  /* Number of hash buckets in use */
+   unsigned long singletons;    /* Number of length one lists */
+   unsigned long maximum_length; /* Maximum list length */
+
+   unsigned long retrievals;    /* Total number of retrievals */
+   unsigned long hits;          /* Number of retrievals from top of a list */
+   unsigned long misses;        /* Number of unsuccessful retrievals */
+} *set_Stats;
+
+typedef unsigned long (*set_HashFunction)( const void * );
+typedef int           (*set_CompareFunction)( const void *, const void * );
+
+extern set_Set             set_create( set_HashFunction hash,
+                                      set_CompareFunction compare );
+extern set_HashFunction    set_get_hash( set_Set set );
+extern set_CompareFunction set_get_compare( set_Set set );
+extern void                set_destroy( set_Set set );
+extern int                 set_insert( set_Set set, const void *elem );
+extern int                 set_delete( set_Set set, const void *elem );
+extern int                 set_member( set_Set set, const void *elem );
+extern int                 set_iterate( set_Set set,
+                                       int (*iterator)( const void *key ) );
+extern int                 set_iterate_arg( set_Set set,
+                                           int (*iterator)( const void *elem,
+                                                            void *arg ),
+                                           void *arg );
+extern set_Set             set_add( set_Set set1, set_Set set2 );
+extern set_Set             set_del( set_Set set1, set_Set set2 );
+extern set_Set             set_union( set_Set set1, set_Set set2 );
+extern set_Set             set_inter( set_Set set1, set_Set set2 );
+extern set_Set             set_diff( set_Set set1, set_Set set2 );
+extern int                 set_equal( set_Set set1, set_Set set2 );
+extern set_Stats           set_get_stats( set_Set set );
+extern void                set_print_stats( set_Set set, FILE *stream );
+extern int                 set_count( set_Set set );
+extern set_Position        set_init_position( set_Set set );
+extern set_Position        set_next_position( set_Set set,
+                                             set_Position position );
+extern void                *set_get_position( set_Position position );
+extern int                 set_readonly( set_Set set, int flag );
+
+#define SET_POSITION_INIT(P,S) ((P)=set_init_position(S))
+#define SET_POSITION_NEXT(P,S) ((P)=set_next_position(S,P))
+#define SET_POSITION_OK(P)     (P)
+#define SET_POSITION_GET(P,E)  ((E)=set_get_position(P))
+
+/* iterate over all entries E in set S */
+#define SET_ITERATE(S,P,E)                                                   \
+   for (SET_POSITION_INIT((P),(S));                                          \
+       SET_POSITION_OK(P) && (SET_POSITION_GET((P),(E)),1);                 \
+       SET_POSITION_NEXT((P),(S)))
+
+/* If the SET_ITERATE loop is exited before all elements in the set are
+   seen, then SET_ITERATE_END should be called.  Calling this function
+   after complete loops does no harm. */
+#define SET_ITERATE_END(S) set_readonly(S,0)
+
+/* stack.c */
+
+typedef void *stk_Stack;
+
+extern stk_Stack stk_create( void );
+extern void      stk_destroy( stk_Stack stack );
+extern void      stk_push( stk_Stack stack, void *datum );
+extern void      *stk_pop( stk_Stack stack );
+extern void      *stk_top( stk_Stack stack );
+
+/* list.c */
+
+typedef void *lst_List;
+typedef void *lst_Position;
+
+extern lst_List     lst_create( void );
+extern void         lst_destroy( lst_List list );
+extern void         lst_append( lst_List list, const void *datum );
+extern void         lst_push( lst_List list, const void *datum );
+extern void         *lst_pop( lst_List list );
+extern void         *lst_top( lst_List list );
+extern void         *lst_nth_get( lst_List list, unsigned int n );
+extern void         lst_nth_set( lst_List list, unsigned int n,
+                                const void *datum );
+extern int          lst_member( lst_List list, const void *datum );
+extern unsigned int lst_length( lst_List list );
+extern int          lst_iterate( lst_List list,
+                                int (*iterator)( const void *datum ) );
+extern int          lst_iterate_arg( lst_List list,
+                                    int (*iterator)( const void *datum,
+                                                     void *arg ),
+                                    void *arg );
+extern void         lst_truncate( lst_List list, unsigned int length );
+extern void         lst_truncate_position( lst_List list,
+                                          lst_Position position );
+extern lst_Position lst_init_position( lst_List list );
+extern lst_Position lst_last_position( lst_List list );
+extern lst_Position lst_next_position( lst_Position position );
+extern lst_Position lst_nth_position( lst_List list, unsigned int n );
+extern void         *lst_get_position( lst_Position position );
+extern void         lst_set_position( lst_Position position,
+                                     const void *datum );
+extern void         lst_dump( lst_List list );
+extern void         _lst_shutdown( void );
+extern long int     lst_total_allocated( void );
+
+#define LST_POSITION_INIT(P,L) ((P)=lst_init_position(L))
+#define LST_POSITION_NEXT(P)   ((P)=lst_next_position(P))
+#define LST_POSITION_OK(P)     (P)
+#define LST_POSITION_GET(P,E)  ((E)=lst_get_position(P))
+
+/* iterate over all entries E in list L */
+#define LST_ITERATE(L,P,E)                                                  \
+   for (LST_POSITION_INIT((P),(L));                                         \
+        LST_POSITION_OK(P) && (LST_POSITION_GET((P),(E)),1);                \
+        LST_POSITION_NEXT(P))
+
+/* iterate over all entries in lists L1 and L2 */
+#define LST_ITERATE2(L1,L2,P1,P2,E1,E2)                                      \
+   for (LST_POSITION_INIT((P1),(L1)), LST_POSITION_INIT((P2),(L2));          \
+       LST_POSITION_OK(P1) && LST_POSITION_OK(P2)                           \
+          && (LST_POSITION_GET((P1),(E1)),LST_POSITION_GET((P2),(E2)),1);   \
+       LST_POSITION_NEXT(P1), LST_POSITION_NEXT(P2))
+
+/* error.c */
+
+extern void       err_set_program_name( const char *programName );
+extern const char *err_program_name( void );
+extern void       err_fatal( const char *routine, const char *format, ... )
+   __attribute__((noreturn,format(printf, 2, 3)));
+extern void       err_fatal_errno( const char *routine,
+                                  const char *format, ... )
+   __attribute__((noreturn,format(printf, 2, 3)));
+
+extern void       err_warning( const char *routine, const char *format, ... )
+   __attribute__((format(printf, 2, 3)));
+
+extern void       err_internal( const char *routine, const char *format, ... )
+   __attribute__((noreturn,format(printf, 2, 3)));
+
+/* memory.c */
+
+typedef void *mem_String;
+typedef void *mem_Object;
+
+typedef struct mem_StringStats {
+   int count;                  /* Number of strings or objects */
+   int bytes;                  /* Number of bytes allocated */
+} *mem_StringStats;
+
+typedef struct mem_ObjectStats {
+   int total;                  /* Total objects requested */
+   int used;                   /* Total currently in use */
+   int reused;                 /* Total reused  */
+   int size;                   /* Size of each object */
+} *mem_ObjectStats;
+
+extern mem_String      mem_create_strings( void );
+extern void            mem_destroy_strings( mem_String info );
+extern const char      *mem_strcpy( mem_String info, const char *string );
+extern const char      *mem_strncpy( mem_String info,
+                                    const char *string,
+                                    int len );
+extern void            mem_grow( mem_String info,
+                                const char *string,
+                                int len );
+extern const char      *mem_finish( mem_String info );
+extern mem_StringStats mem_get_string_stats( mem_String info );
+extern void            mem_print_string_stats( mem_String info, FILE *stream );
+
+extern mem_Object      mem_create_objects( int size );
+extern void            mem_destroy_objects( mem_Object info );
+extern void            *mem_get_object( mem_Object info );
+extern void            *mem_get_empty_object( mem_Object info );
+extern void            mem_free_object( mem_Object info, void *obj );
+extern mem_ObjectStats mem_get_object_stats( mem_Object info );
+extern void            mem_print_object_stats( mem_Object info, FILE *stream );
+
+/* string.c */
+
+typedef void *str_Pool;
+typedef hsh_Position str_Position;
+
+typedef struct str_Stats {
+   int count;                  /* Number of strings created */
+   int bytes;                  /* Number of bytes allocated */
+   int retrievals;             /* Total number of retrievals */
+   int hits;                   /* Number of retrievals from top of a list */
+   int misses;                 /* Number of unsuccessful retrievals */
+} *str_Stats;
+
+extern str_Pool   str_pool_create( void );
+extern void       str_pool_destroy( str_Pool pool );
+extern int        str_pool_exists( str_Pool pool, const char *s );
+extern const char *str_pool_find( str_Pool pool, const char *s );
+extern const char *str_pool_copy( str_Pool pool, const char *s );
+extern const char *str_pool_copyn( str_Pool pool, const char *s, int length );
+extern void       str_pool_grow( str_Pool pool, const char *s, int length );
+extern const char *str_pool_finish( str_Pool pool );
+extern str_Stats  str_pool_get_stats( str_Pool pool );
+extern void       str_pool_print_stats( str_Pool pool, FILE *stream );
+
+extern str_Position  str_pool_init_position(
+   str_Pool table );
+extern str_Position  str_pool_next_position(
+   str_Pool table,
+   str_Position position );
+extern void str_pool_get_position(
+   str_Position position,
+   char const *const *key );
+#define str_pool_readonly(pool, flag) hsh_readonly ((pool), (flag))
+
+extern int        str_pool_iterate(
+   str_Pool pool,
+   int (*iterator)( const char *s ) );
+extern int        str_pool_iterate_arg(
+   str_Pool pool,
+   int (*iterator)( const char *s, void *arg ),
+   void *arg );
+
+#define STR_POSITION_INIT(P,T)  ((P)=str_pool_init_position(T))
+#define STR_POSITION_NEXT(P,T)  ((P)=str_pool_next_position(T,P))
+#define STR_POSITION_OK(P)      (P)
+#define STR_POSITION_GET(P,K)   (str_pool_get_position(P,&K), K)
+
+/* iterate over all keys (K) in string pool T */
+#define STR_ITERATE(T,P,K)                                                   \
+   for (STR_POSITION_INIT((P),(T));                                          \
+       STR_POSITION_OK(P) && (STR_POSITION_GET((P),(K)),1);                 \
+       STR_POSITION_NEXT((P),(T)))
+
+/* If the STR_ITERATE loop is exited before all elements in the table are
+   seen, then STR_ITERATE_END should be called.  Calling this function
+   after complete loops does no harm. */
+#define STR_ITERATE_END(T) str_readonly(T,0)
+
+extern int        str_exists( const char *s );
+extern const char *str_find( const char *s );
+extern const char *str_findn( const char *s, int length );
+extern const char *str_copy( const char *s );
+extern const char *str_copyn( const char *s, int length );
+extern void       str_grow( const char *s, int length );
+extern const char *str_finish( void );
+extern const char *str_unique( const char *prefix );
+extern void       str_destroy( void );
+extern str_Stats  str_get_stats( void );
+extern void       str_print_stats( FILE *stream );
+
+/* debug.c */
+
+typedef unsigned long int dbg_Type;
+
+extern void           dbg_register( dbg_Type flag, const char *name );
+extern void           _dbg_register( dbg_Type flag, const char *name );
+extern void           dbg_destroy( void );
+extern void           dbg_set( const char *name );
+extern void           dbg_set_flag( dbg_Type flag );
+extern void           dbg_unset_flag( dbg_Type flag );
+extern __inline__ int dbg_test( dbg_Type flag );
+extern void           dbg_list( FILE *stream );
+
+#define PRINTF(flag,arg)  if (dbg_test(flag)) { log_info arg; }
+
+/* flags.c */
+
+typedef unsigned long int flg_Type;
+
+extern void           flg_register( flg_Type flag, const char *name );
+extern void           flg_destroy( void );
+extern void           flg_set( const char *name );
+extern __inline__ int flg_test( flg_Type flag );
+extern void           flg_list( FILE *stream );
+extern const          char *flg_name( flg_Type flag );
+
+/* timer.c */
+
+extern void   tim_start( const char *name );
+extern void   tim_stop( const char *name );
+extern void   tim_reset( const char *name );
+extern double tim_get_real( const char *name );
+extern double tim_get_user( const char *name );
+extern double tim_get_system( const char *name );
+extern void   tim_print_timer( FILE *str, const char *name );
+extern void   tim_print_timers( FILE *str );
+extern void   _tim_shutdown( void );
+
+/* arg.c */
+
+#define ARG_NO_ESCAPE 0x0001   /* Backslashed are not escape characters */
+#define ARG_NO_QUOTE  0x0002   /* Don't use quote marks for quoting */
+
+typedef void *arg_List;
+
+extern arg_List   arg_create( void );
+extern void       arg_destroy( arg_List arg );
+extern arg_List   arg_add( arg_List arg, const char *string );
+extern arg_List   arg_addn( arg_List arg, const char *string, int length );
+extern void       arg_grow( arg_List arg, const char *string, int length );
+extern arg_List   arg_finish( arg_List arg );
+extern const char *arg_get( arg_List arg, int item );
+extern int        arg_count( arg_List arg );
+extern void       arg_get_vector( arg_List arg, int *argc, char ***argv );
+extern arg_List   arg_argify( const char *string, int quoteStyle );
+
+/* pr.c */
+
+#define PR_USE_STDIN        0x00000001
+#define PR_USE_STDOUT       0x00000002
+#define PR_USE_STDERR       0x00000004
+#define PR_CREATE_STDIN     0x00000010
+#define PR_CREATE_STDOUT    0x00000020
+#define PR_CREATE_STDERR    0x00000040
+#define PR_STDERR_TO_STDOUT 0x00000100
+
+extern int  pr_open( const char *command, int flags,
+                    int *infd, int *outfd, int *errfd );
+extern int  pr_close_nowait( int fd );
+extern int  pr_close( int fd );
+extern int  pr_wait( int pid );
+extern void _pr_shutdown( void );
+extern int  pr_spawn( const char *command );
+int pr_readwrite( int in, int out,
+                 const char *inBuffer, int inLen,
+                 char *outBuffer, int outMaxLen );
+int pr_filter( const char *command,
+              const char *inBuffer, int inLen,
+              char *outBuffer, int outMaxLen );
+
+/* sl.c */
+
+typedef void *sl_List;
+typedef int (*sl_Iterator)( const void *datum );
+typedef int (*sl_IteratorArg)( const void *datum, void *arg );
+
+extern sl_List    sl_create( int (*compare)( const void *key1,
+                                            const void *key2 ),
+                            const void *(*key)( const void *datum ),
+                            const char *(*print)( const void *datum ) );
+extern void       sl_destroy( sl_List list );
+extern void       _sl_shutdown( void );
+extern void       sl_insert( sl_List list, const void *datum );
+extern void       sl_delete( sl_List list, const void *datum );
+extern const void *sl_find( sl_List list, const void *key );
+extern int        sl_iterate( sl_List list, sl_Iterator f );
+extern int        sl_iterate_arg( sl_List list, sl_IteratorArg f, void *arg );
+extern void       _sl_dump( sl_List list );
+
+/* text.c */
+
+extern const char * txt_soundex( const char *string );
+extern void txt_soundex2(
+   const char *string,
+   char *result /* five chars */ );
+
+/* base64.c */
+
+extern const char    *b64_encode( unsigned long val );
+extern unsigned long b64_decode( const char *val );
+
+/* base26.c */
+
+extern const char    *b26_encode( unsigned long val );
+extern unsigned long b26_decode( const char *val );
+
+/* source.c */
+
+typedef void *src_Type;
+
+typedef struct src_Stats {
+   int lines_used;             /* Lines used */
+   int lines_allocated;                /* Lines allocated */
+   int lines_bytes;            /* Bytes required to store lines */
+   int tokens_total;           /* Tokens used */
+   int tokens_reused;          /* Tokens reused */
+   int tokens_size;            /* Size of a token information object */
+} *src_Stats;
+
+extern void       src_create( void );
+extern void       src_destroy( void );
+extern const char *src_line( const char *line, int len );
+extern void       src_new_file( const char *filename );
+extern void       src_new_line( int line );
+extern void       src_advance( int length );
+extern void       src_cpp_line( const char *line, int length );
+extern src_Type   src_get( int length );
+extern const char *src_filename( src_Type source );
+extern int        src_linenumber( src_Type source );
+extern int        src_offset( src_Type source );
+extern int        src_length( src_Type source );
+extern const char *src_source_line( src_Type source );
+extern void       src_parse_error( FILE *stream, src_Type source,
+                                  const char *message );
+extern void       src_print_error( FILE *stream, src_Type source,
+                                  const char *format, ... );
+extern void       src_print_message( FILE *str, src_Type source,
+                                     const char *format, ... );
+extern void       src_print_line( FILE *stream, src_Type source );
+extern src_Stats  src_get_stats( void );
+extern void       src_print_stats( FILE *stream );
+
+/* parse-concrete.c */
+
+extern void   prs_register_concrete( const char *symbol,
+                                    const char *concrete );
+extern const  char *prs_concrete( const char *symbol );
+extern void   _prs_shutdown( void );
+
+/* log.c */
+#define LOG_OPTION_FULL    1
+#define LOG_OPTION_NO_FULL 2
+
+extern void       log_syslog( const char *ident );
+extern void       log_set_facility( const char *facility );
+extern const char *log_get_facility( void );
+extern void       log_option( int option );
+extern void       log_file( const char *ident, const char *filename );
+extern void       log_stream( const char *ident, FILE *stream );
+extern void       log_close( void );
+extern void       log_error_va( const char *routine,
+                                const char *format, va_list ap );
+extern void       log_error( const char *routine, const char *format, ... );
+extern void       log_info_va( const char *format, va_list ap );
+extern void       log_info( const char *format, ... );
+
+#endif
diff --git a/src/plugins/stardict/precompiled/arm/data.o b/src/plugins/stardict/precompiled/arm/data.o
new file mode 100644 (file)
index 0000000..312f733
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/data.o differ
diff --git a/src/plugins/stardict/precompiled/arm/debug.o b/src/plugins/stardict/precompiled/arm/debug.o
new file mode 100644 (file)
index 0000000..f77e47b
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/debug.o differ
diff --git a/src/plugins/stardict/precompiled/arm/error.o b/src/plugins/stardict/precompiled/arm/error.o
new file mode 100644 (file)
index 0000000..dd327e7
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/error.o differ
diff --git a/src/plugins/stardict/precompiled/arm/hash.o b/src/plugins/stardict/precompiled/arm/hash.o
new file mode 100644 (file)
index 0000000..4468a93
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/hash.o differ
diff --git a/src/plugins/stardict/precompiled/arm/log.o b/src/plugins/stardict/precompiled/arm/log.o
new file mode 100644 (file)
index 0000000..5ab420d
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/log.o differ
diff --git a/src/plugins/stardict/precompiled/arm/memory.o b/src/plugins/stardict/precompiled/arm/memory.o
new file mode 100644 (file)
index 0000000..f9258d3
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/memory.o differ
diff --git a/src/plugins/stardict/precompiled/arm/prime.o b/src/plugins/stardict/precompiled/arm/prime.o
new file mode 100644 (file)
index 0000000..38d26a5
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/prime.o differ
diff --git a/src/plugins/stardict/precompiled/arm/stack.o b/src/plugins/stardict/precompiled/arm/stack.o
new file mode 100644 (file)
index 0000000..d7c4867
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/stack.o differ
diff --git a/src/plugins/stardict/precompiled/arm/string.o b/src/plugins/stardict/precompiled/arm/string.o
new file mode 100644 (file)
index 0000000..f441c0e
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/string.o differ
diff --git a/src/plugins/stardict/precompiled/arm/xmalloc.o b/src/plugins/stardict/precompiled/arm/xmalloc.o
new file mode 100644 (file)
index 0000000..d35c9a0
Binary files /dev/null and b/src/plugins/stardict/precompiled/arm/xmalloc.o differ
diff --git a/src/plugins/stardict/precompiled/i686/data.o b/src/plugins/stardict/precompiled/i686/data.o
new file mode 100644 (file)
index 0000000..f704a65
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/data.o differ
diff --git a/src/plugins/stardict/precompiled/i686/debug.o b/src/plugins/stardict/precompiled/i686/debug.o
new file mode 100644 (file)
index 0000000..9b108b7
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/debug.o differ
diff --git a/src/plugins/stardict/precompiled/i686/error.o b/src/plugins/stardict/precompiled/i686/error.o
new file mode 100644 (file)
index 0000000..c8030b2
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/error.o differ
diff --git a/src/plugins/stardict/precompiled/i686/hash.o b/src/plugins/stardict/precompiled/i686/hash.o
new file mode 100644 (file)
index 0000000..8204f50
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/hash.o differ
diff --git a/src/plugins/stardict/precompiled/i686/log.o b/src/plugins/stardict/precompiled/i686/log.o
new file mode 100644 (file)
index 0000000..c3098eb
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/log.o differ
diff --git a/src/plugins/stardict/precompiled/i686/memory.o b/src/plugins/stardict/precompiled/i686/memory.o
new file mode 100644 (file)
index 0000000..932c1c9
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/memory.o differ
diff --git a/src/plugins/stardict/precompiled/i686/prime.o b/src/plugins/stardict/precompiled/i686/prime.o
new file mode 100644 (file)
index 0000000..a6db0e0
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/prime.o differ
diff --git a/src/plugins/stardict/precompiled/i686/stack.o b/src/plugins/stardict/precompiled/i686/stack.o
new file mode 100644 (file)
index 0000000..a219468
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/stack.o differ
diff --git a/src/plugins/stardict/precompiled/i686/string.o b/src/plugins/stardict/precompiled/i686/string.o
new file mode 100644 (file)
index 0000000..9dec54f
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/string.o differ
diff --git a/src/plugins/stardict/precompiled/i686/xmalloc.o b/src/plugins/stardict/precompiled/i686/xmalloc.o
new file mode 100644 (file)
index 0000000..502c354
Binary files /dev/null and b/src/plugins/stardict/precompiled/i686/xmalloc.o differ
diff --git a/src/plugins/stardict/src/engine_stardict.c b/src/plugins/stardict/src/engine_stardict.c
new file mode 100755 (executable)
index 0000000..f96fe76
--- /dev/null
@@ -0,0 +1,1730 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_stardict.h>
+//------------------------------------------------------------------------------
+
+
+
+
+/** \brief Read and return part of compressed file (dictzip)
+ *
+ * @param part <b>FilePart*</b> defines file part which we want to read
+ * @param data <b>SDData*</b> structure from which we get filename of file to 
+ * read (data->dic_file_name)
+ * @return <b>gchar*</b> buffer with content of file part, or NULL if there 
+ * were some problems
+ */
+static gchar* sd_read_file_part_dz(FilePart* part, gchar* file) 
+{
+       eg_debug("-> %s() called.\n",__FUNCTION__);
+       timer(TIMER_START,(gchar*)__FUNCTION__);
+       gchar* result = NULL;
+       
+       // read into the buffer 'result'
+       dictData* header = NULL;
+       header = dict_data_open(file , 0 );
+       result = dict_data_read_(header,part->offset,part->length,NULL,NULL);
+       dict_data_close(header);
+
+       timer(TIMER_STOP,(gchar*)__FUNCTION__);
+       eg_debug("<- %s() returned string=\n%s.\n",__FUNCTION__,result);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Read and return part of uncompressed file.
+ *
+ * @param part <b>FilePart*</b> defines file part which we want to read
+ * @param data <b>SDData*</b> structure from which we get filename of file to 
+ * read (data->dic_file_name)
+ * @return <b>gchar*</b> buffer with content of file part, or NULL if there 
+ * were some problems
+ */
+static gchar* sd_read_file_part(FilePart* part, gchar* file)
+{
+       eg_debug("-> %s() called.\n",__FUNCTION__);
+       timer(TIMER_START,(gchar*)__FUNCTION__);
+       guint length = part->length;
+
+       // open file
+       gint fd = open(file, O_RDONLY);
+       if(fd == -1)
+       {
+               eg_debug("---> Error: could not open *.dict file!\n");
+               timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               eg_debug("<- %s() finished with error.\n",
+                       __FUNCTION__);
+               return NULL;
+       }
+
+       // read from file to buffer
+       gchar* result = (gchar*)g_try_malloc0(length+1);
+       gint readed = (gint)read(fd, result, length);
+       if(readed != part->length)
+       {
+               eg_debug("---> Error: could not read *.dict file!\n");
+               g_free(result);
+               result = NULL;
+       }
+       result[length] = '\0';
+
+       timer(TIMER_STOP,(gchar*)__FUNCTION__);
+       eg_debug("<- %s() returned string=\n%s.\n",__FUNCTION__,result);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Search offset and length of article in dictionary for word.
+ *
+ * @param data <b>SDData*</b> where to search for descriptor of article
+ * @param word <b>gchar*</b> for what word we are looking format
+ * @return <b>FilePart*</b> describing part of file containing article about 
+ * word or NULL if there were some problems
+ */
+FilePart* sd_find_file_part(SDData* data, gchar* word)
+{
+       eg_debug("-> %s() called.\n",__FUNCTION__);
+       timer(TIMER_START,(gchar*)__FUNCTION__);
+
+       FilePart* result = NULL;
+       data->sd_seek_idx(data->idx_file, 0, _FILES_WRAPPER_BEG);
+       gchar buffer[WORD_LIST_BUFFER_LENGTH + 1];
+       gint readed =0;
+       gint offset = 0;
+       gchar* tmp = NULL;
+       guint len = 0;
+       guint pl = strlen(word);
+       gboolean further = FALSE;
+       do
+       {
+               readed =  data->sd_read_idx(data->idx_file,
+                                       buffer + offset,
+                                       WORD_LIST_BUFFER_LENGTH - offset
+                                       );
+               if(readed < 0)
+               {
+                       eg_debug("---> Error while reading file for searching"
+                               " matched FilePart in dictionary to word: %s",
+                               word
+                               );
+                       break;
+               }
+               else
+               {
+                       further = (readed == (WORD_LIST_BUFFER_LENGTH-offset));
+               }
+               tmp = buffer;
+
+               guint i = 0;
+               gint min = _MIN(readed, WORD_LIST_BUFFER_LENGTH-270);
+               while(i<min)
+               {
+                       // check next words
+                       if(g_ascii_strncasecmp(tmp,word,pl) == 0 &&
+                          strlen(tmp) == pl)
+                       {
+                               // we have found word in dictionary
+                               guint val = 0;
+                               result = 
+                               (FilePart*)g_try_malloc0(sizeof(FilePart));
+                               len = strlen(tmp)+1;
+                               tmp += len;
+                               memcpy(&val,tmp,sizeof(guint));
+                               result->offset = ntohl(val);
+                               tmp = tmp + sizeof(guint);
+                               memcpy(&val,tmp,sizeof(guint));
+                               result->length = ntohl(val);
+                               further = FALSE;
+                               break;
+                       }
+                       // calculate length of word
+                       len = strlen(tmp)+1;
+                       // jump in buffer over this word, and ...
+                       tmp += len;
+                       // ...skip offset and length of translation
+                       tmp += 2 * sizeof(guint);
+                       // update i value
+                       i = i + len + 2 * sizeof(guint);
+               }
+               if(!further) break;
+               offset = WORD_LIST_BUFFER_LENGTH - i;
+               g_memmove(buffer,buffer+WORD_LIST_BUFFER_LENGTH-offset, offset);
+       }
+       while(further);
+
+       timer(TIMER_STOP,(gchar*)__FUNCTION__);
+       if(result)
+       {
+               eg_debug("<- %s() return: OFFSET=%d LENGTH=%d.\n",
+                       __FUNCTION__,
+                       result->offset,
+                       result->length
+                       );
+       }
+       else
+       {
+               eg_debug("<- %s() didn't find proper FilePart!\n",__FUNCTION__);
+       }       
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Close and clean unused dictionary.
+ *
+ * This function is called whenever you call macro dict_eng_destroy(). Every 
+ * engine could have some memory allocated for its, so it is obligatory to call 
+ * this function every time when You do not need engine no more.
+ *
+ * @param engine <b>Engine*</b> to close and clean
+ */
+void sd_engine_close(Engine* engine)
+{
+       eg_debug("StarDict/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+            __FILE__,
+            __FUNCTION__,
+            engine
+           );
+
+       g_assert(engine != NULL);
+       SDData* data = (SDData*)(engine->engine_data);
+
+       data->sd_close_idx(data->idx_file);
+       g_free(data->idx_file);
+       g_free(data->dict_path);
+       g_free(data->idx_file_name);
+       g_free(data->ifo_file_name);
+       g_free(data->dic_file_name);
+       g_free(data->icon);
+       g_free(data->lang_from);
+       g_free(data->lang_to);
+       g_free(data->title);
+       g_free(data);
+       g_free(engine); 
+       eg_debug("StarDict/%s->%s() engine at adress=%p is deleted.\n",
+            __FILE__,
+            __FUNCTION__,
+            engine
+           );
+       engine = NULL;
+}
+//------------------------------------------------------------------------------
+/** \brief Create engine to dictionary in given directory.
+ *
+ * Construct and initialize new engine from concrete location.
+ *
+ * @param location <b>gchar*</b> from where we are trying to load StarDict 
+ * dictionary
+ * @param auto_cache <b>gboolean</b> flag defining if we want automaticlly turn
+ * on the optimization of newly created engine. In StarDict dictionaries this 
+ * flag is unused.
+ * @param progress_handler <b>gpointer</b> is a function which will be called 
+ * from time to time
+ * while optimization proccess is running. As far as there is no optimization
+ * for StarDict dictionaries, this flag is unused either.
+ * @param progress_data <b>gpointer</b> given as a parameter to progress_handler
+ * @param seed <b>gdouble</b> tells how often to call progress_handler
+ */
+Engine* sd_engine_create(gchar* location,
+                       EngineOptimizationFlag auto_cache,
+                       cb_progress progress_handler,
+                       gpointer progress_data,
+                       gdouble seed
+                       )
+{
+       eg_debug("StarDict/%s->%s() called.\n"
+               "-->PARAM:location=\'%s\'\n"
+               "-->PARAM:auto_cache=%d\n",
+               __FILE__,
+               __FUNCTION__,
+               location,
+               (guint)auto_cache
+               );
+       g_assert(location != NULL);
+
+       sd_timer(TIMER_START,(gchar*)__FUNCTION__); 
+
+       gchar* tmp = g_strdup(location);
+       string_to_path(&tmp);
+
+       Engine* result = (Engine*)g_try_malloc0(sizeof(Engine));
+       result->engine_location = sd_engine_location;
+       result->engine_is_optimized = sd_engine_is_optimized;
+       result->engine_optimize = sd_engine_optimize;
+       result->engine_search_word_list = sd_engine_search_word_list;
+       result->engine_search_word_translation = 
+               sd_engine_search_word_translation;       
+       result->engine_close = sd_engine_close;
+       result->engine_status = sd_engine_status;
+       result->engine_error_message = sd_engine_status_message;
+       result->engine_set_callback = sd_engine_set_callback;
+       result->engine_set_progress_seed = sd_engine_set_progress_seed;
+       result->engine_set_auto_free = sd_engine_set_auto_free;
+       result->engine_get_lang_to = sd_engine_get_lang_to;
+       result->engine_get_lang_from = sd_engine_get_lang_from;
+       result->engine_get_title = sd_engine_get_title;
+       result->engine_get_icon_path = sd_engine_get_icon_path;
+       result->engine_add_word = sd_engine_add_word;
+       result->engine_remove_word = sd_engine_remove_word;
+
+       SDData* data = (SDData*)g_try_malloc0(sizeof(SDData));
+       result->engine_data = (gpointer)data;
+       data->dict_path = g_strdup(tmp);
+       data->cb_progress_caching = progress_handler;
+       data->cb_progress_caching_data = progress_data; 
+       data->cb_progress_caching_seed = seed; 
+       data->cb_progress_word_list = NULL;
+       data->cb_progress_word_list_data = NULL;
+       data->cb_progress_word_list_seed = 0.01;
+       data->cb_progress_word_trans = NULL;
+       data->cb_progress_word_trans_data = NULL;
+       data->cb_progress_word_trans_seed = 0.01;
+       data->cb_search_word_list = NULL;
+       data->cb_search_word_list_data = NULL;
+       data->cb_search_word_trans = NULL;
+       data->cb_search_word_trans_data = NULL;
+       data->auto_free = FALSE;
+
+       if(!sd_read_files_names(data))
+       {
+               eg_warning("Error while loading dictionaries filenames!\n");    
+               result->engine_close(result);
+               result = NULL;
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               return result;
+       }
+       if(!sd_parse_ifo_file(data))
+       {
+               eg_warning("Error while reading *.ifo file!\n");        
+               result->engine_close(result);
+               result = NULL;
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               return result;
+       }
+       // there are no information about this parameter of dictionaries in
+       // StarDict format
+       data->lang_from = NULL;
+       data->lang_to = NULL;
+       // StarDict dictionaries do NOT support different icons, so set global
+       data->icon = g_strdup(ICON_PATH);
+       
+       sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+       eg_debug("StarDict/%s->%s() returned Engine at adress=%p\n",
+               __FILE__,
+               __FUNCTION__,
+               result
+              );
+       g_free(tmp); tmp = NULL;
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Search for word list in dictionary.
+ *
+ * @param engine <b>Engine*</b> to search in
+ * @param pattern <b>gchar*</b> to search for
+ */
+void sd_engine_search_word_list(Engine* engine,
+                                gchar* pattern,
+                                gpointer cb_data)
+{
+       eg_debug("-> %s() called. Searching words list\n"
+               "--->PARAM:engine at adress=%p\n"
+               "--->PARAM:pattern=\"%s\"\n",
+               __FUNCTION__,
+               engine,
+               pattern
+               );
+       g_assert(engine != NULL);
+       g_assert(pattern != NULL);
+
+       sd_timer(TIMER_START,(gchar*)__FUNCTION__);
+       SDData* data = (SDData*)(engine->engine_data);
+       if(data->cb_search_word_list == NULL) {
+               eg_warning("---> %s() callback for Word List not set. "
+                       "Searching aborted.\n",
+                       __FUNCTION__
+                       );
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               return;
+       };
+
+       data->sd_seek_idx(data->idx_file, 0, _FILES_WRAPPER_BEG);
+       gchar buffer[WORD_LIST_BUFFER_LENGTH + 1];
+       gint readed =0;
+       gint offset = 0;
+       gchar* tmp = NULL;
+       guint len = 0;
+//     guint pl = strlen(pattern);
+       GPatternSpec* regex;
+       regex = g_pattern_spec_new (pattern);
+       
+       gboolean further = FALSE;
+       guint count = 0;
+       GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*));
+       do
+       {
+               readed =  data->sd_read_idx(data->idx_file,
+                                       buffer + offset,
+                                       WORD_LIST_BUFFER_LENGTH - offset
+                                       );
+               if(readed < 0)
+               {
+                       eg_debug("---> Error while reading file for searching"
+                               " matched words in dictionary to pattern: %s",
+                               pattern
+                               );
+                       break;
+               }
+               else
+               {
+                       further = (readed == (WORD_LIST_BUFFER_LENGTH-offset));
+               }
+               tmp = buffer;
+
+               guint i = 0;
+               gint min = _MIN(readed, WORD_LIST_BUFFER_LENGTH-270);
+               while(i<min)
+               {
+                       // check next words
+                       if(g_pattern_match_string (regex, tmp) == TRUE)
+                       {
+                               gchar* new = g_strdup(tmp);
+                               g_array_append_val(result,new);
+                               ++count;
+                               eg_debug("New word %d. \'%s\' matched to "
+                                       "pattern \'%s\'\n",
+                                       count,
+                                       new,
+                                       pattern
+                                       );
+                       }
+                       // calculate length of word
+                       len = strlen(tmp)+1;
+                       // jump in buffer over this word, and ...
+                       tmp += len;
+                       // ...skip offset and length of translation
+                       tmp += 2 * sizeof(guint);
+                       // update i value
+                       i = i + len + 2 * sizeof(guint);
+               }
+               offset = WORD_LIST_BUFFER_LENGTH - i;
+               g_memmove(buffer,buffer+WORD_LIST_BUFFER_LENGTH-offset, offset);
+       }
+       while(further);
+
+       sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        sd_timer(TIMER_START,"callback for returning words LIST START");
+       if (NULL == cb_data )
+       {
+               cb_data = data->cb_search_word_list_data;
+       }
+        data->cb_search_word_list(result,
+                               pattern,
+                               cb_data,
+                               ENGINE_NO_ERROR
+                               );
+        sd_timer(TIMER_STOP,"callback for returning word LIST END");
+       guint i = 0;
+       for (i=0; i<result->len; i++)
+       {
+               g_free(g_array_index(result, gchar*, i));
+       }
+       g_array_free(result, TRUE);
+       g_pattern_spec_free (regex);
+}
+//------------------------------------------------------------------------------
+/** \brief Search translation of word in dictionary.
+ *
+ * @param engine <b>Engine*</b> to search in
+ * @param word <b>gchar*</b> to search for
+ */
+void sd_engine_search_word_translation(Engine* engine,
+                                       gchar* word,
+                                       gpointer cb_data)
+{
+       eg_debug("-> %s() called.\n"
+               "-->PARAM:engine at adress=%p\n"
+               "-->PARAM:word=\'%s\'\n",
+               __FUNCTION__,
+               engine,
+               word);
+       g_assert(engine != NULL);
+       g_assert(word != NULL);
+       // start sd_timer for this function
+       sd_timer(TIMER_START, (gchar*)__FUNCTION__);
+       SDData* data = (SDData*)(engine->engine_data);
+       gchar* trans0 = NULL;
+
+       if (NULL == cb_data )
+       {
+               cb_data = data->cb_search_word_list_data;
+       }
+
+       FilePart* part = sd_find_file_part(data, word);
+       if(!part)
+       {
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               eg_debug("<- %s did not found any article for word: %s",
+                       __FUNCTION__,
+                       word
+                       );
+
+               data->cb_search_word_trans(NULL,
+                                       word,
+                                       cb_data,
+                                       ENGINE_NO_ERROR
+                                       );
+               return;
+       }
+
+       trans0 = data->sd_read_dic_part(part,data->dic_file_name);
+       
+       if(!trans0)
+       {
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               eg_debug("<- %s could not read from *.dict[.dz] file: %s",
+                       __FUNCTION__,
+                       data->dic_file_name
+                       );
+
+               data->cb_search_word_trans(NULL,
+                                       word,
+                                       cb_data,
+                                       ENGINE_NO_ERROR
+                                       );
+               return;
+       }
+
+       // "parse" returned part of file with article about word
+       gchar* trans = sd_parse_stardict_article(trans0,
+                                               data->types,
+                                               part->length
+                                               );
+       g_free(trans0); trans0 = NULL;
+
+       // check if returned article has apprioprate format (only text)
+       if(!trans)
+       {
+               sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+               eg_debug("<- %s could not parse stardict article!",
+                       __FUNCTION__
+                       );
+
+               data->cb_search_word_trans(NULL,
+                                       word,
+                                       cb_data,
+                                       ENGINE_NO_ERROR
+                                       );
+               return;
+       }
+
+       sd_timer(TIMER_STOP,(gchar*)__FUNCTION__);
+       sd_timer(TIMER_START,"callback for returning word's translation START");
+       // calling callback for word translation
+
+       data->cb_search_word_trans(trans,
+                               word,
+                               cb_data,
+                               ENGINE_NO_ERROR
+                               );
+       
+       
+       sd_timer(TIMER_STOP,"callback for returning word's translation END");
+
+       /*if(data->auto_free) {
+               eg_debug("---> %s() deleting all dynamic data because "
+                       "AUTO_FREE=TRUE\n",
+                       __FUNCTION__
+               );
+               g_free(trans);
+       }*/
+       g_free(trans);
+       trans = NULL;
+}
+//------------------------------------------------------------------------------
+/** \brief Print only beggining end end of given buffer
+ *
+ * @param buffer to present
+ */
+static void sd_print_buffer_partial(gchar* buffer)
+{
+#ifndef NOLOGS
+#define PRINT_LEN 100
+#define EDGE "\n-------------------------------------------------------------\n"
+       gchar tmp = 0;
+       guint len = strlen(buffer);
+       if(!buffer)
+       {
+               eg_debug("Buffer is empty!\n");
+       }
+       else if(PRINT_LEN >= len)
+       {
+               eg_debug("Buffer(%p):whole=%s%s%s", buffer, EDGE, buffer, EDGE);
+       }
+       else
+       {
+               // printf first 100 bytes
+               tmp = buffer[PRINT_LEN+1];
+               buffer[PRINT_LEN+1] = '\0';
+               eg_debug("Buffer(%p): first %db=%s%s (....)\n\n",
+                       buffer,
+                       PRINT_LEN,
+                       EDGE,
+                       buffer
+                       );
+               buffer[PRINT_LEN+1] = tmp; 
+
+               //print last 100 bytes
+               eg_debug("Buffer(%p): last %db=\n(....)%s%s",
+                       buffer,
+                       PRINT_LEN,
+                       buffer+len-PRINT_LEN,
+                       EDGE
+                       );
+       }
+#endif
+}
+
+/** \brief Check and parse pure stardict data containing whole article.
+ *
+ * @param buf <b>gchar*</b> buffer with pure data get from stardict 
+ * *.dict[.gz] file
+ * @param type <b>gchar*</b> sametypesequence defined in *.ifo filed - 
+ * defines what kind of data will be in *.dict[.dz] or NULL if *.ifo did not 
+ * define this
+ * @param length <b>guint</b> length of buffer buf
+ * @return <b>gchar*</b> new allocated buffer with proper translation or NULL 
+ * if there were no good data for engine (e.g. if engine do not handle PNG, WAV 
+ * file etc.)
+ */
+gchar* sd_parse_stardict_article(gchar* buf, gchar* type, guint length)
+{
+       eg_debug("-> %s()\n--->PARAM:type=%p\n--->PARAM:length=%d",
+               __FUNCTION__,
+               type,
+               length
+               );
+       sd_print_buffer_partial(buf);
+       sd_timer(TIMER_START, (gchar*)__FUNCTION__);
+       g_assert(buf != NULL);
+       g_assert(length > 0);
+
+       gchar* result = (gchar*)g_try_malloc0(sizeof(gchar));
+       result[0] = '\0';
+       gchar next_type = 0;
+       gchar* ptr = buf;
+
+       while(length > 0)
+       {
+               if(type == NULL)
+               {
+                       memcpy(&next_type, ptr, sizeof(gchar));
+                       ++ptr;
+                       --length;
+               }
+               else
+               {
+                       next_type = type[0];
+                       ++type;
+               }
+       
+               // check if this is a text or binary data
+               // all text data are signaled by low level letter
+               if(g_ascii_islower(next_type))
+               {
+                       // text, so add this to translation
+                       gchar* new_txt = sd_get_buffer_from_article(&ptr,
+                                                               &length
+                                                               );
+                       gchar* new_tra = g_strconcat(result,
+                                               new_txt,
+                                               "\n<br/>",
+                                               NULL
+                                               );
+                       g_free(result);
+                       result = new_tra;
+                       new_tra = NULL;
+                       g_free(new_txt);
+                       new_txt = NULL;
+               }
+               else
+               {
+                       // binary, so skip it
+                       // read hom many bytes to skip
+                       guint len = 0;
+                       g_memmove(&len, ptr, sizeof(guint));
+                       //omit in buf and len - field containting size of data
+                       length -= sizeof(guint);
+                       ptr += sizeof(guint);
+                       // conver network byte oredered guint to host ordered
+                       len = ntohl(len);
+                       // skip uneeded bytes
+                       length -= len;
+                       ptr += len;
+               }
+       }
+
+       sd_timer(TIMER_STOP, (gchar*)__FUNCTION__);
+       eg_debug("<- %s() returned buffer at %p\n",__FUNCTION__,result);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get string from buffer.
+ *
+ * Function gets from buffer string of char NULL-terminated, but no more than
+ * len. Additionaly it update start position of the buffer and lenght of buffer
+ * left.
+ *
+ * @param buffer <b>gchar**</b> with part of article
+ * @param len <b>guint</b> number of bytes which could be maximally readed
+ * @return <b>gchar*</b> next string available in the buffer
+ */
+gchar* sd_get_buffer_from_article(gchar** buffer, guint* len)
+{
+       eg_debug("-> %s\n",__FUNCTION__);
+       g_assert(len > 0);
+
+       guint buf_len = 0;
+       gchar* tmp = *buffer;
+       while(tmp && *len > 0)
+       {
+               ++buf_len;
+               ++tmp;
+               --(*len);
+       }
+
+       gchar* result = (gchar*)g_try_malloc0(buf_len+1);
+       g_memmove(result, *buffer, buf_len);
+       result[buf_len] = '\0';
+
+       *buffer = tmp;
+       eg_debug("<- %s\n",__FUNCTION__);
+       return result;
+}
+
+//------------------------------------------------------------------------------
+//==============================================================================
+//==============================================================================
+//==============================================================================
+//----------------------------------------------------------- FINISHED FUNCTIONS
+//==============================================================================
+/** \brief Trying to find file names of default StarDict dictionary files
+ *
+ * @param data <b>SDData*</b> this is a structure from which function gets
+ * directory to search in (data->dict_path) for files. Also puts there founded
+ * (if any) filenames (data->[idx|ifo|dic]_file_name)
+ * @return <b>gboolean</b> telling us are there all of obligatory StarDict files
+ * in directory: data->dict_path
+ */
+gboolean sd_read_files_names(SDData* data) {
+       eg_debug("-> %s()\n",__FUNCTION__);
+       GError *dir_err = NULL;
+       gchar* tmp = data->dict_path;
+       GDir* dir = g_dir_open (tmp, 0, &dir_err);
+       if(!dir) 
+       {
+               eg_debug("---> Could not open a dir:\n%s\n",data->dict_path);
+               return FALSE;
+       }
+       gboolean ifo = FALSE;
+       gboolean idx = FALSE;
+       gboolean dic = FALSE;
+       const gchar* fn = g_dir_read_name(dir);
+
+       while((fn != NULL) && !(ifo && idx && dic)) 
+       {
+               if(g_str_has_suffix(fn, ".ifo")) 
+               {
+                       data->ifo_file_name = g_strconcat(tmp,"/",fn,NULL);
+                       ifo = TRUE;
+               };
+               if(g_str_has_suffix(fn, ".idx")) 
+               {
+                       data->idx_file_name = g_strconcat(tmp,"/",fn,NULL);
+                       data->idx_compressed = FALSE;
+                       data->sd_open_idx = sd_open;
+                       data->sd_read_idx = sd_read;
+                       data->sd_seek_idx = sd_seek;
+                       data->sd_close_idx = sd_close;
+                       idx = TRUE;
+               };
+               if(g_str_has_suffix(fn, ".idx.gz")) 
+               {
+                       data->idx_file_name = g_strconcat(tmp,"/",fn,NULL);
+                       data->idx_compressed = TRUE;
+                       data->sd_open_idx = sd_open_z;
+                       data->sd_read_idx = sd_read_z;
+                       data->sd_seek_idx = sd_seek_z;
+                       data->sd_close_idx = sd_close_z;
+                       idx = TRUE;
+               };
+               if(g_str_has_suffix(fn, ".dict")) 
+               {
+                       data->dic_file_name = g_strconcat(tmp,"/",fn,NULL);
+                       data->dic_compressed = FALSE;
+                       data->sd_read_dic_part = sd_read_file_part;
+                       dic = TRUE;
+               };
+               if(g_str_has_suffix(fn, ".dict.dz")) 
+               {
+                       data->dic_file_name = g_strconcat(tmp,"/",fn,NULL);
+                       data->dic_compressed = TRUE;
+                       data->sd_read_dic_part = sd_read_file_part_dz;
+                       dic = TRUE;
+               };
+               fn = g_dir_read_name(dir);
+       }
+       g_dir_close(dir);
+
+       if(ifo && idx && dic)
+       {
+               eg_debug("---> Dictionary files :\nifo=%s\nidx=%s\ndict=%s\n",
+                       data->idx_file_name,
+                       data->idx_file_name,
+                       data->dic_file_name
+                       );
+               data->idx_file = data->sd_open_idx(data->idx_file_name);
+               if(data->idx_file == NULL)
+               {
+                               g_free(data->idx_file_name);
+                               data->idx_file_name = NULL;
+                               g_free(data->ifo_file_name);
+                               data->ifo_file_name = NULL;
+                               g_free(data->dic_file_name);
+                               data->dic_file_name = NULL;
+                               eg_debug("---> Could no open *.idx file!");
+                               return FALSE;
+               }
+               eg_debug("<- %s()\n",__FUNCTION__);
+               return TRUE;
+       }
+       else 
+       {
+               if(idx) 
+               {
+                       g_free(data->idx_file_name);
+                       data->idx_file_name = NULL;
+               }
+               if(ifo) 
+               {
+                       g_free(data->ifo_file_name);
+                       data->ifo_file_name = NULL;
+               }
+               if(dic) 
+               {
+                       g_free(data->dic_file_name);
+                       data->dic_file_name = NULL;
+               }
+       }
+       eg_debug("<- %s()\n",__FUNCTION__);
+       return FALSE;
+}
+// -----------------------------------------------------------------------------
+/** \brief Check if location is a proper location of StarDict dictionary.
+ *
+ * @param location <b>gchar*</b> location to check
+ * @return <b>gboolean</b> telling if this location is location of some 
+ * StarDict dictionary
+ */
+gboolean sd_engine_check(gchar* location) 
+{
+       eg_debug("-> %s()\n--->PARAM:location=%s\n",
+               __FUNCTION__,
+               location
+               );
+       g_assert(location);
+
+       gboolean result = TRUE; 
+       gchar* filepath = g_strdup(location);
+       string_to_path(&filepath);
+       if (filepath == NULL)
+       {
+               result = FALSE;
+               eg_debug("---> %s is not a proper path!\n",location);
+       }
+       else
+       {
+               SDData* tmp = g_try_malloc0(sizeof(SDData));
+               tmp->dict_path = filepath;
+
+               result = sd_read_files_names(tmp);
+
+               g_free(tmp->idx_file_name);
+               g_free(tmp->ifo_file_name);
+               g_free(tmp->dic_file_name);
+               g_free(tmp); tmp = NULL;
+       };
+       g_free(filepath);
+
+       eg_debug("<- %s() returned bool statement=%s.\n",
+               __FUNCTION__,
+               PRINT_STATE(result)
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Simple measuring of time needed for functions to work.
+ *
+ * @param start <b>gboolean</b> if we pass flag TIMER_START timer will start 
+ * to work and if we pass TIMER_STOP timer will stop working and print short 
+ * summary of working time
+ * @return <b>gdouble</b> time in seconds for which function has been working
+ * or (if we pass TIMER_START as a flag) 0.0.
+ */
+static double timer(gboolean start, gchar* message)
+{
+       static GArray* stack = NULL;
+       static gboolean first_run = TRUE;
+       static struct timeval actual_time;
+       static struct timeval last_time;
+       static struct timeval result;
+       static double seconds = 0.0;
+       if(first_run)
+       {
+               first_run = FALSE;
+               stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+       };
+
+       if (start)
+       {
+               eg_debug("TIMER:function %s()'s timer has started.\n",message);
+               g_array_prepend_val(stack, actual_time);
+               gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+               return -1.0;
+       }
+       // we just want to end some sd_timer - print some information about 
+       // working time;
+       else {
+               gettimeofday(&actual_time,NULL);
+               last_time = g_array_index(stack, struct timeval, 0);
+               g_array_remove_index(stack, 0);
+
+               if (actual_time.tv_usec < last_time.tv_usec)
+               {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       (1000000 + 1);
+                       last_time.tv_usec -= 1000000 * nsec;
+                       last_time.tv_sec += nsec;
+               }
+               if (actual_time.tv_usec - last_time.tv_usec > 1000000)
+               {
+                       int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                       1000000;
+                       last_time.tv_usec += 1000000 * nsec;
+                       last_time.tv_sec -= nsec;
+               }
+               result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+               result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+               seconds = (((double)(result.tv_usec)) / 1e6) +
+                       ((double)(result.tv_sec));
+
+               eg_debug("TIMER:Function \'%s()\' was working for: %g "
+                       "[s] or %ld [us].\n",
+                       message,
+                       seconds,
+                       ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                       );
+               // stack is empty so we delete everything
+               if(stack->len == 0)   
+               {
+                       g_array_free(stack, TRUE);
+                       first_run = TRUE;
+               }
+       }
+       return seconds;
+}
+//------------------------------------------------------------------------------
+/** \brief Cleans string and check if this is a proper directory path.
+ *
+ * @param string <b>gchar**</b> it is pointer to string which we want to check
+ * if it is proper directory/file path
+ * @return <b>gchar*</b> this is cleaned string (without filename at the end, 
+ * spaces etc.) or NULL if passed string under pointer do not describe existing 
+ * directory/file. On to this string points also passed pointer.
+ *
+ */
+static gchar* string_to_path(gchar** string)
+{
+       eg_debug("-> %s()\n-->PARAM:string=%s\n",__FUNCTION__,string[0]);
+
+       gchar* arg = string[0];
+       gchar* new = NULL;
+       // cleaning from leading and trailing whitespaces
+       g_strstrip(arg); 
+       // add current directory if this is not absolute directory
+       if (!g_path_is_absolute(arg))
+       {
+               gchar* tmp = g_get_current_dir();
+               new = g_strconcat(tmp,"/",arg,NULL);
+               g_free(arg); arg = new; new = NULL;
+       };
+       // this is not a directory
+       if (!g_file_test(arg, G_FILE_TEST_IS_DIR))
+       {
+               // if this is wrong filepath, string was wrong
+               if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR))
+               {
+                       g_free(arg);
+                       new = NULL;
+               }
+               //if this is a file, remove filename
+               else
+               {
+                       new = g_path_get_dirname (arg);
+                       g_free(arg);
+               }
+       }
+       // this is a directory
+       else
+       {
+               // remove suffix "/" if neded...     
+               if (g_str_has_suffix(arg,"/") )
+               {
+                       new = g_path_get_dirname (arg);
+                       g_free(arg);
+               }
+               else
+               {
+                       new = arg;
+               }
+       };
+       // now in new should be proper filepath, if not, string was wrong
+       if (!g_file_test(new, G_FILE_TEST_IS_DIR))
+       {
+               // if that directory does not exist, passed string wasn't proper
+               g_free(new);
+               new = NULL;
+       };
+       // replace string under passed address
+       string[0] = new;
+       eg_debug("<- %s() returned string=%s\n",__FUNCTION__,string[0]);
+       return new;
+}
+//------------------------------------------------------------------------------
+/** \brief Get full filename (with path) to the icon file for this dictionary
+ *
+ * @param engine <b>Engine*</b> pointer to engine to which we want to get icon
+ * @return <b>gchar*</b> string containing full filepath with filename to icon
+ * file. If auto_free=FALSE of engine You should free this string if you do not
+ * need it any more. If auto_free is set to TRUE you should remember to not
+ * modyfing returned string!
+ */
+gchar* sd_engine_get_icon_path(Engine* engine)
+{
+       eg_debug("-> %s\n",__FUNCTION__);
+       
+       gchar* result;
+       SDData* data = (SDData*)(engine->engine_data);
+       if(data->auto_free)
+       {
+               result = data->icon;
+       }
+       else
+       {
+               result = g_strdup(data->icon);
+       }
+
+       eg_debug("<- %s return string = \"%s\"\n",__FUNCTION__,result);
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Function not supported.
+ */
+gboolean sd_engine_add_word(Engine* engine, gchar*  word, gchar*  translation)
+{
+       eg_debug("<->%s Operation not supported in this engine\n",__FUNCTION__);
+       return FALSE;
+}
+//------------------------------------------------------------------------------
+/** \brief Function not supported.
+ */
+gboolean sd_engine_remove_word(Engine* engine, gchar*  word)
+{
+       eg_debug("<->%s Operation not supported in this engine\n",__FUNCTION__);
+       return FALSE;
+} 
+//------------------------------------------------------------------------------
+/** \brief Get language FROM which this dictionary translates.
+ *
+ * @param engine <b>Engine*</b> to check
+ */
+gchar* sd_engine_get_lang_from(Engine* engine)
+{
+       eg_debug("-> %s\n",__FUNCTION__);
+
+       gchar* result;
+       SDData* data = (SDData*)(engine->engine_data);
+       if(data->auto_free)
+       {
+               result = data->lang_from;
+       }
+       else
+       {
+               result = g_strdup(data->lang_from);
+       }
+
+       eg_debug("<- %s return string = \"%s\"\n",__FUNCTION__,result);
+       return result;  
+}
+//------------------------------------------------------------------------------
+/** \brief Get language TO which this dictionary translates.
+ *
+ * @param engine <b>Engine*</b> to check
+ */
+gchar* sd_engine_get_lang_to(Engine* engine)
+{
+       eg_debug("-> %s\n",__FUNCTION__);
+
+       gchar* result;
+       SDData* data = (SDData*)(engine->engine_data);
+       if(data->auto_free)
+       {
+               result = data->lang_to;
+       }
+       else
+       {
+               result = g_strdup(data->lang_to);
+       }
+
+       eg_debug("<- %s return string = \"%s\"\n",__FUNCTION__,result);
+       return result;  
+}
+//------------------------------------------------------------------------------
+/** \brief Gets title of dictionary.
+ *
+ * @param engine <b>Engine*</b> which title we want to get
+ */
+gchar* sd_engine_get_title(Engine* engine)
+{
+       eg_debug("-> %s\n",__FUNCTION__);
+
+       gchar* result;
+       SDData* data = (SDData*)(engine->engine_data);
+       if(data->auto_free)
+       {
+               result = data->title;
+       }
+       else
+       {
+               result = g_strdup(data->title);
+       }
+
+       eg_debug("<- %s return string = \"%s\"\n",__FUNCTION__,result);
+       return result;  
+}
+//------------------------------------------------------------------------------
+/** \brief Sets callbacks for this dictionary.
+ *
+ * @param engine <b>Engine*</b>which callback we want to set
+ * @param signal <b>gchar*</b> define which callback we want to set
+ * @param c_handler <b>gpointer</b> function which we want to handle signal 
+ * callback
+ * @param user_data <b>gpointer</b> which will be passed always as a argument 
+ * to callback
+ * \sa dict_eng_set_callback
+ */
+gpointer sd_engine_set_callback(Engine* engine,
+                            gchar* signal,
+                            gpointer c_handler,
+                            gpointer user_data)
+{
+       eg_debug("-> %s().\n",__FUNCTION__);
+       g_assert(engine != NULL);
+       g_assert(signal != NULL);
+       g_assert(c_handler != NULL);
+       SDData* data = (SDData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)
+       {
+               gpointer result = data->cb_progress_caching;
+               data->cb_progress_caching = c_handler;
+               data->cb_progress_caching_data = user_data;
+               eg_debug("---> %s() sets handler for signal \"%s\".\n",
+                       __FUNCTION__,
+                       signal
+                      );
+               eg_debug("---> %s() Function at adress =  %p.\n",
+                       __FUNCTION__,
+                       c_handler
+                      );
+               eg_debug("---> %s()     Data at adress =  %p.\n",
+                       __FUNCTION__,
+                       user_data
+                      );
+               eg_debug("<- %s().\n",__FUNCTION__);
+               return result;
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0)
+       {
+               gpointer result = data->cb_search_word_list;
+               data->cb_search_word_list = c_handler;
+               data->cb_search_word_list_data = user_data;
+               eg_debug("---> %s() sets handler for signal \"%s\".\n",
+                       __FUNCTION__,
+                       signal
+                      );
+               eg_debug("---> %s() Function at adress =  %p.\n",
+                       __FUNCTION__,
+                       c_handler
+                      );
+               eg_debug("---> %s()     Data at adress =  %p.\n",
+                       __FUNCTION__,
+                       user_data
+                      );
+               eg_debug("<- %s().\n",__FUNCTION__);
+               return result;
+       }
+       else if(g_ascii_strcasecmp(signal, ENGINE_WORD_TRANSLATION_SIGNAL) == 0)
+       {
+               gpointer result = data->cb_search_word_trans;
+               data->cb_search_word_trans = c_handler;
+               data->cb_search_word_trans_data = user_data;
+               eg_debug("---> %s() sets handler for signal \"%s\".\n",
+                       __FUNCTION__,
+                       signal
+                       );
+               eg_debug("---> %s() Function at adress =  %p.\n",
+                       __FUNCTION__,
+                       c_handler
+                       );
+               eg_debug("---> %s()     Data at adress =  %p.\n",
+                       __FUNCTION__,
+                       user_data
+                       );
+               eg_debug("<- %s().\n",__FUNCTION__);
+               return result;   
+       }
+       else
+       {
+               eg_warning("---> %s() unsupported signal: %s.\n",
+                               __FUNCTION__,
+                               signal
+                               );
+               eg_debug("<- %s().\n",__FUNCTION__);
+               return NULL;
+       }
+}
+//------------------------------------------------------------------------------
+// for macro: dict_eng_set_progress_seed(engine, signal, val)
+/** \brief Sets how often should be called concrete progress calback.
+ *
+ * @param engine <b>Engine*</b> for which we want set seed for progress proccess
+ * @param signal <b>gchar*</b> for which we want to set seed
+ * @param seed <b>gdouble</b> which we want to set
+ */
+void sd_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed)
+{
+       eg_debug("-> %s().\n",__FUNCTION__);
+       SDData* data = (SDData*)(engine->engine_data);
+       if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)
+       {
+               data->cb_progress_caching_seed = seed;
+               eg_debug("--->%s() sets new seed=%0.2f for for signal %s.\n",
+                       __FUNCTION__,
+                       seed,
+                       signal
+                       );
+       }
+       else
+       {
+               g_warning("--->%s() unsupported signal for progress: %s.\n",
+                       __FUNCTION__,
+                       signal
+                       );
+       };
+       eg_debug("<- %s().\n",__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+/** \brief Get the last status of engine.
+ *
+ * @param engine <b>Engine*</b> which status we want to get
+ * @return <b>EngineStatus</b> status of the engine
+ * \sa dict_eng_get_last_status
+ */
+EngineStatus sd_engine_status(Engine* engine) 
+{
+       eg_debug("-> %s()\n--->PARAM:engine at adress=%p\n",
+               __FUNCTION__,
+               engine
+               );
+       SDData* data = (SDData*)(engine->engine_data);
+       eg_debug("<- %s() returned error code: %d\n",
+               __FUNCTION__,
+               (gint)(data->last_error)
+               );
+       return data->last_error;
+}
+//------------------------------------------------------------------------------
+/** \brief Tells if engine is optimized or not - not supported in StarDict.
+ */
+gboolean sd_engine_is_optimized(Engine* engine) 
+{
+       eg_debug("-> %s() for engine at adress=%p\n",
+               __FUNCTION__,
+               engine
+               );
+       g_assert(engine != NULL);
+
+       gboolean result = TRUE;
+
+       eg_debug("<- %s() returned bool statement=%s.\n",
+               __FUNCTION__,
+               PRINT_STATE(result)
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Optimize dictionary - not supported in StarDict dictionaries.
+ */
+void sd_engine_optimize(Engine* engine)
+{
+       eg_debug("-> %s() called for engine at adress=%p\n",
+               __FUNCTION__,
+               engine
+               );
+       eg_debug("---> Unsupported method for this engine\n");
+       eg_debug("<- %s()\n",__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+/** \brief Get structure and access to all module functions.
+ *
+ * @return <b>EngineModule</b> structure containing all functions which are 
+ * needed to handle new dictionary's format
+ */
+EngineModule engine_global_functions()
+{
+       eg_debug("-> %s() called.\n",__FUNCTION__);
+       EngineModule result; 
+       result.engine_check      = sd_engine_check;
+       result.engine_description= sd_engine_description;
+       result.engine_format     = sd_engine_format;
+       result.engine_version    = sd_engine_version;
+       result.engine_create     = sd_engine_create;
+       eg_debug("<- %s() returned EngineModule at adress=%p.\n",
+               __FUNCTION__,
+               &result
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Translate status code to meaningful, human-readable information.
+ *
+ * @param status <b>EngineStatus</b> to translates
+ * @return <b>gchar*</b> message describing status (e.g. its reason etc.)
+ * \sa dict_eng_status_message
+ */
+gchar* sd_engine_status_message(EngineStatus status) 
+{
+       eg_debug("<-> %s() called.\n",__FUNCTION__);
+       switch (status)
+       {
+               case ENGINE_NO_ERROR:
+                       return "No error.";
+               case ENGINE_WRONG_FILE:
+                       return "File, You are trying to use, is wrong type.";
+               case ENGINE_COULDNT_READ:
+                       return "Could not read from file.";
+               case ENGINE_NO_FILE:
+                       return "There is no such a file.";
+               case ENGINE_OUT_OF_MEMORY:
+                       return "There were no enough memory for this action.";
+               default:
+                       return "Wrong engine's status identifier!";
+       }
+}
+//------------------------------------------------------------------------------
+/** \brief Gets version of module.
+ * @return <b>gchar*</b> version of this module.
+ * \sa dict_eng_module_get_version
+ */
+gchar* sd_engine_version() 
+{
+       eg_debug("-> %s()\n",__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_VERSION);
+       eg_debug("<- %s() return string=%s\n",
+               __FUNCTION__,
+               result
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get information about what kind of dictionaries this engine support.
+ *
+ * @return <b>gchar*</b> telling about supported dictionaries (e.g. XDXF, 
+ * StarDict etc.)
+ * \sa dict_eng_module_get_format
+ */
+gchar* sd_engine_format() 
+{
+       eg_debug("-> %s()\n",__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_FORMAT);
+       eg_debug("<- %s() return string=%s\n",
+               __FUNCTION__,
+               result
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get short description of the module - dictionary engine.
+ *
+ * @return <b>gchar*</b> description of the module
+ * \sa dict_eng_module_get_description
+ */
+gchar* sd_engine_description() 
+{
+       eg_debug("-> %s()\n",__FUNCTION__);
+       gchar* result = g_strdup(DIC_ENG_DESCRIPTION);
+       eg_debug("<- %s() return string=%s\n",
+               __FUNCTION__,
+               result
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Get path to the dictionary - location of its files.
+ *
+ * @param engine <b>Engine*</b> which directory path we want to get
+ * @return <b>gchar*</b> location of the dictionary
+ * \sa dict_eng_get_location
+ */
+gchar* sd_engine_location(Engine* engine)
+{
+       eg_debug("->%s() called.\n-->PARAM: engine adress=%p\n",
+               __FUNCTION__,
+               engine
+               );
+       g_assert(engine != NULL);
+       SDData* data = (SDData*)(engine->engine_data);
+       gchar* result;
+       if(data->auto_free)
+       {
+               result = data->dict_path;
+       }
+       else
+       {
+               result = g_strdup(data->dict_path);
+       }
+
+       eg_debug("<- %s() returned string=%s\n",
+               __FUNCTION__,
+               result
+               );
+       return result;
+}
+//------------------------------------------------------------------------------
+/** \brief Set auto free status for engine.
+ *
+ * When auto flag is set to TRUE, user of engine do not have to worry about 
+ * freeing any of buffer returned by the engine. Engine will clean up
+ * everything. When auto free is set as FALSE, user has to remember that every-
+ * thing returned from engine should be deallocated.
+ *
+ * @param engine <b>Engine*</b> which auto free flag we want to sets
+ * @param state <b>gboolean</b> new value for auto free flag
+ * \sa dict_eng_set_auto_free
+ */
+void sd_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+       eg_debug("-> %s()\n"
+               "--->PARAM:engine at adress=%p\n--->PARAM:state=%s\n",
+               __FUNCTION__,
+               engine,
+               PRINT_STATE(state)
+               );
+       g_assert(engine != NULL);
+       SDData* data = (SDData*)(engine->engine_data);
+       data->auto_free = state;
+       eg_debug("<- %s() Current auto_free is %s\n",
+               __FUNCTION__,
+               PRINT_STATE(data->auto_free)
+              );
+}
+//------------------------------------------------------------------------------
+/** \brief Parse single record from *.ifo file from StarDict dictionary
+ *
+ * @param data <b>SDData*</b> structure which we will try to complete with
+ * information from new record
+ * @param key <b>gchar*</b> string representing key of record
+ * @param value <b>gchar*</b> value of the key in record
+ */
+void sd_parse_record(SDData* data,gchar* key, gchar* value)
+{
+       if(g_ascii_strncasecmp(key,"version",100) == 0)
+       {
+       }
+       else if(g_ascii_strncasecmp(key,"bookname",100) == 0)
+       {
+               data->title = g_strdup(value);
+               eg_debug("%s set title to: %s\n",__FUNCTION__, data->title);
+       }
+       else if(g_ascii_strncasecmp(key,"wordcount",100) == 0)
+       {
+               data->word_count = (gint)g_ascii_strtoull( value, NULL, 10);
+               eg_debug("%s set word count to: %d\n",
+                       __FUNCTION__,
+                       data->word_count
+                       );
+       }
+       else if(g_ascii_strncasecmp(key,"idxfilesize",100) == 0)
+       {
+               data->idx_file_length = (gint)g_ascii_strtoull(value, NULL, 10);
+               eg_debug("%s set idx file length to: %d\n",
+                       __FUNCTION__,
+                       data->idx_file_length
+                       );
+       }
+       else if(g_ascii_strncasecmp(key,"sametypesequence",100) == 0)
+       {
+               data->types = g_strdup(value);
+               eg_debug("%s set data types to: %s\n",__FUNCTION__,data->types);
+       }
+       else
+       {
+               eg_debug("%s trying to set usupported field\n",__FUNCTION__);
+       }
+       /* ----- as far unsupported field from *.ifo files
+       else if(g_ascii_strncasecmp(key,"author",100))
+       {
+       }
+       else if(g_ascii_strncasecmp(key,"email",100))
+       {
+       }
+       else if(g_ascii_strncasecmp(key,"website",100))
+       {
+       }
+       else if(g_ascii_strncasecmp(key,"description",100))
+       {
+       }
+       else if(g_ascii_strncasecmp(key,"date",100))
+       {
+       } */
+}
+//------------------------------------------------------------------------------
+/** \brief Try to read and parse whole *.ifo file from StarDict Dictionary
+ *
+ * @param data <b>SDData*</b> structure to which we try save information about
+ * dictionary in data->dict_path path
+ * @return <b>gboolean</b> if data->dict_path is good path and it contains all 
+ * obligatory StarDict files, function return TRUE. Otherwise return FALSE.
+ */
+gboolean sd_parse_ifo_file(SDData* data)
+{
+       GnomeVFSHandle* fd = NULL;
+       GnomeVFSResult  fr = 0;
+       GnomeVFSFileSize n = 0;
+       GnomeVFSFileSize k = 0;
+
+       if(!gnome_vfs_initialized ())
+       {
+               gnome_vfs_init ();                       
+       };
+       // open the file
+       fr = gnome_vfs_open (&fd, data->ifo_file_name, GNOME_VFS_OPEN_READ);
+       if(fr != GNOME_VFS_OK)
+       {
+               eg_warning("Error while trying to open file:\n%s\n",
+                       data->ifo_file_name
+                       );
+               return FALSE;
+       }
+       gnome_vfs_seek(fd, GNOME_VFS_SEEK_END, 0);
+       fr = gnome_vfs_tell(fd, &n);
+       gnome_vfs_seek(fd, GNOME_VFS_SEEK_START, 0);
+       // read whole content
+       gchar* tmp = g_try_malloc0(sizeof(gchar)*((gint)(n)));
+       fr = gnome_vfs_read(fd, tmp, n, &k);
+       if(fr != GNOME_VFS_OK) {
+               eg_warning("Error while trying to read file:\n%s\n",
+                       data->ifo_file_name
+                       );
+               gnome_vfs_close(fd);
+               return FALSE;
+       }
+       gnome_vfs_close(fd);    
+       // now we have in tmp whole content of file, we have to "parse it"
+       gchar** table = g_strsplit(tmp, "\n", 100);
+       gint i;
+       for(i=0; table[i]!=NULL; ++i)
+       {
+               gchar* eq = g_strstr_len (table[i], 0xffff, "=");
+               if(eq == NULL) continue;
+               *eq = '\0';
+               ++eq;
+               eg_debug("SD *.ifo record -> Key=%s => Value=%s\n",table[i],eq);
+               sd_parse_record(data, table[i], eq);
+       }
+
+       g_free(tmp); tmp = NULL;
+       g_strfreev(table); table = NULL;
+       if(data->title)
+       {
+               return TRUE;
+       }
+       else 
+       {
+               return FALSE;
+       }
+}
+//------------------------------------------------------------------------------
+//-------------------------------------------------------------- STANDARD ------
+//------------------------------------------------------------------------------
+/** \brief Opening file not compressed
+ * 
+ * @param filename <b>gchar*</b> full filename (with path) to file to open
+ * @return <b>gpointer</b> pointer to memory which is needed for other functions
+ * from this wrapper. Under this pointer could be simple gint or more
+ * complicated structure - depends on what kind of file we are trying to open.
+ * If opening failed - function return NULL.
+ */
+static gpointer sd_open(gchar* filename)
+{
+       gint tmp = open(filename, O_RDONLY);
+       if(tmp == -1)
+       {
+               eg_debug("---> Error while trying to open file %s\n",filename);
+               return NULL;
+       }
+       gint* result = (int*)g_try_malloc0(sizeof(gint));
+       *result = tmp;
+       return (gpointer)result;
+}
+//------------------------------------------------------------------------------
+/** \brief Reading from not compressed file
+ * 
+ * @param f <b>gpointer</b> pointer returned from sd_open()
+ * @param buffer <b>gchar*</b> buffer where data should be put after reading
+ * @param l <b>gint</b> maximum bytes to read. Effective number of bytes readed
+ * could be different from this argument and is returned from function.
+ * @return <b>gint</b> effective number of readed bytes
+ */
+static gint sd_read(gpointer f, gchar* buffer, gint l)
+{
+       gint tmp = *((gint*)(f));
+       return (gint)read(tmp, buffer, l);
+}
+//------------------------------------------------------------------------------
+/** \brief Seek throught not compressed files
+ *
+ * @param f <b>gpointer</b>  pointer returned from sd_open()
+ * @param l <b>glong</b> offset which we want to seek
+ * @param from <b>gchar</b> postion from which we want to seek. Possible values
+ * are:\n _FILES_WRAPPER_BEG for the beggining of file \n
+ * _FILES_WRAPPER_CUR for the current position \n
+ * _FILES_WRAPPER_END for the end of file.
+ * @return <b>glong</b> previous position in file if operation was successful,
+ * or non positive value if there was an error.
+ */
+static glong sd_seek(gpointer f, glong l, gchar from)
+{
+       gint tmp = *((gint*)(f));
+       switch(from)
+       {
+               case _FILES_WRAPPER_BEG:
+                       return (glong)lseek(tmp, l, SEEK_SET);
+               case _FILES_WRAPPER_CUR:
+                       return (glong)lseek(tmp, l, SEEK_CUR);
+               case _FILES_WRAPPER_END:
+                       return (glong)lseek(tmp, l, SEEK_END);
+               default:
+                       eg_debug("---> Wrong relative position for sd_seek!\n");
+                       return -2;
+       }
+}
+//------------------------------------------------------------------------------
+/** \brief Close uncompressed file
+ *
+ * @param f <b>gpointer</b> pointer returned from sd_open() - file to close.
+ */
+static void sd_close(gpointer f)
+{
+       gint tmp = *((gint*)(f));
+       close(tmp);
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------- GZIPPED --------------
+//------------------------------------------------------------------------------
+/** \brief Opening file compressed with standard gzip
+ * 
+ * @param filename <b>gchar*</b> full filename (with path) to file to open
+ * @return <b>gpointer</b> pointer to memory which is needed for other functions
+ * from this wrapper. Under this pointer could be simple gint or more
+ * complicated structure - depends on what kind of file we are trying to open.
+ * If opening failed - function return NULL.
+ */
+static gpointer sd_open_z(gchar* filename)
+{
+       gzFile* out = (gzFile*)g_try_malloc0(sizeof(gzFile));
+       *out = gzopen(filename, "rb9");
+       if(out == NULL)
+       {
+               eg_debug("Error while opening compressed file with gzip!\n");
+       }
+       return (gpointer)out;
+}
+//------------------------------------------------------------------------------
+/** \brief Reading from compressed file with gzip
+ * 
+ * @param f <b>gpointer</b> pointer retunred from sd_open()
+ * @param buffer <b>gchar*</b> buffer where data should be put after reading
+ * @param l <b>gint</b> maximum bytes to read. Effective number of bytes readed
+ * could be different from this argument and is returned from function.
+ * @return <b>gint</b> effective number of readed bytes
+ */
+static gint sd_read_z(gpointer f, gchar* buffer, gint l)
+{
+       gzFile tmp = *((gzFile*)f);
+       return (gint)gzread(tmp, buffer, l);
+}
+//------------------------------------------------------------------------------
+/** \brief Seek throught compressed files with gzip
+ *
+ * @param f <b>gpointer</b>  pointer returned from sd_open()
+ * @param l <b>glong</b> offset which we want to seek
+ * @param from <b>gchar</b> postion from which we want to seek. Possible values
+ * are:\n _FILES_WRAPPER_BEG for the beggining of file \n
+ * _FILES_WRAPPER_CUR for the current position \n
+ * _FILES_WRAPPER_END for the end of file.
+ * @return <b>glong</b> previous position in file if operation was successful,
+ * or non positive value if there was an error.
+ */
+static glong sd_seek_z(gpointer f, glong l, gchar from)
+{
+       gzFile tmp = *((gzFile*)f);
+       switch(from)
+       {
+               case _FILES_WRAPPER_BEG:
+                       return (glong)gzseek(tmp, l, SEEK_SET);
+               case _FILES_WRAPPER_CUR:
+                       return (glong)gzseek(tmp, l, SEEK_CUR);
+               default:
+                       eg_debug("---> Wrong position for sd_seek_z!\n");
+                       return -2;
+       }
+}
+//------------------------------------------------------------------------------
+/** \brief Close compressed file with gzip
+ *
+ * @param f <b>gpointer</b> pointer returned from sd_open() - file to close.
+ */
+static void sd_close_z(gpointer f)
+{
+       gzFile tmp = *((gzFile*)f);
+       gzclose(tmp);
+}
diff --git a/src/plugins/stardict/src/test.c b/src/plugins/stardict/src/test.c
new file mode 100755 (executable)
index 0000000..0239d5b
--- /dev/null
@@ -0,0 +1,133 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+#define DICT_PATH0 "/home/str/whitestork/stardictDicts/stardict-comn_dictd03_slovnyk_pl-ru-2.4.2"
+#define DICT_PATH1 "/home/str/whitestork/stardictDicts/stardict-comn_dictd03_slovnyk_pl-en-2.4.2"
+#define DICT_PATH2 "/home/str/whitestork/stardictDicts/stardict-dictd_www.dict.org_foldoc-2.4.2"
+#define DICT_PATH3 "/home/str/whitestork/stardictDicts/stardict-dictd_www.freedict.de_eng-fra-2.4.2"
+#define DICT_PATH4 "/home/gandzia/MyDocs/.documents/stardict-comn_dictd03_engcom-2.4.2"
+#define DICT_PATH5 "/home/lukasz/MyDocs/stardict-foldoc"
+#define DICT_PATH6
+
+
+#define DICT_PATH DICT_PATH5
+
+gchar* dictionaries[] = {
+       DICT_PATH0,
+       DICT_PATH1,
+       DICT_PATH2,
+       DICT_PATH3,
+       NULL
+};
+
+getting_additional get_functions; // additional functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "StarDictEngine test: ";
+       printf("%sStarting test program of module: dictionary_engine - StarDict\n",nameApp);
+
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/bin/engine_stardict.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       if(!library)
+       {
+               printf("%sLoading module failed. \nReason: %s\n",nameApp,g_module_error());
+               return 1;               
+       };
+       
+       g_module_symbol ( (library),_GLOBAL_FUNCTIONS_NAME_, (gpointer)&get_functions);
+       if(get_functions == NULL)
+       {
+               printf("%sLoading function failed\n",nameApp);
+               return 2;
+       }
+       else 
+       {
+               printf("%sLoading function OK\n",nameApp);
+       }
+
+       EngineModule module = get_functions();
+       printf("Module description: %s\n",dict_eng_module_get_description(module));
+       Engine* sd;
+       
+        gboolean is_compatible = dict_eng_module_check(module, DICT_PATH);
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+       
+
+       sd = dict_eng_module_create(module, DICT_PATH, ENGINE_NO);
+       printf("Searching in dictionary: \'%s\'\n",dict_eng_get_title(sd));
+       dict_eng_set_callback(sd,
+                             ENGINE_WORD_LIST_SIGNAL,
+                             print_list,
+                             "Word list matches to pattern: %s\n"
+                            );
+       dict_eng_set_callback(sd,
+                       ENGINE_WORD_TRANSLATION_SIGNAL ,
+                       print_translation,
+                       "Translation for word\'%s\':\n"
+                       );
+
+       dict_eng_search_word_list(sd,"a");
+       dict_eng_search_word_list(sd,"z");
+       dict_eng_search_word_translation(sd,"deb");
+       dict_eng_search_word_translation(sd,"abort");
+       
+       
+       dict_eng_destroy(sd);
+       printf("%sClosed.\n",nameApp);  
+       return 0;
+}
+
diff --git a/src/plugins/stardict/test_dictsip/data.c b/src/plugins/stardict/test_dictsip/data.c
new file mode 100644 (file)
index 0000000..1463d05
--- /dev/null
@@ -0,0 +1,524 @@
+/* data.c -- 
+ * Created: Tue Jul 16 12:45:41 1996 by faith@dict.org
+ * Revised: Sat Mar 30 10:46:06 2002 by faith@dict.org
+ * Copyright 1996, 1997, 1998, 2000, 2002 Rickard E. Faith (faith@dict.org)
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ * $Id: data.c,v 1.24 2004/10/12 12:55:14 cheusov Exp $
+ * 
+ */
+
+#include "dictP.h"
+
+#include "data.h"
+#include "dictzip.h"
+
+#include <sys/stat.h>
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+#endif
+#include <ctype.h>
+#include <fcntl.h>
+#include <assert.h>
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+#endif
+
+#define USE_CACHE 1
+
+#ifdef HAVE_MMAP
+int mmap_mode = 1; /* dictd uses mmap() function (the default) */
+#else
+int mmap_mode = 0;
+#endif
+
+int dict_data_filter( char *buffer, int *len, int maxLength,
+                     const char *filter )
+{
+   char *outBuffer;
+   int  outLen;
+
+   if (!filter) return 0;
+   outBuffer = xmalloc( maxLength + 2 );
+   
+   outLen = pr_filter( filter, buffer, *len, outBuffer, maxLength + 1 );
+   if (outLen > maxLength )
+      err_fatal( __FUNCTION__,
+                "Filter grew buffer from %d past limit of %d\n",
+                *len, maxLength );
+   memcpy( buffer, outBuffer, outLen );
+   xfree( outBuffer );
+
+   PRINTF(DBG_UNZIP|DBG_ZIP,("Length was %d, now is %d\n",*len,outLen));
+
+   *len = outLen;
+   
+   return 0;
+}
+
+static int dict_read_header( const char *filename,
+                            dictData *header, int computeCRC )
+{
+   FILE          *str;
+   int           id1, id2, si1, si2;
+   char          buffer[BUFFERSIZE];
+   int           extraLength, subLength;
+   int           i;
+   char          *pt;
+   int           c;
+   struct stat   sb;
+   unsigned long crc   = crc32( 0L, Z_NULL, 0 );
+   int           count;
+   unsigned long offset;
+
+   if (!(str = fopen( filename, "r" )))
+      err_fatal_errno( __FUNCTION__,
+                      "Cannot open data file \"%s\" for read\n", filename );
+
+   header->filename     = str_find( filename );
+   header->headerLength = GZ_XLEN - 1;
+   header->type         = DICT_UNKNOWN;
+   
+   id1                  = getc( str );
+   id2                  = getc( str );
+
+   if (id1 != GZ_MAGIC1 || id2 != GZ_MAGIC2) {
+      header->type = DICT_TEXT;
+      fstat( fileno( str ), &sb );
+      header->compressedLength = header->length = sb.st_size;
+      header->origFilename     = str_find( filename );
+      header->mtime            = sb.st_mtime;
+      if (computeCRC) {
+        rewind( str );
+        while (!feof( str )) {
+           if ((count = fread( buffer, 1, BUFFERSIZE, str ))) {
+              crc = crc32( crc, buffer, count );
+           }
+        }
+      }
+      header->crc = crc;
+      fclose( str );
+      return 0;
+   }
+   header->type = DICT_GZIP;
+   
+   header->method       = getc( str );
+   header->flags        = getc( str );
+   header->mtime        = getc( str ) <<  0;
+   header->mtime       |= getc( str ) <<  8;
+   header->mtime       |= getc( str ) << 16;
+   header->mtime       |= getc( str ) << 24;
+   header->extraFlags   = getc( str );
+   header->os           = getc( str );
+   
+   if (header->flags & GZ_FEXTRA) {
+      extraLength          = getc( str ) << 0;
+      extraLength         |= getc( str ) << 8;
+      header->headerLength += extraLength + 2;
+      si1                  = getc( str );
+      si2                  = getc( str );
+      
+      if (si1 == GZ_RND_S1 && si2 == GZ_RND_S2) {
+        subLength            = getc( str ) << 0;
+        subLength           |= getc( str ) << 8;
+        header->version      = getc( str ) << 0;
+        header->version     |= getc( str ) << 8;
+        
+        if (header->version != 1)
+           err_internal( __FUNCTION__,
+                         "dzip header version %d not supported\n",
+                         header->version );
+   
+        header->chunkLength  = getc( str ) << 0;
+        header->chunkLength |= getc( str ) << 8;
+        header->chunkCount   = getc( str ) << 0;
+        header->chunkCount  |= getc( str ) << 8;
+        
+        if (header->chunkCount <= 0) {
+           fclose( str );
+           return 5;
+        }
+        header->chunks = xmalloc( sizeof( header->chunks[0] )
+                                  * header->chunkCount );
+        for (i = 0; i < header->chunkCount; i++) {
+           header->chunks[i]  = getc( str ) << 0;
+           header->chunks[i] |= getc( str ) << 8;
+        }
+        header->type = DICT_DZIP;
+      } else {
+        fseek( str, header->headerLength, SEEK_SET );
+      }
+   }
+   
+   if (header->flags & GZ_FNAME) { /* FIXME! Add checking against header len */
+      pt = buffer;
+      while ((c = getc( str )) && c != EOF){
+        *pt++ = c;
+
+        if (pt == buffer + sizeof (buffer)){
+           err_fatal (
+              __FUNCTION__,
+              "too long FNAME field in dzip file \"%s\"\n", filename);
+        }
+      }
+
+      *pt = '\0';
+      header->origFilename = str_find( buffer );
+      header->headerLength += strlen( header->origFilename ) + 1;
+   } else {
+      header->origFilename = NULL;
+   }
+   
+   if (header->flags & GZ_COMMENT) { /* FIXME! Add checking for header len */
+      pt = buffer;
+      while ((c = getc( str )) && c != EOF){
+        *pt++ = c;
+
+        if (pt == buffer + sizeof (buffer)){
+           err_fatal (
+              __FUNCTION__,
+              "too long COMMENT field in dzip file \"%s\"\n", filename);
+        }
+      }
+
+      *pt = '\0';
+      header->comment = str_find( buffer );
+      header->headerLength += strlen( header->comment ) + 1;
+   } else {
+      header->comment = NULL;
+   }
+
+   if (header->flags & GZ_FHCRC) {
+      getc( str );
+      getc( str );
+      header->headerLength += 2;
+   }
+
+   if (ftell( str ) != header->headerLength + 1)
+      err_internal( __FUNCTION__,
+                   "File position (%lu) != header length + 1 (%d)\n",
+                   ftell( str ), header->headerLength + 1 );
+
+   fseek( str, -8, SEEK_END );
+   header->crc     = getc( str ) <<  0;
+   header->crc    |= getc( str ) <<  8;
+   header->crc    |= getc( str ) << 16;
+   header->crc    |= getc( str ) << 24;
+   header->length  = getc( str ) <<  0;
+   header->length |= getc( str ) <<  8;
+   header->length |= getc( str ) << 16;
+   header->length |= getc( str ) << 24;
+   header->compressedLength = ftell( str );
+
+                               /* Compute offsets */
+   header->offsets = xmalloc( sizeof( header->offsets[0] )
+                             * header->chunkCount );
+   for (offset = header->headerLength + 1, i = 0;
+       i < header->chunkCount;
+       i++)
+   {
+      header->offsets[i] = offset;
+      offset += header->chunks[i];
+   }
+
+   fclose( str );
+   return 0;
+}
+
+dictData *dict_data_open( const char *filename, int computeCRC )
+{
+   dictData    *h = NULL;
+   struct stat sb;
+   int         j;
+
+   if (!filename)
+      return NULL;
+
+   h = xmalloc( sizeof( struct dictData ) );
+
+   memset( h, 0, sizeof( struct dictData ) );
+   h->initialized = 0;
+
+   if (stat( filename, &sb ) || !S_ISREG(sb.st_mode)) {
+      err_warning( __FUNCTION__,
+                  "%s is not a regular file -- ignoring\n", filename );
+      return h;
+   }
+   
+   if (dict_read_header( filename, h, computeCRC )) {
+      err_fatal( __FUNCTION__,
+                "\"%s\" not in text or dzip format\n", filename );
+   }
+   
+   if ((h->fd = open( filename, O_RDONLY )) < 0)
+      err_fatal_errno( __FUNCTION__,
+                      "Cannot open data file \"%s\"\n", filename );
+   if (fstat( h->fd, &sb ))
+      err_fatal_errno( __FUNCTION__,
+                      "Cannot stat data file \"%s\"\n", filename );
+   h->size = sb.st_size;
+
+   if (mmap_mode){
+#ifdef HAVE_MMAP
+      h->start = mmap( NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0 );
+      if ((void *)h->start == (void *)(-1))
+        err_fatal_errno(
+           __FUNCTION__,
+           "Cannot mmap data file \"%s\"\n", filename );
+#else
+      err_fatal (__FUNCTION__, "This should not happen");
+#endif
+   }else{
+      h->start = xmalloc (h->size);
+      if (-1 == read (h->fd, (char *) h->start, h->size))
+        err_fatal_errno (
+           __FUNCTION__,
+           "Cannot read data file \"%s\"\n", filename );
+
+      close (h -> fd);
+      h -> fd = 0;
+   }
+
+   h->end = h->start + h->size;
+
+   for (j = 0; j < DICT_CACHE_SIZE; j++) {
+      h->cache[j].chunk    = -1;
+      h->cache[j].stamp    = -1;
+      h->cache[j].inBuffer = NULL;
+      h->cache[j].count    = 0;
+   }
+   
+   return h;
+}
+
+void dict_data_close( dictData *header )
+{
+   int i;
+
+   if (!header)
+      return;
+
+   if (header->fd >= 0) {
+      if (mmap_mode){
+#ifdef HAVE_MMAP
+        munmap( (void *)header->start, header->size );
+        close( header->fd );
+        header->fd = 0;
+        header->start = header->end = NULL;
+#else
+        err_fatal (__FUNCTION__, "This should not happen");
+#endif
+      }else{
+        if (header -> start)
+           xfree ((char *) header -> start);
+      }
+   }
+
+   if (header->chunks)       xfree( header->chunks );
+   if (header->offsets)      xfree( header->offsets );
+
+   if (header->initialized) {
+      if (inflateEnd( &header->zStream ))
+        err_internal( __FUNCTION__,
+                      "Cannot shut down inflation engine: %s\n",
+                      header->zStream.msg );
+   }
+
+   for (i = 0; i < DICT_CACHE_SIZE; ++i){
+      if (header -> cache [i].inBuffer)
+        xfree (header -> cache [i].inBuffer);
+   }
+
+   memset( header, 0, sizeof( struct dictData ) );
+   xfree( header );
+}
+
+char *dict_data_obtain (const dictDatabase *db, const dictWord *dw)
+{
+   char *word_copy;
+   int len;
+
+   if (!dw || !db)
+      return NULL;
+
+   if (dw -> def){
+      if (-1 == dw -> def_size){
+        len = strlen (dw -> def);
+      }else{
+        len = dw -> def_size;
+      }
+
+      word_copy = xmalloc (2 + len);
+      memcpy (word_copy, dw -> def, len);
+      word_copy [len + 0] = '\n';
+      word_copy [len + 1] = 0;
+
+      return word_copy;
+   }else{
+      assert (db);
+      assert (db -> data);
+
+      return dict_data_read_ (
+        db -> data, dw -> start, dw -> end,
+        db->prefilter, db->postfilter);
+   }
+}
+
+char *dict_data_read_ (
+   dictData *h, unsigned long start, unsigned long size,
+   const char *preFilter, const char *postFilter )
+{
+   char          *buffer, *pt;
+   unsigned long end;
+   int           count;
+   char          *inBuffer;
+   char          outBuffer[OUT_BUFFER_SIZE];
+   int           firstChunk, lastChunk;
+   int           firstOffset, lastOffset;
+   int           i, j;
+   int           found, target, lastStamp;
+   static int    stamp = 0;
+
+   end  = start + size;
+
+   buffer = xmalloc( size + 1 );
+   
+   PRINTF(DBG_UNZIP,
+         ("dict_data_read( %p, %lu, %lu, %s, %s )\n",
+          h, start, size, preFilter, postFilter ));
+
+   assert( h != NULL);
+   switch (h->type) {
+   case DICT_GZIP:
+      err_fatal( __FUNCTION__,
+                "Cannot seek on pure gzip format files.\n"
+                "Use plain text (for performance)"
+                " or dzip format (for space savings).\n" );
+      break;
+   case DICT_TEXT:
+      memcpy( buffer, h->start + start, size );
+      buffer[size] = '\0';
+      break;
+   case DICT_DZIP:
+      if (!h->initialized) {
+        ++h->initialized;
+        h->zStream.zalloc    = NULL;
+        h->zStream.zfree     = NULL;
+        h->zStream.opaque    = NULL;
+        h->zStream.next_in   = 0;
+        h->zStream.avail_in  = 0;
+        h->zStream.next_out  = NULL;
+        h->zStream.avail_out = 0;
+        if (inflateInit2( &h->zStream, -15 ) != Z_OK)
+           err_internal( __FUNCTION__,
+                         "Cannot initialize inflation engine: %s\n",
+                         h->zStream.msg );
+      }
+      firstChunk  = start / h->chunkLength;
+      firstOffset = start - firstChunk * h->chunkLength;
+      lastChunk   = end / h->chunkLength;
+      lastOffset  = end - lastChunk * h->chunkLength;
+      PRINTF(DBG_UNZIP,
+            ("   start = %lu, end = %lu\n"
+             "firstChunk = %d, firstOffset = %d,"
+             " lastChunk = %d, lastOffset = %d\n",
+             start, end, firstChunk, firstOffset, lastChunk, lastOffset ));
+      for (pt = buffer, i = firstChunk; i <= lastChunk; i++) {
+
+                               /* Access cache */
+        found  = 0;
+        target = 0;
+        lastStamp = INT_MAX;
+        for (j = 0; j < DICT_CACHE_SIZE; j++) {
+#if USE_CACHE
+           if (h->cache[j].chunk == i) {
+              found  = 1;
+              target = j;
+              break;
+           }
+#endif
+           if (h->cache[j].stamp < lastStamp) {
+              lastStamp = h->cache[j].stamp;
+              target = j;
+           }
+        }
+
+        h->cache[target].stamp = ++stamp;
+        if (found) {
+           count = h->cache[target].count;
+           inBuffer = h->cache[target].inBuffer;
+        } else {
+           h->cache[target].chunk = i;
+           if (!h->cache[target].inBuffer)
+              h->cache[target].inBuffer = xmalloc( IN_BUFFER_SIZE );
+           inBuffer = h->cache[target].inBuffer;
+
+           if (h->chunks[i] >= OUT_BUFFER_SIZE ) {
+              err_internal( __FUNCTION__,
+                            "h->chunks[%d] = %d >= %ld (OUT_BUFFER_SIZE)\n",
+                            i, h->chunks[i], OUT_BUFFER_SIZE );
+           }
+           memcpy( outBuffer, h->start + h->offsets[i], h->chunks[i] );
+           dict_data_filter( outBuffer, &count, OUT_BUFFER_SIZE, preFilter );
+        
+           h->zStream.next_in   = outBuffer;
+           h->zStream.avail_in  = h->chunks[i];
+           h->zStream.next_out  = inBuffer;
+           h->zStream.avail_out = IN_BUFFER_SIZE;
+           if (inflate( &h->zStream,  Z_PARTIAL_FLUSH ) != Z_OK)
+              err_fatal( __FUNCTION__, "inflate: %s\n", h->zStream.msg );
+           if (h->zStream.avail_in)
+              err_internal( __FUNCTION__,
+                            "inflate did not flush (%d pending, %d avail)\n",
+                            h->zStream.avail_in, h->zStream.avail_out );
+           
+           count = IN_BUFFER_SIZE - h->zStream.avail_out;
+           dict_data_filter( inBuffer, &count, IN_BUFFER_SIZE, postFilter );
+
+           h->cache[target].count = count;
+        }
+        
+        if (i == firstChunk) {
+           if (i == lastChunk) {
+              memcpy( pt, inBuffer + firstOffset, lastOffset-firstOffset);
+              pt += lastOffset - firstOffset;
+           } else {
+              if (count != h->chunkLength )
+                 err_internal( __FUNCTION__,
+                               "Length = %d instead of %d\n",
+                               count, h->chunkLength );
+              memcpy( pt, inBuffer + firstOffset,
+                      h->chunkLength - firstOffset );
+              pt += h->chunkLength - firstOffset;
+           }
+        } else if (i == lastChunk) {
+           memcpy( pt, inBuffer, lastOffset );
+           pt += lastOffset;
+        } else {
+           assert( count == h->chunkLength );
+           memcpy( pt, inBuffer, h->chunkLength );
+           pt += h->chunkLength;
+        }
+      }
+      *pt = '\0';
+      break;
+   case DICT_UNKNOWN:
+      err_fatal( __FUNCTION__, "Cannot read unknown file type\n" );
+      break;
+   }
+   
+   return buffer;
+}
diff --git a/src/plugins/stardict/test_dictsip/data.h b/src/plugins/stardict/test_dictsip/data.h
new file mode 100644 (file)
index 0000000..0cd39da
--- /dev/null
@@ -0,0 +1,56 @@
+/* data.h -- 
+ * Created: Sat Mar 15 18:04:25 2003 by Aleksey Cheusov <vle@gmx.net>
+ * Copyright 1994-2003 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: data.h,v 1.1 2003/03/19 16:43:15 cheusov Exp $
+ */
+
+#ifndef _DATA_H_
+#define _DATA_H_
+
+#include "dictP.h"
+#include "defs.h"
+
+/* initialize .data file */
+extern dictData *dict_data_open (
+   const char *filename, int computeCRC);
+/* */
+extern void dict_data_close (
+   dictData *data);
+
+extern void     dict_data_print_header( FILE *str, dictData *data );
+extern int      dict_data_zip(
+   const char *inFilename, const char *outFilename,
+   const char *preFilter, const char *postFilter );
+
+extern char *dict_data_obtain (
+   const dictDatabase *db,
+   const dictWord *dw);
+
+extern char *dict_data_read_ (
+   dictData *data,
+   unsigned long start, unsigned long end,
+   const char *preFilter,
+   const char *postFilter );
+
+extern int   dict_data_filter(
+   char *buffer, int *len, int maxLength,
+   const char *filter );
+
+extern int        mmap_mode;
+
+#endif /* _DATA_H_ */
diff --git a/src/plugins/stardict/test_dictsip/dictd.c b/src/plugins/stardict/test_dictsip/dictd.c
new file mode 100644 (file)
index 0000000..64a9edc
--- /dev/null
@@ -0,0 +1,1962 @@
+/* dictd.c -- 
+ * Created: Fri Feb 21 20:09:09 1997 by faith@dict.org
+ * Revised: Sat May  4 21:58:16 2002 by faith@dict.org
+ * Copyright 1997-2000, 2002 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ * $Id: dictd.c,v 1.124 2005/04/14 07:52:16 cheusov Exp $
+ * 
+ */
+
+#include "dictd.h"
+#include "str.h"
+
+#include "servparse.h"
+#include "strategy.h"
+#include "index.h"
+#include "data.h"
+#include "parse.h"
+
+#ifdef USE_PLUGIN
+#include "plugin.h"
+#endif
+
+#include <grp.h>                /* initgroups */
+#include <pwd.h>                /* getpwuid */
+#include <locale.h>             /* setlocale */
+#include <ctype.h>
+
+#define MAXPROCTITLE 2048       /* Maximum amount of proc title we'll use. */
+#undef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#ifndef UID_NOBODY
+#define UID_NOBODY  65534
+#endif
+#ifndef GID_NOGROUP
+#define GID_NOGROUP 65534
+#endif
+
+
+
+
+
+extern int        yy_flex_debug;
+
+static int        _dict_daemon;
+static int        _dict_reaps;
+
+static char      *_dict_argvstart;
+static int        _dict_argvlen;
+
+       int        _dict_forks;
+
+
+
+int default_strategy_set; /* 1 if set by command line option */
+
+
+int                logOptions   = 0;
+
+const char         *logFile     = NULL;
+int logFile_set; /* 1 if set by command line option */
+
+const char *pidFile     = "/var/run/dictd.pid";
+int pidFile_set; /* 1 if set by command line option */
+
+const char         *daemon_service     = DICT_DEFAULT_SERVICE;
+int daemon_service_set; /* 1 if set by command line option */
+
+int        _dict_daemon_limit        = DICT_DAEMON_LIMIT;
+int _dict_daemon_limit_set; /* 1 if set by command line option */
+
+int        _dict_markTime = 0;
+int _dict_markTime_set; /* 1 if set by command line option */
+
+const char        *locale       = NULL;
+int locale_set; /* 1 if set by command line option */
+
+int         client_delay        = DICT_DEFAULT_DELAY;
+int client_delay_set; /* 1 if set by command line option */
+
+int                depth        = DICT_QUEUE_DEPTH;
+int depth_set; /* 1 if set by command line option */
+
+int                useSyslog    = 0;
+int syslog_facility_set; /* 1 if set by command line option */
+
+const char        *preprocessor = NULL;
+
+const char        *bind_to      = NULL;
+int bind_to_set; /* 1 if set by command line option */
+
+
+
+
+
+
+int                inetd        = 0;
+
+int                need_reload_config    = 0;
+
+int                need_unload_databases = 0;
+int                databases_unloaded    = 0;
+
+static const char *configFile  = DICT_CONFIG_PATH DICTD_CONFIG_NAME;
+
+static void dict_close_databases (dictConfig *c);
+static void sanity (const char *confFile);
+static void dict_init_databases (dictConfig *c);
+static void dict_config_print (FILE *stream, dictConfig *c);
+static void postprocess_filenames (dictConfig *dc);
+
+void dict_initsetproctitle( int argc, char **argv, char **envp )
+{
+   int i;
+
+   _dict_argvstart = argv[0];
+   
+   for (i = 0; envp[i]; i++) continue;
+
+   if (i)
+      _dict_argvlen = envp[i-1] + strlen(envp[i-1]) - _dict_argvstart;
+   else
+      _dict_argvlen = argv[argc-1] + strlen(argv[argc-1]) - _dict_argvstart;
+
+   argv[1] = NULL;
+}
+
+void dict_setproctitle( const char *format, ... )
+{
+   va_list ap;
+   int     len;
+   char    buf[MAXPROCTITLE];
+
+   va_start( ap, format );
+   vsnprintf( buf, MAXPROCTITLE, format, ap );
+   va_end( ap );
+
+   if ((len = strlen(buf)) > MAXPROCTITLE-1)
+      err_fatal( __FUNCTION__, "buffer overflow (%d)\n", len );
+
+   buf[ MIN(_dict_argvlen,MAXPROCTITLE) - 1 ] = '\0';
+   strcpy( _dict_argvstart, buf );
+   memset( _dict_argvstart+len, 0, _dict_argvlen-len );
+}
+
+const char *dict_format_time( double t )
+{
+   static int  current = 0;
+   static char buf[10][128];   /* Rotate 10 buffers */
+   static char *this;
+   long int    s, m, h, d;
+
+   this = buf[current];
+   if (++current >= 10) current = 0;
+
+   if (t < 600) {
+      snprintf( this, sizeof (buf [0]), "%0.3f", t );
+   } else {
+      s = (long int)t;
+      d = s / (3600*24);
+      s -= d * 3600 * 24;
+      h = s / 3600;
+      s -= h * 3600;
+      m = s / 60;
+      s -= m * 60;
+
+      if (d)
+        snprintf( this, sizeof (buf [0]), "%ld+%02ld:%02ld:%02ld", d, h, m, s );
+      else if (h)
+        snprintf( this, sizeof (buf [0]), "%02ld:%02ld:%02ld", h, m, s );
+      else
+        snprintf( this, sizeof (buf [0]), "%02ld:%02ld", m, s );
+   }
+
+   return this;
+}
+
+static int waitpid__exit_status (int status)
+{
+   if (WIFEXITED(status)){
+      return WEXITSTATUS(status);
+   }else if (WIFSIGNALED(status)){
+      return 128 + WTERMSIG(status);
+   }else{
+      return -1;
+   }
+}
+
+static void reaper( int dummy )
+{
+#if 0
+   union wait status;
+#else
+   int        status;
+#endif
+   pid_t      pid;
+
+   while ((pid = wait3(&status, WNOHANG, NULL)) > 0) {
+      ++_dict_reaps;
+
+      if (flg_test(LOG_SERVER))
+         log_info( ":I: Reaped %d%s, exit status %i\n",
+                   pid,
+                   _dict_daemon ? " IN CHILD": "",
+                  waitpid__exit_status (status));
+   }
+}
+
+static int start_daemon( void )
+{
+   pid_t pid;
+   
+   ++_dict_forks;
+   switch ((pid = fork())) {
+   case 0:
+      ++_dict_daemon;
+      break;
+   case -1:
+      log_info( ":E: Unable to fork daemon\n" );
+      alarm(10);               /* Can't use sleep() here */
+      pause();
+      break;
+   default:
+      if (flg_test(LOG_SERVER)) log_info( ":I: Forked %d\n", pid );
+      break;
+   }
+   return pid;
+}
+
+static const char * signal2name (int sig)
+{
+   static char name [50];
+
+   switch (sig) {
+   case SIGHUP:
+      return "SIGHUP";
+   case SIGINT:
+      return "SIGINT";
+   case SIGQUIT:
+      return "SIGQUIT";
+   case SIGILL:
+      return "SIGILL";
+   case SIGTRAP:
+      return "SIGTRAP";
+   case SIGTERM:
+      return "SIGTERM";
+   case SIGPIPE:
+      return "SIGPIPE";
+   case SIGALRM:
+      return "SIGALRM";
+   default:
+      snprintf (name, sizeof (name), "Signal %d", sig);
+      return name;
+   }
+}
+
+static void log_sig_info (int sig)
+{
+   log_info (
+      ":I: %s: c/f = %d/%d; %sr %su %ss\n",
+      signal2name (sig),
+      _dict_comparisons,
+      _dict_forks,
+      dict_format_time (tim_get_real ("dictd")),
+      dict_format_time (tim_get_user ("dictd")),
+      dict_format_time (tim_get_system ("dictd")));
+}
+
+static void unload_databases (void)
+{
+   dict_close_databases (DictConfig);
+   DictConfig = NULL;
+}
+
+static void reload_config (void)
+{
+   dict_close_databases (DictConfig);
+
+   if (!access(configFile,R_OK)){
+      prs_file_pp (preprocessor, configFile);
+      postprocess_filenames (DictConfig);
+   }
+
+   sanity (configFile);
+
+   if (dbg_test (DBG_VERBOSE))
+      dict_config_print( NULL, DictConfig );
+
+   dict_init_databases (DictConfig);
+}
+
+static void handler( int sig )
+{
+   const char *name = NULL;
+   time_t     t;
+
+   name = signal2name (sig);
+
+   if (_dict_daemon) {
+      daemon_terminate( sig, name );
+   } else {
+      tim_stop( "dictd" );
+      switch (sig){
+      case SIGALRM:
+        if (_dict_markTime > 0){
+           time(&t);
+           log_info( ":T: %24.24s; %d/%d %sr %su %ss\n",
+                     ctime(&t),
+                     _dict_forks - _dict_reaps,
+                     _dict_forks,
+                     dict_format_time( tim_get_real( "dictd" ) ),
+                     dict_format_time( tim_get_user( "dictd" ) ),
+                     dict_format_time( tim_get_system( "dictd" ) ) );
+           alarm(_dict_markTime);
+           return;
+        }
+
+        break;
+      }
+
+      log_sig_info (sig);
+   }
+   if (!dbg_test(DBG_NOFORK) || sig != SIGALRM)
+      exit(sig+128);
+}
+
+static const char *postprocess_filename (const char *fn, const char *prefix)
+{
+   char *new_fn;
+
+   if (!fn)
+      return NULL;
+
+   if (fn [0] != '/' && fn [0] != '.'){
+      new_fn = xmalloc (2 + strlen (prefix) + strlen (fn));
+      strcpy (new_fn, prefix);
+      strcat (new_fn, fn);
+
+      return new_fn;
+   }else{
+      return xstrdup (fn);
+   }
+}
+
+const char *postprocess_plugin_filename (const char *fn)
+{
+   return postprocess_filename (fn, DICT_PLUGIN_PATH);
+}
+
+const char *postprocess_dict_filename (const char *fn)
+{
+   return postprocess_filename (fn, DICT_DICTIONARY_PATH);
+}
+
+static void postprocess_filenames (dictConfig *dc)
+{
+   lst_Position p;
+   dictDatabase *db;
+
+   LST_ITERATE(dc -> dbl, p, db) {
+      db -> dataFilename = postprocess_dict_filename (db -> dataFilename);
+      db -> indexFilename = postprocess_dict_filename (db -> indexFilename);
+      db -> indexsuffixFilename = postprocess_dict_filename (db -> indexsuffixFilename);
+      db -> indexwordFilename = postprocess_dict_filename (db -> indexwordFilename);
+      db -> pluginFilename = postprocess_plugin_filename (db -> pluginFilename);
+   }
+
+   dc -> site = postprocess_dict_filename (dc -> site);
+}
+
+static void handler_sighup (int sig)
+{
+   log_sig_info (sig);
+   need_reload_config = 1;
+}
+
+static void handler_sigusr1 (int sig)
+{
+   log_sig_info (sig);
+   need_unload_databases = 1;
+}
+
+static void setsig( int sig, void (*f)(int), int sa_flags )
+{
+   struct sigaction   sa;
+
+   sa.sa_handler = f;
+   sigemptyset(&sa.sa_mask);
+   sa.sa_flags = sa_flags;
+   sigaction(sig, &sa, NULL);
+}
+
+struct access_print_struct {
+   FILE *s;
+   int  offset;
+};
+
+static int access_print( const void *datum, void *arg )
+{
+   dictAccess                 *a     = (dictAccess *)datum;
+   struct access_print_struct *aps   = (struct access_print_struct *)arg;
+   FILE                       *s     = aps->s;
+   int                        offset = aps->offset;
+   int                        i;
+   const char                 *desc;
+
+   for (i = 0; i < offset; i++) fputc( ' ', s );
+   switch (a->type) {
+   case DICT_DENY:     desc = "deny";     break;
+   case DICT_ALLOW:    desc = "allow";    break;
+   case DICT_AUTHONLY: desc = "authonly"; break;
+   case DICT_USER:     desc = "user";     break;
+   case DICT_GROUP:    desc = "group";    break; /* Not implemented. */
+   default:            desc = "unknown";  break;
+   }
+   fprintf( s, "%s %s\n", desc, a->spec );
+   return 0;
+}
+
+static void acl_print( FILE *s, lst_List l, int offset)
+{
+   struct access_print_struct aps;
+   int                        i;
+
+   aps.s      = s;
+   aps.offset = offset + 3;
+   
+   for (i = 0; i < offset; i++) fputc( ' ', s );
+   fprintf( s, "access {\n" );
+   lst_iterate_arg( l, access_print, &aps );
+   for (i = 0; i < offset; i++) fputc( ' ', s );
+   fprintf( s, "}\n" );
+}
+
+static int user_print( const void *key, const void *datum, void *arg )
+{
+   const char *username = (const char *)key;
+   const char *secret   = (const char *)datum;
+   FILE       *s        = (FILE *)arg;
+
+   if (dbg_test(DBG_AUTH))
+      fprintf( s, "user %s %s\n", username, secret );
+   else
+      fprintf( s, "user %s *\n", username );
+   return 0;
+}
+
+static int config_print( const void *datum, void *arg )
+{
+   dictDatabase *db = (dictDatabase *)datum;
+   FILE         *s  = (FILE *)arg;
+
+   fprintf( s, "database %s {\n", db->databaseName );
+
+   if (db->dataFilename)
+      fprintf( s, "   data       %s\n", db->dataFilename );
+   if (db->indexFilename)
+      fprintf( s, "   index      %s\n", db->indexFilename );
+   if (db->indexsuffixFilename)
+      fprintf( s, "   index_suffix      %s\n", db->indexsuffixFilename );
+   if (db->indexwordFilename)
+      fprintf( s, "   index_word      %s\n", db->indexwordFilename );
+   if (db->filter)
+      fprintf( s, "   filter     %s\n", db->filter );
+   if (db->prefilter)
+      fprintf( s, "   prefilter  %s\n", db->prefilter );
+   if (db->postfilter)
+      fprintf( s, "   postfilter %s\n", db->postfilter );
+   if (db->databaseShort)
+      fprintf( s, "   name       %s\n", db->databaseShort );
+   if (db->acl)
+      acl_print( s, db->acl, 3 );
+
+   fprintf( s, "}\n" );
+
+   return 0;
+}
+
+static void dict_config_print( FILE *stream, dictConfig *c )
+{
+   FILE *s = stream ? stream : stderr;
+
+   if (c->acl) acl_print( s, c->acl, 0 );
+   lst_iterate_arg( c->dbl, config_print, s );
+   if (c->usl) hsh_iterate_arg( c->usl, user_print, s );
+}
+
+static const char *get_entry_info( dictDatabase *db, const char *entryName )
+{
+   dictWord *dw;
+   lst_List list = lst_create();
+   char     *pt, *buf;
+
+   if (
+      0 >= dict_search (
+        list, entryName, db, DICT_STRAT_EXACT, 0,
+        NULL, NULL, NULL ))
+   {
+#ifdef USE_PLUGIN
+      call_dictdb_free (DictConfig->dbl);
+#endif
+      lst_destroy( list );
+      return NULL;
+   }
+
+   dw = lst_nth_get( list, 1 );
+
+   assert (dw -> database);
+
+   buf = pt = dict_data_obtain( dw -> database, dw );
+
+   if (!strncmp (pt, "00database", 10) || !strncmp (pt, "00-database", 11)){
+      while (*pt != '\n')
+        ++pt;
+
+      ++pt;
+   }
+
+   while (*pt == ' ' || *pt == '\t')
+      ++pt;
+
+   pt[ strlen(pt) - 1 ] = '\0';
+
+#ifdef USE_PLUGIN
+   call_dictdb_free (DictConfig->dbl);
+#endif
+   dict_destroy_list( list );
+
+   pt = xstrdup (pt);
+
+   xfree (buf);
+
+   return pt;
+}
+
+static dictDatabase *dbname2database (const char *dbname)
+{
+   dictDatabase *db    = NULL;
+   lst_Position db_pos = lst_init_position (DictConfig->dbl);
+
+   while (db_pos){
+      db = lst_get_position (db_pos);
+
+      if (!strcmp (db -> databaseName, dbname)){
+        return db;
+      }
+
+      db_pos = lst_next_position (db_pos);
+   }
+
+   return NULL;
+}
+
+static lst_List string2virtual_db_list (char *s)
+{
+   int len, i;
+   lst_List virtual_db_list;
+   char *p;
+
+   dictDatabase *db = NULL;
+
+   p   = s;
+   len = strlen (s);
+
+   virtual_db_list = lst_create ();
+
+   for (i = 0; i <= len; ++i){
+      if (s [i] == ',' || s [i] == '\n' || s [i] == '\0'){
+        s [i] = '\0';
+
+        if (*p){
+           db = dbname2database (p);
+
+           if (db){
+              lst_append (virtual_db_list, db);
+           }else{
+              log_info( ":E: Unknown database '%s'\n", p );
+              PRINTF(DBG_INIT, (":E: Unknown database '%s'\n", p));
+              exit (2);
+           }
+        }
+
+        p = s + i + 1;
+      }
+   }
+
+   return virtual_db_list;
+}
+
+static int init_virtual_db_list (const void *datum)
+{
+   lst_List list;
+   dictDatabase *db  = (dictDatabase *)datum;
+   dictWord *dw;
+   char *buf;
+   int ret;
+
+   if (db -> database_list){
+      buf = xstrdup (db -> database_list);
+      db -> virtual_db_list = string2virtual_db_list (buf);
+      xfree (buf);
+   }else{
+      if (!db -> index)
+        return 0;
+
+      list = lst_create();
+      ret = dict_search (
+        list, DICT_FLAG_VIRTUAL, db, DICT_STRAT_EXACT, 0,
+        NULL, NULL, NULL);
+
+      switch (ret){
+      case 1: case 2:
+        dw  = (dictWord *) lst_pop (list);
+        buf = dict_data_obtain (db, dw);
+        dict_destroy_datum (dw);
+
+        db -> virtual_db_list = string2virtual_db_list (buf);
+
+        xfree (buf);
+        break;
+      case 0:
+        break;
+      default:
+        err_fatal (
+           __FUNCTION__,
+           "index file contains more than one %s entry",
+           DICT_FLAG_VIRTUAL);
+      }
+
+      dict_destroy_list (list);
+   }
+
+   return 0;
+}
+
+static int init_mime_db_list (const void *datum)
+{
+   lst_List list;
+   dictDatabase *db  = (dictDatabase *)datum;
+   dictWord *dw;
+   char *buf;
+   int ret;
+
+   if (!db -> mime_db)
+      return 0;
+
+   /* MIME */
+   if (db -> mime_mimeDbname){
+      db -> mime_mimeDB = dbname2database (db -> mime_mimeDbname);
+
+      if (!db -> mime_mimeDB){
+        err_fatal (
+           __FUNCTION__,
+           "Incorrect database name '%s'\n",
+           db -> mime_mimeDbname);
+      }
+   }else{
+      err_fatal (
+        __FUNCTION__,
+        "MIME database '%s' has no mime_dbname keyword\n",
+        db -> databaseName);
+   }
+
+   /* NO MIME */
+   if (db -> mime_nomimeDbname){
+      db -> mime_nomimeDB = dbname2database (db -> mime_nomimeDbname);
+
+      if (!db -> mime_nomimeDB){
+        err_fatal (
+           __FUNCTION__,
+           "Incorrect database name '%s'\n",
+           db -> mime_nomimeDbname);
+      }
+   }else{
+      err_fatal (
+        __FUNCTION__,
+        "MIME database '%s' has no nomime_dbname keyword\n",
+        db -> databaseName);
+   }
+
+   return 0;
+}
+
+static int init_plugin( const void *datum )
+{
+#ifdef USE_PLUGIN
+   dictDatabase *db = (dictDatabase *)datum;
+   dict_plugin_init (db);
+#endif
+
+   return 0;
+}
+
+void dict_disable_strat (dictDatabase *db, const char* strategy)
+{
+   int strat = -1;
+   int array_size = get_max_strategy_num () + 1;
+
+   assert (db);
+   assert (strategy);
+
+   if (!db -> strategy_disabled){
+      db -> strategy_disabled = xmalloc (array_size * sizeof (int));
+      memset (db -> strategy_disabled, 0, array_size * sizeof (int));
+   }
+
+   strat = lookup_strategy_ex (strategy);
+   assert (strat >= 0);
+
+   db -> strategy_disabled [strat] = 1;
+}
+
+static void init_database_alphabet (dictDatabase *db)
+{
+   int ret;
+   lst_List l;
+   const dictWord *dw;
+   char *data;
+
+   if (!db -> normal_db)
+      return;
+
+   l = lst_create ();
+
+   ret = dict_search_database_ (l, DICT_FLAG_ALPHABET, db, DICT_STRAT_EXACT);
+
+   if (ret){
+      dw = (const dictWord *) lst_top (l);
+      data = dict_data_obtain (db, dw);
+      db -> alphabet = data;
+
+      data = strchr (db -> alphabet, '\n');
+      if (data)
+        *data = 0;
+   }
+
+   dict_destroy_list (l);
+}
+
+static void init_database_default_strategy (dictDatabase *db)
+{
+   int ret;
+   lst_List l;
+   const dictWord *dw;
+   char *data;
+   int def_strat = -1;
+   char *p;
+
+   if (!db -> normal_db)
+      return;
+
+   if (db -> default_strategy > 0){
+      /* already set by `default_strategy' directive*/
+      return;
+   }
+
+   l = lst_create ();
+
+   ret = dict_search_database_ (l, DICT_FLAG_DEFAULT_STRAT, db, DICT_STRAT_EXACT);
+
+   if (ret){
+      dw = (const dictWord *) lst_top (l);
+      data = dict_data_obtain (db, dw);
+
+      for (p=data; *p && isalpha ((unsigned char) *p); ++p){
+      }
+      *p = '\0';
+
+      def_strat = lookup_strategy (data);
+      if (-1 == def_strat){
+        PRINTF (DBG_INIT, (":I:     `%s' is not supported by dictd\n", data));
+      }else{
+        db -> default_strategy = def_strat;
+      }
+
+      xfree (data);
+   }
+
+   dict_destroy_list (l);
+}
+
+static int init_database_mime_header (const void *datum)
+{
+   dictDatabase *db = (dictDatabase *) datum;
+   int ret;
+   lst_List l;
+   const dictWord *dw;
+   char *data;
+
+   if (!db -> normal_db)
+      return 0;
+
+   if (db -> mime_header){
+      /* already set by `mime_header' directive*/
+      return 0;
+   }
+
+   l = lst_create ();
+
+   ret = dict_search_database_ (l, DICT_FLAG_MIME_HEADER, db, DICT_STRAT_EXACT);
+
+   if (ret){
+      dw = (const dictWord *) lst_top (l);
+      data = dict_data_obtain (db, dw);
+
+      db -> mime_header = xstrdup (data);
+
+      xfree (data);
+   }
+
+   dict_destroy_list (l);
+
+   return 0;
+}
+
+static int init_database( const void *datum )
+{
+   dictDatabase *db = (dictDatabase *)datum;
+   const char *strat_name = NULL;
+
+   PRINTF (DBG_INIT, (":I: Initializing '%s'\n", db->databaseName));
+
+   if (db->indexFilename){
+      PRINTF (DBG_INIT, (":I:   Opening indices\n"));
+   }
+
+   db->index        = dict_index_open( db->indexFilename, 1, 0, 0 );
+
+   if (db->indexFilename){
+      PRINTF (DBG_INIT, (":I:     .index <ok>\n"));
+   }
+
+   if (db->index){
+      db->index_suffix = dict_index_open(
+        db->indexsuffixFilename,
+        0, db->index->flag_utf8, db->index->flag_allchars);
+      db->index_word = dict_index_open(
+        db->indexwordFilename,
+        0, db->index->flag_utf8, db->index->flag_allchars);
+   }
+
+   if (db->index_suffix){
+      PRINTF (DBG_INIT, (":I:     .indexsuffix <ok>\n"));
+      db->index_suffix->flag_8bit     = db->index->flag_8bit;
+      db->index_suffix->flag_utf8     = db->index->flag_utf8;
+      db->index_suffix->flag_allchars = db->index->flag_allchars;
+   }
+   if (db->index_word){
+      PRINTF (DBG_INIT, (":I:     .indexword <ok>\n"));
+      db->index_word->flag_utf8     = db->index->flag_utf8;
+      db->index_word->flag_8bit     = db->index->flag_8bit;
+      db->index_word->flag_allchars = db->index->flag_allchars;
+   }
+
+   if (db->dataFilename){
+      PRINTF (DBG_INIT, (":I:   Opening data\n"));
+   }
+
+   db->data         = dict_data_open( db->dataFilename, 0 );
+
+   init_database_alphabet (db);
+   if (db -> alphabet){
+      PRINTF (DBG_INIT, (":I:     alphabet: %s\n", db -> alphabet));
+   }else{
+      PRINTF (DBG_INIT, (":I:     alphabet: (NULL)\n"));
+   }
+
+   if (db -> default_strategy){
+      strat_name = get_strategy (db -> default_strategy) -> name;
+      PRINTF (DBG_INIT, (":I:     default_strategy (from conf file): %s\n",
+                        strat_name));
+   }else{
+      init_database_default_strategy (db);
+      if (db -> default_strategy){
+        strat_name = get_strategy (db -> default_strategy) -> name;
+        PRINTF (DBG_INIT, (":I:     default_strategy (from db): %s\n", strat_name));
+      }else{
+        db -> default_strategy = default_strategy;
+      }
+   }
+
+   if (db->dataFilename){
+      PRINTF(DBG_INIT,
+            (":I: '%s' initialized\n", db->databaseName));
+   }
+
+   return 0;
+}
+
+static int init_database_short (const void *datum)
+{
+   char *NL;
+
+   dictDatabase *db = (dictDatabase *) datum;
+
+   if (!db->databaseShort){
+      db->databaseShort = get_entry_info( db, DICT_SHORT_ENTRY_NAME );
+   }else if (*db->databaseShort == '@'){
+      db->databaseShort = get_entry_info( db, db->databaseShort + 1 );
+   }else{
+      db->databaseShort = xstrdup (db->databaseShort);
+   }
+
+   if (db->databaseShort){
+      NL = strchr (db->databaseShort, '\n');
+      if (NL)
+        *NL = 0;
+   }
+
+   if (!db->databaseShort)
+      db->databaseShort = xstrdup (db->databaseName);
+
+   return 0;
+}
+
+static int close_plugin (const void *datum)
+{
+#ifdef USE_PLUGIN
+   dictDatabase  *db = (dictDatabase *)datum;
+   dict_plugin_destroy (db);
+#endif
+
+   return 0;
+}
+
+static int close_database (const void *datum)
+{
+   dictDatabase  *db = (dictDatabase *)datum;
+
+   dict_index_close (db->index);
+   dict_index_close (db->index_suffix);
+   dict_index_close (db->index_word);
+
+   dict_data_close (db->data);
+
+   if (db -> databaseShort)
+      xfree ((void *) db -> databaseShort);
+
+   if (db -> indexFilename)
+      xfree ((void *) db -> indexFilename);
+   if (db -> dataFilename)
+      xfree ((void *) db -> dataFilename);
+   if (db -> indexwordFilename)
+      xfree ((void *) db -> indexwordFilename);
+   if (db -> indexsuffixFilename)
+      xfree ((void *) db -> indexsuffixFilename);
+   if (db -> pluginFilename)
+      xfree ((void *) db -> pluginFilename);
+   if (db -> strategy_disabled)
+      xfree ((void *) db -> strategy_disabled);
+   if (db -> alphabet)
+      xfree ((void *) db -> alphabet);
+   if (db -> mime_header)
+      xfree ((void *) db -> mime_header);
+
+   return 0;
+}
+
+static int log_database_info( const void *datum )
+{
+   dictDatabase  *db = (dictDatabase *)datum;
+   const char    *pt;
+   unsigned long headwords = 0;
+
+   if (db->index){
+      for (pt = db->index->start; pt < db->index->end; pt++)
+        if (*pt == '\n') ++headwords;
+      db->index->headwords = headwords;
+
+      log_info( ":I: %-12.12s %12lu %12lu %12lu %12lu\n",
+               db->databaseName, headwords,
+               db->index->size, db->data->size, db->data->length );
+   }
+
+   return 0;
+}
+
+static void dict_ltdl_init ()
+{
+#if USE_PLUGIN && !HAVE_DLFCN_H
+   if (lt_dlinit ())
+      err_fatal( __FUNCTION__, "Can not initialize 'ltdl' library\n" );
+#endif
+}
+
+static void dict_ltdl_close ()
+{
+#if USE_PLUGIN && !HAVE_DLFCN_H
+   if (lt_dlexit ())
+      err_fatal( __FUNCTION__, "Can not deinitialize 'ltdl' library\n" );
+#endif
+}
+
+/*
+  Makes dictionary_exit db invisible if it is the last visible one
+ */
+static void make_dictexit_invisible (dictConfig *c)
+{
+   lst_Position p;
+   dictDatabase *db;
+   dictDatabase *db_exit = NULL;
+
+   LST_ITERATE(c -> dbl, p, db) {
+      if (!db -> invisible){
+        if (db_exit)
+           db_exit -> invisible = 0;
+
+        db_exit = NULL;
+      }
+
+      if (db -> exit_db){
+        db_exit = db;
+        db_exit -> invisible = 1;
+      }
+   }
+}
+
+static void dict_init_databases( dictConfig *c )
+{
+   make_dictexit_invisible (c);
+
+   lst_iterate( c->dbl, init_database );
+   lst_iterate( c->dbl, init_plugin );
+   lst_iterate( c->dbl, init_virtual_db_list );
+   lst_iterate( c->dbl, init_mime_db_list );
+   lst_iterate( c->dbl, init_database_short );
+   lst_iterate( c->dbl, init_database_mime_header);
+   lst_iterate( c->dbl, log_database_info );
+}
+
+static void dict_close_databases (dictConfig *c)
+{
+   dictDatabase *db;
+   dictAccess   *acl;
+
+   if (!c)
+      return;
+
+   if (c -> dbl){
+      while (lst_length (c -> dbl) > 0){
+        db = (dictDatabase *) lst_pop (c -> dbl);
+
+        if (db -> virtual_db_list)
+           lst_destroy (db -> virtual_db_list);
+
+        close_plugin (db);
+        close_database (db);
+        xfree (db);
+      }
+      lst_destroy (c -> dbl);
+   }
+
+   if (c -> acl){
+      while (lst_length (c -> acl) > 0){
+        acl = (dictAccess *) lst_pop (c->acl);
+        xfree (acl);
+      }
+      lst_destroy (c -> acl);
+   }
+
+   if (c -> site)
+      xfree ((void *) c -> site);
+
+   xfree (c);
+}
+
+static int match_mode = 0;
+
+static int dump_def( const void *datum )
+{
+   char         *buf;
+   const dictWord     *dw = (dictWord *)datum;
+
+   const dictDatabase *db = dw -> database_visible;
+   if (!db)
+      db = dw -> database;
+
+   if (match_mode){
+      printf (
+        "%s:\t\"%s\"\n", db -> databaseName, dw -> word );
+   }else{
+      buf = dict_data_obtain( dw -> database, dw );
+
+      printf (
+        "From %s [%s]:\n\n%s\n", db -> databaseShort, db -> databaseName, buf );
+
+      xfree( buf );
+   }
+
+   return 0;
+}
+
+static void dict_dump_defs( lst_List list )
+{
+   lst_iterate (list, dump_def);
+}
+
+static const char *id_string( const char *id )
+{
+   static char buffer [BUFFERSIZE];
+
+   snprintf( buffer, BUFFERSIZE, "%s", DICT_VERSION );
+
+   return buffer;
+}
+
+const char *dict_get_banner( int shortFlag )
+{
+   static char    *shortBuffer = NULL;
+   static char    *longBuffer = NULL;
+   const char     *id = "$Id: dictd.c,v 1.124 2005/04/14 07:52:16 cheusov Exp $";
+   struct utsname uts;
+   
+   if (shortFlag && shortBuffer) return shortBuffer;
+   if (!shortFlag && longBuffer) return longBuffer;
+   
+   uname( &uts );
+
+   shortBuffer = xmalloc(256);
+   snprintf(
+      shortBuffer, 256,
+      "%s %s", err_program_name(), id_string( id ) );
+
+   longBuffer = xmalloc(256);
+   snprintf(
+      longBuffer, 256,
+      "%s %s/rf on %s %s", err_program_name(), id_string( id ),
+      uts.sysname,
+      uts.release );
+
+   if (shortFlag)
+      return shortBuffer;
+
+   return longBuffer;
+}
+
+static void banner( void )
+{
+   printf( "%s\n", dict_get_banner(0) );
+   printf( "Copyright 1997-2002 Rickard E. Faith (faith@dict.org)\n\n" );
+}
+
+static void license( void )
+{
+   static const char *license_msg[] = {
+     "This program is free software; you can redistribute it and/or modify it",
+     "under the terms of the GNU General Public License as published by the",
+     "Free Software Foundation; either version 1, or (at your option) any",
+     "later version.",
+     "",
+     "This program is distributed in the hope that it will be useful, but",
+     "WITHOUT ANY WARRANTY; without even the implied warranty of",
+     "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU",
+     "General Public License for more details.",
+     "",
+     "You should have received a copy of the GNU General Public License along",
+     "with this program; if not, write to the Free Software Foundation, Inc.,",
+     "675 Mass Ave, Cambridge, MA 02139, USA.",
+   0 };
+   const char        **p = license_msg;
+   
+   banner();
+   while (*p) printf( "   %s\n", *p++ );
+}
+
+static void help( void )
+{
+   static const char *help_msg[] = {
+   "Usage: dictd [options]",
+   "Start the dictd daemon",
+   "",
+      "-h --help             give this help",
+      "   --license          display software license",
+      "-v --verbose          verbose mode",
+      "-V --version          display version number",
+      "-p --port <port>      port number",
+      "   --delay <seconds>  client timeout in seconds",
+      "   --depth <length>   TCP/IP queue depth",
+      "   --limit <children> maximum simultaneous children",
+      "-c --config <file>    configuration file",
+      "-l --log <option>     select logging option",
+      "-s --syslog           log via syslog(3)",
+      "-L --logfile <file>   log via specified file",
+      "-m --mark <minutes>   how often should a timestamp be logged",
+      "   --facility <fac>   set syslog logging facility",
+      "-d --debug <option>   select debug option",
+      "-i --inetd            run from inetd",
+      "   --pid-file <path>  PID filename",
+      "   --pp <prog>        set preprocessor for configuration file",
+      "-f --force            force startup even if daemon running",
+      "   --locale <locale>  specifies the locale used for searching.\n\
+                      if no locale is specified, the \"C\" locale is used.",
+"   --default-strategy   set the default search strategy for 'match' queries.\n\
+                      the default is 'lev'.",
+"   --without-strategy <strategies> disable strategies.\n\
+                                   <strategies> is a comma-separated list.",
+"   --add-strategy <strat>:<descr>  adds new strategy <strat>\n\
+                                   with a description <descr>.",
+"   --listen-to                     bind a socket to the specified address",
+"\n------------------ options for debugging ---------------------------",
+"-t --test <word>                lookup word",
+"   --test-file <file>",
+"   --ftest <file>               lookup all words in file",
+"   --test-strategy <strategy>   search strategy for --test and --ftest.\n\
+                                the default is 'exact'",
+"   --test-db <database>         database name for --test and --ftest.\n\
+                                the default is '*'",
+"   --test-match                 show matched words but the definitions",
+"   --test-nooutput              produces no output",
+"   --test-idle                  does everything except search",
+"   --test-show-info <database>  shows information about specified database",
+"   --fast-start                 don't create additional index.",
+#ifdef HAVE_MMAP
+"   --without-mmap               do not use mmap() function and load files\n\
+                                into memory instead.",
+#endif
+      0 };
+   const char        **p = help_msg;
+
+   banner();
+   while (*p)
+      printf( "%s\n", *p++ );
+}
+
+void set_minimal( void )
+{
+   flg_set(flg_name(LOG_FOUND));
+   flg_set(flg_name(LOG_NOTFOUND));
+   flg_set(flg_name(LOG_STATS));
+   flg_set(flg_name(LOG_CLIENT));
+   flg_set(flg_name(LOG_AUTH));
+   flg_set("-min");
+}
+
+static void release_root_privileges( void )
+/* At the spring 1999 Linux Expo in Raleigh, Rik Faith told me that he
+ * did not want dictd to be allowed to run as root for any reason.
+ * This patch irrevocably releases root privileges.  -- Kirk Hilliard
+ *
+ * Updated to set the user to `dictd' if that user exists on the
+ * system; if user dictd doesn't exist, it sets the user to `nobody'.
+ * -- Bob Hilliard
+ */
+{
+   if (geteuid() == 0) {
+      struct passwd *pwd;
+
+      if ((pwd = getpwnam("dictd"))) {
+         setgid(pwd->pw_gid);
+         initgroups("dictd",pwd->pw_gid);
+         setuid(pwd->pw_uid);
+      } else if ((pwd = getpwnam("nobody"))) {
+         setgid(pwd->pw_gid);
+         initgroups("nobody",pwd->pw_gid);
+         setuid(pwd->pw_uid);
+      } else {
+         setgid(GID_NOGROUP);
+         initgroups("nobody", GID_NOGROUP);
+         setuid(UID_NOBODY);
+      }
+   }
+}
+
+/* Perform sanity checks that are often problems for people trying to
+ * get dictd running.  Do this early, before we detach from the
+ * console. */
+static void sanity(const char *confFile)
+{
+   int           fail = 0;
+   int           reading_error = 0;
+   struct passwd *pw = NULL;
+   struct group  *gr = NULL;
+
+   if (access(confFile,R_OK)) {
+      log_info(":E: %s is not readable (config file)\n", confFile);
+      ++fail;
+   }
+   if (DictConfig && !DictConfig->dbl) {
+      log_info(":E: no databases have been defined\n");
+      log_info(":E: check %s or use -c\n", confFile);
+      ++fail;
+   }
+   if (DictConfig && DictConfig->dbl) {
+      lst_Position p;
+      dictDatabase *e;
+      LST_ITERATE(DictConfig->dbl, p, e) {
+        if (e->indexFilename && access(e->indexFilename, R_OK)) {
+           log_info(":E: %s is not readable (index file)\n",
+                    e->indexFilename);
+           ++fail;
+           reading_error = 1;
+        }
+        if (e->indexsuffixFilename && access(e->indexsuffixFilename, R_OK)) {
+           log_info(":E: %s is not readable (index_suffix file)\n",
+                    e->indexsuffixFilename);
+           ++fail;
+           reading_error = 1;
+        }
+        if (e->indexwordFilename && access(e->indexwordFilename, R_OK)) {
+           log_info(":E: %s is not readable (index_word file)\n",
+                    e->indexwordFilename);
+           ++fail;
+           reading_error = 1;
+        }
+        if (e->dataFilename && access(e->dataFilename, R_OK)) {
+           log_info(":E: %s is not readable (data file)\n",
+                    e->dataFilename);
+           ++fail;
+           reading_error = 1;
+        }
+        if (e->virtual_db && !e->database_list){
+           log_info(
+              ":E: database list is not specified for virtual dictionary '%s'\n",
+              e->databaseName);
+           ++fail;
+        }
+        if (e->normal_db && !e->dataFilename){
+           log_info(
+              ":E: data filename is not specified for dictionary '%s'\n",
+              e->databaseName);
+           ++fail;
+        }
+        if (e->normal_db && !e->indexFilename){
+           log_info(
+              ":E: index filename is not specified for dictionary '%s'\n",
+              e->databaseName);
+           ++fail;
+        }
+        if (e->plugin_db && !e->pluginFilename){
+           log_info(
+              ":E: plugin filename is not specified for dictionary '%s'\n",
+              e->databaseName);
+           ++fail;
+        }
+#ifndef USE_PLUGIN
+        if (e -> plugin_db){
+           log_info (
+              ":E: plugin support was disabled at compile time\n");
+           ++fail;
+        }
+#endif
+      }
+   }
+   if (fail) {
+      if (reading_error){
+        pw = getpwuid (geteuid ());
+        gr = getgrgid (getegid ());
+
+        log_info(":E: for security, this program will not run as root.\n");
+        log_info(":E: if started as root, this program will change"
+                 " to \"dictd\" or \"nobody\".\n");
+        log_info(":E: currently running as user %d/%s, group %d/%s\n",
+                 geteuid(), pw && pw->pw_name ? pw->pw_name : "?",
+                 getegid(), gr && gr->gr_name ? gr->gr_name : "?");
+        log_info(":E: config and db files must be readable by that user\n");
+      }
+      err_fatal(__FUNCTION__, ":E: terminating due to errors. See log file\n");
+   }
+}
+
+static void set_locale_and_flags (const char *loc)
+{
+   const char *charset = NULL;
+   int ascii_mode;
+
+   if (!setlocale(LC_COLLATE, loc) || !setlocale(LC_CTYPE, loc)){
+      fprintf (stderr, "invalid locale '%s'\n", locale);
+      exit (2);
+   }
+
+   charset = nl_langinfo (CODESET);
+
+   utf8_mode = !strcmp (charset, "UTF-8") || !strcmp (charset, "utf-8");
+
+#if !HAVE_UTF8
+   if (utf8_mode){
+      err_fatal (
+        __FUNCTION__,
+        "utf-8 support was disabled at compile time\n");
+   }
+#endif
+
+   ascii_mode = 
+      !strcmp (charset, "ANSI_X3.4-1968") ||
+      !strcmp (charset, "US-ASCII") ||
+      (locale [0] == 'C' && locale [1] == 0);
+
+   bit8_mode = !ascii_mode && !utf8_mode;
+}
+
+static void init (const char *fn)
+{
+   maa_init (fn);
+   dict_ltdl_init ();
+   dict_init_strategies ();
+}
+
+static void destroy ()
+{
+   maa_shutdown ();
+
+   dict_ltdl_close ();
+   dict_destroy_strategies ();
+}
+
+static void dict_make_dbs_available (dictConfig *cfg)
+{
+   lst_Position  p;
+   dictDatabase *db;
+
+   LST_ITERATE (cfg -> dbl, p, db) {
+      db -> available = 1;
+   }
+}
+
+static const char *database_arg="*";
+
+static int idle_mode     = 0;
+static int nooutput_mode = 0;
+static int show_info_mode= 0;
+
+static void dict_test (
+   const char *word,
+   int strategy)
+{
+   lst_List l;
+   int count = 0;
+   int db_found = 0;
+
+   l = lst_create ();
+
+   count = dict_search_databases (l, NULL, database_arg, word, strategy, &db_found);
+
+   if (db_found){
+      if (!nooutput_mode){
+        if (count > 0){
+           dict_dump_defs (l);
+        }else{
+           fprintf (stderr, "No definitions found for \"%s\"\n", word);
+        }
+      }
+   }else{
+      fprintf (stderr, "%s is not a valid database\n", database_arg);
+   }
+
+#ifdef USE_PLUGIN
+   call_dictdb_free (DictConfig->dbl);
+#endif
+
+   dict_destroy_list (l);
+}
+
+static void dict_test_word (const char *word, int strategy)
+{
+   dict_config_print( NULL, DictConfig );
+   dict_init_databases( DictConfig );
+
+   dict_make_dbs_available (DictConfig);
+
+   if (!idle_mode){
+      dict_test (word, strategy);
+
+      if (!nooutput_mode){
+        fprintf( stderr, "%d comparisons\n", _dict_comparisons );
+      }
+   }
+
+   dict_close_databases (DictConfig);
+
+   destroy ();
+
+   exit( 0 );
+}
+
+static void dict_test_file (const char *filename, int strategy)
+{
+   FILE         *str;
+   char         buf[1024], *pt;
+   int          words = 0;
+   int                word_len;
+
+   if (!(str = fopen(filename,"r")))
+      err_fatal_errno( "Cannot open \"%s\" for read\n", filename );
+
+   dict_config_print( NULL, DictConfig );
+   dict_init_databases( DictConfig );
+   dict_make_dbs_available (DictConfig);
+
+   while (fgets(buf,1024,str)) {
+      word_len = strlen( buf );
+      if (word_len > 0){
+        if ('\n' == buf [word_len - 1]){
+           buf [word_len - 1] = '\0';
+        }
+      }
+
+      if ((pt = strchr(buf, '\t')))
+        *pt = '\0'; /* stop at tab */
+
+      if (buf[0]){
+        ++words;
+
+        if (!idle_mode){
+           dict_test (buf, strategy);
+        }
+      }
+
+      if (words && !(words % 1000)){
+        if (!nooutput_mode){
+           fprintf(
+              stderr,
+              "%d comparisons, %d words\n", _dict_comparisons, words );
+        }
+      }
+   }
+
+   if (!nooutput_mode){
+      fprintf(
+        stderr,
+        "%d comparisons, %d words\n", _dict_comparisons, words );
+   }
+
+   fclose( str);
+
+   dict_close_databases (DictConfig);
+
+   destroy ();
+
+   exit(0);
+/* Comparisons:
+   P5/133
+   1878064 comparisons, 113955 words
+   39:18.72u 1.480s 55:20.27 71%
+*/
+}
+
+extern void daemon_show_info (
+   const char *cmdline, int argc, const char **argv);
+
+static void dict_test_show_info (const char *database)
+{
+   const char * argv [] = {"SHOW", "INFO", database};
+
+   dict_config_print( NULL, DictConfig );
+   dict_init_databases( DictConfig );
+   dict_make_dbs_available (DictConfig);
+
+   daemon_show_info ("", 3, argv);
+
+   dict_close_databases (DictConfig);
+
+   destroy ();
+
+   exit (0);
+}
+
+static void create_pid_file ()
+{
+   FILE *fd = fopen (pidFile, "w");
+
+   if (!fd){
+      log_info(":E: cannot open pif file '%s'\n:E:    err msg: %s\n",
+              pidFile, strerror (errno));
+      exit (1);
+   }
+
+   fprintf (fd, "%lu", (unsigned long) getpid ());
+   if (fclose (fd)){
+      log_info(":E: cannot write to pif file '%s'\n:E:    err msg: %s\n",
+              pidFile, strerror (errno));
+      exit (1);
+   }
+}
+
+int main (int argc, char **argv, char **envp)
+{
+   int                childSocket;
+   int                masterSocket;
+   struct sockaddr_in csin;
+   int                c;
+   time_t             startTime;
+   int                alen         = sizeof(csin);
+   int                detach       = 1;
+   const char         *testWord    = NULL;
+   const char         *testFile    = NULL;
+   int                forceStartup = 0;
+   int                i;
+
+   const char *       strategy_arg = "exact";
+   int                strategy     = DICT_STRAT_EXACT;
+
+   const char *       default_strategy_arg = "???";
+
+   char *             new_strategy;
+   char *             new_strategy_descr;
+
+   struct option      longopts[]   = {
+      { "verbose",  0, 0, 'v' },
+      { "version",  0, 0, 'V' },
+      { "debug",    1, 0, 'd' },
+      { "port",     1, 0, 'p' },
+      { "config",   1, 0, 'c' },
+      { "help",     0, 0, 'h' },
+      { "license",  0, 0, 500 },
+      { "test",     1, 0, 't' },
+      { "ftest",    1, 0, 501 },
+      { "test-file",1, 0, 501 },
+      { "log",      1, 0, 'l' },
+      { "logfile",  1, 0, 'L' },
+      { "syslog",   0, 0, 's' },
+      { "mark",     1, 0, 'm' },
+      { "delay",    1, 0, 502 },
+      { "depth",    1, 0, 503 },
+      { "limit",    1, 0, 504 },
+      { "facility", 1, 0, 505 },
+      { "force",    1, 0, 'f' },
+      { "inetd",    0, 0, 'i' },
+      { "locale",           1, 0, 506 },
+      { "test-strategy",    1, 0, 507 },
+#ifdef HAVE_MMAP
+      { "no-mmap",          0, 0, 508 },
+      { "without-mmap",     0, 0, 508 },
+#endif
+      { "test-db",          1, 0, 509 },
+      { "default-strategy", 1, 0, 511 },
+      { "test-match",       0, 0, 512 },
+      { "without-strategy", 1, 0, 513 },
+      { "test-nooutput",    0, 0, 514 },
+      { "test-idle",        0, 0, 515 },
+      { "add-strategy",     1, 0, 516 },
+      { "fast-start",       0, 0, 517 },
+      { "pp",               1, 0, 518 },
+      { "listen-to",        1, 0, 519 },
+      { "test-show-info",   1, 0, 520 },
+      { "pid-file",         1, 0, 521 },
+      { 0,                  0, 0, 0  }
+   };
+
+   init (argv[0]);
+
+   flg_register( LOG_SERVER,    "server" );
+   flg_register( LOG_CONNECT,   "connect" );
+   flg_register( LOG_STATS,     "stats" );
+   flg_register( LOG_COMMAND,   "command" );
+   flg_register( LOG_FOUND,     "found" );
+   flg_register( LOG_NOTFOUND,  "notfound" );
+   flg_register( LOG_CLIENT,    "client" );
+   flg_register( LOG_HOST,      "host" );
+   flg_register( LOG_TIMESTAMP, "timestamp" );
+   flg_register( LOG_MIN,       "min" );
+   flg_register( LOG_AUTH,      "auth" );
+
+   dbg_register( DBG_VERBOSE,  "verbose" );
+   dbg_register( DBG_UNZIP,    "unzip" );
+   dbg_register( DBG_SCAN,     "scan" );
+   dbg_register( DBG_PARSE,    "parse" );
+   dbg_register( DBG_SEARCH,   "search" );
+   dbg_register( DBG_INIT,     "init" );
+   dbg_register( DBG_PORT,     "port" );
+   dbg_register( DBG_LEV,      "lev" );
+   dbg_register( DBG_AUTH,     "auth" );
+   dbg_register( DBG_NODETACH, "nodetach" );
+   dbg_register( DBG_NOFORK,   "nofork" );
+   dbg_register( DBG_ALT,      "alt" );
+
+   log_stream ("dictd", stderr);
+
+   while ((c = getopt_long( argc, argv,
+                           "vVd:p:c:hL:t:l:sm:fi", longopts, NULL )) != EOF)
+      switch (c) {
+                                /* Remember to copy optarg since we're
+                                   going to destroy argv soon... */
+      case 'v': dbg_set( "verbose" );                     break;
+      case 'V': banner(); exit(1);                        break;
+      case 'd': dbg_set( optarg );                        break;
+      case 'p':
+        daemon_service     = str_copy(optarg);
+        daemon_service_set = 1;
+        break;
+      case 'c': configFile = str_copy(optarg);            break;
+      case 't': testWord = str_copy(optarg);              break;
+      case 'L':
+        logFile     = str_copy(optarg);
+        logFile_set = 1;
+        break;
+      case 's': ++useSyslog;                              break;
+      case 'm':
+        _dict_markTime     = 60*atoi(optarg);
+        _dict_markTime_set = 1;
+        break;
+      case 'f': ++forceStartup;                           break;
+      case 'i':
+        inetd         = 1;
+        optStart_mode = 0;
+        break;
+      case 'l':
+        ++logOptions;
+        flg_set( optarg );
+        if (flg_test(LOG_MIN)) set_minimal();
+        break;
+      case 500: license(); exit(1);                       break;
+      case 501: testFile = str_copy(optarg);              break;
+      case 502:
+        client_delay     = atoi(optarg);
+        client_delay_set = 1;
+        break;
+      case 503:
+        depth     = atoi(optarg);
+        depth_set = 1;
+        break;
+      case 504:
+        _dict_daemon_limit     = atoi(optarg);
+        _dict_daemon_limit_set = 1;
+        break;
+      case 505:
+        ++useSyslog;
+        log_set_facility (optarg);
+        syslog_facility_set = 1;
+        break;
+      case 506:
+        locale     = str_copy (optarg);
+        locale_set = 1;
+        break;
+      case 508: mmap_mode = 0;                            break;
+      case 509: database_arg = str_copy(optarg);          break;
+      case 507:
+        strategy_arg = str_copy (optarg);
+        strategy = lookup_strategy (strategy_arg);
+        break;
+      case 511:
+        default_strategy_arg = str_copy (optarg);
+        default_strategy     = lookup_strategy_ex (default_strategy_arg);
+        default_strategy_set = 1;
+        break;
+      case 512:
+        match_mode = 1;
+        break;
+      case 513:
+        dict_disable_strategies (optarg);
+        break;
+      case 514:
+        nooutput_mode = 1;
+        break;
+      case 515:
+        idle_mode = 1;
+        break;
+      case 516:
+        new_strategy = optarg;
+        new_strategy_descr = strchr (new_strategy, ':');
+        if (!new_strategy_descr){
+           fprintf (stderr, "missing ':' symbol in --add-strategy option\n");
+           exit (1);
+        }
+
+        *new_strategy_descr++ = 0;
+
+        dict_add_strategy (new_strategy, new_strategy_descr);
+
+        break;
+      case 517: optStart_mode = 0;                        break;
+      case 518: preprocessor = str_copy (optarg);         break;
+      case 519:
+        bind_to     = str_copy (optarg);
+        bind_to_set = 1;
+        break;
+      case 520:
+        database_arg = str_copy(optarg);
+        show_info_mode = 1;
+        break;
+      case 521:
+        pidFile     = str_copy(optarg);
+        pidFile_set = 1;
+        break;
+      case 'h':
+      default:  help(); exit(0);                          break;
+      }
+
+   log_stream (NULL, NULL);
+
+   if (testWord || testFile || inetd || show_info_mode)
+      detach = 0;
+
+   if (
+      -1 == strategy ||
+      (strategy_arg = default_strategy_arg, -1 == default_strategy))
+   {
+      fprintf (stderr, "%s is not a valid search strategy\n", strategy_arg);
+      fprintf (stderr, "available ones are:\n");
+      for (i = 0; i < get_strategy_count (); ++i){
+         fprintf (
+             stderr, "  %15s : %s\n",
+             get_strategies () [i] -> name, get_strategies () [i] -> description);
+      }
+      exit (1);
+   }
+
+   if (dbg_test(DBG_NOFORK))    dbg_set_flag( DBG_NODETACH);
+   if (dbg_test(DBG_NODETACH))  detach = 0;
+   if (dbg_test(DBG_PARSE))     prs_set_debug(1);
+   if (dbg_test(DBG_SCAN))      yy_flex_debug = 1;
+   else                         yy_flex_debug = 0;
+   if (flg_test(LOG_TIMESTAMP)) log_option( LOG_OPTION_FULL );
+   else                         log_option( LOG_OPTION_NO_FULL );
+
+   if (!access(configFile,R_OK)) {
+      prs_file_pp (preprocessor, configFile );
+      postprocess_filenames (DictConfig);
+   }
+
+   if (detach)
+      net_detach();
+
+   if (logFile)   log_file ("dictd", logFile);
+   if (useSyslog) log_syslog ("dictd");
+   if (! inetd && ! detach)   log_stream ("dictd", stderr);
+   if (detach) create_pid_file ();
+
+   release_root_privileges();
+
+   if ((logFile || useSyslog || !detach) && !logOptions)
+      set_minimal();
+
+   time(&startTime);
+   log_info(":I: %d starting %s %24.24s\n",
+           getpid(), dict_get_banner(0), ctime(&startTime));
+
+   tim_start( "dictd" );
+   alarm(_dict_markTime);
+
+   if (locale)
+      set_locale_and_flags (locale);
+
+   sanity(configFile);
+
+   if (match_mode)
+      strategy |= DICT_MATCH_MASK;
+
+
+   if (show_info_mode) {
+      dict_test_show_info (database_arg);
+      abort (); /* this should not happen */
+   }
+
+   if (testWord) {             /* stand-alone test mode */
+      dict_test_word (testWord, strategy);
+      abort (); /* this should not happen */
+   }
+
+   if (testFile) {
+      dict_test_file (testFile, strategy);
+      abort (); /* this should not happen */
+   }
+
+   setsig(SIGCHLD, reaper, SA_RESTART);
+   setsig(SIGHUP,   handler_sighup, 0);
+   setsig(SIGUSR1,  handler_sigusr1, 0);
+   if (!dbg_test(DBG_NOFORK))
+      setsig(SIGINT,  handler, 0);
+   setsig(SIGQUIT, handler, 0);
+   setsig(SIGILL,  handler, 0);
+   setsig(SIGTRAP, handler, 0);
+   setsig(SIGTERM, handler, 0);
+   setsig(SIGPIPE, handler, 0);
+   setsig(SIGALRM, handler, SA_RESTART);
+
+   fflush(stdout);
+   fflush(stderr);
+
+   if (locale)
+      log_info(":I: using locale \"%s\"\n", locale);
+
+   if (dbg_test(DBG_VERBOSE))
+      dict_config_print( NULL, DictConfig );
+
+   dict_init_databases( DictConfig );
+
+   dict_initsetproctitle(argc, argv, envp);
+
+   if (inetd) {
+      dict_inetd(&argv, client_delay, 0);
+      exit(0);
+   }
+
+   masterSocket = net_open_tcp( bind_to, daemon_service, depth );
+
+
+   for (;;) {
+      dict_setproctitle( "%s: %d/%d",
+                        dict_get_banner(1),
+                        _dict_forks - _dict_reaps,
+                        _dict_forks );
+      if (flg_test(LOG_SERVER))
+         log_info( ":I: %d accepting on %s\n", getpid(), daemon_service );
+      if ((childSocket = accept(masterSocket,
+                               (struct sockaddr *)&csin, &alen)) < 0) {
+        if (errno == EINTR){
+           if (need_reload_config){
+              reload_config ();
+              need_reload_config = 0;
+              databases_unloaded = 0;
+           }
+
+           if (need_unload_databases){
+              unload_databases ();
+              need_unload_databases = 0;
+              databases_unloaded = 1;
+           }
+           continue;
+        }
+
+#ifdef __linux__
+                               /* Linux seems to return more types of
+                                   errors than other OSs. */
+        if (errno == ETIMEDOUT
+            || errno == ECONNRESET
+            || errno == EHOSTUNREACH
+            || errno == ENETUNREACH) continue;
+        log_info( ":E: can't accept: errno = %d: %s\n",
+                  errno, strerror(errno) );
+#else
+        err_fatal_errno( __FUNCTION__, ":E: can't accept" );
+#endif
+      }
+
+      if (_dict_daemon || dbg_test(DBG_NOFORK)) {
+        dict_daemon(childSocket,&csin,&argv,client_delay,0);
+      } else {
+        if (_dict_forks - _dict_reaps < _dict_daemon_limit) {
+           if (!start_daemon()) { /* child */
+              int databases_loaded = (DictConfig != NULL);
+
+              alarm(0);
+              dict_daemon (
+                 childSocket, &csin, &argv, client_delay,
+                 databases_loaded ? 0 : 2);
+              exit(0);
+           } else {               /* parent */
+              close(childSocket);
+           }
+        } else {
+           dict_daemon(childSocket,&csin,&argv,client_delay,1);
+        }
+      }
+   }
+
+   dict_close_databases (DictConfig);
+
+   destroy ();
+}
diff --git a/src/plugins/stardict/test_dictsip/dictd.h b/src/plugins/stardict/test_dictsip/dictd.h
new file mode 100644 (file)
index 0000000..0e68b9c
--- /dev/null
@@ -0,0 +1,127 @@
+/* dictd.h -- Header file for dict program
+ * Created: Fri Dec  2 20:01:18 1994 by faith@dict
+ * Revised: Mon Apr 22 15:47:26 2002 by faith@dict.org
+ * Copyright 1994-2000, 2002 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DICTD_H_
+#define _DICTD_H_
+
+#include "dictP.h"
+#include "maa.h"
+#include "codes.h"
+#include "defs.h"
+
+#include "net.h"
+#include <errno.h>
+
+#include <netdb.h>
+#include <signal.h>
+/*
+#ifdef __osf__
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#include <sys/wait.h>
+#include <grp.h>
+#include <arpa/inet.h>
+*/
+
+extern const char *daemon_service;
+extern int client_delay;
+extern int depth;
+extern int _dict_daemon_limit;
+extern int _dict_markTime;
+extern const char *logFile;
+extern const char *pidFile;
+extern int logOptions;
+extern const char *bind_to;
+extern int useSyslog;
+extern const char *logFile;
+
+extern int daemon_service_set;
+extern int logFile_set;
+extern int pidFile_set;
+extern int _dict_markTime_set;
+extern int client_delay_set;
+extern int depth_set;
+extern int _dict_daemon_limit_set;
+extern int syslog_facility_set;
+extern int locale_set;
+extern int default_strategy_set;
+extern int bind_to_set;
+
+
+
+
+extern void       dict_disable_strat (dictDatabase *db, const char* strat);
+
+extern void       dict_dump_list( lst_List list );
+extern void       dict_destroy_list( lst_List list );
+
+extern int        dict_destroy_datum( const void *datum );
+
+#ifdef USE_PLUGIN
+extern int        dict_plugin_open (dictDatabase *db);
+extern void       dict_plugin_close (dictDatabase *db);
+#endif
+
+/* dictd.c */
+
+extern void set_minimal (void);
+
+extern void       dict_initsetproctitle( int argc, char **argv, char **envp );
+extern void       dict_setproctitle( const char *format, ... );
+extern const char *dict_format_time( double t );
+extern const char *dict_get_hostname( void );
+extern const char *dict_get_banner( int shortFlag );
+
+extern dictConfig *DictConfig;  /* GLOBAL VARIABLE */
+extern int        _dict_comparisons; /* GLOBAL VARIABLE */
+extern int        _dict_forks; /* GLOBAL VARIABLE */
+extern const char *locale;
+
+extern const char *locale;
+extern       int   inetd;    /* 1 if --inetd is applied, 0 otherwise */
+
+/*
+  If the filename doesn't start with / or .,
+  it is prepended with DICT_DIR
+*/
+extern const char *postprocess_dict_filename (const char *fn);
+/*
+  If the filename doesn't start with / or .,
+  it is prepended with PLUGIN_DIR
+*/
+extern const char *postprocess_plugin_filename (const char *fn);
+
+/* daemon.c */
+
+extern int  dict_daemon( int s, struct sockaddr_in *csin, char ***argv0,
+                        int delay_, int error );
+extern int  dict_inetd( char ***argv0, int delay_, int error );
+extern void daemon_terminate( int sig, const char *name );
+
+/* */
+extern int        utf8_mode;
+
+                               /* dmalloc must be last */
+#ifdef DMALLOC_FUNC_CHECK
+# include "dmalloc.h"
+#endif
+
+#endif
diff --git a/src/plugins/stardict/test_dictsip/dictzip.c b/src/plugins/stardict/test_dictsip/dictzip.c
new file mode 100644 (file)
index 0000000..400ded7
--- /dev/null
@@ -0,0 +1,529 @@
+/* dictzip.c -- 
+ * Created: Tue Jul 16 12:45:41 1996 by faith@dict.org
+ * Revised: Mon Apr 22 11:40:17 2002 by faith@dict.org
+ * Copyright 1996-1998, 2000, 2002 Rickard E. Faith (faith@dict.org)
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+ * $Id: dictzip.c,v 1.26 2004/11/17 12:39:44 cheusov Exp $
+ * 
+ */
+
+#include "dictzip.h"
+#include "data.h"
+
+#include <sys/stat.h>
+
+void dict_data_print_header( FILE *str, dictData *header )
+{
+   char        *date, *year;
+   long        ratio, num, den;
+   static int  first = 1;
+
+   if (first) {
+      fprintf( str,
+              "type   crc        date    time chunks  size     compr."
+              "  uncompr. ratio name\n" );
+      first = 0;
+   }
+   
+   switch (header->type) {
+   case DICT_TEXT:
+      date = ctime( &header->mtime ) + 4; /* no day of week */
+      date[12] = date[20] = '\0'; /* no year or newline*/
+      year = &date[16];
+      fprintf( str, "text %08lx %s %11s ", header->crc, year, date );
+      fprintf( str, "            " );
+      fprintf( str, "          %9ld ", header->length );
+      fprintf( str, "  0.0%% %s",
+              header->origFilename ? header->origFilename : "" );
+      putc( '\n', str );
+      break;
+   case DICT_GZIP:
+   case DICT_DZIP:
+      fprintf( str, "%s", header->type == DICT_DZIP ? "dzip " : "gzip " );
+#if 0
+      switch (header->method) {
+      case 0:  fprintf( str, "store" ); break;
+      case 1:  fprintf( str, "compr" ); break;
+      case 2:  fprintf( str, "pack " ); break;
+      case 3:  fprintf( str, "lzh  " ); break;
+      case 8:  fprintf( str, "defla" ); break;
+      default: fprintf( str, "?    " ); break;
+      }
+#endif
+      date = ctime( &header->mtime ) + 4; /* no day of week */
+      date[12] = date[20] = '\0'; /* no year or newline*/
+      year = &date[16];
+      fprintf( str, "%08lx %s %11s ", header->crc, year, date );
+      if (header->type == DICT_DZIP) {
+        fprintf( str, "%5d %5d ", header->chunkCount, header->chunkLength );
+      } else {
+        fprintf( str, "            " );
+      }
+      fprintf( str, "%9ld %9ld ", header->compressedLength, header->length );
+      /* Algorithm for calculating ratio from gzip-1.2.4,
+         util.c:display_ratio Copyright (C) 1992-1993 Jean-loup Gailly.
+         May be distributed under the terms of the GNU General Public
+         License. */
+      num = header->length-(header->compressedLength-header->headerLength);
+      den = header->length;
+      if (!den)
+        ratio = 0;
+      else if (den < 2147483L)
+        ratio = 1000L * num / den;
+      else
+        ratio = num / (den/1000L);
+      if (ratio < 0) {
+        putc( '-', str );
+        ratio = -ratio;
+      } else putc( ' ', str );
+      fprintf( str, "%2ld.%1ld%%", ratio / 10L, ratio % 10L);
+      fprintf( str, " %s",
+              header->origFilename ? header->origFilename : "" );
+      putc( '\n', str );
+      break;
+   case DICT_UNKNOWN:
+   default:
+      break;
+   }
+}
+
+int dict_data_zip( const char *inFilename, const char *outFilename,
+                  const char *preFilter, const char *postFilter )
+{
+   char          inBuffer[IN_BUFFER_SIZE];
+   char          outBuffer[OUT_BUFFER_SIZE];
+   int           count;
+   unsigned long inputCRC = crc32( 0L, Z_NULL, 0 );
+   z_stream      zStream;
+   FILE          *outStr;
+   FILE          *inStr;
+   int           len;
+   struct stat   st;
+   char          *header;
+   int           headerLength;
+   int           dataLength;
+   int           extraLength;
+   int           chunkLength;
+#if HEADER_CRC
+   int           headerCRC;
+#endif
+   unsigned long chunks;
+   unsigned long chunk = 0;
+   unsigned long total = 0;
+   int           i;
+   char          tail[8];
+   char          *pt, *origFilename;
+
+   
+   /* Open files */
+   if (!(inStr = fopen( inFilename, "r" )))
+      err_fatal_errno( __FUNCTION__,
+                      "Cannot open \"%s\" for read\n", inFilename );
+   if (!(outStr = fopen( outFilename, "w" )))
+      err_fatal_errno( __FUNCTION__,
+                      "Cannot open \"%s\"for write\n", outFilename );
+
+   origFilename = xmalloc( strlen( inFilename ) + 1 );
+   if ((pt = strrchr( inFilename, '/' )))
+      strcpy( origFilename, pt + 1 );
+   else
+      strcpy( origFilename, inFilename );
+
+   /* Initialize compression engine */
+   zStream.zalloc    = NULL;
+   zStream.zfree     = NULL;
+   zStream.opaque    = NULL;
+   zStream.next_in   = NULL;
+   zStream.avail_in  = 0;
+   zStream.next_out  = NULL;
+   zStream.avail_out = 0;
+   if (deflateInit2( &zStream,
+                    Z_BEST_COMPRESSION,
+                    Z_DEFLATED,
+                    -15,       /* Suppress zlib header */
+                    Z_BEST_COMPRESSION,
+                    Z_DEFAULT_STRATEGY ) != Z_OK)
+      err_internal( __FUNCTION__,
+                   "Cannot initialize deflation engine: %s\n", zStream.msg );
+
+   /* Write initial header information */
+   chunkLength = (preFilter ? PREFILTER_IN_BUFFER_SIZE : IN_BUFFER_SIZE );
+   fstat( fileno( inStr ), &st );
+   chunks = st.st_size / chunkLength;
+   if (st.st_size % chunkLength) ++chunks;
+   PRINTF(DBG_VERBOSE,("%lu chunks * %u per chunk = %lu (filesize = %lu)\n",
+                       chunks, chunkLength, chunks * chunkLength,
+                       (unsigned long) st.st_size ));
+   dataLength   = chunks * 2;
+   extraLength  = 10 + dataLength;
+   headerLength = GZ_FEXTRA_START
+                 + extraLength         /* FEXTRA */
+                 + strlen( origFilename ) + 1  /* FNAME  */
+                 + (HEADER_CRC ? 2 : 0);       /* FHCRC  */
+   PRINTF(DBG_VERBOSE,("(data = %d, extra = %d, header = %d)\n",
+                      dataLength, extraLength, headerLength ));
+   header = xmalloc( headerLength );
+   for (i = 0; i < headerLength; i++) header[i] = 0;
+   header[GZ_ID1]        = GZ_MAGIC1;
+   header[GZ_ID2]        = GZ_MAGIC2;
+   header[GZ_CM]         = Z_DEFLATED;
+   header[GZ_FLG]        = GZ_FEXTRA | GZ_FNAME;
+#if HEADER_CRC
+   header[GZ_FLG]        |= GZ_FHCRC;
+#endif
+   header[GZ_MTIME+3]    = (st.st_mtime & 0xff000000) >> 24;
+   header[GZ_MTIME+2]    = (st.st_mtime & 0x00ff0000) >> 16;
+   header[GZ_MTIME+1]    = (st.st_mtime & 0x0000ff00) >>  8;
+   header[GZ_MTIME+0]    = (st.st_mtime & 0x000000ff) >>  0;
+   header[GZ_XFL]        = GZ_MAX;
+   header[GZ_OS]         = GZ_OS_UNIX;
+   header[GZ_XLEN+1]     = (extraLength & 0xff00) >> 8;
+   header[GZ_XLEN+0]     = (extraLength & 0x00ff) >> 0;
+   header[GZ_SI1]        = GZ_RND_S1;
+   header[GZ_SI2]        = GZ_RND_S2;
+   header[GZ_SUBLEN+1]   = ((extraLength - 4) & 0xff00) >> 8;
+   header[GZ_SUBLEN+0]   = ((extraLength - 4) & 0x00ff) >> 0;
+   header[GZ_VERSION+1]  = 0;
+   header[GZ_VERSION+0]  = 1;
+   header[GZ_CHUNKLEN+1] = (chunkLength & 0xff00) >> 8;
+   header[GZ_CHUNKLEN+0] = (chunkLength & 0x00ff) >> 0;
+   header[GZ_CHUNKCNT+1] = (chunks & 0xff00) >> 8;
+   header[GZ_CHUNKCNT+0] = (chunks & 0x00ff) >> 0;
+   strcpy( &header[GZ_FEXTRA_START + extraLength], origFilename );
+   fwrite( header, 1, headerLength, outStr );
+    
+   /* Read, compress, write */
+   while (!feof( inStr )) {
+      if ((count = fread( inBuffer, 1, chunkLength, inStr ))) {
+        dict_data_filter( inBuffer, &count, IN_BUFFER_SIZE, preFilter );
+        
+        inputCRC = crc32( inputCRC, inBuffer, count );
+        zStream.next_in   = inBuffer;
+        zStream.avail_in  = count;
+        zStream.next_out  = outBuffer;
+        zStream.avail_out = OUT_BUFFER_SIZE;
+        if (deflate( &zStream, Z_FULL_FLUSH ) != Z_OK)
+           err_fatal( __FUNCTION__, "deflate: %s\n", zStream.msg );
+        assert( zStream.avail_in == 0 );
+        len = OUT_BUFFER_SIZE - zStream.avail_out;
+        assert( len <= 0xffff );
+
+        dict_data_filter( outBuffer, &len, OUT_BUFFER_SIZE, postFilter );
+        
+        assert( len <= 0xffff );
+        header[GZ_RNDDATA + chunk*2 + 1] = (len & 0xff00) >>  8;
+        header[GZ_RNDDATA + chunk*2 + 0] = (len & 0x00ff) >>  0;
+        fwrite( outBuffer, 1, len, outStr );
+
+        ++chunk;
+        total += count;
+        if (dbg_test( DBG_VERBOSE )) {
+           printf( "chunk %5lu: %lu of %lu total\r",
+                   chunk, total, (unsigned long) st.st_size );
+           fflush( stdout );
+        }
+      }
+   }
+   PRINTF(DBG_VERBOSE,("total: %lu chunks, %lu bytes\n", chunks, (unsigned long) st.st_size));
+    
+   /* Write last bit */
+#if 0
+   dmalloc_verify(0);
+#endif
+   zStream.next_in   = inBuffer;
+   zStream.avail_in  = 0;
+   zStream.next_out  = outBuffer;
+   zStream.avail_out = OUT_BUFFER_SIZE;
+   if (deflate( &zStream, Z_FINISH ) != Z_STREAM_END)
+      err_fatal( __FUNCTION__, "deflate: %s\n", zStream.msg );
+   assert( zStream.avail_in == 0 );
+   len = OUT_BUFFER_SIZE - zStream.avail_out;
+   fwrite( outBuffer, 1, len, outStr );
+   PRINTF(DBG_VERBOSE,("(wrote %d bytes, final, crc = %lx)\n",
+                      len, inputCRC ));
+
+   /* Write CRC and length */
+#if 0
+   dmalloc_verify(0);
+#endif
+   tail[0 + 3] = (inputCRC & 0xff000000) >> 24;
+   tail[0 + 2] = (inputCRC & 0x00ff0000) >> 16;
+   tail[0 + 1] = (inputCRC & 0x0000ff00) >>  8;
+   tail[0 + 0] = (inputCRC & 0x000000ff) >>  0;
+   tail[4 + 3] = (st.st_size & 0xff000000) >> 24;
+   tail[4 + 2] = (st.st_size & 0x00ff0000) >> 16;
+   tail[4 + 1] = (st.st_size & 0x0000ff00) >>  8;
+   tail[4 + 0] = (st.st_size & 0x000000ff) >>  0;
+   fwrite( tail, 1, 8, outStr );
+
+   /* Write final header information */
+#if 0
+   dmalloc_verify(0);
+#endif
+   rewind( outStr );
+#if HEADER_CRC
+   headerCRC = crc32( 0L, Z_NULL, 0 );
+   headerCRC = crc32( headerCRC, header, headerLength - 2);
+   header[headerLength - 1] = (headerCRC & 0xff00) >> 8;
+   header[headerLength - 2] = (headerCRC & 0x00ff) >> 0;
+#endif
+   fwrite( header, 1, headerLength, outStr );
+
+   /* Close files */
+#if 0
+   dmalloc_verify(0);
+#endif
+   fclose( outStr );
+   fclose( inStr );
+    
+   /* Shut down compression */
+   if (deflateEnd( &zStream ) != Z_OK)
+      err_fatal( __FUNCTION__, "defalteEnd: %s\n", zStream.msg );
+
+   xfree( origFilename );
+   xfree( header );
+
+   return 0;
+}
+
+static const char *id_string( const char *id )
+{
+   static char buffer[BUFFERSIZE];
+   char        *pt;
+
+   snprintf( buffer, BUFFERSIZE, "%s", DICT_VERSION );
+   pt = buffer + strlen( buffer );
+
+   return buffer;
+}
+
+static void banner( void )
+{
+   const char *id = "$Id: dictzip.c,v 1.26 2004/11/17 12:39:44 cheusov Exp $";
+   
+   fprintf( stderr, "%s %s\n", err_program_name(), id_string( id ) );
+   fprintf( stderr,
+           "Copyright 1996-2002 Rickard E. Faith (faith@dict.org)\n\n" );
+}
+
+static void license( void )
+{
+   static const char *license_msg[] = {
+     "This program is free software; you can redistribute it and/or modify it",
+     "under the terms of the GNU General Public License as published by the",
+     "Free Software Foundation; either version 1, or (at your option) any",
+     "later version.",
+     "",
+     "This program is distributed in the hope that it will be useful, but",
+     "WITHOUT ANY WARRANTY; without even the implied warranty of",
+     "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU",
+     "General Public License for more details.",
+     "",
+     "You should have received a copy of the GNU General Public License along",
+     "with this program; if not, write to the Free Software Foundation, Inc.,",
+     "675 Mass Ave, Cambridge, MA 02139, USA.",
+   0 };
+   const char        **p = license_msg;
+   
+   banner();
+   while (*p) fprintf( stderr, "   %s\n", *p++ );
+}
+
+static void help( void )
+{
+   static const char *help_msg[] = {
+      "Usage: dictzip [options] name",
+      "",
+      "-d --decompress      decompress",
+      "-f --force           force overwrite of output file",
+      "-h --help            give this help",
+      "-k --keep            do not delete original file",
+      "-l --list            list compressed file contents",
+      "-L --license         display software license",
+      "-c --stdout          write to stdout (decompression only)",
+      "-t --test            test compressed file integrity",
+      "-v --verbose         verbose mode",
+      "-V --version         display version number",
+      "-D --debug           select debug option",
+      "-s --start <offset>  starting offset for decompression (decimal)",
+      "-e --size <offset>   size for decompression (decimal)",
+      "-S --Start <offset>  starting offset for decompression (base64)",
+      "-E --Size <offset>   size for decompression (base64)",
+      "-p --pre <filter>    pre-compression filter",
+      "-P --post <filter>   post-compression filter",
+      0 };
+   const char        **p = help_msg;
+
+   banner();
+   while (*p) fprintf( stderr, "%s\n", *p++ );
+}
+
+int main( int argc, char **argv )
+{
+   int           c;
+   size_t        i;
+   size_t        j;
+   int           decompressFlag = 0;
+   int           forceFlag      = 0;
+   int           keepFlag       = 0;
+   int           listFlag       = 0;
+   int           stdoutFlag     = 0;
+   int           testFlag       = 0;
+   char          buffer[BUFFERSIZE];
+   char          *buf;
+   char          *pre           = NULL;
+   char          *post          = NULL;
+   unsigned long start          = 0;
+   unsigned long size           = 0;
+   unsigned long clSize         = 0; /* from command line */
+   unsigned long clStart        = 0; /* from comment line */
+   dictData      *header;
+   char          *pt;
+   FILE          *str;
+   int           len;
+   char          filename[BUFFERSIZE];
+   struct option longopts[] = {
+      { "stdout",       0, 0, 'c' },
+      { "decompress",   0, 0, 'd' },
+      { "force",        0, 0, 'f' },
+      { "help",         0, 0, 'h' },
+      { "keep",         0, 0, 'k' },
+      { "list",         0, 0, 'l' },
+      { "license",      0, 0, 'L' },
+      { "test",         0, 0, 't' },
+      { "verbose",      0, 0, 'v' },
+      { "version",      0, 0, 'V' },
+      { "debug",        1, 0, 'D' },
+      { "start",        1, 0, 's' },
+      { "size",         1, 0, 'e' },
+      { "Start",        1, 0, 'S' },
+      { "Size",         1, 0, 'E' },
+      { "pre",          1, 0, 'p' },
+      { "post",         1, 0, 'P' },
+      { 0,              0, 0,  0  }
+   };
+
+   /* Initialize Libmaa */
+   maa_init( argv[0] );
+   dbg_register( DBG_VERBOSE, "verbose" );
+   dbg_register( DBG_ZIP,     "zip" );
+   dbg_register( DBG_UNZIP,   "unzip" );
+
+   if ((pt = strrchr( argv[0], '/' ))) ++pt;
+   else                                pt = argv[0];
+   if (!strcmp(pt, "dictunzip")) ++decompressFlag;
+   if (!strcmp(pt, "dictzcat")) {
+      ++decompressFlag;
+      ++stdoutFlag;
+   }
+   
+#if 0
+   if (signal( SIGINT, SIG_IGN ) != SIG_IGN)  signal( SIGINT, sig_handler );
+   if (signal( SIGQUIT, SIG_IGN ) != SIG_IGN) signal( SIGQUIT, sig_handler );
+#endif
+
+   while ((c = getopt_long( argc, argv,
+                           "cdfhklLe:E:s:S:tvVD:p:P:",
+                           longopts, NULL )) != EOF)
+      switch (c) {
+      case 'd': ++decompressFlag;                                      break;
+      case 'f': ++forceFlag;                                           break;
+      case 'k': ++keepFlag;                                            break;
+      case 'l': ++listFlag;                                            break;
+      case 'L': license(); exit( 1 );                                  break;
+      case 'c': ++stdoutFlag;                                          break;
+      case 't': ++testFlag;                                            break;
+      case 'v': dbg_set( "verbose" );                                  break;
+      case 'V': banner(); exit( 1 );                                   break;
+      case 'D': dbg_set( optarg );                                     break;
+      case 's': ++decompressFlag; clStart = strtoul( optarg, NULL, 10 ); break;
+      case 'e': ++decompressFlag; clSize  = strtoul( optarg, NULL, 10 ); break;
+      case 'S': ++decompressFlag; clStart = b64_decode( optarg );        break;
+      case 'E': ++decompressFlag; clSize  = b64_decode( optarg );        break;
+      case 'p': pre = optarg;                                          break;
+      case 'P': post = optarg;                                         break;
+      default:  
+      case 'h': help(); exit( 1 );                                     break;
+      }
+
+   if (testFlag) ++listFlag;
+
+   for (i = optind; i < (size_t) argc; i++) {
+      size  = clSize  ? clSize  : 0;
+      start = clStart ? clStart : 0;
+      if (listFlag) {
+        header = dict_data_open( argv[i], 1 );
+        dict_data_print_header( stdout, header );
+        dict_data_close( header );
+      } else if (decompressFlag) {
+        if (stdoutFlag) {
+           header = dict_data_open( argv[i], 0 );
+           if (!size) size = header->length;
+           if (!start) {
+              len = header->chunkLength;
+              for (j = 0; j < size; j += len) {
+                 if (j + len >= size) len = size - j;
+                 buf = dict_data_read_ ( header, j, len, pre, post );
+                 fwrite( buf, len, 1, stdout );
+                 fflush( stdout );
+                 xfree( buf );
+              }
+           } else {
+              buf = dict_data_read_ ( header, start, size, pre, post );
+              fwrite( buf, size, 1, stdout );
+              fflush( stdout );
+              xfree( buf );
+           }
+           dict_data_close( header );
+        } else {
+           strlcpy( filename, argv[i], BUFFERSIZE );
+
+           if ((pt = strrchr( filename, '.' ))) *pt = '\0';
+           else
+              err_fatal( __FUNCTION__, "Cannot truncate filename\n" );
+           if (!forceFlag && (str = fopen( filename, "r" )))
+              err_fatal( __FUNCTION__, "%s already exists\n", filename );
+           if (!(str = fopen( filename, "w" )))
+              err_fatal_errno( __FUNCTION__,
+                               "Cannot open %s for write\n", filename );
+           header = dict_data_open( argv[i], 0 );
+           if (!size) size = header->length;
+           len = header->chunkLength;
+           for (j = 0; j < size; j += len) {
+              if (j + len >= size) len = size - j;
+              buf = dict_data_read_ ( header, j, len, pre, post );
+              fwrite( buf, len, 1, str );
+              fflush( str );
+              xfree( buf );
+           }       
+           dict_data_close( header );
+           if (!keepFlag && unlink( argv[i] ))
+              err_fatal_errno( __FUNCTION__, "Cannot unlink %s\n", argv[i] );
+        }
+      } else {
+        snprintf( buffer,BUFFERSIZE-1, "%s.dz", argv[i] );
+        if (!dict_data_zip( argv[i], buffer, pre, post )) {
+           if (!keepFlag && unlink( argv[i] ))
+               err_fatal_errno( __FUNCTION__, "Cannot unlink %s\n", argv[i] );
+        } else {
+           err_fatal( __FUNCTION__, "Compression failed\n" );
+        }
+      }
+   }
+
+   return 0;
+}
diff --git a/src/plugins/stardict/test_dictsip/dictzip.h b/src/plugins/stardict/test_dictsip/dictzip.h
new file mode 100644 (file)
index 0000000..6da7e2c
--- /dev/null
@@ -0,0 +1,120 @@
+/* dictzip.h -- Header file for dict program
+ * Created: Fri Dec  2 20:01:18 1994 by faith@dict.org
+ * Revised: Fri Dec 22 06:06:31 2000 by faith@dict.org
+ * Copyright 1994, 1995, 1996, 1997, 2000 Rickard E. Faith (faith@dict.org)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 1, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DICTZIP_H_
+#define _DICTZIP_H_
+
+//#include "maa.h"
+#include "zlib.h"
+//#include "dictd.h"
+
+                               /* End of configurable things */
+
+#define BUFFERSIZE 10240
+#define DBG_VERBOSE     (0<<30|1<< 0) /* Verbose                           */
+#define DBG_ZIP         (0<<30|1<< 1) /* Zip                               */
+#define DBG_UNZIP       (0<<30|1<< 2) /* Unzip                             */
+#define DBG_SEARCH      (0<<30|1<< 3) /* Search                            */
+#define DBG_SCAN        (0<<30|1<< 4) /* Config file scan                  */
+#define DBG_PARSE       (0<<30|1<< 5) /* Config file parse                 */
+#define DBG_INIT        (0<<30|1<< 6) /* Database initialization           */
+
+#define HEADER_CRC 0           /* Conflicts with gzip 1.2.4               */
+
+/* Use of the FEXTRA fields.  The FEXTRA area can be 0xffff bytes long, 2
+   bytes of which are used for the subfield ID, and 2 bytes of which are
+   used for the subfield length.  This leaves 0xfffb bytes (0x7ffd 2-byte
+   entries or 0x3ffe 4-byte entries).  Given that the zip output buffer must
+   be 10% + 12 bytes larger than the input buffer, we can store 58969 bytes
+   per entry, or about 1.8GB if the 2-byte entries are used.  If this
+   becomes a limiting factor, another format version can be selected and
+   defined for 4-byte entries. */
+
+
+                               /* Output buffer must be greater than or
+                                   equal to 110% of input buffer size, plus
+                                   12 bytes. */
+#define OUT_BUFFER_SIZE 0xffffL
+
+#define IN_BUFFER_SIZE ((unsigned long)((double)(OUT_BUFFER_SIZE - 12) * 0.89))
+
+#define PREFILTER_IN_BUFFER_SIZE (IN_BUFFER_SIZE * 0.89)
+
+
+/* For gzip-compatible header, as defined in RFC 1952 */
+
+                               /* Magic for GZIP (rfc1952)                */
+#define GZ_MAGIC1     0x1f     /* First magic byte                        */
+#define GZ_MAGIC2     0x8b     /* Second magic byte                       */
+
+                               /* FLaGs (bitmapped), from rfc1952         */
+#define GZ_FTEXT      0x01     /* Set for ASCII text                      */
+#define GZ_FHCRC      0x02     /* Header CRC16                            */
+#define GZ_FEXTRA     0x04     /* Optional field (random access index)    */
+#define GZ_FNAME      0x08     /* Original name                           */
+#define GZ_COMMENT    0x10     /* Zero-terminated, human-readable comment */
+#define GZ_MAX           2     /* Maximum compression                     */
+#define GZ_FAST          4     /* Fasted compression                      */
+
+                               /* These are from rfc1952                  */
+#define GZ_OS_FAT        0     /* FAT filesystem (MS-DOS, OS/2, NT/Win32) */
+#define GZ_OS_AMIGA      1     /* Amiga                                   */
+#define GZ_OS_VMS        2     /* VMS (or OpenVMS)                        */
+#define GZ_OS_UNIX       3      /* Unix                                    */
+#define GZ_OS_VMCMS      4      /* VM/CMS                                  */
+#define GZ_OS_ATARI      5      /* Atari TOS                               */
+#define GZ_OS_HPFS       6      /* HPFS filesystem (OS/2, NT)              */
+#define GZ_OS_MAC        7      /* Macintosh                               */
+#define GZ_OS_Z          8      /* Z-System                                */
+#define GZ_OS_CPM        9      /* CP/M                                    */
+#define GZ_OS_TOPS20    10      /* TOPS-20                                 */
+#define GZ_OS_NTFS      11      /* NTFS filesystem (NT)                    */
+#define GZ_OS_QDOS      12      /* QDOS                                    */
+#define GZ_OS_ACORN     13      /* Acorn RISCOS                            */
+#define GZ_OS_UNKNOWN  255      /* unknown                                 */
+
+#define GZ_RND_S1       'R'    /* First magic for random access format    */
+#define GZ_RND_S2       'A'    /* Second magic for random access format   */
+
+#define GZ_ID1           0     /* GZ_MAGIC1                               */
+#define GZ_ID2           1     /* GZ_MAGIC2                               */
+#define GZ_CM            2     /* Compression Method (Z_DEFALTED)         */
+#define GZ_FLG          3      /* FLaGs (see above)                       */
+#define GZ_MTIME         4     /* Modification TIME                       */
+#define GZ_XFL           8     /* eXtra FLags (GZ_MAX or GZ_FAST)         */
+#define GZ_OS            9     /* Operating System                        */
+#define GZ_XLEN         10     /* eXtra LENgth (16bit)                    */
+#define GZ_FEXTRA_START 12     /* Start of extra fields                   */
+#define GZ_SI1          12     /* Subfield ID1                            */
+#define GZ_SI2          13      /* Subfield ID2                            */
+#define GZ_SUBLEN       14     /* Subfield length (16bit)                 */
+#define GZ_VERSION      16      /* Version for subfield format             */
+#define GZ_CHUNKLEN     18     /* Chunk length (16bit)                    */
+#define GZ_CHUNKCNT     20     /* Number of chunks (16bit)                */
+#define GZ_RNDDATA      22     /* Random access data (16bit)              */
+
+#define DICT_UNKNOWN    0
+#define DICT_TEXT       1
+#define DICT_GZIP       2
+#define DICT_DZIP       3
+
+
+#endif
diff --git a/src/plugins/xdxf/COPYING b/src/plugins/xdxf/COPYING
new file mode 100644 (file)
index 0000000..fb6319b
--- /dev/null
@@ -0,0 +1,339 @@
+    GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
\ No newline at end of file
diff --git a/src/plugins/xdxf/Makefile b/src/plugins/xdxf/Makefile
new file mode 100755 (executable)
index 0000000..60c71ec
--- /dev/null
@@ -0,0 +1,43 @@
+COMPILER = gcc
+DEBUG = -Wall -g
+INCLUDE = include
+INCLUDE_ENGINE = ../../../include
+LIBS = `pkg-config --libs glib-2.0 gmodule-2.0 gnome-vfs-2.0` -lexpat
+FLAGS = `pkg-config --cflags glib-2.0 gmodule-2.0 gnome-vfs-2.0` -I${INCLUDE} -I${INCLUDE_ENGINE}
+SOURCES = src
+BINARIES = bin
+MAIN_BINARIES = ../../../bin
+EXECUTABLE = ${SOURCES}/test_engin
+
+${EXECUTABLE}: ${BINARIES}/engine_xdxf.o ${INCLUDE_ENGINE}/dictionary_engine.h                 
+               @echo -e -n   "| Linking engine-xdxf to dynamic library...                                          |\n"
+               @gcc -shared -fPIC ${FLAGS} ${LIBS} ${DEBUG} ${BINARIES}/engine_xdxf.o -o ${SOURCES}/engine_xdxf.so 
+               @echo -e -n   "| Building engine_xdxf module done...                                                |\n"
+               @echo -e -n   "+------------------------------------------------------------------------------------+\n\n"
+               @cp ${SOURCES}/engine_xdxf.so ${MAIN_BINARIES}
+
+
+${BINARIES}/engine_xdxf.o: ${SOURCES}/engine_xdxf.c ${INCLUDE}/engine_xdxf.h
+               @echo -e -n "\n+---------------- ENGINE XDXF -------------------------------------------------------+\n"
+               @echo -e -n   "| Compiling engine_xdxf module => engine_xdxf.o ...                                  |\n"
+               @gcc ${FLAGS} ${DEBUG} -c -fPIC ${SOURCES}/engine_xdxf.c -o ${BINARIES}/engine_xdxf.o 
+
+test: test.o
+               @echo "Linking test program..."
+               @gcc ${LIBS} ${DEBUG} ${DEBUG} -o ${SOURCES}/test ${BINARIES}/test.o
+               @echo -e "Building test program finished.\n"
+test.o:
+               @echo "Compiling test program..."
+               @gcc ${FLAGS} ${DEBUG} -c -o ${BINARIES}/test.o ${SOURCES}/test.c
+
+check:
+               @echo "Running test program:"
+               @run-standalone.sh ${SOURCES}/test
+
+clean :
+               @rm -f ${BINARIES}/*
+               @rm -f ${SOURCES}/test
+               @rm -f ${SOURCES}/*~
+               @rm -f *~
+               @rm -f ${INCLUDE}/*~
+               @rm -f ${SOURCES}/engine_xdxf.so
diff --git a/src/plugins/xdxf/include/engine_xdxf.h b/src/plugins/xdxf/include/engine_xdxf.h
new file mode 100644 (file)
index 0000000..c611cc8
--- /dev/null
@@ -0,0 +1,334 @@
+/*******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+#ifndef _DICTIONARY_ENGINE_XDXF
+#define _DICTIONARY_ENGINE_XDXF
+
+#ifdef __cplusplus
+        extern "C" {
+#endif
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************************* HEADERS SECTION:
+//------------------------------------------------------------------------------
+// headers with unix types/functions - onl for timers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>     
+#include <unistd.h>   
+//------------------------------------------------------------------------------
+// header with GLIB definitions/functions/types
+#include <glib.h>
+//------------------------------------------------------------------------------
+// header with gnome-vfs - recommended I/O API for maemo
+#include <libgnomevfs/gnome-vfs.h>
+//------------------------------------------------------------------------------
+// header with expat - XML Parser API
+#include <expat.h>
+//------------------------------------------------------------------------------
+// header wit engine API
+#include "dictionary_engine.h"
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//********************************************************* DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+// definitions for timer function - flag telling if we want to start or stop
+// timing
+#define TIMER_START     TRUE
+#define TIMER_STOP      FALSE
+//------------------------------------------------------------------------------
+// definitions of version and format which engine handles
+#define DIC_ENG_VERSION "0.1b"
+#define DIC_ENG_FORMAT  "XDXF"
+//------------------------------------------------------------------------------
+// defines lenght of buffers for particular functions in engine which needs
+// big buffers
+#define DICT_CACHEING_BUFF_SIZE                 16*1024
+#define DICT_SEARCHING_WORD_LIST_BUFF_SIZE      16*1024
+#define DICT_SEARCHING_WORD_TRAN_BUFF_SIZE      16*1024
+//------------------------------------------------------------------------------
+// maximum length of word possible to find in any dictionary
+#define DICT_MAX_WORD_LENGTH   512
+//------------------------------------------------------------------------------
+// macro for "printing" gboolean statement - "TRUE" or "FALSE"
+#define PRINT_STATE(state) ( (state) ? "TRUE" : "FALSE" )
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************** DATA STRUCTURE DEFINITIONS SECTION:
+//------------------------------------------------------------------------------
+/** \brief Structure used while dict_eng_module_check() is working.
+ */
+struct _XDXFCheckingData {
+        gboolean        further;
+        gboolean        good;
+        guint                deep;
+};
+typedef struct _XDXFCheckingData        XDXFCheckingData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help parse xdxf file for searching words list.
+ */
+struct _XDXFWordsListData {
+        gchar* last_word;
+        gchar* pattern;
+        guint  pattern_len;
+        guint  last_word_length;
+        GArray* result;
+        guint  one_word;
+        gboolean cont;
+};
+typedef struct _XDXFWordsListData       XDXFWordsListData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help parse xdxf file for searching word's translation.
+ */
+struct _XDXFWordsTransData {
+        gchar* last_word;
+        gchar* word;
+        guint  word_len;
+        guint  last_word_length;
+        gchar* translation;
+        guint  one_word;
+        gboolean cont;
+        gulong last_start;
+        XML_Parser* parser;
+        gboolean found;
+        GnomeVFSHandle*        xdxf;
+};
+typedef struct _XDXFWordsTransData      XDXFWordsTransData;
+//------------------------------------------------------------------------------
+/** \brief Structure to help make optimization possible
+ */
+struct _XDXFCacheData {
+        gchar* buffer;
+        long last_start;
+        long last_stop;
+        long last_length;
+        GnomeVFSHandle* cache;
+        XML_Parser parser;
+        int state;
+        long buffer_length;
+};
+typedef struct _XDXFCacheData           XDXFCacheData;
+//------------------------------------------------------------------------------
+/** \brief Internal data structure for representing part of file.
+ */
+struct _FilePart {
+        guint offset;
+        guint length;
+};
+typedef struct _FilePart        FilePart;
+//------------------------------------------------------------------------------
+/** \brief Internal data structure of XDXF Engine.
+ */
+struct _XDXFData {
+        GnomeVFSHandle*         xdxf;
+        GnomeVFSHandle*         cache;
+        gchar*                  dict_path;
+        EngineStatus            last_error;
+        gboolean                auto_free;
+
+        cb_progress             cb_progress_caching;
+        gpointer                cb_progress_caching_data;
+        gdouble                 cb_progress_caching_seed;
+
+        cb_progress             cb_progress_word_list;
+        gpointer                cb_progress_word_list_data;
+        gdouble                 cb_progress_word_list_seed;
+
+        cb_progress             cb_progress_word_trans;
+        gpointer                cb_progress_word_trans_data;
+        gdouble                 cb_progress_word_trans_seed;
+
+        cb_word_list            cb_search_word_list;
+        gpointer                cb_search_word_list_data;
+
+        cb_word_translation     cb_search_word_trans;
+        gpointer                cb_search_word_trans_data;      
+};
+typedef struct _XDXFData        XDXFData;
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//*************************************************** PARSING FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// while is_xdxf_file() is working
+static void     is_xdxf_file_start(void *data,
+                                   const char *el,
+                                   const char **attr);
+static void     is_xdxf_file_end(void *data,  const char *el);
+//------------------------------------------------------------------------------                                                 
+// while dict_eng_search_word_list() is working
+static void     search_word_list_start(void *data,
+                                       const char *el,
+                                       const char **attr); 
+static void     search_word_list_end(void *data, const char *el);
+static void     search_word_list_text(void *data, const XML_Char *txt, int len);
+//------------------------------------------------------------------------------
+// // while dict_eng_search_word_translation() is working
+static void     search_word_trans_start(void *data,
+                                        const char *el,
+                                        const char **attr);
+static void     search_word_trans_end(void *data, const char *el);                             
+static void     search_word_trans_text(void *data,
+                                       const XML_Char *txt,
+                                       int len);
+//------------------------------------------------------------------------------
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//************************************************ ADDITIONAL FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// returning concrete part of file
+static gchar*           read_file_part(FilePart* part, GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// convert string to proper path name (no filename, no "/" at the ned, file 
+// exist)
+static gchar*           string_to_path(gchar** string);
+//------------------------------------------------------------------------------
+// tells if file is in XDXF format (file should exist)
+static gboolean         is_xdxf_file(gchar* file); 
+//------------------------------------------------------------------------------
+// start/stop timers -  returnet -1.0 if we start or seconds passed from start 
+// if we want to stop timer
+//static double           timer(gboolean start, gchar* message);
+//------------------------------------------------------------------------------
+// return size of files
+static guint64          get_file_size(GnomeVFSHandle* file);
+//------------------------------------------------------------------------------
+// return how many records (from cache file) are in current buffer a with length
+// length.
+static guint            get_max_length(gchar* a, guint length);
+//------------------------------------------------------------------------------
+// return translation of word using cache file
+static gchar* word_translation_cache(XDXFData* data, gchar* word);
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static gchar* word_translation_xdxf(XDXFData* data, gchar* word);
+//------------------------------------------------------------------------------
+// return translation of word using cache file
+static void word_list_cache(XDXFData* data,
+                            gchar* pattern,
+                            GArray* result,
+                            gpointer cb_data);
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static void word_list_xdxf(XDXFData* data,
+                           gchar* pattern,
+                           GArray* result,
+                           gpointer cb_data);
+//------------------------------------------------------------------------------
+
+
+
+//______________________________________________________________________________
+// *****************************************************************************
+//****************************************************** MAIN FUNCTIONS SECTION:
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_check(module,location) function
+gboolean        xdxf_engine_check(gchar* location);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_description(module) function
+gchar*          xdxf_engine_description();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_format(module) function
+gchar*          xdxf_engine_format();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_get_version(module) function
+gchar*          xdxf_engine_version();
+//------------------------------------------------------------------------------
+// implementation of dict_eng_module_create(module,location,flags) and
+// dict_eng_module_create_ext(module,location,flags) functions
+Engine*         xdxf_engine_create(gchar* location, 
+                              EngineOptimizationFlag flags,
+                              cb_progress progress_handler,
+                              gpointer progress_data,
+                              gdouble seed);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_destroy(engine) function
+void            xdxf_engine_close(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_location(engine) function
+gchar*          xdxf_engine_location(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_optimize(engine) function
+void            xdxf_engine_optimize(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_is_optimized( engine ) function
+gboolean        xdxf_engine_is_optimized(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_auto_free(engine, state) function
+void            xdxf_engine_set_auto_free(Engine* engine, gboolean state);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_callback(engine,signal,c_handler,data) 
+// function
+gpointer        xdxf_engine_set_callbacks(Engine* engine,
+                                     gchar* event,
+                                     gpointer c_handler,
+                                     gpointer user_data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_set_progress_seed(engine, signal, val) function
+void            xdxf_engine_set_progress_seed(Engine* engine,
+                                         gchar* signal,
+                                         gdouble seed);
+//------------------------------------------------------------------------------
+// implementation ofdict_eng_search_word_list(engine,pattern) function
+void            xdxf_engine_search_word_list(Engine* engine,
+                                             gchar* pattern,
+                                             gpointer data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation(engine,word) function
+void            xdxf_engine_search_word_translation(Engine* engine,
+                                                    gchar* word,
+                                                    gpointer data);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_search_word_translation_extended(engine,word)
+// function
+void            xdxf_engine_search_word_translation_extended(Engine* engine,
+                                                        gchar* word);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_get_last_state(engine) function
+EngineStatus    xdxf_engine_error(Engine* engine);
+//------------------------------------------------------------------------------
+// implementation of dict_eng_state_message(error) function
+gchar*          xdxf_engine_error_message(EngineStatus error);
+//------------------------------------------------------------------------------
+// implementation of engine_global_functions(void) function
+// API 2.0
+gboolean       xdxf_engine_add_word(Engine* engine,
+                               gchar*  word,
+                               gchar*  translation);
+
+gboolean       xdxf_engine_remove_word(Engine* engine, gchar*  word);
+
+EngineModule    engine_global_functions();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/plugins/xdxf/src/engine_xdxf.c b/src/plugins/xdxf/src/engine_xdxf.c
new file mode 100644 (file)
index 0000000..fb05efc
--- /dev/null
@@ -0,0 +1,1677 @@
+/******************************************************************************
+This file is part of WhiteStork.
+
+WhiteStork is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WhiteStork is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License 
+along with WhiteStork; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+******************************************************************************/
+
+// header with data structure and function definition for XDXF engine.
+// Also Engine API. 
+#include <engine_xdxf.h>
+#include <string.h>
+//------------------------------------------------------------------------------
+
+
+
+// searching word translation in cache file
+static gchar* word_translation_cache(XDXFData* data, gchar* word)
+{
+        gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);
+        gchar b[DICT_SEARCHING_WORD_TRAN_BUFF_SIZE + 1];
+        GnomeVFSFileSize bytes_readed;
+
+        guint word_length = strlen(word);
+        guint record_length = 0;
+        guint trans_offset = 0;
+        guint already = 0;
+        guint64 readed = 0;
+        gchar* buffer = NULL;
+        gchar* trans = NULL;
+        guint file_size = get_file_size(data->cache);
+        while(TRUE) {
+                gnome_vfs_read(data->cache,
+                               b,
+                               DICT_SEARCHING_WORD_TRAN_BUFF_SIZE,
+                               &bytes_readed
+                              );
+                guint max_length = (guint)get_max_length(b,bytes_readed);
+                readed += max_length;
+                buffer = b;
+                already = 0;
+               gchar* tmp = NULL;
+                while(already < max_length) {
+                        memcpy(&record_length, buffer, sizeof(guint));
+                        memcpy(&trans_offset,
+                                buffer+record_length-2*sizeof(guint),
+                                sizeof(guint)
+                              );
+                        buffer[record_length-sizeof(guint)*2] = '\0';
+                       tmp = g_utf8_casefold(buffer+sizeof(guint), -1);
+                        if(((record_length - 3*sizeof(guint)) == word_length) &&
+                           (g_utf8_collate(word,tmp) == 0)) {
+                                FilePart translation = {0,0};
+                                translation.offset = trans_offset;
+                                memcpy(&(translation.length),
+                                        buffer + record_length - sizeof(guint),
+                                        sizeof(guint)
+                                      );
+                                trans =read_file_part(&translation, data->xdxf);
+                               g_free(tmp); tmp = NULL;
+                                break;
+                        };
+                        already += record_length;
+                        buffer += record_length;
+                       g_free(tmp); tmp = NULL;
+                };
+               
+
+                if( ( bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE ) || 
+                      ( readed > (file_size - 3) ))
+               {
+                        break;
+               };
+               gnome_vfs_seek(data->cache,
+                       GNOME_VFS_SEEK_CURRENT,
+                       ((gint)max_length) -DICT_SEARCHING_WORD_TRAN_BUFF_SIZE
+                       );
+        }
+        return trans;
+}
+//------------------------------------------------------------------------------
+// searching word translation in xdxf dictionary
+static gchar* word_translation_xdxf(XDXFData* data, gchar* word) {
+       gchar* casefold_word = g_utf8_casefold(word, -1);
+       guint word_length = strlen(casefold_word);
+        gchar* trans = NULL;
+        gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 0);
+        GnomeVFSResult vfs_result;
+        GnomeVFSFileSize bytes_readed = DICT_SEARCHING_WORD_TRAN_BUFF_SIZE;
+        gchar buffer[DICT_SEARCHING_WORD_TRAN_BUFF_SIZE+1];
+        guint64 file_size = get_file_size(data->xdxf);
+
+
+        XML_Parser parser = XML_ParserCreate(NULL);
+        if (!parser) {
+                g_warning("XDXF/%s->%s() Could not open initialize "
+                          "XML parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return NULL;
+        };
+
+        gchar tmp[DICT_MAX_WORD_LENGTH];
+        XDXFWordsTransData search_data = {tmp,
+                                          casefold_word,
+                                          word_length,
+                                          0,
+                                          NULL,
+                                          FALSE,
+                                          TRUE,
+                                          0,
+                                          &parser,
+                                          FALSE,
+                                          data->xdxf
+                                         };
+        XML_SetElementHandler(parser,
+                              search_word_trans_start,
+                              search_word_trans_end
+                             );
+        XML_SetCharacterDataHandler(parser, search_word_trans_text);
+                
+        XML_SetUserData(parser, &search_data);
+
+        //gdouble last_prog = 0;
+        while(TRUE) {
+                vfs_result = gnome_vfs_read(data->xdxf,
+                                            buffer,
+                                            DICT_SEARCHING_WORD_TRAN_BUFF_SIZE,
+                                            &bytes_readed
+                                           );
+                XML_Parse(parser,
+                          buffer,
+                          bytes_readed,
+                          bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE
+                         );
+                        
+                gdouble last_prog = 0.0;
+                if(data->cb_progress_word_trans != NULL) {
+                        GnomeVFSFileSize act_pos;
+                        gnome_vfs_tell(data->xdxf, &act_pos);
+                        gdouble progress = 
+                                ((gdouble)act_pos)/((gdouble)file_size);
+                        if((( (progress - last_prog)/
+                              (data->cb_progress_word_trans_seed) ) > 1.0) ||
+                            (progress >= 1.0)) {
+                                data->
+                                cb_progress_word_trans(progress,
+                                              data->cb_progress_word_trans_data,
+                                              ENGINE_NO_ERROR
+                                                      );
+                                last_prog = progress;
+                        };
+                }
+                if(bytes_readed < DICT_SEARCHING_WORD_TRAN_BUFF_SIZE) {
+                        break;
+                }
+                if(search_data.cont == FALSE) {
+                        break;
+                }
+        }
+        XML_ParserFree(parser);
+        trans = search_data.translation; 
+       g_free(casefold_word); casefold_word = NULL;
+        return trans;        
+}
+//------------------------------------------------------------------------------
+// searching word by concrete engine
+void xdxf_engine_search_word_translation(Engine* engine,
+                                         gchar* word,
+                                         gpointer user_data)
+{
+        g_debug("XDXF/%s->%s() called.\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:word=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 engine,
+                 word);
+        g_assert(engine != NULL);
+        g_assert(word != NULL);
+        // start timer for this function
+        //timer(TIMER_START, (gchar*)__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        // if callback is not set, we do not have to search word
+        if(data->cb_search_word_trans == NULL) {
+                g_warning("XDXF/%s->%s() callback for Word Translation not set."
+                          " Searching aborted.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                // do not send any signal, just exit
+                return;                
+        };
+        
+        //guint word_length = strlen(word);
+        gchar* trans;
+       gchar* casefold_word = g_utf8_casefold(word, -1);
+        // dictionary is optimized
+        if(data->cache != NULL) {
+                trans = word_translation_cache(data, casefold_word);
+        }
+       else
+       // dictionary is not optimized right now
+        {
+                trans = word_translation_xdxf(data, casefold_word);
+        };
+       g_free(casefold_word); casefold_word = NULL;
+
+        g_debug("XDXF/%s->%s() found for word \'%s\' translation:\n\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                word,
+                trans
+               );
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        //timer(TIMER_START,"callback for returning word's translation START");
+        // calling callback for word translation
+       gpointer tmp = user_data;
+       if (NULL == tmp)
+       {
+               tmp = data->cb_search_word_trans_data;
+       }
+       
+        data->cb_search_word_trans(trans,
+                                   word,
+                                   tmp,
+                                   ENGINE_NO_ERROR
+                                  );
+        //timer(TIMER_STOP,"callback for returning word's translation END");
+        /*if(data->auto_free) {
+                g_debug("XDXF/%s->%s() deleting all dynamic data because "
+                        "AUTO_FREE=TRUE\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                g_free(trans);
+               trans = NULL;
+        }*/
+       if (trans != NULL)
+       { 
+               g_free(trans);
+               trans = NULL;
+       }
+       return;
+}
+//------------------------------------------------------------------------------
+gboolean xdxf_engine_remove_word(Engine* engine,
+                             gchar*  word)
+{
+       g_debug("%s -> %s()", __FILE__, __FUNCTION__);
+       g_debug("Not implemented yet. And wont be.");
+       return FALSE;
+}
+
+gboolean xdxf_engine_add_word(Engine* engine,
+                         gchar*  word,
+                         gchar*  translation) 
+{
+       g_debug("%s -> %s()", __FILE__, __FUNCTION__);
+       g_debug("Not implemented yet. And wont be.");
+       return FALSE;
+}
+
+static void search_word_trans_start(void *data,
+                                    const char *el,
+                                    const char **attr
+                                   )
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if( (NULL != loc_data->translation) || !(loc_data->cont) )
+       {
+               //g_debug("STOP SEARCHING! -> _start\n");
+                return;
+        };
+
+        if( ('k' == el[0]) && ('\0' == el[1]) )
+       {
+                loc_data->one_word = 1;
+                loc_data->last_word_length = 0;
+               loc_data->last_word[0] = '\0';
+        }
+       else if( ('a' == el[0]) && ('r' == el[1]) && ('\0' == el[2]) )
+       {
+                loc_data->last_start = 
+                                XML_GetCurrentByteIndex(*(loc_data->parser));
+        }
+}
+//------------------------------------------------------------------------------
+static void search_word_trans_end(void *data, const char *el)
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if( (NULL != loc_data->translation) || (FALSE == loc_data->cont) ) {
+               //g_debug("STOP SEARCHING! -> _end\n");
+                return;
+        };
+
+        if( ('k' == el[0]) && ('\0' == el[1]) ) {
+                loc_data->one_word = 0;
+               gchar* tmp = g_utf8_casefold(loc_data->last_word, -1);
+                gint com = g_utf8_collate(tmp, loc_data->word);
+               g_free(tmp); tmp = NULL;
+                if(com != 0)
+               {
+                        //loc_data->cont = FALSE;
+                       // dictionaries are not alway properly sorted, so for
+                       // searching we should lookd in whole file!
+                        return;
+                }
+               else if((loc_data->last_word_length == loc_data->word_len) &&
+                          (0 == com))
+               {
+                        loc_data->found = TRUE;
+                };
+                // "clearing" buffer for next word
+                loc_data->last_word_length = 0;
+               //loc_data->last_word[0] = '\0';
+        }
+        else if( (TRUE == loc_data->found) && (0 == g_utf8_collate(el,"ar")) )
+       {
+                loc_data->found = FALSE;
+                loc_data->cont = FALSE;
+                gulong last_stop = 
+                       (gulong)XML_GetCurrentByteIndex(*(loc_data->parser));
+                last_stop += strlen("</ar>");
+                FilePart fp = {loc_data->last_start,
+                               (last_stop - (loc_data->last_start))
+                              };
+                loc_data->translation = read_file_part(&fp, loc_data->xdxf);
+               //g_debug("File part returned from file is: %s\n",loc_data->translation);
+        }
+}
+//------------------------------------------------------------------------------
+static void search_word_trans_text(void *data, const XML_Char *txt, int len)
+{
+        XDXFWordsTransData* loc_data = (XDXFWordsTransData*)data;
+        if( (NULL != loc_data->translation ) || (FALSE == loc_data->cont) )  {
+               //g_debug("STOP SEARCHING! -> _text\n");
+               return;
+        };
+
+        if(1 == loc_data->one_word) {
+                memcpy(&(loc_data->last_word[loc_data->last_word_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->last_word_length += (guint)len;
+                loc_data->last_word[loc_data->last_word_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+void xdxf_engine_search_word_translation_extended(Engine* engine, gchar* word)
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+void xdxf_engine_set_progress_seed(Engine* engine, gchar* signal, gdouble seed) {
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+                data->cb_progress_caching_seed = seed;
+                g_debug("XDXF/%s->%s() sets new seed=%0.2f for for signal "
+                        "\"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        seed,
+                        signal
+                       );        
+        } 
+        else {
+                g_warning("XDXF/%s->%s() unsupported signal"
+                          "for progress: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          signal
+                         );
+        };
+}
+//------------------------------------------------------------------------------
+gpointer xdxf_engine_set_callbacks(Engine* engine,
+                             gchar* signal,
+                             gpointer c_handler,
+                             gpointer user_data)
+{
+       g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        g_assert(engine != NULL);
+        g_assert(signal != NULL);
+        g_assert(c_handler != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(g_ascii_strcasecmp(signal,ENGINE_PROGRESS_OPTIMIZING_SIGNAL) == 0)  {
+                gpointer result = data->cb_progress_caching;
+                data->cb_progress_caching = c_handler;
+                data->cb_progress_caching_data = user_data;
+                g_debug("XDXF/%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("XDXF/%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("XDXF/%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;
+        }
+        else if(g_ascii_strcasecmp(signal, ENGINE_WORD_LIST_SIGNAL) == 0) {
+                gpointer result = data->cb_search_word_list;
+                data->cb_search_word_list = c_handler;
+                data->cb_search_word_list_data = user_data;
+                g_debug("XDXF/%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("XDXF/%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("XDXF/%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;
+        }
+        else if(g_ascii_strcasecmp(signal,
+                                   ENGINE_WORD_TRANSLATION_SIGNAL) == 0)  {
+                gpointer result = data->cb_search_word_trans;
+                data->cb_search_word_trans = c_handler;
+                data->cb_search_word_trans_data = user_data;
+                g_debug("XDXF/%s->%s() sets handler for signal \"%s\".\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        signal
+                       );
+                g_debug("XDXF/%s->%s() Function at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)c_handler
+                       );
+                g_debug("XDXF/%s->%s()     Data at adress =  %d.\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        (guint)user_data
+                       );
+                return result;
+        }
+        else {
+                g_warning("XDXF/%s->%s() unsupported signal: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          signal
+                         );
+                return NULL;
+        }
+}
+//------------------------------------------------------------------------------
+void xdxf_engine_close(Engine* engine)
+{
+        g_debug("XDXF/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine);
+        if(engine == NULL) {
+                g_warning("XDXF/%s->%s() Trying delete not existed engine.\n",
+                           __FILE__,
+                           __FUNCTION__
+                          );
+                return;
+        }
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(data->cache != NULL) {
+                gnome_vfs_close(data->cache);
+        };
+        if(data->xdxf != NULL) {
+                gnome_vfs_close(data->xdxf);
+        };
+
+        g_free(data->dict_path);
+        g_free(data);
+        g_free(engine);
+       //gnome_vfs_shutdown();
+        g_debug("XDXF/%s->%s() engine at adress=%p is deleted.\n",
+                __FILE__,
+                __FUNCTION__,
+                engine);
+}
+//------------------------------------------------------------------------------
+gchar* xdxf_engine_error_message(EngineStatus error) 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        return "Error - not yet implemented.";
+}
+//------------------------------------------------------------------------------
+Engine* xdxf_engine_create(gchar* location,
+                      EngineOptimizationFlag auto_cache,
+                      cb_progress progress_handler,
+                      gpointer progress_data,
+                      gdouble seed)
+{
+        g_debug("XDXF/%s->%s() called.\n"
+                "-->PARAM:location=\'%s\'\n"
+                "-->PARAM:auto_cache=%d\n",
+                __FILE__,
+                __FUNCTION__,
+                location,
+                (guint)auto_cache
+               );
+        //timer(TIMER_START,(gchar*)__FUNCTION__);
+        GnomeVFSResult    open_result;
+
+        if(!gnome_vfs_initialized ()) {
+                gnome_vfs_init ();
+        };
+
+        gchar* tmp = g_strdup(location);
+        string_to_path(&tmp);
+
+        Engine* result = (Engine*)g_try_malloc(sizeof(Engine));
+        result->engine_location = xdxf_engine_location;
+        result->engine_is_optimized = xdxf_engine_is_optimized;
+        result->engine_optimize = xdxf_engine_optimize;
+        result->engine_search_word_list = xdxf_engine_search_word_list;
+        result->engine_search_word_translation = 
+                        xdxf_engine_search_word_translation;
+
+        result->engine_close = xdxf_engine_close;
+        result->engine_status = xdxf_engine_error;
+        result->engine_error_message = xdxf_engine_error_message;
+        result->engine_set_callback = xdxf_engine_set_callbacks;
+        result->engine_set_progress_seed = xdxf_engine_set_progress_seed;
+        result->engine_set_auto_free = xdxf_engine_set_auto_free;
+       // API 0.2
+       result->engine_add_word = xdxf_engine_add_word;
+        result->engine_remove_word = xdxf_engine_remove_word;
+
+        XDXFData* data = (XDXFData*)g_try_malloc(sizeof(XDXFData));
+        result->engine_data = (gpointer)data;
+
+        g_debug("XDXF/%s->%s() opening file...\'%s\'.\n",
+                __FILE__,
+                __FUNCTION__,
+                location
+                );
+        gchar* tmp2 = g_strconcat(tmp,"/dict.xdxf",NULL);
+        open_result = 
+                gnome_vfs_open (&(data->xdxf), tmp2, GNOME_VFS_OPEN_READ);
+        g_free(tmp2); tmp2 = NULL;
+        
+        if(open_result != GNOME_VFS_OK)  {
+                g_warning("XDXF/%s->%s() opening dictionary file failed"
+                                " due to reason: %s.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                gnome_vfs_result_to_string(open_result)
+                                );
+                result->engine_data = NULL;
+                g_free(data);
+                g_free(result);
+                result = NULL;
+        }
+        else {
+                g_debug("XDXF/%s->%s() opening dictionary file successed.\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                data->dict_path = g_strdup(tmp);
+                data->cache = NULL;
+                data->cb_progress_caching = progress_handler;
+                data->cb_progress_caching_data = progress_data;        
+                data->cb_progress_caching_seed = seed;        
+                data->cb_progress_word_list = NULL;
+                data->cb_progress_word_list_data = NULL;
+                data->cb_progress_word_list_seed = 0.01;
+                data->cb_progress_word_trans = NULL;
+                data->cb_progress_word_trans_data = NULL;
+                data->cb_progress_word_trans_seed = 0.01;
+
+                data->cb_search_word_list = NULL;
+                data->cb_search_word_list_data = NULL;
+
+                data->cb_search_word_trans = NULL;
+                data->cb_search_word_trans_data = NULL;
+
+                data->auto_free = FALSE;
+                if(auto_cache != ENGINE_NO) {
+                        if(auto_cache == ENGINE_REFRESH) {
+                                xdxf_engine_optimize(result);
+                        }
+                        else if(auto_cache == ENGINE_CREATE) {
+                                gchar* cache_path = g_strconcat(data->dict_path,
+                                                                "/dict.cache",
+                                                                NULL);
+                                open_result = 
+                                        gnome_vfs_open (&(data->cache),
+                                                        cache_path,
+                                                        GNOME_VFS_OPEN_READ
+                                                       );
+                                if(open_result != GNOME_VFS_OK) {
+                                        xdxf_engine_optimize(result);
+                                };
+                                g_free(cache_path); cache_path = NULL;
+                        }
+                };
+        }
+        g_free(tmp); tmp = NULL;
+
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("XDXF/%s->%s() returned Engine at adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+EngineModule engine_global_functions()
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        EngineModule result;        
+                result.engine_check             = xdxf_engine_check;
+                result.engine_description       = xdxf_engine_description;
+                result.engine_format            = xdxf_engine_format;
+                result.engine_version           = xdxf_engine_version;
+                result.engine_create            = xdxf_engine_create;
+        g_debug("XDXF/%s->%s() returned EngineModule at adress=%p.\n",
+                __FILE__,
+                __FUNCTION__,
+                &result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+/*static double timer(gboolean start, gchar* message)
+{
+        static GArray* stack = NULL;
+        static gboolean first_run = TRUE;
+        static struct timeval actual_time;
+        static struct timeval last_time;
+        static struct timeval result;
+        static double seconds = 0.0;
+        if(first_run) {
+                first_run = FALSE;
+                stack = g_array_new(TRUE, TRUE, sizeof(struct timeval));
+        };
+
+        if (start) {
+                g_debug("XDXF->%s() start counting time for function '%s()'.\n",
+                        __FUNCTION__,
+                        message
+                       );
+                g_array_prepend_val(stack, actual_time);
+                gettimeofday(&g_array_index(stack, struct timeval, 0),NULL);
+                return -1.0;
+        }
+        // we just want to end some timer - print some information about 
+        // working time;
+        else {
+                gettimeofday(&actual_time,NULL);
+                last_time = g_array_index(stack, struct timeval, 0);
+                g_array_remove_index(stack, 0);
+
+                if (actual_time.tv_usec < last_time.tv_usec) {
+                        int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                                                  (1000000 + 1);
+                        last_time.tv_usec -= 1000000 * nsec;
+                        last_time.tv_sec += nsec;
+                }
+                if (actual_time.tv_usec - last_time.tv_usec > 1000000) {
+                        int nsec = (last_time.tv_usec - actual_time.tv_usec) / 
+                                                                        1000000;
+                        last_time.tv_usec += 1000000 * nsec;
+                        last_time.tv_sec -= nsec;
+                }
+                result.tv_sec = actual_time.tv_sec - last_time.tv_sec;
+                result.tv_usec = actual_time.tv_usec - last_time.tv_usec;
+                seconds = (((double)(result.tv_usec)) / 1e6) +
+                                                      ((double)(result.tv_sec));
+
+                g_debug("XDXF->%s() function \'%s()\' was working for: %g [s] "
+                        "or %ld [us].\n",
+                        __FUNCTION__,
+                        message,
+                        seconds,
+                        ((long)(result.tv_sec*1e6)+(result.tv_usec))
+                       );
+                // stack is empty so we delete everything
+                if(stack->len == 0)   
+                {
+                        g_array_free(stack, TRUE);
+                        first_run = TRUE;
+                }
+        }
+        return seconds;
+}*/
+//------------------------------------------------------------------------------
+static gchar* read_file_part(FilePart* part, GnomeVFSHandle* file) 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        //timer(TIMER_START,(gchar*)__FUNCTION__);
+        gchar* result = NULL;
+        GnomeVFSResult    f_result;
+       GnomeVFSFileSize  bytes_read;
+
+        f_result = gnome_vfs_seek(file, GNOME_VFS_SEEK_START, part->offset);
+        if(f_result != GNOME_VFS_OK) {
+                g_warning("XDXF/%s->%s() failed. Not possible to seek "
+                          "through file!\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return result;
+        };
+        result = g_try_malloc((part->length + 1) * sizeof(gchar));
+        if(result == NULL) {
+                g_warning("XDXF/%s->%s() failed. Not possible to allocate "
+                          "so big memmory chunk!\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return result;
+        };
+        f_result = gnome_vfs_read (file, result, part->length, &bytes_read);
+        if((f_result != GNOME_VFS_OK) ||
+                (((gulong)bytes_read) != part->length)) {
+                g_debug("XDXF/%s->%s() failed. Not possible to read from "
+                        "file!\n",
+                        __FILE__,
+                        __FUNCTION__
+                       );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                g_free(result); result = NULL;
+                return result;
+        };
+        result[part->length] = '\0';
+
+        g_debug("XDXF/%s->%s() returned string=\n\'%s\'.\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        return result;
+}
+//------------------------------------------------------------------------------
+/** Translate given string to proper full file path. Function works "in-situ". 
+* It means that string is translated and replaced by proper full file path if 
+* this file path exists, or this string is cleared and setted to NULL, if string
+* was representing wrong path. This function is static - to use only 
+* within this module.
+*
+* @param string :: <b><i>gchar**</i></b> - pointer to pointer to string 
+*       representing file path - it will be replaced by a proper filepath.
+*       It should be path to directory or file, ended with "/" or not, absolute 
+*       or not
+* @return <b><i>gchar*</i></b> - pointer to new full file path, it is the same
+*       as string[0] in fact and it is returned only for abillity of nesting of 
+* functions by pointer to string identyfying full file path
+*/
+static gchar* string_to_path(gchar** string) {
+        g_debug("XDXF/%s->%s() called.\n\
+                 -->PARAM:string=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 string[0]
+               );
+        gchar* arg = string[0];
+        gchar* new = NULL;
+        // cleaning from leading and trailing whitespaces
+        g_strstrip(arg);        
+         // add current directory if this is not absolute directory
+        if (!g_path_is_absolute(arg)) {
+                gchar* tmp = g_get_current_dir();
+                new = g_strconcat(tmp,"/",arg,NULL);
+                g_free(arg); arg = new; new = NULL;
+        };
+        // this is not a directory
+        if (!g_file_test(arg, G_FILE_TEST_IS_DIR)) {        
+                // if this is wrong filepath, string was wrong
+                if (!g_file_test(arg, G_FILE_TEST_IS_REGULAR)) {        
+                        g_free(arg);
+                        new = NULL;
+                }
+                //if this is a file, remove filename
+                else
+                {   
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+        }
+        // this is a directory
+        else {   
+                // remove suffix "/" if neded...     
+                if (g_str_has_suffix(arg,"/") ) {        
+                        new = g_path_get_dirname (arg);
+                        g_free(arg);
+                }
+                else {
+                        new = arg;
+                }
+        };
+        // now in new should be proper filepath, if not, string was wrong
+        if (!g_file_test(new, G_FILE_TEST_IS_DIR))  {        
+                // if that directory does not exist, passed string wasn't proper       
+                g_free(new);
+                new = NULL;
+        };
+        // replace string under passed address
+        string[0] = new;
+        g_debug("XDXF/%s->%s() returned string=\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                string[0]
+               );
+        return new;
+}
+//------------------------------------------------------------------------------
+static gboolean is_xdxf_file(gchar* file) {
+        g_debug("XDXF/%s->%s() called.\n\
+                 -->PARAM:file=\'%s\'\n",
+                 __FILE__,
+                 __FUNCTION__,
+                 file
+               );
+        gboolean                result = TRUE;
+        GnomeVFSHandle*         fd = NULL;
+        GnomeVFSResult          file_result;
+        GnomeVFSFileSize        bytes_read;
+
+        if(!gnome_vfs_initialized ()) {
+                gnome_vfs_init ();
+        };
+
+        file_result = gnome_vfs_open (&fd, file, GNOME_VFS_OPEN_READ);
+        if(file_result != GNOME_VFS_OK) {
+                g_warning("XDXF/%s->%s() Could not open the file.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                return FALSE;
+        };
+
+        XML_Parser p = XML_ParserCreate(NULL);        
+        if (!p) {
+                g_warning("XDXF/%s->%s() Could not open initialize "
+                          "XML parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                gnome_vfs_close(fd);
+                return FALSE;
+        };
+        XML_SetElementHandler(p, is_xdxf_file_start, is_xdxf_file_end);
+        XDXFCheckingData user_data = {TRUE, FALSE, 0};
+        XML_SetUserData(p, &user_data);
+        gchar buffer[DICT_CACHEING_BUFF_SIZE];
+
+        guint loop_count = 0;
+        while(TRUE) {
+                file_result = gnome_vfs_read (fd,
+                                              buffer,
+                                              DICT_CACHEING_BUFF_SIZE,
+                                              &bytes_read
+                                             );
+                if  (file_result != GNOME_VFS_OK) {
+                        result = FALSE;
+                        g_warning("XDXF/%s->%s() Could not read enought from"
+                                  " file.\n",
+                                  __FILE__,
+                                  __FUNCTION__
+                                 );
+                        break;
+                };
+                if (! XML_Parse(p,
+                                buffer,
+                                (gulong)bytes_read,
+                                ((gulong)bytes_read) < DICT_CACHEING_BUFF_SIZE
+                               ) ) {
+                        result = FALSE;
+                        g_warning("XDXF/%s->%s() Could not parse file.\n",
+                                  __FILE__,
+                                  __FUNCTION__
+                                 );
+                        break;
+                };
+                if (user_data.further == FALSE) {
+                        result = user_data.good;
+                        g_debug("XDXF/%s->%s() statement: location is "
+                                "compatible with this module, is %s\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                PRINT_STATE(result)
+                               );
+                        break;
+                };
+                if (loop_count > 1) {
+                        result = FALSE;
+                        g_debug("XDXF/%s->%s() Wrong file format.\n",
+                                __FILE__,
+                                __FUNCTION__
+                               );
+                        break;
+                };
+                loop_count++;
+        }
+
+        gnome_vfs_close(fd);
+        XML_ParserFree(p);
+        g_debug("XDXF/%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+static void is_xdxf_file_start(void *data, const char *el, const char **attr) 
+{
+        XDXFCheckingData* user_data = (XDXFCheckingData*)data;
+        if (user_data->deep == 0) {
+                if (g_utf8_collate (el,"xdxf") != 0) {
+                        user_data->good = FALSE;
+                }
+                else {
+                        user_data->good = TRUE;
+                }
+                user_data->further = FALSE;        
+        }
+        user_data->deep++;
+}
+//------------------------------------------------------------------------------
+static void is_xdxf_file_end(void *data, const char *el) 
+{
+        // clear as far as in this callback is nothing to do
+}
+//------------------------------------------------------------------------------
+EngineStatus xdxf_engine_error(Engine* engine) 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        g_debug("XDXF/%s->%s() returned error code: %d\n",
+                __FILE__,
+                __FUNCTION__,
+                (gint)(data->last_error)
+               );        
+        return data->last_error;
+}
+//------------------------------------------------------------------------------
+static void caching_expat_start(void *data, const char *el, const char **attr) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+        if(g_utf8_collate(el,"ar") == 0)  {
+                loc_data->last_start = 
+                                     XML_GetCurrentByteIndex(loc_data->parser);
+        }
+        else if(g_utf8_collate(el,"k") == 0) {
+                loc_data->state = 1;
+        }
+        else {
+                //loc_data->state = 0;
+        }
+}
+//------------------------------------------------------------------------------
+static void caching_expat_end(void *data, const char *el) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+        loc_data->last_stop = XML_GetCurrentByteIndex(loc_data->parser);
+
+        static guint record_length;
+        static guint start;
+        static guint length;
+        static guint buffer_length;
+
+        if((g_utf8_collate("k",el) == 0) &&
+                (loc_data->state == 1))  {
+                loc_data->state = 2;
+        }
+        else if((g_utf8_collate("ar",el) == 0) &&
+                        (loc_data->state == 2)) {
+                buffer_length = loc_data->buffer_length;
+                record_length = sizeof(guint)*3 + loc_data->buffer_length;
+                start = loc_data->last_start;
+                length = loc_data->last_stop + strlen("</ar>") - 
+                         loc_data->last_start;
+
+                gboolean error_writting = FALSE;
+                GnomeVFSFileSize bytes_written;
+                GnomeVFSResult vfs_result;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &record_length,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             loc_data->buffer,
+                                             loc_data->buffer_length,
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &start,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+                vfs_result = gnome_vfs_write(loc_data->cache,
+                                             &length,
+                                             sizeof(guint),
+                                             &bytes_written
+                                            );
+                        if(vfs_result != GNOME_VFS_OK) error_writting = TRUE;
+
+                loc_data->buffer[0] = '\0';
+                loc_data->buffer_length = 0;
+                loc_data->state = 0;
+        };
+}
+//------------------------------------------------------------------------------
+static void caching_expat_text(void *data, const XML_Char *txt, int len) {
+        XDXFCacheData* loc_data = (XDXFCacheData*)data;
+
+        if(loc_data->state == 1) {
+                memcpy(&(loc_data->buffer[loc_data->buffer_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->buffer_length += (long)len;
+                loc_data->buffer[loc_data->buffer_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+static guint64 get_file_size(GnomeVFSHandle* file)
+{
+        guint64 result = 0;
+        guint64 old_pos = 0;
+        gnome_vfs_tell(file, &old_pos);
+
+        if( gnome_vfs_seek(file, GNOME_VFS_SEEK_END, 0) != GNOME_VFS_OK) {
+                return 0;
+        }
+
+        if( gnome_vfs_tell(file, &result) != GNOME_VFS_OK) {
+                result = 0;
+        }
+
+        gnome_vfs_seek(file, GNOME_VFS_SEEK_START, old_pos);
+        return result;
+}
+//------------------------------------------------------------------------------
+void xdxf_engine_optimize(Engine* engine)
+{
+        g_debug("XDXF/%s->%s() called for engine at adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        //timer(TIMER_START,(gchar*)__FUNCTION__);
+
+        GnomeVFSResult vfs_result;
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        gchar* cache_path = g_strconcat(data->dict_path,"/dict.cache",NULL);
+        vfs_result = gnome_vfs_create(&(data->cache),
+                                      cache_path,
+                                      GNOME_VFS_OPEN_WRITE,
+                                      FALSE,
+                                      0666
+                                     );
+        if(vfs_result != GNOME_VFS_OK)  {
+               data->cache = NULL;
+               g_warning("XDXF/%s->%s().Could not create new cache file: %s.\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          cache_path
+                         );
+        }
+        else {
+                XDXFCacheData* c_data = 
+                            (XDXFCacheData*)g_try_malloc(sizeof(XDXFCacheData));
+                c_data->parser = XML_ParserCreate(NULL);
+                c_data->cache = data->cache;
+                c_data->buffer = 
+                    (gchar*)g_try_malloc(sizeof(gchar)*DICT_CACHEING_BUFF_SIZE);
+                c_data->buffer_length = 0;
+                c_data->last_start = 0;
+                c_data->last_stop = 0;
+                c_data->last_length = 0;
+                
+                guint64 file_size = get_file_size(data->xdxf);
+                /*g_debug("XDXF/%s->%s(): caching dictionaries size is %.2f kB "
+                        "[%d bytes = %.2f MB].\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        ((gdouble)file_size)/1024.0,
+                        file_size,
+                        ((gdouble)file_size)/(1024.0*1024.0)
+                       );*/
+
+                XML_SetUserData(c_data->parser, (gpointer)c_data);
+                XML_SetElementHandler(c_data->parser,
+                                      caching_expat_start,
+                                      caching_expat_end
+                                     );
+                XML_SetCharacterDataHandler(c_data->parser, caching_expat_text);
+
+                GnomeVFSFileSize bytes_readed = DICT_CACHEING_BUFF_SIZE;
+                gchar b[DICT_CACHEING_BUFF_SIZE + 1];
+                gdouble last_prog = 0;
+                while(TRUE) {
+                        vfs_result = gnome_vfs_read(data->xdxf,
+                                                    b,
+                                                    DICT_CACHEING_BUFF_SIZE,
+                                                    &bytes_readed
+                                                   );
+                        XML_Parse(c_data->parser,
+                                  b,
+                                  bytes_readed,
+                                  bytes_readed < DICT_CACHEING_BUFF_SIZE
+                                 );
+
+                        if(data->cb_progress_caching != NULL) {
+                                GnomeVFSFileSize act_pos;
+                                gnome_vfs_tell(data->xdxf, &act_pos);
+                                gdouble progress = ((gdouble)act_pos)/
+                                                           ((gdouble)file_size);
+                                if((( (progress - last_prog) /
+                                    (data->cb_progress_caching_seed) ) > 1.0) ||
+                                   (progress >= 1.0)) {
+                                        data->cb_progress_caching(
+                                                 progress,
+                                                 data->cb_progress_caching_data,
+                                                 ENGINE_NO_ERROR
+                                                                 );
+                                        last_prog = progress;
+                                };
+                        }
+                        if(bytes_readed < DICT_CACHEING_BUFF_SIZE) break;
+                }
+
+                g_free(c_data->buffer);
+                g_free(c_data);
+        }
+
+        vfs_result = gnome_vfs_close(data->cache);
+        vfs_result = gnome_vfs_open(&(data->cache),
+                                    cache_path,
+                                    GNOME_VFS_OPEN_READ
+                                   );
+        g_free(cache_path); cache_path = NULL;
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("XDXF/%s->%s()'s work finished.\n",__FILE__,__FUNCTION__);
+}
+//------------------------------------------------------------------------------
+gboolean xdxf_engine_check(gchar* location) 
+{
+        g_debug("XDXF/%s->%s() called.\n-->PARAM:location=\'%s\'\n",
+                __FILE__,
+                __FUNCTION__,
+                location
+               );
+        //timer(TIMER_START,(gchar*)__FUNCTION__);
+        gboolean result = TRUE;        
+        gchar* filepath = g_strdup(location);
+        gchar* tmp = NULL;
+
+        string_to_path(&filepath);
+        if (filepath == NULL) {
+                result = FALSE;
+                g_warning("XDXF/%s->%s() location \'%s\' is not a proper "
+                          "path!\n",
+                          __FILE__,
+                          __FUNCTION__,
+                          location
+                         );
+        }
+        else {
+                tmp = g_strconcat(filepath,"/dict.xdxf",NULL);
+                g_free(filepath);
+                filepath = tmp;
+                tmp = NULL;
+
+                g_debug("XDXF/%s->%s() finnal file to check is: %s\n",
+                        __FILE__,
+                        __FUNCTION__,
+                        filepath
+                       );
+                if (!g_file_test(filepath, G_FILE_TEST_IS_REGULAR)) {
+                        g_warning("XDXF/%s->%s() file \'%s\' does not "
+                                  "exists!\n",
+                                  __FILE__,
+                                  __FUNCTION__,
+                                  filepath
+                                 );
+                        result = FALSE;
+                };
+        };
+        if (result != FALSE) {
+                result = is_xdxf_file(filepath);
+        };
+
+        g_free(filepath);
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        g_debug("XDXF/%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+static guint get_max_length(gchar* a, guint length) 
+{
+        gchar* b = a;
+        guint len = 0;
+        guint n = 0;
+        memcpy(&n,b,sizeof(guint));
+        while((len + n) <= length) {
+                len += n;
+                b = b + n;
+               if(len >= (length-sizeof(guint))) break;
+                memcpy(&n,b,sizeof(guint));
+        }
+        return len;
+}
+//------------------------------------------------------------------------------                                                                                     // finished functions:
+void xdxf_engine_set_auto_free(Engine* engine, gboolean state) 
+{
+        g_debug("XDXF/%s->%s() called.\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:state=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                engine,
+                PRINT_STATE(state)
+               );
+        g_assert(engine != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        data->auto_free = state;
+        g_debug("XDXF/%s->%s() Current auto_free is %s\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(data->auto_free)
+               );
+}
+//------------------------------------------------------------------------------
+gchar* xdxf_engine_version() 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        gchar* result = g_strdup(DIC_ENG_VERSION);
+        g_debug("XDXF/%s->%s() return string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* xdxf_engine_format() 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        gchar* result = g_strdup(DIC_ENG_FORMAT);
+        g_debug("XDXF/%s->%s() return string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* xdxf_engine_description() 
+{
+        g_debug("XDXF/%s->%s() called.\n",__FILE__,__FUNCTION__);
+        gchar* result = g_strdup("This module operates on " 
+                                 DIC_ENG_FORMAT
+                                 " dictionaries. Version "
+                                 DIC_ENG_VERSION
+                                 "."
+                                );
+        g_debug("XDXF/%s->%s() return string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gboolean xdxf_engine_is_optimized(Engine* engine) 
+{
+        g_debug("XDXF/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        g_assert(engine != NULL);                
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        gboolean result = (data->cache != NULL);
+        g_debug("XDXF/%s->%s() returned bool statement=%s.\n",
+                __FILE__,
+                __FUNCTION__,
+                PRINT_STATE(result)
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+gchar* xdxf_engine_location(Engine* engine)
+{
+        g_debug("XDXF/%s->%s() called.\n-->PARAM: engine adress=%p\n",
+                __FILE__,
+                __FUNCTION__,
+                engine
+               );
+        g_assert(engine != NULL);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        gchar* result;
+        if(data->auto_free) {
+                result = data->dict_path;
+        }
+        else {
+                result = g_strdup(data->dict_path);
+        }
+
+        g_debug("XDXF/%s->%s() returned string=%s\n",
+                __FILE__,
+                __FUNCTION__,
+                result
+               );
+        return result;
+}
+//------------------------------------------------------------------------------
+static void search_word_list_start(void *data,
+                                   const char *el,
+                                   const char **attr
+                                  )
+{
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+        if( ('k' == el[0]) && ('\0' == el[1]) ) {
+                loc_data->one_word = 1;
+        };
+}
+//------------------------------------------------------------------------------
+static void search_word_list_end(void *data, const char *el)
+{
+       static gint compare_result = 0;
+        static gboolean matched   = FALSE;
+       static gchar* tmp = NULL;
+
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+       GPatternSpec* regex;
+       regex = g_pattern_spec_new (loc_data->pattern);
+       
+       if( ('k' == el[0]) && ('\0' == el[1]) )
+       {
+                loc_data->one_word = 0;
+        }
+        else
+       {
+                return;
+        }
+
+       tmp = g_utf8_casefold(loc_data->last_word, -1);
+
+/*     if(loc_data->last_word_length > loc_data->pattern_len)
+       {
+               tmp[loc_data->pattern_len] = '\0';
+       };*/
+       compare_result = g_pattern_match_string (regex, tmp);
+       
+        if( ( loc_data->last_word_length >= loc_data->pattern_len ) &&
+            ( compare_result == TRUE ) )
+       {
+                matched = TRUE;
+                gchar* new = g_strdup(loc_data->last_word);
+                g_array_append_val((loc_data->result), new);
+                g_debug("New Word for pattern \"%s\" found: %s\n",
+                        loc_data->pattern,
+                        new
+                       );
+        }
+       else {
+               matched = FALSE;
+       }
+        // "clearing" buffer for next word        
+        loc_data->last_word_length = 0;
+        // if we passed words matching -> ends
+        if( (loc_data->result->len > 0) && (!matched) ) {
+                loc_data->cont = FALSE;
+        };
+       g_free(tmp); tmp = NULL;
+       g_pattern_spec_free (regex);
+}
+//------------------------------------------------------------------------------
+static void search_word_list_text(void *data, const XML_Char *txt, int len) 
+{
+        XDXFWordsListData* loc_data = (XDXFWordsListData*)data;
+
+        if(1 == loc_data->one_word) {
+                memcpy(&(loc_data->last_word[loc_data->last_word_length]),
+                       (gchar*)txt,
+                       len
+                      );
+                loc_data->last_word_length += (guint)len;
+                loc_data->last_word[loc_data->last_word_length] = '\0';
+        };
+}
+//------------------------------------------------------------------------------
+// return translation of word using cache file
+static void word_list_cache(XDXFData* data,
+                            gchar* pattern,
+                            GArray* result,
+                            gpointer cb_data) {
+        gnome_vfs_seek(data->cache, GNOME_VFS_SEEK_START, 0);        
+        //GnomeVFSResult vfs_result;
+        GnomeVFSFileSize bytes_readed;
+        guint record_length = 0;
+        gchar buffer[DICT_SEARCHING_WORD_LIST_BUFF_SIZE];
+        gchar* buf;
+        guint already = 0;
+        guint max_length = 0;
+        guint64 file_size = get_file_size(data->cache);
+       gchar* casefold_pattern = g_utf8_casefold(pattern, -1);
+       //gchar* casefold_word = NULL;
+        guint pattern_len = strlen(pattern);
+       
+       GPatternSpec* regex;
+       regex = g_pattern_spec_new (casefold_pattern);
+       
+       guint i = 0;
+        while(TRUE)
+       {
+                gnome_vfs_read(data->cache,
+                               buffer,
+                               DICT_SEARCHING_WORD_LIST_BUFF_SIZE,
+                               &bytes_readed
+                              );
+
+                max_length = get_max_length(buffer, (guint)bytes_readed);
+                already += max_length;
+                buf = buffer;
+
+                guint how_far = 0;
+                while(how_far < max_length) {
+                       ++i;
+                        memcpy(&record_length, buf, sizeof(guint));
+                       buf[record_length-sizeof(guint)*2] = '\0';
+                       gchar* tmp = g_utf8_casefold(buf + sizeof(guint), -1);
+                       
+                        if(((record_length - 3*sizeof(guint)) >= pattern_len) &&
+                           ( g_pattern_match_string (regex, tmp) == TRUE ) ) {
+                                gchar* new = g_strndup(buf + sizeof(guint),
+                                                       record_length - 
+                                                               3*sizeof(guint));
+                                g_array_append_val(result, new);
+                                g_debug("New Word for pattern \"%s\" found: "
+                                        "%s (pos:%d)\n",
+                                        pattern,
+                                        new,
+                                       i
+                                       );
+                        };
+                        how_far += record_length;
+                        buf = buf + record_length;
+                       g_free(tmp); tmp = NULL;
+                }
+                if( (bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE) || 
+                     (already > (file_size -3)) )
+               {
+                       break;
+               }
+               gnome_vfs_seek(data->cache,
+                              GNOME_VFS_SEEK_CURRENT,
+                              (gint)max_length -
+                                    DICT_SEARCHING_WORD_LIST_BUFF_SIZE
+                             );
+        }
+       
+
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        //timer(TIMER_START,"callback for returning words list START");
+        data->cb_search_word_list(result,
+                                  pattern,
+                                  cb_data,
+                                  ENGINE_NO_ERROR
+                                 );
+       g_free(casefold_pattern); casefold_pattern = NULL;
+        //timer(TIMER_STOP,"callback for returning words list END");
+}
+//------------------------------------------------------------------------------
+// return translation of word but using only xdxf dictionary file
+static void word_list_xdxf(XDXFData* data,
+                           gchar* pattern,
+                           GArray* result,
+                           gpointer cb_data)
+{
+        gnome_vfs_seek(data->xdxf, GNOME_VFS_SEEK_START, 0);
+        GnomeVFSResult vfs_result;
+        GnomeVFSFileSize bytes_readed = DICT_SEARCHING_WORD_LIST_BUFF_SIZE;
+        gchar buffer[DICT_SEARCHING_WORD_LIST_BUFF_SIZE+1];
+        guint64 file_size = get_file_size(data->xdxf);
+       gchar* casefold_pattern = g_utf8_casefold(pattern, -1);
+        guint pattern_len = strlen(casefold_pattern);
+       
+
+        XML_Parser parser = XML_ParserCreate(NULL);
+        if (!parser) {
+                g_warning("XDXF/%s->%s() Could not open initialize XML "
+                          "parser.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return;
+        };
+
+        gchar tmp[DICT_MAX_WORD_LENGTH];
+        XML_SetElementHandler(parser,
+                              search_word_list_start,
+                              search_word_list_end
+                             );
+        XML_SetCharacterDataHandler(parser, search_word_list_text);
+
+        // buffer for single word 
+        // pattern to search 
+        // length of pattern 
+        // actal length of readed word 
+        // array to append words 
+        // continuation of the same word 
+        // continue of searching?
+        XDXFWordsListData search_data = {tmp,
+                                         casefold_pattern,
+                                         pattern_len,
+                                         0,
+                                         result,
+                                         0,
+                                         TRUE
+                                        }; 
+        XML_SetUserData(parser, &search_data);
+
+        gdouble last_prog = 0;
+        while(TRUE) {
+                vfs_result = gnome_vfs_read(data->xdxf,
+                                            buffer,
+                                            DICT_SEARCHING_WORD_LIST_BUFF_SIZE,
+                                            &bytes_readed
+                                           );
+                XML_Parse(parser,
+                          buffer,
+                          bytes_readed,
+                          bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE
+                         );
+
+                if(NULL != data->cb_progress_word_list)
+               {
+                        GnomeVFSFileSize act_pos;
+                        gnome_vfs_tell(data->xdxf, &act_pos);
+                        gdouble progress = ((gdouble)act_pos)/
+                                                           ((gdouble)file_size);
+                        if((((progress - last_prog)/
+                            (data->cb_progress_word_list_seed)) > 1.0) ||
+                            (progress >= 1.0)) {
+                                data->cb_progress_word_list(
+                                               progress,
+                                               data->cb_progress_word_list_data,
+                                               ENGINE_NO_ERROR
+                                                           );
+                                last_prog = progress;
+                        };
+                };
+
+                if(bytes_readed < DICT_SEARCHING_WORD_LIST_BUFF_SIZE)
+               {
+                        break;
+                };
+
+                if(FALSE == search_data.cont)
+               {
+                        g_debug("XDXF/%s->%s() We found every words matching "
+                                "pattern \"%s\". Abort further searching.\n",
+                                __FILE__,
+                                __FUNCTION__,
+                                pattern
+                               );
+                        break;
+                };
+        }
+        XML_ParserFree(parser);
+       g_free(casefold_pattern); casefold_pattern = NULL;
+
+        //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+        //timer(TIMER_START,"callback for returning words list START");
+        data->cb_search_word_list(result,
+                                  pattern,
+                                  cb_data,
+                                  ENGINE_NO_ERROR
+                                 );
+        //timer(TIMER_STOP,"callback for returning words list END");
+}
+//------------------------------------------------------------------------------
+void xdxf_engine_search_word_list(Engine* engine,
+                                  gchar* pattern,
+                                  gpointer user_data)
+{
+        g_debug("XDXF/%s->%s() called. Searching words list\n"
+                "-->PARAM:engine at adress=%p\n"
+                "-->PARAM:pattern=\"%s\"\n",
+                __FILE__,
+                __FUNCTION__,
+                engine,
+                pattern
+               );
+        g_assert(engine != NULL);
+        g_assert(pattern != NULL);
+
+        //timer(TIMER_START,(gchar*)__FUNCTION__);
+        XDXFData* data = (XDXFData*)(engine->engine_data);
+        if(data->cb_search_word_list == NULL)
+       {
+                g_warning("XDXF/%s->%s() callback for Word List not set. "
+                          "Searching aborted.\n",
+                          __FILE__,
+                          __FUNCTION__
+                         );
+                //timer(TIMER_STOP,(gchar*)__FUNCTION__);
+                return;
+        };
+
+       gpointer cb_data =  user_data;
+       if ( NULL == cb_data )
+       {
+               cb_data = data->cb_search_word_list_data;
+       }
+        GArray* result = g_array_new(TRUE,FALSE,sizeof(gchar*));
+        // dictionary is optimized so search in cache file
+        if(data->cache != NULL)
+       {
+                word_list_cache(data, pattern, result, cb_data);
+        }
+        // dictionary is not optimized so search directly fom XDXF file
+        else
+       {
+                word_list_xdxf(data, pattern, result, cb_data);
+        };
+       guint i = 0;
+
+       if (result!=NULL){
+               for (i=0; i<result->len; i++)
+               {
+                       g_free(g_array_index(result, gchar*, i));
+               }
+               g_array_free(result, TRUE);
+               result = NULL;
+       }
+        g_debug("XDXF/%s->%s() finished definately its work.\n",
+                __FILE__,
+                __FUNCTION__
+               );
+       return;
+}
diff --git a/src/plugins/xdxf/src/test.c b/src/plugins/xdxf/src/test.c
new file mode 100644 (file)
index 0000000..e47f51e
--- /dev/null
@@ -0,0 +1,114 @@
+/**********************************************************************************
+ *     copyright (C) 2006, Dariusz Wiechecki
+ *     dariusz.wiechecki@gmail.com
+ *     14 August 2006, Lodz, Poland
+ **********************************************************************************
+ *             This file is part of str-vfs-test.
+ *
+ *     str-vfs-test is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     str-vfs-test is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with str-vfs-test; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *********************************************************************************/
+#include <gmodule.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dictionary_engine.h>
+
+
+getting_additional get_functions; // additinal functions for concrete module (e.g. XDXF)
+
+void print_list(GArray* list, gchar* pattern, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,pattern);
+       int i = 0;
+       while(g_array_index(list, gchar*, i) != NULL) 
+       {
+               printf("  %d. : %s\n",i+1,g_array_index(list, gchar*, i));
+               i++;
+       }
+
+}
+
+void print_translation(gchar* translation, gchar* word, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,word);
+       printf("%s\n\nTRANSLATION ENDS.\n",translation);
+}
+
+void caching_progress(gdouble value, gpointer user_data, EngineStatus error) {
+       printf((gchar*)user_data,value);
+}
+
+int main(int argc, char** argv) 
+{
+       char* nameApp = "WhiteStork: ";
+       printf("%sStarting test program of module: dictionary_engine.\n",nameApp);
+       
+       gchar* current_directory = g_get_current_dir();
+       printf("%sCurrent directory: %s\n",nameApp,current_directory);
+       gchar* library_to_path = g_strconcat(current_directory, "/src/engine_xdxf.so", NULL);
+       printf("%sEngine library should be in location:\n\t%s\n",nameApp,library_to_path);
+       
+       GModule *library = g_module_open(library_to_path, G_MODULE_BIND_LAZY);
+       g_module_symbol (library, "engine_global_functions", (gpointer)&get_functions);
+       
+
+       if(get_functions == NULL) {
+               printf("%sLoading function failed\n",nameApp);
+               return 1;
+       }
+       else printf("%sLoading function OK\n",nameApp);
+       
+
+       EngineModule module = get_functions();
+       Engine* xdxf;
+
+        gboolean is_compatible = dict_eng_module_check(module,"/home/lukasz/MyDocs/idioms_eng_eng");
+       if(is_compatible == TRUE)
+       {
+               printf("Location is compatible with enigne!\n");
+       }
+       else {
+               printf("Location is not compatible with enigne!\n");
+               return 1;
+       }
+
+       //printf("%sCheck OK. Module description: %s\n", nameApp, dict_eng_module_get_description(module));
+
+       //xdxf = dict_eng_module_create_ext(module, "/home/lukasz/MyDocs/repo/WhiteStork/trunk/engine/bin" , ENGINE_CREATE, caching_progress, "Current progress of caching is: %0.2f.\n", 0.03 );
+       //home/stranger/whitestork/engine0.2/
+//     xdxf = dict_eng_module_create(module, "/home/stranger/whitestork/engine0.2/" , ENGINE_NO);
+//     dict_eng_set_callback(xdxf, ENGINE_PROGRESS_CACHING, caching_progress, "Current progress of caching is: %0.2f.\n");
+//     dict_eng_set_progress_seed(xdxf, ENGINE_PROGRESS_CACHING, 0.02);
+
+/*     if(dict_eng_is_optimized(xdxf) == FALSE)
+       {
+               printf("Dictionary has no cache!\nCreating cache file....\n");
+               dict_eng_optimize(xdxf);
+       }
+       else {
+               printf("Dictionary has already cache file!\n");
+       }*/
+        xdxf = dict_eng_module_create(module, "/home/lukasz/MyDocs/idioms_eng_eng" , ENGINE_CREATE);
+       dict_eng_set_callback(xdxf, ENGINE_WORD_LIST_SIGNAL , print_list, "Wort list matches to pattern: %s\n");
+       dict_eng_set_callback(xdxf, ENGINE_WORD_TRANSLATION_SIGNAL , print_translation, "Translation for word\'%s\':\n");
+       
+       dict_eng_search_word_list(xdxf,"z");
+       dict_eng_search_word_translation(xdxf,"zone defense");
+       //dict_eng_search_word_list(xdxf,"A");  
+       
+       dict_eng_destroy(xdxf);
+       g_free(current_directory);
+       g_free(library_to_path);
+       printf("%sClosed.\n",nameApp);
+       return 0;
+}
+