From 4bd4ac21f11fdb5b76ffda985397398102a81e9b Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 15 Dec 2020 11:30:44 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 3a75bdfe83b71ef1dbc2fbf52f2d18b8174e22e5) --- akregator/src/pageviewer.cpp | 2 +- indexlib/bitio.h | 2 +- indexlib/bitio.tcc | 4 +- indexlib/boost-compat/checked_delete.h | 69 + indexlib/boost-compat/checked_delete.hpp | 69 - indexlib/boost-compat/config.h | 70 + indexlib/boost-compat/config.hpp | 70 - indexlib/boost-compat/config/abi/borland_prefix.h | 27 + .../boost-compat/config/abi/borland_prefix.hpp | 27 - indexlib/boost-compat/config/abi/borland_suffix.h | 12 + .../boost-compat/config/abi/borland_suffix.hpp | 12 - indexlib/boost-compat/config/abi/msvc_prefix.h | 8 + indexlib/boost-compat/config/abi/msvc_prefix.hpp | 8 - indexlib/boost-compat/config/abi/msvc_suffix.h | 8 + indexlib/boost-compat/config/abi/msvc_suffix.hpp | 8 - indexlib/boost-compat/config/abi_prefix.h | 20 + indexlib/boost-compat/config/abi_prefix.hpp | 20 - indexlib/boost-compat/config/abi_suffix.h | 23 + indexlib/boost-compat/config/abi_suffix.hpp | 23 - indexlib/boost-compat/config/auto_link.h | 336 +++ indexlib/boost-compat/config/auto_link.hpp | 336 --- indexlib/boost-compat/config/compiler/borland.h | 177 ++ indexlib/boost-compat/config/compiler/borland.hpp | 177 -- indexlib/boost-compat/config/compiler/comeau.h | 61 + indexlib/boost-compat/config/compiler/comeau.hpp | 61 - indexlib/boost-compat/config/compiler/common_edg.h | 53 + .../boost-compat/config/compiler/common_edg.hpp | 53 - indexlib/boost-compat/config/compiler/compaq_cxx.h | 20 + .../boost-compat/config/compiler/compaq_cxx.hpp | 20 - .../boost-compat/config/compiler/digitalmars.h | 49 + .../boost-compat/config/compiler/digitalmars.hpp | 49 - indexlib/boost-compat/config/compiler/gcc.h | 96 + indexlib/boost-compat/config/compiler/gcc.hpp | 96 - indexlib/boost-compat/config/compiler/greenhills.h | 28 + .../boost-compat/config/compiler/greenhills.hpp | 28 - indexlib/boost-compat/config/compiler/hp_acc.h | 69 + indexlib/boost-compat/config/compiler/hp_acc.hpp | 69 - indexlib/boost-compat/config/compiler/intel.h | 151 ++ indexlib/boost-compat/config/compiler/intel.hpp | 151 -- indexlib/boost-compat/config/compiler/kai.h | 35 + indexlib/boost-compat/config/compiler/kai.hpp | 35 - indexlib/boost-compat/config/compiler/metrowerks.h | 97 + .../boost-compat/config/compiler/metrowerks.hpp | 97 - indexlib/boost-compat/config/compiler/mpw.h | 51 + indexlib/boost-compat/config/compiler/mpw.hpp | 51 - .../boost-compat/config/compiler/sgi_mipspro.h | 24 + .../boost-compat/config/compiler/sgi_mipspro.hpp | 24 - indexlib/boost-compat/config/compiler/sunpro_cc.h | 89 + .../boost-compat/config/compiler/sunpro_cc.hpp | 89 - indexlib/boost-compat/config/compiler/vacpp.h | 58 + indexlib/boost-compat/config/compiler/vacpp.hpp | 58 - indexlib/boost-compat/config/compiler/visualc.h | 146 ++ indexlib/boost-compat/config/compiler/visualc.hpp | 146 -- indexlib/boost-compat/config/platform/aix.h | 33 + indexlib/boost-compat/config/platform/aix.hpp | 33 - indexlib/boost-compat/config/platform/amigaos.h | 15 + indexlib/boost-compat/config/platform/amigaos.hpp | 15 - indexlib/boost-compat/config/platform/beos.h | 26 + indexlib/boost-compat/config/platform/beos.hpp | 26 - indexlib/boost-compat/config/platform/bsd.h | 70 + indexlib/boost-compat/config/platform/bsd.hpp | 70 - indexlib/boost-compat/config/platform/cygwin.h | 48 + indexlib/boost-compat/config/platform/cygwin.hpp | 48 - indexlib/boost-compat/config/platform/hpux.h | 62 + indexlib/boost-compat/config/platform/hpux.hpp | 62 - indexlib/boost-compat/config/platform/irix.h | 31 + indexlib/boost-compat/config/platform/irix.hpp | 31 - indexlib/boost-compat/config/platform/linux.h | 98 + indexlib/boost-compat/config/platform/linux.hpp | 98 - indexlib/boost-compat/config/platform/macos.h | 68 + indexlib/boost-compat/config/platform/macos.hpp | 68 - indexlib/boost-compat/config/platform/solaris.h | 21 + indexlib/boost-compat/config/platform/solaris.hpp | 21 - indexlib/boost-compat/config/platform/win32.h | 50 + indexlib/boost-compat/config/platform/win32.hpp | 50 - indexlib/boost-compat/config/posix_features.h | 87 + indexlib/boost-compat/config/posix_features.hpp | 87 - indexlib/boost-compat/config/requires_threads.h | 92 + indexlib/boost-compat/config/requires_threads.hpp | 92 - .../boost-compat/config/select_compiler_config.h | 83 + .../boost-compat/config/select_compiler_config.hpp | 83 - .../boost-compat/config/select_platform_config.h | 86 + .../boost-compat/config/select_platform_config.hpp | 86 - .../boost-compat/config/select_stdlib_config.h | 68 + .../boost-compat/config/select_stdlib_config.hpp | 68 - indexlib/boost-compat/config/stdlib/dinkumware.h | 106 + indexlib/boost-compat/config/stdlib/dinkumware.hpp | 106 - indexlib/boost-compat/config/stdlib/libcomo.h | 46 + indexlib/boost-compat/config/stdlib/libcomo.hpp | 46 - indexlib/boost-compat/config/stdlib/libstdcpp3.h | 51 + indexlib/boost-compat/config/stdlib/libstdcpp3.hpp | 51 - indexlib/boost-compat/config/stdlib/modena.h | 30 + indexlib/boost-compat/config/stdlib/modena.hpp | 30 - indexlib/boost-compat/config/stdlib/msl.h | 54 + indexlib/boost-compat/config/stdlib/msl.hpp | 54 - indexlib/boost-compat/config/stdlib/roguewave.h | 123 + indexlib/boost-compat/config/stdlib/roguewave.hpp | 123 - indexlib/boost-compat/config/stdlib/sgi.h | 111 + indexlib/boost-compat/config/stdlib/sgi.hpp | 111 - indexlib/boost-compat/config/stdlib/stlport.h | 201 ++ indexlib/boost-compat/config/stdlib/stlport.hpp | 201 -- indexlib/boost-compat/config/stdlib/vacpp.h | 18 + indexlib/boost-compat/config/stdlib/vacpp.hpp | 18 - indexlib/boost-compat/config/suffix.h | 543 ++++ indexlib/boost-compat/config/suffix.hpp | 543 ---- indexlib/boost-compat/config/user.h | 124 + indexlib/boost-compat/config/user.hpp | 124 - indexlib/boost-compat/intrusive_ptr.h | 272 ++ indexlib/boost-compat/intrusive_ptr.hpp | 272 -- indexlib/boost-compat/next_prior.h | 51 + indexlib/boost-compat/next_prior.hpp | 51 - indexlib/boost-compat/noncopyable.h | 36 + indexlib/boost-compat/noncopyable.hpp | 36 - indexlib/boost-compat/remove_cv.h | 61 + indexlib/boost-compat/remove_cv.hpp | 61 - indexlib/boost-compat/scoped_ptr.h | 118 + indexlib/boost-compat/scoped_ptr.hpp | 118 - indexlib/boost-compat/shared_ptr.h | 473 ++++ indexlib/boost-compat/shared_ptr.hpp | 473 ---- indexlib/boost-compat/smart_ptr.h | 31 + indexlib/boost-compat/smart_ptr.hpp | 31 - indexlib/boost-compat/static_assert.h | 11 + indexlib/boost-compat/static_assert.hpp | 11 - indexlib/boost-compat/weak_ptr.h | 192 ++ indexlib/boost-compat/weak_ptr.hpp | 192 -- indexlib/configure.in.in | 2 +- indexlib/ifile.cpp | 2 +- indexlib/index_slow.h | 2 +- indexlib/leafdata.cpp | 2 +- indexlib/memvector.h | 4 +- indexlib/pointer.h | 2 +- indexlib/stringarray.h | 2 +- kaddressbook/xxport/pab_pablib.cpp | 2 +- kaddressbook/xxport/pab_pablib.h | 6 +- karm/karm.tdevelop | 2 +- kmail/folderdiaacltab.cpp | 2 +- kmailcvt/CMakeLists.txt | 12 +- kmailcvt/Makefile.am | 42 +- kmailcvt/README | 6 +- kmailcvt/filter_evolution.cpp | 200 ++ kmailcvt/filter_evolution.cxx | 200 -- kmailcvt/filter_evolution.h | 45 + kmailcvt/filter_evolution.hxx | 45 - kmailcvt/filter_evolution_v2.cpp | 231 ++ kmailcvt/filter_evolution_v2.cxx | 231 -- kmailcvt/filter_evolution_v2.h | 43 + kmailcvt/filter_evolution_v2.hxx | 43 - kmailcvt/filter_kmail_archive.cpp | 35 + kmailcvt/filter_kmail_archive.cxx | 35 - kmailcvt/filter_kmail_archive.h | 32 + kmailcvt/filter_kmail_archive.hxx | 32 - kmailcvt/filter_kmail_maildir.cpp | 218 ++ kmailcvt/filter_kmail_maildir.cxx | 218 -- kmailcvt/filter_kmail_maildir.h | 43 + kmailcvt/filter_kmail_maildir.hxx | 43 - kmailcvt/filter_lnotes.cpp | 157 ++ kmailcvt/filter_lnotes.cxx | 157 -- kmailcvt/filter_lnotes.h | 53 + kmailcvt/filter_lnotes.hxx | 53 - kmailcvt/filter_mailapp.cpp | 168 ++ kmailcvt/filter_mailapp.cxx | 168 -- kmailcvt/filter_mailapp.h | 36 + kmailcvt/filter_mailapp.hxx | 36 - kmailcvt/filter_mbox.cpp | 144 + kmailcvt/filter_mbox.cxx | 144 - kmailcvt/filter_mbox.h | 37 + kmailcvt/filter_mbox.hxx | 37 - kmailcvt/filter_oe.cpp | 429 +++ kmailcvt/filter_oe.cxx | 429 --- kmailcvt/filter_oe.h | 84 + kmailcvt/filter_oe.hxx | 84 - kmailcvt/filter_opera.cpp | 158 ++ kmailcvt/filter_opera.cxx | 158 -- kmailcvt/filter_opera.h | 37 + kmailcvt/filter_opera.hxx | 37 - kmailcvt/filter_outlook.cpp | 61 + kmailcvt/filter_outlook.cxx | 61 - kmailcvt/filter_outlook.h | 38 + kmailcvt/filter_outlook.hxx | 38 - kmailcvt/filter_plain.cpp | 87 + kmailcvt/filter_plain.cxx | 87 - kmailcvt/filter_plain.h | 37 + kmailcvt/filter_plain.hxx | 37 - kmailcvt/filter_pmail.cpp | 346 +++ kmailcvt/filter_pmail.cxx | 346 --- kmailcvt/filter_pmail.h | 76 + kmailcvt/filter_pmail.hxx | 76 - kmailcvt/filter_sylpheed.cpp | 228 ++ kmailcvt/filter_sylpheed.cxx | 228 -- kmailcvt/filter_sylpheed.h | 47 + kmailcvt/filter_sylpheed.hxx | 47 - kmailcvt/filter_thebat.cpp | 231 ++ kmailcvt/filter_thebat.cxx | 231 -- kmailcvt/filter_thebat.h | 42 + kmailcvt/filter_thebat.hxx | 42 - kmailcvt/filter_thunderbird.cpp | 234 ++ kmailcvt/filter_thunderbird.cxx | 234 -- kmailcvt/filter_thunderbird.h | 42 + kmailcvt/filter_thunderbird.hxx | 42 - kmailcvt/filters.cpp | 216 ++ kmailcvt/filters.cxx | 216 -- kmailcvt/filters.h | 145 ++ kmailcvt/filters.hxx | 145 -- kmailcvt/kmailcvt.cpp | 2 +- kmailcvt/kselfilterpage.cpp | 32 +- kode/kwsdl/creator.cpp | 2 +- kode/kwsdl/tests/google/Makefile.am | 2 +- kode/kwsdl/tests/google/README | 2 +- kode/kwsdl/tests/google/googlesearch.cc | 94 - kode/kwsdl/tests/google/googlesearch.cpp | 94 + kode/kwsdl/tests/google/googlesearch.h | 61 + kode/kwsdl/tests/google/googlesearch.hh | 61 - kode/kwsdl/tests/google/main.cc | 23 - kode/kwsdl/tests/google/main.cpp | 23 + mimelib/Changes | 4 +- tdefile-plugins/palm-databases/tdefile_palm.cpp | 2 +- tdeioslave/imap4/CMakeLists.txt | 6 +- tdeioslave/imap4/Makefile.am | 8 +- tdeioslave/imap4/imap4.cc | 2746 -------------------- tdeioslave/imap4/imap4.cpp | 2746 ++++++++++++++++++++ tdeioslave/imap4/imapcommand.cc | 408 --- tdeioslave/imap4/imapcommand.cpp | 408 +++ tdeioslave/imap4/imapinfo.cc | 239 -- tdeioslave/imap4/imapinfo.cpp | 239 ++ tdeioslave/imap4/imaplist.cc | 135 - tdeioslave/imap4/imaplist.cpp | 135 + tdeioslave/imap4/imapparser.cc | 2094 --------------- tdeioslave/imap4/imapparser.cpp | 2094 +++++++++++++++ tdeioslave/imap4/mailaddress.cc | 324 --- tdeioslave/imap4/mailaddress.cpp | 324 +++ tdeioslave/imap4/mailheader.cc | 203 -- tdeioslave/imap4/mailheader.cpp | 203 ++ tdeioslave/imap4/mimehdrline.cc | 521 ---- tdeioslave/imap4/mimehdrline.cpp | 521 ++++ tdeioslave/imap4/mimeheader.cc | 745 ------ tdeioslave/imap4/mimeheader.cpp | 745 ++++++ tdeioslave/imap4/mimeio.cc | 188 -- tdeioslave/imap4/mimeio.cpp | 188 ++ tdeioslave/imap4/rfcdecoder.cc | 668 ----- tdeioslave/imap4/rfcdecoder.cpp | 668 +++++ tdeioslave/mbox/CMakeLists.txt | 2 +- tdeioslave/mbox/Makefile.am | 10 +- tdeioslave/mbox/mbox.cc | 168 -- tdeioslave/mbox/mbox.cpp | 168 ++ tdeioslave/mbox/mboxfile.cc | 45 - tdeioslave/mbox/mboxfile.cpp | 45 + tdeioslave/mbox/readmbox.cc | 204 -- tdeioslave/mbox/readmbox.cpp | 204 ++ tdeioslave/mbox/stat.cc | 115 - tdeioslave/mbox/stat.cpp | 115 + tdeioslave/mbox/urlinfo.cc | 133 - tdeioslave/mbox/urlinfo.cpp | 133 + tderesources/groupwise/soap/ksslsocket.cpp | 2 +- tderesources/tvanytime/tvanytime.tdevelop | 2 +- 254 files changed, 18547 insertions(+), 18547 deletions(-) create mode 100644 indexlib/boost-compat/checked_delete.h delete mode 100644 indexlib/boost-compat/checked_delete.hpp create mode 100644 indexlib/boost-compat/config.h delete mode 100644 indexlib/boost-compat/config.hpp create mode 100644 indexlib/boost-compat/config/abi/borland_prefix.h delete mode 100644 indexlib/boost-compat/config/abi/borland_prefix.hpp create mode 100644 indexlib/boost-compat/config/abi/borland_suffix.h delete mode 100644 indexlib/boost-compat/config/abi/borland_suffix.hpp create mode 100644 indexlib/boost-compat/config/abi/msvc_prefix.h delete mode 100644 indexlib/boost-compat/config/abi/msvc_prefix.hpp create mode 100644 indexlib/boost-compat/config/abi/msvc_suffix.h delete mode 100644 indexlib/boost-compat/config/abi/msvc_suffix.hpp create mode 100644 indexlib/boost-compat/config/abi_prefix.h delete mode 100644 indexlib/boost-compat/config/abi_prefix.hpp create mode 100644 indexlib/boost-compat/config/abi_suffix.h delete mode 100644 indexlib/boost-compat/config/abi_suffix.hpp create mode 100644 indexlib/boost-compat/config/auto_link.h delete mode 100644 indexlib/boost-compat/config/auto_link.hpp create mode 100644 indexlib/boost-compat/config/compiler/borland.h delete mode 100644 indexlib/boost-compat/config/compiler/borland.hpp create mode 100644 indexlib/boost-compat/config/compiler/comeau.h delete mode 100644 indexlib/boost-compat/config/compiler/comeau.hpp create mode 100644 indexlib/boost-compat/config/compiler/common_edg.h delete mode 100644 indexlib/boost-compat/config/compiler/common_edg.hpp create mode 100644 indexlib/boost-compat/config/compiler/compaq_cxx.h delete mode 100644 indexlib/boost-compat/config/compiler/compaq_cxx.hpp create mode 100644 indexlib/boost-compat/config/compiler/digitalmars.h delete mode 100644 indexlib/boost-compat/config/compiler/digitalmars.hpp create mode 100644 indexlib/boost-compat/config/compiler/gcc.h delete mode 100644 indexlib/boost-compat/config/compiler/gcc.hpp create mode 100644 indexlib/boost-compat/config/compiler/greenhills.h delete mode 100644 indexlib/boost-compat/config/compiler/greenhills.hpp create mode 100644 indexlib/boost-compat/config/compiler/hp_acc.h delete mode 100644 indexlib/boost-compat/config/compiler/hp_acc.hpp create mode 100644 indexlib/boost-compat/config/compiler/intel.h delete mode 100644 indexlib/boost-compat/config/compiler/intel.hpp create mode 100644 indexlib/boost-compat/config/compiler/kai.h delete mode 100644 indexlib/boost-compat/config/compiler/kai.hpp create mode 100644 indexlib/boost-compat/config/compiler/metrowerks.h delete mode 100644 indexlib/boost-compat/config/compiler/metrowerks.hpp create mode 100644 indexlib/boost-compat/config/compiler/mpw.h delete mode 100644 indexlib/boost-compat/config/compiler/mpw.hpp create mode 100644 indexlib/boost-compat/config/compiler/sgi_mipspro.h delete mode 100644 indexlib/boost-compat/config/compiler/sgi_mipspro.hpp create mode 100644 indexlib/boost-compat/config/compiler/sunpro_cc.h delete mode 100644 indexlib/boost-compat/config/compiler/sunpro_cc.hpp create mode 100644 indexlib/boost-compat/config/compiler/vacpp.h delete mode 100644 indexlib/boost-compat/config/compiler/vacpp.hpp create mode 100644 indexlib/boost-compat/config/compiler/visualc.h delete mode 100644 indexlib/boost-compat/config/compiler/visualc.hpp create mode 100644 indexlib/boost-compat/config/platform/aix.h delete mode 100644 indexlib/boost-compat/config/platform/aix.hpp create mode 100644 indexlib/boost-compat/config/platform/amigaos.h delete mode 100644 indexlib/boost-compat/config/platform/amigaos.hpp create mode 100644 indexlib/boost-compat/config/platform/beos.h delete mode 100644 indexlib/boost-compat/config/platform/beos.hpp create mode 100644 indexlib/boost-compat/config/platform/bsd.h delete mode 100644 indexlib/boost-compat/config/platform/bsd.hpp create mode 100644 indexlib/boost-compat/config/platform/cygwin.h delete mode 100644 indexlib/boost-compat/config/platform/cygwin.hpp create mode 100644 indexlib/boost-compat/config/platform/hpux.h delete mode 100644 indexlib/boost-compat/config/platform/hpux.hpp create mode 100644 indexlib/boost-compat/config/platform/irix.h delete mode 100644 indexlib/boost-compat/config/platform/irix.hpp create mode 100644 indexlib/boost-compat/config/platform/linux.h delete mode 100644 indexlib/boost-compat/config/platform/linux.hpp create mode 100644 indexlib/boost-compat/config/platform/macos.h delete mode 100644 indexlib/boost-compat/config/platform/macos.hpp create mode 100644 indexlib/boost-compat/config/platform/solaris.h delete mode 100644 indexlib/boost-compat/config/platform/solaris.hpp create mode 100644 indexlib/boost-compat/config/platform/win32.h delete mode 100644 indexlib/boost-compat/config/platform/win32.hpp create mode 100644 indexlib/boost-compat/config/posix_features.h delete mode 100644 indexlib/boost-compat/config/posix_features.hpp create mode 100644 indexlib/boost-compat/config/requires_threads.h delete mode 100644 indexlib/boost-compat/config/requires_threads.hpp create mode 100644 indexlib/boost-compat/config/select_compiler_config.h delete mode 100644 indexlib/boost-compat/config/select_compiler_config.hpp create mode 100644 indexlib/boost-compat/config/select_platform_config.h delete mode 100644 indexlib/boost-compat/config/select_platform_config.hpp create mode 100644 indexlib/boost-compat/config/select_stdlib_config.h delete mode 100644 indexlib/boost-compat/config/select_stdlib_config.hpp create mode 100644 indexlib/boost-compat/config/stdlib/dinkumware.h delete mode 100644 indexlib/boost-compat/config/stdlib/dinkumware.hpp create mode 100644 indexlib/boost-compat/config/stdlib/libcomo.h delete mode 100644 indexlib/boost-compat/config/stdlib/libcomo.hpp create mode 100644 indexlib/boost-compat/config/stdlib/libstdcpp3.h delete mode 100644 indexlib/boost-compat/config/stdlib/libstdcpp3.hpp create mode 100644 indexlib/boost-compat/config/stdlib/modena.h delete mode 100644 indexlib/boost-compat/config/stdlib/modena.hpp create mode 100644 indexlib/boost-compat/config/stdlib/msl.h delete mode 100644 indexlib/boost-compat/config/stdlib/msl.hpp create mode 100644 indexlib/boost-compat/config/stdlib/roguewave.h delete mode 100644 indexlib/boost-compat/config/stdlib/roguewave.hpp create mode 100644 indexlib/boost-compat/config/stdlib/sgi.h delete mode 100644 indexlib/boost-compat/config/stdlib/sgi.hpp create mode 100644 indexlib/boost-compat/config/stdlib/stlport.h delete mode 100644 indexlib/boost-compat/config/stdlib/stlport.hpp create mode 100644 indexlib/boost-compat/config/stdlib/vacpp.h delete mode 100644 indexlib/boost-compat/config/stdlib/vacpp.hpp create mode 100644 indexlib/boost-compat/config/suffix.h delete mode 100644 indexlib/boost-compat/config/suffix.hpp create mode 100644 indexlib/boost-compat/config/user.h delete mode 100644 indexlib/boost-compat/config/user.hpp create mode 100644 indexlib/boost-compat/intrusive_ptr.h delete mode 100644 indexlib/boost-compat/intrusive_ptr.hpp create mode 100644 indexlib/boost-compat/next_prior.h delete mode 100644 indexlib/boost-compat/next_prior.hpp create mode 100644 indexlib/boost-compat/noncopyable.h delete mode 100644 indexlib/boost-compat/noncopyable.hpp create mode 100644 indexlib/boost-compat/remove_cv.h delete mode 100644 indexlib/boost-compat/remove_cv.hpp create mode 100644 indexlib/boost-compat/scoped_ptr.h delete mode 100644 indexlib/boost-compat/scoped_ptr.hpp create mode 100644 indexlib/boost-compat/shared_ptr.h delete mode 100644 indexlib/boost-compat/shared_ptr.hpp create mode 100644 indexlib/boost-compat/smart_ptr.h delete mode 100644 indexlib/boost-compat/smart_ptr.hpp create mode 100644 indexlib/boost-compat/static_assert.h delete mode 100644 indexlib/boost-compat/static_assert.hpp create mode 100644 indexlib/boost-compat/weak_ptr.h delete mode 100644 indexlib/boost-compat/weak_ptr.hpp create mode 100644 kmailcvt/filter_evolution.cpp delete mode 100644 kmailcvt/filter_evolution.cxx create mode 100644 kmailcvt/filter_evolution.h delete mode 100644 kmailcvt/filter_evolution.hxx create mode 100644 kmailcvt/filter_evolution_v2.cpp delete mode 100644 kmailcvt/filter_evolution_v2.cxx create mode 100644 kmailcvt/filter_evolution_v2.h delete mode 100644 kmailcvt/filter_evolution_v2.hxx create mode 100644 kmailcvt/filter_kmail_archive.cpp delete mode 100644 kmailcvt/filter_kmail_archive.cxx create mode 100644 kmailcvt/filter_kmail_archive.h delete mode 100644 kmailcvt/filter_kmail_archive.hxx create mode 100644 kmailcvt/filter_kmail_maildir.cpp delete mode 100644 kmailcvt/filter_kmail_maildir.cxx create mode 100644 kmailcvt/filter_kmail_maildir.h delete mode 100644 kmailcvt/filter_kmail_maildir.hxx create mode 100644 kmailcvt/filter_lnotes.cpp delete mode 100644 kmailcvt/filter_lnotes.cxx create mode 100644 kmailcvt/filter_lnotes.h delete mode 100644 kmailcvt/filter_lnotes.hxx create mode 100644 kmailcvt/filter_mailapp.cpp delete mode 100644 kmailcvt/filter_mailapp.cxx create mode 100644 kmailcvt/filter_mailapp.h delete mode 100644 kmailcvt/filter_mailapp.hxx create mode 100644 kmailcvt/filter_mbox.cpp delete mode 100644 kmailcvt/filter_mbox.cxx create mode 100644 kmailcvt/filter_mbox.h delete mode 100644 kmailcvt/filter_mbox.hxx create mode 100644 kmailcvt/filter_oe.cpp delete mode 100644 kmailcvt/filter_oe.cxx create mode 100644 kmailcvt/filter_oe.h delete mode 100644 kmailcvt/filter_oe.hxx create mode 100644 kmailcvt/filter_opera.cpp delete mode 100644 kmailcvt/filter_opera.cxx create mode 100644 kmailcvt/filter_opera.h delete mode 100644 kmailcvt/filter_opera.hxx create mode 100644 kmailcvt/filter_outlook.cpp delete mode 100644 kmailcvt/filter_outlook.cxx create mode 100644 kmailcvt/filter_outlook.h delete mode 100644 kmailcvt/filter_outlook.hxx create mode 100644 kmailcvt/filter_plain.cpp delete mode 100644 kmailcvt/filter_plain.cxx create mode 100644 kmailcvt/filter_plain.h delete mode 100644 kmailcvt/filter_plain.hxx create mode 100644 kmailcvt/filter_pmail.cpp delete mode 100644 kmailcvt/filter_pmail.cxx create mode 100644 kmailcvt/filter_pmail.h delete mode 100644 kmailcvt/filter_pmail.hxx create mode 100644 kmailcvt/filter_sylpheed.cpp delete mode 100644 kmailcvt/filter_sylpheed.cxx create mode 100644 kmailcvt/filter_sylpheed.h delete mode 100644 kmailcvt/filter_sylpheed.hxx create mode 100644 kmailcvt/filter_thebat.cpp delete mode 100644 kmailcvt/filter_thebat.cxx create mode 100644 kmailcvt/filter_thebat.h delete mode 100644 kmailcvt/filter_thebat.hxx create mode 100644 kmailcvt/filter_thunderbird.cpp delete mode 100644 kmailcvt/filter_thunderbird.cxx create mode 100644 kmailcvt/filter_thunderbird.h delete mode 100644 kmailcvt/filter_thunderbird.hxx create mode 100644 kmailcvt/filters.cpp delete mode 100644 kmailcvt/filters.cxx create mode 100644 kmailcvt/filters.h delete mode 100644 kmailcvt/filters.hxx delete mode 100644 kode/kwsdl/tests/google/googlesearch.cc create mode 100644 kode/kwsdl/tests/google/googlesearch.cpp create mode 100644 kode/kwsdl/tests/google/googlesearch.h delete mode 100644 kode/kwsdl/tests/google/googlesearch.hh delete mode 100644 kode/kwsdl/tests/google/main.cc create mode 100644 kode/kwsdl/tests/google/main.cpp delete mode 100644 tdeioslave/imap4/imap4.cc create mode 100644 tdeioslave/imap4/imap4.cpp delete mode 100644 tdeioslave/imap4/imapcommand.cc create mode 100644 tdeioslave/imap4/imapcommand.cpp delete mode 100644 tdeioslave/imap4/imapinfo.cc create mode 100644 tdeioslave/imap4/imapinfo.cpp delete mode 100644 tdeioslave/imap4/imaplist.cc create mode 100644 tdeioslave/imap4/imaplist.cpp delete mode 100644 tdeioslave/imap4/imapparser.cc create mode 100644 tdeioslave/imap4/imapparser.cpp delete mode 100644 tdeioslave/imap4/mailaddress.cc create mode 100644 tdeioslave/imap4/mailaddress.cpp delete mode 100644 tdeioslave/imap4/mailheader.cc create mode 100644 tdeioslave/imap4/mailheader.cpp delete mode 100644 tdeioslave/imap4/mimehdrline.cc create mode 100644 tdeioslave/imap4/mimehdrline.cpp delete mode 100644 tdeioslave/imap4/mimeheader.cc create mode 100644 tdeioslave/imap4/mimeheader.cpp delete mode 100644 tdeioslave/imap4/mimeio.cc create mode 100644 tdeioslave/imap4/mimeio.cpp delete mode 100644 tdeioslave/imap4/rfcdecoder.cc create mode 100644 tdeioslave/imap4/rfcdecoder.cpp delete mode 100644 tdeioslave/mbox/mbox.cc create mode 100644 tdeioslave/mbox/mbox.cpp delete mode 100644 tdeioslave/mbox/mboxfile.cc create mode 100644 tdeioslave/mbox/mboxfile.cpp delete mode 100644 tdeioslave/mbox/readmbox.cc create mode 100644 tdeioslave/mbox/readmbox.cpp delete mode 100644 tdeioslave/mbox/stat.cc create mode 100644 tdeioslave/mbox/stat.cpp delete mode 100644 tdeioslave/mbox/urlinfo.cc create mode 100644 tdeioslave/mbox/urlinfo.cpp diff --git a/akregator/src/pageviewer.cpp b/akregator/src/pageviewer.cpp index 14e702aa..f818043b 100644 --- a/akregator/src/pageviewer.cpp +++ b/akregator/src/pageviewer.cpp @@ -384,7 +384,7 @@ void PageViewer::slotSetCaption(const TQString& cap) void PageViewer::slotPaletteOrFontChanged() { kdDebug() << "PageViewer::slotPaletteOrFontChanged()" << endl; - // taken from KonqView (tdebase/konqueror/konq_view.cc) + // taken from KonqView (tdebase/konqueror/konq_view.cpp) TQObject *obj = KParts::BrowserExtension::childObject(this); if ( !obj ) // not all views have a browser extension ! diff --git a/indexlib/bitio.h b/indexlib/bitio.h index 913f44ea..1ecc0cb2 100644 --- a/indexlib/bitio.h +++ b/indexlib/bitio.h @@ -32,7 +32,7 @@ */ #include -#include "boost-compat/remove_cv.hpp" +#include "boost-compat/remove_cv.h" /** * \namespace byte_io diff --git a/indexlib/bitio.tcc b/indexlib/bitio.tcc index f6dbdfc0..f1c14c77 100644 --- a/indexlib/bitio.tcc +++ b/indexlib/bitio.tcc @@ -1,5 +1,5 @@ -#include "boost-compat/static_assert.hpp" -#include "boost-compat/remove_cv.hpp" +#include "boost-compat/static_assert.h" +#include "boost-compat/remove_cv.h" #ifdef HAVE_BOOST #include #endif diff --git a/indexlib/boost-compat/checked_delete.h b/indexlib/boost-compat/checked_delete.h new file mode 100644 index 00000000..db740fcb --- /dev/null +++ b/indexlib/boost-compat/checked_delete.h @@ -0,0 +1,69 @@ +#ifndef BOOST_CHECKED_DELETE_H_INCLUDED +#define BOOST_CHECKED_DELETE_H_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// boost/checked_delete.hpp +// +// Copyright (c) 2002, 2003 Peter Dimov +// Copyright (c) 2003 Daniel Frey +// Copyright (c) 2003 Howard Hinnant +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/utility/checked_delete.html for documentation. +// + +namespace boost +{ + +// verify that types are complete for increased safety + +template inline void checked_delete(T * x) +{ + // intentionally complex - simplification causes regressions + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + (void) sizeof(type_must_be_complete); + delete x; +} + +template inline void checked_array_delete(T * x) +{ + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + (void) sizeof(type_must_be_complete); + delete [] x; +} + +template struct checked_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) const + { + // boost:: disables ADL + boost::checked_delete(x); + } +}; + +template struct checked_array_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) const + { + boost::checked_array_delete(x); + } +}; + +} // namespace boost + +#endif // #ifndef BOOST_CHECKED_DELETE_H_INCLUDED diff --git a/indexlib/boost-compat/checked_delete.hpp b/indexlib/boost-compat/checked_delete.hpp deleted file mode 100644 index 9bb84e8e..00000000 --- a/indexlib/boost-compat/checked_delete.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED -#define BOOST_CHECKED_DELETE_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/checked_delete.hpp -// -// Copyright (c) 2002, 2003 Peter Dimov -// Copyright (c) 2003 Daniel Frey -// Copyright (c) 2003 Howard Hinnant -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/utility/checked_delete.html for documentation. -// - -namespace boost -{ - -// verify that types are complete for increased safety - -template inline void checked_delete(T * x) -{ - // intentionally complex - simplification causes regressions - typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; - (void) sizeof(type_must_be_complete); - delete x; -} - -template inline void checked_array_delete(T * x) -{ - typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; - (void) sizeof(type_must_be_complete); - delete [] x; -} - -template struct checked_deleter -{ - typedef void result_type; - typedef T * argument_type; - - void operator()(T * x) const - { - // boost:: disables ADL - boost::checked_delete(x); - } -}; - -template struct checked_array_deleter -{ - typedef void result_type; - typedef T * argument_type; - - void operator()(T * x) const - { - boost::checked_array_delete(x); - } -}; - -} // namespace boost - -#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED diff --git a/indexlib/boost-compat/config.h b/indexlib/boost-compat/config.h new file mode 100644 index 00000000..86f12b81 --- /dev/null +++ b/indexlib/boost-compat/config.h @@ -0,0 +1,70 @@ +// Boost config.h configuration header file ------------------------------// + +// (C) Copyright John Maddock 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for most recent version. + +// Boost config.h policy and rationale documentation has been moved to +// http://www.boost.org/libs/config +// +// CAUTION: This file is intended to be completely stable - +// DO NOT MODIFY THIS FILE! +// + +#ifndef BOOST_CONFIG_H +#define BOOST_CONFIG_H + +// if we don't have a user config, then use the default location: +#if !defined(BOOST_USER_CONFIG) && !defined(BOOST_NO_USER_CONFIG) +# define BOOST_USER_CONFIG +#endif +// include it first: +#ifdef BOOST_USER_CONFIG +# include BOOST_USER_CONFIG +#endif + +// if we don't have a compiler config set, try and find one: +#if !defined(BOOST_COMPILER_CONFIG) && !defined(BOOST_NO_COMPILER_CONFIG) && !defined(BOOST_NO_CONFIG) +# include +#endif +// if we have a compiler config, include it now: +#ifdef BOOST_COMPILER_CONFIG +# include BOOST_COMPILER_CONFIG +#endif + +// if we don't have a std library config set, try and find one: +#if !defined(BOOST_STDLIB_CONFIG) && !defined(BOOST_NO_STDLIB_CONFIG) && !defined(BOOST_NO_CONFIG) +# include +#endif +// if we have a std library config, include it now: +#ifdef BOOST_STDLIB_CONFIG +# include BOOST_STDLIB_CONFIG +#endif + +// if we don't have a platform config set, try and find one: +#if !defined(BOOST_PLATFORM_CONFIG) && !defined(BOOST_NO_PLATFORM_CONFIG) && !defined(BOOST_NO_CONFIG) +# include +#endif +// if we have a platform config, include it now: +#ifdef BOOST_PLATFORM_CONFIG +# include BOOST_PLATFORM_CONFIG +#endif + +// get config suffix code: +#include + +#endif // BOOST_CONFIG_H + + + + + + + + + + + diff --git a/indexlib/boost-compat/config.hpp b/indexlib/boost-compat/config.hpp deleted file mode 100644 index 055a2785..00000000 --- a/indexlib/boost-compat/config.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Boost config.hpp configuration header file ------------------------------// - -// (C) Copyright John Maddock 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/config for most recent version. - -// Boost config.hpp policy and rationale documentation has been moved to -// http://www.boost.org/libs/config -// -// CAUTION: This file is intended to be completely stable - -// DO NOT MODIFY THIS FILE! -// - -#ifndef BOOST_CONFIG_HPP -#define BOOST_CONFIG_HPP - -// if we don't have a user config, then use the default location: -#if !defined(BOOST_USER_CONFIG) && !defined(BOOST_NO_USER_CONFIG) -# define BOOST_USER_CONFIG -#endif -// include it first: -#ifdef BOOST_USER_CONFIG -# include BOOST_USER_CONFIG -#endif - -// if we don't have a compiler config set, try and find one: -#if !defined(BOOST_COMPILER_CONFIG) && !defined(BOOST_NO_COMPILER_CONFIG) && !defined(BOOST_NO_CONFIG) -# include -#endif -// if we have a compiler config, include it now: -#ifdef BOOST_COMPILER_CONFIG -# include BOOST_COMPILER_CONFIG -#endif - -// if we don't have a std library config set, try and find one: -#if !defined(BOOST_STDLIB_CONFIG) && !defined(BOOST_NO_STDLIB_CONFIG) && !defined(BOOST_NO_CONFIG) -# include -#endif -// if we have a std library config, include it now: -#ifdef BOOST_STDLIB_CONFIG -# include BOOST_STDLIB_CONFIG -#endif - -// if we don't have a platform config set, try and find one: -#if !defined(BOOST_PLATFORM_CONFIG) && !defined(BOOST_NO_PLATFORM_CONFIG) && !defined(BOOST_NO_CONFIG) -# include -#endif -// if we have a platform config, include it now: -#ifdef BOOST_PLATFORM_CONFIG -# include BOOST_PLATFORM_CONFIG -#endif - -// get config suffix code: -#include - -#endif // BOOST_CONFIG_HPP - - - - - - - - - - - diff --git a/indexlib/boost-compat/config/abi/borland_prefix.h b/indexlib/boost-compat/config/abi/borland_prefix.h new file mode 100644 index 00000000..49f42494 --- /dev/null +++ b/indexlib/boost-compat/config/abi/borland_prefix.h @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// for C++ Builder the following options effect the ABI: +// +// -b (on or off - effect emum sizes) +// -Vx (on or off - empty members) +// -Ve (on or off - empty base classes) +// -aX (alignment - 5 options). +// -pX (Calling convention - 4 options) +// -VmX (member pointer size and layout - 5 options) +// -VC (on or off, changes name mangling) +// -Vl (on or off, changes struct layout). + +// In addition the following warnings are sufficiently annoying (and +// unfixable) to have them turned off by default: +// +// 8027 - functions containing [for|while] loops are not expanded inline +// 8026 - functions taking class by value arguments are not expanded inline + +#pragma nopushoptwarn +# pragma option push -Vx -Ve -a8 -b -pc -Vmv -VC- -Vl- -w-8027 -w-8026 + + + diff --git a/indexlib/boost-compat/config/abi/borland_prefix.hpp b/indexlib/boost-compat/config/abi/borland_prefix.hpp deleted file mode 100644 index 49f42494..00000000 --- a/indexlib/boost-compat/config/abi/borland_prefix.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// for C++ Builder the following options effect the ABI: -// -// -b (on or off - effect emum sizes) -// -Vx (on or off - empty members) -// -Ve (on or off - empty base classes) -// -aX (alignment - 5 options). -// -pX (Calling convention - 4 options) -// -VmX (member pointer size and layout - 5 options) -// -VC (on or off, changes name mangling) -// -Vl (on or off, changes struct layout). - -// In addition the following warnings are sufficiently annoying (and -// unfixable) to have them turned off by default: -// -// 8027 - functions containing [for|while] loops are not expanded inline -// 8026 - functions taking class by value arguments are not expanded inline - -#pragma nopushoptwarn -# pragma option push -Vx -Ve -a8 -b -pc -Vmv -VC- -Vl- -w-8027 -w-8026 - - - diff --git a/indexlib/boost-compat/config/abi/borland_suffix.h b/indexlib/boost-compat/config/abi/borland_suffix.h new file mode 100644 index 00000000..940535f3 --- /dev/null +++ b/indexlib/boost-compat/config/abi/borland_suffix.h @@ -0,0 +1,12 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# pragma option pop +#pragma nopushoptwarn + + + + + diff --git a/indexlib/boost-compat/config/abi/borland_suffix.hpp b/indexlib/boost-compat/config/abi/borland_suffix.hpp deleted file mode 100644 index 940535f3..00000000 --- a/indexlib/boost-compat/config/abi/borland_suffix.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -# pragma option pop -#pragma nopushoptwarn - - - - - diff --git a/indexlib/boost-compat/config/abi/msvc_prefix.h b/indexlib/boost-compat/config/abi/msvc_prefix.h new file mode 100644 index 00000000..3d3905c2 --- /dev/null +++ b/indexlib/boost-compat/config/abi/msvc_prefix.h @@ -0,0 +1,8 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma pack(push,8) + + diff --git a/indexlib/boost-compat/config/abi/msvc_prefix.hpp b/indexlib/boost-compat/config/abi/msvc_prefix.hpp deleted file mode 100644 index 3d3905c2..00000000 --- a/indexlib/boost-compat/config/abi/msvc_prefix.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma pack(push,8) - - diff --git a/indexlib/boost-compat/config/abi/msvc_suffix.h b/indexlib/boost-compat/config/abi/msvc_suffix.h new file mode 100644 index 00000000..a64d783e --- /dev/null +++ b/indexlib/boost-compat/config/abi/msvc_suffix.h @@ -0,0 +1,8 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma pack(pop) + + diff --git a/indexlib/boost-compat/config/abi/msvc_suffix.hpp b/indexlib/boost-compat/config/abi/msvc_suffix.hpp deleted file mode 100644 index a64d783e..00000000 --- a/indexlib/boost-compat/config/abi/msvc_suffix.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma pack(pop) - - diff --git a/indexlib/boost-compat/config/abi_prefix.h b/indexlib/boost-compat/config/abi_prefix.h new file mode 100644 index 00000000..d4ddd29b --- /dev/null +++ b/indexlib/boost-compat/config/abi_prefix.h @@ -0,0 +1,20 @@ +// abi_prefix header -------------------------------------------------------// + +// © Copyright John Maddock 2003 + +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#ifndef BOOST_CONFIG_ABI_PREFIX_H +# define BOOST_CONFIG_ABI_PREFIX_H +#else +# error double inclusion of header boost/config/abi_prefix.hpp is an error +#endif + +#include + +// this must occur after all other includes and before any code appears: +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif diff --git a/indexlib/boost-compat/config/abi_prefix.hpp b/indexlib/boost-compat/config/abi_prefix.hpp deleted file mode 100644 index 1733dc03..00000000 --- a/indexlib/boost-compat/config/abi_prefix.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// abi_prefix header -------------------------------------------------------// - -// © Copyright John Maddock 2003 - -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt). - -#ifndef BOOST_CONFIG_ABI_PREFIX_HPP -# define BOOST_CONFIG_ABI_PREFIX_HPP -#else -# error double inclusion of header boost/config/abi_prefix.hpp is an error -#endif - -#include - -// this must occur after all other includes and before any code appears: -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif diff --git a/indexlib/boost-compat/config/abi_suffix.h b/indexlib/boost-compat/config/abi_suffix.h new file mode 100644 index 00000000..4876507e --- /dev/null +++ b/indexlib/boost-compat/config/abi_suffix.h @@ -0,0 +1,23 @@ +// abi_sufffix header -------------------------------------------------------// + +// © Copyright John Maddock 2003 + +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +// This header should be #included AFTER code that was preceded by a #include +// . + +#ifndef BOOST_CONFIG_ABI_PREFIX_H +# error Header boost/config/abi_prefix.hpp must only be used after boost/config/abi_prefix.hpp +#else +# undef BOOST_CONFIG_ABI_PREFIX_H +#endif + +// the suffix header occurs after all of our code: +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + + diff --git a/indexlib/boost-compat/config/abi_suffix.hpp b/indexlib/boost-compat/config/abi_suffix.hpp deleted file mode 100644 index 6339da63..00000000 --- a/indexlib/boost-compat/config/abi_suffix.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// abi_sufffix header -------------------------------------------------------// - -// © Copyright John Maddock 2003 - -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt). - -// This header should be #included AFTER code that was preceded by a #include -// . - -#ifndef BOOST_CONFIG_ABI_PREFIX_HPP -# error Header boost/config/abi_prefix.hpp must only be used after boost/config/abi_prefix.hpp -#else -# undef BOOST_CONFIG_ABI_PREFIX_HPP -#endif - -// the suffix header occurs after all of our code: -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - - diff --git a/indexlib/boost-compat/config/auto_link.h b/indexlib/boost-compat/config/auto_link.h new file mode 100644 index 00000000..c6d9bc90 --- /dev/null +++ b/indexlib/boost-compat/config/auto_link.h @@ -0,0 +1,336 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE auto_link.h + * VERSION see + * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. + */ + +/************************************************************************* + +USAGE: +~~~~~~ + +Before including this header you must define one or more of define the following macros: + +BOOST_LIB_NAME: Required: A string containing the basename of the library, + for example boost_regex. +BOOST_DYN_LINK: Optional: when set link to dll rather than static library. +BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name + of the library selected (useful for debugging). + +These macros will be undef'ed at the end of the header, further this header +has no include guards - so be sure to include it only once from your library! + +Algorithm: +~~~~~~~~~~ + +Libraries for Borland and Microsoft compilers are automatically +selected here, the name of the lib is selected according to the following +formula: + +BOOST_LIB_PREFIX + + BOOST_LIB_NAME + + "_" + + BOOST_LIB_TOOLSET + + BOOST_LIB_THREAD_OPT + + BOOST_LIB_RT_OPT + "-" + + BOOST_LIB_VERSION + +These are defined as: + +BOOST_LIB_PREFIX: "lib" for static libraries otherwise "". + +BOOST_LIB_NAME: The base name of the lib ( for example boost_regex). + +BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). + +BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing. + +BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used, + contains one or more of the following letters after + a hiphen: + + s static runtime (dynamic if not present). + d debug build (release if not present). + g debug/diagnostic runtime (release if not present). + p STLPort Build. + +BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. + + +***************************************************************************/ + +#ifdef __cplusplus +# ifndef BOOST_CONFIG_H +# include +# endif +#elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__) +// +// C language compatability (no, honestly) +// +# define BOOST_MSVC _MSC_VER +# define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) +# define BOOST_DO_STRINGIZE(X) #X +#endif +// +// Only include what follows for known and supported compilers: +// +#if defined(BOOST_MSVC) \ + || defined(__BORLANDC__) \ + || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ + || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) + +#ifndef BOOST_VERSION_H +# include +#endif + +#ifndef BOOST_LIB_NAME +# error "Macro BOOST_LIB_NAME not set (internal error)" +#endif + +// +// error check: +// +#if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG) +# pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors") +# pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes") +# error "Incompatible build options" +#endif +// +// select toolset: +// +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) + + // vc6: +# define BOOST_LIB_TOOLSET "vc6" + +#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) + + // vc7: +# define BOOST_LIB_TOOLSET "vc7" + +#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310) + + // vc71: +# define BOOST_LIB_TOOLSET "vc71" + +#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) + + // vc80: +# define BOOST_LIB_TOOLSET "vc80" + +#elif defined(__BORLANDC__) + + // CBuilder 6: +# define BOOST_LIB_TOOLSET "bcb" + +#elif defined(__ICL) + + // Intel C++, no version number: +# define BOOST_LIB_TOOLSET "iw" + +#elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) + + // Metrowerks CodeWarrior 8.x +# define BOOST_LIB_TOOLSET "cw8" + +#elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) + + // Metrowerks CodeWarrior 9.x +# define BOOST_LIB_TOOLSET "cw9" + +#endif + +// +// select thread opt: +// +#if defined(_MT) || defined(__MT__) +# define BOOST_LIB_THREAD_OPT "-mt" +#else +# define BOOST_LIB_THREAD_OPT +#endif + +#if defined(_MSC_VER) || defined(__MWERKS__) + +# ifdef _DLL + +# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) + +# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) +# define BOOST_LIB_RT_OPT "-gdp" +# elif defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-gdp" +# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") +# error "Build options aren't compatible with pre-built libraries" +# else +# define BOOST_LIB_RT_OPT "-p" +# endif + +# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) + +# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) +# define BOOST_LIB_RT_OPT "-gdpn" +# elif defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-gdpn" +# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") +# error "Build options aren't compatible with pre-built libraries" +# else +# define BOOST_LIB_RT_OPT "-pn" +# endif + +# else + +# if defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-gd" +# else +# define BOOST_LIB_RT_OPT +# endif + +# endif + +# else + +# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) + +# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) +# define BOOST_LIB_RT_OPT "-sgdp" +# elif defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-sgdp" +# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") +# error "Build options aren't compatible with pre-built libraries" +# else +# define BOOST_LIB_RT_OPT "-sp" +# endif + +# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) + +# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) +# define BOOST_LIB_RT_OPT "-sgdpn" +# elif defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-sgdpn" +# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") +# error "Build options aren't compatible with pre-built libraries" +# else +# define BOOST_LIB_RT_OPT "-spn" +# endif + +# else + +# if defined(_DEBUG) +# define BOOST_LIB_RT_OPT "-sgd" +# else +# define BOOST_LIB_RT_OPT "-s" +# endif + +# endif + +# endif + +#elif defined(__BORLANDC__) + +// +// figure out whether we want the debug builds or not: +// +#pragma defineonoption BOOST_BORLAND_DEBUG -v +// +// sanity check: +// +#if defined(__STL_DEBUG) || defined(_STLP_DEBUG) +#error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form" +#endif + +# ifdef _RTLDLL + +# ifdef BOOST_BORLAND_DEBUG +# define BOOST_LIB_RT_OPT "-d" +# else +# define BOOST_LIB_RT_OPT +# endif + +# else + +# ifdef BOOST_BORLAND_DEBUG +# define BOOST_LIB_RT_OPT "-sd" +# else +# define BOOST_LIB_RT_OPT "-s" +# endif + +# endif + +#endif + +// +// select linkage opt: +// +#if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) +# define BOOST_LIB_PREFIX +#elif defined(BOOST_DYN_LINK) +# error "Mixing a dll boost library with a static runtime is a really bad idea..." +#else +# define BOOST_LIB_PREFIX "lib" +#endif + +// +// now include the lib: +// +#if defined(BOOST_LIB_NAME) \ + && defined(BOOST_LIB_PREFIX) \ + && defined(BOOST_LIB_TOOLSET) \ + && defined(BOOST_LIB_THREAD_OPT) \ + && defined(BOOST_LIB_RT_OPT) \ + && defined(BOOST_LIB_VERSION) + +# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") +#ifdef BOOST_LIB_DIAGNOSTIC +# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") +#endif + +#else +# error "some required macros where not defined (internal logic error)." +#endif + + +#endif // _MSC_VER || __BORLANDC__ + +// +// finally undef any macros we may have set: +// +#ifdef BOOST_LIB_PREFIX +# undef BOOST_LIB_PREFIX +#endif +#if defined(BOOST_LIB_NAME) +# undef BOOST_LIB_NAME +#endif +#if defined(BOOST_LIB_TOOLSET) +# undef BOOST_LIB_TOOLSET +#endif +#if defined(BOOST_LIB_THREAD_OPT) +# undef BOOST_LIB_THREAD_OPT +#endif +#if defined(BOOST_LIB_RT_OPT) +# undef BOOST_LIB_RT_OPT +#endif +#if defined(BOOST_LIB_LINK_OPT) +# undef BOOST_LIB_LINK_OPT +#endif +#if defined(BOOST_LIB_DEBUG_OPT) +# undef BOOST_LIB_DEBUG_OPT +#endif +#if defined(BOOST_DYN_LINK) +# undef BOOST_DYN_LINK +#endif + + + + + + + + + diff --git a/indexlib/boost-compat/config/auto_link.hpp b/indexlib/boost-compat/config/auto_link.hpp deleted file mode 100644 index b4e580ff..00000000 --- a/indexlib/boost-compat/config/auto_link.hpp +++ /dev/null @@ -1,336 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE auto_link.hpp - * VERSION see - * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. - */ - -/************************************************************************* - -USAGE: -~~~~~~ - -Before including this header you must define one or more of define the following macros: - -BOOST_LIB_NAME: Required: A string containing the basename of the library, - for example boost_regex. -BOOST_DYN_LINK: Optional: when set link to dll rather than static library. -BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name - of the library selected (useful for debugging). - -These macros will be undef'ed at the end of the header, further this header -has no include guards - so be sure to include it only once from your library! - -Algorithm: -~~~~~~~~~~ - -Libraries for Borland and Microsoft compilers are automatically -selected here, the name of the lib is selected according to the following -formula: - -BOOST_LIB_PREFIX - + BOOST_LIB_NAME - + "_" - + BOOST_LIB_TOOLSET - + BOOST_LIB_THREAD_OPT - + BOOST_LIB_RT_OPT - "-" - + BOOST_LIB_VERSION - -These are defined as: - -BOOST_LIB_PREFIX: "lib" for static libraries otherwise "". - -BOOST_LIB_NAME: The base name of the lib ( for example boost_regex). - -BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). - -BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing. - -BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used, - contains one or more of the following letters after - a hiphen: - - s static runtime (dynamic if not present). - d debug build (release if not present). - g debug/diagnostic runtime (release if not present). - p STLPort Build. - -BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. - - -***************************************************************************/ - -#ifdef __cplusplus -# ifndef BOOST_CONFIG_HPP -# include -# endif -#elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__) -// -// C language compatability (no, honestly) -// -# define BOOST_MSVC _MSC_VER -# define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) -# define BOOST_DO_STRINGIZE(X) #X -#endif -// -// Only include what follows for known and supported compilers: -// -#if defined(BOOST_MSVC) \ - || defined(__BORLANDC__) \ - || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ - || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) - -#ifndef BOOST_VERSION_HPP -# include -#endif - -#ifndef BOOST_LIB_NAME -# error "Macro BOOST_LIB_NAME not set (internal error)" -#endif - -// -// error check: -// -#if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG) -# pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors") -# pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes") -# error "Incompatible build options" -#endif -// -// select toolset: -// -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) - - // vc6: -# define BOOST_LIB_TOOLSET "vc6" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) - - // vc7: -# define BOOST_LIB_TOOLSET "vc7" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310) - - // vc71: -# define BOOST_LIB_TOOLSET "vc71" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) - - // vc80: -# define BOOST_LIB_TOOLSET "vc80" - -#elif defined(__BORLANDC__) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb" - -#elif defined(__ICL) - - // Intel C++, no version number: -# define BOOST_LIB_TOOLSET "iw" - -#elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) - - // Metrowerks CodeWarrior 8.x -# define BOOST_LIB_TOOLSET "cw8" - -#elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) - - // Metrowerks CodeWarrior 9.x -# define BOOST_LIB_TOOLSET "cw9" - -#endif - -// -// select thread opt: -// -#if defined(_MT) || defined(__MT__) -# define BOOST_LIB_THREAD_OPT "-mt" -#else -# define BOOST_LIB_THREAD_OPT -#endif - -#if defined(_MSC_VER) || defined(__MWERKS__) - -# ifdef _DLL - -# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) - -# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) -# define BOOST_LIB_RT_OPT "-gdp" -# elif defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-gdp" -# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") -# error "Build options aren't compatible with pre-built libraries" -# else -# define BOOST_LIB_RT_OPT "-p" -# endif - -# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) - -# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) -# define BOOST_LIB_RT_OPT "-gdpn" -# elif defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-gdpn" -# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") -# error "Build options aren't compatible with pre-built libraries" -# else -# define BOOST_LIB_RT_OPT "-pn" -# endif - -# else - -# if defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-gd" -# else -# define BOOST_LIB_RT_OPT -# endif - -# endif - -# else - -# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) - -# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) -# define BOOST_LIB_RT_OPT "-sgdp" -# elif defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-sgdp" -# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") -# error "Build options aren't compatible with pre-built libraries" -# else -# define BOOST_LIB_RT_OPT "-sp" -# endif - -# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) - -# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) -# define BOOST_LIB_RT_OPT "-sgdpn" -# elif defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-sgdpn" -# pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") -# error "Build options aren't compatible with pre-built libraries" -# else -# define BOOST_LIB_RT_OPT "-spn" -# endif - -# else - -# if defined(_DEBUG) -# define BOOST_LIB_RT_OPT "-sgd" -# else -# define BOOST_LIB_RT_OPT "-s" -# endif - -# endif - -# endif - -#elif defined(__BORLANDC__) - -// -// figure out whether we want the debug builds or not: -// -#pragma defineonoption BOOST_BORLAND_DEBUG -v -// -// sanity check: -// -#if defined(__STL_DEBUG) || defined(_STLP_DEBUG) -#error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form" -#endif - -# ifdef _RTLDLL - -# ifdef BOOST_BORLAND_DEBUG -# define BOOST_LIB_RT_OPT "-d" -# else -# define BOOST_LIB_RT_OPT -# endif - -# else - -# ifdef BOOST_BORLAND_DEBUG -# define BOOST_LIB_RT_OPT "-sd" -# else -# define BOOST_LIB_RT_OPT "-s" -# endif - -# endif - -#endif - -// -// select linkage opt: -// -#if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) -# define BOOST_LIB_PREFIX -#elif defined(BOOST_DYN_LINK) -# error "Mixing a dll boost library with a static runtime is a really bad idea..." -#else -# define BOOST_LIB_PREFIX "lib" -#endif - -// -// now include the lib: -// -#if defined(BOOST_LIB_NAME) \ - && defined(BOOST_LIB_PREFIX) \ - && defined(BOOST_LIB_TOOLSET) \ - && defined(BOOST_LIB_THREAD_OPT) \ - && defined(BOOST_LIB_RT_OPT) \ - && defined(BOOST_LIB_VERSION) - -# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") -#ifdef BOOST_LIB_DIAGNOSTIC -# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") -#endif - -#else -# error "some required macros where not defined (internal logic error)." -#endif - - -#endif // _MSC_VER || __BORLANDC__ - -// -// finally undef any macros we may have set: -// -#ifdef BOOST_LIB_PREFIX -# undef BOOST_LIB_PREFIX -#endif -#if defined(BOOST_LIB_NAME) -# undef BOOST_LIB_NAME -#endif -#if defined(BOOST_LIB_TOOLSET) -# undef BOOST_LIB_TOOLSET -#endif -#if defined(BOOST_LIB_THREAD_OPT) -# undef BOOST_LIB_THREAD_OPT -#endif -#if defined(BOOST_LIB_RT_OPT) -# undef BOOST_LIB_RT_OPT -#endif -#if defined(BOOST_LIB_LINK_OPT) -# undef BOOST_LIB_LINK_OPT -#endif -#if defined(BOOST_LIB_DEBUG_OPT) -# undef BOOST_LIB_DEBUG_OPT -#endif -#if defined(BOOST_DYN_LINK) -# undef BOOST_DYN_LINK -#endif - - - - - - - - - diff --git a/indexlib/boost-compat/config/compiler/borland.h b/indexlib/boost-compat/config/compiler/borland.h new file mode 100644 index 00000000..531691ef --- /dev/null +++ b/indexlib/boost-compat/config/compiler/borland.h @@ -0,0 +1,177 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Aleksey Gurtovoy 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Borland C++ compiler setup: + +// Version 5.0 and below: +# if __BORLANDC__ <= 0x0550 +// Borland C++Builder 4 and 5: +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# if __BORLANDC__ == 0x0550 +// Borland C++Builder 5, command-line compiler 5.5: +# define BOOST_NO_OPERATORS_IN_NAMESPACE +# endif +# endif + +// Version 5.51 and below: +#if (__BORLANDC__ <= 0x551) +# define BOOST_NO_CV_SPECIALIZATIONS +# define BOOST_NO_CV_VOID_SPECIALIZATIONS +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +# define BOOST_NO_DEDUCED_TYPENAME +// workaround for missing WCHAR_MAX/WCHAR_MIN: +#include +#include +#ifndef WCHAR_MAX +# define WCHAR_MAX 0xffff +#endif +#ifndef WCHAR_MIN +# define WCHAR_MIN 0 +#endif +#endif + +#if (__BORLANDC__ <= 0x564) +# define BOOST_NO_SFINAE +#endif + +// Version 7.0 (Kylix) and below: +#if (__BORLANDC__ <= 0x570) +# define BOOST_NO_INTEGRAL_INT64_T +# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS +# define BOOST_NO_PRIVATE_IN_AGGREGATE +# define BOOST_NO_USING_TEMPLATE +# define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG +# define BOOST_NO_TEMPLATE_TEMPLATES +# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS + // we shouldn't really need this - but too many things choke + // without it, this needs more investigation: +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# ifdef NDEBUG + // fix broken so that Boost.test works: +# include +# undef strcmp +# endif + +// +// new bug in 5.61: +#if (__BORLANDC__ >= 0x561) && (__BORLANDC__ <= 0x570) + // this seems to be needed by the command line compiler, but not the IDE: +# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS +#endif + +# ifdef _WIN32 +# define BOOST_NO_SWPRINTF +# elif defined(linux) || defined(__linux__) || defined(__linux) + // we should really be able to do without this + // but the wcs* functions aren't imported into std:: +# define BOOST_NO_STDC_NAMESPACE + // _CPPUNWIND doesn't get automatically set for some reason: +# pragma defineonoption BOOST_CPPUNWIND -x +# endif +#endif + +// +// Post 0x561 we have long long and stdint.h: +#if __BORLANDC__ >= 0x561 +# ifndef __NO_LONG_LONG +# define BOOST_HAS_LONG_LONG +# endif + // On non-Win32 platforms let the platform config figure this out: +# ifdef _WIN32 +# define BOOST_HAS_STDINT_H +# endif +#endif + +// Borland C++Builder 6 defaults to using STLPort. If _USE_OLD_RW_STL is +// defined, then we have 0x560 or greater with the Rogue Wave implementation +// which presumably has the std::DBL_MAX bug. +#if ((__BORLANDC__ >= 0x550) && (__BORLANDC__ < 0x560)) || defined(_USE_OLD_RW_STL) +// is partly broken, some macros define symbols that are really in +// namespace std, so you end up having to use illegal constructs like +// std::DBL_MAX, as a fix we'll just include float.h and have done with: +#include +#endif +// +// __int64: +// +#if (__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__) +# define BOOST_HAS_MS_INT64 +#endif +// +// check for exception handling support: +// +#if !defined(_CPPUNWIND) && !defined(BOOST_CPPUNWIND) && !defined(__EXCEPTIONS) +# define BOOST_NO_EXCEPTIONS +#endif +// +// all versions have a : +// +#ifndef __STRICT_ANSI__ +# define BOOST_HAS_DIRENT_H +#endif +// +// all versions support __declspec: +// +#ifndef __STRICT_ANSI__ +# define BOOST_HAS_DECLSPEC +#endif +// +// ABI fixing headers: +// +#if __BORLANDC__ < 0x600 // not implemented for version 6 compiler yet +#ifndef BOOST_ABI_PREFIX +# define BOOST_ABI_PREFIX "boost/config/abi/borland_prefix.hpp" +#endif +#ifndef BOOST_ABI_SUFFIX +# define BOOST_ABI_SUFFIX "boost/config/abi/borland_suffix.hpp" +#endif +#endif +// +// Disable Win32 support in ANSI mode: +// +#if __BORLANDC__ < 0x600 +# pragma defineonoption BOOST_DISABLE_WIN32 -A +#elif defined(__STRICT_ANSI__) +# define BOOST_DISABLE_WIN32 +#endif +// +// MSVC compatibility mode does some nasty things: +// +#if defined(_MSC_VER) && (_MSC_VER <= 1200) +# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# define BOOST_NO_VOID_RETURNS +#endif + +#define BOOST_COMPILER "Borland C++ version " BOOST_STRINGIZE(__BORLANDC__) + +// +// versions check: +// we don't support Borland prior to version 5.4: +#if __BORLANDC__ < 0x540 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 1536 (Builder X preview): +#if (__BORLANDC__ > 1536) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# else +# pragma message( "Unknown compiler version - please run the configure tests and report the results") +# endif +#endif + + + + + + + + diff --git a/indexlib/boost-compat/config/compiler/borland.hpp b/indexlib/boost-compat/config/compiler/borland.hpp deleted file mode 100644 index 531691ef..00000000 --- a/indexlib/boost-compat/config/compiler/borland.hpp +++ /dev/null @@ -1,177 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Aleksey Gurtovoy 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Borland C++ compiler setup: - -// Version 5.0 and below: -# if __BORLANDC__ <= 0x0550 -// Borland C++Builder 4 and 5: -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -# if __BORLANDC__ == 0x0550 -// Borland C++Builder 5, command-line compiler 5.5: -# define BOOST_NO_OPERATORS_IN_NAMESPACE -# endif -# endif - -// Version 5.51 and below: -#if (__BORLANDC__ <= 0x551) -# define BOOST_NO_CV_SPECIALIZATIONS -# define BOOST_NO_CV_VOID_SPECIALIZATIONS -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -# define BOOST_NO_DEDUCED_TYPENAME -// workaround for missing WCHAR_MAX/WCHAR_MIN: -#include -#include -#ifndef WCHAR_MAX -# define WCHAR_MAX 0xffff -#endif -#ifndef WCHAR_MIN -# define WCHAR_MIN 0 -#endif -#endif - -#if (__BORLANDC__ <= 0x564) -# define BOOST_NO_SFINAE -#endif - -// Version 7.0 (Kylix) and below: -#if (__BORLANDC__ <= 0x570) -# define BOOST_NO_INTEGRAL_INT64_T -# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS -# define BOOST_NO_PRIVATE_IN_AGGREGATE -# define BOOST_NO_USING_TEMPLATE -# define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG -# define BOOST_NO_TEMPLATE_TEMPLATES -# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS - // we shouldn't really need this - but too many things choke - // without it, this needs more investigation: -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -# ifdef NDEBUG - // fix broken so that Boost.test works: -# include -# undef strcmp -# endif - -// -// new bug in 5.61: -#if (__BORLANDC__ >= 0x561) && (__BORLANDC__ <= 0x570) - // this seems to be needed by the command line compiler, but not the IDE: -# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS -#endif - -# ifdef _WIN32 -# define BOOST_NO_SWPRINTF -# elif defined(linux) || defined(__linux__) || defined(__linux) - // we should really be able to do without this - // but the wcs* functions aren't imported into std:: -# define BOOST_NO_STDC_NAMESPACE - // _CPPUNWIND doesn't get automatically set for some reason: -# pragma defineonoption BOOST_CPPUNWIND -x -# endif -#endif - -// -// Post 0x561 we have long long and stdint.h: -#if __BORLANDC__ >= 0x561 -# ifndef __NO_LONG_LONG -# define BOOST_HAS_LONG_LONG -# endif - // On non-Win32 platforms let the platform config figure this out: -# ifdef _WIN32 -# define BOOST_HAS_STDINT_H -# endif -#endif - -// Borland C++Builder 6 defaults to using STLPort. If _USE_OLD_RW_STL is -// defined, then we have 0x560 or greater with the Rogue Wave implementation -// which presumably has the std::DBL_MAX bug. -#if ((__BORLANDC__ >= 0x550) && (__BORLANDC__ < 0x560)) || defined(_USE_OLD_RW_STL) -// is partly broken, some macros define symbols that are really in -// namespace std, so you end up having to use illegal constructs like -// std::DBL_MAX, as a fix we'll just include float.h and have done with: -#include -#endif -// -// __int64: -// -#if (__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__) -# define BOOST_HAS_MS_INT64 -#endif -// -// check for exception handling support: -// -#if !defined(_CPPUNWIND) && !defined(BOOST_CPPUNWIND) && !defined(__EXCEPTIONS) -# define BOOST_NO_EXCEPTIONS -#endif -// -// all versions have a : -// -#ifndef __STRICT_ANSI__ -# define BOOST_HAS_DIRENT_H -#endif -// -// all versions support __declspec: -// -#ifndef __STRICT_ANSI__ -# define BOOST_HAS_DECLSPEC -#endif -// -// ABI fixing headers: -// -#if __BORLANDC__ < 0x600 // not implemented for version 6 compiler yet -#ifndef BOOST_ABI_PREFIX -# define BOOST_ABI_PREFIX "boost/config/abi/borland_prefix.hpp" -#endif -#ifndef BOOST_ABI_SUFFIX -# define BOOST_ABI_SUFFIX "boost/config/abi/borland_suffix.hpp" -#endif -#endif -// -// Disable Win32 support in ANSI mode: -// -#if __BORLANDC__ < 0x600 -# pragma defineonoption BOOST_DISABLE_WIN32 -A -#elif defined(__STRICT_ANSI__) -# define BOOST_DISABLE_WIN32 -#endif -// -// MSVC compatibility mode does some nasty things: -// -#if defined(_MSC_VER) && (_MSC_VER <= 1200) -# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -# define BOOST_NO_VOID_RETURNS -#endif - -#define BOOST_COMPILER "Borland C++ version " BOOST_STRINGIZE(__BORLANDC__) - -// -// versions check: -// we don't support Borland prior to version 5.4: -#if __BORLANDC__ < 0x540 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 1536 (Builder X preview): -#if (__BORLANDC__ > 1536) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# else -# pragma message( "Unknown compiler version - please run the configure tests and report the results") -# endif -#endif - - - - - - - - diff --git a/indexlib/boost-compat/config/compiler/comeau.h b/indexlib/boost-compat/config/compiler/comeau.h new file mode 100644 index 00000000..16a1b93c --- /dev/null +++ b/indexlib/boost-compat/config/compiler/comeau.h @@ -0,0 +1,61 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Douglas Gregor 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright Aleksey Gurtovoy 2003. +// (C) Copyright Beman Dawes 2003. +// (C) Copyright Jens Maurer 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Comeau C++ compiler setup: + +#include "boost/config/compiler/common_edg.hpp" + +#if (__COMO_VERSION__ <= 4245) + +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL + +# if defined(_MSC_VER) && _MSC_VER <= 1300 +# if _MSC_VER > 100 + // only set this in non-strict mode: +# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# endif +# endif + +// Void returns don't work when emulating VC 6 (Peter Dimov) + +# if defined(_MSC_VER) && (_MSC_VER == 1200) +# define BOOST_NO_VOID_RETURNS +# endif + +#endif // version 4245 + +// +// enable __int64 support in VC emulation mode +// +# if defined(_MSC_VER) && (_MSC_VER >= 1200) +# define BOOST_HAS_MS_INT64 +# endif + +#define BOOST_COMPILER "Comeau compiler version " BOOST_STRINGIZE(__COMO_VERSION__) + +// +// versions check: +// we don't know Comeau prior to version 4245: +#if __COMO_VERSION__ < 4245 +# error "Compiler not configured - please reconfigure" +#endif +// +// last known and checked version is 4245: +#if (__COMO_VERSION__ > 4245) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + + diff --git a/indexlib/boost-compat/config/compiler/comeau.hpp b/indexlib/boost-compat/config/compiler/comeau.hpp deleted file mode 100644 index 16a1b93c..00000000 --- a/indexlib/boost-compat/config/compiler/comeau.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Douglas Gregor 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright Aleksey Gurtovoy 2003. -// (C) Copyright Beman Dawes 2003. -// (C) Copyright Jens Maurer 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Comeau C++ compiler setup: - -#include "boost/config/compiler/common_edg.hpp" - -#if (__COMO_VERSION__ <= 4245) - -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL - -# if defined(_MSC_VER) && _MSC_VER <= 1300 -# if _MSC_VER > 100 - // only set this in non-strict mode: -# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -# endif -# endif - -// Void returns don't work when emulating VC 6 (Peter Dimov) - -# if defined(_MSC_VER) && (_MSC_VER == 1200) -# define BOOST_NO_VOID_RETURNS -# endif - -#endif // version 4245 - -// -// enable __int64 support in VC emulation mode -// -# if defined(_MSC_VER) && (_MSC_VER >= 1200) -# define BOOST_HAS_MS_INT64 -# endif - -#define BOOST_COMPILER "Comeau compiler version " BOOST_STRINGIZE(__COMO_VERSION__) - -// -// versions check: -// we don't know Comeau prior to version 4245: -#if __COMO_VERSION__ < 4245 -# error "Compiler not configured - please reconfigure" -#endif -// -// last known and checked version is 4245: -#if (__COMO_VERSION__ > 4245) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - - diff --git a/indexlib/boost-compat/config/compiler/common_edg.h b/indexlib/boost-compat/config/compiler/common_edg.h new file mode 100644 index 00000000..28b164a8 --- /dev/null +++ b/indexlib/boost-compat/config/compiler/common_edg.h @@ -0,0 +1,53 @@ +// (C) Copyright John Maddock 2001 - 2002. +// (C) Copyright Jens Maurer 2001. +// (C) Copyright David Abrahams 2002. +// (C) Copyright Aleksey Gurtovoy 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// +// Options common to all edg based compilers. +// +// This is included from within the individual compiler mini-configs. + +#ifndef __EDG_VERSION__ +# error This file requires that __EDG_VERSION__ be defined. +#endif + +#if (__EDG_VERSION__ <= 238) +# define BOOST_NO_INTEGRAL_INT64_T +# define BOOST_NO_SFINAE +#endif + +#if (__EDG_VERSION__ <= 240) +# define BOOST_NO_VOID_RETURNS +#endif + +#if (__EDG_VERSION__ <= 241) && !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) +# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +#endif + +#if (__EDG_VERSION__ <= 244) && !defined(BOOST_NO_TEMPLATE_TEMPLATES) +# define BOOST_NO_TEMPLATE_TEMPLATES +#endif + +// See also kai.h which checks a Kai-specific symbol for EH +# if !defined(__KCC) && !defined(__EXCEPTIONS) +# define BOOST_NO_EXCEPTIONS +# endif + +# if !defined(__NO_LONG_LONG) +# define BOOST_HAS_LONG_LONG +# endif + +#ifdef c_plusplus +// EDG has "long long" in non-strict mode +// However, some libraries have insufficient "long long" support +// #define BOOST_HAS_LONG_LONG +#endif + + + diff --git a/indexlib/boost-compat/config/compiler/common_edg.hpp b/indexlib/boost-compat/config/compiler/common_edg.hpp deleted file mode 100644 index c7c0b56e..00000000 --- a/indexlib/boost-compat/config/compiler/common_edg.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// (C) Copyright Jens Maurer 2001. -// (C) Copyright David Abrahams 2002. -// (C) Copyright Aleksey Gurtovoy 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// -// Options common to all edg based compilers. -// -// This is included from within the individual compiler mini-configs. - -#ifndef __EDG_VERSION__ -# error This file requires that __EDG_VERSION__ be defined. -#endif - -#if (__EDG_VERSION__ <= 238) -# define BOOST_NO_INTEGRAL_INT64_T -# define BOOST_NO_SFINAE -#endif - -#if (__EDG_VERSION__ <= 240) -# define BOOST_NO_VOID_RETURNS -#endif - -#if (__EDG_VERSION__ <= 241) && !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -#endif - -#if (__EDG_VERSION__ <= 244) && !defined(BOOST_NO_TEMPLATE_TEMPLATES) -# define BOOST_NO_TEMPLATE_TEMPLATES -#endif - -// See also kai.hpp which checks a Kai-specific symbol for EH -# if !defined(__KCC) && !defined(__EXCEPTIONS) -# define BOOST_NO_EXCEPTIONS -# endif - -# if !defined(__NO_LONG_LONG) -# define BOOST_HAS_LONG_LONG -# endif - -#ifdef c_plusplus -// EDG has "long long" in non-strict mode -// However, some libraries have insufficient "long long" support -// #define BOOST_HAS_LONG_LONG -#endif - - - diff --git a/indexlib/boost-compat/config/compiler/compaq_cxx.h b/indexlib/boost-compat/config/compiler/compaq_cxx.h new file mode 100644 index 00000000..3c0c6b7f --- /dev/null +++ b/indexlib/boost-compat/config/compiler/compaq_cxx.h @@ -0,0 +1,20 @@ +// (C) Copyright John Maddock 2001 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Dec Alpha True64 C++ compiler setup: + +#define BOOST_COMPILER "Dec Alpha True64 " BOOST_STRINGIZE(__DECCXX_VER) + +#include "boost/config/compiler/common_edg.hpp" + +// +// versions check: +// Nothing to do here? + +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL + + diff --git a/indexlib/boost-compat/config/compiler/compaq_cxx.hpp b/indexlib/boost-compat/config/compiler/compaq_cxx.hpp deleted file mode 100644 index 3c0c6b7f..00000000 --- a/indexlib/boost-compat/config/compiler/compaq_cxx.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Dec Alpha True64 C++ compiler setup: - -#define BOOST_COMPILER "Dec Alpha True64 " BOOST_STRINGIZE(__DECCXX_VER) - -#include "boost/config/compiler/common_edg.hpp" - -// -// versions check: -// Nothing to do here? - -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL - - diff --git a/indexlib/boost-compat/config/compiler/digitalmars.h b/indexlib/boost-compat/config/compiler/digitalmars.h new file mode 100644 index 00000000..32fc71fa --- /dev/null +++ b/indexlib/boost-compat/config/compiler/digitalmars.h @@ -0,0 +1,49 @@ +// Copyright (C) Christof Meerwald 2003 +// Copyright (C) Dan Watkins 2003 +// +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Digital Mars C++ compiler setup: +#define BOOST_COMPILER __DMC_VERSION_STRING__ + +#define BOOST_HAS_LONG_LONG +#define BOOST_HAS_PRAGMA_ONCE + +#if (__DMC__ <= 0x833) +#define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +#define BOOST_NO_TEMPLATE_TEMPLATES +#define BOOST_NEEDS_TOKEN_PASTING_OP_FOR_TOKENS_JUXTAPOSING +#define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS +#define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#endif +#if (__DMC__ <= 0x840) || !defined(BOOST_STRICT_CONFIG) +#define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +#define BOOST_NO_OPERATORS_IN_NAMESPACE +#define BOOST_NO_UNREACHABLE_RETURN_DETECTION +#define BOOST_NO_SFINAE +#define BOOST_NO_USING_TEMPLATE +#define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +#endif + +// +// has macros: +#if (__DMC__ >= 0x840) +#define BOOST_HAS_DIRENT_H +#define BOOST_HAS_STDINT_H +#define BOOST_HAS_WINTHREADS +#endif + + +// check for exception handling support: +#ifndef _CPPUNWIND +# define BOOST_NO_EXCEPTIONS +#endif + +#if (__DMC__ < 0x840) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif diff --git a/indexlib/boost-compat/config/compiler/digitalmars.hpp b/indexlib/boost-compat/config/compiler/digitalmars.hpp deleted file mode 100644 index 32fc71fa..00000000 --- a/indexlib/boost-compat/config/compiler/digitalmars.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) Christof Meerwald 2003 -// Copyright (C) Dan Watkins 2003 -// -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// Digital Mars C++ compiler setup: -#define BOOST_COMPILER __DMC_VERSION_STRING__ - -#define BOOST_HAS_LONG_LONG -#define BOOST_HAS_PRAGMA_ONCE - -#if (__DMC__ <= 0x833) -#define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -#define BOOST_NO_TEMPLATE_TEMPLATES -#define BOOST_NEEDS_TOKEN_PASTING_OP_FOR_TOKENS_JUXTAPOSING -#define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS -#define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -#endif -#if (__DMC__ <= 0x840) || !defined(BOOST_STRICT_CONFIG) -#define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -#define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -#define BOOST_NO_OPERATORS_IN_NAMESPACE -#define BOOST_NO_UNREACHABLE_RETURN_DETECTION -#define BOOST_NO_SFINAE -#define BOOST_NO_USING_TEMPLATE -#define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -#endif - -// -// has macros: -#if (__DMC__ >= 0x840) -#define BOOST_HAS_DIRENT_H -#define BOOST_HAS_STDINT_H -#define BOOST_HAS_WINTHREADS -#endif - - -// check for exception handling support: -#ifndef _CPPUNWIND -# define BOOST_NO_EXCEPTIONS -#endif - -#if (__DMC__ < 0x840) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif diff --git a/indexlib/boost-compat/config/compiler/gcc.h b/indexlib/boost-compat/config/compiler/gcc.h new file mode 100644 index 00000000..2c5ad198 --- /dev/null +++ b/indexlib/boost-compat/config/compiler/gcc.h @@ -0,0 +1,96 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001 - 2002. +// (C) Copyright Jens Maurer 2001 - 2002. +// (C) Copyright Beman Dawes 2001 - 2003. +// (C) Copyright Douglas Gregor 2002. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Synge Todo 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// GNU C++ compiler setup: + +# if __GNUC__ == 2 && __GNUC_MINOR__ == 91 + // egcs 1.1 won't parse shared_ptr.h without this: +# define BOOST_NO_AUTO_PTR +# endif +# if __GNUC__ == 2 && __GNUC_MINOR__ < 95 + // + // Prior to gcc 2.95 member templates only partly + // work - define BOOST_MSVC6_MEMBER_TEMPLATES + // instead since inline member templates mostly work. + // +# define BOOST_NO_MEMBER_TEMPLATES +# if __GNUC_MINOR__ >= 9 +# define BOOST_MSVC6_MEMBER_TEMPLATES +# endif +# endif + +# if __GNUC__ == 2 && __GNUC_MINOR__ < 96 +# define BOOST_NO_SFINAE +# endif + +# if __GNUC__ == 2 && __GNUC_MINOR__ <= 97 +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# define BOOST_NO_OPERATORS_IN_NAMESPACE +# endif + +# if __GNUC__ < 3 +# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# endif + +#ifndef __EXCEPTIONS +# define BOOST_NO_EXCEPTIONS +#endif + +// +// Bug specific to gcc 3.1 and 3.2: +// +#if (__GNUC__ == 3) && ((__GNUC_MINOR__ == 1) || (__GNUC_MINOR__ == 2)) +# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#endif + +// +// Threading support: Turn this on unconditionally here (except for +// those platforms where we can know for sure). It will get turned off again +// later if no threading API is detected. +// +#if !defined(__MINGW32__) && !defined(linux) && !defined(__linux) && !defined(__linux__) +# define BOOST_HAS_THREADS +#endif + +// +// gcc has "long long" +// +#define BOOST_HAS_LONG_LONG + +// +// gcc implements the named return value optimization since version 3.1 +// +#if __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 1 ) +#define BOOST_HAS_NRVO +#endif + +#define BOOST_COMPILER "GNU C++ version " __VERSION__ + +// +// versions check: +// we don't know gcc prior to version 2.90: +#if (__GNUC__ == 2) && (__GNUC_MINOR__ < 90) +# error "Compiler not configured - please reconfigure" +#endif +// +// last known and checked version is 3.4: +#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 4)) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# else +# warning "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + diff --git a/indexlib/boost-compat/config/compiler/gcc.hpp b/indexlib/boost-compat/config/compiler/gcc.hpp deleted file mode 100644 index 4dc3f608..00000000 --- a/indexlib/boost-compat/config/compiler/gcc.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001 - 2002. -// (C) Copyright Jens Maurer 2001 - 2002. -// (C) Copyright Beman Dawes 2001 - 2003. -// (C) Copyright Douglas Gregor 2002. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Synge Todo 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// GNU C++ compiler setup: - -# if __GNUC__ == 2 && __GNUC_MINOR__ == 91 - // egcs 1.1 won't parse shared_ptr.hpp without this: -# define BOOST_NO_AUTO_PTR -# endif -# if __GNUC__ == 2 && __GNUC_MINOR__ < 95 - // - // Prior to gcc 2.95 member templates only partly - // work - define BOOST_MSVC6_MEMBER_TEMPLATES - // instead since inline member templates mostly work. - // -# define BOOST_NO_MEMBER_TEMPLATES -# if __GNUC_MINOR__ >= 9 -# define BOOST_MSVC6_MEMBER_TEMPLATES -# endif -# endif - -# if __GNUC__ == 2 && __GNUC_MINOR__ < 96 -# define BOOST_NO_SFINAE -# endif - -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 97 -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -# define BOOST_NO_OPERATORS_IN_NAMESPACE -# endif - -# if __GNUC__ < 3 -# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -# endif - -#ifndef __EXCEPTIONS -# define BOOST_NO_EXCEPTIONS -#endif - -// -// Bug specific to gcc 3.1 and 3.2: -// -#if (__GNUC__ == 3) && ((__GNUC_MINOR__ == 1) || (__GNUC_MINOR__ == 2)) -# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -#endif - -// -// Threading support: Turn this on unconditionally here (except for -// those platforms where we can know for sure). It will get turned off again -// later if no threading API is detected. -// -#if !defined(__MINGW32__) && !defined(linux) && !defined(__linux) && !defined(__linux__) -# define BOOST_HAS_THREADS -#endif - -// -// gcc has "long long" -// -#define BOOST_HAS_LONG_LONG - -// -// gcc implements the named return value optimization since version 3.1 -// -#if __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 1 ) -#define BOOST_HAS_NRVO -#endif - -#define BOOST_COMPILER "GNU C++ version " __VERSION__ - -// -// versions check: -// we don't know gcc prior to version 2.90: -#if (__GNUC__ == 2) && (__GNUC_MINOR__ < 90) -# error "Compiler not configured - please reconfigure" -#endif -// -// last known and checked version is 3.4: -#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 4)) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# else -# warning "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - diff --git a/indexlib/boost-compat/config/compiler/greenhills.h b/indexlib/boost-compat/config/compiler/greenhills.h new file mode 100644 index 00000000..038b6b2b --- /dev/null +++ b/indexlib/boost-compat/config/compiler/greenhills.h @@ -0,0 +1,28 @@ +// (C) Copyright John Maddock 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Greenhills C++ compiler setup: + +#define BOOST_COMPILER "Greenhills C++ version " BOOST_STRINGIZE(__ghs) + +#include "boost/config/compiler/common_edg.hpp" + +// +// versions check: +// we don't support Greenhills prior to version 0: +#if __ghs < 0 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 0: +#if (__ghs > 0) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + diff --git a/indexlib/boost-compat/config/compiler/greenhills.hpp b/indexlib/boost-compat/config/compiler/greenhills.hpp deleted file mode 100644 index 038b6b2b..00000000 --- a/indexlib/boost-compat/config/compiler/greenhills.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// (C) Copyright John Maddock 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Greenhills C++ compiler setup: - -#define BOOST_COMPILER "Greenhills C++ version " BOOST_STRINGIZE(__ghs) - -#include "boost/config/compiler/common_edg.hpp" - -// -// versions check: -// we don't support Greenhills prior to version 0: -#if __ghs < 0 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 0: -#if (__ghs > 0) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - diff --git a/indexlib/boost-compat/config/compiler/hp_acc.h b/indexlib/boost-compat/config/compiler/hp_acc.h new file mode 100644 index 00000000..b5c587ab --- /dev/null +++ b/indexlib/boost-compat/config/compiler/hp_acc.h @@ -0,0 +1,69 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001 - 2003. +// (C) Copyright Aleksey Gurtovoy 2002. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Toon Knapen 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// HP aCC C++ compiler setup: + +#if (__HP_aCC <= 33100) +# define BOOST_NO_INTEGRAL_INT64_T +# define BOOST_NO_OPERATORS_IN_NAMESPACE +# if !defined(_NAMESPACE_STD) +# define BOOST_NO_STD_LOCALE +# define BOOST_NO_STRINGSTREAM +# endif +#endif + +#if (__HP_aCC <= 33300) +// member templates are sufficiently broken that we disable them for now +# define BOOST_NO_MEMBER_TEMPLATES +# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS +# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE +#endif + +#if (__HP_aCC <= 33900) || !defined(BOOST_STRICT_CONFIG) +# define BOOST_NO_UNREACHABLE_RETURN_DETECTION +# define BOOST_NO_TEMPLATE_TEMPLATES +# define BOOST_NO_SWPRINTF +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +// std lib config should set this one already: +//# define BOOST_NO_STD_ALLOCATOR +#endif + +// optional features rather than defects: +#if (__HP_aCC >= 33900) +# define BOOST_HAS_LONG_LONG +# define BOOST_HAS_PARTIAL_STD_ALLOCATOR +#endif + +#if (__HP_aCC >= 50000 ) && (__HP_aCC <= 53800 ) || (__HP_aCC < 31300 ) +# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD +#endif + +#define BOOST_NO_MEMBER_TEMPLATE_FRIENDS + +#define BOOST_COMPILER "HP aCC version " BOOST_STRINGIZE(__HP_aCC) + +// +// versions check: +// we don't support HP aCC prior to version 0: +#if __HP_aCC < 33000 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 0: +#if (__HP_aCC > 53800) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + + diff --git a/indexlib/boost-compat/config/compiler/hp_acc.hpp b/indexlib/boost-compat/config/compiler/hp_acc.hpp deleted file mode 100644 index b5c587ab..00000000 --- a/indexlib/boost-compat/config/compiler/hp_acc.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001 - 2003. -// (C) Copyright Aleksey Gurtovoy 2002. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Toon Knapen 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// HP aCC C++ compiler setup: - -#if (__HP_aCC <= 33100) -# define BOOST_NO_INTEGRAL_INT64_T -# define BOOST_NO_OPERATORS_IN_NAMESPACE -# if !defined(_NAMESPACE_STD) -# define BOOST_NO_STD_LOCALE -# define BOOST_NO_STRINGSTREAM -# endif -#endif - -#if (__HP_aCC <= 33300) -// member templates are sufficiently broken that we disable them for now -# define BOOST_NO_MEMBER_TEMPLATES -# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS -# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE -#endif - -#if (__HP_aCC <= 33900) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_NO_UNREACHABLE_RETURN_DETECTION -# define BOOST_NO_TEMPLATE_TEMPLATES -# define BOOST_NO_SWPRINTF -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -// std lib config should set this one already: -//# define BOOST_NO_STD_ALLOCATOR -#endif - -// optional features rather than defects: -#if (__HP_aCC >= 33900) -# define BOOST_HAS_LONG_LONG -# define BOOST_HAS_PARTIAL_STD_ALLOCATOR -#endif - -#if (__HP_aCC >= 50000 ) && (__HP_aCC <= 53800 ) || (__HP_aCC < 31300 ) -# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD -#endif - -#define BOOST_NO_MEMBER_TEMPLATE_FRIENDS - -#define BOOST_COMPILER "HP aCC version " BOOST_STRINGIZE(__HP_aCC) - -// -// versions check: -// we don't support HP aCC prior to version 0: -#if __HP_aCC < 33000 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 0: -#if (__HP_aCC > 53800) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - - diff --git a/indexlib/boost-compat/config/compiler/intel.h b/indexlib/boost-compat/config/compiler/intel.h new file mode 100644 index 00000000..060338bc --- /dev/null +++ b/indexlib/boost-compat/config/compiler/intel.h @@ -0,0 +1,151 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright Jens Maurer 2001. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Aleksey Gurtovoy 2002 - 2003. +// (C) Copyright Guillaume Melquiond 2002 - 2003. +// (C) Copyright Beman Dawes 2003. +// (C) Copyright Martin Wille 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Intel compiler setup: + +#include "boost/config/compiler/common_edg.hpp" + +#if defined(__INTEL_COMPILER) +# define BOOST_INTEL_CXX_VERSION __INTEL_COMPILER +#elif defined(__ICL) +# define BOOST_INTEL_CXX_VERSION __ICL +#elif defined(__ICC) +# define BOOST_INTEL_CXX_VERSION __ICC +#elif defined(__ECC) +# define BOOST_INTEL_CXX_VERSION __ECC +#endif + +#define BOOST_COMPILER "Intel C++ version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) +#define BOOST_INTEL BOOST_INTEL_CXX_VERSION + +#if defined(_WIN32) || defined(_WIN64) +# define BOOST_INTEL_WIN BOOST_INTEL +#else +# define BOOST_INTEL_LINUX BOOST_INTEL +#endif + +#if (BOOST_INTEL_CXX_VERSION <= 500) && defined(_MSC_VER) +# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +# define BOOST_NO_TEMPLATE_TEMPLATES +#endif + +#if (BOOST_INTEL_CXX_VERSION <= 600) + +# if defined(_MSC_VER) && (_MSC_VER <= 1300) // added check for <= VC 7 (Peter Dimov) + +// Boost libraries assume strong standard conformance unless otherwise +// indicated by a config macro. As configured by Intel, the EDG front-end +// requires certain compiler options be set to achieve that strong conformance. +// Particularly /Qoption,c,--arg_dep_lookup (reported by Kirk Klobe & Thomas Witt) +// and /Zc:wchar_t,forScope. See boost-root/tools/build/intel-win32-tools.jam for +// details as they apply to particular versions of the compiler. When the +// compiler does not predefine a macro indicating if an option has been set, +// this config file simply assumes the option has been set. +// Thus BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP will not be defined, even if +// the compiler option is not enabled. + +# define BOOST_NO_SWPRINTF +# endif + +// Void returns, 64 bit integrals don't work when emulating VC 6 (Peter Dimov) + +# if defined(_MSC_VER) && (_MSC_VER <= 1200) +# define BOOST_NO_VOID_RETURNS +# define BOOST_NO_INTEGRAL_INT64_T +# endif + +#endif + +#if (BOOST_INTEL_CXX_VERSION <= 710) && defined(_WIN32) +# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS +#endif + +// See http://aspn.activestate.com/ASPN/Mail/Message/boost/1614864 +#if BOOST_INTEL_CXX_VERSION < 600 +# define BOOST_NO_INTRINSIC_WCHAR_T +#else +// We should test the macro _WCHAR_T_DEFINED to check if the compiler +// supports wchar_t natively. *BUT* there is a problem here: the standard +// headers define this macro if they typedef wchar_t. Anyway, we're lucky +// because they define it without a value, while Intel C++ defines it +// to 1. So we can check its value to see if the macro was defined natively +// or not. +// Under UNIX, the situation is exactly the same, but the macro _WCHAR_T +// is used instead. +# if ((_WCHAR_T_DEFINED + 0) == 0) && ((_WCHAR_T + 0) == 0) +# define BOOST_NO_INTRINSIC_WCHAR_T +# endif +#endif + +// +// Verify that we have actually got BOOST_NO_INTRINSIC_WCHAR_T +// set correctly, if we don't do this now, we will get errors later +// in type_traits code among other things, getting this correct +// for the Intel compiler is actually remarkably fragile and tricky: +// +#if defined(BOOST_NO_INTRINSIC_WCHAR_T) +#include +template< typename T > struct assert_no_intrinsic_wchar_t; +template<> struct assert_no_intrinsic_wchar_t { typedef void type; }; +// if you see an error here then you need to unset BOOST_NO_INTRINSIC_WCHAR_T +// where it is defined above: +typedef assert_no_intrinsic_wchar_t::type assert_no_intrinsic_wchar_t_; +#else +template< typename T > struct assert_intrinsic_wchar_t; +template<> struct assert_intrinsic_wchar_t {}; +// if you see an error here then define BOOST_NO_INTRINSIC_WCHAR_T on the command line: +template<> struct assert_intrinsic_wchar_t {}; +#endif + + +#if (BOOST_INTEL_CXX_VERSION <= 800) || !defined(BOOST_STRICT_CONFIG) +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +#endif + +#if _MSC_VER+0 >= 1000 +# if _MSC_VER >= 1200 +# define BOOST_HAS_MS_INT64 +# endif +# define BOOST_NO_SWPRINTF +#elif defined(_WIN32) +# define BOOST_DISABLE_WIN32 +#endif + +// I checked version 6.0 build 020312Z, it implements the NRVO. +// Correct this as you find out which version of the compiler +// implemented the NRVO first. (Daniel Frey) +#if (BOOST_INTEL_CXX_VERSION >= 600) +# define BOOST_HAS_NRVO +#endif + +// +// versions check: +// we don't support Intel prior to version 5.0: +#if BOOST_INTEL_CXX_VERSION < 500 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version: +#if (BOOST_INTEL_CXX_VERSION > 810) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# elif defined(_MSC_VER) +# pragma message("Unknown compiler version - please run the configure tests and report the results") +# endif +#endif + + + + + diff --git a/indexlib/boost-compat/config/compiler/intel.hpp b/indexlib/boost-compat/config/compiler/intel.hpp deleted file mode 100644 index 060338bc..00000000 --- a/indexlib/boost-compat/config/compiler/intel.hpp +++ /dev/null @@ -1,151 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright Jens Maurer 2001. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Aleksey Gurtovoy 2002 - 2003. -// (C) Copyright Guillaume Melquiond 2002 - 2003. -// (C) Copyright Beman Dawes 2003. -// (C) Copyright Martin Wille 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Intel compiler setup: - -#include "boost/config/compiler/common_edg.hpp" - -#if defined(__INTEL_COMPILER) -# define BOOST_INTEL_CXX_VERSION __INTEL_COMPILER -#elif defined(__ICL) -# define BOOST_INTEL_CXX_VERSION __ICL -#elif defined(__ICC) -# define BOOST_INTEL_CXX_VERSION __ICC -#elif defined(__ECC) -# define BOOST_INTEL_CXX_VERSION __ECC -#endif - -#define BOOST_COMPILER "Intel C++ version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) -#define BOOST_INTEL BOOST_INTEL_CXX_VERSION - -#if defined(_WIN32) || defined(_WIN64) -# define BOOST_INTEL_WIN BOOST_INTEL -#else -# define BOOST_INTEL_LINUX BOOST_INTEL -#endif - -#if (BOOST_INTEL_CXX_VERSION <= 500) && defined(_MSC_VER) -# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -# define BOOST_NO_TEMPLATE_TEMPLATES -#endif - -#if (BOOST_INTEL_CXX_VERSION <= 600) - -# if defined(_MSC_VER) && (_MSC_VER <= 1300) // added check for <= VC 7 (Peter Dimov) - -// Boost libraries assume strong standard conformance unless otherwise -// indicated by a config macro. As configured by Intel, the EDG front-end -// requires certain compiler options be set to achieve that strong conformance. -// Particularly /Qoption,c,--arg_dep_lookup (reported by Kirk Klobe & Thomas Witt) -// and /Zc:wchar_t,forScope. See boost-root/tools/build/intel-win32-tools.jam for -// details as they apply to particular versions of the compiler. When the -// compiler does not predefine a macro indicating if an option has been set, -// this config file simply assumes the option has been set. -// Thus BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP will not be defined, even if -// the compiler option is not enabled. - -# define BOOST_NO_SWPRINTF -# endif - -// Void returns, 64 bit integrals don't work when emulating VC 6 (Peter Dimov) - -# if defined(_MSC_VER) && (_MSC_VER <= 1200) -# define BOOST_NO_VOID_RETURNS -# define BOOST_NO_INTEGRAL_INT64_T -# endif - -#endif - -#if (BOOST_INTEL_CXX_VERSION <= 710) && defined(_WIN32) -# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS -#endif - -// See http://aspn.activestate.com/ASPN/Mail/Message/boost/1614864 -#if BOOST_INTEL_CXX_VERSION < 600 -# define BOOST_NO_INTRINSIC_WCHAR_T -#else -// We should test the macro _WCHAR_T_DEFINED to check if the compiler -// supports wchar_t natively. *BUT* there is a problem here: the standard -// headers define this macro if they typedef wchar_t. Anyway, we're lucky -// because they define it without a value, while Intel C++ defines it -// to 1. So we can check its value to see if the macro was defined natively -// or not. -// Under UNIX, the situation is exactly the same, but the macro _WCHAR_T -// is used instead. -# if ((_WCHAR_T_DEFINED + 0) == 0) && ((_WCHAR_T + 0) == 0) -# define BOOST_NO_INTRINSIC_WCHAR_T -# endif -#endif - -// -// Verify that we have actually got BOOST_NO_INTRINSIC_WCHAR_T -// set correctly, if we don't do this now, we will get errors later -// in type_traits code among other things, getting this correct -// for the Intel compiler is actually remarkably fragile and tricky: -// -#if defined(BOOST_NO_INTRINSIC_WCHAR_T) -#include -template< typename T > struct assert_no_intrinsic_wchar_t; -template<> struct assert_no_intrinsic_wchar_t { typedef void type; }; -// if you see an error here then you need to unset BOOST_NO_INTRINSIC_WCHAR_T -// where it is defined above: -typedef assert_no_intrinsic_wchar_t::type assert_no_intrinsic_wchar_t_; -#else -template< typename T > struct assert_intrinsic_wchar_t; -template<> struct assert_intrinsic_wchar_t {}; -// if you see an error here then define BOOST_NO_INTRINSIC_WCHAR_T on the command line: -template<> struct assert_intrinsic_wchar_t {}; -#endif - - -#if (BOOST_INTEL_CXX_VERSION <= 800) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -#endif - -#if _MSC_VER+0 >= 1000 -# if _MSC_VER >= 1200 -# define BOOST_HAS_MS_INT64 -# endif -# define BOOST_NO_SWPRINTF -#elif defined(_WIN32) -# define BOOST_DISABLE_WIN32 -#endif - -// I checked version 6.0 build 020312Z, it implements the NRVO. -// Correct this as you find out which version of the compiler -// implemented the NRVO first. (Daniel Frey) -#if (BOOST_INTEL_CXX_VERSION >= 600) -# define BOOST_HAS_NRVO -#endif - -// -// versions check: -// we don't support Intel prior to version 5.0: -#if BOOST_INTEL_CXX_VERSION < 500 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version: -#if (BOOST_INTEL_CXX_VERSION > 810) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# elif defined(_MSC_VER) -# pragma message("Unknown compiler version - please run the configure tests and report the results") -# endif -#endif - - - - - diff --git a/indexlib/boost-compat/config/compiler/kai.h b/indexlib/boost-compat/config/compiler/kai.h new file mode 100644 index 00000000..fefda9ce --- /dev/null +++ b/indexlib/boost-compat/config/compiler/kai.h @@ -0,0 +1,35 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright David Abrahams 2002. +// (C) Copyright Aleksey Gurtovoy 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Kai C++ compiler setup: + +#include "boost/config/compiler/common_edg.hpp" + +# if (__KCC_VERSION <= 4001) || !defined(BOOST_STRICT_CONFIG) + // at least on Sun, the contents of is not in namespace std +# define BOOST_NO_STDC_NAMESPACE +# endif + +// see also common_edg.h which needs a special check for __KCC +# if !defined(_EXCEPTIONS) +# define BOOST_NO_EXCEPTIONS +# endif + +#define BOOST_COMPILER "Kai C++ version " BOOST_STRINGIZE(__KCC_VERSION) + +// +// last known and checked version is 4001: +#if (__KCC_VERSION > 4001) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + diff --git a/indexlib/boost-compat/config/compiler/kai.hpp b/indexlib/boost-compat/config/compiler/kai.hpp deleted file mode 100644 index de16f1a6..00000000 --- a/indexlib/boost-compat/config/compiler/kai.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright David Abrahams 2002. -// (C) Copyright Aleksey Gurtovoy 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Kai C++ compiler setup: - -#include "boost/config/compiler/common_edg.hpp" - -# if (__KCC_VERSION <= 4001) || !defined(BOOST_STRICT_CONFIG) - // at least on Sun, the contents of is not in namespace std -# define BOOST_NO_STDC_NAMESPACE -# endif - -// see also common_edg.hpp which needs a special check for __KCC -# if !defined(_EXCEPTIONS) -# define BOOST_NO_EXCEPTIONS -# endif - -#define BOOST_COMPILER "Kai C++ version " BOOST_STRINGIZE(__KCC_VERSION) - -// -// last known and checked version is 4001: -#if (__KCC_VERSION > 4001) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - diff --git a/indexlib/boost-compat/config/compiler/metrowerks.h b/indexlib/boost-compat/config/compiler/metrowerks.h new file mode 100644 index 00000000..a74cadef --- /dev/null +++ b/indexlib/boost-compat/config/compiler/metrowerks.h @@ -0,0 +1,97 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright David Abrahams 2001 - 2002. +// (C) Copyright Beman Dawes 2001 - 2003. +// (C) Copyright Stefan Slapeta 2004. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Metrowerks C++ compiler setup: + +// locale support is disabled when linking with the dynamic runtime +# ifdef _MSL_NO_LOCALE +# define BOOST_NO_STD_LOCALE +# endif + +# if __MWERKS__ <= 0x2301 // 5.3 +# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING +# define BOOST_NO_POINTER_TO_MEMBER_CONST +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD +# endif + +# if __MWERKS__ <= 0x2401 // 6.2 +//# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING +# endif + +# if(__MWERKS__ <= 0x2407) // 7.x +# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS +# define BOOST_NO_UNREACHABLE_RETURN_DETECTION +# endif + +# if(__MWERKS__ <= 0x3003) // 8.x +# define BOOST_NO_SFINAE +# endif + +# if(__MWERKS__ <= 0x3204) // 9.3 +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# endif + +#if !__option(wchar_type) +# define BOOST_NO_INTRINSIC_WCHAR_T +#endif + +#if !__option(exceptions) +# define BOOST_NO_EXCEPTIONS +#endif + +#if (__INTEL__ && _WIN32) || (__POWERPC__ && macintosh) +# if __MWERKS__ == 0x3000 +# define BOOST_COMPILER_VERSION 8.0 +# elif __MWERKS__ == 0x3001 +# define BOOST_COMPILER_VERSION 8.1 +# elif __MWERKS__ == 0x3002 +# define BOOST_COMPILER_VERSION 8.2 +# elif __MWERKS__ == 0x3003 +# define BOOST_COMPILER_VERSION 8.3 +# elif __MWERKS__ == 0x3200 +# define BOOST_COMPILER_VERSION 9.0 +# elif __MWERKS__ == 0x3201 +# define BOOST_COMPILER_VERSION 9.1 +# elif __MWERKS__ == 0x3202 +# define BOOST_COMPILER_VERSION 9.2 +# elif __MWERKS__ == 0x3204 +# define BOOST_COMPILER_VERSION 9.3 +# else +# define BOOST_COMPILER_VERSION __MWERKS__ +# endif +#else +# define BOOST_COMPILER_VERSION __MWERKS__ +#endif + +#define BOOST_COMPILER "Metrowerks CodeWarrior C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) + +// +// versions check: +// we don't support Metrowerks prior to version 5.3: +#if __MWERKS__ < 0x2301 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version: +#if (__MWERKS__ > 0x3204) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + + + + + diff --git a/indexlib/boost-compat/config/compiler/metrowerks.hpp b/indexlib/boost-compat/config/compiler/metrowerks.hpp deleted file mode 100644 index a74cadef..00000000 --- a/indexlib/boost-compat/config/compiler/metrowerks.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright David Abrahams 2001 - 2002. -// (C) Copyright Beman Dawes 2001 - 2003. -// (C) Copyright Stefan Slapeta 2004. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Metrowerks C++ compiler setup: - -// locale support is disabled when linking with the dynamic runtime -# ifdef _MSL_NO_LOCALE -# define BOOST_NO_STD_LOCALE -# endif - -# if __MWERKS__ <= 0x2301 // 5.3 -# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# define BOOST_NO_POINTER_TO_MEMBER_CONST -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD -# endif - -# if __MWERKS__ <= 0x2401 // 6.2 -//# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# endif - -# if(__MWERKS__ <= 0x2407) // 7.x -# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS -# define BOOST_NO_UNREACHABLE_RETURN_DETECTION -# endif - -# if(__MWERKS__ <= 0x3003) // 8.x -# define BOOST_NO_SFINAE -# endif - -# if(__MWERKS__ <= 0x3204) // 9.3 -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -# endif - -#if !__option(wchar_type) -# define BOOST_NO_INTRINSIC_WCHAR_T -#endif - -#if !__option(exceptions) -# define BOOST_NO_EXCEPTIONS -#endif - -#if (__INTEL__ && _WIN32) || (__POWERPC__ && macintosh) -# if __MWERKS__ == 0x3000 -# define BOOST_COMPILER_VERSION 8.0 -# elif __MWERKS__ == 0x3001 -# define BOOST_COMPILER_VERSION 8.1 -# elif __MWERKS__ == 0x3002 -# define BOOST_COMPILER_VERSION 8.2 -# elif __MWERKS__ == 0x3003 -# define BOOST_COMPILER_VERSION 8.3 -# elif __MWERKS__ == 0x3200 -# define BOOST_COMPILER_VERSION 9.0 -# elif __MWERKS__ == 0x3201 -# define BOOST_COMPILER_VERSION 9.1 -# elif __MWERKS__ == 0x3202 -# define BOOST_COMPILER_VERSION 9.2 -# elif __MWERKS__ == 0x3204 -# define BOOST_COMPILER_VERSION 9.3 -# else -# define BOOST_COMPILER_VERSION __MWERKS__ -# endif -#else -# define BOOST_COMPILER_VERSION __MWERKS__ -#endif - -#define BOOST_COMPILER "Metrowerks CodeWarrior C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) - -// -// versions check: -// we don't support Metrowerks prior to version 5.3: -#if __MWERKS__ < 0x2301 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version: -#if (__MWERKS__ > 0x3204) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - - - - - diff --git a/indexlib/boost-compat/config/compiler/mpw.h b/indexlib/boost-compat/config/compiler/mpw.h new file mode 100644 index 00000000..8ab2aacb --- /dev/null +++ b/indexlib/boost-compat/config/compiler/mpw.h @@ -0,0 +1,51 @@ +// (C) Copyright John Maddock 2001 - 2002. +// (C) Copyright Aleksey Gurtovoy 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// MPW C++ compilers setup: + +# if defined(__SC__) +# define BOOST_COMPILER "MPW SCpp version " BOOST_STRINGIZE(__SC__) +# elif defined(__MRC__) +# define BOOST_COMPILER "MPW MrCpp version " BOOST_STRINGIZE(__MRC__) +# else +# error "Using MPW compiler configuration by mistake. Please update." +# endif + +// +// MPW 8.90: +// +#if (MPW_CPLUS <= 0x890) || !defined(BOOST_STRICT_CONFIG) +# define BOOST_NO_CV_SPECIALIZATIONS +# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION +# define BOOST_NO_INTRINSIC_WCHAR_T +# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# define BOOST_NO_USING_TEMPLATE + +# define BOOST_NO_CWCHAR +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + +# define BOOST_NO_STD_ALLOCATOR /* actually a bug with const reference overloading */ +#endif + +// +// versions check: +// we don't support MPW prior to version 8.9: +#if MPW_CPLUS < 0x890 +# error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 0x890: +#if (MPW_CPLUS > 0x890) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + diff --git a/indexlib/boost-compat/config/compiler/mpw.hpp b/indexlib/boost-compat/config/compiler/mpw.hpp deleted file mode 100644 index 8ab2aacb..00000000 --- a/indexlib/boost-compat/config/compiler/mpw.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// (C) Copyright Aleksey Gurtovoy 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// MPW C++ compilers setup: - -# if defined(__SC__) -# define BOOST_COMPILER "MPW SCpp version " BOOST_STRINGIZE(__SC__) -# elif defined(__MRC__) -# define BOOST_COMPILER "MPW MrCpp version " BOOST_STRINGIZE(__MRC__) -# else -# error "Using MPW compiler configuration by mistake. Please update." -# endif - -// -// MPW 8.90: -// -#if (MPW_CPLUS <= 0x890) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_NO_CV_SPECIALIZATIONS -# define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# define BOOST_NO_INTRINSIC_WCHAR_T -# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -# define BOOST_NO_USING_TEMPLATE - -# define BOOST_NO_CWCHAR -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - -# define BOOST_NO_STD_ALLOCATOR /* actually a bug with const reference overloading */ -#endif - -// -// versions check: -// we don't support MPW prior to version 8.9: -#if MPW_CPLUS < 0x890 -# error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 0x890: -#if (MPW_CPLUS > 0x890) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - diff --git a/indexlib/boost-compat/config/compiler/sgi_mipspro.h b/indexlib/boost-compat/config/compiler/sgi_mipspro.h new file mode 100644 index 00000000..689b67ee --- /dev/null +++ b/indexlib/boost-compat/config/compiler/sgi_mipspro.h @@ -0,0 +1,24 @@ +// (C) Copyright John Maddock 2001 - 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// SGI C++ compiler setup: + +#define BOOST_COMPILER "SGI Irix compiler version " BOOST_STRINGIZE(_COMPILER_VERSION) + +#include "boost/config/compiler/common_edg.hpp" + +// +// Threading support: +// Turn this on unconditionally here, it will get turned off again later +// if no threading API is detected. +// +#define BOOST_HAS_THREADS +// +// version check: +// probably nothing to do here? + + diff --git a/indexlib/boost-compat/config/compiler/sgi_mipspro.hpp b/indexlib/boost-compat/config/compiler/sgi_mipspro.hpp deleted file mode 100644 index 689b67ee..00000000 --- a/indexlib/boost-compat/config/compiler/sgi_mipspro.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// SGI C++ compiler setup: - -#define BOOST_COMPILER "SGI Irix compiler version " BOOST_STRINGIZE(_COMPILER_VERSION) - -#include "boost/config/compiler/common_edg.hpp" - -// -// Threading support: -// Turn this on unconditionally here, it will get turned off again later -// if no threading API is detected. -// -#define BOOST_HAS_THREADS -// -// version check: -// probably nothing to do here? - - diff --git a/indexlib/boost-compat/config/compiler/sunpro_cc.h b/indexlib/boost-compat/config/compiler/sunpro_cc.h new file mode 100644 index 00000000..80dc3913 --- /dev/null +++ b/indexlib/boost-compat/config/compiler/sunpro_cc.h @@ -0,0 +1,89 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Jens Maurer 2001 - 2003. +// (C) Copyright Peter Dimov 2002. +// (C) Copyright Aleksey Gurtovoy 2002 - 2003. +// (C) Copyright David Abrahams 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Sun C++ compiler setup: + +# if __SUNPRO_CC <= 0x500 +# define BOOST_NO_MEMBER_TEMPLATES +# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING +# endif + +# if (__SUNPRO_CC <= 0x520) + // + // Sunpro 5.2 and earler: + // + // although sunpro 5.2 supports the syntax for + // inline initialization it often gets the value + // wrong, especially where the value is computed + // from other constants (J Maddock 6th May 2001) +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION + + // Although sunpro 5.2 supports the syntax for + // partial specialization, it often seems to + // bind to the wrong specialization. Better + // to disable it until suppport becomes more stable + // (J Maddock 6th May 2001). +# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# endif + +# if (__SUNPRO_CC <= 0x530) || !defined(BOOST_STRICT_CONFIG) + // Requesting debug info (-g) with Boost.Python results + // in an internal compiler error for "static const" + // initialized in-class. + // >> Assertion: (../links/dbg_cstabs.cpp, line 611) + // while processing ../test.cpp at line 0. + // (Jens Maurer according to Gottfried Ganßauge 04 Mar 2002) +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION + + // SunPro 5.3 has better support for partial specialization, + // but breaks when compiling std::less > + // (Jens Maurer 4 Nov 2001). + + // std::less specialization fixed as reported by George + // Heintzelman; partial specialization re-enabled + // (Peter Dimov 17 Jan 2002) + +//# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // integral constant expressions with 64 bit numbers fail +# define BOOST_NO_INTEGRAL_INT64_T +# endif + +# if (__SUNPRO_CC <= 0x540) || !defined(BOOST_STRICT_CONFIG) +# define BOOST_NO_TEMPLATE_TEMPLATES + // see http://lists.boost.org/MailArchives/boost/msg47184.php + // and http://lists.boost.org/MailArchives/boost/msg47220.php +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION +# define BOOST_NO_SFINAE +# define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS +# endif + +#define BOOST_COMPILER "Sun compiler version " BOOST_STRINGIZE(__SUNPRO_CC) + +// +// versions check: +// we don't support sunpro prior to version 4: +#if __SUNPRO_CC < 0x400 +#error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 0x530: +#if (__SUNPRO_CC > 0x530) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + + + + diff --git a/indexlib/boost-compat/config/compiler/sunpro_cc.hpp b/indexlib/boost-compat/config/compiler/sunpro_cc.hpp deleted file mode 100644 index 8a61199f..00000000 --- a/indexlib/boost-compat/config/compiler/sunpro_cc.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Jens Maurer 2001 - 2003. -// (C) Copyright Peter Dimov 2002. -// (C) Copyright Aleksey Gurtovoy 2002 - 2003. -// (C) Copyright David Abrahams 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Sun C++ compiler setup: - -# if __SUNPRO_CC <= 0x500 -# define BOOST_NO_MEMBER_TEMPLATES -# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# endif - -# if (__SUNPRO_CC <= 0x520) - // - // Sunpro 5.2 and earler: - // - // although sunpro 5.2 supports the syntax for - // inline initialization it often gets the value - // wrong, especially where the value is computed - // from other constants (J Maddock 6th May 2001) -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION - - // Although sunpro 5.2 supports the syntax for - // partial specialization, it often seems to - // bind to the wrong specialization. Better - // to disable it until suppport becomes more stable - // (J Maddock 6th May 2001). -# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -# endif - -# if (__SUNPRO_CC <= 0x530) || !defined(BOOST_STRICT_CONFIG) - // Requesting debug info (-g) with Boost.Python results - // in an internal compiler error for "static const" - // initialized in-class. - // >> Assertion: (../links/dbg_cstabs.cc, line 611) - // while processing ../test.cpp at line 0. - // (Jens Maurer according to Gottfried Ganßauge 04 Mar 2002) -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION - - // SunPro 5.3 has better support for partial specialization, - // but breaks when compiling std::less > - // (Jens Maurer 4 Nov 2001). - - // std::less specialization fixed as reported by George - // Heintzelman; partial specialization re-enabled - // (Peter Dimov 17 Jan 2002) - -//# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // integral constant expressions with 64 bit numbers fail -# define BOOST_NO_INTEGRAL_INT64_T -# endif - -# if (__SUNPRO_CC <= 0x540) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_NO_TEMPLATE_TEMPLATES - // see http://lists.boost.org/MailArchives/boost/msg47184.php - // and http://lists.boost.org/MailArchives/boost/msg47220.php -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# define BOOST_NO_SFINAE -# define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS -# endif - -#define BOOST_COMPILER "Sun compiler version " BOOST_STRINGIZE(__SUNPRO_CC) - -// -// versions check: -// we don't support sunpro prior to version 4: -#if __SUNPRO_CC < 0x400 -#error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 0x530: -#if (__SUNPRO_CC > 0x530) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - - - - diff --git a/indexlib/boost-compat/config/compiler/vacpp.h b/indexlib/boost-compat/config/compiler/vacpp.h new file mode 100644 index 00000000..4cf0de7c --- /dev/null +++ b/indexlib/boost-compat/config/compiler/vacpp.h @@ -0,0 +1,58 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Toon Knapen 2001 - 2003. +// (C) Copyright Lie-Quan Lee 2001. +// (C) Copyright Markus Schöpflin 2002 - 2003. +// (C) Copyright Beman Dawes 2002 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Visual Age (IBM) C++ compiler setup: + +#if __IBMCPP__ <= 501 +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS +#endif + +#if (__IBMCPP__ <= 502) +// Actually the compiler supports inclass member initialization but it +// requires a definition for the class member and it doesn't recognize +// it as an integral constant expression when used as a template argument. +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION +# define BOOST_NO_INTEGRAL_INT64_T +# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD +#endif + +#if (__IBMCPP__ <= 600) || !defined(BOOST_STRICT_CONFIG) +# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS +# define BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES 1 +#endif + +// +// On AIX thread support seems to be indicated by _THREAD_SAFE: +// +#ifdef _THREAD_SAFE +# define BOOST_HAS_THREADS +#endif + +#define BOOST_COMPILER "IBM Visual Age version " BOOST_STRINGIZE(__IBMCPP__) + +// +// versions check: +// we don't support Visual age prior to version 5: +#if __IBMCPP__ < 500 +#error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 600: +#if (__IBMCPP__ > 600) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# endif +#endif + + + + diff --git a/indexlib/boost-compat/config/compiler/vacpp.hpp b/indexlib/boost-compat/config/compiler/vacpp.hpp deleted file mode 100644 index 4cf0de7c..00000000 --- a/indexlib/boost-compat/config/compiler/vacpp.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Toon Knapen 2001 - 2003. -// (C) Copyright Lie-Quan Lee 2001. -// (C) Copyright Markus Schöpflin 2002 - 2003. -// (C) Copyright Beman Dawes 2002 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Visual Age (IBM) C++ compiler setup: - -#if __IBMCPP__ <= 501 -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS -#endif - -#if (__IBMCPP__ <= 502) -// Actually the compiler supports inclass member initialization but it -// requires a definition for the class member and it doesn't recognize -// it as an integral constant expression when used as a template argument. -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# define BOOST_NO_INTEGRAL_INT64_T -# define BOOST_NO_MEMBER_TEMPLATE_KEYWORD -#endif - -#if (__IBMCPP__ <= 600) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS -# define BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES 1 -#endif - -// -// On AIX thread support seems to be indicated by _THREAD_SAFE: -// -#ifdef _THREAD_SAFE -# define BOOST_HAS_THREADS -#endif - -#define BOOST_COMPILER "IBM Visual Age version " BOOST_STRINGIZE(__IBMCPP__) - -// -// versions check: -// we don't support Visual age prior to version 5: -#if __IBMCPP__ < 500 -#error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 600: -#if (__IBMCPP__ > 600) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# endif -#endif - - - - diff --git a/indexlib/boost-compat/config/compiler/visualc.h b/indexlib/boost-compat/config/compiler/visualc.h new file mode 100644 index 00000000..32353260 --- /dev/null +++ b/indexlib/boost-compat/config/compiler/visualc.h @@ -0,0 +1,146 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001 - 2002. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright Aleksey Gurtovoy 2002. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Beman Dawes 2002 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Microsoft Visual C++ compiler setup: + +#define BOOST_MSVC _MSC_VER + +// turn off the warnings before we #include anything +#pragma warning( disable : 4503 ) // warning: decorated name length exceeded + +#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1201 == EVC4.2 +#pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +# define BOOST_NO_VOID_RETURNS +# define BOOST_NO_EXCEPTION_STD_NAMESPACE + // disable min/max macro defines on vc6: + // +#endif + +#if (_MSC_VER <= 1300) // 1300 == VC++ 7.0 + +#if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +#endif + +# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION +# define BOOST_NO_PRIVATE_IN_AGGREGATE +# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# define BOOST_NO_INTEGRAL_INT64_T +# define BOOST_NO_DEDUCED_TYPENAME +# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE + +// VC++ 6/7 has member templates but they have numerous problems including +// cases of silent failure, so for safety we define: +# define BOOST_NO_MEMBER_TEMPLATES +// For VC++ experts wishing to attempt workarounds, we define: +# define BOOST_MSVC6_MEMBER_TEMPLATES + +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# define BOOST_NO_CV_VOID_SPECIALIZATIONS +# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING +# define BOOST_NO_USING_TEMPLATE +# define BOOST_NO_SWPRINTF +# define BOOST_NO_TEMPLATE_TEMPLATES +# define BOOST_NO_SFINAE +# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS +# if (_MSC_VER > 1200) +# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS +# endif + +#endif + +#if _MSC_VER < 1310 // 1310 == VC++ 7.1 +# define BOOST_NO_SWPRINTF +#endif + +#if _MSC_VER <= 1400 // 1400 == VC++ 8.0 +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +#endif + +#ifndef _NATIVE_WCHAR_T_DEFINED +# define BOOST_NO_INTRINSIC_WCHAR_T +#endif + +#ifdef _WIN32_WCE +# define BOOST_NO_THREADEX +# define BOOST_NO_GETSYSTEMTIMEASFILETIME +#endif + +// +// check for exception handling support: +#ifndef _CPPUNWIND +# define BOOST_NO_EXCEPTIONS +#endif + +// +// __int64 support: +// +#if (_MSC_VER >= 1200) +# define BOOST_HAS_MS_INT64 +#endif +#if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS) +# define BOOST_HAS_LONG_LONG +#endif +// +// disable Win32 API's if compiler extentions are +// turned off: +// +#ifndef _MSC_EXTENSIONS +# define BOOST_DISABLE_WIN32 +#endif + +// +// all versions support __declspec: +// +#define BOOST_HAS_DECLSPEC +// +// prefix and suffix headers: +// +#ifndef BOOST_ABI_PREFIX +# define BOOST_ABI_PREFIX "boost/config/abi/msvc_prefix.hpp" +#endif +#ifndef BOOST_ABI_SUFFIX +# define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp" +#endif + +# if _MSC_VER == 1200 +# define BOOST_COMPILER_VERSION 6.0 +# elif _MSC_VER == 1300 +# define BOOST_COMPILER_VERSION 7.0 +# elif _MSC_VER == 1310 +# define BOOST_COMPILER_VERSION 7.1 +# elif _MSC_VER == 1400 +# define BOOST_COMPILER_VERSION 8.0 +# else +# define BOOST_COMPILER_VERSION _MSC_VER +# endif + +#define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) + +// +// versions check: +// we don't support Visual C++ prior to version 6: +#if _MSC_VER < 1200 +#error "Compiler not supported or configured - please reconfigure" +#endif +// +// last known and checked version is 1310: +#if (_MSC_VER > 1400) +# if defined(BOOST_ASSERT_CONFIG) +# error "Unknown compiler version - please run the configure tests and report the results" +# else +# pragma message("Unknown compiler version - please run the configure tests and report the results") +# endif +#endif diff --git a/indexlib/boost-compat/config/compiler/visualc.hpp b/indexlib/boost-compat/config/compiler/visualc.hpp deleted file mode 100644 index 32353260..00000000 --- a/indexlib/boost-compat/config/compiler/visualc.hpp +++ /dev/null @@ -1,146 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001 - 2002. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright Aleksey Gurtovoy 2002. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Beman Dawes 2002 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Microsoft Visual C++ compiler setup: - -#define BOOST_MSVC _MSC_VER - -// turn off the warnings before we #include anything -#pragma warning( disable : 4503 ) // warning: decorated name length exceeded - -#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1201 == EVC4.2 -#pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -# define BOOST_NO_VOID_RETURNS -# define BOOST_NO_EXCEPTION_STD_NAMESPACE - // disable min/max macro defines on vc6: - // -#endif - -#if (_MSC_VER <= 1300) // 1300 == VC++ 7.0 - -#if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -#endif - -# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# define BOOST_NO_PRIVATE_IN_AGGREGATE -# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -# define BOOST_NO_INTEGRAL_INT64_T -# define BOOST_NO_DEDUCED_TYPENAME -# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE - -// VC++ 6/7 has member templates but they have numerous problems including -// cases of silent failure, so for safety we define: -# define BOOST_NO_MEMBER_TEMPLATES -// For VC++ experts wishing to attempt workarounds, we define: -# define BOOST_MSVC6_MEMBER_TEMPLATES - -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -# define BOOST_NO_CV_VOID_SPECIALIZATIONS -# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# define BOOST_NO_USING_TEMPLATE -# define BOOST_NO_SWPRINTF -# define BOOST_NO_TEMPLATE_TEMPLATES -# define BOOST_NO_SFINAE -# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS -# if (_MSC_VER > 1200) -# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS -# endif - -#endif - -#if _MSC_VER < 1310 // 1310 == VC++ 7.1 -# define BOOST_NO_SWPRINTF -#endif - -#if _MSC_VER <= 1400 // 1400 == VC++ 8.0 -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS -#endif - -#ifndef _NATIVE_WCHAR_T_DEFINED -# define BOOST_NO_INTRINSIC_WCHAR_T -#endif - -#ifdef _WIN32_WCE -# define BOOST_NO_THREADEX -# define BOOST_NO_GETSYSTEMTIMEASFILETIME -#endif - -// -// check for exception handling support: -#ifndef _CPPUNWIND -# define BOOST_NO_EXCEPTIONS -#endif - -// -// __int64 support: -// -#if (_MSC_VER >= 1200) -# define BOOST_HAS_MS_INT64 -#endif -#if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS) -# define BOOST_HAS_LONG_LONG -#endif -// -// disable Win32 API's if compiler extentions are -// turned off: -// -#ifndef _MSC_EXTENSIONS -# define BOOST_DISABLE_WIN32 -#endif - -// -// all versions support __declspec: -// -#define BOOST_HAS_DECLSPEC -// -// prefix and suffix headers: -// -#ifndef BOOST_ABI_PREFIX -# define BOOST_ABI_PREFIX "boost/config/abi/msvc_prefix.hpp" -#endif -#ifndef BOOST_ABI_SUFFIX -# define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp" -#endif - -# if _MSC_VER == 1200 -# define BOOST_COMPILER_VERSION 6.0 -# elif _MSC_VER == 1300 -# define BOOST_COMPILER_VERSION 7.0 -# elif _MSC_VER == 1310 -# define BOOST_COMPILER_VERSION 7.1 -# elif _MSC_VER == 1400 -# define BOOST_COMPILER_VERSION 8.0 -# else -# define BOOST_COMPILER_VERSION _MSC_VER -# endif - -#define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) - -// -// versions check: -// we don't support Visual C++ prior to version 6: -#if _MSC_VER < 1200 -#error "Compiler not supported or configured - please reconfigure" -#endif -// -// last known and checked version is 1310: -#if (_MSC_VER > 1400) -# if defined(BOOST_ASSERT_CONFIG) -# error "Unknown compiler version - please run the configure tests and report the results" -# else -# pragma message("Unknown compiler version - please run the configure tests and report the results") -# endif -#endif diff --git a/indexlib/boost-compat/config/platform/aix.h b/indexlib/boost-compat/config/platform/aix.h new file mode 100644 index 00000000..894ef42c --- /dev/null +++ b/indexlib/boost-compat/config/platform/aix.h @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2001 - 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// IBM/Aix specific config options: + +#define BOOST_PLATFORM "IBM Aix" + +#define BOOST_HAS_UNISTD_H +#define BOOST_HAS_NL_TYPES_H +#define BOOST_HAS_NANOSLEEP +#define BOOST_HAS_CLOCK_GETTIME + +// This needs support in "boost/cstdint.hpp" exactly like FreeBSD. +// This platform has header named which includes all +// the things needed. +#define BOOST_HAS_STDINT_H + +// Threading API's: +#define BOOST_HAS_PTHREADS +#define BOOST_HAS_PTHREAD_DELAY_NP +#define BOOST_HAS_SCHED_YIELD +//#define BOOST_HAS_PTHREAD_YIELD + +// boilerplate code: +#include + + + + diff --git a/indexlib/boost-compat/config/platform/aix.hpp b/indexlib/boost-compat/config/platform/aix.hpp deleted file mode 100644 index 894ef42c..00000000 --- a/indexlib/boost-compat/config/platform/aix.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// IBM/Aix specific config options: - -#define BOOST_PLATFORM "IBM Aix" - -#define BOOST_HAS_UNISTD_H -#define BOOST_HAS_NL_TYPES_H -#define BOOST_HAS_NANOSLEEP -#define BOOST_HAS_CLOCK_GETTIME - -// This needs support in "boost/cstdint.hpp" exactly like FreeBSD. -// This platform has header named which includes all -// the things needed. -#define BOOST_HAS_STDINT_H - -// Threading API's: -#define BOOST_HAS_PTHREADS -#define BOOST_HAS_PTHREAD_DELAY_NP -#define BOOST_HAS_SCHED_YIELD -//#define BOOST_HAS_PTHREAD_YIELD - -// boilerplate code: -#include - - - - diff --git a/indexlib/boost-compat/config/platform/amigaos.h b/indexlib/boost-compat/config/platform/amigaos.h new file mode 100644 index 00000000..34bcf412 --- /dev/null +++ b/indexlib/boost-compat/config/platform/amigaos.h @@ -0,0 +1,15 @@ +// (C) Copyright John Maddock 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +#define BOOST_PLATFORM "AmigaOS" + +#define BOOST_DISABLE_THREADS +#define BOOST_NO_CWCHAR +#define BOOST_NO_STD_WSTRING +#define BOOST_NO_INTRINSIC_WCHAR_T + + diff --git a/indexlib/boost-compat/config/platform/amigaos.hpp b/indexlib/boost-compat/config/platform/amigaos.hpp deleted file mode 100644 index 34bcf412..00000000 --- a/indexlib/boost-compat/config/platform/amigaos.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// (C) Copyright John Maddock 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -#define BOOST_PLATFORM "AmigaOS" - -#define BOOST_DISABLE_THREADS -#define BOOST_NO_CWCHAR -#define BOOST_NO_STD_WSTRING -#define BOOST_NO_INTRINSIC_WCHAR_T - - diff --git a/indexlib/boost-compat/config/platform/beos.h b/indexlib/boost-compat/config/platform/beos.h new file mode 100644 index 00000000..48c3d8dc --- /dev/null +++ b/indexlib/boost-compat/config/platform/beos.h @@ -0,0 +1,26 @@ +// (C) Copyright John Maddock 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// BeOS specific config options: + +#define BOOST_PLATFORM "BeOS" + +#define BOOST_NO_CWCHAR +#define BOOST_NO_CWCTYPE +#define BOOST_HAS_UNISTD_H + +#define BOOST_HAS_BETHREADS + +#ifndef BOOST_DISABLE_THREADS +# define BOOST_HAS_THREADS +#endif + +// boilerplate code: +#include + + + diff --git a/indexlib/boost-compat/config/platform/beos.hpp b/indexlib/boost-compat/config/platform/beos.hpp deleted file mode 100644 index 48c3d8dc..00000000 --- a/indexlib/boost-compat/config/platform/beos.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// (C) Copyright John Maddock 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// BeOS specific config options: - -#define BOOST_PLATFORM "BeOS" - -#define BOOST_NO_CWCHAR -#define BOOST_NO_CWCTYPE -#define BOOST_HAS_UNISTD_H - -#define BOOST_HAS_BETHREADS - -#ifndef BOOST_DISABLE_THREADS -# define BOOST_HAS_THREADS -#endif - -// boilerplate code: -#include - - - diff --git a/indexlib/boost-compat/config/platform/bsd.h b/indexlib/boost-compat/config/platform/bsd.h new file mode 100644 index 00000000..4f04ed2a --- /dev/null +++ b/indexlib/boost-compat/config/platform/bsd.h @@ -0,0 +1,70 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Douglas Gregor 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// generic BSD config options: + +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) +#error "This platform is not BSD" +#endif + +#ifdef __FreeBSD__ +#define BOOST_PLATFORM "FreeBSD " BOOST_STRINGIZE(__FreeBSD__) +#elif defined(__NetBSD__) +#define BOOST_PLATFORM "NetBSD " BOOST_STRINGIZE(__NetBSD__) +#elif defined(__OpenBSD__) +#define BOOST_PLATFORM "OpenBSD " BOOST_STRINGIZE(__OpenBSD__) +#endif + +// +// is this the correct version check? +// FreeBSD has but does not +// advertise the fact in : +// +#if defined(__FreeBSD__) && (__FreeBSD__ >= 3) +# define BOOST_HAS_NL_TYPES_H +#endif + +// +// FreeBSD 3.x has pthreads support, but defines _POSIX_THREADS in +// and not in +// +#if defined(__FreeBSD__) && (__FreeBSD__ <= 3) +# define BOOST_HAS_PTHREADS +#endif + +// +// No wide character support in the BSD header files: +// +#define BOOST_NO_CWCHAR + +// +// The BSD has macros only, no functions: +// +#if !defined(__OpenBSD__) +# define BOOST_NO_CTYPE_FUNCTIONS +#endif + +// +// thread API's not auto detected: +// +#define BOOST_HAS_SCHED_YIELD +#define BOOST_HAS_NANOSLEEP +#define BOOST_HAS_GETTIMEOFDAY +#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +#define BOOST_HAS_SIGACTION + +// boilerplate code: +#define BOOST_HAS_UNISTD_H +#include + + + + + + diff --git a/indexlib/boost-compat/config/platform/bsd.hpp b/indexlib/boost-compat/config/platform/bsd.hpp deleted file mode 100644 index 4f04ed2a..00000000 --- a/indexlib/boost-compat/config/platform/bsd.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Douglas Gregor 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// generic BSD config options: - -#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) -#error "This platform is not BSD" -#endif - -#ifdef __FreeBSD__ -#define BOOST_PLATFORM "FreeBSD " BOOST_STRINGIZE(__FreeBSD__) -#elif defined(__NetBSD__) -#define BOOST_PLATFORM "NetBSD " BOOST_STRINGIZE(__NetBSD__) -#elif defined(__OpenBSD__) -#define BOOST_PLATFORM "OpenBSD " BOOST_STRINGIZE(__OpenBSD__) -#endif - -// -// is this the correct version check? -// FreeBSD has but does not -// advertise the fact in : -// -#if defined(__FreeBSD__) && (__FreeBSD__ >= 3) -# define BOOST_HAS_NL_TYPES_H -#endif - -// -// FreeBSD 3.x has pthreads support, but defines _POSIX_THREADS in -// and not in -// -#if defined(__FreeBSD__) && (__FreeBSD__ <= 3) -# define BOOST_HAS_PTHREADS -#endif - -// -// No wide character support in the BSD header files: -// -#define BOOST_NO_CWCHAR - -// -// The BSD has macros only, no functions: -// -#if !defined(__OpenBSD__) -# define BOOST_NO_CTYPE_FUNCTIONS -#endif - -// -// thread API's not auto detected: -// -#define BOOST_HAS_SCHED_YIELD -#define BOOST_HAS_NANOSLEEP -#define BOOST_HAS_GETTIMEOFDAY -#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -#define BOOST_HAS_SIGACTION - -// boilerplate code: -#define BOOST_HAS_UNISTD_H -#include - - - - - - diff --git a/indexlib/boost-compat/config/platform/cygwin.h b/indexlib/boost-compat/config/platform/cygwin.h new file mode 100644 index 00000000..0fd2ebe2 --- /dev/null +++ b/indexlib/boost-compat/config/platform/cygwin.h @@ -0,0 +1,48 @@ +// (C) Copyright John Maddock 2001 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// cygwin specific config options: + +#define BOOST_PLATFORM "Cygwin" +#define BOOST_NO_CWCTYPE +#define BOOST_NO_CWCHAR +#define BOOST_NO_SWPRINTF +#define BOOST_HAS_DIRENT_H + +// +// Threading API: +// See if we have POSIX threads, if we do use them, otherwise +// revert to native Win threads. +#define BOOST_HAS_UNISTD_H +#include +#if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) && !defined(BOOST_HAS_WINTHREADS) +# define BOOST_HAS_PTHREADS +# define BOOST_HAS_SCHED_YIELD +# define BOOST_HAS_GETTIMEOFDAY +# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +# define BOOST_HAS_SIGACTION +#else +# if !defined(BOOST_HAS_WINTHREADS) +# define BOOST_HAS_WINTHREADS +# endif +# define BOOST_HAS_FTIME +#endif + +// +// find out if we have a stdint.h, there should be a better way to do this: +// +#include +#ifdef _STDINT_H +#define BOOST_HAS_STDINT_H +#endif + +// boilerplate code: +#include + + + + diff --git a/indexlib/boost-compat/config/platform/cygwin.hpp b/indexlib/boost-compat/config/platform/cygwin.hpp deleted file mode 100644 index 0fd2ebe2..00000000 --- a/indexlib/boost-compat/config/platform/cygwin.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// cygwin specific config options: - -#define BOOST_PLATFORM "Cygwin" -#define BOOST_NO_CWCTYPE -#define BOOST_NO_CWCHAR -#define BOOST_NO_SWPRINTF -#define BOOST_HAS_DIRENT_H - -// -// Threading API: -// See if we have POSIX threads, if we do use them, otherwise -// revert to native Win threads. -#define BOOST_HAS_UNISTD_H -#include -#if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) && !defined(BOOST_HAS_WINTHREADS) -# define BOOST_HAS_PTHREADS -# define BOOST_HAS_SCHED_YIELD -# define BOOST_HAS_GETTIMEOFDAY -# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -# define BOOST_HAS_SIGACTION -#else -# if !defined(BOOST_HAS_WINTHREADS) -# define BOOST_HAS_WINTHREADS -# endif -# define BOOST_HAS_FTIME -#endif - -// -// find out if we have a stdint.h, there should be a better way to do this: -// -#include -#ifdef _STDINT_H -#define BOOST_HAS_STDINT_H -#endif - -// boilerplate code: -#include - - - - diff --git a/indexlib/boost-compat/config/platform/hpux.h b/indexlib/boost-compat/config/platform/hpux.h new file mode 100644 index 00000000..21049059 --- /dev/null +++ b/indexlib/boost-compat/config/platform/hpux.h @@ -0,0 +1,62 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001 - 2003. +// (C) Copyright David Abrahams 2002. +// (C) Copyright Toon Knapen 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// hpux specific config options: + +#define BOOST_PLATFORM "HP-UX" + +// In principle, HP-UX has a nice under the name +// However, it has the following problem: +// Use of UINT32_C(0) results in "0u l" for the preprocessed source +// (verifyable with gcc 2.95.3, assumed for HP aCC) +// #define BOOST_HAS_STDINT_H + +#define BOOST_NO_SWPRINTF +#define BOOST_NO_CWCTYPE + +#ifdef __GNUC__ + // GNU C on HP-UX does not support threads (checked up to gcc 3.3) +# define BOOST_DISABLE_THREADS +#endif + +// boilerplate code: +#define BOOST_HAS_UNISTD_H +#include + +// the following are always available: +#ifndef BOOST_HAS_GETTIMEOFDAY +# define BOOST_HAS_GETTIMEOFDAY +#endif +#ifndef BOOST_HAS_SCHED_YIELD +# define BOOST_HAS_SCHED_YIELD +#endif +#ifndef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +#endif +#ifndef BOOST_HAS_NL_TYPES_H +# define BOOST_HAS_NL_TYPES_H +#endif +#ifndef BOOST_HAS_NANOSLEEP +# define BOOST_HAS_NANOSLEEP +#endif +#ifndef BOOST_HAS_GETTIMEOFDAY +# define BOOST_HAS_GETTIMEOFDAY +#endif +#ifndef BOOST_HAS_DIRENT_H +# define BOOST_HAS_DIRENT_H +#endif +#ifndef BOOST_HAS_CLOCK_GETTIME +# define BOOST_HAS_CLOCK_GETTIME +#endif +#ifndef BOOST_HAS_SIGACTION +# define BOOST_HAS_SIGACTION +#endif + + diff --git a/indexlib/boost-compat/config/platform/hpux.hpp b/indexlib/boost-compat/config/platform/hpux.hpp deleted file mode 100644 index 21049059..00000000 --- a/indexlib/boost-compat/config/platform/hpux.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001 - 2003. -// (C) Copyright David Abrahams 2002. -// (C) Copyright Toon Knapen 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// hpux specific config options: - -#define BOOST_PLATFORM "HP-UX" - -// In principle, HP-UX has a nice under the name -// However, it has the following problem: -// Use of UINT32_C(0) results in "0u l" for the preprocessed source -// (verifyable with gcc 2.95.3, assumed for HP aCC) -// #define BOOST_HAS_STDINT_H - -#define BOOST_NO_SWPRINTF -#define BOOST_NO_CWCTYPE - -#ifdef __GNUC__ - // GNU C on HP-UX does not support threads (checked up to gcc 3.3) -# define BOOST_DISABLE_THREADS -#endif - -// boilerplate code: -#define BOOST_HAS_UNISTD_H -#include - -// the following are always available: -#ifndef BOOST_HAS_GETTIMEOFDAY -# define BOOST_HAS_GETTIMEOFDAY -#endif -#ifndef BOOST_HAS_SCHED_YIELD -# define BOOST_HAS_SCHED_YIELD -#endif -#ifndef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -#endif -#ifndef BOOST_HAS_NL_TYPES_H -# define BOOST_HAS_NL_TYPES_H -#endif -#ifndef BOOST_HAS_NANOSLEEP -# define BOOST_HAS_NANOSLEEP -#endif -#ifndef BOOST_HAS_GETTIMEOFDAY -# define BOOST_HAS_GETTIMEOFDAY -#endif -#ifndef BOOST_HAS_DIRENT_H -# define BOOST_HAS_DIRENT_H -#endif -#ifndef BOOST_HAS_CLOCK_GETTIME -# define BOOST_HAS_CLOCK_GETTIME -#endif -#ifndef BOOST_HAS_SIGACTION -# define BOOST_HAS_SIGACTION -#endif - - diff --git a/indexlib/boost-compat/config/platform/irix.h b/indexlib/boost-compat/config/platform/irix.h new file mode 100644 index 00000000..aeae49c8 --- /dev/null +++ b/indexlib/boost-compat/config/platform/irix.h @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +// See http://www.boost.org for most recent version. + +// SGI Irix specific config options: + +#define BOOST_PLATFORM "SGI Irix" + +#define BOOST_NO_SWPRINTF +// +// these are not auto detected by POSIX feature tests: +// +#define BOOST_HAS_GETTIMEOFDAY +#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE + +#ifdef __GNUC__ + // GNU C on IRIX does not support threads (checked up to gcc 3.3) +# define BOOST_DISABLE_THREADS +#endif + +// boilerplate code: +#define BOOST_HAS_UNISTD_H +#include + + + diff --git a/indexlib/boost-compat/config/platform/irix.hpp b/indexlib/boost-compat/config/platform/irix.hpp deleted file mode 100644 index aeae49c8..00000000 --- a/indexlib/boost-compat/config/platform/irix.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -// See http://www.boost.org for most recent version. - -// SGI Irix specific config options: - -#define BOOST_PLATFORM "SGI Irix" - -#define BOOST_NO_SWPRINTF -// -// these are not auto detected by POSIX feature tests: -// -#define BOOST_HAS_GETTIMEOFDAY -#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE - -#ifdef __GNUC__ - // GNU C on IRIX does not support threads (checked up to gcc 3.3) -# define BOOST_DISABLE_THREADS -#endif - -// boilerplate code: -#define BOOST_HAS_UNISTD_H -#include - - - diff --git a/indexlib/boost-compat/config/platform/linux.h b/indexlib/boost-compat/config/platform/linux.h new file mode 100644 index 00000000..51ae1334 --- /dev/null +++ b/indexlib/boost-compat/config/platform/linux.h @@ -0,0 +1,98 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// linux specific config options: + +#define BOOST_PLATFORM "linux" + +// make sure we have __GLIBC_PREREQ if available at all +#include + +// +// added to glibc 2.1.1 +// We can only test for 2.1 though: +// +#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))) + // defines int64_t unconditionally, but defines + // int64_t only if __GNUC__. Thus, assume a fully usable + // only when using GCC. +# if defined __GNUC__ +# define BOOST_HAS_STDINT_H +# endif +#endif + +#if defined(__LIBCOMO__) + // + // como on linux doesn't have std:: c functions: + // NOTE: versions of libcomo prior to beta28 have octal version numbering, + // e.g. version 25 is 21 (dec) + // +# if __LIBCOMO_VERSION__ <= 20 +# define BOOST_NO_STDC_NAMESPACE +# endif + +# if __LIBCOMO_VERSION__ <= 21 +# define BOOST_NO_SWPRINTF +# endif + +#endif + +// +// If glibc is past version 2 then we definitely have +// gettimeofday, earlier versions may or may not have it: +// +#if defined(__GLIBC__) && (__GLIBC__ >= 2) +# define BOOST_HAS_GETTIMEOFDAY +#endif + +#ifdef __USE_POSIX199309 +# define BOOST_HAS_NANOSLEEP +#endif + +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +// __GLIBC_PREREQ is available since 2.1.2 + + // swprintf is available since glibc 2.2.0 +# if !__GLIBC_PREREQ(2,2) || (!defined(__USE_ISOC99) && !defined(__USE_UNIX98)) +# define BOOST_NO_SWPRINTF +# endif +#else +# define BOOST_NO_SWPRINTF +#endif + +// boilerplate code: +#define BOOST_HAS_UNISTD_H +#include + +#ifndef __GNUC__ +// +// if the compiler is not gcc we still need to be able to parse +// the GNU system headers, some of which (mainly ) +// use GNU specific extensions: +// +# ifndef __extension__ +# define __extension__ +# endif +# ifndef __const__ +# define __const__ const +# endif +# ifndef __volatile__ +# define __volatile__ volatile +# endif +# ifndef __signed__ +# define __signed__ signed +# endif +# ifndef __typeof__ +# define __typeof__ typeof +# endif +# ifndef __inline__ +# define __inline__ inline +# endif +#endif + + diff --git a/indexlib/boost-compat/config/platform/linux.hpp b/indexlib/boost-compat/config/platform/linux.hpp deleted file mode 100644 index 51ae1334..00000000 --- a/indexlib/boost-compat/config/platform/linux.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// linux specific config options: - -#define BOOST_PLATFORM "linux" - -// make sure we have __GLIBC_PREREQ if available at all -#include - -// -// added to glibc 2.1.1 -// We can only test for 2.1 though: -// -#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))) - // defines int64_t unconditionally, but defines - // int64_t only if __GNUC__. Thus, assume a fully usable - // only when using GCC. -# if defined __GNUC__ -# define BOOST_HAS_STDINT_H -# endif -#endif - -#if defined(__LIBCOMO__) - // - // como on linux doesn't have std:: c functions: - // NOTE: versions of libcomo prior to beta28 have octal version numbering, - // e.g. version 25 is 21 (dec) - // -# if __LIBCOMO_VERSION__ <= 20 -# define BOOST_NO_STDC_NAMESPACE -# endif - -# if __LIBCOMO_VERSION__ <= 21 -# define BOOST_NO_SWPRINTF -# endif - -#endif - -// -// If glibc is past version 2 then we definitely have -// gettimeofday, earlier versions may or may not have it: -// -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -# define BOOST_HAS_GETTIMEOFDAY -#endif - -#ifdef __USE_POSIX199309 -# define BOOST_HAS_NANOSLEEP -#endif - -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) -// __GLIBC_PREREQ is available since 2.1.2 - - // swprintf is available since glibc 2.2.0 -# if !__GLIBC_PREREQ(2,2) || (!defined(__USE_ISOC99) && !defined(__USE_UNIX98)) -# define BOOST_NO_SWPRINTF -# endif -#else -# define BOOST_NO_SWPRINTF -#endif - -// boilerplate code: -#define BOOST_HAS_UNISTD_H -#include - -#ifndef __GNUC__ -// -// if the compiler is not gcc we still need to be able to parse -// the GNU system headers, some of which (mainly ) -// use GNU specific extensions: -// -# ifndef __extension__ -# define __extension__ -# endif -# ifndef __const__ -# define __const__ const -# endif -# ifndef __volatile__ -# define __volatile__ volatile -# endif -# ifndef __signed__ -# define __signed__ signed -# endif -# ifndef __typeof__ -# define __typeof__ typeof -# endif -# ifndef __inline__ -# define __inline__ inline -# endif -#endif - - diff --git a/indexlib/boost-compat/config/platform/macos.h b/indexlib/boost-compat/config/platform/macos.h new file mode 100644 index 00000000..3a5f4130 --- /dev/null +++ b/indexlib/boost-compat/config/platform/macos.h @@ -0,0 +1,68 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001 - 2002. +// (C) Copyright Bill Kempf 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Mac OS specific config options: + +#define BOOST_PLATFORM "Mac OS" + +#if __MACH__ && !defined(_MSL_USING_MSL_C) + +// Using the Mac OS X system BSD-style C library. + +# ifndef BOOST_HAS_UNISTD_H +# define BOOST_HAS_UNISTD_H +# endif +// boilerplate code: +# ifndef TARGET_CARBON +# include +# endif +# ifndef BOOST_HAS_STDINT_H +# define BOOST_HAS_STDINT_H +# endif + +// +// BSD runtime has pthreads, sigaction, sched_yield and gettimeofday, +// of these only pthreads are advertised in , so set the +// other options explicitly: +// +# define BOOST_HAS_SCHED_YIELD +# define BOOST_HAS_GETTIMEOFDAY +# define BOOST_HAS_SIGACTION + +# if (__GNUC__ < 3) && !defined( __APPLE_CC__) + +// GCC strange "ignore std" mode works better if you pretend everything +// is in the std namespace, for the most part. + +# define BOOST_NO_STDC_NAMESPACE +# endif + +#else + +// Using the MSL C library. + +// We will eventually support threads in non-Carbon builds, but we do +// not support this yet. +# if TARGET_CARBON + +# define BOOST_HAS_MPTASKS + +// The MP task implementation of Boost Threads aims to replace MP-unsafe +// parts of the MSL, so we turn on threads unconditionally. +# define BOOST_HAS_THREADS + +// The remote call manager depends on this. +# define BOOST_BIND_ENABLE_PASCAL + +# endif + +#endif + + + diff --git a/indexlib/boost-compat/config/platform/macos.hpp b/indexlib/boost-compat/config/platform/macos.hpp deleted file mode 100644 index 3a5f4130..00000000 --- a/indexlib/boost-compat/config/platform/macos.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001 - 2002. -// (C) Copyright Bill Kempf 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Mac OS specific config options: - -#define BOOST_PLATFORM "Mac OS" - -#if __MACH__ && !defined(_MSL_USING_MSL_C) - -// Using the Mac OS X system BSD-style C library. - -# ifndef BOOST_HAS_UNISTD_H -# define BOOST_HAS_UNISTD_H -# endif -// boilerplate code: -# ifndef TARGET_CARBON -# include -# endif -# ifndef BOOST_HAS_STDINT_H -# define BOOST_HAS_STDINT_H -# endif - -// -// BSD runtime has pthreads, sigaction, sched_yield and gettimeofday, -// of these only pthreads are advertised in , so set the -// other options explicitly: -// -# define BOOST_HAS_SCHED_YIELD -# define BOOST_HAS_GETTIMEOFDAY -# define BOOST_HAS_SIGACTION - -# if (__GNUC__ < 3) && !defined( __APPLE_CC__) - -// GCC strange "ignore std" mode works better if you pretend everything -// is in the std namespace, for the most part. - -# define BOOST_NO_STDC_NAMESPACE -# endif - -#else - -// Using the MSL C library. - -// We will eventually support threads in non-Carbon builds, but we do -// not support this yet. -# if TARGET_CARBON - -# define BOOST_HAS_MPTASKS - -// The MP task implementation of Boost Threads aims to replace MP-unsafe -// parts of the MSL, so we turn on threads unconditionally. -# define BOOST_HAS_THREADS - -// The remote call manager depends on this. -# define BOOST_BIND_ENABLE_PASCAL - -# endif - -#endif - - - diff --git a/indexlib/boost-compat/config/platform/solaris.h b/indexlib/boost-compat/config/platform/solaris.h new file mode 100644 index 00000000..700dc3ce --- /dev/null +++ b/indexlib/boost-compat/config/platform/solaris.h @@ -0,0 +1,21 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// sun specific config options: + +#define BOOST_PLATFORM "Sun Solaris" + +#define BOOST_HAS_GETTIMEOFDAY + +// boilerplate code: +#define BOOST_HAS_UNISTD_H +#include + + + + diff --git a/indexlib/boost-compat/config/platform/solaris.hpp b/indexlib/boost-compat/config/platform/solaris.hpp deleted file mode 100644 index 700dc3ce..00000000 --- a/indexlib/boost-compat/config/platform/solaris.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// sun specific config options: - -#define BOOST_PLATFORM "Sun Solaris" - -#define BOOST_HAS_GETTIMEOFDAY - -// boilerplate code: -#define BOOST_HAS_UNISTD_H -#include - - - - diff --git a/indexlib/boost-compat/config/platform/win32.h b/indexlib/boost-compat/config/platform/win32.h new file mode 100644 index 00000000..548bff28 --- /dev/null +++ b/indexlib/boost-compat/config/platform/win32.h @@ -0,0 +1,50 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Bill Kempf 2001. +// (C) Copyright Aleksey Gurtovoy 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Win32 specific config options: + +#define BOOST_PLATFORM "Win32" + +#if defined(__GNUC__) && !defined(BOOST_NO_SWPRINTF) +# define BOOST_NO_SWPRINTF +#endif + +#if !defined(__GNUC__) && !defined(BOOST_HAS_DECLSPEC) +# define BOOST_HAS_DECLSPEC +#endif + +#if defined(__MINGW32__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))) +# define BOOST_HAS_STDINT_H +# define __STDC_LIMIT_MACROS +#endif + +// +// Win32 will normally be using native Win32 threads, +// but there is a pthread library avaliable as an option, +// we used to disable this when BOOST_DISABLE_WIN32 was +// defined but no longer - this should allow some +// files to be compiled in strict mode - while maintaining +// a consistent setting of BOOST_HAS_THREADS across +// all translation units (needed for shared_ptr etc). +// + +#ifdef _WIN32_WCE +# define BOOST_NO_ANSI_APIS +#endif + +#ifndef BOOST_HAS_PTHREADS +# define BOOST_HAS_WINTHREADS +#endif + +#ifndef BOOST_DISABLE_WIN32 +// WEK: Added +#define BOOST_HAS_FTIME +#define BOOST_WINDOWS 1 + +#endif diff --git a/indexlib/boost-compat/config/platform/win32.hpp b/indexlib/boost-compat/config/platform/win32.hpp deleted file mode 100644 index 548bff28..00000000 --- a/indexlib/boost-compat/config/platform/win32.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Bill Kempf 2001. -// (C) Copyright Aleksey Gurtovoy 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Win32 specific config options: - -#define BOOST_PLATFORM "Win32" - -#if defined(__GNUC__) && !defined(BOOST_NO_SWPRINTF) -# define BOOST_NO_SWPRINTF -#endif - -#if !defined(__GNUC__) && !defined(BOOST_HAS_DECLSPEC) -# define BOOST_HAS_DECLSPEC -#endif - -#if defined(__MINGW32__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))) -# define BOOST_HAS_STDINT_H -# define __STDC_LIMIT_MACROS -#endif - -// -// Win32 will normally be using native Win32 threads, -// but there is a pthread library avaliable as an option, -// we used to disable this when BOOST_DISABLE_WIN32 was -// defined but no longer - this should allow some -// files to be compiled in strict mode - while maintaining -// a consistent setting of BOOST_HAS_THREADS across -// all translation units (needed for shared_ptr etc). -// - -#ifdef _WIN32_WCE -# define BOOST_NO_ANSI_APIS -#endif - -#ifndef BOOST_HAS_PTHREADS -# define BOOST_HAS_WINTHREADS -#endif - -#ifndef BOOST_DISABLE_WIN32 -// WEK: Added -#define BOOST_HAS_FTIME -#define BOOST_WINDOWS 1 - -#endif diff --git a/indexlib/boost-compat/config/posix_features.h b/indexlib/boost-compat/config/posix_features.h new file mode 100644 index 00000000..4afb476b --- /dev/null +++ b/indexlib/boost-compat/config/posix_features.h @@ -0,0 +1,87 @@ +// (C) Copyright John Maddock 2001 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +// See http://www.boost.org for most recent version. + +// All POSIX feature tests go in this file, +// Note that we test _POSIX_C_SOURCE and _XOPEN_SOURCE as well +// _POSIX_VERSION and _XOPEN_VERSION: on some systems POSIX API's +// may be present but none-functional unless _POSIX_C_SOURCE and +// _XOPEN_SOURCE have been defined to the right value (it's up +// to the user to do this *before* including any header, although +// in most cases the compiler will do this for you). + +# if defined(BOOST_HAS_UNISTD_H) +# include + + // XOpen has , but is this the correct version check? +# if defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 3) +# define BOOST_HAS_NL_TYPES_H +# endif + + // POSIX version 6 requires +# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200100) +# define BOOST_HAS_STDINT_H +# endif + + // POSIX version 2 requires +# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199009L) +# define BOOST_HAS_DIRENT_H +# endif + + // POSIX version 3 requires to have sigaction: +# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199506L) +# define BOOST_HAS_SIGACTION +# endif + // POSIX defines _POSIX_THREADS > 0 for pthread support, + // however some platforms define _POSIX_THREADS without + // a value, hence the (_POSIX_THREADS+0 >= 0) check. + // Strictly speaking this may catch platforms with a + // non-functioning stub , but such occurrences should + // occur very rarely if at all. +# if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) && !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_MPTASKS) +# define BOOST_HAS_PTHREADS +# endif + + // BOOST_HAS_NANOSLEEP: + // This is predicated on _POSIX_TIMERS or _XOPEN_REALTIME: +# if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0)) \ + || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0)) +# define BOOST_HAS_NANOSLEEP +# endif + + // BOOST_HAS_CLOCK_GETTIME: + // This is predicated on _POSIX_TIMERS (also on _XOPEN_REALTIME + // but at least one platform - linux - defines that flag without + // defining clock_gettime): +# if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0)) +# define BOOST_HAS_CLOCK_GETTIME +# endif + + // BOOST_HAS_SCHED_YIELD: + // This is predicated on _POSIX_PRIORITY_SCHEDULING or + // on _POSIX_THREAD_PRIORITY_SCHEDULING or on _XOPEN_REALTIME. +# if defined(_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING+0 > 0)\ + || (defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING+0 > 0))\ + || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0)) +# define BOOST_HAS_SCHED_YIELD +# endif + + // BOOST_HAS_GETTIMEOFDAY: + // BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE: + // These are predicated on _XOPEN_VERSION, and appears to be first released + // in issue 4, version 2 (_XOPEN_VERSION > 500). +# if defined(_XOPEN_VERSION) && (_XOPEN_VERSION+0 >= 500) +# define BOOST_HAS_GETTIMEOFDAY +# if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE+0 >= 500) +# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +# endif +# endif + +# endif + + + diff --git a/indexlib/boost-compat/config/posix_features.hpp b/indexlib/boost-compat/config/posix_features.hpp deleted file mode 100644 index 4afb476b..00000000 --- a/indexlib/boost-compat/config/posix_features.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -// See http://www.boost.org for most recent version. - -// All POSIX feature tests go in this file, -// Note that we test _POSIX_C_SOURCE and _XOPEN_SOURCE as well -// _POSIX_VERSION and _XOPEN_VERSION: on some systems POSIX API's -// may be present but none-functional unless _POSIX_C_SOURCE and -// _XOPEN_SOURCE have been defined to the right value (it's up -// to the user to do this *before* including any header, although -// in most cases the compiler will do this for you). - -# if defined(BOOST_HAS_UNISTD_H) -# include - - // XOpen has , but is this the correct version check? -# if defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 3) -# define BOOST_HAS_NL_TYPES_H -# endif - - // POSIX version 6 requires -# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200100) -# define BOOST_HAS_STDINT_H -# endif - - // POSIX version 2 requires -# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199009L) -# define BOOST_HAS_DIRENT_H -# endif - - // POSIX version 3 requires to have sigaction: -# if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199506L) -# define BOOST_HAS_SIGACTION -# endif - // POSIX defines _POSIX_THREADS > 0 for pthread support, - // however some platforms define _POSIX_THREADS without - // a value, hence the (_POSIX_THREADS+0 >= 0) check. - // Strictly speaking this may catch platforms with a - // non-functioning stub , but such occurrences should - // occur very rarely if at all. -# if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) && !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_MPTASKS) -# define BOOST_HAS_PTHREADS -# endif - - // BOOST_HAS_NANOSLEEP: - // This is predicated on _POSIX_TIMERS or _XOPEN_REALTIME: -# if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0)) \ - || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0)) -# define BOOST_HAS_NANOSLEEP -# endif - - // BOOST_HAS_CLOCK_GETTIME: - // This is predicated on _POSIX_TIMERS (also on _XOPEN_REALTIME - // but at least one platform - linux - defines that flag without - // defining clock_gettime): -# if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0)) -# define BOOST_HAS_CLOCK_GETTIME -# endif - - // BOOST_HAS_SCHED_YIELD: - // This is predicated on _POSIX_PRIORITY_SCHEDULING or - // on _POSIX_THREAD_PRIORITY_SCHEDULING or on _XOPEN_REALTIME. -# if defined(_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING+0 > 0)\ - || (defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING+0 > 0))\ - || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0)) -# define BOOST_HAS_SCHED_YIELD -# endif - - // BOOST_HAS_GETTIMEOFDAY: - // BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE: - // These are predicated on _XOPEN_VERSION, and appears to be first released - // in issue 4, version 2 (_XOPEN_VERSION > 500). -# if defined(_XOPEN_VERSION) && (_XOPEN_VERSION+0 >= 500) -# define BOOST_HAS_GETTIMEOFDAY -# if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE+0 >= 500) -# define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -# endif -# endif - -# endif - - - diff --git a/indexlib/boost-compat/config/requires_threads.h b/indexlib/boost-compat/config/requires_threads.h new file mode 100644 index 00000000..03259ae9 --- /dev/null +++ b/indexlib/boost-compat/config/requires_threads.h @@ -0,0 +1,92 @@ +// (C) Copyright John Maddock 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_CONFIG_REQUIRES_THREADS_H +#define BOOST_CONFIG_REQUIRES_THREADS_H + +#ifndef BOOST_CONFIG_H +# include +#endif + +#if defined(BOOST_DISABLE_THREADS) + +// +// special case to handle versions of gcc which don't currently support threads: +// +#if defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC_MINOR__ <= 3) || !defined(BOOST_STRICT_CONFIG)) +// +// this is checked up to gcc 3.3: +// +#if defined(__sgi) || defined(__hpux) +# error "Multi-threaded programs are not supported by gcc on HPUX or Irix (last checked with gcc 3.3)" +#endif + +#endif + +# error "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS" + +#elif !defined(BOOST_HAS_THREADS) + +# if defined __COMO__ +// Comeau C++ +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -D_MT (Windows) or -D_REENTRANT (Unix)" + +#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) +// Intel +#ifdef _WIN32 +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd" +#else +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -openmp" +#endif + +# elif defined __GNUC__ +// GNU C++: +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" + +#elif defined __sgi +// SGI MIPSpro C++ +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -D_SGI_MP_SOURCE" + +#elif defined __DECCXX +// Compaq Tru64 Unix cxx +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread" + +#elif defined __BORLANDC__ +// Borland +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -tWM" + +#elif defined __MWERKS__ +// Metrowerks CodeWarrior +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either -runtime sm, -runtime smd, -runtime dm, or -runtime dmd" + +#elif defined __SUNPRO_CC +// Sun Workshop Compiler C++ +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -mt" + +#elif defined __HP_aCC +// HP aCC +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -mt" + +#elif defined(__IBMCPP__) +// IBM Visual Age +# error "Compiler threading support is not turned on. Please compile the code with the xlC_r compiler" + +#elif defined _MSC_VER +// Microsoft Visual C++ +// +// Must remain the last #elif since some other vendors (Metrowerks, for +// example) also #define _MSC_VER +# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd" + +#else + +# error "Compiler threading support is not turned on. Please consult your compiler's documentation for the appropriate options to use" + +#endif // compilers + +#endif // BOOST_HAS_THREADS + +#endif // BOOST_CONFIG_REQUIRES_THREADS_H diff --git a/indexlib/boost-compat/config/requires_threads.hpp b/indexlib/boost-compat/config/requires_threads.hpp deleted file mode 100644 index cfaff230..00000000 --- a/indexlib/boost-compat/config/requires_threads.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// (C) Copyright John Maddock 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_CONFIG_REQUIRES_THREADS_HPP -#define BOOST_CONFIG_REQUIRES_THREADS_HPP - -#ifndef BOOST_CONFIG_HPP -# include -#endif - -#if defined(BOOST_DISABLE_THREADS) - -// -// special case to handle versions of gcc which don't currently support threads: -// -#if defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC_MINOR__ <= 3) || !defined(BOOST_STRICT_CONFIG)) -// -// this is checked up to gcc 3.3: -// -#if defined(__sgi) || defined(__hpux) -# error "Multi-threaded programs are not supported by gcc on HPUX or Irix (last checked with gcc 3.3)" -#endif - -#endif - -# error "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS" - -#elif !defined(BOOST_HAS_THREADS) - -# if defined __COMO__ -// Comeau C++ -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -D_MT (Windows) or -D_REENTRANT (Unix)" - -#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) -// Intel -#ifdef _WIN32 -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd" -#else -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -openmp" -#endif - -# elif defined __GNUC__ -// GNU C++: -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" - -#elif defined __sgi -// SGI MIPSpro C++ -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -D_SGI_MP_SOURCE" - -#elif defined __DECCXX -// Compaq Tru64 Unix cxx -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread" - -#elif defined __BORLANDC__ -// Borland -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -tWM" - -#elif defined __MWERKS__ -// Metrowerks CodeWarrior -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either -runtime sm, -runtime smd, -runtime dm, or -runtime dmd" - -#elif defined __SUNPRO_CC -// Sun Workshop Compiler C++ -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -mt" - -#elif defined __HP_aCC -// HP aCC -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -mt" - -#elif defined(__IBMCPP__) -// IBM Visual Age -# error "Compiler threading support is not turned on. Please compile the code with the xlC_r compiler" - -#elif defined _MSC_VER -// Microsoft Visual C++ -// -// Must remain the last #elif since some other vendors (Metrowerks, for -// example) also #define _MSC_VER -# error "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd" - -#else - -# error "Compiler threading support is not turned on. Please consult your compiler's documentation for the appropriate options to use" - -#endif // compilers - -#endif // BOOST_HAS_THREADS - -#endif // BOOST_CONFIG_REQUIRES_THREADS_HPP diff --git a/indexlib/boost-compat/config/select_compiler_config.h b/indexlib/boost-compat/config/select_compiler_config.h new file mode 100644 index 00000000..3453f1a3 --- /dev/null +++ b/indexlib/boost-compat/config/select_compiler_config.h @@ -0,0 +1,83 @@ +// Boost compiler configuration selection header file + +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Martin Wille 2003. +// (C) Copyright Guillaume Melquiond 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// locate which compiler we are using and define +// BOOST_COMPILER_CONFIG as needed: + +# if defined __COMO__ +// Comeau C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/comeau.hpp" + +#elif defined __DMC__ +// Digital Mars C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/digitalmars.hpp" + +#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) +// Intel +# define BOOST_COMPILER_CONFIG "boost/config/compiler/intel.hpp" + +# elif defined __GNUC__ +// GNU C++: +# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp" + +#elif defined __KCC +// Kai C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/kai.hpp" + +#elif defined __sgi +// SGI MIPSpro C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/sgi_mipspro.hpp" + +#elif defined __DECCXX +// Compaq Tru64 Unix cxx +# define BOOST_COMPILER_CONFIG "boost/config/compiler/compaq_cxx.hpp" + +#elif defined __ghs +// Greenhills C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/greenhills.hpp" + +#elif defined __BORLANDC__ +// Borland +# define BOOST_COMPILER_CONFIG "boost/config/compiler/borland.hpp" + +#elif defined __MWERKS__ +// Metrowerks CodeWarrior +# define BOOST_COMPILER_CONFIG "boost/config/compiler/metrowerks.hpp" + +#elif defined __SUNPRO_CC +// Sun Workshop Compiler C++ +# define BOOST_COMPILER_CONFIG "boost/config/compiler/sunpro_cc.hpp" + +#elif defined __HP_aCC +// HP aCC +# define BOOST_COMPILER_CONFIG "boost/config/compiler/hp_acc.hpp" + +#elif defined(__MRC__) || defined(__SC__) +// MPW MrCpp or SCpp +# define BOOST_COMPILER_CONFIG "boost/config/compiler/mpw.hpp" + +#elif defined(__IBMCPP__) +// IBM Visual Age +# define BOOST_COMPILER_CONFIG "boost/config/compiler/vacpp.hpp" + +#elif defined _MSC_VER +// Microsoft Visual C++ +// +// Must remain the last #elif since some other vendors (Metrowerks, for +// example) also #define _MSC_VER +# define BOOST_COMPILER_CONFIG "boost/config/compiler/visualc.hpp" + +#elif defined (BOOST_ASSERT_CONFIG) +// this must come last - generate an error if we don't +// recognise the compiler: +# error "Unknown compiler - please configure (http://www.boost.org/libs/config/config.htm#configuring) and report the results to the main boost mailing list (http://www.boost.org/more/mailing_lists.htm#main)" + +#endif diff --git a/indexlib/boost-compat/config/select_compiler_config.hpp b/indexlib/boost-compat/config/select_compiler_config.hpp deleted file mode 100644 index 3453f1a3..00000000 --- a/indexlib/boost-compat/config/select_compiler_config.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Boost compiler configuration selection header file - -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Martin Wille 2003. -// (C) Copyright Guillaume Melquiond 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// locate which compiler we are using and define -// BOOST_COMPILER_CONFIG as needed: - -# if defined __COMO__ -// Comeau C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/comeau.hpp" - -#elif defined __DMC__ -// Digital Mars C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/digitalmars.hpp" - -#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) -// Intel -# define BOOST_COMPILER_CONFIG "boost/config/compiler/intel.hpp" - -# elif defined __GNUC__ -// GNU C++: -# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp" - -#elif defined __KCC -// Kai C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/kai.hpp" - -#elif defined __sgi -// SGI MIPSpro C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/sgi_mipspro.hpp" - -#elif defined __DECCXX -// Compaq Tru64 Unix cxx -# define BOOST_COMPILER_CONFIG "boost/config/compiler/compaq_cxx.hpp" - -#elif defined __ghs -// Greenhills C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/greenhills.hpp" - -#elif defined __BORLANDC__ -// Borland -# define BOOST_COMPILER_CONFIG "boost/config/compiler/borland.hpp" - -#elif defined __MWERKS__ -// Metrowerks CodeWarrior -# define BOOST_COMPILER_CONFIG "boost/config/compiler/metrowerks.hpp" - -#elif defined __SUNPRO_CC -// Sun Workshop Compiler C++ -# define BOOST_COMPILER_CONFIG "boost/config/compiler/sunpro_cc.hpp" - -#elif defined __HP_aCC -// HP aCC -# define BOOST_COMPILER_CONFIG "boost/config/compiler/hp_acc.hpp" - -#elif defined(__MRC__) || defined(__SC__) -// MPW MrCpp or SCpp -# define BOOST_COMPILER_CONFIG "boost/config/compiler/mpw.hpp" - -#elif defined(__IBMCPP__) -// IBM Visual Age -# define BOOST_COMPILER_CONFIG "boost/config/compiler/vacpp.hpp" - -#elif defined _MSC_VER -// Microsoft Visual C++ -// -// Must remain the last #elif since some other vendors (Metrowerks, for -// example) also #define _MSC_VER -# define BOOST_COMPILER_CONFIG "boost/config/compiler/visualc.hpp" - -#elif defined (BOOST_ASSERT_CONFIG) -// this must come last - generate an error if we don't -// recognise the compiler: -# error "Unknown compiler - please configure (http://www.boost.org/libs/config/config.htm#configuring) and report the results to the main boost mailing list (http://www.boost.org/more/mailing_lists.htm#main)" - -#endif diff --git a/indexlib/boost-compat/config/select_platform_config.h b/indexlib/boost-compat/config/select_platform_config.h new file mode 100644 index 00000000..5699b2a2 --- /dev/null +++ b/indexlib/boost-compat/config/select_platform_config.h @@ -0,0 +1,86 @@ +// Boost compiler configuration selection header file + +// (C) Copyright John Maddock 2001 - 2002. +// (C) Copyright Jens Maurer 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// locate which platform we are on and define BOOST_PLATFORM_CONFIG as needed. +// Note that we define the headers to include using "header_name" not +// in order to prevent macro expansion within the header +// name (for example "linux" is a macro on linux systems). + +#if defined(linux) || defined(__linux) || defined(__linux__) +// linux: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/linux.hpp" + +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +// BSD: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/bsd.hpp" + +#elif defined(sun) || defined(__sun) +// solaris: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/solaris.hpp" + +#elif defined(__sgi) +// SGI Irix: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/irix.hpp" + +#elif defined(__hpux) +// hp unix: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/hpux.hpp" + +#elif defined(__CYGWIN__) +// cygwin is not win32: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/cygwin.hpp" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +// win32: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/win32.hpp" + +#elif defined(__BEOS__) +// BeOS +# define BOOST_PLATFORM_CONFIG "boost/config/platform/beos.hpp" + +#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) +// MacOS +# define BOOST_PLATFORM_CONFIG "boost/config/platform/macos.hpp" + +#elif defined(__IBMCPP__) +// IBM +# define BOOST_PLATFORM_CONFIG "boost/config/platform/aix.hpp" + +#elif defined(__amigaos__) +// AmigaOS +# define BOOST_PLATFORM_CONFIG "boost/config/platform/amigaos.hpp" + +#else + +# if defined(unix) \ + || defined(__unix) \ + || defined(_XOPEN_SOURCE) \ + || defined(_POSIX_SOURCE) + + // generic unix platform: + +# ifndef BOOST_HAS_UNISTD_H +# define BOOST_HAS_UNISTD_H +# endif + +# include + +# endif + +# if defined (BOOST_ASSERT_CONFIG) + // this must come last - generate an error if we don't + // recognise the platform: +# error "Unknown platform - please configure and report the results to boost.org" +# endif + +#endif + + + diff --git a/indexlib/boost-compat/config/select_platform_config.hpp b/indexlib/boost-compat/config/select_platform_config.hpp deleted file mode 100644 index 5699b2a2..00000000 --- a/indexlib/boost-compat/config/select_platform_config.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Boost compiler configuration selection header file - -// (C) Copyright John Maddock 2001 - 2002. -// (C) Copyright Jens Maurer 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// locate which platform we are on and define BOOST_PLATFORM_CONFIG as needed. -// Note that we define the headers to include using "header_name" not -// in order to prevent macro expansion within the header -// name (for example "linux" is a macro on linux systems). - -#if defined(linux) || defined(__linux) || defined(__linux__) -// linux: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/linux.hpp" - -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) -// BSD: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/bsd.hpp" - -#elif defined(sun) || defined(__sun) -// solaris: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/solaris.hpp" - -#elif defined(__sgi) -// SGI Irix: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/irix.hpp" - -#elif defined(__hpux) -// hp unix: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/hpux.hpp" - -#elif defined(__CYGWIN__) -// cygwin is not win32: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/cygwin.hpp" - -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -// win32: -# define BOOST_PLATFORM_CONFIG "boost/config/platform/win32.hpp" - -#elif defined(__BEOS__) -// BeOS -# define BOOST_PLATFORM_CONFIG "boost/config/platform/beos.hpp" - -#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) -// MacOS -# define BOOST_PLATFORM_CONFIG "boost/config/platform/macos.hpp" - -#elif defined(__IBMCPP__) -// IBM -# define BOOST_PLATFORM_CONFIG "boost/config/platform/aix.hpp" - -#elif defined(__amigaos__) -// AmigaOS -# define BOOST_PLATFORM_CONFIG "boost/config/platform/amigaos.hpp" - -#else - -# if defined(unix) \ - || defined(__unix) \ - || defined(_XOPEN_SOURCE) \ - || defined(_POSIX_SOURCE) - - // generic unix platform: - -# ifndef BOOST_HAS_UNISTD_H -# define BOOST_HAS_UNISTD_H -# endif - -# include - -# endif - -# if defined (BOOST_ASSERT_CONFIG) - // this must come last - generate an error if we don't - // recognise the platform: -# error "Unknown platform - please configure and report the results to boost.org" -# endif - -#endif - - - diff --git a/indexlib/boost-compat/config/select_stdlib_config.h b/indexlib/boost-compat/config/select_stdlib_config.h new file mode 100644 index 00000000..b7bf5914 --- /dev/null +++ b/indexlib/boost-compat/config/select_stdlib_config.h @@ -0,0 +1,68 @@ +// Boost compiler configuration selection header file + +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001 - 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +// See http://www.boost.org for most recent version. + +// locate which std lib we are using and define BOOST_STDLIB_CONFIG as needed: + +// we need to include a std lib header here in order to detect which +// library is in use, use as it's about the smallest +// of the std lib headers - do not rely on this header being included - +// users can short-circuit this header if they know whose std lib +// they are using. + +#include + +#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) +// STLPort library; this _must_ come first, otherwise since +// STLport typically sits on top of some other library, we +// can end up detecting that first rather than STLport: +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/stlport.hpp" + +#elif defined(__LIBCOMO__) +// Comeau STL: +#define BOOST_STDLIB_CONFIG "boost/config/stdlib/libcomo.hpp" + +#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// Rogue Wave library: +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/roguewave.hpp" + +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +// GNU libstdc++ 3 +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/libstdcpp3.hpp" + +#elif defined(__STL_CONFIG_H) +// generic SGI STL +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/sgi.hpp" + +#elif defined(__MSL_CPP__) +// MSL standard lib: +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/msl.hpp" + +#elif defined(__IBMCPP__) +// take the default VACPP std lib +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/vacpp.hpp" + +#elif defined(MSIPL_COMPILE_H) +// Modena C++ standard library +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/modena.hpp" + +#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) +// Dinkumware Library (this has to appear after any possible replacement libraries): +# define BOOST_STDLIB_CONFIG "boost/config/stdlib/dinkumware.hpp" + +#elif defined (BOOST_ASSERT_CONFIG) +// this must come last - generate an error if we don't +// recognise the library: +# error "Unknown standard library - please configure and report the results to boost.org" + +#endif + + + diff --git a/indexlib/boost-compat/config/select_stdlib_config.hpp b/indexlib/boost-compat/config/select_stdlib_config.hpp deleted file mode 100644 index b7bf5914..00000000 --- a/indexlib/boost-compat/config/select_stdlib_config.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Boost compiler configuration selection header file - -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001 - 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -// See http://www.boost.org for most recent version. - -// locate which std lib we are using and define BOOST_STDLIB_CONFIG as needed: - -// we need to include a std lib header here in order to detect which -// library is in use, use as it's about the smallest -// of the std lib headers - do not rely on this header being included - -// users can short-circuit this header if they know whose std lib -// they are using. - -#include - -#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) -// STLPort library; this _must_ come first, otherwise since -// STLport typically sits on top of some other library, we -// can end up detecting that first rather than STLport: -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/stlport.hpp" - -#elif defined(__LIBCOMO__) -// Comeau STL: -#define BOOST_STDLIB_CONFIG "boost/config/stdlib/libcomo.hpp" - -#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) -// Rogue Wave library: -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/roguewave.hpp" - -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) -// GNU libstdc++ 3 -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/libstdcpp3.hpp" - -#elif defined(__STL_CONFIG_H) -// generic SGI STL -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/sgi.hpp" - -#elif defined(__MSL_CPP__) -// MSL standard lib: -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/msl.hpp" - -#elif defined(__IBMCPP__) -// take the default VACPP std lib -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/vacpp.hpp" - -#elif defined(MSIPL_COMPILE_H) -// Modena C++ standard library -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/modena.hpp" - -#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) -// Dinkumware Library (this has to appear after any possible replacement libraries): -# define BOOST_STDLIB_CONFIG "boost/config/stdlib/dinkumware.hpp" - -#elif defined (BOOST_ASSERT_CONFIG) -// this must come last - generate an error if we don't -// recognise the library: -# error "Unknown standard library - please configure and report the results to boost.org" - -#endif - - - diff --git a/indexlib/boost-compat/config/stdlib/dinkumware.h b/indexlib/boost-compat/config/stdlib/dinkumware.h new file mode 100644 index 00000000..aa214fc1 --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/dinkumware.h @@ -0,0 +1,106 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright David Abrahams 2002. +// (C) Copyright Guillaume Melquiond 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Dinkumware standard library config: + +#if !defined(_YVALS) && !defined(_CPPLIB_VER) +#include +#if !defined(_YVALS) && !defined(_CPPLIB_VER) +#error This is not the Dinkumware lib! +#endif +#endif + + +#if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 306) + // full dinkumware 3.06 and above + // fully conforming provided the compiler supports it: +# if !(defined(_GLOBAL_USING) && (_GLOBAL_USING+0 > 0)) && !defined(__BORLANDC__) && !defined(_STD) && !(defined(__ICC) && (__ICC >= 700)) // can be defined in yvals.h +# define BOOST_NO_STDC_NAMESPACE +# endif +# if !(defined(_HAS_MEMBER_TEMPLATES_REBIND) && (_HAS_MEMBER_TEMPLATES_REBIND+0 > 0)) && !(defined(_MSC_VER) && (_MSC_VER > 1300)) && defined(BOOST_MSVC) +# define BOOST_NO_STD_ALLOCATOR +# endif +# define BOOST_HAS_PARTIAL_STD_ALLOCATOR +# if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) + // if this lib version is set up for vc6 then there is no std::use_facet: +# define BOOST_NO_STD_USE_FACET +# define BOOST_HAS_TWO_ARG_USE_FACET + // C lib functions aren't in namespace std either: +# define BOOST_NO_STDC_NAMESPACE + // and nor is +# define BOOST_NO_EXCEPTION_STD_NAMESPACE +# endif +// There's no numeric_limits support unless _LONGLONG is defined: +# if !defined(_LONGLONG) && (_CPPLIB_VER <= 310) +# define BOOST_NO_MS_INT64_NUMERIC_LIMITS +# endif +// 3.06 appears to have (non-sgi versions of) & , +// and no at all +#else +# define BOOST_MSVC_STD_ITERATOR 1 +# define BOOST_NO_STD_ITERATOR +# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS +# define BOOST_NO_STD_ALLOCATOR +# define BOOST_NO_STDC_NAMESPACE +# define BOOST_NO_STD_USE_FACET +# define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN +# define BOOST_HAS_MACRO_USE_FACET +# ifndef _CPPLIB_VER + // Updated Dinkum library defines this, and provides + // its own min and max definitions. +# define BOOST_NO_STD_MIN_MAX +# define BOOST_NO_MS_INT64_NUMERIC_LIMITS +# endif +#endif + +// +// std extension namespace is stdext for vc7.1 and later, +// the same applies to other compilers that sit on top +// of vc7.1 (Intel and Comeau): +// +#if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(__BORLANDC__) +# define BOOST_STD_EXTENSION_NAMESPACE stdext +#endif + + +#if (defined(_MSC_VER) && (_MSC_VER <= 1300) && !defined(__BORLANDC__)) || !defined(_CPPLIB_VER) || (_CPPLIB_VER < 306) + // if we're using a dinkum lib that's + // been configured for VC6/7 then there is + // no iterator traits (true even for icl) +# define BOOST_NO_STD_ITERATOR_TRAITS +#endif + +#if defined(__ICL) && (__ICL < 800) && defined(_CPPLIB_VER) && (_CPPLIB_VER <= 310) +// Intel C++ chokes over any non-trivial use of +// this may be an overly restrictive define, but regex fails without it: +# define BOOST_NO_STD_LOCALE +#endif + +#ifdef _CPPLIB_VER +# define BOOST_DINKUMWARE_STDLIB _CPPLIB_VER +#else +# define BOOST_DINKUMWARE_STDLIB 1 +#endif + +#ifdef _CPPLIB_VER +# define BOOST_STDLIB "Dinkumware standard library version " BOOST_STRINGIZE(_CPPLIB_VER) +#else +# define BOOST_STDLIB "Dinkumware standard library version 1.x" +#endif + + + + + + + + + diff --git a/indexlib/boost-compat/config/stdlib/dinkumware.hpp b/indexlib/boost-compat/config/stdlib/dinkumware.hpp deleted file mode 100644 index aa214fc1..00000000 --- a/indexlib/boost-compat/config/stdlib/dinkumware.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright David Abrahams 2002. -// (C) Copyright Guillaume Melquiond 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Dinkumware standard library config: - -#if !defined(_YVALS) && !defined(_CPPLIB_VER) -#include -#if !defined(_YVALS) && !defined(_CPPLIB_VER) -#error This is not the Dinkumware lib! -#endif -#endif - - -#if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 306) - // full dinkumware 3.06 and above - // fully conforming provided the compiler supports it: -# if !(defined(_GLOBAL_USING) && (_GLOBAL_USING+0 > 0)) && !defined(__BORLANDC__) && !defined(_STD) && !(defined(__ICC) && (__ICC >= 700)) // can be defined in yvals.h -# define BOOST_NO_STDC_NAMESPACE -# endif -# if !(defined(_HAS_MEMBER_TEMPLATES_REBIND) && (_HAS_MEMBER_TEMPLATES_REBIND+0 > 0)) && !(defined(_MSC_VER) && (_MSC_VER > 1300)) && defined(BOOST_MSVC) -# define BOOST_NO_STD_ALLOCATOR -# endif -# define BOOST_HAS_PARTIAL_STD_ALLOCATOR -# if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) - // if this lib version is set up for vc6 then there is no std::use_facet: -# define BOOST_NO_STD_USE_FACET -# define BOOST_HAS_TWO_ARG_USE_FACET - // C lib functions aren't in namespace std either: -# define BOOST_NO_STDC_NAMESPACE - // and nor is -# define BOOST_NO_EXCEPTION_STD_NAMESPACE -# endif -// There's no numeric_limits support unless _LONGLONG is defined: -# if !defined(_LONGLONG) && (_CPPLIB_VER <= 310) -# define BOOST_NO_MS_INT64_NUMERIC_LIMITS -# endif -// 3.06 appears to have (non-sgi versions of) & , -// and no at all -#else -# define BOOST_MSVC_STD_ITERATOR 1 -# define BOOST_NO_STD_ITERATOR -# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS -# define BOOST_NO_STD_ALLOCATOR -# define BOOST_NO_STDC_NAMESPACE -# define BOOST_NO_STD_USE_FACET -# define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN -# define BOOST_HAS_MACRO_USE_FACET -# ifndef _CPPLIB_VER - // Updated Dinkum library defines this, and provides - // its own min and max definitions. -# define BOOST_NO_STD_MIN_MAX -# define BOOST_NO_MS_INT64_NUMERIC_LIMITS -# endif -#endif - -// -// std extension namespace is stdext for vc7.1 and later, -// the same applies to other compilers that sit on top -// of vc7.1 (Intel and Comeau): -// -#if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(__BORLANDC__) -# define BOOST_STD_EXTENSION_NAMESPACE stdext -#endif - - -#if (defined(_MSC_VER) && (_MSC_VER <= 1300) && !defined(__BORLANDC__)) || !defined(_CPPLIB_VER) || (_CPPLIB_VER < 306) - // if we're using a dinkum lib that's - // been configured for VC6/7 then there is - // no iterator traits (true even for icl) -# define BOOST_NO_STD_ITERATOR_TRAITS -#endif - -#if defined(__ICL) && (__ICL < 800) && defined(_CPPLIB_VER) && (_CPPLIB_VER <= 310) -// Intel C++ chokes over any non-trivial use of -// this may be an overly restrictive define, but regex fails without it: -# define BOOST_NO_STD_LOCALE -#endif - -#ifdef _CPPLIB_VER -# define BOOST_DINKUMWARE_STDLIB _CPPLIB_VER -#else -# define BOOST_DINKUMWARE_STDLIB 1 -#endif - -#ifdef _CPPLIB_VER -# define BOOST_STDLIB "Dinkumware standard library version " BOOST_STRINGIZE(_CPPLIB_VER) -#else -# define BOOST_STDLIB "Dinkumware standard library version 1.x" -#endif - - - - - - - - - diff --git a/indexlib/boost-compat/config/stdlib/libcomo.h b/indexlib/boost-compat/config/stdlib/libcomo.h new file mode 100644 index 00000000..b2c8e440 --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/libcomo.h @@ -0,0 +1,46 @@ +// (C) Copyright John Maddock 2002 - 2003. +// (C) Copyright Jens Maurer 2002 - 2003. +// (C) Copyright Beman Dawes 2002 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Comeau STL: + +#if !defined(__LIBCOMO__) +# include +# if !defined(__LIBCOMO__) +# error "This is not the Comeau STL!" +# endif +#endif + +// +// std::streambuf is non-standard +// NOTE: versions of libcomo prior to beta28 have octal version numbering, +// e.g. version 25 is 21 (dec) +#if __LIBCOMO_VERSION__ <= 22 +# define BOOST_NO_STD_WSTREAMBUF +#endif + +#if (__LIBCOMO_VERSION__ <= 31) && defined(_WIN32) +#define BOOST_NO_SWPRINTF +#endif + +#if __LIBCOMO_VERSION__ >= 31 +# define BOOST_HAS_HASH +# define BOOST_HAS_SLIST +#endif + +// +// Intrinsic type_traits support. +// The SGI STL has it's own __type_traits class, which +// has intrinsic compiler support with SGI's compilers. +// Whatever map SGI style type traits to boost equivalents: +// +#define BOOST_HAS_SGI_TYPE_TRAITS + +#define BOOST_STDLIB "Comeau standard library " BOOST_STRINGIZE(__LIBCOMO_VERSION__) + + diff --git a/indexlib/boost-compat/config/stdlib/libcomo.hpp b/indexlib/boost-compat/config/stdlib/libcomo.hpp deleted file mode 100644 index b2c8e440..00000000 --- a/indexlib/boost-compat/config/stdlib/libcomo.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// (C) Copyright John Maddock 2002 - 2003. -// (C) Copyright Jens Maurer 2002 - 2003. -// (C) Copyright Beman Dawes 2002 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Comeau STL: - -#if !defined(__LIBCOMO__) -# include -# if !defined(__LIBCOMO__) -# error "This is not the Comeau STL!" -# endif -#endif - -// -// std::streambuf is non-standard -// NOTE: versions of libcomo prior to beta28 have octal version numbering, -// e.g. version 25 is 21 (dec) -#if __LIBCOMO_VERSION__ <= 22 -# define BOOST_NO_STD_WSTREAMBUF -#endif - -#if (__LIBCOMO_VERSION__ <= 31) && defined(_WIN32) -#define BOOST_NO_SWPRINTF -#endif - -#if __LIBCOMO_VERSION__ >= 31 -# define BOOST_HAS_HASH -# define BOOST_HAS_SLIST -#endif - -// -// Intrinsic type_traits support. -// The SGI STL has it's own __type_traits class, which -// has intrinsic compiler support with SGI's compilers. -// Whatever map SGI style type traits to boost equivalents: -// -#define BOOST_HAS_SGI_TYPE_TRAITS - -#define BOOST_STDLIB "Comeau standard library " BOOST_STRINGIZE(__LIBCOMO_VERSION__) - - diff --git a/indexlib/boost-compat/config/stdlib/libstdcpp3.h b/indexlib/boost-compat/config/stdlib/libstdcpp3.h new file mode 100644 index 00000000..99e711ce --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/libstdcpp3.h @@ -0,0 +1,51 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Jens Maurer 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// config for libstdc++ v3 +// not much to go in here: + +#ifdef __GLIBCXX__ +#define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCXX__) +#else +#define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCPP__) +#endif + +#if !defined(_GLIBCPP_USE_WCHAR_T) && !defined(_GLIBCXX_USE_WCHAR_T) +# define BOOST_NO_CWCHAR +# define BOOST_NO_CWCTYPE +# define BOOST_NO_STD_WSTRING +# define BOOST_NO_STD_WSTREAMBUF +#endif + +#if defined(__osf__) && !defined(_REENTRANT) && defined(_GLIBCXX_HAVE_GTHR_DEFAULT) +// GCC 3.4 on Tru64 forces the definition of _REENTRANT when any std lib header +// file is included, therefore for consistency we define it here as well. +# define _REENTRANT +#endif + +#ifdef __GLIBCXX__ // gcc 3.4 and greater: +# ifdef _GLIBCXX_HAVE_GTHR_DEFAULT + // + // If the std lib has thread support turned on, then turn it on in Boost + // as well. We do this because some gcc-3.4 std lib headers define _REENTANT + // while others do not... + // +# define BOOST_HAS_THREADS +# else +# define BOOST_DISABLE_THREADS +# endif +#endif + + +#if !defined(_GLIBCPP_USE_LONG_LONG) \ + && !defined(_GLIBCXX_USE_LONG_LONG)\ + && defined(BOOST_HAS_LONG_LONG) +// May have been set by compiler/*.h, but "long long" without library +// support is useless. +# undef BOOST_HAS_LONG_LONG +#endif diff --git a/indexlib/boost-compat/config/stdlib/libstdcpp3.hpp b/indexlib/boost-compat/config/stdlib/libstdcpp3.hpp deleted file mode 100644 index 9774e876..00000000 --- a/indexlib/boost-compat/config/stdlib/libstdcpp3.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Jens Maurer 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// config for libstdc++ v3 -// not much to go in here: - -#ifdef __GLIBCXX__ -#define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCXX__) -#else -#define BOOST_STDLIB "GNU libstdc++ version " BOOST_STRINGIZE(__GLIBCPP__) -#endif - -#if !defined(_GLIBCPP_USE_WCHAR_T) && !defined(_GLIBCXX_USE_WCHAR_T) -# define BOOST_NO_CWCHAR -# define BOOST_NO_CWCTYPE -# define BOOST_NO_STD_WSTRING -# define BOOST_NO_STD_WSTREAMBUF -#endif - -#if defined(__osf__) && !defined(_REENTRANT) && defined(_GLIBCXX_HAVE_GTHR_DEFAULT) -// GCC 3.4 on Tru64 forces the definition of _REENTRANT when any std lib header -// file is included, therefore for consistency we define it here as well. -# define _REENTRANT -#endif - -#ifdef __GLIBCXX__ // gcc 3.4 and greater: -# ifdef _GLIBCXX_HAVE_GTHR_DEFAULT - // - // If the std lib has thread support turned on, then turn it on in Boost - // as well. We do this because some gcc-3.4 std lib headers define _REENTANT - // while others do not... - // -# define BOOST_HAS_THREADS -# else -# define BOOST_DISABLE_THREADS -# endif -#endif - - -#if !defined(_GLIBCPP_USE_LONG_LONG) \ - && !defined(_GLIBCXX_USE_LONG_LONG)\ - && defined(BOOST_HAS_LONG_LONG) -// May have been set by compiler/*.hpp, but "long long" without library -// support is useless. -# undef BOOST_HAS_LONG_LONG -#endif diff --git a/indexlib/boost-compat/config/stdlib/modena.h b/indexlib/boost-compat/config/stdlib/modena.h new file mode 100644 index 00000000..61e31b7d --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/modena.h @@ -0,0 +1,30 @@ +// (C) Copyright Jens Maurer 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Modena C++ standard library (comes with KAI C++) + +#if !defined(MSIPL_COMPILE_H) +# include +# if !defined(__MSIPL_COMPILE_H) +# error "This is not the Modena C++ library!" +# endif +#endif + +#ifndef MSIPL_NL_TYPES +#define BOOST_NO_STD_MESSAGES +#endif + +#ifndef MSIPL_WCHART +#define BOOST_NO_STD_WSTRING +#endif + +#define BOOST_STDLIB "Modena C++ standard library" + + + + + diff --git a/indexlib/boost-compat/config/stdlib/modena.hpp b/indexlib/boost-compat/config/stdlib/modena.hpp deleted file mode 100644 index 61e31b7d..00000000 --- a/indexlib/boost-compat/config/stdlib/modena.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright Jens Maurer 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Modena C++ standard library (comes with KAI C++) - -#if !defined(MSIPL_COMPILE_H) -# include -# if !defined(__MSIPL_COMPILE_H) -# error "This is not the Modena C++ library!" -# endif -#endif - -#ifndef MSIPL_NL_TYPES -#define BOOST_NO_STD_MESSAGES -#endif - -#ifndef MSIPL_WCHART -#define BOOST_NO_STD_WSTRING -#endif - -#define BOOST_STDLIB "Modena C++ standard library" - - - - - diff --git a/indexlib/boost-compat/config/stdlib/msl.h b/indexlib/boost-compat/config/stdlib/msl.h new file mode 100644 index 00000000..f8ad3d9a --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/msl.h @@ -0,0 +1,54 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Darin Adler 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Metrowerks standard library: + +#ifndef __MSL_CPP__ +# include +# ifndef __MSL_CPP__ +# error This is not the MSL standard library! +# endif +#endif + +#if __MSL_CPP__ >= 0x6000 // Pro 6 +# define BOOST_HAS_HASH +# define BOOST_STD_EXTENSION_NAMESPACE Metrowerks +#endif +#define BOOST_HAS_SLIST + +#if __MSL_CPP__ < 0x6209 +# define BOOST_NO_STD_MESSAGES +#endif + +// check C lib version for +#include + +#if defined(__MSL__) && (__MSL__ >= 0x5000) +# define BOOST_HAS_STDINT_H +# if !defined(__PALMOS_TRAPS__) +# define BOOST_HAS_UNISTD_H +# endif + // boilerplate code: +# include +#endif + +#if defined(_MWMT) || _MSL_THREADSAFE +# define BOOST_HAS_THREADS +#endif + + +#define BOOST_STDLIB "Metrowerks Standard Library version " BOOST_STRINGIZE(__MSL_CPP__) + + + + + + + + + diff --git a/indexlib/boost-compat/config/stdlib/msl.hpp b/indexlib/boost-compat/config/stdlib/msl.hpp deleted file mode 100644 index f8ad3d9a..00000000 --- a/indexlib/boost-compat/config/stdlib/msl.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Darin Adler 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Metrowerks standard library: - -#ifndef __MSL_CPP__ -# include -# ifndef __MSL_CPP__ -# error This is not the MSL standard library! -# endif -#endif - -#if __MSL_CPP__ >= 0x6000 // Pro 6 -# define BOOST_HAS_HASH -# define BOOST_STD_EXTENSION_NAMESPACE Metrowerks -#endif -#define BOOST_HAS_SLIST - -#if __MSL_CPP__ < 0x6209 -# define BOOST_NO_STD_MESSAGES -#endif - -// check C lib version for -#include - -#if defined(__MSL__) && (__MSL__ >= 0x5000) -# define BOOST_HAS_STDINT_H -# if !defined(__PALMOS_TRAPS__) -# define BOOST_HAS_UNISTD_H -# endif - // boilerplate code: -# include -#endif - -#if defined(_MWMT) || _MSL_THREADSAFE -# define BOOST_HAS_THREADS -#endif - - -#define BOOST_STDLIB "Metrowerks Standard Library version " BOOST_STRINGIZE(__MSL_CPP__) - - - - - - - - - diff --git a/indexlib/boost-compat/config/stdlib/roguewave.h b/indexlib/boost-compat/config/stdlib/roguewave.h new file mode 100644 index 00000000..ec3d881b --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/roguewave.h @@ -0,0 +1,123 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Jens Maurer 2001. +// (C) Copyright David Abrahams 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Rogue Wave std lib: + +#if !defined(__STD_RWCOMPILER_H__) && !defined(_RWSTD_VER) +# include +# if !defined(__STD_RWCOMPILER_H__) && !defined(_RWSTD_VER) +# error This is not the Rogue Wave standard library +# endif +#endif +// +// figure out a consistent version number: +// +#ifndef _RWSTD_VER +# define BOOST_RWSTD_VER 0x010000 +#elif _RWSTD_VER < 0x010000 +# define BOOST_RWSTD_VER (_RWSTD_VER << 8) +#else +# define BOOST_RWSTD_VER _RWSTD_VER +#endif + +#ifndef _RWSTD_VER +# define BOOST_STDLIB "Rogue Wave standard library version (Unknown version)" +#else +# define BOOST_STDLIB "Rogue Wave standard library version " BOOST_STRINGIZE(_RWSTD_VER) +#endif + +// +// Prior to version 2.2.0 the primary template for std::numeric_limits +// does not have compile time constants, even though specializations of that +// template do: +// +#if BOOST_RWSTD_VER < 0x020200 +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#endif + +// Sun CC 5.5 patch 113817-07 adds long long specialization, but does not change the +// library version number (http://sunsolve6.sun.com/search/document.do?assetkey=1-21-113817): +#if BOOST_RWSTD_VER <= 0x020101 && (!defined(__SUNPRO_CC) || (__SUNPRO_CC < 0x550)) +# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS +# endif + +// +// Borland version of numeric_limits lacks __int64 specialisation: +// +#ifdef __BORLANDC__ +# define BOOST_NO_MS_INT64_NUMERIC_LIMITS +#endif + +// +// No std::iterator if it can't figure out default template args: +// +#if defined(_RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES) || defined(RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES) || (BOOST_RWSTD_VER < 0x020000) +# define BOOST_NO_STD_ITERATOR +#endif + +// +// No iterator traits without partial specialization: +// +#if defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) || defined(RWSTD_NO_CLASS_PARTIAL_SPEC) +# define BOOST_NO_STD_ITERATOR_TRAITS +#endif + +// +// Prior to version 2.0, std::auto_ptr was buggy, and there were no +// new-style iostreams, and no conformant std::allocator: +// +#if (BOOST_RWSTD_VER < 0x020000) +# define BOOST_NO_AUTO_PTR +# define BOOST_NO_STRINGSTREAM +# define BOOST_NO_STD_ALLOCATOR +# define BOOST_NO_STD_LOCALE +#endif + +// +// No template iterator constructors without member template support: +// +#if defined(RWSTD_NO_MEMBER_TEMPLATES) || defined(_RWSTD_NO_MEMBER_TEMPLATES) +# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS +#endif + +// +// RW defines _RWSTD_ALLOCATOR if the allocator is conformant and in use +// (the or _HPACC_ part is a hack - the library seems to define _RWSTD_ALLOCATOR +// on HP aCC systems even though the allocator is in fact broken): +// +#if !defined(_RWSTD_ALLOCATOR) || (defined(__HP_aCC) && __HP_aCC <= 33100) +# define BOOST_NO_STD_ALLOCATOR +#endif + +// +// If we have a std::locale, we still may not have std::use_facet: +// +#if defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE) && !defined(BOOST_NO_STD_LOCALE) +# define BOOST_NO_STD_USE_FACET +# define BOOST_HAS_TWO_ARG_USE_FACET +#endif + +// +// There's no std::distance prior to version 2, or without +// partial specialization support: +// +#if (BOOST_RWSTD_VER < 0x020000) || defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + #define BOOST_NO_STD_DISTANCE +#endif + +// +// Some versions of the rogue wave library don't have assignable +// OutputIterators: +// +#if BOOST_RWSTD_VER < 0x020100 +# define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN +#endif + + + diff --git a/indexlib/boost-compat/config/stdlib/roguewave.hpp b/indexlib/boost-compat/config/stdlib/roguewave.hpp deleted file mode 100644 index ec3d881b..00000000 --- a/indexlib/boost-compat/config/stdlib/roguewave.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Jens Maurer 2001. -// (C) Copyright David Abrahams 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Rogue Wave std lib: - -#if !defined(__STD_RWCOMPILER_H__) && !defined(_RWSTD_VER) -# include -# if !defined(__STD_RWCOMPILER_H__) && !defined(_RWSTD_VER) -# error This is not the Rogue Wave standard library -# endif -#endif -// -// figure out a consistent version number: -// -#ifndef _RWSTD_VER -# define BOOST_RWSTD_VER 0x010000 -#elif _RWSTD_VER < 0x010000 -# define BOOST_RWSTD_VER (_RWSTD_VER << 8) -#else -# define BOOST_RWSTD_VER _RWSTD_VER -#endif - -#ifndef _RWSTD_VER -# define BOOST_STDLIB "Rogue Wave standard library version (Unknown version)" -#else -# define BOOST_STDLIB "Rogue Wave standard library version " BOOST_STRINGIZE(_RWSTD_VER) -#endif - -// -// Prior to version 2.2.0 the primary template for std::numeric_limits -// does not have compile time constants, even though specializations of that -// template do: -// -#if BOOST_RWSTD_VER < 0x020200 -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -#endif - -// Sun CC 5.5 patch 113817-07 adds long long specialization, but does not change the -// library version number (http://sunsolve6.sun.com/search/document.do?assetkey=1-21-113817): -#if BOOST_RWSTD_VER <= 0x020101 && (!defined(__SUNPRO_CC) || (__SUNPRO_CC < 0x550)) -# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS -# endif - -// -// Borland version of numeric_limits lacks __int64 specialisation: -// -#ifdef __BORLANDC__ -# define BOOST_NO_MS_INT64_NUMERIC_LIMITS -#endif - -// -// No std::iterator if it can't figure out default template args: -// -#if defined(_RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES) || defined(RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES) || (BOOST_RWSTD_VER < 0x020000) -# define BOOST_NO_STD_ITERATOR -#endif - -// -// No iterator traits without partial specialization: -// -#if defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) || defined(RWSTD_NO_CLASS_PARTIAL_SPEC) -# define BOOST_NO_STD_ITERATOR_TRAITS -#endif - -// -// Prior to version 2.0, std::auto_ptr was buggy, and there were no -// new-style iostreams, and no conformant std::allocator: -// -#if (BOOST_RWSTD_VER < 0x020000) -# define BOOST_NO_AUTO_PTR -# define BOOST_NO_STRINGSTREAM -# define BOOST_NO_STD_ALLOCATOR -# define BOOST_NO_STD_LOCALE -#endif - -// -// No template iterator constructors without member template support: -// -#if defined(RWSTD_NO_MEMBER_TEMPLATES) || defined(_RWSTD_NO_MEMBER_TEMPLATES) -# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS -#endif - -// -// RW defines _RWSTD_ALLOCATOR if the allocator is conformant and in use -// (the or _HPACC_ part is a hack - the library seems to define _RWSTD_ALLOCATOR -// on HP aCC systems even though the allocator is in fact broken): -// -#if !defined(_RWSTD_ALLOCATOR) || (defined(__HP_aCC) && __HP_aCC <= 33100) -# define BOOST_NO_STD_ALLOCATOR -#endif - -// -// If we have a std::locale, we still may not have std::use_facet: -// -#if defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE) && !defined(BOOST_NO_STD_LOCALE) -# define BOOST_NO_STD_USE_FACET -# define BOOST_HAS_TWO_ARG_USE_FACET -#endif - -// -// There's no std::distance prior to version 2, or without -// partial specialization support: -// -#if (BOOST_RWSTD_VER < 0x020000) || defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - #define BOOST_NO_STD_DISTANCE -#endif - -// -// Some versions of the rogue wave library don't have assignable -// OutputIterators: -// -#if BOOST_RWSTD_VER < 0x020100 -# define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN -#endif - - - diff --git a/indexlib/boost-compat/config/stdlib/sgi.h b/indexlib/boost-compat/config/stdlib/sgi.h new file mode 100644 index 00000000..67f7a0a4 --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/sgi.h @@ -0,0 +1,111 @@ +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Jens Maurer 2001 - 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// generic SGI STL: + +#if !defined(__STL_CONFIG_H) +# include +# if !defined(__STL_CONFIG_H) +# error "This is not the SGI STL!" +# endif +#endif + +// +// No std::iterator traits without partial specialisation: +// +#if !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) +# define BOOST_NO_STD_ITERATOR_TRAITS +#endif + +// +// No std::stringstream with gcc < 3 +// +#if defined(__GNUC__) && (__GNUC__ < 3) && \ + ((__GNUC_MINOR__ < 95) || (__GNUC_MINOR__ == 96)) && \ + !defined(__STL_USE_NEW_IOSTREAMS) || \ + defined(__APPLE_CC__) + // Note that we only set this for GNU C++ prior to 2.95 since the + // latest patches for that release do contain a minimal + // If you are running a 2.95 release prior to 2.95.3 then this will need + // setting, but there is no way to detect that automatically (other + // than by running the configure script). + // Also, the unofficial GNU C++ 2.96 included in RedHat 7.1 doesn't + // have . +# define BOOST_NO_STRINGSTREAM +#endif + +// +// Assume no std::locale without own iostreams (this may be an +// incorrect assumption in some cases): +// +#if !defined(__SGI_STL_OWN_IOSTREAMS) && !defined(__STL_USE_NEW_IOSTREAMS) +# define BOOST_NO_STD_LOCALE +#endif + +// +// Original native SGI streams have non-standard std::messages facet: +// +#if defined(__sgi) && (_COMPILER_VERSION <= 650) && !defined(__SGI_STL_OWN_IOSTREAMS) +# define BOOST_NO_STD_LOCALE +#endif + +// +// SGI's new iostreams have missing "const" in messages<>::open +// +#if defined(__sgi) && (_COMPILER_VERSION <= 740) && defined(__STL_USE_NEW_IOSTREAMS) +# define BOOST_NO_STD_MESSAGES +#endif + +// +// No template iterator constructors, or std::allocator +// without member templates: +// +#if !defined(__STL_MEMBER_TEMPLATES) +# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS +# define BOOST_NO_STD_ALLOCATOR +#endif + +// +// We always have SGI style hash_set, hash_map, and slist: +// +#define BOOST_HAS_HASH +#define BOOST_HAS_SLIST + +// +// If this is GNU libstdc++2, then no and no std::wstring: +// +#if (defined(__GNUC__) && (__GNUC__ < 3)) +# include +# if defined(__BASTRING__) +# define BOOST_NO_LIMITS +// Note: will provide compile-time constants +# undef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +# define BOOST_NO_STD_WSTRING +# endif +#endif + +// +// There is no standard iterator unless we have namespace support: +// +#if !defined(__STL_USE_NAMESPACES) +# define BOOST_NO_STD_ITERATOR +#endif + +// +// Intrinsic type_traits support. +// The SGI STL has it's own __type_traits class, which +// has intrinsic compiler support with SGI's compilers. +// Whatever map SGI style type traits to boost equivalents: +// +#define BOOST_HAS_SGI_TYPE_TRAITS + +#define BOOST_STDLIB "SGI standard library" + + + diff --git a/indexlib/boost-compat/config/stdlib/sgi.hpp b/indexlib/boost-compat/config/stdlib/sgi.hpp deleted file mode 100644 index 67f7a0a4..00000000 --- a/indexlib/boost-compat/config/stdlib/sgi.hpp +++ /dev/null @@ -1,111 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Jens Maurer 2001 - 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// generic SGI STL: - -#if !defined(__STL_CONFIG_H) -# include -# if !defined(__STL_CONFIG_H) -# error "This is not the SGI STL!" -# endif -#endif - -// -// No std::iterator traits without partial specialisation: -// -#if !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) -# define BOOST_NO_STD_ITERATOR_TRAITS -#endif - -// -// No std::stringstream with gcc < 3 -// -#if defined(__GNUC__) && (__GNUC__ < 3) && \ - ((__GNUC_MINOR__ < 95) || (__GNUC_MINOR__ == 96)) && \ - !defined(__STL_USE_NEW_IOSTREAMS) || \ - defined(__APPLE_CC__) - // Note that we only set this for GNU C++ prior to 2.95 since the - // latest patches for that release do contain a minimal - // If you are running a 2.95 release prior to 2.95.3 then this will need - // setting, but there is no way to detect that automatically (other - // than by running the configure script). - // Also, the unofficial GNU C++ 2.96 included in RedHat 7.1 doesn't - // have . -# define BOOST_NO_STRINGSTREAM -#endif - -// -// Assume no std::locale without own iostreams (this may be an -// incorrect assumption in some cases): -// -#if !defined(__SGI_STL_OWN_IOSTREAMS) && !defined(__STL_USE_NEW_IOSTREAMS) -# define BOOST_NO_STD_LOCALE -#endif - -// -// Original native SGI streams have non-standard std::messages facet: -// -#if defined(__sgi) && (_COMPILER_VERSION <= 650) && !defined(__SGI_STL_OWN_IOSTREAMS) -# define BOOST_NO_STD_LOCALE -#endif - -// -// SGI's new iostreams have missing "const" in messages<>::open -// -#if defined(__sgi) && (_COMPILER_VERSION <= 740) && defined(__STL_USE_NEW_IOSTREAMS) -# define BOOST_NO_STD_MESSAGES -#endif - -// -// No template iterator constructors, or std::allocator -// without member templates: -// -#if !defined(__STL_MEMBER_TEMPLATES) -# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS -# define BOOST_NO_STD_ALLOCATOR -#endif - -// -// We always have SGI style hash_set, hash_map, and slist: -// -#define BOOST_HAS_HASH -#define BOOST_HAS_SLIST - -// -// If this is GNU libstdc++2, then no and no std::wstring: -// -#if (defined(__GNUC__) && (__GNUC__ < 3)) -# include -# if defined(__BASTRING__) -# define BOOST_NO_LIMITS -// Note: will provide compile-time constants -# undef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -# define BOOST_NO_STD_WSTRING -# endif -#endif - -// -// There is no standard iterator unless we have namespace support: -// -#if !defined(__STL_USE_NAMESPACES) -# define BOOST_NO_STD_ITERATOR -#endif - -// -// Intrinsic type_traits support. -// The SGI STL has it's own __type_traits class, which -// has intrinsic compiler support with SGI's compilers. -// Whatever map SGI style type traits to boost equivalents: -// -#define BOOST_HAS_SGI_TYPE_TRAITS - -#define BOOST_STDLIB "SGI standard library" - - - diff --git a/indexlib/boost-compat/config/stdlib/stlport.h b/indexlib/boost-compat/config/stdlib/stlport.h new file mode 100644 index 00000000..4843ea59 --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/stlport.h @@ -0,0 +1,201 @@ +// (C) Copyright John Maddock 2001 - 2002. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Jens Maurer 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// STLPort standard library config: + +#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +# include +# if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +# error "This is not STLPort!" +# endif +#endif + +// +// __STL_STATIC_CONST_INIT_BUG implies BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +// for versions prior to 4.1(beta) +// +#if (defined(__STL_STATIC_CONST_INIT_BUG) || defined(_STLP_STATIC_CONST_INIT_BUG)) && (__SGI_STL_PORT <= 0x400) +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#endif + +// +// If STLport thinks that there is no partial specialisation, then there is no +// std::iterator traits: +// +#if !(defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined(__STL_CLASS_PARTIAL_SPECIALIZATION)) +# define BOOST_NO_STD_ITERATOR_TRAITS +#endif + +// +// No new style iostreams on GCC without STLport's iostreams enabled: +// +#if (defined(__GNUC__) && (__GNUC__ < 3)) && !(defined(__SGI_STL_OWN_IOSTREAMS) || defined(_STLP_OWN_IOSTREAMS)) +# define BOOST_NO_STRINGSTREAM +#endif + +// +// No new iostreams implies no std::locale, and no std::stringstream: +// +#if defined(__STL_NO_IOSTREAMS) || defined(__STL_NO_NEW_IOSTREAMS) || defined(_STLP_NO_IOSTREAMS) || defined(_STLP_NO_NEW_IOSTREAMS) +# define BOOST_NO_STD_LOCALE +# define BOOST_NO_STRINGSTREAM +#endif + +// +// If the streams are not native, and we have a "using ::x" compiler bug +// then the io stream facets are not available in namespace std:: +// +#ifdef _STLPORT_VERSION +# if !defined(_STLP_OWN_IOSTREAMS) && defined(_STLP_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) +# define BOOST_NO_STD_LOCALE +# endif +#else +# if !defined(__SGI_STL_OWN_IOSTREAMS) && defined(__STL_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) +# define BOOST_NO_STD_LOCALE +# endif +#endif + +// +// Without member template support enabled, their are no template +// iterate constructors, and no std::allocator: +// +#if !(defined(__STL_MEMBER_TEMPLATES) || defined(_STLP_MEMBER_TEMPLATES)) +# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS +# define BOOST_NO_STD_ALLOCATOR +#endif +// +// however we always have at least a partial allocator: +// +#define BOOST_HAS_PARTIAL_STD_ALLOCATOR + +#if !defined(_STLP_MEMBER_TEMPLATE_CLASSES) +# define BOOST_NO_STD_ALLOCATOR +#endif + +#if defined(_STLP_NO_MEMBER_TEMPLATE_KEYWORD) && defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) +# define BOOST_NO_STD_ALLOCATOR +#endif + +// +// If STLport thinks there is no wchar_t at all, then we have to disable +// the support for the relevant specilazations of std:: templates. +// +#if !defined(_STLP_HAS_WCHAR_T) && !defined(_STLP_WCHAR_T_IS_USHORT) +# ifndef BOOST_NO_STD_WSTRING +# define BOOST_NO_STD_WSTRING +# endif +# ifndef BOOST_NO_STD_WSTREAMBUF +# define BOOST_NO_STD_WSTREAMBUF +# endif +#endif + +// +// We always have SGI style hash_set, hash_map, and slist: +// +#define BOOST_HAS_HASH +#define BOOST_HAS_SLIST + +// +// STLport does a good job of importing names into namespace std::, +// but doesn't always get them all, define BOOST_NO_STDC_NAMESPACE, since our +// workaround does not conflict with STLports: +// +// +// Harold Howe says: +// Borland switched to STLport in BCB6. Defining BOOST_NO_STDC_NAMESPACE with +// BCB6 does cause problems. If we detect C++ Builder, then don't define +// BOOST_NO_STDC_NAMESPACE +// +#if !defined(__BORLANDC__) && !defined(__DMC__) +// +// If STLport is using it's own namespace, and the real names are in +// the global namespace, then we duplicate STLport's using declarations +// (by defining BOOST_NO_STDC_NAMESPACE), we do this because STLport doesn't +// necessarily import all the names we need into namespace std:: +// +# if (defined(__STL_IMPORT_VENDOR_CSTD) \ + || defined(__STL_USE_OWN_NAMESPACE) \ + || defined(_STLP_IMPORT_VENDOR_CSTD) \ + || defined(_STLP_USE_OWN_NAMESPACE)) \ + && (defined(__STL_VENDOR_GLOBAL_CSTD) || defined (_STLP_VENDOR_GLOBAL_CSTD)) +# define BOOST_NO_STDC_NAMESPACE +# define BOOST_NO_EXCEPTION_STD_NAMESPACE +# endif +#elif defined(__BORLANDC__) && __BORLANDC__ < 0x560 +// STLport doesn't import std::abs correctly: +#include +namespace std { using ::abs; } +// and strcmp/strcpy don't get imported either ('cos they are macros) +#include +#ifdef strcpy +# undef strcpy +#endif +#ifdef strcmp +# undef strcmp +#endif +#ifdef _STLP_VENDOR_CSTD +namespace std{ using _STLP_VENDOR_CSTD::strcmp; using _STLP_VENDOR_CSTD::strcpy; } +#endif +#endif + +// +// std::use_facet may be non-standard, uses a class instead: +// +#if defined(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) || defined(_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) +# define BOOST_NO_STD_USE_FACET +# define BOOST_HAS_STLP_USE_FACET +#endif + +// +// If STLport thinks there are no wide functions, etc. is not working; but +// only if BOOST_NO_STDC_NAMESPACE is not defined (if it is then we do the import +// into std:: ourselves). +// +#if defined(_STLP_NO_NATIVE_WIDE_FUNCTIONS) && !defined(BOOST_NO_STDC_NAMESPACE) +# define BOOST_NO_CWCHAR +# define BOOST_NO_CWCTYPE +#endif + +// +// If STLport for some reason was configured so that it thinks that wchar_t +// is not an intrinsic type, then we have to disable the support for it as +// well (we would be missing required specializations otherwise). +// +#if !defined( _STLP_HAS_WCHAR_T) || defined(_STLP_WCHAR_T_IS_USHORT) +# undef BOOST_NO_INTRINSIC_WCHAR_T +# define BOOST_NO_INTRINSIC_WCHAR_T +#endif + +// +// Borland ships a version of STLport with C++ Builder 6 that lacks +// hashtables and the like: +// +#if defined(__BORLANDC__) && (__BORLANDC__ == 0x560) +# undef BOOST_HAS_HASH +#endif + +// +// gcc-2.95.3/STLPort does not like the using declarations we use to get ADL with std::min/max +// +#if defined(__GNUC__) && (__GNUC__ < 3) +# include // for std::min and std::max +# define BOOST_USING_STD_MIN() ((void)0) +# define BOOST_USING_STD_MAX() ((void)0) +namespace boost { using std::min; using std::max; } +#endif + +#define BOOST_STDLIB "STLPort standard library version " BOOST_STRINGIZE(__SGI_STL_PORT) + + + + + + + + diff --git a/indexlib/boost-compat/config/stdlib/stlport.hpp b/indexlib/boost-compat/config/stdlib/stlport.hpp deleted file mode 100644 index 4843ea59..00000000 --- a/indexlib/boost-compat/config/stdlib/stlport.hpp +++ /dev/null @@ -1,201 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Jens Maurer 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// STLPort standard library config: - -#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) -# include -# if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) -# error "This is not STLPort!" -# endif -#endif - -// -// __STL_STATIC_CONST_INIT_BUG implies BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -// for versions prior to 4.1(beta) -// -#if (defined(__STL_STATIC_CONST_INIT_BUG) || defined(_STLP_STATIC_CONST_INIT_BUG)) && (__SGI_STL_PORT <= 0x400) -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -#endif - -// -// If STLport thinks that there is no partial specialisation, then there is no -// std::iterator traits: -// -#if !(defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined(__STL_CLASS_PARTIAL_SPECIALIZATION)) -# define BOOST_NO_STD_ITERATOR_TRAITS -#endif - -// -// No new style iostreams on GCC without STLport's iostreams enabled: -// -#if (defined(__GNUC__) && (__GNUC__ < 3)) && !(defined(__SGI_STL_OWN_IOSTREAMS) || defined(_STLP_OWN_IOSTREAMS)) -# define BOOST_NO_STRINGSTREAM -#endif - -// -// No new iostreams implies no std::locale, and no std::stringstream: -// -#if defined(__STL_NO_IOSTREAMS) || defined(__STL_NO_NEW_IOSTREAMS) || defined(_STLP_NO_IOSTREAMS) || defined(_STLP_NO_NEW_IOSTREAMS) -# define BOOST_NO_STD_LOCALE -# define BOOST_NO_STRINGSTREAM -#endif - -// -// If the streams are not native, and we have a "using ::x" compiler bug -// then the io stream facets are not available in namespace std:: -// -#ifdef _STLPORT_VERSION -# if !defined(_STLP_OWN_IOSTREAMS) && defined(_STLP_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) -# define BOOST_NO_STD_LOCALE -# endif -#else -# if !defined(__SGI_STL_OWN_IOSTREAMS) && defined(__STL_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) -# define BOOST_NO_STD_LOCALE -# endif -#endif - -// -// Without member template support enabled, their are no template -// iterate constructors, and no std::allocator: -// -#if !(defined(__STL_MEMBER_TEMPLATES) || defined(_STLP_MEMBER_TEMPLATES)) -# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS -# define BOOST_NO_STD_ALLOCATOR -#endif -// -// however we always have at least a partial allocator: -// -#define BOOST_HAS_PARTIAL_STD_ALLOCATOR - -#if !defined(_STLP_MEMBER_TEMPLATE_CLASSES) -# define BOOST_NO_STD_ALLOCATOR -#endif - -#if defined(_STLP_NO_MEMBER_TEMPLATE_KEYWORD) && defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) -# define BOOST_NO_STD_ALLOCATOR -#endif - -// -// If STLport thinks there is no wchar_t at all, then we have to disable -// the support for the relevant specilazations of std:: templates. -// -#if !defined(_STLP_HAS_WCHAR_T) && !defined(_STLP_WCHAR_T_IS_USHORT) -# ifndef BOOST_NO_STD_WSTRING -# define BOOST_NO_STD_WSTRING -# endif -# ifndef BOOST_NO_STD_WSTREAMBUF -# define BOOST_NO_STD_WSTREAMBUF -# endif -#endif - -// -// We always have SGI style hash_set, hash_map, and slist: -// -#define BOOST_HAS_HASH -#define BOOST_HAS_SLIST - -// -// STLport does a good job of importing names into namespace std::, -// but doesn't always get them all, define BOOST_NO_STDC_NAMESPACE, since our -// workaround does not conflict with STLports: -// -// -// Harold Howe says: -// Borland switched to STLport in BCB6. Defining BOOST_NO_STDC_NAMESPACE with -// BCB6 does cause problems. If we detect C++ Builder, then don't define -// BOOST_NO_STDC_NAMESPACE -// -#if !defined(__BORLANDC__) && !defined(__DMC__) -// -// If STLport is using it's own namespace, and the real names are in -// the global namespace, then we duplicate STLport's using declarations -// (by defining BOOST_NO_STDC_NAMESPACE), we do this because STLport doesn't -// necessarily import all the names we need into namespace std:: -// -# if (defined(__STL_IMPORT_VENDOR_CSTD) \ - || defined(__STL_USE_OWN_NAMESPACE) \ - || defined(_STLP_IMPORT_VENDOR_CSTD) \ - || defined(_STLP_USE_OWN_NAMESPACE)) \ - && (defined(__STL_VENDOR_GLOBAL_CSTD) || defined (_STLP_VENDOR_GLOBAL_CSTD)) -# define BOOST_NO_STDC_NAMESPACE -# define BOOST_NO_EXCEPTION_STD_NAMESPACE -# endif -#elif defined(__BORLANDC__) && __BORLANDC__ < 0x560 -// STLport doesn't import std::abs correctly: -#include -namespace std { using ::abs; } -// and strcmp/strcpy don't get imported either ('cos they are macros) -#include -#ifdef strcpy -# undef strcpy -#endif -#ifdef strcmp -# undef strcmp -#endif -#ifdef _STLP_VENDOR_CSTD -namespace std{ using _STLP_VENDOR_CSTD::strcmp; using _STLP_VENDOR_CSTD::strcpy; } -#endif -#endif - -// -// std::use_facet may be non-standard, uses a class instead: -// -#if defined(__STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS) || defined(_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) -# define BOOST_NO_STD_USE_FACET -# define BOOST_HAS_STLP_USE_FACET -#endif - -// -// If STLport thinks there are no wide functions, etc. is not working; but -// only if BOOST_NO_STDC_NAMESPACE is not defined (if it is then we do the import -// into std:: ourselves). -// -#if defined(_STLP_NO_NATIVE_WIDE_FUNCTIONS) && !defined(BOOST_NO_STDC_NAMESPACE) -# define BOOST_NO_CWCHAR -# define BOOST_NO_CWCTYPE -#endif - -// -// If STLport for some reason was configured so that it thinks that wchar_t -// is not an intrinsic type, then we have to disable the support for it as -// well (we would be missing required specializations otherwise). -// -#if !defined( _STLP_HAS_WCHAR_T) || defined(_STLP_WCHAR_T_IS_USHORT) -# undef BOOST_NO_INTRINSIC_WCHAR_T -# define BOOST_NO_INTRINSIC_WCHAR_T -#endif - -// -// Borland ships a version of STLport with C++ Builder 6 that lacks -// hashtables and the like: -// -#if defined(__BORLANDC__) && (__BORLANDC__ == 0x560) -# undef BOOST_HAS_HASH -#endif - -// -// gcc-2.95.3/STLPort does not like the using declarations we use to get ADL with std::min/max -// -#if defined(__GNUC__) && (__GNUC__ < 3) -# include // for std::min and std::max -# define BOOST_USING_STD_MIN() ((void)0) -# define BOOST_USING_STD_MAX() ((void)0) -namespace boost { using std::min; using std::max; } -#endif - -#define BOOST_STDLIB "STLPort standard library version " BOOST_STRINGIZE(__SGI_STL_PORT) - - - - - - - - diff --git a/indexlib/boost-compat/config/stdlib/vacpp.h b/indexlib/boost-compat/config/stdlib/vacpp.h new file mode 100644 index 00000000..8321ee0c --- /dev/null +++ b/indexlib/boost-compat/config/stdlib/vacpp.h @@ -0,0 +1,18 @@ +// (C) Copyright John Maddock 2001 - 2002. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +#if __IBMCPP__ <= 501 +# define BOOST_NO_STD_ALLOCATOR +#endif + +#define BOOST_HAS_MACRO_USE_FACET +#define BOOST_NO_STD_MESSAGES + +#define BOOST_STDLIB "Visual Age default standard library" + + + diff --git a/indexlib/boost-compat/config/stdlib/vacpp.hpp b/indexlib/boost-compat/config/stdlib/vacpp.hpp deleted file mode 100644 index 8321ee0c..00000000 --- a/indexlib/boost-compat/config/stdlib/vacpp.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright John Maddock 2001 - 2002. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -#if __IBMCPP__ <= 501 -# define BOOST_NO_STD_ALLOCATOR -#endif - -#define BOOST_HAS_MACRO_USE_FACET -#define BOOST_NO_STD_MESSAGES - -#define BOOST_STDLIB "Visual Age default standard library" - - - diff --git a/indexlib/boost-compat/config/suffix.h b/indexlib/boost-compat/config/suffix.h new file mode 100644 index 00000000..313faea9 --- /dev/null +++ b/indexlib/boost-compat/config/suffix.h @@ -0,0 +1,543 @@ +// Boost config.h configuration header file ------------------------------// + +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright Bill Kempf 2002. +// (C) Copyright Jens Maurer 2002. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Gennaro Prota 2003. +// (C) Copyright Eric Friedman 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for most recent version. + +// Boost config.h policy and rationale documentation has been moved to +// http://www.boost.org/libs/config +// +// This file is intended to be stable, and relatively unchanging. +// It should contain boilerplate code only - no compiler specific +// code unless it is unavoidable - no changes unless unavoidable. + +#ifndef BOOST_CONFIG_SUFFIX_H +#define BOOST_CONFIG_SUFFIX_H + +// +// look for long long by looking for the appropriate macros in . +// Note that we use limits.h rather than climits for maximal portability, +// remember that since these just declare a bunch of macros, there should be +// no namespace issues from this. +// +#include +# if !defined(BOOST_HAS_LONG_LONG) \ + && !(defined(BOOST_MSVC) && BOOST_MSVC <=1300) && !defined(__BORLANDC__) \ + && (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)) +# define BOOST_HAS_LONG_LONG +#endif +#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T) +# define BOOST_NO_INTEGRAL_INT64_T +#endif + +// GCC 3.x will clean up all of those nasty macro definitions that +// BOOST_NO_CTYPE_FUNCTIONS is intended to help work around, so undefine +// it under GCC 3.x. +#if defined(__GNUC__) && (__GNUC__ >= 3) && defined(BOOST_NO_CTYPE_FUNCTIONS) +# undef BOOST_NO_CTYPE_FUNCTIONS +#endif + + +// +// Assume any extensions are in namespace std:: unless stated otherwise: +// +# ifndef BOOST_STD_EXTENSION_NAMESPACE +# define BOOST_STD_EXTENSION_NAMESPACE std +# endif + +// +// If cv-qualified specializations are not allowed, then neither are cv-void ones: +// +# if defined(BOOST_NO_CV_SPECIALIZATIONS) \ + && !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) +# define BOOST_NO_CV_VOID_SPECIALIZATIONS +# endif + +// +// If there is no numeric_limits template, then it can't have any compile time +// constants either! +// +# if defined(BOOST_NO_LIMITS) \ + && !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) +# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +# define BOOST_NO_MS_INT64_NUMERIC_LIMITS +# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS +# endif + +// +// if there is no long long then there is no specialisation +// for numeric_limits either: +// +#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_LONG_LONG_NUMERIC_LIMITS) +# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS +#endif + +// +// if there is no __int64 then there is no specialisation +// for numeric_limits<__int64> either: +// +#if !defined(BOOST_HAS_MS_INT64) && !defined(BOOST_NO_MS_INT64_NUMERIC_LIMITS) +# define BOOST_NO_MS_INT64_NUMERIC_LIMITS +#endif + +// +// if member templates are supported then so is the +// VC6 subset of member templates: +// +# if !defined(BOOST_NO_MEMBER_TEMPLATES) \ + && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) +# define BOOST_MSVC6_MEMBER_TEMPLATES +# endif + +// +// Without partial specialization, can't test for partial specialisation bugs: +// +# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) +# define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG +# endif + +// +// Without partial specialization, we can't have array-type partial specialisations: +// +# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +# define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS +# endif + +// +// Without partial specialization, std::iterator_traits can't work: +// +# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_NO_STD_ITERATOR_TRAITS) +# define BOOST_NO_STD_ITERATOR_TRAITS +# endif + +// +// Without member template support, we can't have template constructors +// in the standard library either: +// +# if defined(BOOST_NO_MEMBER_TEMPLATES) \ + && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \ + && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) +# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS +# endif + +// +// Without member template support, we can't have a conforming +// std::allocator template either: +// +# if defined(BOOST_NO_MEMBER_TEMPLATES) \ + && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \ + && !defined(BOOST_NO_STD_ALLOCATOR) +# define BOOST_NO_STD_ALLOCATOR +# endif + +// +// without ADL support then using declarations will break ADL as well: +// +#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) && !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL) +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +#endif + +// +// If we have a standard allocator, then we have a partial one as well: +// +#if !defined(BOOST_NO_STD_ALLOCATOR) +# define BOOST_HAS_PARTIAL_STD_ALLOCATOR +#endif + +// +// We can't have a working std::use_facet if there is no std::locale: +// +# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_USE_FACET) +# define BOOST_NO_STD_USE_FACET +# endif + +// +// We can't have a std::messages facet if there is no std::locale: +// +# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_MESSAGES) +# define BOOST_NO_STD_MESSAGES +# endif + +// +// We can't have a working std::wstreambuf if there is no std::locale: +// +# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_WSTREAMBUF) +# define BOOST_NO_STD_WSTREAMBUF +# endif + +// +// We can't have a if there is no : +// +# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_CWCTYPE) +# define BOOST_NO_CWCTYPE +# endif + +// +// We can't have a swprintf if there is no : +// +# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_SWPRINTF) +# define BOOST_NO_SWPRINTF +# endif + +// +// If Win32 support is turned off, then we must turn off +// threading support also, unless there is some other +// thread API enabled: +// +#if defined(BOOST_DISABLE_WIN32) && defined(_WIN32) \ + && !defined(BOOST_DISABLE_THREADS) && !defined(BOOST_HAS_PTHREADS) +# define BOOST_DISABLE_THREADS +#endif + +// +// Turn on threading support if the compiler thinks that it's in +// multithreaded mode. We put this here because there are only a +// limited number of macros that identify this (if there's any missing +// from here then add to the appropriate compiler section): +// +#if (defined(__MT__) || defined(_MT) || defined(_REENTRANT) \ + || defined(_PTHREADS)) && !defined(BOOST_HAS_THREADS) +# define BOOST_HAS_THREADS +#endif + +// +// Turn threading support off if BOOST_DISABLE_THREADS is defined: +// +#if defined(BOOST_DISABLE_THREADS) && defined(BOOST_HAS_THREADS) +# undef BOOST_HAS_THREADS +#endif + +// +// Turn threading support off if we don't recognise the threading API: +// +#if defined(BOOST_HAS_THREADS) && !defined(BOOST_HAS_PTHREADS)\ + && !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_BETHREADS)\ + && !defined(BOOST_HAS_MPTASKS) +# undef BOOST_HAS_THREADS +#endif + +// +// Turn threading detail macros off if we don't (want to) use threading +// +#ifndef BOOST_HAS_THREADS +# undef BOOST_HAS_PTHREADS +# undef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +# undef BOOST_HAS_WINTHREADS +# undef BOOST_HAS_BETHREADS +# undef BOOST_HAS_MPTASKS +#endif + +// +// If the compiler claims to be C99 conformant, then it had better +// have a : +// +# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) +# define BOOST_HAS_STDINT_H +# endif + +// +// Define BOOST_NO_SLIST and BOOST_NO_HASH if required. +// Note that this is for backwards compatibility only. +// +# ifndef BOOST_HAS_SLIST +# define BOOST_NO_SLIST +# endif + +# ifndef BOOST_HAS_HASH +# define BOOST_NO_HASH +# endif + +// BOOST_HAS_ABI_HEADERS +// This macro gets set if we have headers that fix the ABI, +// and prevent ODR violations when linking to external libraries: +#if defined(BOOST_ABI_PREFIX) && defined(BOOST_ABI_SUFFIX) && !defined(BOOST_HAS_ABI_HEADERS) +# define BOOST_HAS_ABI_HEADERS +#endif + +#if defined(BOOST_HAS_ABI_HEADERS) && defined(BOOST_DISABLE_ABI_HEADERS) +# undef BOOST_HAS_ABI_HEADERS +#endif + +// BOOST_NO_STDC_NAMESPACE workaround --------------------------------------// +// Because std::size_t usage is so common, even in boost headers which do not +// otherwise use the C library, the workaround is included here so +// that ugly workaround code need not appear in many other boost headers. +// NOTE WELL: This is a workaround for non-conforming compilers; +// must still be #included in the usual places so that inclusion +// works as expected with standard conforming compilers. The resulting +// double inclusion of is harmless. + +# ifdef BOOST_NO_STDC_NAMESPACE +# include + namespace std { using ::ptrdiff_t; using ::size_t; } +# endif + +// Workaround for the unfortunate min/max macros defined by some platform headers + +#define BOOST_PREVENT_MACRO_SUBSTITUTION + +#ifndef BOOST_USING_STD_MIN +# define BOOST_USING_STD_MIN() using std::min +#endif + +#ifndef BOOST_USING_STD_MAX +# define BOOST_USING_STD_MAX() using std::max +#endif + +// BOOST_NO_STD_MIN_MAX workaround -----------------------------------------// + +# ifdef BOOST_NO_STD_MIN_MAX + +namespace std { + template + inline const _Tp& min BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) { + return __b < __a ? __b : __a; + } + template + inline const _Tp& max BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) { + return __a < __b ? __b : __a; + } +} + +# endif + +// BOOST_STATIC_CONSTANT workaround --------------------------------------- // +// On compilers which don't allow in-class initialization of static integral +// constant members, we must use enums as a workaround if we want the constants +// to be available at compile-time. This macro gives us a convenient way to +// declare such constants. + +# ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION +# define BOOST_STATIC_CONSTANT(type, assignment) enum { assignment } +# else +# define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment +# endif + +// BOOST_USE_FACET / HAS_FACET workaround ----------------------------------// +// When the standard library does not have a conforming std::use_facet there +// are various workarounds available, but they differ from library to library. +// The same problem occurs with has_facet. +// These macros provide a consistent way to access a locale's facets. +// Usage: +// replace +// std::use_facet(loc); +// with +// BOOST_USE_FACET(Type, loc); +// Note do not add a std:: prefix to the front of BOOST_USE_FACET! +// Use for BOOST_HAS_FACET is analagous. + +#if defined(BOOST_NO_STD_USE_FACET) +# ifdef BOOST_HAS_TWO_ARG_USE_FACET +# define BOOST_USE_FACET(Type, loc) std::use_facet(loc, static_cast(0)) +# define BOOST_HAS_FACET(Type, loc) std::has_facet(loc, static_cast(0)) +# elif defined(BOOST_HAS_MACRO_USE_FACET) +# define BOOST_USE_FACET(Type, loc) std::_USE(loc, Type) +# define BOOST_HAS_FACET(Type, loc) std::_HAS(loc, Type) +# elif defined(BOOST_HAS_STLP_USE_FACET) +# define BOOST_USE_FACET(Type, loc) (*std::_Use_facet(loc)) +# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc) +# endif +#else +# define BOOST_USE_FACET(Type, loc) std::use_facet< Type >(loc) +# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc) +#endif + +// BOOST_NESTED_TEMPLATE workaround ------------------------------------------// +// Member templates are supported by some compilers even though they can't use +// the A::template member syntax, as a workaround replace: +// +// typedef typename A::template rebind binder; +// +// with: +// +// typedef typename A::BOOST_NESTED_TEMPLATE rebind binder; + +#ifndef BOOST_NO_MEMBER_TEMPLATE_KEYWORD +# define BOOST_NESTED_TEMPLATE template +#else +# define BOOST_NESTED_TEMPLATE +#endif + +// BOOST_UNREACHABLE_RETURN(x) workaround -------------------------------------// +// Normally evaluates to nothing, unless BOOST_NO_UNREACHABLE_RETURN_DETECTION +// is defined, in which case it evaluates to return x; Use when you have a return +// statement that can never be reached. + +#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION +# define BOOST_UNREACHABLE_RETURN(x) return x; +#else +# define BOOST_UNREACHABLE_RETURN(x) +#endif + +// BOOST_DEDUCED_TYPENAME workaround ------------------------------------------// +// +// Some compilers don't support the use of `typename' for dependent +// types in deduced contexts, e.g. +// +// template void f(T, typename T::type); +// ^^^^^^^^ +// Replace these declarations with: +// +// template void f(T, BOOST_DEDUCED_TYPENAME T::type); + +#ifndef BOOST_NO_DEDUCED_TYPENAME +# define BOOST_DEDUCED_TYPENAME typename +#else +# define BOOST_DEDUCED_TYPENAME +#endif + +// long long workaround ------------------------------------------// +// On gcc (and maybe other compilers?) long long is alway supported +// but it's use may generate either warnings (with -ansi), or errors +// (with -pedantic -ansi) unless it's use is prefixed by __extension__ +// +#if defined(BOOST_HAS_LONG_LONG) +namespace boost{ +# ifdef __GNUC__ + __extension__ typedef long long long_long_type; + __extension__ typedef unsigned long long ulong_long_type; +# else + typedef long long long_long_type; + typedef unsigned long long ulong_long_type; +# endif +} +#endif + +// BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------// +// +// Some compilers have problems with function templates whose +// template parameters don't appear in the function parameter +// list (basically they just link one instantiation of the +// template in the final executable). These macros provide a +// uniform way to cope with the problem with no effects on the +// calling syntax. + +// Example: +// +// #include +// #include +// #include +// +// template +// void f() { std::cout << n << ' '; } +// +// template +// void g() { std::cout << typeid(T).name() << ' '; } +// +// int main() { +// f<1>(); +// f<2>(); +// +// g(); +// g(); +// } +// +// With VC++ 6.0 the output is: +// +// 2 2 double double +// +// To fix it, write +// +// template +// void f(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, n)) { ... } +// +// template +// void g(BOOST_EXPLICIT_TEMPLATE_TYPE(T)) { ... } +// + + +#if defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS + +# include "boost/type.hpp" +# include "boost/non_type.hpp" + +# define BOOST_EXPLICIT_TEMPLATE_TYPE(t) boost::type* = 0 +# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::type* +# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::non_type* = 0 +# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::non_type* + +# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \ + , BOOST_EXPLICIT_TEMPLATE_TYPE(t) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \ + , BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \ + , BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \ + , BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) + +#else + +// no workaround needed: expand to nothing + +# define BOOST_EXPLICIT_TEMPLATE_TYPE(t) +# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) +# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) +# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) + +# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) +# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) + + +#endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS + + +// ---------------------------------------------------------------------------// + +// +// Helper macro BOOST_STRINGIZE: +// Converts the parameter X to a string after macro replacement +// on X has been performed. +// +#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) +#define BOOST_DO_STRINGIZE(X) #X + +// +// Helper macro BOOST_JOIN: +// The following piece of macro magic joins the two +// arguments together, even when one of the arguments is +// itself a macro (see 16.3.1 in C++ standard). The key +// is that macro expansion of macro arguments does not +// occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN. +// +#define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y ) +#define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y) +#define BOOST_DO_JOIN2( X, Y ) X##Y + +// +// Set some default values for compiler/library/platform names. +// These are for debugging config setup only: +// +# ifndef BOOST_COMPILER +# define BOOST_COMPILER "Unknown ISO C++ Compiler" +# endif +# ifndef BOOST_STDLIB +# define BOOST_STDLIB "Unknown ISO standard library" +# endif +# ifndef BOOST_PLATFORM +# if defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) \ + || defined(_POSIX_SOURCE) +# define BOOST_PLATFORM "Generic Unix" +# else +# define BOOST_PLATFORM "Unknown" +# endif +# endif + +#endif + + + diff --git a/indexlib/boost-compat/config/suffix.hpp b/indexlib/boost-compat/config/suffix.hpp deleted file mode 100644 index 77d9deca..00000000 --- a/indexlib/boost-compat/config/suffix.hpp +++ /dev/null @@ -1,543 +0,0 @@ -// Boost config.hpp configuration header file ------------------------------// - -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright Bill Kempf 2002. -// (C) Copyright Jens Maurer 2002. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Gennaro Prota 2003. -// (C) Copyright Eric Friedman 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version. - -// Boost config.hpp policy and rationale documentation has been moved to -// http://www.boost.org/libs/config -// -// This file is intended to be stable, and relatively unchanging. -// It should contain boilerplate code only - no compiler specific -// code unless it is unavoidable - no changes unless unavoidable. - -#ifndef BOOST_CONFIG_SUFFIX_HPP -#define BOOST_CONFIG_SUFFIX_HPP - -// -// look for long long by looking for the appropriate macros in . -// Note that we use limits.h rather than climits for maximal portability, -// remember that since these just declare a bunch of macros, there should be -// no namespace issues from this. -// -#include -# if !defined(BOOST_HAS_LONG_LONG) \ - && !(defined(BOOST_MSVC) && BOOST_MSVC <=1300) && !defined(__BORLANDC__) \ - && (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)) -# define BOOST_HAS_LONG_LONG -#endif -#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T) -# define BOOST_NO_INTEGRAL_INT64_T -#endif - -// GCC 3.x will clean up all of those nasty macro definitions that -// BOOST_NO_CTYPE_FUNCTIONS is intended to help work around, so undefine -// it under GCC 3.x. -#if defined(__GNUC__) && (__GNUC__ >= 3) && defined(BOOST_NO_CTYPE_FUNCTIONS) -# undef BOOST_NO_CTYPE_FUNCTIONS -#endif - - -// -// Assume any extensions are in namespace std:: unless stated otherwise: -// -# ifndef BOOST_STD_EXTENSION_NAMESPACE -# define BOOST_STD_EXTENSION_NAMESPACE std -# endif - -// -// If cv-qualified specializations are not allowed, then neither are cv-void ones: -// -# if defined(BOOST_NO_CV_SPECIALIZATIONS) \ - && !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) -# define BOOST_NO_CV_VOID_SPECIALIZATIONS -# endif - -// -// If there is no numeric_limits template, then it can't have any compile time -// constants either! -// -# if defined(BOOST_NO_LIMITS) \ - && !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) -# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -# define BOOST_NO_MS_INT64_NUMERIC_LIMITS -# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS -# endif - -// -// if there is no long long then there is no specialisation -// for numeric_limits either: -// -#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_LONG_LONG_NUMERIC_LIMITS) -# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS -#endif - -// -// if there is no __int64 then there is no specialisation -// for numeric_limits<__int64> either: -// -#if !defined(BOOST_HAS_MS_INT64) && !defined(BOOST_NO_MS_INT64_NUMERIC_LIMITS) -# define BOOST_NO_MS_INT64_NUMERIC_LIMITS -#endif - -// -// if member templates are supported then so is the -// VC6 subset of member templates: -// -# if !defined(BOOST_NO_MEMBER_TEMPLATES) \ - && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) -# define BOOST_MSVC6_MEMBER_TEMPLATES -# endif - -// -// Without partial specialization, can't test for partial specialisation bugs: -// -# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && !defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) -# define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG -# endif - -// -// Without partial specialization, we can't have array-type partial specialisations: -// -# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) -# define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS -# endif - -// -// Without partial specialization, std::iterator_traits can't work: -// -# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ - && !defined(BOOST_NO_STD_ITERATOR_TRAITS) -# define BOOST_NO_STD_ITERATOR_TRAITS -# endif - -// -// Without member template support, we can't have template constructors -// in the standard library either: -// -# if defined(BOOST_NO_MEMBER_TEMPLATES) \ - && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \ - && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) -# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS -# endif - -// -// Without member template support, we can't have a conforming -// std::allocator template either: -// -# if defined(BOOST_NO_MEMBER_TEMPLATES) \ - && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \ - && !defined(BOOST_NO_STD_ALLOCATOR) -# define BOOST_NO_STD_ALLOCATOR -# endif - -// -// without ADL support then using declarations will break ADL as well: -// -#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) && !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL) -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -#endif - -// -// If we have a standard allocator, then we have a partial one as well: -// -#if !defined(BOOST_NO_STD_ALLOCATOR) -# define BOOST_HAS_PARTIAL_STD_ALLOCATOR -#endif - -// -// We can't have a working std::use_facet if there is no std::locale: -// -# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_USE_FACET) -# define BOOST_NO_STD_USE_FACET -# endif - -// -// We can't have a std::messages facet if there is no std::locale: -// -# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_MESSAGES) -# define BOOST_NO_STD_MESSAGES -# endif - -// -// We can't have a working std::wstreambuf if there is no std::locale: -// -# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_WSTREAMBUF) -# define BOOST_NO_STD_WSTREAMBUF -# endif - -// -// We can't have a if there is no : -// -# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_CWCTYPE) -# define BOOST_NO_CWCTYPE -# endif - -// -// We can't have a swprintf if there is no : -// -# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_SWPRINTF) -# define BOOST_NO_SWPRINTF -# endif - -// -// If Win32 support is turned off, then we must turn off -// threading support also, unless there is some other -// thread API enabled: -// -#if defined(BOOST_DISABLE_WIN32) && defined(_WIN32) \ - && !defined(BOOST_DISABLE_THREADS) && !defined(BOOST_HAS_PTHREADS) -# define BOOST_DISABLE_THREADS -#endif - -// -// Turn on threading support if the compiler thinks that it's in -// multithreaded mode. We put this here because there are only a -// limited number of macros that identify this (if there's any missing -// from here then add to the appropriate compiler section): -// -#if (defined(__MT__) || defined(_MT) || defined(_REENTRANT) \ - || defined(_PTHREADS)) && !defined(BOOST_HAS_THREADS) -# define BOOST_HAS_THREADS -#endif - -// -// Turn threading support off if BOOST_DISABLE_THREADS is defined: -// -#if defined(BOOST_DISABLE_THREADS) && defined(BOOST_HAS_THREADS) -# undef BOOST_HAS_THREADS -#endif - -// -// Turn threading support off if we don't recognise the threading API: -// -#if defined(BOOST_HAS_THREADS) && !defined(BOOST_HAS_PTHREADS)\ - && !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_BETHREADS)\ - && !defined(BOOST_HAS_MPTASKS) -# undef BOOST_HAS_THREADS -#endif - -// -// Turn threading detail macros off if we don't (want to) use threading -// -#ifndef BOOST_HAS_THREADS -# undef BOOST_HAS_PTHREADS -# undef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE -# undef BOOST_HAS_WINTHREADS -# undef BOOST_HAS_BETHREADS -# undef BOOST_HAS_MPTASKS -#endif - -// -// If the compiler claims to be C99 conformant, then it had better -// have a : -// -# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) -# define BOOST_HAS_STDINT_H -# endif - -// -// Define BOOST_NO_SLIST and BOOST_NO_HASH if required. -// Note that this is for backwards compatibility only. -// -# ifndef BOOST_HAS_SLIST -# define BOOST_NO_SLIST -# endif - -# ifndef BOOST_HAS_HASH -# define BOOST_NO_HASH -# endif - -// BOOST_HAS_ABI_HEADERS -// This macro gets set if we have headers that fix the ABI, -// and prevent ODR violations when linking to external libraries: -#if defined(BOOST_ABI_PREFIX) && defined(BOOST_ABI_SUFFIX) && !defined(BOOST_HAS_ABI_HEADERS) -# define BOOST_HAS_ABI_HEADERS -#endif - -#if defined(BOOST_HAS_ABI_HEADERS) && defined(BOOST_DISABLE_ABI_HEADERS) -# undef BOOST_HAS_ABI_HEADERS -#endif - -// BOOST_NO_STDC_NAMESPACE workaround --------------------------------------// -// Because std::size_t usage is so common, even in boost headers which do not -// otherwise use the C library, the workaround is included here so -// that ugly workaround code need not appear in many other boost headers. -// NOTE WELL: This is a workaround for non-conforming compilers; -// must still be #included in the usual places so that inclusion -// works as expected with standard conforming compilers. The resulting -// double inclusion of is harmless. - -# ifdef BOOST_NO_STDC_NAMESPACE -# include - namespace std { using ::ptrdiff_t; using ::size_t; } -# endif - -// Workaround for the unfortunate min/max macros defined by some platform headers - -#define BOOST_PREVENT_MACRO_SUBSTITUTION - -#ifndef BOOST_USING_STD_MIN -# define BOOST_USING_STD_MIN() using std::min -#endif - -#ifndef BOOST_USING_STD_MAX -# define BOOST_USING_STD_MAX() using std::max -#endif - -// BOOST_NO_STD_MIN_MAX workaround -----------------------------------------// - -# ifdef BOOST_NO_STD_MIN_MAX - -namespace std { - template - inline const _Tp& min BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) { - return __b < __a ? __b : __a; - } - template - inline const _Tp& max BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) { - return __a < __b ? __b : __a; - } -} - -# endif - -// BOOST_STATIC_CONSTANT workaround --------------------------------------- // -// On compilers which don't allow in-class initialization of static integral -// constant members, we must use enums as a workaround if we want the constants -// to be available at compile-time. This macro gives us a convenient way to -// declare such constants. - -# ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# define BOOST_STATIC_CONSTANT(type, assignment) enum { assignment } -# else -# define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment -# endif - -// BOOST_USE_FACET / HAS_FACET workaround ----------------------------------// -// When the standard library does not have a conforming std::use_facet there -// are various workarounds available, but they differ from library to library. -// The same problem occurs with has_facet. -// These macros provide a consistent way to access a locale's facets. -// Usage: -// replace -// std::use_facet(loc); -// with -// BOOST_USE_FACET(Type, loc); -// Note do not add a std:: prefix to the front of BOOST_USE_FACET! -// Use for BOOST_HAS_FACET is analagous. - -#if defined(BOOST_NO_STD_USE_FACET) -# ifdef BOOST_HAS_TWO_ARG_USE_FACET -# define BOOST_USE_FACET(Type, loc) std::use_facet(loc, static_cast(0)) -# define BOOST_HAS_FACET(Type, loc) std::has_facet(loc, static_cast(0)) -# elif defined(BOOST_HAS_MACRO_USE_FACET) -# define BOOST_USE_FACET(Type, loc) std::_USE(loc, Type) -# define BOOST_HAS_FACET(Type, loc) std::_HAS(loc, Type) -# elif defined(BOOST_HAS_STLP_USE_FACET) -# define BOOST_USE_FACET(Type, loc) (*std::_Use_facet(loc)) -# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc) -# endif -#else -# define BOOST_USE_FACET(Type, loc) std::use_facet< Type >(loc) -# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc) -#endif - -// BOOST_NESTED_TEMPLATE workaround ------------------------------------------// -// Member templates are supported by some compilers even though they can't use -// the A::template member syntax, as a workaround replace: -// -// typedef typename A::template rebind binder; -// -// with: -// -// typedef typename A::BOOST_NESTED_TEMPLATE rebind binder; - -#ifndef BOOST_NO_MEMBER_TEMPLATE_KEYWORD -# define BOOST_NESTED_TEMPLATE template -#else -# define BOOST_NESTED_TEMPLATE -#endif - -// BOOST_UNREACHABLE_RETURN(x) workaround -------------------------------------// -// Normally evaluates to nothing, unless BOOST_NO_UNREACHABLE_RETURN_DETECTION -// is defined, in which case it evaluates to return x; Use when you have a return -// statement that can never be reached. - -#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION -# define BOOST_UNREACHABLE_RETURN(x) return x; -#else -# define BOOST_UNREACHABLE_RETURN(x) -#endif - -// BOOST_DEDUCED_TYPENAME workaround ------------------------------------------// -// -// Some compilers don't support the use of `typename' for dependent -// types in deduced contexts, e.g. -// -// template void f(T, typename T::type); -// ^^^^^^^^ -// Replace these declarations with: -// -// template void f(T, BOOST_DEDUCED_TYPENAME T::type); - -#ifndef BOOST_NO_DEDUCED_TYPENAME -# define BOOST_DEDUCED_TYPENAME typename -#else -# define BOOST_DEDUCED_TYPENAME -#endif - -// long long workaround ------------------------------------------// -// On gcc (and maybe other compilers?) long long is alway supported -// but it's use may generate either warnings (with -ansi), or errors -// (with -pedantic -ansi) unless it's use is prefixed by __extension__ -// -#if defined(BOOST_HAS_LONG_LONG) -namespace boost{ -# ifdef __GNUC__ - __extension__ typedef long long long_long_type; - __extension__ typedef unsigned long long ulong_long_type; -# else - typedef long long long_long_type; - typedef unsigned long long ulong_long_type; -# endif -} -#endif - -// BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------// -// -// Some compilers have problems with function templates whose -// template parameters don't appear in the function parameter -// list (basically they just link one instantiation of the -// template in the final executable). These macros provide a -// uniform way to cope with the problem with no effects on the -// calling syntax. - -// Example: -// -// #include -// #include -// #include -// -// template -// void f() { std::cout << n << ' '; } -// -// template -// void g() { std::cout << typeid(T).name() << ' '; } -// -// int main() { -// f<1>(); -// f<2>(); -// -// g(); -// g(); -// } -// -// With VC++ 6.0 the output is: -// -// 2 2 double double -// -// To fix it, write -// -// template -// void f(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, n)) { ... } -// -// template -// void g(BOOST_EXPLICIT_TEMPLATE_TYPE(T)) { ... } -// - - -#if defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS - -# include "boost/type.hpp" -# include "boost/non_type.hpp" - -# define BOOST_EXPLICIT_TEMPLATE_TYPE(t) boost::type* = 0 -# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::type* -# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::non_type* = 0 -# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::non_type* - -# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \ - , BOOST_EXPLICIT_TEMPLATE_TYPE(t) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \ - , BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \ - , BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \ - , BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) - -#else - -// no workaround needed: expand to nothing - -# define BOOST_EXPLICIT_TEMPLATE_TYPE(t) -# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) -# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) -# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) - -# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) -# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) - - -#endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS - - -// ---------------------------------------------------------------------------// - -// -// Helper macro BOOST_STRINGIZE: -// Converts the parameter X to a string after macro replacement -// on X has been performed. -// -#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) -#define BOOST_DO_STRINGIZE(X) #X - -// -// Helper macro BOOST_JOIN: -// The following piece of macro magic joins the two -// arguments together, even when one of the arguments is -// itself a macro (see 16.3.1 in C++ standard). The key -// is that macro expansion of macro arguments does not -// occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN. -// -#define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y ) -#define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y) -#define BOOST_DO_JOIN2( X, Y ) X##Y - -// -// Set some default values for compiler/library/platform names. -// These are for debugging config setup only: -// -# ifndef BOOST_COMPILER -# define BOOST_COMPILER "Unknown ISO C++ Compiler" -# endif -# ifndef BOOST_STDLIB -# define BOOST_STDLIB "Unknown ISO standard library" -# endif -# ifndef BOOST_PLATFORM -# if defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) \ - || defined(_POSIX_SOURCE) -# define BOOST_PLATFORM "Generic Unix" -# else -# define BOOST_PLATFORM "Unknown" -# endif -# endif - -#endif - - - diff --git a/indexlib/boost-compat/config/user.h b/indexlib/boost-compat/config/user.h new file mode 100644 index 00000000..14b02c67 --- /dev/null +++ b/indexlib/boost-compat/config/user.h @@ -0,0 +1,124 @@ +// boost/config/user.h ---------------------------------------------------// + +// (C) Copyright John Maddock 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Do not check in modified versions of this file, +// This file may be customized by the end user, but not by boost. + +// +// Use this file to define a site and compiler specific +// configuration policy: +// + +// define this to locate a compiler config file: +// #define BOOST_COMPILER_CONFIG + +// define this to locate a stdlib config file: +// #define BOOST_STDLIB_CONFIG + +// define this to locate a platform config file: +// #define BOOST_PLATFORM_CONFIG + +// define this to disable compiler config, +// use if your compiler config has nothing to set: +// #define BOOST_NO_COMPILER_CONFIG + +// define this to disable stdlib config, +// use if your stdlib config has nothing to set: +// #define BOOST_NO_STDLIB_CONFIG + +// define this to disable platform config, +// use if your platform config has nothing to set: +// #define BOOST_NO_PLATFORM_CONFIG + +// define this to disable all config options, +// excluding the user config. Use if your +// setup is fully ISO compliant, and has no +// useful extensions, or for autoconf generated +// setups: +// #define BOOST_NO_CONFIG + +// define this to make the config "optimistic" +// about unknown compiler versions. Normally +// unknown compiler versions are assumed to have +// all the defects of the last known version, however +// setting this flag, causes the config to assume +// that unknown compiler versions are fully conformant +// with the standard: +// #define BOOST_STRICT_CONFIG + +// define this to cause the config to halt compilation +// with an #error if it encounters anything unknown -- +// either an unknown compiler version or an unknown +// compiler/platform/library: +// #define BOOST_ASSERT_CONFIG + + +// define if you want to disable threading support, even +// when available: +// #define BOOST_DISABLE_THREADS + +// define when you want to disable Win32 specific features +// even when available: +// #define BOOST_DISABLE_WIN32 + +// BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any +// prefix/suffix headers that normally control things like struct +// packing and alignment. +// #define BOOST_DISABLE_ABI_HEADERS + +// BOOST_ABI_PREFIX: A prefix header to include in place of whatever +// boost.config would normally select, any replacement should set up +// struct packing and alignment options as required. +// #define BOOST_ABI_PREFIX my-header-name + +// BOOST_ABI_SUFFIX: A suffix header to include in place of whatever +// boost.config would normally select, any replacement should undo +// the effects of the prefix header. +// #define BOOST_ABI_SUFFIX my-header-name + +// BOOST_ALL_DYN_LINK: Forces all libraries that have separate source, +// to be linked as dll's rather than static libraries on Microsoft Windows +// (this macro is used to turn on __declspec(dllimport) modifiers, so that +// the compiler knows which symbols to look for in a dll rather than in a +// static library). Note that there may be some libraries that can only +// be statically linked (Boost.Test for example) and others which may only +// be dynamically linked (Boost.Threads for example), in these cases this +// macro has no effect. +// #define BOOST_ALL_DYN_LINK + +// BOOST_WHATEVER_DYN_LINK: Forces library "whatever" to be linked as a dll +// rather than a static library on Microsoft Windows: replace the WHATEVER +// part of the macro name with the name of the library that you want to +// dynamically link to, for example use BOOST_DATE_TIME_DYN_LINK or +// BOOST_REGEX_DYN_LINK etc (this macro is used to turn on __declspec(dllimport) +// modifiers, so that the compiler knows which symbols to look for in a dll +// rather than in a static library). +// Note that there may be some libraries that can only be statically linked +// (Boost.Test for example) and others which may only be dynamically linked +// (Boost.Threads for example), in these cases this macro is unsupported. +// #define BOOST_WHATEVER_DYN_LINK + +// BOOST_ALL_NO_LIB: Tells the config system not to automatically select +// which libraries to link against. +// Normally if a compiler supports #pragma lib, then the correct library +// build variant will be automatically selected and linked against, +// simply by the act of including one of that library's headers. +// This macro turns that feature off. +// #define BOOST_ALL_NO_LIB + +// BOOST_WHATEVER_NO_LIB: Tells the config system not to automatically +// select which library to link against for library "whatever", +// replace WHATEVER in the macro name with the name of the library; +// for example BOOST_DATE_TIME_NO_LIB or BOOST_REGEX_NO_LIB. +// Normally if a compiler supports #pragma lib, then the correct library +// build variant will be automatically selected and linked against, simply +// by the act of including one of that library's headers. This macro turns +// that feature off. +// #define BOOST_WHATEVER_NO_LIB + + + diff --git a/indexlib/boost-compat/config/user.hpp b/indexlib/boost-compat/config/user.hpp deleted file mode 100644 index 5a4a9d47..00000000 --- a/indexlib/boost-compat/config/user.hpp +++ /dev/null @@ -1,124 +0,0 @@ -// boost/config/user.hpp ---------------------------------------------------// - -// (C) Copyright John Maddock 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// Do not check in modified versions of this file, -// This file may be customized by the end user, but not by boost. - -// -// Use this file to define a site and compiler specific -// configuration policy: -// - -// define this to locate a compiler config file: -// #define BOOST_COMPILER_CONFIG - -// define this to locate a stdlib config file: -// #define BOOST_STDLIB_CONFIG - -// define this to locate a platform config file: -// #define BOOST_PLATFORM_CONFIG - -// define this to disable compiler config, -// use if your compiler config has nothing to set: -// #define BOOST_NO_COMPILER_CONFIG - -// define this to disable stdlib config, -// use if your stdlib config has nothing to set: -// #define BOOST_NO_STDLIB_CONFIG - -// define this to disable platform config, -// use if your platform config has nothing to set: -// #define BOOST_NO_PLATFORM_CONFIG - -// define this to disable all config options, -// excluding the user config. Use if your -// setup is fully ISO compliant, and has no -// useful extensions, or for autoconf generated -// setups: -// #define BOOST_NO_CONFIG - -// define this to make the config "optimistic" -// about unknown compiler versions. Normally -// unknown compiler versions are assumed to have -// all the defects of the last known version, however -// setting this flag, causes the config to assume -// that unknown compiler versions are fully conformant -// with the standard: -// #define BOOST_STRICT_CONFIG - -// define this to cause the config to halt compilation -// with an #error if it encounters anything unknown -- -// either an unknown compiler version or an unknown -// compiler/platform/library: -// #define BOOST_ASSERT_CONFIG - - -// define if you want to disable threading support, even -// when available: -// #define BOOST_DISABLE_THREADS - -// define when you want to disable Win32 specific features -// even when available: -// #define BOOST_DISABLE_WIN32 - -// BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any -// prefix/suffix headers that normally control things like struct -// packing and alignment. -// #define BOOST_DISABLE_ABI_HEADERS - -// BOOST_ABI_PREFIX: A prefix header to include in place of whatever -// boost.config would normally select, any replacement should set up -// struct packing and alignment options as required. -// #define BOOST_ABI_PREFIX my-header-name - -// BOOST_ABI_SUFFIX: A suffix header to include in place of whatever -// boost.config would normally select, any replacement should undo -// the effects of the prefix header. -// #define BOOST_ABI_SUFFIX my-header-name - -// BOOST_ALL_DYN_LINK: Forces all libraries that have separate source, -// to be linked as dll's rather than static libraries on Microsoft Windows -// (this macro is used to turn on __declspec(dllimport) modifiers, so that -// the compiler knows which symbols to look for in a dll rather than in a -// static library). Note that there may be some libraries that can only -// be statically linked (Boost.Test for example) and others which may only -// be dynamically linked (Boost.Threads for example), in these cases this -// macro has no effect. -// #define BOOST_ALL_DYN_LINK - -// BOOST_WHATEVER_DYN_LINK: Forces library "whatever" to be linked as a dll -// rather than a static library on Microsoft Windows: replace the WHATEVER -// part of the macro name with the name of the library that you want to -// dynamically link to, for example use BOOST_DATE_TIME_DYN_LINK or -// BOOST_REGEX_DYN_LINK etc (this macro is used to turn on __declspec(dllimport) -// modifiers, so that the compiler knows which symbols to look for in a dll -// rather than in a static library). -// Note that there may be some libraries that can only be statically linked -// (Boost.Test for example) and others which may only be dynamically linked -// (Boost.Threads for example), in these cases this macro is unsupported. -// #define BOOST_WHATEVER_DYN_LINK - -// BOOST_ALL_NO_LIB: Tells the config system not to automatically select -// which libraries to link against. -// Normally if a compiler supports #pragma lib, then the correct library -// build variant will be automatically selected and linked against, -// simply by the act of including one of that library's headers. -// This macro turns that feature off. -// #define BOOST_ALL_NO_LIB - -// BOOST_WHATEVER_NO_LIB: Tells the config system not to automatically -// select which library to link against for library "whatever", -// replace WHATEVER in the macro name with the name of the library; -// for example BOOST_DATE_TIME_NO_LIB or BOOST_REGEX_NO_LIB. -// Normally if a compiler supports #pragma lib, then the correct library -// build variant will be automatically selected and linked against, simply -// by the act of including one of that library's headers. This macro turns -// that feature off. -// #define BOOST_WHATEVER_NO_LIB - - - diff --git a/indexlib/boost-compat/intrusive_ptr.h b/indexlib/boost-compat/intrusive_ptr.h new file mode 100644 index 00000000..39b4b7b2 --- /dev/null +++ b/indexlib/boost-compat/intrusive_ptr.h @@ -0,0 +1,272 @@ +#ifndef BOOST_INTRUSIVE_PTR_H_INCLUDED +#define BOOST_INTRUSIVE_PTR_H_INCLUDED + +// +// intrusive_ptr.h +// +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation. +// + +#include + +#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash +# pragma warning(push) +# pragma warning(disable:4284) // odd return type for operator-> +#endif + +#include +#include + +#include // for std::less +#include // for std::basic_ostream + + +namespace boost +{ + +// +// intrusive_ptr +// +// A smart pointer that uses intrusive reference counting. +// +// Relies on unqualified calls to +// +// void intrusive_ptr_add_ref(T * p); +// void intrusive_ptr_release(T * p); +// +// (p != 0) +// +// The object is responsible for destroying itself. +// + +template class intrusive_ptr +{ +private: + + typedef intrusive_ptr this_type; + +public: + + typedef T element_type; + + intrusive_ptr(): p_(0) + { + } + + intrusive_ptr(T * p, bool add_ref = true): p_(p) + { + if(p_ != 0 && add_ref) intrusive_ptr_add_ref(p_); + } + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) + + template intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.get()) + { + if(p_ != 0) intrusive_ptr_add_ref(p_); + } + +#endif + + intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.p_) + { + if(p_ != 0) intrusive_ptr_add_ref(p_); + } + + ~intrusive_ptr() + { + if(p_ != 0) intrusive_ptr_release(p_); + } + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) + + template intrusive_ptr & operator=(intrusive_ptr const & rhs) + { + this_type(rhs).swap(*this); + return *this; + } + +#endif + + intrusive_ptr & operator=(intrusive_ptr const & rhs) + { + this_type(rhs).swap(*this); + return *this; + } + + intrusive_ptr & operator=(T * rhs) + { + this_type(rhs).swap(*this); + return *this; + } + + T * get() const + { + return p_; + } + + T & operator*() const + { + return *p_; + } + + T * operator->() const + { + return p_; + } + +#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return p_ != 0; + } + +#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + typedef T * (this_type::*unspecified_bool_type)() const; + + operator unspecified_bool_type() const // never throws + { + return p_ == 0? 0: &this_type::get; + } + +#else + + typedef T * this_type::*unspecified_bool_type; + + operator unspecified_bool_type () const + { + return p_ == 0? 0: &this_type::p_; + } + +#endif + + // operator! is a Borland-specific workaround + bool operator! () const + { + return p_ == 0; + } + + void swap(intrusive_ptr & rhs) + { + T * tmp = p_; + p_ = rhs.p_; + rhs.p_ = tmp; + } + +private: + + T * p_; +}; + +template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) +{ + return a.get() == b.get(); +} + +template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) +{ + return a.get() != b.get(); +} + +template inline bool operator==(intrusive_ptr const & a, T * b) +{ + return a.get() == b; +} + +template inline bool operator!=(intrusive_ptr const & a, T * b) +{ + return a.get() != b; +} + +template inline bool operator==(T * a, intrusive_ptr const & b) +{ + return a == b.get(); +} + +template inline bool operator!=(T * a, intrusive_ptr const & b) +{ + return a != b.get(); +} + +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) +{ + return a.get() != b.get(); +} + +#endif + +template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) +{ + return std::less()(a.get(), b.get()); +} + +template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs) +{ + lhs.swap(rhs); +} + +// mem_fn support + +template T * get_pointer(intrusive_ptr const & p) +{ + return p.get(); +} + +template intrusive_ptr static_pointer_cast(intrusive_ptr const & p) +{ + return static_cast(p.get()); +} + +template intrusive_ptr const_pointer_cast(intrusive_ptr const & p) +{ + return const_cast(p.get()); +} + +template intrusive_ptr dynamic_pointer_cast(intrusive_ptr const & p) +{ + return dynamic_cast(p.get()); +} + +// operator<< + +#if defined(__GNUC__) && (__GNUC__ < 3) + +template std::ostream & operator<< (std::ostream & os, intrusive_ptr const & p) +{ + os << p.get(); + return os; +} + +#else + +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT) +// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL +using std::basic_ostream; +template basic_ostream & operator<< (basic_ostream & os, intrusive_ptr const & p) +# else +template std::basic_ostream & operator<< (std::basic_ostream & os, intrusive_ptr const & p) +# endif +{ + os << p.get(); + return os; +} + +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#endif // #ifndef BOOST_INTRUSIVE_PTR_H_INCLUDED diff --git a/indexlib/boost-compat/intrusive_ptr.hpp b/indexlib/boost-compat/intrusive_ptr.hpp deleted file mode 100644 index 7efbadee..00000000 --- a/indexlib/boost-compat/intrusive_ptr.hpp +++ /dev/null @@ -1,272 +0,0 @@ -#ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED -#define BOOST_INTRUSIVE_PTR_HPP_INCLUDED - -// -// intrusive_ptr.hpp -// -// Copyright (c) 2001, 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation. -// - -#include - -#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash -# pragma warning(push) -# pragma warning(disable:4284) // odd return type for operator-> -#endif - -#include -#include - -#include // for std::less -#include // for std::basic_ostream - - -namespace boost -{ - -// -// intrusive_ptr -// -// A smart pointer that uses intrusive reference counting. -// -// Relies on unqualified calls to -// -// void intrusive_ptr_add_ref(T * p); -// void intrusive_ptr_release(T * p); -// -// (p != 0) -// -// The object is responsible for destroying itself. -// - -template class intrusive_ptr -{ -private: - - typedef intrusive_ptr this_type; - -public: - - typedef T element_type; - - intrusive_ptr(): p_(0) - { - } - - intrusive_ptr(T * p, bool add_ref = true): p_(p) - { - if(p_ != 0 && add_ref) intrusive_ptr_add_ref(p_); - } - -#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) - - template intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.get()) - { - if(p_ != 0) intrusive_ptr_add_ref(p_); - } - -#endif - - intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.p_) - { - if(p_ != 0) intrusive_ptr_add_ref(p_); - } - - ~intrusive_ptr() - { - if(p_ != 0) intrusive_ptr_release(p_); - } - -#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) - - template intrusive_ptr & operator=(intrusive_ptr const & rhs) - { - this_type(rhs).swap(*this); - return *this; - } - -#endif - - intrusive_ptr & operator=(intrusive_ptr const & rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - intrusive_ptr & operator=(T * rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - T * get() const - { - return p_; - } - - T & operator*() const - { - return *p_; - } - - T * operator->() const - { - return p_; - } - -#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) - - operator bool () const - { - return p_ != 0; - } - -#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - typedef T * (this_type::*unspecified_bool_type)() const; - - operator unspecified_bool_type() const // never throws - { - return p_ == 0? 0: &this_type::get; - } - -#else - - typedef T * this_type::*unspecified_bool_type; - - operator unspecified_bool_type () const - { - return p_ == 0? 0: &this_type::p_; - } - -#endif - - // operator! is a Borland-specific workaround - bool operator! () const - { - return p_ == 0; - } - - void swap(intrusive_ptr & rhs) - { - T * tmp = p_; - p_ = rhs.p_; - rhs.p_ = tmp; - } - -private: - - T * p_; -}; - -template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() != b.get(); -} - -template inline bool operator==(intrusive_ptr const & a, T * b) -{ - return a.get() == b; -} - -template inline bool operator!=(intrusive_ptr const & a, T * b) -{ - return a.get() != b; -} - -template inline bool operator==(T * a, intrusive_ptr const & b) -{ - return a == b.get(); -} - -template inline bool operator!=(T * a, intrusive_ptr const & b) -{ - return a != b.get(); -} - -#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 - -// Resolve the ambiguity between our op!= and the one in rel_ops - -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() != b.get(); -} - -#endif - -template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return std::less()(a.get(), b.get()); -} - -template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs) -{ - lhs.swap(rhs); -} - -// mem_fn support - -template T * get_pointer(intrusive_ptr const & p) -{ - return p.get(); -} - -template intrusive_ptr static_pointer_cast(intrusive_ptr const & p) -{ - return static_cast(p.get()); -} - -template intrusive_ptr const_pointer_cast(intrusive_ptr const & p) -{ - return const_cast(p.get()); -} - -template intrusive_ptr dynamic_pointer_cast(intrusive_ptr const & p) -{ - return dynamic_cast(p.get()); -} - -// operator<< - -#if defined(__GNUC__) && (__GNUC__ < 3) - -template std::ostream & operator<< (std::ostream & os, intrusive_ptr const & p) -{ - os << p.get(); - return os; -} - -#else - -# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT) -// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL -using std::basic_ostream; -template basic_ostream & operator<< (basic_ostream & os, intrusive_ptr const & p) -# else -template std::basic_ostream & operator<< (std::basic_ostream & os, intrusive_ptr const & p) -# endif -{ - os << p.get(); - return os; -} - -#endif - -} // namespace boost - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -#endif // #ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED diff --git a/indexlib/boost-compat/next_prior.h b/indexlib/boost-compat/next_prior.h new file mode 100644 index 00000000..cdacf29c --- /dev/null +++ b/indexlib/boost-compat/next_prior.h @@ -0,0 +1,51 @@ +// Boost next_prior.h header file ---------------------------------------// + +// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/utility for documentation. + +// Revision History +// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker) + +#ifndef BOOST_NEXT_PRIOR_H_INCLUDED +#define BOOST_NEXT_PRIOR_H_INCLUDED + +#include + +namespace boost { + +// Helper functions for classes like bidirectional iterators not supporting +// operator+ and operator- +// +// Usage: +// const std::list::iterator p = get_some_iterator(); +// const std::list::iterator prev = boost::prior(p); +// const std::list::iterator next = boost::next(prev, 2); + +// Contributed by Dave Abrahams + +template +inline T next(T x) { return ++x; } + +template +inline T next(T x, Distance n) +{ + std::advance(x, n); + return x; +} + +template +inline T prior(T x) { return --x; } + +template +inline T prior(T x, Distance n) +{ + std::advance(x, -n); + return x; +} + +} // namespace boost + +#endif // BOOST_NEXT_PRIOR_H_INCLUDED diff --git a/indexlib/boost-compat/next_prior.hpp b/indexlib/boost-compat/next_prior.hpp deleted file mode 100644 index e1d2e428..00000000 --- a/indexlib/boost-compat/next_prior.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Boost next_prior.hpp header file ---------------------------------------// - -// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/utility for documentation. - -// Revision History -// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker) - -#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED -#define BOOST_NEXT_PRIOR_HPP_INCLUDED - -#include - -namespace boost { - -// Helper functions for classes like bidirectional iterators not supporting -// operator+ and operator- -// -// Usage: -// const std::list::iterator p = get_some_iterator(); -// const std::list::iterator prev = boost::prior(p); -// const std::list::iterator next = boost::next(prev, 2); - -// Contributed by Dave Abrahams - -template -inline T next(T x) { return ++x; } - -template -inline T next(T x, Distance n) -{ - std::advance(x, n); - return x; -} - -template -inline T prior(T x) { return --x; } - -template -inline T prior(T x, Distance n) -{ - std::advance(x, -n); - return x; -} - -} // namespace boost - -#endif // BOOST_NEXT_PRIOR_HPP_INCLUDED diff --git a/indexlib/boost-compat/noncopyable.h b/indexlib/boost-compat/noncopyable.h new file mode 100644 index 00000000..0d94ea6a --- /dev/null +++ b/indexlib/boost-compat/noncopyable.h @@ -0,0 +1,36 @@ +// Boost noncopyable.h header file --------------------------------------// + +// (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/utility for documentation. + +#ifndef BOOST_NONCOPYABLE_H_INCLUDED +#define BOOST_NONCOPYABLE_H_INCLUDED + +namespace boost { + +// Private copy constructor and copy assignment ensure classes derived from +// class noncopyable cannot be copied. + +// Contributed by Dave Abrahams + +namespace noncopyable_ // protection from unintended ADL +{ + class noncopyable + { + protected: + noncopyable() {} + ~noncopyable() {} + private: // emphasize the following members are private + noncopyable( const noncopyable& ); + const noncopyable& operator=( const noncopyable& ); + }; +} + +typedef noncopyable_::noncopyable noncopyable; + +} // namespace boost + +#endif // BOOST_NONCOPYABLE_H_INCLUDED diff --git a/indexlib/boost-compat/noncopyable.hpp b/indexlib/boost-compat/noncopyable.hpp deleted file mode 100644 index 7770bdbd..00000000 --- a/indexlib/boost-compat/noncopyable.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Boost noncopyable.hpp header file --------------------------------------// - -// (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/utility for documentation. - -#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED -#define BOOST_NONCOPYABLE_HPP_INCLUDED - -namespace boost { - -// Private copy constructor and copy assignment ensure classes derived from -// class noncopyable cannot be copied. - -// Contributed by Dave Abrahams - -namespace noncopyable_ // protection from unintended ADL -{ - class noncopyable - { - protected: - noncopyable() {} - ~noncopyable() {} - private: // emphasize the following members are private - noncopyable( const noncopyable& ); - const noncopyable& operator=( const noncopyable& ); - }; -} - -typedef noncopyable_::noncopyable noncopyable; - -} // namespace boost - -#endif // BOOST_NONCOPYABLE_HPP_INCLUDED diff --git a/indexlib/boost-compat/remove_cv.h b/indexlib/boost-compat/remove_cv.h new file mode 100644 index 00000000..c59970a8 --- /dev/null +++ b/indexlib/boost-compat/remove_cv.h @@ -0,0 +1,61 @@ +#ifndef BOOST_TT_REMOVE_CV_H_INCLUDED +#define BOOST_TT_REMOVE_CV_H_INCLUDED +#ifndef BOOST_TT_DETAIL_CV_TRAITS_IMPL_H_INCLUDED +#define BOOST_TT_DETAIL_CV_TRAITS_IMPL_H_INCLUDED +// ADAPTED (TAKEN) FROM BOOST +// +// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard +// Hinnant & John Maddock 2000. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. +// + + + + +namespace boost { +namespace detail { + +// implementation helper: + +template struct cv_traits_imp {}; + +template +struct cv_traits_imp +{ + typedef T unqualified_type; +}; + +template +struct cv_traits_imp +{ + typedef T unqualified_type; +}; + +template +struct cv_traits_imp +{ + typedef T unqualified_type; +}; + +template +struct cv_traits_imp +{ + typedef T unqualified_type; +}; + +} // namespace detail + +template +struct remove_cv { + typedef typename detail::cv_traits_imp::unqualified_type type; +}; +} // namespace boost + + + +#endif +#endif diff --git a/indexlib/boost-compat/remove_cv.hpp b/indexlib/boost-compat/remove_cv.hpp deleted file mode 100644 index ec7c1a95..00000000 --- a/indexlib/boost-compat/remove_cv.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef BOOST_TT_REMOVE_CV_HPP_INCLUDED -#define BOOST_TT_REMOVE_CV_HPP_INCLUDED -#ifndef BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED -#define BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED -// ADAPTED (TAKEN) FROM BOOST -// -// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard -// Hinnant & John Maddock 2000. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt). -// -// See http://www.boost.org/libs/type_traits for most recent version including documentation. -// - - - - -namespace boost { -namespace detail { - -// implementation helper: - -template struct cv_traits_imp {}; - -template -struct cv_traits_imp -{ - typedef T unqualified_type; -}; - -template -struct cv_traits_imp -{ - typedef T unqualified_type; -}; - -template -struct cv_traits_imp -{ - typedef T unqualified_type; -}; - -template -struct cv_traits_imp -{ - typedef T unqualified_type; -}; - -} // namespace detail - -template -struct remove_cv { - typedef typename detail::cv_traits_imp::unqualified_type type; -}; -} // namespace boost - - - -#endif -#endif diff --git a/indexlib/boost-compat/scoped_ptr.h b/indexlib/boost-compat/scoped_ptr.h new file mode 100644 index 00000000..60078bf1 --- /dev/null +++ b/indexlib/boost-compat/scoped_ptr.h @@ -0,0 +1,118 @@ +#ifndef BOOST_SCOPED_PTR_H_INCLUDED +#define BOOST_SCOPED_PTR_H_INCLUDED + +// ADAPTED FOR indexlib + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm +// + +#include "checked_delete.h" + +#include // for std::auto_ptr +#include + +namespace boost +{ + + +// scoped_ptr mimics a built-in pointer except that it guarantees deletion +// of the object pointed to, either on destruction of the scoped_ptr or via +// an explicit reset(). scoped_ptr is a simple solution for simple needs; +// use shared_ptr or std::auto_ptr if your needs are more complex. + +template class scoped_ptr // noncopyable +{ +private: + + T * ptr; + + scoped_ptr(scoped_ptr const &); + scoped_ptr & operator=(scoped_ptr const &); + + typedef scoped_ptr this_type; + +public: + + typedef T element_type; + + explicit scoped_ptr(T * p = 0): ptr(p) // never throws + { + } + + + explicit scoped_ptr(std::auto_ptr p): ptr(p.release()) // never throws + { + } + + ~scoped_ptr() // never throws + { + boost::checked_delete(ptr); + } + + void reset(T * p = 0) // never throws + { + assert(p == 0 || p != ptr); // catch self-reset errors + this_type(p).swap(*this); + } + + T & operator*() const // never throws + { + assert(ptr != 0); + return *ptr; + } + + T * operator->() const // never throws + { + assert(ptr != 0); + return ptr; + } + + T * get() const // never throws + { + return ptr; + } + + // implicit conversion to "bool" + + typedef T * this_type::*unspecified_bool_type; + + operator unspecified_bool_type() const // never throws + { + return ptr == 0? 0: &this_type::ptr; + } + + bool operator! () const // never throws + { + return ptr == 0; + } + + void swap(scoped_ptr & b) // never throws + { + T * tmp = b.ptr; + b.ptr = ptr; + ptr = tmp; + } +}; + +template inline void swap(scoped_ptr & a, scoped_ptr & b) // never throws +{ + a.swap(b); +} + +// get_pointer(p) is a generic way to say p.get() + +template inline T * get_pointer(scoped_ptr const & p) +{ + return p.get(); +} + +} // namespace boost + +#endif // #ifndef BOOST_SCOPED_PTR_H_INCLUDED diff --git a/indexlib/boost-compat/scoped_ptr.hpp b/indexlib/boost-compat/scoped_ptr.hpp deleted file mode 100644 index 1260066a..00000000 --- a/indexlib/boost-compat/scoped_ptr.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED -#define BOOST_SCOPED_PTR_HPP_INCLUDED - -// ADAPTED FOR indexlib - -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm -// - -#include "checked_delete.hpp" - -#include // for std::auto_ptr -#include - -namespace boost -{ - - -// scoped_ptr mimics a built-in pointer except that it guarantees deletion -// of the object pointed to, either on destruction of the scoped_ptr or via -// an explicit reset(). scoped_ptr is a simple solution for simple needs; -// use shared_ptr or std::auto_ptr if your needs are more complex. - -template class scoped_ptr // noncopyable -{ -private: - - T * ptr; - - scoped_ptr(scoped_ptr const &); - scoped_ptr & operator=(scoped_ptr const &); - - typedef scoped_ptr this_type; - -public: - - typedef T element_type; - - explicit scoped_ptr(T * p = 0): ptr(p) // never throws - { - } - - - explicit scoped_ptr(std::auto_ptr p): ptr(p.release()) // never throws - { - } - - ~scoped_ptr() // never throws - { - boost::checked_delete(ptr); - } - - void reset(T * p = 0) // never throws - { - assert(p == 0 || p != ptr); // catch self-reset errors - this_type(p).swap(*this); - } - - T & operator*() const // never throws - { - assert(ptr != 0); - return *ptr; - } - - T * operator->() const // never throws - { - assert(ptr != 0); - return ptr; - } - - T * get() const // never throws - { - return ptr; - } - - // implicit conversion to "bool" - - typedef T * this_type::*unspecified_bool_type; - - operator unspecified_bool_type() const // never throws - { - return ptr == 0? 0: &this_type::ptr; - } - - bool operator! () const // never throws - { - return ptr == 0; - } - - void swap(scoped_ptr & b) // never throws - { - T * tmp = b.ptr; - b.ptr = ptr; - ptr = tmp; - } -}; - -template inline void swap(scoped_ptr & a, scoped_ptr & b) // never throws -{ - a.swap(b); -} - -// get_pointer(p) is a generic way to say p.get() - -template inline T * get_pointer(scoped_ptr const & p) -{ - return p.get(); -} - -} // namespace boost - -#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED diff --git a/indexlib/boost-compat/shared_ptr.h b/indexlib/boost-compat/shared_ptr.h new file mode 100644 index 00000000..c236e3bd --- /dev/null +++ b/indexlib/boost-compat/shared_ptr.h @@ -0,0 +1,473 @@ +#ifndef BOOST_SHARED_PTR_H_INCLUDED +#define BOOST_SHARED_PTR_H_INCLUDED + +// +// shared_ptr.h +// +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002, 2003 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. +// + +#include // for broken compiler workarounds + +#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) +#include +#else + +#include +#include +#include +#include +#include + +#include // for std::auto_ptr +#include // for std::swap +#include // for std::less +#include // for std::bad_cast +#include // for std::basic_ostream + +#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash +# pragma warning(push) +# pragma warning(disable:4284) // odd return type for operator-> +#endif + +namespace boost +{ + +template class weak_ptr; +template class enable_shared_from_this; + +namespace detail +{ + +struct static_cast_tag {}; +struct const_cast_tag {}; +struct dynamic_cast_tag {}; +struct polymorphic_cast_tag {}; + +template struct shared_ptr_traits +{ + typedef T & reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +#endif + +// enable_shared_from_this support + +template void sp_enable_shared_from_this( shared_count const & pn, boost::enable_shared_from_this const * pe, Y const * px ) +{ + if(pe != 0) pe->_internal_weak_this._internal_assign(const_cast(px), pn); +} + +inline void sp_enable_shared_from_this( shared_count const & /*pn*/, ... ) +{ +} + +} // namespace detail + + +// +// shared_ptr +// +// An enhanced relative of scoped_ptr with reference counted copy semantics. +// The object pointed to is deleted when the last shared_ptr pointing to it +// is destroyed or reset. +// + +template class shared_ptr +{ +private: + + // Borland 5.5.1 specific workaround + typedef shared_ptr this_type; + +public: + + typedef T element_type; + typedef T value_type; + typedef T * pointer; + typedef typename detail::shared_ptr_traits::reference reference; + + shared_ptr(): px(0), pn() // never throws in 1.30+ + { + } + + template + explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter()) // Y must be complete + { + detail::sp_enable_shared_from_this( pn, p, p ); + } + + // + // Requirements: D's copy constructor must not throw + // + // shared_ptr will release p by calling d(p) + // + + template shared_ptr(Y * p, D d): px(p), pn(p, d) + { + detail::sp_enable_shared_from_this( pn, p, p ); + } + +// generated copy constructor, assignment, destructor are fine... + +// except that Borland C++ has a bug, and g++ with -Wsynth warns +#if defined(__BORLANDC__) || defined(__GNUC__) + + shared_ptr & operator=(shared_ptr const & r) // never throws + { + px = r.px; + pn = r.pn; // shared_count::op= doesn't throw + return *this; + } + +#endif + + template + explicit shared_ptr(weak_ptr const & r): pn(r.pn) // may throw + { + // it is now safe to copy r.px, as pn(r.pn) did not throw + px = r.px; + } + + template + shared_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws + { + } + + template + shared_ptr(shared_ptr const & r, detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn) + { + } + + template + shared_ptr(shared_ptr const & r, detail::const_cast_tag): px(const_cast(r.px)), pn(r.pn) + { + } + + template + shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) + { + if(px == 0) // need to allocate new counter -- the cast failed + { + pn = detail::shared_count(); + } + } + + template + shared_ptr(shared_ptr const & r, detail::polymorphic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) + { + if(px == 0) + { + boost::throw_exception(std::bad_cast()); + } + } + +#ifndef BOOST_NO_AUTO_PTR + + template + explicit shared_ptr(std::auto_ptr & r): px(r.get()), pn() + { + Y * tmp = r.get(); + pn = detail::shared_count(r); + detail::sp_enable_shared_from_this( pn, tmp, tmp ); + } + +#endif + +#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200) + + template + shared_ptr & operator=(shared_ptr const & r) // never throws + { + px = r.px; + pn = r.pn; // shared_count::op= doesn't throw + return *this; + } + +#endif + +#ifndef BOOST_NO_AUTO_PTR + + template + shared_ptr & operator=(std::auto_ptr & r) + { + this_type(r).swap(*this); + return *this; + } + +#endif + + void reset() // never throws in 1.30+ + { + this_type().swap(*this); + } + + template void reset(Y * p) // Y must be complete + { + BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors + this_type(p).swap(*this); + } + + template void reset(Y * p, D d) + { + this_type(p, d).swap(*this); + } + + reference operator* () const // never throws + { + BOOST_ASSERT(px != 0); + return *px; + } + + T * operator-> () const // never throws + { + BOOST_ASSERT(px != 0); + return px; + } + + T * get() const // never throws + { + return px; + } + + // implicit conversion to "bool" + +#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) + + operator bool () const + { + return px != 0; + } + +#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + typedef T * (this_type::*unspecified_bool_type)() const; + + operator unspecified_bool_type() const // never throws + { + return px == 0? 0: &this_type::get; + } + +#else + + typedef T * this_type::*unspecified_bool_type; + + operator unspecified_bool_type() const // never throws + { + return px == 0? 0: &this_type::px; + } + +#endif + + // operator! is redundant, but some compilers need it + + bool operator! () const // never throws + { + return px == 0; + } + + bool unique() const // never throws + { + return pn.unique(); + } + + long use_count() const // never throws + { + return pn.use_count(); + } + + void swap(shared_ptr & other) // never throws + { + std::swap(px, other.px); + pn.swap(other.pn); + } + + template bool _internal_less(shared_ptr const & rhs) const + { + return pn < rhs.pn; + } + + void * _internal_get_deleter(std::type_info const & ti) const + { + return pn.get_deleter(ti); + } + +// Tasteless as this may seem, making all members public allows member templates +// to work in the absence of member template friends. (Matthew Langston) + +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + +private: + + template friend class shared_ptr; + template friend class weak_ptr; + + +#endif + + T * px; // contained pointer + detail::shared_count pn; // reference counter + +}; // shared_ptr + +template inline bool operator==(shared_ptr const & a, shared_ptr const & b) +{ + return a.get() == b.get(); +} + +template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) +{ + return a.get() != b.get(); +} + +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) +{ + return a.get() != b.get(); +} + +#endif + +template inline bool operator<(shared_ptr const & a, shared_ptr const & b) +{ + return a._internal_less(b); +} + +template inline void swap(shared_ptr & a, shared_ptr & b) +{ + a.swap(b); +} + +template shared_ptr static_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::static_cast_tag()); +} + +template shared_ptr const_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::const_cast_tag()); +} + +template shared_ptr dynamic_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::dynamic_cast_tag()); +} + +// shared_*_cast names are deprecated. Use *_pointer_cast instead. + +template shared_ptr shared_static_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::static_cast_tag()); +} + +template shared_ptr shared_dynamic_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::dynamic_cast_tag()); +} + +template shared_ptr shared_polymorphic_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::polymorphic_cast_tag()); +} + +template shared_ptr shared_polymorphic_downcast(shared_ptr const & r) +{ + BOOST_ASSERT(dynamic_cast(r.get()) == r.get()); + return shared_static_cast(r); +} + +// get_pointer() enables boost::mem_fn to recognize shared_ptr + +template inline T * get_pointer(shared_ptr const & p) +{ + return p.get(); +} + +// operator<< + +#if defined(__GNUC__) && (__GNUC__ < 3) + +template std::ostream & operator<< (std::ostream & os, shared_ptr const & p) +{ + os << p.get(); + return os; +} + +#else + +# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT) +// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL +using std::basic_ostream; +template basic_ostream & operator<< (basic_ostream & os, shared_ptr const & p) +# else +template std::basic_ostream & operator<< (std::basic_ostream & os, shared_ptr const & p) +# endif +{ + os << p.get(); + return os; +} + +#endif + +// get_deleter (experimental) + +#if (defined(__GNUC__) && (__GNUC__ < 3)) || (defined(__EDG_VERSION__) && (__EDG_VERSION__ <= 238)) + +// g++ 2.9x doesn't allow static_cast(void *) +// apparently EDG 2.38 also doesn't accept it + +template D * get_deleter(shared_ptr const & p) +{ + void const * q = p._internal_get_deleter(typeid(D)); + return const_cast(static_cast(q)); +} + +#else + +template D * get_deleter(shared_ptr const & p) +{ + return static_cast(p._internal_get_deleter(typeid(D))); +} + +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) + +#endif // #ifndef BOOST_SHARED_PTR_H_INCLUDED diff --git a/indexlib/boost-compat/shared_ptr.hpp b/indexlib/boost-compat/shared_ptr.hpp deleted file mode 100644 index 0a3bf6d8..00000000 --- a/indexlib/boost-compat/shared_ptr.hpp +++ /dev/null @@ -1,473 +0,0 @@ -#ifndef BOOST_SHARED_PTR_HPP_INCLUDED -#define BOOST_SHARED_PTR_HPP_INCLUDED - -// -// shared_ptr.hpp -// -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002, 2003 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. -// - -#include // for broken compiler workarounds - -#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) -#include -#else - -#include -#include -#include -#include -#include - -#include // for std::auto_ptr -#include // for std::swap -#include // for std::less -#include // for std::bad_cast -#include // for std::basic_ostream - -#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash -# pragma warning(push) -# pragma warning(disable:4284) // odd return type for operator-> -#endif - -namespace boost -{ - -template class weak_ptr; -template class enable_shared_from_this; - -namespace detail -{ - -struct static_cast_tag {}; -struct const_cast_tag {}; -struct dynamic_cast_tag {}; -struct polymorphic_cast_tag {}; - -template struct shared_ptr_traits -{ - typedef T & reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -#endif - -// enable_shared_from_this support - -template void sp_enable_shared_from_this( shared_count const & pn, boost::enable_shared_from_this const * pe, Y const * px ) -{ - if(pe != 0) pe->_internal_weak_this._internal_assign(const_cast(px), pn); -} - -inline void sp_enable_shared_from_this( shared_count const & /*pn*/, ... ) -{ -} - -} // namespace detail - - -// -// shared_ptr -// -// An enhanced relative of scoped_ptr with reference counted copy semantics. -// The object pointed to is deleted when the last shared_ptr pointing to it -// is destroyed or reset. -// - -template class shared_ptr -{ -private: - - // Borland 5.5.1 specific workaround - typedef shared_ptr this_type; - -public: - - typedef T element_type; - typedef T value_type; - typedef T * pointer; - typedef typename detail::shared_ptr_traits::reference reference; - - shared_ptr(): px(0), pn() // never throws in 1.30+ - { - } - - template - explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter()) // Y must be complete - { - detail::sp_enable_shared_from_this( pn, p, p ); - } - - // - // Requirements: D's copy constructor must not throw - // - // shared_ptr will release p by calling d(p) - // - - template shared_ptr(Y * p, D d): px(p), pn(p, d) - { - detail::sp_enable_shared_from_this( pn, p, p ); - } - -// generated copy constructor, assignment, destructor are fine... - -// except that Borland C++ has a bug, and g++ with -Wsynth warns -#if defined(__BORLANDC__) || defined(__GNUC__) - - shared_ptr & operator=(shared_ptr const & r) // never throws - { - px = r.px; - pn = r.pn; // shared_count::op= doesn't throw - return *this; - } - -#endif - - template - explicit shared_ptr(weak_ptr const & r): pn(r.pn) // may throw - { - // it is now safe to copy r.px, as pn(r.pn) did not throw - px = r.px; - } - - template - shared_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws - { - } - - template - shared_ptr(shared_ptr const & r, detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn) - { - } - - template - shared_ptr(shared_ptr const & r, detail::const_cast_tag): px(const_cast(r.px)), pn(r.pn) - { - } - - template - shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) - { - if(px == 0) // need to allocate new counter -- the cast failed - { - pn = detail::shared_count(); - } - } - - template - shared_ptr(shared_ptr const & r, detail::polymorphic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) - { - if(px == 0) - { - boost::throw_exception(std::bad_cast()); - } - } - -#ifndef BOOST_NO_AUTO_PTR - - template - explicit shared_ptr(std::auto_ptr & r): px(r.get()), pn() - { - Y * tmp = r.get(); - pn = detail::shared_count(r); - detail::sp_enable_shared_from_this( pn, tmp, tmp ); - } - -#endif - -#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200) - - template - shared_ptr & operator=(shared_ptr const & r) // never throws - { - px = r.px; - pn = r.pn; // shared_count::op= doesn't throw - return *this; - } - -#endif - -#ifndef BOOST_NO_AUTO_PTR - - template - shared_ptr & operator=(std::auto_ptr & r) - { - this_type(r).swap(*this); - return *this; - } - -#endif - - void reset() // never throws in 1.30+ - { - this_type().swap(*this); - } - - template void reset(Y * p) // Y must be complete - { - BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors - this_type(p).swap(*this); - } - - template void reset(Y * p, D d) - { - this_type(p, d).swap(*this); - } - - reference operator* () const // never throws - { - BOOST_ASSERT(px != 0); - return *px; - } - - T * operator-> () const // never throws - { - BOOST_ASSERT(px != 0); - return px; - } - - T * get() const // never throws - { - return px; - } - - // implicit conversion to "bool" - -#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530) - - operator bool () const - { - return px != 0; - } - -#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - typedef T * (this_type::*unspecified_bool_type)() const; - - operator unspecified_bool_type() const // never throws - { - return px == 0? 0: &this_type::get; - } - -#else - - typedef T * this_type::*unspecified_bool_type; - - operator unspecified_bool_type() const // never throws - { - return px == 0? 0: &this_type::px; - } - -#endif - - // operator! is redundant, but some compilers need it - - bool operator! () const // never throws - { - return px == 0; - } - - bool unique() const // never throws - { - return pn.unique(); - } - - long use_count() const // never throws - { - return pn.use_count(); - } - - void swap(shared_ptr & other) // never throws - { - std::swap(px, other.px); - pn.swap(other.pn); - } - - template bool _internal_less(shared_ptr const & rhs) const - { - return pn < rhs.pn; - } - - void * _internal_get_deleter(std::type_info const & ti) const - { - return pn.get_deleter(ti); - } - -// Tasteless as this may seem, making all members public allows member templates -// to work in the absence of member template friends. (Matthew Langston) - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - -private: - - template friend class shared_ptr; - template friend class weak_ptr; - - -#endif - - T * px; // contained pointer - detail::shared_count pn; // reference counter - -}; // shared_ptr - -template inline bool operator==(shared_ptr const & a, shared_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) -{ - return a.get() != b.get(); -} - -#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 - -// Resolve the ambiguity between our op!= and the one in rel_ops - -template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) -{ - return a.get() != b.get(); -} - -#endif - -template inline bool operator<(shared_ptr const & a, shared_ptr const & b) -{ - return a._internal_less(b); -} - -template inline void swap(shared_ptr & a, shared_ptr & b) -{ - a.swap(b); -} - -template shared_ptr static_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::static_cast_tag()); -} - -template shared_ptr const_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::const_cast_tag()); -} - -template shared_ptr dynamic_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::dynamic_cast_tag()); -} - -// shared_*_cast names are deprecated. Use *_pointer_cast instead. - -template shared_ptr shared_static_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::static_cast_tag()); -} - -template shared_ptr shared_dynamic_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::dynamic_cast_tag()); -} - -template shared_ptr shared_polymorphic_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::polymorphic_cast_tag()); -} - -template shared_ptr shared_polymorphic_downcast(shared_ptr const & r) -{ - BOOST_ASSERT(dynamic_cast(r.get()) == r.get()); - return shared_static_cast(r); -} - -// get_pointer() enables boost::mem_fn to recognize shared_ptr - -template inline T * get_pointer(shared_ptr const & p) -{ - return p.get(); -} - -// operator<< - -#if defined(__GNUC__) && (__GNUC__ < 3) - -template std::ostream & operator<< (std::ostream & os, shared_ptr const & p) -{ - os << p.get(); - return os; -} - -#else - -# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT) -// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL -using std::basic_ostream; -template basic_ostream & operator<< (basic_ostream & os, shared_ptr const & p) -# else -template std::basic_ostream & operator<< (std::basic_ostream & os, shared_ptr const & p) -# endif -{ - os << p.get(); - return os; -} - -#endif - -// get_deleter (experimental) - -#if (defined(__GNUC__) && (__GNUC__ < 3)) || (defined(__EDG_VERSION__) && (__EDG_VERSION__ <= 238)) - -// g++ 2.9x doesn't allow static_cast(void *) -// apparently EDG 2.38 also doesn't accept it - -template D * get_deleter(shared_ptr const & p) -{ - void const * q = p._internal_get_deleter(typeid(D)); - return const_cast(static_cast(q)); -} - -#else - -template D * get_deleter(shared_ptr const & p) -{ - return static_cast(p._internal_get_deleter(typeid(D))); -} - -#endif - -} // namespace boost - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) - -#endif // #ifndef BOOST_SHARED_PTR_HPP_INCLUDED diff --git a/indexlib/boost-compat/smart_ptr.h b/indexlib/boost-compat/smart_ptr.h new file mode 100644 index 00000000..578a48e4 --- /dev/null +++ b/indexlib/boost-compat/smart_ptr.h @@ -0,0 +1,31 @@ +#ifndef LPC_SMART_PTR_H1119293317_INCLUDE_GUARD_ +#define LPC_SMART_PTR_H1119293317_INCLUDE_GUARD_ + +// +// smart_ptr.h +// +// For convenience, this header includes the rest of the smart +// pointer library headers. +// +// Copyright (c) 2003 Peter Dimov Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// http://www.boost.org/libs/smart_ptr/smart_ptr.htm +// + +#include + +#include +#include +#include +#include + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) +# include +# include +# include +#endif + + +#endif /* LPC_SMART_PTR_H1119293317_INCLUDE_GUARD_ */ diff --git a/indexlib/boost-compat/smart_ptr.hpp b/indexlib/boost-compat/smart_ptr.hpp deleted file mode 100644 index c10de457..00000000 --- a/indexlib/boost-compat/smart_ptr.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef LPC_SMART_PTR_HPP1119293317_INCLUDE_GUARD_ -#define LPC_SMART_PTR_HPP1119293317_INCLUDE_GUARD_ - -// -// smart_ptr.hpp -// -// For convenience, this header includes the rest of the smart -// pointer library headers. -// -// Copyright (c) 2003 Peter Dimov Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// http://www.boost.org/libs/smart_ptr/smart_ptr.htm -// - -#include - -#include -#include -#include -#include - -#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES) -# include -# include -# include -#endif - - -#endif /* LPC_SMART_PTR_HPP1119293317_INCLUDE_GUARD_ */ diff --git a/indexlib/boost-compat/static_assert.h b/indexlib/boost-compat/static_assert.h new file mode 100644 index 00000000..1d020c9f --- /dev/null +++ b/indexlib/boost-compat/static_assert.h @@ -0,0 +1,11 @@ +#ifndef LPC_STATIC_ASSERT_H1119293317_INCLUDE_GUARD_ +#define LPC_STATIC_ASSERT_H1119293317_INCLUDE_GUARD_ + +#ifdef HAVE_BOOST +#include +#elif !defined( BOOST_STATIC_ASSERT ) +#define BOOST_STATIC_ASSERT( x ) +#endif + + +#endif /* LPC_STATIC_ASSERT_H1119293317_INCLUDE_GUARD_ */ diff --git a/indexlib/boost-compat/static_assert.hpp b/indexlib/boost-compat/static_assert.hpp deleted file mode 100644 index 76de9c49..00000000 --- a/indexlib/boost-compat/static_assert.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef LPC_STATIC_ASSERT_HPP1119293317_INCLUDE_GUARD_ -#define LPC_STATIC_ASSERT_HPP1119293317_INCLUDE_GUARD_ - -#ifdef HAVE_BOOST -#include -#elif !defined( BOOST_STATIC_ASSERT ) -#define BOOST_STATIC_ASSERT( x ) -#endif - - -#endif /* LPC_STATIC_ASSERT_HPP1119293317_INCLUDE_GUARD_ */ diff --git a/indexlib/boost-compat/weak_ptr.h b/indexlib/boost-compat/weak_ptr.h new file mode 100644 index 00000000..338e5221 --- /dev/null +++ b/indexlib/boost-compat/weak_ptr.h @@ -0,0 +1,192 @@ +#ifndef BOOST_WEAK_PTR_H_INCLUDED +#define BOOST_WEAK_PTR_H_INCLUDED + +// +// weak_ptr.h +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/smart_ptr/weak_ptr.htm for documentation. +// + +#include + +#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash +# pragma warning(push) +# pragma warning(disable:4284) // odd return type for operator-> +#endif + +namespace boost +{ + +template class weak_ptr +{ +private: + + // Borland 5.5.1 specific workarounds + typedef weak_ptr this_type; + +public: + + typedef T element_type; + + weak_ptr(): px(0), pn() // never throws in 1.30+ + { + } + +// generated copy constructor, assignment, destructor are fine + + +// +// The "obvious" converting constructor implementation: +// +// template +// weak_ptr(weak_ptr const & r): px(r.px), pn(r.pn) // never throws +// { +// } +// +// has a serious problem. +// +// r.px may already have been invalidated. The px(r.px) +// conversion may require access to *r.px (virtual inheritance). +// +// It is not possible to avoid spurious access violations since +// in multithreaded programs r.px may be invalidated at any point. +// + + template + weak_ptr(weak_ptr const & r): pn(r.pn) // never throws + { + px = r.lock().get(); + } + + template + weak_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws + { + } + +#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200) + + template + weak_ptr & operator=(weak_ptr const & r) // never throws + { + px = r.lock().get(); + pn = r.pn; + return *this; + } + + template + weak_ptr & operator=(shared_ptr const & r) // never throws + { + px = r.px; + pn = r.pn; + return *this; + } + +#endif + + shared_ptr lock() const // never throws + { +#if defined(BOOST_HAS_THREADS) + + // optimization: avoid throw overhead + if(expired()) + { + return shared_ptr(); + } + + try + { + return shared_ptr(*this); + } + catch(bad_weak_ptr const &) + { + // Q: how can we get here? + // A: another thread may have invalidated r after the use_count test above. + return shared_ptr(); + } + +#else + + // optimization: avoid try/catch overhead when single threaded + return expired()? shared_ptr(): shared_ptr(*this); + +#endif + } + + long use_count() const // never throws + { + return pn.use_count(); + } + + bool expired() const // never throws + { + return pn.use_count() == 0; + } + + void reset() // never throws in 1.30+ + { + this_type().swap(*this); + } + + void swap(this_type & other) // never throws + { + std::swap(px, other.px); + pn.swap(other.pn); + } + + void _internal_assign(T * px2, detail::shared_count const & pn2) + { + px = px2; + pn = pn2; + } + + template bool _internal_less(weak_ptr const & rhs) const + { + return pn < rhs.pn; + } + +// Tasteless as this may seem, making all members public allows member templates +// to work in the absence of member template friends. (Matthew Langston) + +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + +private: + + template friend class weak_ptr; + template friend class shared_ptr; + +#endif + + T * px; // contained pointer + detail::weak_count pn; // reference counter + +}; // weak_ptr + +template inline bool operator<(weak_ptr const & a, weak_ptr const & b) +{ + return a._internal_less(b); +} + +template void swap(weak_ptr & a, weak_ptr & b) +{ + a.swap(b); +} + +// deprecated, provided for backward compatibility +template shared_ptr make_shared(weak_ptr const & r) +{ + return r.lock(); +} + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#endif // #ifndef BOOST_WEAK_PTR_H_INCLUDED diff --git a/indexlib/boost-compat/weak_ptr.hpp b/indexlib/boost-compat/weak_ptr.hpp deleted file mode 100644 index c2385007..00000000 --- a/indexlib/boost-compat/weak_ptr.hpp +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef BOOST_WEAK_PTR_HPP_INCLUDED -#define BOOST_WEAK_PTR_HPP_INCLUDED - -// -// weak_ptr.hpp -// -// Copyright (c) 2001, 2002, 2003 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/weak_ptr.htm for documentation. -// - -#include - -#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash -# pragma warning(push) -# pragma warning(disable:4284) // odd return type for operator-> -#endif - -namespace boost -{ - -template class weak_ptr -{ -private: - - // Borland 5.5.1 specific workarounds - typedef weak_ptr this_type; - -public: - - typedef T element_type; - - weak_ptr(): px(0), pn() // never throws in 1.30+ - { - } - -// generated copy constructor, assignment, destructor are fine - - -// -// The "obvious" converting constructor implementation: -// -// template -// weak_ptr(weak_ptr const & r): px(r.px), pn(r.pn) // never throws -// { -// } -// -// has a serious problem. -// -// r.px may already have been invalidated. The px(r.px) -// conversion may require access to *r.px (virtual inheritance). -// -// It is not possible to avoid spurious access violations since -// in multithreaded programs r.px may be invalidated at any point. -// - - template - weak_ptr(weak_ptr const & r): pn(r.pn) // never throws - { - px = r.lock().get(); - } - - template - weak_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws - { - } - -#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200) - - template - weak_ptr & operator=(weak_ptr const & r) // never throws - { - px = r.lock().get(); - pn = r.pn; - return *this; - } - - template - weak_ptr & operator=(shared_ptr const & r) // never throws - { - px = r.px; - pn = r.pn; - return *this; - } - -#endif - - shared_ptr lock() const // never throws - { -#if defined(BOOST_HAS_THREADS) - - // optimization: avoid throw overhead - if(expired()) - { - return shared_ptr(); - } - - try - { - return shared_ptr(*this); - } - catch(bad_weak_ptr const &) - { - // Q: how can we get here? - // A: another thread may have invalidated r after the use_count test above. - return shared_ptr(); - } - -#else - - // optimization: avoid try/catch overhead when single threaded - return expired()? shared_ptr(): shared_ptr(*this); - -#endif - } - - long use_count() const // never throws - { - return pn.use_count(); - } - - bool expired() const // never throws - { - return pn.use_count() == 0; - } - - void reset() // never throws in 1.30+ - { - this_type().swap(*this); - } - - void swap(this_type & other) // never throws - { - std::swap(px, other.px); - pn.swap(other.pn); - } - - void _internal_assign(T * px2, detail::shared_count const & pn2) - { - px = px2; - pn = pn2; - } - - template bool _internal_less(weak_ptr const & rhs) const - { - return pn < rhs.pn; - } - -// Tasteless as this may seem, making all members public allows member templates -// to work in the absence of member template friends. (Matthew Langston) - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - -private: - - template friend class weak_ptr; - template friend class shared_ptr; - -#endif - - T * px; // contained pointer - detail::weak_count pn; // reference counter - -}; // weak_ptr - -template inline bool operator<(weak_ptr const & a, weak_ptr const & b) -{ - return a._internal_less(b); -} - -template void swap(weak_ptr & a, weak_ptr & b) -{ - a.swap(b); -} - -// deprecated, provided for backward compatibility -template shared_ptr make_shared(weak_ptr const & r) -{ - return r.lock(); -} - -} // namespace boost - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -#endif // #ifndef BOOST_WEAK_PTR_HPP_INCLUDED diff --git a/indexlib/configure.in.in b/indexlib/configure.in.in index 1f1a806a..b66b049c 100644 --- a/indexlib/configure.in.in +++ b/indexlib/configure.in.in @@ -19,4 +19,4 @@ if test "x$have_boost" = "xyes"; then CXXFLAGS="-DHAVE_BOOST $CXXFLAGS" fi - \ No newline at end of file + diff --git a/indexlib/ifile.cpp b/indexlib/ifile.cpp index b71297a0..5709bb41 100644 --- a/indexlib/ifile.cpp +++ b/indexlib/ifile.cpp @@ -39,7 +39,7 @@ #include #include #include "format.h" -#include "boost-compat/next_prior.hpp" +#include "boost-compat/next_prior.h" ifile::ifile( std::string name ): diff --git a/indexlib/index_slow.h b/indexlib/index_slow.h index bbb4f7b7..6f1dcced 100644 --- a/indexlib/index_slow.h +++ b/indexlib/index_slow.h @@ -34,7 +34,7 @@ #include "index.h" #include "slow.h" -#include "boost-compat/noncopyable.hpp" +#include "boost-compat/noncopyable.h" /** * \see class slow which should be merged into this one. diff --git a/indexlib/leafdata.cpp b/indexlib/leafdata.cpp index db61119a..c8882156 100644 --- a/indexlib/leafdata.cpp +++ b/indexlib/leafdata.cpp @@ -33,7 +33,7 @@ #include "logfile.h" #include #include -#include "boost-compat/next_prior.hpp" +#include "boost-compat/next_prior.h" #include "format.h" namespace { diff --git a/indexlib/memvector.h b/indexlib/memvector.h index 446fddf9..feb96268 100644 --- a/indexlib/memvector.h +++ b/indexlib/memvector.h @@ -35,8 +35,8 @@ #include "bitio.h" #include "compat.h" #include "manager.h" -#include "boost-compat/static_assert.hpp" -#include "boost-compat/scoped_ptr.hpp" +#include "boost-compat/static_assert.h" +#include "boost-compat/scoped_ptr.h" #ifdef HAVE_BOOST #include #endif diff --git a/indexlib/pointer.h b/indexlib/pointer.h index 70721918..336ede76 100644 --- a/indexlib/pointer.h +++ b/indexlib/pointer.h @@ -34,7 +34,7 @@ #include #include -#include "boost-compat/static_assert.hpp" +#include "boost-compat/static_assert.h" #ifdef HAVE_BOOST #include #endif diff --git a/indexlib/stringarray.h b/indexlib/stringarray.h index a928db31..6202036c 100644 --- a/indexlib/stringarray.h +++ b/indexlib/stringarray.h @@ -34,7 +34,7 @@ #include #include -#include "boost-compat/scoped_ptr.hpp" +#include "boost-compat/scoped_ptr.h" #include "manager.h" #include "memvector.h" diff --git a/kaddressbook/xxport/pab_pablib.cpp b/kaddressbook/xxport/pab_pablib.cpp index 344647f6..bae854c2 100644 --- a/kaddressbook/xxport/pab_pablib.cpp +++ b/kaddressbook/xxport/pab_pablib.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - pablib.cxx - description + pablib.cpp - description ------------------- begin : Tue Jul 4 2000 copyright : (C) 2000 by Hans Dijkema diff --git a/kaddressbook/xxport/pab_pablib.h b/kaddressbook/xxport/pab_pablib.h index 910688cc..f7cf7645 100644 --- a/kaddressbook/xxport/pab_pablib.h +++ b/kaddressbook/xxport/pab_pablib.h @@ -1,5 +1,5 @@ /*************************************************************************** - pablib.hxx - description + pablib.h - description ------------------- begin : Tue Jul 4 2000 copyright : (C) 2000 by Hans Dijkema @@ -16,8 +16,8 @@ ***************************************************************************/ -#ifndef PAB_LIB_HXX -#define PAB_LIB_HXX +#ifndef PAB_LIB_H +#define PAB_LIB_H #include #include diff --git a/karm/karm.tdevelop b/karm/karm.tdevelop index e0436fba..963fa7c4 100644 --- a/karm/karm.tdevelop +++ b/karm/karm.tdevelop @@ -17,7 +17,7 @@ - + diff --git a/kmail/folderdiaacltab.cpp b/kmail/folderdiaacltab.cpp index 35b72784..43d15a51 100644 --- a/kmail/folderdiaacltab.cpp +++ b/kmail/folderdiaacltab.cpp @@ -255,7 +255,7 @@ void KMail::FolderDiaACLTab::ListViewItem::setPermissions( unsigned int permissi void KMail::FolderDiaACLTab::ListViewItem::load( const ACLListEntry& entry ) { // Don't allow spaces in userids. If you need this, fix the slave->app communication, - // since it uses space as a separator (imap4.cc, look for GETACL) + // since it uses space as a separator (imap4.cpp, look for GETACL) // It's ok in distribution list names though, that's why this check is only done here // and also why there's no validator on the lineedit. if ( entry.userId.contains( ' ' ) ) diff --git a/kmailcvt/CMakeLists.txt b/kmailcvt/CMakeLists.txt index 9a566690..ac96928a 100644 --- a/kmailcvt/CMakeLists.txt +++ b/kmailcvt/CMakeLists.txt @@ -38,12 +38,12 @@ install( tde_add_executable( kmailcvt AUTOMOC SOURCES kimportpagedlg.ui kimportpage.cpp kselfilterpagedlg.ui - kselfilterpage.cpp filters.cxx filter_oe.cxx kmailcvt.cpp main.cpp - filter_pmail.cxx filter_plain.cxx filter_outlook.cxx filter_mbox.cxx - filter_evolution.cxx filter_mailapp.cxx filter_evolution_v2.cxx - filter_opera.cxx filter_thunderbird.cxx filter_kmail_maildir.cxx - filter_sylpheed.cxx filter_thebat.cxx filter_lnotes.cxx - filter_kmail_archive.cxx + kselfilterpage.cpp filters.cpp filter_oe.cpp kmailcvt.cpp main.cpp + filter_pmail.cpp filter_plain.cpp filter_outlook.cpp filter_mbox.cpp + filter_evolution.cpp filter_mailapp.cpp filter_evolution_v2.cpp + filter_opera.cpp filter_thunderbird.cpp filter_kmail_maildir.cpp + filter_sylpheed.cpp filter_thebat.cpp filter_lnotes.cpp + filter_kmail_archive.cpp LINK tdeio-shared DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/kmailcvt/Makefile.am b/kmailcvt/Makefile.am index 7c49b36a..46a25870 100644 --- a/kmailcvt/Makefile.am +++ b/kmailcvt/Makefile.am @@ -1,32 +1,32 @@ bin_PROGRAMS = kmailcvt kmailcvt_SOURCES = kimportpagedlg.ui kimportpage.cpp kselfilterpagedlg.ui \ - kselfilterpage.cpp filters.cxx filter_oe.cxx kmailcvt.cpp \ - main.cpp filter_pmail.cxx filter_plain.cxx filter_outlook.cxx \ - filter_mbox.cxx filter_evolution.cxx filter_mailapp.cxx \ - filter_evolution_v2.cxx filter_opera.cxx filter_thunderbird.cxx \ - filter_kmail_maildir.cxx filter_sylpheed.cxx filter_thebat.cxx \ - filter_lnotes.cxx filter_kmail_archive.cxx + kselfilterpage.cpp filters.cpp filter_oe.cpp kmailcvt.cpp \ + main.cpp filter_pmail.cpp filter_plain.cpp filter_outlook.cpp \ + filter_mbox.cpp filter_evolution.cpp filter_mailapp.cpp \ + filter_evolution_v2.cpp filter_opera.cpp filter_thunderbird.cpp \ + filter_kmail_maildir.cpp filter_sylpheed.cpp filter_thebat.cpp \ + filter_lnotes.cpp filter_kmail_archive.cpp kmailcvt_LDADD = $(LIB_TDEFILE) EXTRA_DIST = main.cpp kmailcvt.cpp kimportpage.cpp kimportpage.h \ kselfilterpage.cpp kselfilterpage.h kmailcvt.h \ - kmailcvt.desktop filter_oe.cxx filter_oe.hxx \ - filters.cxx filters.hxx \ + kmailcvt.desktop filter_oe.cpp filter_oe.h \ + filters.cpp filters.h \ PAB_format.html sv9429424.gif \ - filter_pmail.cxx filter_pmail.hxx \ - filter_plain.cxx filter_plain.hxx \ - filter_mbox.cxx filter_mbox.hxx \ - filter_evolution.cxx filter_evolution.hxx \ - filter_mailapp.hxx filter_mailapp.cxx \ - filter_opera.hxx filter_opera.cxx \ - filter_evolution_v2.hxx filter_evolution_v2.cxx \ - filter_thunderbird.hxx filter_thunderbird.cxx \ - filter_kmail_maildir.hxx filter_kmail_maildir.cxx \ - filter_sylpheed.hxx filter_sylpheed.cxx \ - filter_thebat.hxx filter_thebat.cxx filter_lnotes.hxx filter_lnotes.cxx \ - filter_kmail_archive.cxx fitler_kmail_archive.hxx + filter_pmail.cpp filter_pmail.h \ + filter_plain.cpp filter_plain.h \ + filter_mbox.cpp filter_mbox.h \ + filter_evolution.cpp filter_evolution.h \ + filter_mailapp.h filter_mailapp.cpp \ + filter_opera.h filter_opera.cpp \ + filter_evolution_v2.h filter_evolution_v2.cpp \ + filter_thunderbird.h filter_thunderbird.cpp \ + filter_kmail_maildir.h filter_kmail_maildir.cpp \ + filter_sylpheed.h filter_sylpheed.cpp \ + filter_thebat.h filter_thebat.cpp filter_lnotes.h filter_lnotes.cpp \ + filter_kmail_archive.cpp fitler_kmail_archive.h install-data-local: uninstall.desktop $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Utilities @@ -45,7 +45,7 @@ kmailcvt_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) KDE_ICON=AUTO messages: rc.cpp - LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + LIST=`find . -name \*.h -o -name \*.cpp`; \ if test -n "$$LIST"; then \ $(XGETTEXT) $$LIST -o $(podir)/kmailcvt.pot; \ fi diff --git a/kmailcvt/README b/kmailcvt/README index d8322ed4..d1105fe4 100644 --- a/kmailcvt/README +++ b/kmailcvt/README @@ -7,9 +7,9 @@ with KMail via its DCOP interface to add messages. Writing a filter ---------------- -...is very easy. Create two files filter_myformat.cxx and filter_myformat.hxx -and add "filter_myformat.cxx" to the end of the kmailcvt_SOURCES line in -Makefile.am and "filter_myformat.cxx filter_myformat.hxx" to the end of the +...is very easy. Create two files filter_myformat.cpp and filter_myformat.h +and add "filter_myformat.cpp" to the end of the kmailcvt_SOURCES line in +Makefile.am and "filter_myformat.cpp filter_myformat.h" to the end of the EXTRA_DIST line in Makefile.am. Now run "make -f Makefile.cvs; ./configure" in your tdepim source directory. diff --git a/kmailcvt/filter_evolution.cpp b/kmailcvt/filter_evolution.cpp new file mode 100644 index 00000000..a372058e --- /dev/null +++ b/kmailcvt/filter_evolution.cpp @@ -0,0 +1,200 @@ +/* + * filter_evolution.cpp + * Author : Simon MARTIN + * Copyright (c) 2004 Simon MARTIN + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "filter_evolution.h" + +#include +#include +#include +#include + + +/** Default constructor. */ +FilterEvolution::FilterEvolution(void) : + Filter(i18n("Import Evolution 1.x Local Mails and Folder Structure"), + "Simon MARTIN

( Filter accelerated by Danny Kukawka )", + i18n("

Evolution 1.x import filter

" + "

Select the base directory of Evolution's mails (usually ~/evolution/local).

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"Evolution-Import\".

")) +{} + +/** Destructor. */ +FilterEvolution::~FilterEvolution(void) +{ +} + +/** Recursive import of Evolution's mboxes. */ +void FilterEvolution::import(FilterInfo *info) +{ + // We ask the user to choose Evolution's root directory. + TQString evolDir = TQDir::homeDirPath() + "/evolution/local"; + TQDir d( evolDir ); + if ( !d.exists() ) { + evolDir = TQDir::homeDirPath(); + } + + mailDir = KFileDialog::getExistingDirectory(evolDir, info->parent()); + + if (mailDir.isEmpty()) { + info->alert(i18n("No directory selected.")); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { + info->addLog(i18n("No files found for import.")); + } else { + info->setOverall(0); + // Recursive import of the MBoxes. + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { + importDirContents(info, dir.filePath(*filename), *filename, TQString()); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + } + } + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. + */ +void FilterEvolution::importDirContents(FilterInfo *info, const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) +{ + // If there is a mbox, we import it + TQDir dir(dirName); + if(dir.exists("mbox")) { + importMBox(info, dirName + "/mbox", KMailRootDir, KMailSubDir); + } + // If there are subfolders, we import them one by one + if(dir.exists("subfolders")) { + TQDir subfolders(dirName + "/subfolders"); + TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + TQString kSubDir; + if(!KMailSubDir.isNull()) { + kSubDir = KMailSubDir + "/" + *filename; + } else { + kSubDir = *filename; + } + importDirContents(info, subfolders.filePath(*filename), KMailRootDir, kSubDir); + } + } +} + +/** + * Import of a MBox file. + * @param info Information storage for the operation. + * @param dirName The MBox's name. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's equivalent in KMail's folder structure. * + */ +void FilterEvolution::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) +{ + TQFile mbox(mboxName); + bool first_msg = true; + TQString tmp_from = mboxName; + if (!mbox.open(IO_ReadOnly)) { + info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); + } else { + TQFileInfo filenameInfo(mboxName); + + info->setCurrent(0); + if( mboxName.length() > 20 ) { + TQString tmp_info = mboxName; + tmp_info = tmp_info.replace( mailDir, ".." ); + if (tmp_info.contains("subfolders/")) + tmp_info.remove("subfolders/"); + info->setFrom( tmp_info ); + tmp_from = tmp_info; + } else + info->setFrom(mboxName); + if(targetDir.contains("subfolders/")) { + TQString tmp_info = targetDir; + tmp_info.remove("subfolders/"); + info->setTo(tmp_info); + } else + info->setTo(targetDir); + + info->addLog(i18n("Importing emails from %1...").arg(tmp_from)); + + TQByteArray input(MAX_LINE); + long l = 0; + + while (!mbox.atEnd()) { + KTempFile tmp; + /* comment by Danny: + * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + tmp.file()->writeBlock( input, l ); + + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; + + TQString destFolder = rootDir; + if(!targetDir.isNull()) { + destFolder = "Evolution-Import/" + destFolder + "/" + targetDir; + } else { + destFolder = "Evolution-Import/" + destFolder; + } + + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(info->removeDupMsg) + addMessage( info, destFolder, tmp.name() ); + else + addMessage_fastImport( info, destFolder, tmp.name() ); + + tmp.unlink(); + int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); + info->setCurrent(currentPercentage); + if (info->shouldTerminate()) return; + } + + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + count_duplicates = 0; + mbox.close(); + } +} diff --git a/kmailcvt/filter_evolution.cxx b/kmailcvt/filter_evolution.cxx deleted file mode 100644 index b4443d14..00000000 --- a/kmailcvt/filter_evolution.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/* - * filter_evolution.cxx - * Author : Simon MARTIN - * Copyright (c) 2004 Simon MARTIN - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that 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 General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "filter_evolution.hxx" - -#include -#include -#include -#include - - -/** Default constructor. */ -FilterEvolution::FilterEvolution(void) : - Filter(i18n("Import Evolution 1.x Local Mails and Folder Structure"), - "Simon MARTIN

( Filter accelerated by Danny Kukawka )", - i18n("

Evolution 1.x import filter

" - "

Select the base directory of Evolution's mails (usually ~/evolution/local).

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"Evolution-Import\".

")) -{} - -/** Destructor. */ -FilterEvolution::~FilterEvolution(void) -{ -} - -/** Recursive import of Evolution's mboxes. */ -void FilterEvolution::import(FilterInfo *info) -{ - // We ask the user to choose Evolution's root directory. - TQString evolDir = TQDir::homeDirPath() + "/evolution/local"; - TQDir d( evolDir ); - if ( !d.exists() ) { - evolDir = TQDir::homeDirPath(); - } - - mailDir = KFileDialog::getExistingDirectory(evolDir, info->parent()); - - if (mailDir.isEmpty()) { - info->alert(i18n("No directory selected.")); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { - info->addLog(i18n("No files found for import.")); - } else { - info->setOverall(0); - // Recursive import of the MBoxes. - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { - importDirContents(info, dir.filePath(*filename), *filename, TQString()); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - } - } - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. - */ -void FilterEvolution::importDirContents(FilterInfo *info, const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) -{ - // If there is a mbox, we import it - TQDir dir(dirName); - if(dir.exists("mbox")) { - importMBox(info, dirName + "/mbox", KMailRootDir, KMailSubDir); - } - // If there are subfolders, we import them one by one - if(dir.exists("subfolders")) { - TQDir subfolders(dirName + "/subfolders"); - TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - TQString kSubDir; - if(!KMailSubDir.isNull()) { - kSubDir = KMailSubDir + "/" + *filename; - } else { - kSubDir = *filename; - } - importDirContents(info, subfolders.filePath(*filename), KMailRootDir, kSubDir); - } - } -} - -/** - * Import of a MBox file. - * @param info Information storage for the operation. - * @param dirName The MBox's name. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's equivalent in KMail's folder structure. * - */ -void FilterEvolution::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) -{ - TQFile mbox(mboxName); - bool first_msg = true; - TQString tmp_from = mboxName; - if (!mbox.open(IO_ReadOnly)) { - info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); - } else { - TQFileInfo filenameInfo(mboxName); - - info->setCurrent(0); - if( mboxName.length() > 20 ) { - TQString tmp_info = mboxName; - tmp_info = tmp_info.replace( mailDir, ".." ); - if (tmp_info.contains("subfolders/")) - tmp_info.remove("subfolders/"); - info->setFrom( tmp_info ); - tmp_from = tmp_info; - } else - info->setFrom(mboxName); - if(targetDir.contains("subfolders/")) { - TQString tmp_info = targetDir; - tmp_info.remove("subfolders/"); - info->setTo(tmp_info); - } else - info->setTo(targetDir); - - info->addLog(i18n("Importing emails from %1...").arg(tmp_from)); - - TQByteArray input(MAX_LINE); - long l = 0; - - while (!mbox.atEnd()) { - KTempFile tmp; - /* comment by Danny: - * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - - if(!first_msg) - tmp.file()->writeBlock( input, l ); - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; - - TQString destFolder = rootDir; - if(!targetDir.isNull()) { - destFolder = "Evolution-Import/" + destFolder + "/" + targetDir; - } else { - destFolder = "Evolution-Import/" + destFolder; - } - - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(info->removeDupMsg) - addMessage( info, destFolder, tmp.name() ); - else - addMessage_fastImport( info, destFolder, tmp.name() ); - - tmp.unlink(); - int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); - info->setCurrent(currentPercentage); - if (info->shouldTerminate()) return; - } - - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - count_duplicates = 0; - mbox.close(); - } -} diff --git a/kmailcvt/filter_evolution.h b/kmailcvt/filter_evolution.h new file mode 100644 index 00000000..83fb4155 --- /dev/null +++ b/kmailcvt/filter_evolution.h @@ -0,0 +1,45 @@ +/* + * filter_evolution.h + * Author : Simon MARTIN + * Copyright (c) 2004 Simon MARTIN + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef FILTER_EVOLUTION_H +#define FILTER_EVOLUTION_H + +#include "filters.h" + +/** + * Imports Evolution mboxes recursively, keeping the folder structure. + * @author Simon MARTIN + */ +class FilterEvolution : public Filter +{ +public: + FilterEvolution(void); + ~FilterEvolution(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + void importDirContents(FilterInfo*, const TQString&, const TQString&, const TQString&); + void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); +}; + +#endif diff --git a/kmailcvt/filter_evolution.hxx b/kmailcvt/filter_evolution.hxx deleted file mode 100644 index 1aa5184f..00000000 --- a/kmailcvt/filter_evolution.hxx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * filter_evolution.hxx - * Author : Simon MARTIN - * Copyright (c) 2004 Simon MARTIN - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that 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 General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef FILTER_EVOLUTION_HXX -#define FILTER_EVOLUTION_HXX - -#include "filters.hxx" - -/** - * Imports Evolution mboxes recursively, keeping the folder structure. - * @author Simon MARTIN - */ -class FilterEvolution : public Filter -{ -public: - FilterEvolution(void); - ~FilterEvolution(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - void importDirContents(FilterInfo*, const TQString&, const TQString&, const TQString&); - void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); -}; - -#endif diff --git a/kmailcvt/filter_evolution_v2.cpp b/kmailcvt/filter_evolution_v2.cpp new file mode 100644 index 00000000..a4c6203c --- /dev/null +++ b/kmailcvt/filter_evolution_v2.cpp @@ -0,0 +1,231 @@ +/*************************************************************************** + filter_evolution_v2.cpp - Evolution 2.0.x mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + (inspired and partly copied from filter_evolution) + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "filter_evolution_v2.h" + +#include +#include +#include +#include + + +/** Default constructor. */ +FilterEvolution_v2::FilterEvolution_v2(void) : + Filter(i18n("Import Evolution 2.x Local Mails and Folder Structure"), + "Danny Kukawka", + i18n("

Evolution 2.x import filter

" + "

Select the base directory of your local Evolution mailfolder (usually ~/.evolution/mail/local/).

" + "

Note: Never choose a Folder which does not contain mbox-files (for example " + "a maildir): if you do, you will get many new folders.

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"Evolution-Import\".

")) +{} + +/** Destructor. */ +FilterEvolution_v2::~FilterEvolution_v2(void) +{ +} + +/** Recursive import of Evolution's mboxes. */ +void FilterEvolution_v2::import(FilterInfo *info) +{ + /** + * We ask the user to choose Evolution's root directory. + * This should be usually ~/.evolution/mail/local/ + */ + TQString evolDir = TQDir::homeDirPath() + "/.evolution/mail/local"; + TQDir d( evolDir ); + if ( !d.exists() ) { + evolDir = TQDir::homeDirPath(); + } + + //TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); + KFileDialog *kfd; + kfd = new KFileDialog( evolDir, "", 0, "tdefiledialog", true ); + kfd->setMode(KFile::Directory | KFile::LocalOnly); + kfd->exec(); + mailDir = kfd->selectedFile(); + delete kfd; + + if (mailDir.isEmpty()) { + info->alert(i18n("No directory selected.")); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { + info->addLog(i18n("No files found for import.")); + } else { + info->setOverall(0); + + /** Recursive import of the MailArchives */ + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator dirname = rootSubDirs.begin() ; dirname != rootSubDirs.end() ; ++dirname, ++currentDir) { + if (info->shouldTerminate()) break; + importDirContents(info, false, dir.filePath(*dirname), *dirname, *dirname); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + } + + /** import last but not least all archives from the root-dir */ + importDirContents(info, true, mailDir, TQString(), TQString()); + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if(count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + } + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param root if this is the rootdir or not + * @param dirName The name of the directory to import. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. + */ +void FilterEvolution_v2::importDirContents(FilterInfo *info, bool root, + const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) +{ + if (info->shouldTerminate()) return; + + /** Here Import all archives in the current dir */ + TQDir dir(dirName); + + TQDir importDir (dirName); + TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { + if (info->shouldTerminate()) break; + TQString temp_mailfile = *mailFile; + if (temp_mailfile.endsWith(".cmeta") || temp_mailfile.endsWith(".ev-summary") || temp_mailfile.endsWith(".ev-summary-meta") || + temp_mailfile.endsWith(".ibex.index") || temp_mailfile.endsWith(".ibex.index.data") ) {} + else { + info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); + if (!root) + importMBox(info, (dirName + "/" + temp_mailfile) , KMailRootDir, KMailSubDir); + else + importMBox(info, dirName + temp_mailfile , temp_mailfile, TQString()); + } + } + + if (!root) { + /** If there are subfolders, we import them one by one */ + TQDir subfolders(dirName); + TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + TQString kSubDir; + if(!KMailSubDir.isNull()) { + kSubDir = KMailSubDir + "/" + *filename; + } else { + kSubDir = *filename; + } + importDirContents(info, false, subfolders.filePath(*filename), KMailRootDir, kSubDir); + } + } +} + +/** + * Import of a MBox file. + * @param info Information storage for the operation. + * @param dirName The MBox's name. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's equivalent in KMail's folder structure. * + */ +void FilterEvolution_v2::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) +{ + TQFile mbox(mboxName); + bool first_msg = true; + if (!mbox.open(IO_ReadOnly)) { + info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); + } else { + TQFileInfo filenameInfo(mboxName); + + info->setCurrent(0); + if( mboxName.length() > 20 ) { + TQString tmp_info = mboxName; + tmp_info = tmp_info.replace( mailDir, "../" ); + if (tmp_info.contains(".sbd")) + tmp_info.remove(".sbd"); + info->setFrom( tmp_info ); + } else + info->setFrom(mboxName); + if(targetDir.contains(".sbd")) { + TQString tmp_info = targetDir; + tmp_info.remove(".sbd"); + info->setTo(tmp_info); + } else + info->setTo(targetDir); + + TQByteArray input(MAX_LINE); + long l = 0; + + while (!mbox.atEnd()) { + KTempFile tmp; + /** @todo check if the file is really a mbox, maybe search for 'from' string at start */ + /* comment by Danny: + * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + tmp.file()->writeBlock( input, l ); + + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; + + TQString destFolder; + TQString _targetDir = targetDir; + if(!targetDir.isNull()) { + if(_targetDir.contains(".sbd")) + _targetDir.remove(".sbd"); + destFolder += "Evolution-Import/" + _targetDir + "/" + filenameInfo.baseName(TRUE); // mboxName; + } else { + destFolder = "Evolution-Import/" + rootDir; + if(destFolder.contains(".sbd")) + destFolder.remove(".sbd"); + } + + + if(info->removeDupMsg) + addMessage( info, destFolder, tmp.name() ); + else + addMessage_fastImport( info, destFolder, tmp.name() ); + + tmp.unlink(); + int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); + info->setCurrent(currentPercentage); + if (info->shouldTerminate()) break; + } + mbox.close(); + } +} diff --git a/kmailcvt/filter_evolution_v2.cxx b/kmailcvt/filter_evolution_v2.cxx deleted file mode 100644 index b6ee8a57..00000000 --- a/kmailcvt/filter_evolution_v2.cxx +++ /dev/null @@ -1,231 +0,0 @@ -/*************************************************************************** - filter_evolution_v2.cxx - Evolution 2.0.x mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - (inspired and partly copied from filter_evolution) - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "filter_evolution_v2.hxx" - -#include -#include -#include -#include - - -/** Default constructor. */ -FilterEvolution_v2::FilterEvolution_v2(void) : - Filter(i18n("Import Evolution 2.x Local Mails and Folder Structure"), - "Danny Kukawka", - i18n("

Evolution 2.x import filter

" - "

Select the base directory of your local Evolution mailfolder (usually ~/.evolution/mail/local/).

" - "

Note: Never choose a Folder which does not contain mbox-files (for example " - "a maildir): if you do, you will get many new folders.

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"Evolution-Import\".

")) -{} - -/** Destructor. */ -FilterEvolution_v2::~FilterEvolution_v2(void) -{ -} - -/** Recursive import of Evolution's mboxes. */ -void FilterEvolution_v2::import(FilterInfo *info) -{ - /** - * We ask the user to choose Evolution's root directory. - * This should be usually ~/.evolution/mail/local/ - */ - TQString evolDir = TQDir::homeDirPath() + "/.evolution/mail/local"; - TQDir d( evolDir ); - if ( !d.exists() ) { - evolDir = TQDir::homeDirPath(); - } - - //TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); - KFileDialog *kfd; - kfd = new KFileDialog( evolDir, "", 0, "tdefiledialog", true ); - kfd->setMode(KFile::Directory | KFile::LocalOnly); - kfd->exec(); - mailDir = kfd->selectedFile(); - delete kfd; - - if (mailDir.isEmpty()) { - info->alert(i18n("No directory selected.")); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { - info->addLog(i18n("No files found for import.")); - } else { - info->setOverall(0); - - /** Recursive import of the MailArchives */ - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator dirname = rootSubDirs.begin() ; dirname != rootSubDirs.end() ; ++dirname, ++currentDir) { - if (info->shouldTerminate()) break; - importDirContents(info, false, dir.filePath(*dirname), *dirname, *dirname); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - } - - /** import last but not least all archives from the root-dir */ - importDirContents(info, true, mailDir, TQString(), TQString()); - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if(count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - } - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param root if this is the rootdir or not - * @param dirName The name of the directory to import. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. - */ -void FilterEvolution_v2::importDirContents(FilterInfo *info, bool root, - const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) -{ - if (info->shouldTerminate()) return; - - /** Here Import all archives in the current dir */ - TQDir dir(dirName); - - TQDir importDir (dirName); - TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { - if (info->shouldTerminate()) break; - TQString temp_mailfile = *mailFile; - if (temp_mailfile.endsWith(".cmeta") || temp_mailfile.endsWith(".ev-summary") || temp_mailfile.endsWith(".ev-summary-meta") || - temp_mailfile.endsWith(".ibex.index") || temp_mailfile.endsWith(".ibex.index.data") ) {} - else { - info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); - if (!root) - importMBox(info, (dirName + "/" + temp_mailfile) , KMailRootDir, KMailSubDir); - else - importMBox(info, dirName + temp_mailfile , temp_mailfile, TQString()); - } - } - - if (!root) { - /** If there are subfolders, we import them one by one */ - TQDir subfolders(dirName); - TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - TQString kSubDir; - if(!KMailSubDir.isNull()) { - kSubDir = KMailSubDir + "/" + *filename; - } else { - kSubDir = *filename; - } - importDirContents(info, false, subfolders.filePath(*filename), KMailRootDir, kSubDir); - } - } -} - -/** - * Import of a MBox file. - * @param info Information storage for the operation. - * @param dirName The MBox's name. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's equivalent in KMail's folder structure. * - */ -void FilterEvolution_v2::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) -{ - TQFile mbox(mboxName); - bool first_msg = true; - if (!mbox.open(IO_ReadOnly)) { - info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); - } else { - TQFileInfo filenameInfo(mboxName); - - info->setCurrent(0); - if( mboxName.length() > 20 ) { - TQString tmp_info = mboxName; - tmp_info = tmp_info.replace( mailDir, "../" ); - if (tmp_info.contains(".sbd")) - tmp_info.remove(".sbd"); - info->setFrom( tmp_info ); - } else - info->setFrom(mboxName); - if(targetDir.contains(".sbd")) { - TQString tmp_info = targetDir; - tmp_info.remove(".sbd"); - info->setTo(tmp_info); - } else - info->setTo(targetDir); - - TQByteArray input(MAX_LINE); - long l = 0; - - while (!mbox.atEnd()) { - KTempFile tmp; - /** @todo check if the file is really a mbox, maybe search for 'from' string at start */ - /* comment by Danny: - * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - - if(!first_msg) - tmp.file()->writeBlock( input, l ); - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; - - TQString destFolder; - TQString _targetDir = targetDir; - if(!targetDir.isNull()) { - if(_targetDir.contains(".sbd")) - _targetDir.remove(".sbd"); - destFolder += "Evolution-Import/" + _targetDir + "/" + filenameInfo.baseName(TRUE); // mboxName; - } else { - destFolder = "Evolution-Import/" + rootDir; - if(destFolder.contains(".sbd")) - destFolder.remove(".sbd"); - } - - - if(info->removeDupMsg) - addMessage( info, destFolder, tmp.name() ); - else - addMessage_fastImport( info, destFolder, tmp.name() ); - - tmp.unlink(); - int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); - info->setCurrent(currentPercentage); - if (info->shouldTerminate()) break; - } - mbox.close(); - } -} diff --git a/kmailcvt/filter_evolution_v2.h b/kmailcvt/filter_evolution_v2.h new file mode 100644 index 00000000..2c93bba8 --- /dev/null +++ b/kmailcvt/filter_evolution_v2.h @@ -0,0 +1,43 @@ +/*************************************************************************** + filter_evolution_v2.h - Evolution 2.0.x mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + (inspired and partly copied from filter_evolution) + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_EVOLUTION_V2_H +#define FILTER_EVOLUTION_V2_H + +#include "filters.h" + +/** + * Imports Evolution v2.x mail folder recursively, keeping the folder structure. + * @author Danny Kukawka + */ +class FilterEvolution_v2 : public Filter +{ +public: + FilterEvolution_v2(void); + ~FilterEvolution_v2(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + void importDirContents(FilterInfo*, bool, const TQString&, const TQString&, const TQString&); + void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); +}; + +#endif diff --git a/kmailcvt/filter_evolution_v2.hxx b/kmailcvt/filter_evolution_v2.hxx deleted file mode 100644 index da58b4fe..00000000 --- a/kmailcvt/filter_evolution_v2.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - filter_evolution_v2.hxx - Evolution 2.0.x mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - (inspired and partly copied from filter_evolution) - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_EVOLUTION_V2_HXX -#define FILTER_EVOLUTION_V2_HXX - -#include "filters.hxx" - -/** - * Imports Evolution v2.x mail folder recursively, keeping the folder structure. - * @author Danny Kukawka - */ -class FilterEvolution_v2 : public Filter -{ -public: - FilterEvolution_v2(void); - ~FilterEvolution_v2(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - void importDirContents(FilterInfo*, bool, const TQString&, const TQString&, const TQString&); - void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); -}; - -#endif diff --git a/kmailcvt/filter_kmail_archive.cpp b/kmailcvt/filter_kmail_archive.cpp new file mode 100644 index 00000000..49325d2a --- /dev/null +++ b/kmailcvt/filter_kmail_archive.cpp @@ -0,0 +1,35 @@ +/* Copyright 2009 Klarälvdalens Datakonsult AB + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License or (at your option) version 3 or any later version + accepted by the membership of KDE e.V. (or its successor approved + by the membership of KDE e.V.), which shall act as a proxy + defined in Section 14 of version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#include "filter_kmail_archive.h" + +#include + +FilterKMailArchive::FilterKMailArchive() + : Filter( i18n( "Import KMail Archive File" ), + "Klar\xE4lvdalens Datakonsult AB", + i18n( "

KMail Archive File Import Filter

" + "

This filter will import archives files previously exported by KMail.

" + "

Archive files contain a complete folder subtree compressed into a single file.

" ) ) +{ +} + +void FilterKMailArchive::import( FilterInfo *info ) +{ + showKMailImportArchiveDialog( info ); +} diff --git a/kmailcvt/filter_kmail_archive.cxx b/kmailcvt/filter_kmail_archive.cxx deleted file mode 100644 index 3c7c20d0..00000000 --- a/kmailcvt/filter_kmail_archive.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2009 Klarälvdalens Datakonsult AB - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -#include "filter_kmail_archive.hxx" - -#include - -FilterKMailArchive::FilterKMailArchive() - : Filter( i18n( "Import KMail Archive File" ), - "Klar\xE4lvdalens Datakonsult AB", - i18n( "

KMail Archive File Import Filter

" - "

This filter will import archives files previously exported by KMail.

" - "

Archive files contain a complete folder subtree compressed into a single file.

" ) ) -{ -} - -void FilterKMailArchive::import( FilterInfo *info ) -{ - showKMailImportArchiveDialog( info ); -} diff --git a/kmailcvt/filter_kmail_archive.h b/kmailcvt/filter_kmail_archive.h new file mode 100644 index 00000000..a1f74925 --- /dev/null +++ b/kmailcvt/filter_kmail_archive.h @@ -0,0 +1,32 @@ +/* Copyright 2009 Klarälvdalens Datakonsult AB + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License or (at your option) version 3 or any later version + accepted by the membership of KDE e.V. (or its successor approved + by the membership of KDE e.V.), which shall act as a proxy + defined in Section 14 of version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#ifndef FILTER_KMAIL_ARCHIVE_H +#define FILTER_KMAIL_ARCHIVE_H + +#include "filters.h" + +class FilterKMailArchive : public Filter +{ +public: + FilterKMailArchive(); + void import( FilterInfo *info ); + virtual bool needsSecondPage() { return false; } +}; + +#endif diff --git a/kmailcvt/filter_kmail_archive.hxx b/kmailcvt/filter_kmail_archive.hxx deleted file mode 100644 index 755d3cc2..00000000 --- a/kmailcvt/filter_kmail_archive.hxx +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2009 Klarälvdalens Datakonsult AB - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -#ifndef FILTER_KMAIL_ARCHIVE_HXX -#define FILTER_KMAIL_ARCHIVE_HXX - -#include "filters.hxx" - -class FilterKMailArchive : public Filter -{ -public: - FilterKMailArchive(); - void import( FilterInfo *info ); - virtual bool needsSecondPage() { return false; } -}; - -#endif diff --git a/kmailcvt/filter_kmail_maildir.cpp b/kmailcvt/filter_kmail_maildir.cpp new file mode 100644 index 00000000..f24ef7af --- /dev/null +++ b/kmailcvt/filter_kmail_maildir.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** + filter_kmail_maildir.cpp - Kmail maildir mail import + ------------------- + begin : April 06 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "filter_kmail_maildir.h" + +#include +#include +#include + +/** Default constructor. */ +FilterKMail_maildir::FilterKMail_maildir( void ) : + Filter( i18n( "Import KMail Maildirs and Folder Structure" ), + "Danny Kukawka", + i18n( "

KMail import filter

" + "

Select the base directory of the KMail mailfolder you want to import.

" + "

Note: Never select your current local KMail maildir (usually " + "~/Mail or ~/.trinity/share/apps/kmail/mail ): in this case, KMailCVT may become stuck " + "in a continuous loop.

" + "

This filter does not import KMail mailfolders with mbox files.

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"KMail-Import\" in your local folder.

" ) ) +{} + +/** Destructor. */ +FilterKMail_maildir::~FilterKMail_maildir( void ) +{ +} + +/** Recursive import of KMail maildir. */ +void FilterKMail_maildir::import( FilterInfo *info ) +{ + + TQString _homeDir = TQDir::homeDirPath(); + + KFileDialog *kfd; + kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); + kfd->setMode( KFile::Directory | KFile::LocalOnly ); + kfd->exec(); + mailDir = kfd->selectedFile(); + delete kfd; + + if ( mailDir.isEmpty() ) { + info->alert( i18n( "No directory selected." ) ); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { + info->addLog( i18n( "No files found for import." ) ); + } else { + info->setOverall(0); + + /** Recursive import of the MailArchives */ + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("*", TQDir::Dirs | TQDir::Hidden, TQDir::Name); + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { + if(info->shouldTerminate()) break; + if(!(*filename == "." || *filename == "..")) { + info->setCurrent(0); + importDirContents(info, dir.filePath(*filename)); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + info->setCurrent(100); + } + } + } + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + count_duplicates = 0; + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterKMail_maildir::importDirContents( FilterInfo *info, const TQString& dirName) +{ + + /** Here Import all archives in the current dir */ + importFiles(info, dirName); + + /** If there are subfolders, we import them one by one */ + + TQDir subfolders(dirName); + TQStringList subDirs = subfolders.entryList("*", TQDir::Dirs | TQDir::Hidden, TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + if(info->shouldTerminate()) return; + if(!(*filename == "." || *filename == "..")) { + importDirContents(info, subfolders.filePath(*filename)); + } + } +} + + +/** + * Extract the X-Status flag from a mailfile + * @param info Information storage for the operation. + * @param fileName The full path to the file to import + */ +TQString FilterKMail_maildir::getMessageFlags( FilterInfo *info, const TQString& fileName ) { + + TQString status_flag = ""; + + TQFile mailfile( fileName ); + if (! mailfile.open( IO_ReadOnly ) ) { + info->alert( i18n("Unable to open %1, skipping").arg( fileName ) ); + return status_flag; + } else { + + TQByteArray input(MAX_LINE); + + while ( !mailfile.atEnd() && status_flag.isEmpty()) { + TQCString seperate; + + while ( ! mailfile.atEnd() && mailfile.readLine(input.data(),MAX_LINE) ) { + + if ((seperate = input.data()).left(10) == "X-Status: ") { + status_flag = seperate; + status_flag.remove("X-Status: "); + status_flag = status_flag.stripWhiteSpace(); + // tqDebug("status_flag: %s", status_flag.latin1() ); + break; + } + } + } + mailfile.close(); + } + return status_flag; +} + + +/** + * Import the files within a Folder. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterKMail_maildir::importFiles( FilterInfo *info, const TQString& dirName) +{ + + TQDir dir(dirName); + TQString _path; + bool generatedPath = false; + + TQDir importDir (dirName); + TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); + int currentFile = 1, numFiles = files.size(); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile, ++currentFile) { + if(info->shouldTerminate()) return; + + TQString temp_mailfile = *mailFile; + + if (!(temp_mailfile.endsWith(".index") || temp_mailfile.endsWith(".index.ids") || + temp_mailfile.endsWith(".index.sorted") || temp_mailfile.endsWith(".uidcache") )) { + if(!generatedPath) { + _path = "KMail-Import"; + TQString _tmp = dir.filePath(*mailFile); + _tmp = _tmp.remove( mailDir ,TRUE); + TQStringList subFList = TQStringList::split("/",_tmp,FALSE); + for ( TQStringList::Iterator it = subFList.begin(); it != subFList.end(); ++it ) { + TQString _cat = *it; + if(!(_cat == *mailFile)) { + if(_cat.startsWith(".") && _cat.endsWith(".directory")) { + _cat.remove(0,1); + _cat.remove((_cat.length() - 10), 10); + } else if (_cat.startsWith(".")) { + _cat = _cat.remove(0 , 1); + } + _path += "/" + _cat; + } + } + if(_path.endsWith("cur")) + _path.remove(_path.length() - 4 , 4); + TQString _info = _path; + info->addLog(i18n("Import folder %1...").arg(_info.remove(0,12))); + info->setFrom(_info); + info->setTo(_path); + generatedPath = true; + } + + TQString msg_flag = getMessageFlags(info, dir.filePath(*mailFile)); + + if(info->removeDupMsg) { + if(! addMessage( info, _path, dir.filePath(*mailFile), msg_flag )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + info->setCurrent((int) ((float) currentFile / numFiles * 100)); + } else { + if(! addMessage_fastImport( info, _path, dir.filePath(*mailFile), msg_flag )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + info->setCurrent((int) ((float) currentFile / numFiles * 100)); + } + } + } +} + diff --git a/kmailcvt/filter_kmail_maildir.cxx b/kmailcvt/filter_kmail_maildir.cxx deleted file mode 100644 index 9d642814..00000000 --- a/kmailcvt/filter_kmail_maildir.cxx +++ /dev/null @@ -1,218 +0,0 @@ -/*************************************************************************** - filter_kmail_maildir.cxx - Kmail maildir mail import - ------------------- - begin : April 06 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de -***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "filter_kmail_maildir.hxx" - -#include -#include -#include - -/** Default constructor. */ -FilterKMail_maildir::FilterKMail_maildir( void ) : - Filter( i18n( "Import KMail Maildirs and Folder Structure" ), - "Danny Kukawka", - i18n( "

KMail import filter

" - "

Select the base directory of the KMail mailfolder you want to import.

" - "

Note: Never select your current local KMail maildir (usually " - "~/Mail or ~/.trinity/share/apps/kmail/mail ): in this case, KMailCVT may become stuck " - "in a continuous loop.

" - "

This filter does not import KMail mailfolders with mbox files.

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"KMail-Import\" in your local folder.

" ) ) -{} - -/** Destructor. */ -FilterKMail_maildir::~FilterKMail_maildir( void ) -{ -} - -/** Recursive import of KMail maildir. */ -void FilterKMail_maildir::import( FilterInfo *info ) -{ - - TQString _homeDir = TQDir::homeDirPath(); - - KFileDialog *kfd; - kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); - kfd->setMode( KFile::Directory | KFile::LocalOnly ); - kfd->exec(); - mailDir = kfd->selectedFile(); - delete kfd; - - if ( mailDir.isEmpty() ) { - info->alert( i18n( "No directory selected." ) ); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { - info->addLog( i18n( "No files found for import." ) ); - } else { - info->setOverall(0); - - /** Recursive import of the MailArchives */ - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("*", TQDir::Dirs | TQDir::Hidden, TQDir::Name); - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { - if(info->shouldTerminate()) break; - if(!(*filename == "." || *filename == "..")) { - info->setCurrent(0); - importDirContents(info, dir.filePath(*filename)); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - info->setCurrent(100); - } - } - } - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - count_duplicates = 0; - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterKMail_maildir::importDirContents( FilterInfo *info, const TQString& dirName) -{ - - /** Here Import all archives in the current dir */ - importFiles(info, dirName); - - /** If there are subfolders, we import them one by one */ - - TQDir subfolders(dirName); - TQStringList subDirs = subfolders.entryList("*", TQDir::Dirs | TQDir::Hidden, TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - if(info->shouldTerminate()) return; - if(!(*filename == "." || *filename == "..")) { - importDirContents(info, subfolders.filePath(*filename)); - } - } -} - - -/** - * Extract the X-Status flag from a mailfile - * @param info Information storage for the operation. - * @param fileName The full path to the file to import - */ -TQString FilterKMail_maildir::getMessageFlags( FilterInfo *info, const TQString& fileName ) { - - TQString status_flag = ""; - - TQFile mailfile( fileName ); - if (! mailfile.open( IO_ReadOnly ) ) { - info->alert( i18n("Unable to open %1, skipping").arg( fileName ) ); - return status_flag; - } else { - - TQByteArray input(MAX_LINE); - - while ( !mailfile.atEnd() && status_flag.isEmpty()) { - TQCString seperate; - - while ( ! mailfile.atEnd() && mailfile.readLine(input.data(),MAX_LINE) ) { - - if ((seperate = input.data()).left(10) == "X-Status: ") { - status_flag = seperate; - status_flag.remove("X-Status: "); - status_flag = status_flag.stripWhiteSpace(); - // tqDebug("status_flag: %s", status_flag.latin1() ); - break; - } - } - } - mailfile.close(); - } - return status_flag; -} - - -/** - * Import the files within a Folder. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterKMail_maildir::importFiles( FilterInfo *info, const TQString& dirName) -{ - - TQDir dir(dirName); - TQString _path; - bool generatedPath = false; - - TQDir importDir (dirName); - TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); - int currentFile = 1, numFiles = files.size(); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile, ++currentFile) { - if(info->shouldTerminate()) return; - - TQString temp_mailfile = *mailFile; - - if (!(temp_mailfile.endsWith(".index") || temp_mailfile.endsWith(".index.ids") || - temp_mailfile.endsWith(".index.sorted") || temp_mailfile.endsWith(".uidcache") )) { - if(!generatedPath) { - _path = "KMail-Import"; - TQString _tmp = dir.filePath(*mailFile); - _tmp = _tmp.remove( mailDir ,TRUE); - TQStringList subFList = TQStringList::split("/",_tmp,FALSE); - for ( TQStringList::Iterator it = subFList.begin(); it != subFList.end(); ++it ) { - TQString _cat = *it; - if(!(_cat == *mailFile)) { - if(_cat.startsWith(".") && _cat.endsWith(".directory")) { - _cat.remove(0,1); - _cat.remove((_cat.length() - 10), 10); - } else if (_cat.startsWith(".")) { - _cat = _cat.remove(0 , 1); - } - _path += "/" + _cat; - } - } - if(_path.endsWith("cur")) - _path.remove(_path.length() - 4 , 4); - TQString _info = _path; - info->addLog(i18n("Import folder %1...").arg(_info.remove(0,12))); - info->setFrom(_info); - info->setTo(_path); - generatedPath = true; - } - - TQString msg_flag = getMessageFlags(info, dir.filePath(*mailFile)); - - if(info->removeDupMsg) { - if(! addMessage( info, _path, dir.filePath(*mailFile), msg_flag )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - info->setCurrent((int) ((float) currentFile / numFiles * 100)); - } else { - if(! addMessage_fastImport( info, _path, dir.filePath(*mailFile), msg_flag )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - info->setCurrent((int) ((float) currentFile / numFiles * 100)); - } - } - } -} - diff --git a/kmailcvt/filter_kmail_maildir.h b/kmailcvt/filter_kmail_maildir.h new file mode 100644 index 00000000..f0d8c6ac --- /dev/null +++ b/kmailcvt/filter_kmail_maildir.h @@ -0,0 +1,43 @@ +/*************************************************************************** + filter_kmail_maildir.h - Kmail maildir mail import + ------------------- + begin : April 06 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef FILTER_KMAIL_MAILDIR_H +#define FILTER_KMAIL_MAILDIR_H + +#include "filters.h" + +/** + * Imports KMail mail folder with maildir format recursively, recreating the folder structure. + * @author Danny Kukawka + */ +class FilterKMail_maildir : public Filter +{ +public: + FilterKMail_maildir(void); + ~FilterKMail_maildir(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + TQString getMessageFlags(FilterInfo*, const TQString&); + + void importDirContents(FilterInfo*, const TQString&); + void importFiles(FilterInfo*, const TQString&); +}; + +#endif diff --git a/kmailcvt/filter_kmail_maildir.hxx b/kmailcvt/filter_kmail_maildir.hxx deleted file mode 100644 index 66f44490..00000000 --- a/kmailcvt/filter_kmail_maildir.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - filter_kmail_maildir.hxx - Kmail maildir mail import - ------------------- - begin : April 06 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef FILTER_KMAIL_MAILDIR_HXX -#define FILTER_KMAIL_MAILDIR_HXX - -#include "filters.hxx" - -/** - * Imports KMail mail folder with maildir format recursively, recreating the folder structure. - * @author Danny Kukawka - */ -class FilterKMail_maildir : public Filter -{ -public: - FilterKMail_maildir(void); - ~FilterKMail_maildir(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - TQString getMessageFlags(FilterInfo*, const TQString&); - - void importDirContents(FilterInfo*, const TQString&); - void importFiles(FilterInfo*, const TQString&); -}; - -#endif diff --git a/kmailcvt/filter_lnotes.cpp b/kmailcvt/filter_lnotes.cpp new file mode 100644 index 00000000..7733c1c1 --- /dev/null +++ b/kmailcvt/filter_lnotes.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + filter_lnotes.cpp - Lotus Notes Structured Text mail import + ------------------- + begin : Wed Feb 16, 2005 + copyright : (C) 2005 by Robert Rockers + email : tdeconfigure@rockerssoft.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "filter_lnotes.h" + +/** Default constructor. */ +FilterLNotes::FilterLNotes() : + Filter( i18n("Import Lotus Notes Emails"), + "Robert Rockers", + i18n("

Lotus Notes Structured Text mail import filter

" + "

This filter will import Structured Text files from an exported Lotus Notes email " + "client into KMail. Use this filter if you want to import mails from Lotus or other " + "mailers that use the Lotus Notes Structured Text format.

" + "

Note: Since it is possible to recreate the folder structure, the imported " + "messages will be stored in subfolders under: \"LNotes-Import\", in your local folder, " + "named using the names of the files the messages came from.

")) +{} + +/** Destructor. */ +FilterLNotes::~FilterLNotes() { +} + +/** + * Recursive import of The Bat! maildir. + * @param info Information storage for the operation. + */ +void FilterLNotes::import(FilterInfo *info) { + + inf = info; + currentFile = 1; + totalFiles = 0; + + TQStringList filenames = KFileDialog::getOpenFileNames( TQDir::homeDirPath(), "*|" + i18n("All Files (*)"), + inf->parent() ); + totalFiles = filenames.count(); + inf->setOverall(0); + + // See filter_mbox.cpp for better reference. + for ( TQStringList::Iterator filename = filenames.begin(); filename != filenames.end(); ++filename ) { + + ++currentFile; + info->addLog( i18n("Importing emails from %1").arg(*filename) ); + ImportLNotes( *filename ); + inf->setOverall( 100 * currentFile / totalFiles ); + if ( info->shouldTerminate() ) + break; + } +} + +/** + * Import the files within a Folder. + * @param file The name of the file to import. + */ +void FilterLNotes::ImportLNotes(const TQString& file) { + + // See Filter_pmail.cpp for better reference + + // Format of a Lotus Notes 5 Structured Text Document w form feed + // Each email begins with a custom Header Principal: + // The Message ends with a 0c character + + // open the message + TQFile f(file); + + if (! f.open( IO_ReadOnly ) ) { + inf->alert( i18n("Unable to open %1, skipping").arg( file ) ); + } else { + + int ch = 0; + int state = 0; + int n = 0; + KTempFile *tempfile = 0; + + // Get folder name + TQFileInfo filenameInfo( file ); + TQString folder("LNotes-Import/" + filenameInfo.baseName(TRUE)); + inf->setTo(folder); + + // State machine to read the data in. The fgetc usage is probably terribly slow ... + while ((ch = f.getch()) >= 0) { + switch (state) { + // new message state + case 0: + // open temp output file + tempfile = new KTempFile; + state = 1; + inf->setCurrent(i18n("Message %1").arg(n++)); + if ( inf->shouldTerminate() ) + return; + // fall through + + // inside a message state + case 1: + if (ch == 0x0c) { + // close file, send it + tempfile->close(); + + if(inf->removeDupMsg) + addMessage( inf, folder, tempfile->name() ); + else + addMessage_fastImport( inf, folder, tempfile->name() ); + + tempfile->unlink(); + state = 0; + + int currentPercentage = (int) ( ( (float) f.at() / filenameInfo.size() ) * 100 ); + inf->setCurrent( currentPercentage ); + if ( inf->shouldTerminate() ) + return; + + break; + } + if (ch == 0x0d) { + break; + } + tempfile->file()->putch(ch); + break; + } + } + + // did Folder end without 0x1a at the end? + if (state != 0) { + tempfile->close(); + + if(inf->removeDupMsg) + addMessage( inf, folder, tempfile->name() ); + else + addMessage_fastImport( inf, folder, tempfile->name() ); + + tempfile->unlink(); + delete tempfile; + } + f.close(); + } +} diff --git a/kmailcvt/filter_lnotes.cxx b/kmailcvt/filter_lnotes.cxx deleted file mode 100644 index af92e1b4..00000000 --- a/kmailcvt/filter_lnotes.cxx +++ /dev/null @@ -1,157 +0,0 @@ -/*************************************************************************** - filter_lnotes.cxx - Lotus Notes Structured Text mail import - ------------------- - begin : Wed Feb 16, 2005 - copyright : (C) 2005 by Robert Rockers - email : tdeconfigure@rockerssoft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include - -#include -#include -#include -#include -#include - -#include "filter_lnotes.hxx" - -/** Default constructor. */ -FilterLNotes::FilterLNotes() : - Filter( i18n("Import Lotus Notes Emails"), - "Robert Rockers", - i18n("

Lotus Notes Structured Text mail import filter

" - "

This filter will import Structured Text files from an exported Lotus Notes email " - "client into KMail. Use this filter if you want to import mails from Lotus or other " - "mailers that use the Lotus Notes Structured Text format.

" - "

Note: Since it is possible to recreate the folder structure, the imported " - "messages will be stored in subfolders under: \"LNotes-Import\", in your local folder, " - "named using the names of the files the messages came from.

")) -{} - -/** Destructor. */ -FilterLNotes::~FilterLNotes() { -} - -/** - * Recursive import of The Bat! maildir. - * @param info Information storage for the operation. - */ -void FilterLNotes::import(FilterInfo *info) { - - inf = info; - currentFile = 1; - totalFiles = 0; - - TQStringList filenames = KFileDialog::getOpenFileNames( TQDir::homeDirPath(), "*|" + i18n("All Files (*)"), - inf->parent() ); - totalFiles = filenames.count(); - inf->setOverall(0); - - // See filter_mbox.cxx for better reference. - for ( TQStringList::Iterator filename = filenames.begin(); filename != filenames.end(); ++filename ) { - - ++currentFile; - info->addLog( i18n("Importing emails from %1").arg(*filename) ); - ImportLNotes( *filename ); - inf->setOverall( 100 * currentFile / totalFiles ); - if ( info->shouldTerminate() ) - break; - } -} - -/** - * Import the files within a Folder. - * @param file The name of the file to import. - */ -void FilterLNotes::ImportLNotes(const TQString& file) { - - // See Filter_pmail.cxx for better reference - - // Format of a Lotus Notes 5 Structured Text Document w form feed - // Each email begins with a custom Header Principal: - // The Message ends with a 0c character - - // open the message - TQFile f(file); - - if (! f.open( IO_ReadOnly ) ) { - inf->alert( i18n("Unable to open %1, skipping").arg( file ) ); - } else { - - int ch = 0; - int state = 0; - int n = 0; - KTempFile *tempfile = 0; - - // Get folder name - TQFileInfo filenameInfo( file ); - TQString folder("LNotes-Import/" + filenameInfo.baseName(TRUE)); - inf->setTo(folder); - - // State machine to read the data in. The fgetc usage is probably terribly slow ... - while ((ch = f.getch()) >= 0) { - switch (state) { - // new message state - case 0: - // open temp output file - tempfile = new KTempFile; - state = 1; - inf->setCurrent(i18n("Message %1").arg(n++)); - if ( inf->shouldTerminate() ) - return; - // fall through - - // inside a message state - case 1: - if (ch == 0x0c) { - // close file, send it - tempfile->close(); - - if(inf->removeDupMsg) - addMessage( inf, folder, tempfile->name() ); - else - addMessage_fastImport( inf, folder, tempfile->name() ); - - tempfile->unlink(); - state = 0; - - int currentPercentage = (int) ( ( (float) f.at() / filenameInfo.size() ) * 100 ); - inf->setCurrent( currentPercentage ); - if ( inf->shouldTerminate() ) - return; - - break; - } - if (ch == 0x0d) { - break; - } - tempfile->file()->putch(ch); - break; - } - } - - // did Folder end without 0x1a at the end? - if (state != 0) { - tempfile->close(); - - if(inf->removeDupMsg) - addMessage( inf, folder, tempfile->name() ); - else - addMessage_fastImport( inf, folder, tempfile->name() ); - - tempfile->unlink(); - delete tempfile; - } - f.close(); - } -} diff --git a/kmailcvt/filter_lnotes.h b/kmailcvt/filter_lnotes.h new file mode 100644 index 00000000..bf5cd91c --- /dev/null +++ b/kmailcvt/filter_lnotes.h @@ -0,0 +1,53 @@ +/*************************************************************************** + filter_lnotes.h - Lotus Notes Structured Text mail import + ------------------- + begin : Wed Feb 16, 2005 + copyright : (C) 2005 by Robert Rockers + email : tdeconfigure@rockerssoft.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_LNOTES_H +#define FILTER_LNOTES_H + +#include "filters.h" + +/**imports Lotus Notes Structured Text Archives and archvies messages into KMail + *@author Robert Rockers + */ + +class FilterLNotes : public Filter { + +public: + FilterLNotes(); + ~FilterLNotes(); + /** Standard import filter... starting line for our import */ + void import(FilterInfo *info); + +private: + /** the working directory */ + TQDir dir; + /** Our Filterinfo stuff... important methods for getting the email imported */ + FilterInfo * inf; + /** which file (of totalFiles) is now in the work? */ + int currentFile; + /** total number of files that get imported */ + int totalFiles; + + /** + * This is were all the real action is gonna be handled. + * Gets called once for EACH file imported + */ + void ImportLNotes(const TQString& file); + +}; + +#endif diff --git a/kmailcvt/filter_lnotes.hxx b/kmailcvt/filter_lnotes.hxx deleted file mode 100644 index 430ae83e..00000000 --- a/kmailcvt/filter_lnotes.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - filter_lnotes.hxx - Lotus Notes Structured Text mail import - ------------------- - begin : Wed Feb 16, 2005 - copyright : (C) 2005 by Robert Rockers - email : tdeconfigure@rockerssoft.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_LNOTES_HXX -#define FILTER_LNOTES_HXX - -#include "filters.hxx" - -/**imports Lotus Notes Structured Text Archives and archvies messages into KMail - *@author Robert Rockers - */ - -class FilterLNotes : public Filter { - -public: - FilterLNotes(); - ~FilterLNotes(); - /** Standard import filter... starting line for our import */ - void import(FilterInfo *info); - -private: - /** the working directory */ - TQDir dir; - /** Our Filterinfo stuff... important methods for getting the email imported */ - FilterInfo * inf; - /** which file (of totalFiles) is now in the work? */ - int currentFile; - /** total number of files that get imported */ - int totalFiles; - - /** - * This is were all the real action is gonna be handled. - * Gets called once for EACH file imported - */ - void ImportLNotes(const TQString& file); - -}; - -#endif diff --git a/kmailcvt/filter_mailapp.cpp b/kmailcvt/filter_mailapp.cpp new file mode 100644 index 00000000..1da632ec --- /dev/null +++ b/kmailcvt/filter_mailapp.cpp @@ -0,0 +1,168 @@ +/*************************************************************************** + filter_mailapp.cpp - OS X Mail App import + ------------------- + copyright : (C) 2004 by Chris Howells + email : howells@kde.org + + Derived from code by: + copyright : (C) 2003 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include +#include +#include +#include +#include + +#include "filter_mailapp.h" + +FilterMailApp::FilterMailApp() : + Filter( i18n("Import From OS X Mail"), + "Chris Howells

Filter accelerated by Danny Kukawka )", + i18n("

OS X Mail Import Filter

" + "

This filter imports e-mails from the Mail client in Apple Mac OS X.

")) +{} + +FilterMailApp::~FilterMailApp() +{ +} + +void FilterMailApp::import(FilterInfo *info) +{ + int currentFile = 1; + int overall_status = 0; + bool first_msg = true; + + TQString directory = KFileDialog::getExistingDirectory( TQDir::homeDirPath(), info->parent() ); + + //tqDebug("starting by looking in directory: %s", directory.latin1()); + if ( directory.isEmpty() ) { + info->addLog( i18n("No directory selected.")); + info->addLog( i18n("No files found for import.")); + } else { + info->setOverall(0); + traverseDirectory(info, directory); + + for ( TQStringList::Iterator filename = mMboxFiles.begin(); filename != mMboxFiles.end(); ++filename, ++currentFile) { + if ( info->shouldTerminate() ) break; + TQFile mbox( *filename ); + if (! mbox.open( IO_ReadOnly ) ) { + info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); + } else { + TQFileInfo filenameInfo( *filename ); + kdDebug() << "importing filename " << *filename << endl; + TQStringList name = TQStringList::split("/", *filename); + TQString folderName(name[name.count() - 2]); + + info->setCurrent(0); + info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); + info->setFrom( *filename ); + info->setTo( folderName ); + + TQByteArray input(MAX_LINE); + long l = 0; + + while ( ! mbox.atEnd() ) { + KTempFile tmp; + /* comment by Danny: + * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + tmp.file()->writeBlock( input, l ); + + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; + + // force stop if user chancel the import + if ( info->shouldTerminate() ) { + tmp.unlink(); + break; + } + + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(info->removeDupMsg) + addMessage( info, folderName, tmp.name() ); + else + addMessage_fastImport( info, folderName, tmp.name() ); + + tmp.unlink(); + + int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); + info->setCurrent( currentPercentage ); + if (currentFile == 1) + overall_status = (int)( currentPercentage*((float)currentFile/mMboxFiles.count())); + else + overall_status = (int)(((currentFile-1)*(100.0/(float)mMboxFiles.count()))+(currentPercentage*(1.0/(float)mMboxFiles.count()))); + info->setOverall( overall_status ); + if ( info->shouldTerminate() ) break; + } + + info->addLog( i18n("Finished importing emails from %1").arg( *filename ) ); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", + "%n duplicate messages not imported to folder %1 in KMail", count_duplicates).arg(folderName)); + } + count_duplicates = 0; + mbox.close(); + } + } + } + + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + info->setCurrent(100); + info->setOverall(100); +} + +void FilterMailApp::traverseDirectory(FilterInfo *info, const TQString &dirName) +{ + TQDir dir(dirName); + dir.setFilter(TQDir::Dirs | TQDir::Files); + + const TQFileInfoList *fileinfolist = dir.entryInfoList(); + TQFileInfoListIterator it(*fileinfolist); + TQFileInfo *fi; + + if ( info->shouldTerminate() ) return; + + while ((fi = it.current())) { + if (fi->fileName() == "." || fi->fileName() == "..") { + ++it; + continue; + } + if (fi->isDir() && fi->isReadable()) { + traverseDirectory(info, fi->filePath()); + } else { + if (!fi->isDir() && fi->fileName() == "mbox") { + kdDebug() << "adding the file " << fi->filePath() << endl; + mMboxFiles.append(fi->filePath()); + } + } + ++it; + } +} diff --git a/kmailcvt/filter_mailapp.cxx b/kmailcvt/filter_mailapp.cxx deleted file mode 100644 index fded411d..00000000 --- a/kmailcvt/filter_mailapp.cxx +++ /dev/null @@ -1,168 +0,0 @@ -/*************************************************************************** - filter_mailapp.cxx - OS X Mail App import - ------------------- - copyright : (C) 2004 by Chris Howells - email : howells@kde.org - - Derived from code by: - copyright : (C) 2003 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include -#include -#include -#include -#include - -#include "filter_mailapp.hxx" - -FilterMailApp::FilterMailApp() : - Filter( i18n("Import From OS X Mail"), - "Chris Howells

Filter accelerated by Danny Kukawka )", - i18n("

OS X Mail Import Filter

" - "

This filter imports e-mails from the Mail client in Apple Mac OS X.

")) -{} - -FilterMailApp::~FilterMailApp() -{ -} - -void FilterMailApp::import(FilterInfo *info) -{ - int currentFile = 1; - int overall_status = 0; - bool first_msg = true; - - TQString directory = KFileDialog::getExistingDirectory( TQDir::homeDirPath(), info->parent() ); - - //tqDebug("starting by looking in directory: %s", directory.latin1()); - if ( directory.isEmpty() ) { - info->addLog( i18n("No directory selected.")); - info->addLog( i18n("No files found for import.")); - } else { - info->setOverall(0); - traverseDirectory(info, directory); - - for ( TQStringList::Iterator filename = mMboxFiles.begin(); filename != mMboxFiles.end(); ++filename, ++currentFile) { - if ( info->shouldTerminate() ) break; - TQFile mbox( *filename ); - if (! mbox.open( IO_ReadOnly ) ) { - info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); - } else { - TQFileInfo filenameInfo( *filename ); - kdDebug() << "importing filename " << *filename << endl; - TQStringList name = TQStringList::split("/", *filename); - TQString folderName(name[name.count() - 2]); - - info->setCurrent(0); - info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); - info->setFrom( *filename ); - info->setTo( folderName ); - - TQByteArray input(MAX_LINE); - long l = 0; - - while ( ! mbox.atEnd() ) { - KTempFile tmp; - /* comment by Danny: - * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - - if(!first_msg) - tmp.file()->writeBlock( input, l ); - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; - - // force stop if user chancel the import - if ( info->shouldTerminate() ) { - tmp.unlink(); - break; - } - - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(info->removeDupMsg) - addMessage( info, folderName, tmp.name() ); - else - addMessage_fastImport( info, folderName, tmp.name() ); - - tmp.unlink(); - - int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); - info->setCurrent( currentPercentage ); - if (currentFile == 1) - overall_status = (int)( currentPercentage*((float)currentFile/mMboxFiles.count())); - else - overall_status = (int)(((currentFile-1)*(100.0/(float)mMboxFiles.count()))+(currentPercentage*(1.0/(float)mMboxFiles.count()))); - info->setOverall( overall_status ); - if ( info->shouldTerminate() ) break; - } - - info->addLog( i18n("Finished importing emails from %1").arg( *filename ) ); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", - "%n duplicate messages not imported to folder %1 in KMail", count_duplicates).arg(folderName)); - } - count_duplicates = 0; - mbox.close(); - } - } - } - - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - info->setCurrent(100); - info->setOverall(100); -} - -void FilterMailApp::traverseDirectory(FilterInfo *info, const TQString &dirName) -{ - TQDir dir(dirName); - dir.setFilter(TQDir::Dirs | TQDir::Files); - - const TQFileInfoList *fileinfolist = dir.entryInfoList(); - TQFileInfoListIterator it(*fileinfolist); - TQFileInfo *fi; - - if ( info->shouldTerminate() ) return; - - while ((fi = it.current())) { - if (fi->fileName() == "." || fi->fileName() == "..") { - ++it; - continue; - } - if (fi->isDir() && fi->isReadable()) { - traverseDirectory(info, fi->filePath()); - } else { - if (!fi->isDir() && fi->fileName() == "mbox") { - kdDebug() << "adding the file " << fi->filePath() << endl; - mMboxFiles.append(fi->filePath()); - } - } - ++it; - } -} diff --git a/kmailcvt/filter_mailapp.h b/kmailcvt/filter_mailapp.h new file mode 100644 index 00000000..e562dbf7 --- /dev/null +++ b/kmailcvt/filter_mailapp.h @@ -0,0 +1,36 @@ +/*************************************************************************** + filter_mailapp.h - OS X Mail App import + ------------------- + copyright : (C) 2004 by Chris Howells + email : howells@kde.org + + Derived from code by: + copyright : (C) 2003 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + + ***************************************************************************/ + +#ifndef FILTER_MAILAPP_H +#define FILTER_MAILAPP_H + +#include "filters.h" + +/** + *imports mbox archives messages into KMail + *@author Chris Howells + */ + +class FilterMailApp : public Filter +{ +public: + FilterMailApp(); + ~FilterMailApp(); + + void import(FilterInfo *info); + +private: + TQStringList mMboxFiles; + void traverseDirectory(FilterInfo *info, const TQString &); +}; + +#endif diff --git a/kmailcvt/filter_mailapp.hxx b/kmailcvt/filter_mailapp.hxx deleted file mode 100644 index 571f77ff..00000000 --- a/kmailcvt/filter_mailapp.hxx +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - filter_mailapp.hxx - OS X Mail App import - ------------------- - copyright : (C) 2004 by Chris Howells - email : howells@kde.org - - Derived from code by: - copyright : (C) 2003 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - - ***************************************************************************/ - -#ifndef FILTER_MAILAPP_HXX -#define FILTER_MAILAPP_HXX - -#include "filters.hxx" - -/** - *imports mbox archives messages into KMail - *@author Chris Howells - */ - -class FilterMailApp : public Filter -{ -public: - FilterMailApp(); - ~FilterMailApp(); - - void import(FilterInfo *info); - -private: - TQStringList mMboxFiles; - void traverseDirectory(FilterInfo *info, const TQString &); -}; - -#endif diff --git a/kmailcvt/filter_mbox.cpp b/kmailcvt/filter_mbox.cpp new file mode 100644 index 00000000..c5f87e51 --- /dev/null +++ b/kmailcvt/filter_mbox.cpp @@ -0,0 +1,144 @@ +/*************************************************************************** + filter_mbox.cpp - mbox mail import + ------------------- + begin : Sat Apr 5 2003 + copyright : (C) 2003 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include "filter_mbox.h" + + +FilterMBox::FilterMBox() : + Filter( i18n("Import mbox Files (UNIX, Evolution)"), + "Laurence Anderson

( Filter accelerated by Danny Kukawka )

", + i18n("

mbox import filter

" + "

This filter will import mbox files into KMail. Use this filter " + "if you want to import mails from Ximian Evolution or other mailers " + "that use this traditional UNIX format.

" + "

Note: Emails will be imported into folders named after the " + "file they came from, prefixed with MBOX-

" )) +{} + +FilterMBox::~FilterMBox() +{ +} + +void FilterMBox::import(FilterInfo *info) +{ + int currentFile = 1; + int overall_status = 0; + bool first_msg = true; + + TQStringList filenames = KFileDialog::getOpenFileNames( TQDir::homeDirPath(), "*|" + i18n("mbox Files (*)"), info->parent() ); + info->setOverall(0); + + for ( TQStringList::Iterator filename = filenames.begin(); filename != filenames.end(); ++filename, ++currentFile) { + TQFile mbox( *filename ); + if (! mbox.open( IO_ReadOnly ) ) { + info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); + } else { + TQFileInfo filenameInfo( *filename ); + TQString folderName( "MBOX-" + filenameInfo.baseName(TRUE) ); + + info->setCurrent(0); + info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); + + info->setFrom( *filename ); + info->setTo( folderName ); + + TQByteArray input(MAX_LINE); + long l = 0; + + while ( ! mbox.atEnd() ) { + KTempFile tmp; + TQIODevice::Offset filepos = 0; + /* comment by Danny: + * Don't use TQTextStream to read from mbox, better use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + TQString x_status_flag = ""; + + /* check if the first line start with "From " (and not "From: ") and discard the line + * in this case because some IMAP servers (e.g. Cyrus) don't accept this header line */ + if(!first_msg && ((seperate = input.data()).left(5) != "From ")) + tmp.file()->writeBlock( input, l ); + + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + + if ((seperate = input.data()).left(5) != "From ") + tmp.file()->writeBlock( input, l ); + + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + + if ((seperate = input.data()).left(10) == "X-Status: ") { + x_status_flag = seperate; + x_status_flag.remove("X-Status: "); + x_status_flag = x_status_flag.stripWhiteSpace(); + // tqDebug("x_status_flag: %s", x_status_flag.latin1() ); + } + + // workaround to fix hang if a corrupted mbox contains some + // binary data, for more see bug #106796 + if (mbox.at() == filepos) + mbox.at(mbox.size()); + else + filepos = mbox.at(); + } + tmp.close(); + first_msg = false; + + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(info->removeDupMsg) + addMessage( info, folderName, tmp.name(), x_status_flag ); + else + addMessage_fastImport( info, folderName, tmp.name(), x_status_flag ); + + tmp.unlink(); + int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); + info->setCurrent( currentPercentage ); + if (currentFile == 1) + overall_status = (int)( currentPercentage*((float)currentFile/filenames.count())); + else + overall_status = (int)(((currentFile-1)*(100.0/(float)filenames.count()))+(currentPercentage*(1.0/(float)filenames.count()))); + info->setOverall( overall_status ); + + if ( info->shouldTerminate() ) break; + } + + info->addLog( i18n("Finished importing emails from %1").arg( *filename )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", + "%n duplicate messages not imported to folder %1 in KMail", + count_duplicates).arg(folderName)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + count_duplicates = 0; + // don't forget to close the file !!! + mbox.close(); + } + } +} diff --git a/kmailcvt/filter_mbox.cxx b/kmailcvt/filter_mbox.cxx deleted file mode 100644 index 19afccf2..00000000 --- a/kmailcvt/filter_mbox.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/*************************************************************************** - filter_mbox.cxx - mbox mail import - ------------------- - begin : Sat Apr 5 2003 - copyright : (C) 2003 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include "filter_mbox.hxx" - - -FilterMBox::FilterMBox() : - Filter( i18n("Import mbox Files (UNIX, Evolution)"), - "Laurence Anderson

( Filter accelerated by Danny Kukawka )

", - i18n("

mbox import filter

" - "

This filter will import mbox files into KMail. Use this filter " - "if you want to import mails from Ximian Evolution or other mailers " - "that use this traditional UNIX format.

" - "

Note: Emails will be imported into folders named after the " - "file they came from, prefixed with MBOX-

" )) -{} - -FilterMBox::~FilterMBox() -{ -} - -void FilterMBox::import(FilterInfo *info) -{ - int currentFile = 1; - int overall_status = 0; - bool first_msg = true; - - TQStringList filenames = KFileDialog::getOpenFileNames( TQDir::homeDirPath(), "*|" + i18n("mbox Files (*)"), info->parent() ); - info->setOverall(0); - - for ( TQStringList::Iterator filename = filenames.begin(); filename != filenames.end(); ++filename, ++currentFile) { - TQFile mbox( *filename ); - if (! mbox.open( IO_ReadOnly ) ) { - info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); - } else { - TQFileInfo filenameInfo( *filename ); - TQString folderName( "MBOX-" + filenameInfo.baseName(TRUE) ); - - info->setCurrent(0); - info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); - - info->setFrom( *filename ); - info->setTo( folderName ); - - TQByteArray input(MAX_LINE); - long l = 0; - - while ( ! mbox.atEnd() ) { - KTempFile tmp; - TQIODevice::Offset filepos = 0; - /* comment by Danny: - * Don't use TQTextStream to read from mbox, better use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - TQString x_status_flag = ""; - - /* check if the first line start with "From " (and not "From: ") and discard the line - * in this case because some IMAP servers (e.g. Cyrus) don't accept this header line */ - if(!first_msg && ((seperate = input.data()).left(5) != "From ")) - tmp.file()->writeBlock( input, l ); - - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - - if ((seperate = input.data()).left(5) != "From ") - tmp.file()->writeBlock( input, l ); - - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - - if ((seperate = input.data()).left(10) == "X-Status: ") { - x_status_flag = seperate; - x_status_flag.remove("X-Status: "); - x_status_flag = x_status_flag.stripWhiteSpace(); - // tqDebug("x_status_flag: %s", x_status_flag.latin1() ); - } - - // workaround to fix hang if a corrupted mbox contains some - // binary data, for more see bug #106796 - if (mbox.at() == filepos) - mbox.at(mbox.size()); - else - filepos = mbox.at(); - } - tmp.close(); - first_msg = false; - - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(info->removeDupMsg) - addMessage( info, folderName, tmp.name(), x_status_flag ); - else - addMessage_fastImport( info, folderName, tmp.name(), x_status_flag ); - - tmp.unlink(); - int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); - info->setCurrent( currentPercentage ); - if (currentFile == 1) - overall_status = (int)( currentPercentage*((float)currentFile/filenames.count())); - else - overall_status = (int)(((currentFile-1)*(100.0/(float)filenames.count()))+(currentPercentage*(1.0/(float)filenames.count()))); - info->setOverall( overall_status ); - - if ( info->shouldTerminate() ) break; - } - - info->addLog( i18n("Finished importing emails from %1").arg( *filename )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", - "%n duplicate messages not imported to folder %1 in KMail", - count_duplicates).arg(folderName)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - count_duplicates = 0; - // don't forget to close the file !!! - mbox.close(); - } - } -} diff --git a/kmailcvt/filter_mbox.h b/kmailcvt/filter_mbox.h new file mode 100644 index 00000000..f1f376de --- /dev/null +++ b/kmailcvt/filter_mbox.h @@ -0,0 +1,37 @@ +/*************************************************************************** + filter_mbox.h - mbox mail import + ------------------- + begin : Sat Apr 5 2003 + copyright : (C) 2003 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_MBOX_H +#define FILTER_MBOX_H + +#include "filters.h" + +/** + * imports mbox archives messages into KMail + * @author Laurence Anderson + */ + +class FilterMBox : public Filter +{ +public: + FilterMBox(); + ~FilterMBox(); + + void import(FilterInfo *info); +}; + +#endif diff --git a/kmailcvt/filter_mbox.hxx b/kmailcvt/filter_mbox.hxx deleted file mode 100644 index e1c5e967..00000000 --- a/kmailcvt/filter_mbox.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - filter_mbox.hxx - mbox mail import - ------------------- - begin : Sat Apr 5 2003 - copyright : (C) 2003 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_MBOX_HXX -#define FILTER_MBOX_HXX - -#include "filters.hxx" - -/** - * imports mbox archives messages into KMail - * @author Laurence Anderson - */ - -class FilterMBox : public Filter -{ -public: - FilterMBox(); - ~FilterMBox(); - - void import(FilterInfo *info); -}; - -#endif diff --git a/kmailcvt/filter_oe.cpp b/kmailcvt/filter_oe.cpp new file mode 100644 index 00000000..47002d96 --- /dev/null +++ b/kmailcvt/filter_oe.cpp @@ -0,0 +1,429 @@ +/*************************************************************************** + filter_oe.cpp - Outlook Express mail import + ------------------- + begin : Sat Feb 1 2003 + copyright : (C) 2003 by Laurence Anderson + (C) 2005 by Danny Kukawka + email : l.d.anderson@warwick.ac.uk + danny.Kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// This filter was created by looking at libdbx & liboe + +#include +#include +#include +#include +#include + +#include "filter_oe.h" + +#define OE4_SIG_1 0x36464d4a +#define OE4_SIG_2 0x00010003 +#define OE5_SIG_1 0xfe12adcf +#define OE5_EMAIL_SIG_2 0x6f74fdc5 +#define OE5_FOLDER_SIG_2 0x6f74fdc6 +#define OE5_SIG_3 0x11d1e366 +#define OE5_SIG_4 0xc0004e9a +#define MBX_MAILMAGIC 0x7F007F00 + +FilterOE::FilterOE() : + Filter( i18n("Import Outlook Express Emails"), + "Laurence Anderson
( Filter enhanced by Danny Kukawka )

", + i18n("

Outlook Express 4/5/6 import filter

" + "

You will need to locate the folder where the mailbox has been " + "stored by searching for .dbx or .mbx files under " + "

  • C:\\Windows\\Application Data in Windows 9x" + "
  • Documents and Settings in Windows 2000 or later

" + "

Note: Since it is possible to recreate the folder structure, the folders from " + "Outlook Express 5 and 6 will be stored under: \"OE-Import\" in your local folder.

" )) +{} + +FilterOE::~FilterOE() +{ +} + +void FilterOE::import(FilterInfo *info) +{ + // Select directory containing plain text emails + mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(),info->parent()); + if (mailDir.isEmpty()) { // No directory selected + info->alert(i18n("No directory selected.")); + return; + } + + TQDir dir (mailDir); + TQStringList files = dir.entryList("*.[dDmM][bB][xX]", TQDir::Files, TQDir::Name); + if (files.isEmpty()) { + info->alert(i18n("No Outlook Express mailboxes found in directory %1.").arg(mailDir)); + return; + } + + totalFiles = files.count(); + currentFile = 0; + count0x04 = 0; + count0x84 = 0; + parsedFolder = false; + + info->setOverall(0); + + /** search the folderfile to recreate folder struct */ + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { + if(*mailFile == "Folders.dbx") { + info->addLog(i18n("Import folder structure...")); + importMailBox(info, dir.filePath(*mailFile)); + if(!folderStructure.isEmpty()) parsedFolder = true; + // remove file from TQStringList::files, no longer needed + files.remove(mailFile); + currentIsFolderFile = false; + break; + } + } + + int n=0; + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { + if ( info->shouldTerminate() ) break; + importMailBox(info, dir.filePath(*mailFile)); + info->setOverall(100 * ++n / files.count()); + } + + info->setOverall(100); + info->setCurrent(100); + info->addLog(i18n("Finished importing Outlook Express emails")); + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + + kdDebug() << "\n" << "total emails in current file: " << totalEmails << endl; + kdDebug() << "0x84 Mails: " << count0x84 << endl; + kdDebug() << "0x04 Mails: " << count0x04 << endl; +} + +void FilterOE::importMailBox( FilterInfo *info, const TQString& fileName) +{ + TQFile mailfile(fileName); + TQFileInfo mailfileinfo(fileName); + TQString _nameOfFile = fileName; + _nameOfFile.remove( mailDir ); + _nameOfFile.remove( "/" ); + info->setFrom(mailfileinfo.fileName()); + + if (!mailfile.open(IO_ReadOnly)) { + info->addLog(i18n("Unable to open mailbox %1").arg(fileName)); + return; + } + TQDataStream mailbox(&mailfile); + mailbox.setByteOrder(TQDataStream::LittleEndian); + + // Parse magic + TQ_UINT32 sig_block1, sig_block2; + mailbox >> sig_block1 >> sig_block2; + if (sig_block1 == OE4_SIG_1 && sig_block2 == OE4_SIG_2) { + folderName = "OE-Import/" + mailfileinfo.baseName(TRUE); + info->addLog(i18n("Importing OE4 Mailbox %1").arg( "../" + _nameOfFile)); + info->setTo(folderName); + mbxImport(info, mailbox); + return; + } else { + TQ_UINT32 sig_block3, sig_block4; + mailbox >> sig_block3 >> sig_block4; + if (sig_block1 == OE5_SIG_1 && sig_block3 == OE5_SIG_3 && sig_block4 == OE5_SIG_4) { + if (sig_block2 == OE5_EMAIL_SIG_2) { + folderName = "OE-Import/" + mailfileinfo.baseName(TRUE); + if(parsedFolder) { + TQString _tmpFolder = getFolderName(_nameOfFile); + if(!_tmpFolder.isEmpty()) folderName = "OE-Import/" + _tmpFolder; + } + info->addLog(i18n("Importing OE5+ Mailbox %1").arg( "../" + _nameOfFile)); + info->setTo(folderName); + dbxImport(info, mailbox); + return; + } else if (sig_block2 == OE5_FOLDER_SIG_2) { + if(!parsedFolder) { + info->addLog(i18n("Importing OE5+ Folder file %1").arg( "../" + _nameOfFile)); + currentIsFolderFile = true; + dbxImport(info, mailbox); + currentIsFolderFile = false; + } + return; + } + } + } + // info->addLog(i18n("File %1 does not seem to be an Outlook Express mailbox").arg("../" + _nameOfFile)); +} + +/* ------------------- MBX support ------------------- */ + +void FilterOE::mbxImport( FilterInfo *info, TQDataStream& ds) +{ + TQ_UINT32 msgCount, lastMsgNum, fileSize; + + // Read the header + ds >> msgCount >> lastMsgNum >> fileSize; + ds.device()->at( ds.device()->at() + 64 ); // Skip 0's + kdDebug() << "This mailbox has " << msgCount << " messages" << endl; + if (msgCount == 0) + return; // Don't import empty mailbox + + TQ_UINT32 msgMagic; + ds >> msgMagic; // Read first magic + + while (!ds.atEnd()) { + TQ_UINT32 msgNumber, msgSize, msgTextSize; + KTempFile tmp; + tmp.dataStream()->setByteOrder(TQDataStream::LittleEndian); + + // Read the messages + ds >> msgNumber >> msgSize >> msgTextSize; // All seem to be lies...? + + do { + ds >> msgMagic; + if (msgMagic != MBX_MAILMAGIC) + *tmp.dataStream() << msgMagic; + else + break; + } while ( !ds.atEnd() ); + + tmp.close(); + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(info->removeDupMsg) + addMessage( info, folderName, tmp.name() ); + else + addMessage_fastImport( info, folderName, tmp.name() ); + + tmp.unlink(); + if(info->shouldTerminate()) return; + } +} + +/* ------------------- DBX support ------------------- */ + +void FilterOE::dbxImport( FilterInfo *info, TQDataStream& ds) +{ + // Get item count & offset of index + TQ_UINT32 itemCount, indexPtr; + ds.device()->at(0xc4); + ds >> itemCount; + ds.device()->at(0xe4); + ds >> indexPtr; + kdDebug() << "Item count is " << itemCount << ", Index at " << indexPtr << endl; + + if (itemCount == 0) + return; // Empty file + totalEmails = itemCount; + currentEmail = 0; + // Parse the indexes + ds.device()->at(indexPtr); + dbxReadIndex(info, ds, indexPtr); +} + +void FilterOE::dbxReadIndex( FilterInfo *info, TQDataStream& ds, int filePos) +{ + + if(info->shouldTerminate()) return; + TQ_UINT32 self, unknown, nextIndexPtr, parent, indexCount; + TQ_UINT8 unknown2, ptrCount; + TQ_UINT16 unknown3; + int wasAt = ds.device()->at(); + ds.device()->at(filePos); + + + kdDebug() << "Reading index of file " << folderName << endl; + ds >> self >> unknown >> nextIndexPtr >> parent >> unknown2 >> ptrCount >> unknown3 >> indexCount; // _dbx_tableindexstruct + + kdDebug() << "This index has " << (int) ptrCount << " data pointers" << endl; + for (int count = 0; count < ptrCount; count++) { + if(info->shouldTerminate()) return; + TQ_UINT32 dataIndexPtr, anotherIndexPtr, anotherIndexCount; // _dbx_indexstruct + ds >> dataIndexPtr >> anotherIndexPtr >> anotherIndexCount; + + if (anotherIndexCount > 0) { + kdDebug() << "Recursing to another table @ " << anotherIndexPtr << endl; + dbxReadIndex(info, ds, anotherIndexPtr); + } + kdDebug() << "Data index @ " << dataIndexPtr << endl; + dbxReadDataBlock(info, ds, dataIndexPtr); + } + + if (indexCount > 0) { // deal with nextTablePtr + kdDebug() << "Recuring to next table @ " << nextIndexPtr << endl; + dbxReadIndex(info, ds, nextIndexPtr); + } + + ds.device()->at(wasAt); // Restore file position to same as when function called +} + +void FilterOE::dbxReadDataBlock( FilterInfo *info, TQDataStream& ds, int filePos) +{ + TQ_UINT32 curOffset, blockSize; + TQ_UINT16 unknown; + TQ_UINT8 count, unknown2; + int wasAt = ds.device()->at(); + + TQString folderEntry[4]; + + ds.device()->at(filePos); + + ds >> curOffset >> blockSize >> unknown >> count >> unknown2; // _dbx_email_headerstruct + kdDebug() << "Data block has " << (int) count << " elements" << endl; + + for (int c = 0; c < count; c++) { + if(info->shouldTerminate()) return; + TQ_UINT8 type; // _dbx_email_pointerstruct + TQ_UINT32 value; // Actually 24 bit + + ds >> type >> value; + value &= 0xffffff; + ds.device()->at(ds.device()->at() - 1); // We only wanted 3 bytes + + if(!currentIsFolderFile) { + if (type == 0x84) { // It's an email! + kdDebug() << "**** Offset of emaildata (0x84) " << value << " ****" << endl; + dbxReadEmail(info, ds, value); + ++count0x84; + } else if( type == 0x04) { + int currentFilePos = ds.device()->at(); + ds.device()->at(filePos + 12 + value + (count*4) ); + TQ_UINT32 newOFF; + ds >> newOFF; + kdDebug() << "**** Offset of emaildata (0x04) " << newOFF << endl; + ds.device()->at(currentFilePos); + dbxReadEmail(info, ds, newOFF); + ++count0x04; + } + } + else { + // this is a folderfile + if(type == 0x02) { + // kdDebug() << "**** FOLDER: descriptive name ****" << endl; + folderEntry[0] = parseFolderString(ds, filePos + 12 + value + (count*4) ); + } else if (type == 0x03) { + // kdDebug() << "**** FOLDER: filename ****" << endl; + folderEntry[1] = parseFolderString(ds, filePos + 12 + value + (count*4) ); + + } else if (type == 0x80) { + // kdDebug() << "**** FOLDER: current ID ****" << endl; + folderEntry[2] = TQString::number(value); + + } else if (type == 0x81) { + // kdDebug() << "**** FOLDER: parent ID ****" << endl; + folderEntry[3] = TQString::number(value); + } + } + } + if(currentIsFolderFile) { + folderStructure.append(folderEntry); + } + ds.device()->at(wasAt); // Restore file position to same as when function called +} + +void FilterOE::dbxReadEmail( FilterInfo *info, TQDataStream& ds, int filePos) +{ + if(info->shouldTerminate()) return; + TQ_UINT32 self, nextAddressOffset, nextAddress=0; + TQ_UINT16 blockSize; + TQ_UINT8 intCount, unknown; + KTempFile tmp; + bool _break = false; + int wasAt = ds.device()->at(); + ds.device()->at(filePos); + + do { + ds >> self >> nextAddressOffset >> blockSize >> intCount >> unknown >> nextAddress; // _dbx_block_hdrstruct + TQByteArray blockBuffer(blockSize); + ds.readRawBytes(blockBuffer.data(), blockSize); + tmp.dataStream()->writeRawBytes(blockBuffer.data(), blockSize); + // to detect incomplete mails or corrupted archives. See Bug #86119 + if(ds.atEnd()) { + _break = true; + break; + } + ds.device()->at(nextAddress); + } while (nextAddress != 0); + tmp.close(); + + if(!_break) { + if(info->removeDupMsg) + addMessage( info, folderName, tmp.name() ); + else + addMessage_fastImport( info, folderName, tmp.name() ); + + currentEmail++; + int currentPercentage = (int) ( ( (float) currentEmail / totalEmails ) * 100 ); + info->setCurrent(currentPercentage); + ds.device()->at(wasAt); + } + tmp.unlink(); +} + +/* ------------------- FolderFile support ------------------- */ +TQString FilterOE::parseFolderString( TQDataStream& ds, int filePos ) +{ + char tmp; + TQString returnString; + int wasAt = ds.device()->at(); + ds.device()->at(filePos); + + // read while != 0x00 + while( !ds.device()->atEnd() ) { + tmp = ds.device()->getch(); + if( tmp != 0x00) { + returnString += tmp; + } + else break; + } + ds.device()->at(wasAt); + return returnString; +} + +/** get the foldername for a given file ID from folderMatrix */ +TQString FilterOE::getFolderName(TQString filename) +{ + bool found = false; + bool foundFilename = false; + TQString folder; + // we must do this because folder with more than one upper letter + // at start have maybe not a file named like the folder !!! + TQString search = filename.lower(); + + while (!found) + { + for ( FolderStructureIterator it = folderStructure.begin(); it != folderStructure.end(); it++) { + FolderStructure tmp = *it; + if(foundFilename == false) { + TQString _tmpFileName = tmp[1]; + _tmpFileName = _tmpFileName.lower(); + if(_tmpFileName == search) { + folder.prepend( tmp[0] + TQString::fromLatin1("/") ); + search = tmp[3]; + foundFilename = true; + } + } else { + TQString _currentID = tmp[2]; + TQString _parentID = tmp[3]; + if(_currentID == search) { + if(_parentID.isEmpty()) { // this is the root of the folder + found = true; + break; + } else { + folder.prepend( tmp[0] + TQString::fromLatin1("/") ); + search = tmp[3]; + } + } + } + } + // need to break the while loop maybe in some cases + if((foundFilename == false) && (folder.isEmpty())) return folder; + } + return folder; +} diff --git a/kmailcvt/filter_oe.cxx b/kmailcvt/filter_oe.cxx deleted file mode 100644 index afd96527..00000000 --- a/kmailcvt/filter_oe.cxx +++ /dev/null @@ -1,429 +0,0 @@ -/*************************************************************************** - filter_oe.cxx - Outlook Express mail import - ------------------- - begin : Sat Feb 1 2003 - copyright : (C) 2003 by Laurence Anderson - (C) 2005 by Danny Kukawka - email : l.d.anderson@warwick.ac.uk - danny.Kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -// This filter was created by looking at libdbx & liboe - -#include -#include -#include -#include -#include - -#include "filter_oe.hxx" - -#define OE4_SIG_1 0x36464d4a -#define OE4_SIG_2 0x00010003 -#define OE5_SIG_1 0xfe12adcf -#define OE5_EMAIL_SIG_2 0x6f74fdc5 -#define OE5_FOLDER_SIG_2 0x6f74fdc6 -#define OE5_SIG_3 0x11d1e366 -#define OE5_SIG_4 0xc0004e9a -#define MBX_MAILMAGIC 0x7F007F00 - -FilterOE::FilterOE() : - Filter( i18n("Import Outlook Express Emails"), - "Laurence Anderson
( Filter enhanced by Danny Kukawka )

", - i18n("

Outlook Express 4/5/6 import filter

" - "

You will need to locate the folder where the mailbox has been " - "stored by searching for .dbx or .mbx files under " - "

  • C:\\Windows\\Application Data in Windows 9x" - "
  • Documents and Settings in Windows 2000 or later

" - "

Note: Since it is possible to recreate the folder structure, the folders from " - "Outlook Express 5 and 6 will be stored under: \"OE-Import\" in your local folder.

" )) -{} - -FilterOE::~FilterOE() -{ -} - -void FilterOE::import(FilterInfo *info) -{ - // Select directory containing plain text emails - mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(),info->parent()); - if (mailDir.isEmpty()) { // No directory selected - info->alert(i18n("No directory selected.")); - return; - } - - TQDir dir (mailDir); - TQStringList files = dir.entryList("*.[dDmM][bB][xX]", TQDir::Files, TQDir::Name); - if (files.isEmpty()) { - info->alert(i18n("No Outlook Express mailboxes found in directory %1.").arg(mailDir)); - return; - } - - totalFiles = files.count(); - currentFile = 0; - count0x04 = 0; - count0x84 = 0; - parsedFolder = false; - - info->setOverall(0); - - /** search the folderfile to recreate folder struct */ - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { - if(*mailFile == "Folders.dbx") { - info->addLog(i18n("Import folder structure...")); - importMailBox(info, dir.filePath(*mailFile)); - if(!folderStructure.isEmpty()) parsedFolder = true; - // remove file from TQStringList::files, no longer needed - files.remove(mailFile); - currentIsFolderFile = false; - break; - } - } - - int n=0; - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { - if ( info->shouldTerminate() ) break; - importMailBox(info, dir.filePath(*mailFile)); - info->setOverall(100 * ++n / files.count()); - } - - info->setOverall(100); - info->setCurrent(100); - info->addLog(i18n("Finished importing Outlook Express emails")); - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - - kdDebug() << "\n" << "total emails in current file: " << totalEmails << endl; - kdDebug() << "0x84 Mails: " << count0x84 << endl; - kdDebug() << "0x04 Mails: " << count0x04 << endl; -} - -void FilterOE::importMailBox( FilterInfo *info, const TQString& fileName) -{ - TQFile mailfile(fileName); - TQFileInfo mailfileinfo(fileName); - TQString _nameOfFile = fileName; - _nameOfFile.remove( mailDir ); - _nameOfFile.remove( "/" ); - info->setFrom(mailfileinfo.fileName()); - - if (!mailfile.open(IO_ReadOnly)) { - info->addLog(i18n("Unable to open mailbox %1").arg(fileName)); - return; - } - TQDataStream mailbox(&mailfile); - mailbox.setByteOrder(TQDataStream::LittleEndian); - - // Parse magic - TQ_UINT32 sig_block1, sig_block2; - mailbox >> sig_block1 >> sig_block2; - if (sig_block1 == OE4_SIG_1 && sig_block2 == OE4_SIG_2) { - folderName = "OE-Import/" + mailfileinfo.baseName(TRUE); - info->addLog(i18n("Importing OE4 Mailbox %1").arg( "../" + _nameOfFile)); - info->setTo(folderName); - mbxImport(info, mailbox); - return; - } else { - TQ_UINT32 sig_block3, sig_block4; - mailbox >> sig_block3 >> sig_block4; - if (sig_block1 == OE5_SIG_1 && sig_block3 == OE5_SIG_3 && sig_block4 == OE5_SIG_4) { - if (sig_block2 == OE5_EMAIL_SIG_2) { - folderName = "OE-Import/" + mailfileinfo.baseName(TRUE); - if(parsedFolder) { - TQString _tmpFolder = getFolderName(_nameOfFile); - if(!_tmpFolder.isEmpty()) folderName = "OE-Import/" + _tmpFolder; - } - info->addLog(i18n("Importing OE5+ Mailbox %1").arg( "../" + _nameOfFile)); - info->setTo(folderName); - dbxImport(info, mailbox); - return; - } else if (sig_block2 == OE5_FOLDER_SIG_2) { - if(!parsedFolder) { - info->addLog(i18n("Importing OE5+ Folder file %1").arg( "../" + _nameOfFile)); - currentIsFolderFile = true; - dbxImport(info, mailbox); - currentIsFolderFile = false; - } - return; - } - } - } - // info->addLog(i18n("File %1 does not seem to be an Outlook Express mailbox").arg("../" + _nameOfFile)); -} - -/* ------------------- MBX support ------------------- */ - -void FilterOE::mbxImport( FilterInfo *info, TQDataStream& ds) -{ - TQ_UINT32 msgCount, lastMsgNum, fileSize; - - // Read the header - ds >> msgCount >> lastMsgNum >> fileSize; - ds.device()->at( ds.device()->at() + 64 ); // Skip 0's - kdDebug() << "This mailbox has " << msgCount << " messages" << endl; - if (msgCount == 0) - return; // Don't import empty mailbox - - TQ_UINT32 msgMagic; - ds >> msgMagic; // Read first magic - - while (!ds.atEnd()) { - TQ_UINT32 msgNumber, msgSize, msgTextSize; - KTempFile tmp; - tmp.dataStream()->setByteOrder(TQDataStream::LittleEndian); - - // Read the messages - ds >> msgNumber >> msgSize >> msgTextSize; // All seem to be lies...? - - do { - ds >> msgMagic; - if (msgMagic != MBX_MAILMAGIC) - *tmp.dataStream() << msgMagic; - else - break; - } while ( !ds.atEnd() ); - - tmp.close(); - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(info->removeDupMsg) - addMessage( info, folderName, tmp.name() ); - else - addMessage_fastImport( info, folderName, tmp.name() ); - - tmp.unlink(); - if(info->shouldTerminate()) return; - } -} - -/* ------------------- DBX support ------------------- */ - -void FilterOE::dbxImport( FilterInfo *info, TQDataStream& ds) -{ - // Get item count & offset of index - TQ_UINT32 itemCount, indexPtr; - ds.device()->at(0xc4); - ds >> itemCount; - ds.device()->at(0xe4); - ds >> indexPtr; - kdDebug() << "Item count is " << itemCount << ", Index at " << indexPtr << endl; - - if (itemCount == 0) - return; // Empty file - totalEmails = itemCount; - currentEmail = 0; - // Parse the indexes - ds.device()->at(indexPtr); - dbxReadIndex(info, ds, indexPtr); -} - -void FilterOE::dbxReadIndex( FilterInfo *info, TQDataStream& ds, int filePos) -{ - - if(info->shouldTerminate()) return; - TQ_UINT32 self, unknown, nextIndexPtr, parent, indexCount; - TQ_UINT8 unknown2, ptrCount; - TQ_UINT16 unknown3; - int wasAt = ds.device()->at(); - ds.device()->at(filePos); - - - kdDebug() << "Reading index of file " << folderName << endl; - ds >> self >> unknown >> nextIndexPtr >> parent >> unknown2 >> ptrCount >> unknown3 >> indexCount; // _dbx_tableindexstruct - - kdDebug() << "This index has " << (int) ptrCount << " data pointers" << endl; - for (int count = 0; count < ptrCount; count++) { - if(info->shouldTerminate()) return; - TQ_UINT32 dataIndexPtr, anotherIndexPtr, anotherIndexCount; // _dbx_indexstruct - ds >> dataIndexPtr >> anotherIndexPtr >> anotherIndexCount; - - if (anotherIndexCount > 0) { - kdDebug() << "Recursing to another table @ " << anotherIndexPtr << endl; - dbxReadIndex(info, ds, anotherIndexPtr); - } - kdDebug() << "Data index @ " << dataIndexPtr << endl; - dbxReadDataBlock(info, ds, dataIndexPtr); - } - - if (indexCount > 0) { // deal with nextTablePtr - kdDebug() << "Recuring to next table @ " << nextIndexPtr << endl; - dbxReadIndex(info, ds, nextIndexPtr); - } - - ds.device()->at(wasAt); // Restore file position to same as when function called -} - -void FilterOE::dbxReadDataBlock( FilterInfo *info, TQDataStream& ds, int filePos) -{ - TQ_UINT32 curOffset, blockSize; - TQ_UINT16 unknown; - TQ_UINT8 count, unknown2; - int wasAt = ds.device()->at(); - - TQString folderEntry[4]; - - ds.device()->at(filePos); - - ds >> curOffset >> blockSize >> unknown >> count >> unknown2; // _dbx_email_headerstruct - kdDebug() << "Data block has " << (int) count << " elements" << endl; - - for (int c = 0; c < count; c++) { - if(info->shouldTerminate()) return; - TQ_UINT8 type; // _dbx_email_pointerstruct - TQ_UINT32 value; // Actually 24 bit - - ds >> type >> value; - value &= 0xffffff; - ds.device()->at(ds.device()->at() - 1); // We only wanted 3 bytes - - if(!currentIsFolderFile) { - if (type == 0x84) { // It's an email! - kdDebug() << "**** Offset of emaildata (0x84) " << value << " ****" << endl; - dbxReadEmail(info, ds, value); - ++count0x84; - } else if( type == 0x04) { - int currentFilePos = ds.device()->at(); - ds.device()->at(filePos + 12 + value + (count*4) ); - TQ_UINT32 newOFF; - ds >> newOFF; - kdDebug() << "**** Offset of emaildata (0x04) " << newOFF << endl; - ds.device()->at(currentFilePos); - dbxReadEmail(info, ds, newOFF); - ++count0x04; - } - } - else { - // this is a folderfile - if(type == 0x02) { - // kdDebug() << "**** FOLDER: descriptive name ****" << endl; - folderEntry[0] = parseFolderString(ds, filePos + 12 + value + (count*4) ); - } else if (type == 0x03) { - // kdDebug() << "**** FOLDER: filename ****" << endl; - folderEntry[1] = parseFolderString(ds, filePos + 12 + value + (count*4) ); - - } else if (type == 0x80) { - // kdDebug() << "**** FOLDER: current ID ****" << endl; - folderEntry[2] = TQString::number(value); - - } else if (type == 0x81) { - // kdDebug() << "**** FOLDER: parent ID ****" << endl; - folderEntry[3] = TQString::number(value); - } - } - } - if(currentIsFolderFile) { - folderStructure.append(folderEntry); - } - ds.device()->at(wasAt); // Restore file position to same as when function called -} - -void FilterOE::dbxReadEmail( FilterInfo *info, TQDataStream& ds, int filePos) -{ - if(info->shouldTerminate()) return; - TQ_UINT32 self, nextAddressOffset, nextAddress=0; - TQ_UINT16 blockSize; - TQ_UINT8 intCount, unknown; - KTempFile tmp; - bool _break = false; - int wasAt = ds.device()->at(); - ds.device()->at(filePos); - - do { - ds >> self >> nextAddressOffset >> blockSize >> intCount >> unknown >> nextAddress; // _dbx_block_hdrstruct - TQByteArray blockBuffer(blockSize); - ds.readRawBytes(blockBuffer.data(), blockSize); - tmp.dataStream()->writeRawBytes(blockBuffer.data(), blockSize); - // to detect incomplete mails or corrupted archives. See Bug #86119 - if(ds.atEnd()) { - _break = true; - break; - } - ds.device()->at(nextAddress); - } while (nextAddress != 0); - tmp.close(); - - if(!_break) { - if(info->removeDupMsg) - addMessage( info, folderName, tmp.name() ); - else - addMessage_fastImport( info, folderName, tmp.name() ); - - currentEmail++; - int currentPercentage = (int) ( ( (float) currentEmail / totalEmails ) * 100 ); - info->setCurrent(currentPercentage); - ds.device()->at(wasAt); - } - tmp.unlink(); -} - -/* ------------------- FolderFile support ------------------- */ -TQString FilterOE::parseFolderString( TQDataStream& ds, int filePos ) -{ - char tmp; - TQString returnString; - int wasAt = ds.device()->at(); - ds.device()->at(filePos); - - // read while != 0x00 - while( !ds.device()->atEnd() ) { - tmp = ds.device()->getch(); - if( tmp != 0x00) { - returnString += tmp; - } - else break; - } - ds.device()->at(wasAt); - return returnString; -} - -/** get the foldername for a given file ID from folderMatrix */ -TQString FilterOE::getFolderName(TQString filename) -{ - bool found = false; - bool foundFilename = false; - TQString folder; - // we must do this because folder with more than one upper letter - // at start have maybe not a file named like the folder !!! - TQString search = filename.lower(); - - while (!found) - { - for ( FolderStructureIterator it = folderStructure.begin(); it != folderStructure.end(); it++) { - FolderStructure tmp = *it; - if(foundFilename == false) { - TQString _tmpFileName = tmp[1]; - _tmpFileName = _tmpFileName.lower(); - if(_tmpFileName == search) { - folder.prepend( tmp[0] + TQString::fromLatin1("/") ); - search = tmp[3]; - foundFilename = true; - } - } else { - TQString _currentID = tmp[2]; - TQString _parentID = tmp[3]; - if(_currentID == search) { - if(_parentID.isEmpty()) { // this is the root of the folder - found = true; - break; - } else { - folder.prepend( tmp[0] + TQString::fromLatin1("/") ); - search = tmp[3]; - } - } - } - } - // need to break the while loop maybe in some cases - if((foundFilename == false) && (folder.isEmpty())) return folder; - } - return folder; -} diff --git a/kmailcvt/filter_oe.h b/kmailcvt/filter_oe.h new file mode 100644 index 00000000..2a46854f --- /dev/null +++ b/kmailcvt/filter_oe.h @@ -0,0 +1,84 @@ +/*************************************************************************** + filter_oe.h - Outlook Express mail import + ------------------- + begin : Sat Feb 1 2003 + copyright : (C) 2003 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_OE_H +#define FILTER_OE_H + +#include "filters.h" + +/** + *imports outlook text messages into KMail + *@author Laurence Anderson + */ + +class FilterOE : public Filter +{ +public: + FilterOE(); + ~FilterOE(); + + void import(FilterInfo *info); + +protected: + void importMailBox( FilterInfo *info, const TQString& fileName); + void mbxImport( FilterInfo *info, TQDataStream& ds); + void dbxImport( FilterInfo *info, TQDataStream& ds); + void dbxReadIndex( FilterInfo *info, TQDataStream& ds, int filePos); + void dbxReadDataBlock( FilterInfo *info, TQDataStream& ds, int filePos); + void dbxReadEmail( FilterInfo *info, TQDataStream& ds, int filePos); + + /** helperfunctions for folder structure support */ + TQString parseFolderString( TQDataStream& ds, int filePos); + TQString getFolderName(TQString filename); + +private: // Private methods + /** which file (of totalFiles) is now in the work? */ + int currentFile; + /** total number of files that get imported */ + int totalFiles; + /** total emails in current file */ + int totalEmails; + /** which email (of totalFiles) is now in the work? */ + int currentEmail; + /** number of imported mails with flag 0x04 */ + int count0x04; + /** number of imported mails with flag 0x84 */ + int count0x84; + + /** true if the folderstructure is parsed */ + bool parsedFolder; + /** true if the current parsing file is the folder file */ + bool currentIsFolderFile; + + /** Folder structure with following 4 entries: + 1. descriptive folder name + 2. filename + 3. ID of current folder + 4. ID of parent folder + */ + typedef FolderStructureBase<4> FolderStructure; + /** matrix with information about the folder structure*/ + TQValueList folderStructure; + typedef TQValueList::Iterator FolderStructureIterator; + + /** name of the current folder */ + TQString folderName; + /** name of the chosen folder */ + TQString mailDir; +}; + +#endif diff --git a/kmailcvt/filter_oe.hxx b/kmailcvt/filter_oe.hxx deleted file mode 100644 index 821aa5df..00000000 --- a/kmailcvt/filter_oe.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - filter_oe.hxx - Outlook Express mail import - ------------------- - begin : Sat Feb 1 2003 - copyright : (C) 2003 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_OE_HXX -#define FILTER_OE_HXX - -#include "filters.hxx" - -/** - *imports outlook text messages into KMail - *@author Laurence Anderson - */ - -class FilterOE : public Filter -{ -public: - FilterOE(); - ~FilterOE(); - - void import(FilterInfo *info); - -protected: - void importMailBox( FilterInfo *info, const TQString& fileName); - void mbxImport( FilterInfo *info, TQDataStream& ds); - void dbxImport( FilterInfo *info, TQDataStream& ds); - void dbxReadIndex( FilterInfo *info, TQDataStream& ds, int filePos); - void dbxReadDataBlock( FilterInfo *info, TQDataStream& ds, int filePos); - void dbxReadEmail( FilterInfo *info, TQDataStream& ds, int filePos); - - /** helperfunctions for folder structure support */ - TQString parseFolderString( TQDataStream& ds, int filePos); - TQString getFolderName(TQString filename); - -private: // Private methods - /** which file (of totalFiles) is now in the work? */ - int currentFile; - /** total number of files that get imported */ - int totalFiles; - /** total emails in current file */ - int totalEmails; - /** which email (of totalFiles) is now in the work? */ - int currentEmail; - /** number of imported mails with flag 0x04 */ - int count0x04; - /** number of imported mails with flag 0x84 */ - int count0x84; - - /** true if the folderstructure is parsed */ - bool parsedFolder; - /** true if the current parsing file is the folder file */ - bool currentIsFolderFile; - - /** Folder structure with following 4 entries: - 1. descriptive folder name - 2. filename - 3. ID of current folder - 4. ID of parent folder - */ - typedef FolderStructureBase<4> FolderStructure; - /** matrix with information about the folder structure*/ - TQValueList folderStructure; - typedef TQValueList::Iterator FolderStructureIterator; - - /** name of the current folder */ - TQString folderName; - /** name of the chosen folder */ - TQString mailDir; -}; - -#endif diff --git a/kmailcvt/filter_opera.cpp b/kmailcvt/filter_opera.cpp new file mode 100644 index 00000000..ff537695 --- /dev/null +++ b/kmailcvt/filter_opera.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + filter_opera.cpp - Opera mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include "filter_opera.h" + + +FilterOpera::FilterOpera() : + Filter( i18n("Import Opera Emails"), + "Danny Kukawka", + i18n("

Opera email import filter

" + "

This filter will import mails from Opera mail folder. Use this filter " + "if you want to import all mails within a account in the Opera maildir.

" + "

Select the directory of the account (usually ~/.opera/mail/store/account*).

" + "

Note: Emails will be imported into a folder named after the account " + "they came from, prefixed with OPERA-

" )) +{} + +FilterOpera::~FilterOpera() +{ +} + +void FilterOpera::import(FilterInfo *info) +{ + /** try to go to opera mailfolder in the home of the user */ + TQString startdir = TQDir::homeDirPath() + "/.opera/mail/store/"; + TQDir d( startdir ); + if ( !d.exists() ) { + startdir = TQDir::homeDirPath(); + } + + //TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); + KFileDialog *kfd; + kfd = new KFileDialog( startdir, "", 0, "tdefiledialog", true ); + kfd->setMode(KFile::Directory | KFile::LocalOnly); + kfd->exec(); + TQString operaDir = kfd->selectedFile(); + delete kfd; + + if (operaDir.isEmpty()) { + info->alert(i18n("No directory selected.")); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( operaDir == TQDir::homeDirPath() || operaDir == (TQDir::homeDirPath() + "/")) { + info->addLog(i18n("No files found for import.")); + } else { + info->setOverall(0); + + TQDir importDir (operaDir); + TQStringList files = importDir.entryList("*.[mM][bB][sS]", TQDir::Files, TQDir::Name); + + // Count total number of files to be processed + info->addLog(i18n("Counting files...")); + int totalFiles = files.count(); + int currentFile = 1; + + if(totalFiles > 0) { + int overall_status = 0; + + info->addLog(i18n("Importing new mail files...")); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { + info->setCurrent(0); + TQFile operaArchiv( importDir.filePath(*mailFile) ); + if (! operaArchiv.open( IO_ReadOnly ) ) { + info->alert( i18n("Unable to open %1, skipping").arg( *mailFile ) ); + } else { + info->addLog( i18n("Importing emails from %1...").arg( *mailFile ) ); + TQFileInfo filenameInfo( importDir.filePath(*mailFile) ); + TQString folderName( "OPERA-" + importDir.dirName() ); + + info->setFrom( *mailFile ); + info->setTo( folderName ); + + TQByteArray input(MAX_LINE); + long l = 0; + bool first_msg = true; + + while ( !operaArchiv.atEnd() ) { + KTempFile tmp; + /* comment by Danny: + * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = operaArchiv.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + tmp.file()->writeBlock( input, l ); + + while ( ! operaArchiv.atEnd() && (l = operaArchiv.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + /** remove in KMail unneeded Flags from Opera (for example: X-Opera-Status)*/ + if(seperate.left(8) != "X-Opera-") + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; + + if(info->removeDupMsg) + addMessage( info, folderName, tmp.name() ); + else + addMessage_fastImport( info, folderName, tmp.name() ); + tmp.unlink(); + int currentPercentage = (int) ( ( (float) operaArchiv.at() / filenameInfo.size() ) * 100 ); + info->setCurrent( currentPercentage ); + + if (currentFile == 1) + overall_status = (int) ( currentPercentage * ( (float) currentFile / totalFiles ) ); + else + overall_status = (int)(((currentFile-1)*(100.0/(float)totalFiles))+(currentPercentage*(1.0/(float)totalFiles))); + + info->setOverall( overall_status ); + if ( info->shouldTerminate() ) break; + } + + info->addLog( i18n("Finished importing emails from %1").arg( *mailFile )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + currentFile++; + count_duplicates = 0; + operaArchiv.close(); + } + if ( info->shouldTerminate() ) break; + } + } else { + info->addLog(i18n("No files found for import.")); + } + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + info->setCurrent(100); + info->setOverall(100); +} diff --git a/kmailcvt/filter_opera.cxx b/kmailcvt/filter_opera.cxx deleted file mode 100644 index 90aef382..00000000 --- a/kmailcvt/filter_opera.cxx +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************** - filter_opera.cxx - Opera mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include "filter_opera.hxx" - - -FilterOpera::FilterOpera() : - Filter( i18n("Import Opera Emails"), - "Danny Kukawka", - i18n("

Opera email import filter

" - "

This filter will import mails from Opera mail folder. Use this filter " - "if you want to import all mails within a account in the Opera maildir.

" - "

Select the directory of the account (usually ~/.opera/mail/store/account*).

" - "

Note: Emails will be imported into a folder named after the account " - "they came from, prefixed with OPERA-

" )) -{} - -FilterOpera::~FilterOpera() -{ -} - -void FilterOpera::import(FilterInfo *info) -{ - /** try to go to opera mailfolder in the home of the user */ - TQString startdir = TQDir::homeDirPath() + "/.opera/mail/store/"; - TQDir d( startdir ); - if ( !d.exists() ) { - startdir = TQDir::homeDirPath(); - } - - //TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); - KFileDialog *kfd; - kfd = new KFileDialog( startdir, "", 0, "tdefiledialog", true ); - kfd->setMode(KFile::Directory | KFile::LocalOnly); - kfd->exec(); - TQString operaDir = kfd->selectedFile(); - delete kfd; - - if (operaDir.isEmpty()) { - info->alert(i18n("No directory selected.")); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( operaDir == TQDir::homeDirPath() || operaDir == (TQDir::homeDirPath() + "/")) { - info->addLog(i18n("No files found for import.")); - } else { - info->setOverall(0); - - TQDir importDir (operaDir); - TQStringList files = importDir.entryList("*.[mM][bB][sS]", TQDir::Files, TQDir::Name); - - // Count total number of files to be processed - info->addLog(i18n("Counting files...")); - int totalFiles = files.count(); - int currentFile = 1; - - if(totalFiles > 0) { - int overall_status = 0; - - info->addLog(i18n("Importing new mail files...")); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { - info->setCurrent(0); - TQFile operaArchiv( importDir.filePath(*mailFile) ); - if (! operaArchiv.open( IO_ReadOnly ) ) { - info->alert( i18n("Unable to open %1, skipping").arg( *mailFile ) ); - } else { - info->addLog( i18n("Importing emails from %1...").arg( *mailFile ) ); - TQFileInfo filenameInfo( importDir.filePath(*mailFile) ); - TQString folderName( "OPERA-" + importDir.dirName() ); - - info->setFrom( *mailFile ); - info->setTo( folderName ); - - TQByteArray input(MAX_LINE); - long l = 0; - bool first_msg = true; - - while ( !operaArchiv.atEnd() ) { - KTempFile tmp; - /* comment by Danny: - * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - - if(!first_msg) - tmp.file()->writeBlock( input, l ); - l = operaArchiv.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - - while ( ! operaArchiv.atEnd() && (l = operaArchiv.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - /** remove in KMail unneeded Flags from Opera (for example: X-Opera-Status)*/ - if(seperate.left(8) != "X-Opera-") - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; - - if(info->removeDupMsg) - addMessage( info, folderName, tmp.name() ); - else - addMessage_fastImport( info, folderName, tmp.name() ); - tmp.unlink(); - int currentPercentage = (int) ( ( (float) operaArchiv.at() / filenameInfo.size() ) * 100 ); - info->setCurrent( currentPercentage ); - - if (currentFile == 1) - overall_status = (int) ( currentPercentage * ( (float) currentFile / totalFiles ) ); - else - overall_status = (int)(((currentFile-1)*(100.0/(float)totalFiles))+(currentPercentage*(1.0/(float)totalFiles))); - - info->setOverall( overall_status ); - if ( info->shouldTerminate() ) break; - } - - info->addLog( i18n("Finished importing emails from %1").arg( *mailFile )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - currentFile++; - count_duplicates = 0; - operaArchiv.close(); - } - if ( info->shouldTerminate() ) break; - } - } else { - info->addLog(i18n("No files found for import.")); - } - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - info->setCurrent(100); - info->setOverall(100); -} diff --git a/kmailcvt/filter_opera.h b/kmailcvt/filter_opera.h new file mode 100644 index 00000000..7da80afa --- /dev/null +++ b/kmailcvt/filter_opera.h @@ -0,0 +1,37 @@ +/*************************************************************************** + filter_opera.h - Opera mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_OPERA_H +#define FILTER_OPERA_H + +#include "filters.h" + +/** + *imports opera account-archives into KMail + *@author Danny Kukawka + */ + +class FilterOpera : public Filter +{ +public: + FilterOpera(); + ~FilterOpera(); + + void import(FilterInfo *info); +}; + +#endif diff --git a/kmailcvt/filter_opera.hxx b/kmailcvt/filter_opera.hxx deleted file mode 100644 index 27ded4cc..00000000 --- a/kmailcvt/filter_opera.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - filter_opera.hxx - Opera mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_OPERA_HXX -#define FILTER_OPERA_HXX - -#include "filters.hxx" - -/** - *imports opera account-archives into KMail - *@author Danny Kukawka - */ - -class FilterOpera : public Filter -{ -public: - FilterOpera(); - ~FilterOpera(); - - void import(FilterInfo *info); -}; - -#endif diff --git a/kmailcvt/filter_outlook.cpp b/kmailcvt/filter_outlook.cpp new file mode 100644 index 00000000..bb395918 --- /dev/null +++ b/kmailcvt/filter_outlook.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + filter_opera.cpp - Outlook mail import + ------------------- + begin : February 01 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include +#include +#include +#include +#include + +#include "filter_outlook.h" + +FilterOutlook::FilterOutlook() : + Filter( i18n("Import Outlook Emails"), + "Danny Kukawka", + i18n("

Outlook email import filter

" + "

This filter will import mails from a Outlook pst-file. You will need to locate " + "the folder where the pst-file has been stored by searching for .pst files under: " + "C:\\Documents and Settings in Windows 2000 or later

" + "

Note: Emails will be imported into a folder named after the " + "account they came from, prefixed with OUTLOOK-

" )) +{} + +FilterOutlook::~FilterOutlook() +{ +} + +void FilterOutlook::import(FilterInfo *info) +{ + info->alert(i18n("No directory selected.")); + info->addLog(i18n("Counting files...")); + info->addLog(i18n("Counting mail...")); + info->addLog(i18n("Counting directories...")); + info->addLog(i18n("Counting folders...")); + info->addLog(i18n("Importing new mail files...")); + info->addLog(i18n("No files found for import.")); + + TQString outlookDir; + outlookDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); + TQDir importDir (outlookDir); + TQStringList files = importDir.entryList("*.[pP][sS][tT]", TQDir::Files, TQDir::Name); + for ( TQStringList::Iterator pstFile = files.begin(); pstFile != files.end(); ++pstFile) { + info->addLog( i18n("Importing emails from %1...").arg( *pstFile ) ); + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + info->alert( i18n("Unable to open %1, skipping").arg( *pstFile ) ); + } +} diff --git a/kmailcvt/filter_outlook.cxx b/kmailcvt/filter_outlook.cxx deleted file mode 100644 index 10483d09..00000000 --- a/kmailcvt/filter_outlook.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - filter_opera.cxx - Outlook mail import - ------------------- - begin : February 01 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include -#include -#include -#include -#include - -#include "filter_outlook.hxx" - -FilterOutlook::FilterOutlook() : - Filter( i18n("Import Outlook Emails"), - "Danny Kukawka", - i18n("

Outlook email import filter

" - "

This filter will import mails from a Outlook pst-file. You will need to locate " - "the folder where the pst-file has been stored by searching for .pst files under: " - "C:\\Documents and Settings in Windows 2000 or later

" - "

Note: Emails will be imported into a folder named after the " - "account they came from, prefixed with OUTLOOK-

" )) -{} - -FilterOutlook::~FilterOutlook() -{ -} - -void FilterOutlook::import(FilterInfo *info) -{ - info->alert(i18n("No directory selected.")); - info->addLog(i18n("Counting files...")); - info->addLog(i18n("Counting mail...")); - info->addLog(i18n("Counting directories...")); - info->addLog(i18n("Counting folders...")); - info->addLog(i18n("Importing new mail files...")); - info->addLog(i18n("No files found for import.")); - - TQString outlookDir; - outlookDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(), info->parent()); - TQDir importDir (outlookDir); - TQStringList files = importDir.entryList("*.[pP][sS][tT]", TQDir::Files, TQDir::Name); - for ( TQStringList::Iterator pstFile = files.begin(); pstFile != files.end(); ++pstFile) { - info->addLog( i18n("Importing emails from %1...").arg( *pstFile ) ); - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - info->alert( i18n("Unable to open %1, skipping").arg( *pstFile ) ); - } -} diff --git a/kmailcvt/filter_outlook.h b/kmailcvt/filter_outlook.h new file mode 100644 index 00000000..ec762066 --- /dev/null +++ b/kmailcvt/filter_outlook.h @@ -0,0 +1,38 @@ +/*************************************************************************** + filter_opera.h - Outlook mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_OUTLOOK_H +#define FILTER_OUTLOOK_H + +#include "filters.h" + +/** + * imports mails from Outlook pst-files into KMail + * NOTE: This is a dummy at the moment + * @author Danny Kukawka + */ + +class FilterOutlook : public Filter +{ +public: + FilterOutlook(); + ~FilterOutlook(); + + void import(FilterInfo *info); +}; + +#endif diff --git a/kmailcvt/filter_outlook.hxx b/kmailcvt/filter_outlook.hxx deleted file mode 100644 index bad7d5ee..00000000 --- a/kmailcvt/filter_outlook.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - filter_opera.hxx - Outlook mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_OUTLOOK_HXX -#define FILTER_OUTLOOK_HXX - -#include "filters.hxx" - -/** - * imports mails from Outlook pst-files into KMail - * NOTE: This is a dummy at the moment - * @author Danny Kukawka - */ - -class FilterOutlook : public Filter -{ -public: - FilterOutlook(); - ~FilterOutlook(); - - void import(FilterInfo *info); -}; - -#endif diff --git a/kmailcvt/filter_plain.cpp b/kmailcvt/filter_plain.cpp new file mode 100644 index 00000000..01554c87 --- /dev/null +++ b/kmailcvt/filter_plain.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + FilterPlain.cpp - Plain mail import + ------------------- + begin : Fri Jun 14 2002 + copyright : (C) 2002 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include + +#include "filter_plain.h" + + +FilterPlain::FilterPlain() : + Filter(i18n("Import Plain Text Emails"), + "Laurence Anderson

( Filter accelerated by Danny Kukawka )

", + i18n("

Select the directory containing the emails on your system. " + "The emails are placed in a folder with the same name as the " + "directory they were in, prefixed by PLAIN-

" + "

This filter will import all .msg, .eml and .txt emails.

")) +{} + +FilterPlain::~FilterPlain() +{ +} + +void FilterPlain::import(FilterInfo *info) +{ + // Select directory containing plain text emails + TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(),info->parent()); + if (mailDir.isEmpty()) { // No directory selected + info->alert(i18n("No directory selected.")); + return; + } + TQDir dir (mailDir); + TQStringList files = dir.entryList("*.[eE][mM][lL]; *.[tT][xX][tT]; *.[mM][sS][gG]", TQDir::Files, TQDir::Name); + + // Count total number of files to be processed + info->addLog(i18n("Counting files...")); + int totalFiles = files.count(); + int currentFile = 0; + + info->addLog(i18n("Importing new mail files...")); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { + info->setFrom(*mailFile); + info->setTo(dir.dirName()); + info->setCurrent(0); + + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(info->removeDupMsg) { + if(! addMessage( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + } else { + if( ! addMessage_fastImport( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + } + + info->setCurrent(100); + info->setOverall(100 * ++currentFile/ totalFiles); + if ( info->shouldTerminate() ) break; + } + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + + count_duplicates = 0; +} diff --git a/kmailcvt/filter_plain.cxx b/kmailcvt/filter_plain.cxx deleted file mode 100644 index 9f78b939..00000000 --- a/kmailcvt/filter_plain.cxx +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** - FilterPlain.cxx - Plain mail import - ------------------- - begin : Fri Jun 14 2002 - copyright : (C) 2002 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include - -#include "filter_plain.hxx" - - -FilterPlain::FilterPlain() : - Filter(i18n("Import Plain Text Emails"), - "Laurence Anderson

( Filter accelerated by Danny Kukawka )

", - i18n("

Select the directory containing the emails on your system. " - "The emails are placed in a folder with the same name as the " - "directory they were in, prefixed by PLAIN-

" - "

This filter will import all .msg, .eml and .txt emails.

")) -{} - -FilterPlain::~FilterPlain() -{ -} - -void FilterPlain::import(FilterInfo *info) -{ - // Select directory containing plain text emails - TQString mailDir = KFileDialog::getExistingDirectory(TQDir::homeDirPath(),info->parent()); - if (mailDir.isEmpty()) { // No directory selected - info->alert(i18n("No directory selected.")); - return; - } - TQDir dir (mailDir); - TQStringList files = dir.entryList("*.[eE][mM][lL]; *.[tT][xX][tT]; *.[mM][sS][gG]", TQDir::Files, TQDir::Name); - - // Count total number of files to be processed - info->addLog(i18n("Counting files...")); - int totalFiles = files.count(); - int currentFile = 0; - - info->addLog(i18n("Importing new mail files...")); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { - info->setFrom(*mailFile); - info->setTo(dir.dirName()); - info->setCurrent(0); - - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(info->removeDupMsg) { - if(! addMessage( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - } else { - if( ! addMessage_fastImport( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - } - - info->setCurrent(100); - info->setOverall(100 * ++currentFile/ totalFiles); - if ( info->shouldTerminate() ) break; - } - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - - count_duplicates = 0; -} diff --git a/kmailcvt/filter_plain.h b/kmailcvt/filter_plain.h new file mode 100644 index 00000000..2319e888 --- /dev/null +++ b/kmailcvt/filter_plain.h @@ -0,0 +1,37 @@ +/*************************************************************************** + FilterPlain.h - Plain mail import + ------------------- + begin : Fri Jun 24 2002 + copyright : (C) 2002 by Laurence Anderson + email : l.d.anderson@warwick.ac.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_PLAIN_H +#define FILTER_PLAIN_H + +#include "filters.h" + +/** + *imports Plain text messages into KMail + *@author laurence + */ + +class FilterPlain : public Filter +{ +public: + FilterPlain(); + ~FilterPlain(); + + void import(FilterInfo *info); +}; + +#endif diff --git a/kmailcvt/filter_plain.hxx b/kmailcvt/filter_plain.hxx deleted file mode 100644 index ddd9d494..00000000 --- a/kmailcvt/filter_plain.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - FilterPlain.hxx - Plain mail import - ------------------- - begin : Fri Jun 24 2002 - copyright : (C) 2002 by Laurence Anderson - email : l.d.anderson@warwick.ac.uk - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_PLAIN_HXX -#define FILTER_PLAIN_HXX - -#include "filters.hxx" - -/** - *imports Plain text messages into KMail - *@author laurence - */ - -class FilterPlain : public Filter -{ -public: - FilterPlain(); - ~FilterPlain(); - - void import(FilterInfo *info); -}; - -#endif diff --git a/kmailcvt/filter_pmail.cpp b/kmailcvt/filter_pmail.cpp new file mode 100644 index 00000000..b45a0be4 --- /dev/null +++ b/kmailcvt/filter_pmail.cpp @@ -0,0 +1,346 @@ +/*************************************************************************** + FilterPMail.cpp - Pegasus-Mail import + ------------------- + begin : Sat Jan 6 2001 + copyright : (C) 2001 by Holger Schurig + (C) 2005 by Danny Kukawka + email : holgerschurig@gmx.de + danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "filter_pmail.h" + + +FilterPMail::FilterPMail() : + Filter(i18n("Import Folders From Pegasus-Mail"), + "Holger Schurig
( rewritten by Danny Kukawka )", + i18n("

Select the Pegasus-Mail directory on your system (containing *.CNM, *.PMM and *.MBX files). " + "On many systems this is stored in C:\\pmail\\mail or C:\\pmail\\mail\\admin

" + "

Note: Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"PegasusMail-Import\".

")) +{} + +FilterPMail::~FilterPMail() +{ +} + +void FilterPMail::import(FilterInfo *info) +{ + inf = info; + + // Select directory from where I have to import files + KFileDialog *kfd; + kfd = new KFileDialog( TQDir::homeDirPath(), "", 0, "tdefiledialog", true ); + kfd->setMode(KFile::Directory | KFile::LocalOnly); + kfd->exec(); + chosenDir = kfd->selectedFile(); + delete kfd; + + if (chosenDir.isEmpty()) { + info->alert(i18n("No directory selected.")); + return; + } + + // Count total number of files to be processed + info->addLog(i18n("Counting files...")); + dir.setPath (chosenDir); + TQStringList files = dir.entryList("*.[cC][nN][mM]; *.[pP][mM][mM]; *.[mM][bB][xX]", TQDir::Files, TQDir::Name); + totalFiles = files.count(); + currentFile = 0; + kdDebug() << "Count is " << totalFiles << endl; + + if(!(folderParsed = parseFolderMatrix())) { + info->addLog(i18n("Cannot parse the folder structure; continuing import without subfolder support.")); + } + + info->addLog(i18n("Importing new mail files ('.cnm')...")); + processFiles("*.[cC][nN][mM]", &FilterPMail::importNewMessage); + info->addLog(i18n("Importing mail folders ('.pmm')...")); + processFiles("*.[pP][mM][mM]", &FilterPMail::importMailFolder); + info->addLog(i18n("Importing 'UNIX' mail folders ('.mbx')...")); + processFiles("*.[mM][bB][xX]", &FilterPMail::importUnixMailFolder); + + info->addLog( i18n("Finished importing emails from %1").arg( chosenDir )); + info->setCurrent(100); + info->setOverall(100); +} + +/** this looks for all files with the filemask 'mask' and calls the 'workFunc' on each of them */ +void FilterPMail::processFiles(const TQString& mask, void(FilterPMail::* workFunc)(const TQString&) ) +{ + if (inf->shouldTerminate()) return; + + TQStringList files = dir.entryList(mask, TQDir::Files, TQDir::Name); + //kdDebug() << "Mask is " << mask << " count is " << files.count() << endl; + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { + // Notify current file + TQFileInfo mailfileinfo(*mailFile); + inf->setFrom(mailfileinfo.fileName()); + + // Clear the other fields + inf->setTo(TQString()); + inf->setCurrent(TQString()); + inf->setCurrent(-1); + + // call worker function, increase progressbar + (this->*workFunc)(dir.filePath(*mailFile)); + ++currentFile; + inf->setOverall( (int) ((float) currentFile / totalFiles * 100)); + inf->setCurrent( 100 ); + if (inf->shouldTerminate()) return; + } +} + + +/** this function imports one *.CNM message */ +void FilterPMail::importNewMessage(const TQString& file) +{ + TQString destFolder("PegasusMail-Import/New Messages"); + inf->setTo(destFolder); + + /* comment by Danny Kukawka: + * addMessage() == old function, need more time and check for duplicates + * addMessage_fastImport == new function, faster and no check for duplicates + */ + if(inf->removeDupMsg) + addMessage( inf, destFolder, file ); + else + addMessage_fastImport( inf, destFolder, file ); +} + + +/** this function imports one mail folder file (*.PMM) */ +void FilterPMail::importMailFolder(const TQString& file) +{ + // Format of a PMM file: + // First comes a header with 128 bytes. At the beginning is the name of + // the folder. Then there are some unknown bytes (strings). At offset 128 + // the first message starts. + // + // Each message is terminated by a 0x1A byte. The next message follows + // immediately. + // + // The last message is followed by a 0x1A, too. + // + // 000000 6d 61 69 6c 73 65 72 76 65 72 2d 70 72 6f 6a 65 mailserver-proje + // 000010 63 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ct.............. + // 000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + // 000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + // 000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + // 000050 00 00 00 00 00 00 36 30 34 37 35 37 32 45 3a 36 ......6047572E:6 + // 000060 46 34 39 3a 46 4f 4c 30 31 33 35 35 00 00 00 00 F49:FOL01355.... + // 000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + // 000080 52 65 74 75 72 6e 2d 50 61 74 68 3a 20 3c 75 72 Return-Path: alert(i18n("Unable to open %1, skipping").arg(file)); + } else { + // Get folder name + l = f.readBlock((char *) &pmm_head, sizeof(pmm_head)); + TQString folder("PegasusMail-Import/"); + if(folderParsed) + folder.append(getFolderName((TQString)pmm_head.id)); + else + folder.append(pmm_head.folder); + inf->setTo(folder); + inf->addLog(i18n("Importing %1").arg("../" + TQString(pmm_head.folder))); + + TQByteArray input(MAX_LINE); + bool first_msg = true; + + while (!f.atEnd()) { + KTempFile tempfile; + inf->setCurrent( (int) ( ( (float) f.at() / f.size() ) * 100 ) ); + + if(!first_msg) { + // set the filepos back to last line minus the seperate char (0x1a) + f.at(f.at() - l + 1); + } + + // no problem to loose the last line in file. This only contains a seperate char + while ( ! f.atEnd() && (l = f.readLine(input.data(),MAX_LINE))) { + if (inf->shouldTerminate()){ + tempfile.close(); + tempfile.unlink(); + return; + } + if(input[0] == 0x1a ) { + break; + } else { + tempfile.file()->writeBlock( input, l ); + } + } + tempfile.close(); + + if(inf->removeDupMsg) + addMessage( inf, folder, tempfile.name() ); + else + addMessage_fastImport( inf, folder, tempfile.name() ); + + first_msg = false; + tempfile.unlink(); + } + } + f.close(); +} + + +/** imports a 'unix' format mail folder (*.MBX) */ +void FilterPMail::importUnixMailFolder(const TQString& file) +{ + struct { + char folder[58]; + char id[31]; + } pmg_head; + + TQFile f; + TQString folder("PegasusMail-Import/"), s(file), seperate; + TQByteArray line(MAX_LINE); + int n = 0, l = 0; + + /** Get the folder name */ + s.replace( TQRegExp("mbx$"), "pmg"); + s.replace( TQRegExp("MBX$"), "PMG"); + f.setName(s); + if (! f.open( IO_ReadOnly ) ) { + inf->alert( i18n("Unable to open %1, skipping").arg( s ) ); + return; + } else { + f.readBlock((char *) &pmg_head, sizeof(pmg_head)); + f.close(); + + if(folderParsed) + folder.append(getFolderName((TQString)pmg_head.id)); + else + folder.append(pmg_head.folder); + + inf->setTo(folder); + inf->setTo(folder); + } + + /** Read in the mbox */ + f.setName(file); + if (! f.open( IO_ReadOnly ) ) { + inf->alert( i18n("Unable to open %1, skipping").arg( s ) ); + } else { + inf->addLog(i18n("Importing %1").arg("../" + TQString(pmg_head.folder))); + l = f.readLine( line.data(),MAX_LINE); // read the first line which is unneeded + while ( ! f.atEnd() ) { + KTempFile tempfile; + + // we lost the last line, which is the first line of the new message in + // this lopp, but this is ok, because this is the seperate line with + // "From ???@???" and we can forget them + while ( ! f.atEnd() && (l = f.readLine(line.data(),MAX_LINE)) && ((seperate = line.data()).left(5) != "From ")) { + tempfile.file()->writeBlock(line.data(), l); + if (inf->shouldTerminate()){ + tempfile.close(); + tempfile.unlink(); + return; + } + } + tempfile.close(); + if(inf->removeDupMsg) + addMessage( inf, folder, tempfile.name() ); + else + addMessage_fastImport( inf, folder, tempfile.name() ); + tempfile.unlink(); + + n++; + inf->setCurrent(i18n("Message %1").arg(n)); + inf->setCurrent( (int) ( ( (float) f.at() / f.size() ) * 100 ) ); + } + } + f.close(); +} + +/** Parse the information about folderstructure to folderMatrix */ +bool FilterPMail::parseFolderMatrix() +{ + kdDebug() << "Start parsing the foldermatrix." << endl; + inf->addLog(i18n("Parsing the folder structure...")); + + TQFile hierarch(chosenDir + "/hierarch.pm"); + if (! hierarch.open( IO_ReadOnly ) ) { + inf->alert( i18n("Unable to open %1, skipping").arg( chosenDir + "hierarch.pm" ) ); + return false; + } else { + TQStringList tmpList; + TQString tmpRead; + while ( !hierarch.atEnd() && hierarch.readLine(tmpRead,100)) { + TQString tmpArray[5]; + tmpRead.remove(tmpRead.length() -2,2); + TQStringList tmpList = TQStringList::split(",", tmpRead, false); + int i = 0; + for ( TQStringList::Iterator it = tmpList.begin(); it != tmpList.end(); ++it, i++) { + TQString _tmp = *it; + if(i < 5) tmpArray[i] = _tmp.remove("\""); + else { + hierarch.close(); + return false; + } + } + folderMatrix.append(tmpArray); + } + } + hierarch.close(); + return true; +} + +/** get the foldername for a given file ID from folderMatrix */ +TQString FilterPMail::getFolderName(TQString ID) +{ + bool found = false; + TQString folder; + TQString search = ID; + + while (!found) + { + for ( FolderStructureIterator it = folderMatrix.begin(); it != folderMatrix.end(); it++) { + FolderStructure tmp = *it; + + TQString _ID = tmp[2]; + if(_ID == search) { + TQString _type = tmp[0] + tmp[1]; + if(( _type == "21")) { + found = true; + break; + } + else { + folder.prepend((tmp[4] + "/")); + search = tmp[3]; + } + } + } + } + return folder; +} diff --git a/kmailcvt/filter_pmail.cxx b/kmailcvt/filter_pmail.cxx deleted file mode 100644 index e48e062d..00000000 --- a/kmailcvt/filter_pmail.cxx +++ /dev/null @@ -1,346 +0,0 @@ -/*************************************************************************** - FilterPMail.cxx - Pegasus-Mail import - ------------------- - begin : Sat Jan 6 2001 - copyright : (C) 2001 by Holger Schurig - (C) 2005 by Danny Kukawka - email : holgerschurig@gmx.de - danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "filter_pmail.hxx" - - -FilterPMail::FilterPMail() : - Filter(i18n("Import Folders From Pegasus-Mail"), - "Holger Schurig
( rewritten by Danny Kukawka )", - i18n("

Select the Pegasus-Mail directory on your system (containing *.CNM, *.PMM and *.MBX files). " - "On many systems this is stored in C:\\pmail\\mail or C:\\pmail\\mail\\admin

" - "

Note: Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"PegasusMail-Import\".

")) -{} - -FilterPMail::~FilterPMail() -{ -} - -void FilterPMail::import(FilterInfo *info) -{ - inf = info; - - // Select directory from where I have to import files - KFileDialog *kfd; - kfd = new KFileDialog( TQDir::homeDirPath(), "", 0, "tdefiledialog", true ); - kfd->setMode(KFile::Directory | KFile::LocalOnly); - kfd->exec(); - chosenDir = kfd->selectedFile(); - delete kfd; - - if (chosenDir.isEmpty()) { - info->alert(i18n("No directory selected.")); - return; - } - - // Count total number of files to be processed - info->addLog(i18n("Counting files...")); - dir.setPath (chosenDir); - TQStringList files = dir.entryList("*.[cC][nN][mM]; *.[pP][mM][mM]; *.[mM][bB][xX]", TQDir::Files, TQDir::Name); - totalFiles = files.count(); - currentFile = 0; - kdDebug() << "Count is " << totalFiles << endl; - - if(!(folderParsed = parseFolderMatrix())) { - info->addLog(i18n("Cannot parse the folder structure; continuing import without subfolder support.")); - } - - info->addLog(i18n("Importing new mail files ('.cnm')...")); - processFiles("*.[cC][nN][mM]", &FilterPMail::importNewMessage); - info->addLog(i18n("Importing mail folders ('.pmm')...")); - processFiles("*.[pP][mM][mM]", &FilterPMail::importMailFolder); - info->addLog(i18n("Importing 'UNIX' mail folders ('.mbx')...")); - processFiles("*.[mM][bB][xX]", &FilterPMail::importUnixMailFolder); - - info->addLog( i18n("Finished importing emails from %1").arg( chosenDir )); - info->setCurrent(100); - info->setOverall(100); -} - -/** this looks for all files with the filemask 'mask' and calls the 'workFunc' on each of them */ -void FilterPMail::processFiles(const TQString& mask, void(FilterPMail::* workFunc)(const TQString&) ) -{ - if (inf->shouldTerminate()) return; - - TQStringList files = dir.entryList(mask, TQDir::Files, TQDir::Name); - //kdDebug() << "Mask is " << mask << " count is " << files.count() << endl; - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile ) { - // Notify current file - TQFileInfo mailfileinfo(*mailFile); - inf->setFrom(mailfileinfo.fileName()); - - // Clear the other fields - inf->setTo(TQString()); - inf->setCurrent(TQString()); - inf->setCurrent(-1); - - // call worker function, increase progressbar - (this->*workFunc)(dir.filePath(*mailFile)); - ++currentFile; - inf->setOverall( (int) ((float) currentFile / totalFiles * 100)); - inf->setCurrent( 100 ); - if (inf->shouldTerminate()) return; - } -} - - -/** this function imports one *.CNM message */ -void FilterPMail::importNewMessage(const TQString& file) -{ - TQString destFolder("PegasusMail-Import/New Messages"); - inf->setTo(destFolder); - - /* comment by Danny Kukawka: - * addMessage() == old function, need more time and check for duplicates - * addMessage_fastImport == new function, faster and no check for duplicates - */ - if(inf->removeDupMsg) - addMessage( inf, destFolder, file ); - else - addMessage_fastImport( inf, destFolder, file ); -} - - -/** this function imports one mail folder file (*.PMM) */ -void FilterPMail::importMailFolder(const TQString& file) -{ - // Format of a PMM file: - // First comes a header with 128 bytes. At the beginning is the name of - // the folder. Then there are some unknown bytes (strings). At offset 128 - // the first message starts. - // - // Each message is terminated by a 0x1A byte. The next message follows - // immediately. - // - // The last message is followed by a 0x1A, too. - // - // 000000 6d 61 69 6c 73 65 72 76 65 72 2d 70 72 6f 6a 65 mailserver-proje - // 000010 63 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ct.............. - // 000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - // 000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - // 000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - // 000050 00 00 00 00 00 00 36 30 34 37 35 37 32 45 3a 36 ......6047572E:6 - // 000060 46 34 39 3a 46 4f 4c 30 31 33 35 35 00 00 00 00 F49:FOL01355.... - // 000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - // 000080 52 65 74 75 72 6e 2d 50 61 74 68 3a 20 3c 75 72 Return-Path: alert(i18n("Unable to open %1, skipping").arg(file)); - } else { - // Get folder name - l = f.readBlock((char *) &pmm_head, sizeof(pmm_head)); - TQString folder("PegasusMail-Import/"); - if(folderParsed) - folder.append(getFolderName((TQString)pmm_head.id)); - else - folder.append(pmm_head.folder); - inf->setTo(folder); - inf->addLog(i18n("Importing %1").arg("../" + TQString(pmm_head.folder))); - - TQByteArray input(MAX_LINE); - bool first_msg = true; - - while (!f.atEnd()) { - KTempFile tempfile; - inf->setCurrent( (int) ( ( (float) f.at() / f.size() ) * 100 ) ); - - if(!first_msg) { - // set the filepos back to last line minus the seperate char (0x1a) - f.at(f.at() - l + 1); - } - - // no problem to loose the last line in file. This only contains a seperate char - while ( ! f.atEnd() && (l = f.readLine(input.data(),MAX_LINE))) { - if (inf->shouldTerminate()){ - tempfile.close(); - tempfile.unlink(); - return; - } - if(input[0] == 0x1a ) { - break; - } else { - tempfile.file()->writeBlock( input, l ); - } - } - tempfile.close(); - - if(inf->removeDupMsg) - addMessage( inf, folder, tempfile.name() ); - else - addMessage_fastImport( inf, folder, tempfile.name() ); - - first_msg = false; - tempfile.unlink(); - } - } - f.close(); -} - - -/** imports a 'unix' format mail folder (*.MBX) */ -void FilterPMail::importUnixMailFolder(const TQString& file) -{ - struct { - char folder[58]; - char id[31]; - } pmg_head; - - TQFile f; - TQString folder("PegasusMail-Import/"), s(file), seperate; - TQByteArray line(MAX_LINE); - int n = 0, l = 0; - - /** Get the folder name */ - s.replace( TQRegExp("mbx$"), "pmg"); - s.replace( TQRegExp("MBX$"), "PMG"); - f.setName(s); - if (! f.open( IO_ReadOnly ) ) { - inf->alert( i18n("Unable to open %1, skipping").arg( s ) ); - return; - } else { - f.readBlock((char *) &pmg_head, sizeof(pmg_head)); - f.close(); - - if(folderParsed) - folder.append(getFolderName((TQString)pmg_head.id)); - else - folder.append(pmg_head.folder); - - inf->setTo(folder); - inf->setTo(folder); - } - - /** Read in the mbox */ - f.setName(file); - if (! f.open( IO_ReadOnly ) ) { - inf->alert( i18n("Unable to open %1, skipping").arg( s ) ); - } else { - inf->addLog(i18n("Importing %1").arg("../" + TQString(pmg_head.folder))); - l = f.readLine( line.data(),MAX_LINE); // read the first line which is unneeded - while ( ! f.atEnd() ) { - KTempFile tempfile; - - // we lost the last line, which is the first line of the new message in - // this lopp, but this is ok, because this is the seperate line with - // "From ???@???" and we can forget them - while ( ! f.atEnd() && (l = f.readLine(line.data(),MAX_LINE)) && ((seperate = line.data()).left(5) != "From ")) { - tempfile.file()->writeBlock(line.data(), l); - if (inf->shouldTerminate()){ - tempfile.close(); - tempfile.unlink(); - return; - } - } - tempfile.close(); - if(inf->removeDupMsg) - addMessage( inf, folder, tempfile.name() ); - else - addMessage_fastImport( inf, folder, tempfile.name() ); - tempfile.unlink(); - - n++; - inf->setCurrent(i18n("Message %1").arg(n)); - inf->setCurrent( (int) ( ( (float) f.at() / f.size() ) * 100 ) ); - } - } - f.close(); -} - -/** Parse the information about folderstructure to folderMatrix */ -bool FilterPMail::parseFolderMatrix() -{ - kdDebug() << "Start parsing the foldermatrix." << endl; - inf->addLog(i18n("Parsing the folder structure...")); - - TQFile hierarch(chosenDir + "/hierarch.pm"); - if (! hierarch.open( IO_ReadOnly ) ) { - inf->alert( i18n("Unable to open %1, skipping").arg( chosenDir + "hierarch.pm" ) ); - return false; - } else { - TQStringList tmpList; - TQString tmpRead; - while ( !hierarch.atEnd() && hierarch.readLine(tmpRead,100)) { - TQString tmpArray[5]; - tmpRead.remove(tmpRead.length() -2,2); - TQStringList tmpList = TQStringList::split(",", tmpRead, false); - int i = 0; - for ( TQStringList::Iterator it = tmpList.begin(); it != tmpList.end(); ++it, i++) { - TQString _tmp = *it; - if(i < 5) tmpArray[i] = _tmp.remove("\""); - else { - hierarch.close(); - return false; - } - } - folderMatrix.append(tmpArray); - } - } - hierarch.close(); - return true; -} - -/** get the foldername for a given file ID from folderMatrix */ -TQString FilterPMail::getFolderName(TQString ID) -{ - bool found = false; - TQString folder; - TQString search = ID; - - while (!found) - { - for ( FolderStructureIterator it = folderMatrix.begin(); it != folderMatrix.end(); it++) { - FolderStructure tmp = *it; - - TQString _ID = tmp[2]; - if(_ID == search) { - TQString _type = tmp[0] + tmp[1]; - if(( _type == "21")) { - found = true; - break; - } - else { - folder.prepend((tmp[4] + "/")); - search = tmp[3]; - } - } - } - } - return folder; -} diff --git a/kmailcvt/filter_pmail.h b/kmailcvt/filter_pmail.h new file mode 100644 index 00000000..07f62a36 --- /dev/null +++ b/kmailcvt/filter_pmail.h @@ -0,0 +1,76 @@ +/*************************************************************************** + FilterPMail.h - Pegasus-Mail import + ------------------- + begin : Sat Jan 6 2001 + copyright : (C) 2001 by Holger Schurig + email : holgerschurig@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_PMAIL_H +#define FILTER_PMAIL_H + +#include +#include + +#include "filters.h" + +class FilterPMail : public Filter +{ +public: + FilterPMail(); + ~FilterPMail(); + + void import(FilterInfo *info); + +protected: + /** this looks for all files with the filemask 'mask' and calls the 'workFunc' on each of them */ + void processFiles(const TQString& mask, void(FilterPMail::* workFunc)(const TQString&) ); + /** this function imports one *.CNM message */ + void importNewMessage(const TQString& file); + /** this function imports one mail folder file (*.PMM) */ + void importMailFolder(const TQString& file); + /** imports a 'unix' format mail folder (*.MBX) */ + void importUnixMailFolder(const TQString& file); + /** this function recreate the folder structure */ + bool parseFolderMatrix(); + /** this function parse the folder structure */ + TQString getFolderName(TQString ID); + +private: + /** the working directory */ + TQDir dir; + /** pointer to the info */ + FilterInfo * inf; + + /** Folder structure here has 5 entries. */ + typedef FolderStructureBase<5> FolderStructure; + /** List with the folder matrix, which contains following strings: + 1. type (2 for root-folder, 1 for folder, 0 for mailarchiv) + 2. type (1 for root-folder, 3 for folder, 0 for mailarchiv) + 3. "ID:flag:filename" of folder/archiv + 4. "ID:name" of parent folder + 5. name of folder/archiv + */ + TQValueList folderMatrix; + typedef TQValueList::Iterator FolderStructureIterator; + + bool folderParsed; + + TQString chosenDir; + + /** which file (of totalFiles) is now in the work? */ + int currentFile; + /** total number of files that get imported */ + int totalFiles; + +}; +#endif diff --git a/kmailcvt/filter_pmail.hxx b/kmailcvt/filter_pmail.hxx deleted file mode 100644 index 664fdcc1..00000000 --- a/kmailcvt/filter_pmail.hxx +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - FilterPMail.hxx - Pegasus-Mail import - ------------------- - begin : Sat Jan 6 2001 - copyright : (C) 2001 by Holger Schurig - email : holgerschurig@gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_PMAIL_HXX -#define FILTER_PMAIL_HXX - -#include -#include - -#include "filters.hxx" - -class FilterPMail : public Filter -{ -public: - FilterPMail(); - ~FilterPMail(); - - void import(FilterInfo *info); - -protected: - /** this looks for all files with the filemask 'mask' and calls the 'workFunc' on each of them */ - void processFiles(const TQString& mask, void(FilterPMail::* workFunc)(const TQString&) ); - /** this function imports one *.CNM message */ - void importNewMessage(const TQString& file); - /** this function imports one mail folder file (*.PMM) */ - void importMailFolder(const TQString& file); - /** imports a 'unix' format mail folder (*.MBX) */ - void importUnixMailFolder(const TQString& file); - /** this function recreate the folder structure */ - bool parseFolderMatrix(); - /** this function parse the folder structure */ - TQString getFolderName(TQString ID); - -private: - /** the working directory */ - TQDir dir; - /** pointer to the info */ - FilterInfo * inf; - - /** Folder structure here has 5 entries. */ - typedef FolderStructureBase<5> FolderStructure; - /** List with the folder matrix, which contains following strings: - 1. type (2 for root-folder, 1 for folder, 0 for mailarchiv) - 2. type (1 for root-folder, 3 for folder, 0 for mailarchiv) - 3. "ID:flag:filename" of folder/archiv - 4. "ID:name" of parent folder - 5. name of folder/archiv - */ - TQValueList folderMatrix; - typedef TQValueList::Iterator FolderStructureIterator; - - bool folderParsed; - - TQString chosenDir; - - /** which file (of totalFiles) is now in the work? */ - int currentFile; - /** total number of files that get imported */ - int totalFiles; - -}; -#endif diff --git a/kmailcvt/filter_sylpheed.cpp b/kmailcvt/filter_sylpheed.cpp new file mode 100644 index 00000000..e8f4a66a --- /dev/null +++ b/kmailcvt/filter_sylpheed.cpp @@ -0,0 +1,228 @@ +/*************************************************************************** + filter_sylpheed.h - Sylpheed maildir mail import + ------------------- + begin : April 07 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "filter_sylpheed.h" + +#include +#include +#include +#include + +/** Default constructor. */ +FilterSylpheed::FilterSylpheed( void ) : + Filter( i18n( "Import Sylpheed Maildirs and Folder Structure" ), + "Danny Kukawka", + i18n( "

Sylpheed import filter

" + "

Select the base directory of the Sylpheed mailfolder you want to import " + "(usually: ~/Mail ).

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"Sylpheed-Import\" in your local folder.

" + "

This filter also recreates the status of message, e.g. new or forwarded.") ) +{} + +/** Destructor. */ +FilterSylpheed::~FilterSylpheed( void ) +{ +} + +/** Recursive import of Sylpheed maildir. */ +void FilterSylpheed::import( FilterInfo *info ) +{ + + TQString _homeDir = TQDir::homeDirPath(); + + KFileDialog *kfd; + kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); + kfd->setMode( KFile::Directory | KFile::LocalOnly ); + kfd->exec(); + mailDir = kfd->selectedFile(); + delete kfd; + + if ( mailDir.isEmpty() ) { + info->alert( i18n( "No directory selected." ) ); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { + info->addLog( i18n( "No files found for import." ) ); + } else { + info->setOverall(0); + + /** Recursive import of the MailFolders */ + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { + if(info->shouldTerminate()) break; + importDirContents(info, dir.filePath(*filename)); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + } + } + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + count_duplicates = 0; + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterSylpheed::importDirContents( FilterInfo *info, const TQString& dirName) +{ + if(info->shouldTerminate()) return; + + /** Here Import all archives in the current dir */ + importFiles(info, dirName); + + /** If there are subfolders, we import them one by one */ + TQDir subfolders(dirName); + TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + if(info->shouldTerminate()) return; + importDirContents(info, subfolders.filePath(*filename)); + } +} + + +/** + * Import the files within a Folder. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterSylpheed::importFiles( FilterInfo *info, const TQString& dirName) +{ + TQDir dir(dirName); + TQString _path; + bool generatedPath = false; + + TQDict msgflags; + msgflags.setAutoDelete(true); + + TQDir importDir (dirName); + TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); + int currentFile = 1, numFiles = files.size(); + + readMarkFile(info, dir.filePath(".sylpheed_mark"), msgflags); + + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile, ++currentFile) { + if(info->shouldTerminate()) return; + TQString _mfile = *mailFile; + if (!(_mfile.endsWith(".sylpheed_cache") || _mfile.endsWith(".sylpheed_mark") || _mfile.endsWith(".mh_sequences") )) { + if(!generatedPath) { + _path = "Sylpheed-Import/"; + TQString _tmp = dir.filePath(*mailFile); + _tmp = _tmp.remove(_tmp.length() - _mfile.length() -1, _mfile.length()+1); + _path += _tmp.remove( mailDir ,TRUE); + TQString _info = _path; + info->addLog(i18n("Import folder %1...").arg(_info.remove(0,15))); + + info->setFrom(_info); + info->setTo(_path); + generatedPath = true; + } + + TQString flags; + if (msgflags[_mfile]) + flags = msgFlagsToString(*(msgflags[_mfile])); + + if(info->removeDupMsg) { + if(! addMessage( info, _path, dir.filePath(*mailFile), flags )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + info->setCurrent((int) ((float) currentFile / numFiles * 100)); + } else { + if(! addMessage_fastImport( info, _path, dir.filePath(*mailFile), flags )) { + info->addLog( i18n("Could not import %1").arg( *mailFile ) ); + } + info->setCurrent((int) ((float) currentFile / numFiles * 100)); + } + } + } +} + + +void FilterSylpheed::readMarkFile( FilterInfo *info, const TQString &path, TQDict &dict ) +{ + /* Each sylpheed mail directory contains a .sylpheed_mark file which + * contains all the flags for each messages. The layout of this file + * is documented in the source code of sylpheed: in procmsg.h for + * the flag bits, and procmsg.c. + * + * Note that the mark file stores 32 bit unsigned integers in the + * platform's native "endianness". + * + * The mark file starts with a 32 bit unsigned integer with a version + * number. It is then followed by pairs of 32 bit unsigned integers, + * the first one with the message file name (which is a number), + * and the second one with the actual message flags */ + + TQ_UINT32 in, flags; + TQFile file(path); + + if (!file.open(IO_ReadOnly)) + return; + + TQDataStream stream(&file); + + if (Q_BYTE_ORDER == Q_LITTLE_ENDIAN) + stream.setByteOrder(TQDataStream::LittleEndian); + + + + /* Read version; if the value is reasonably too big, we're looking + * at a file created on another platform. I don't have any test + * marks/folders, so just ignoring this case */ + stream >> in; + if (in > (TQ_UINT32) 0xffff) + return; + + while (!stream.atEnd()) { + if(info->shouldTerminate()){ + file.close(); + return; + } + stream >> in; + stream >> flags; + TQString s; + s.setNum((uint) in); + dict.insert(s, new unsigned long(flags)); + } +} + +TQString FilterSylpheed::msgFlagsToString(unsigned long flags) +{ + TQString status; + + /* see sylpheed's procmsg.h */ + if (flags & 1UL) status += 'N'; + if (flags & 2UL) status += 'U'; + if ((flags & 3UL) == 0UL) status += 'R'; + if (flags & 8UL) status += 'D'; + if (flags & 16UL) status += 'A'; + if (flags & 32UL) status += 'F'; + + return status; +} diff --git a/kmailcvt/filter_sylpheed.cxx b/kmailcvt/filter_sylpheed.cxx deleted file mode 100644 index 1fc008d4..00000000 --- a/kmailcvt/filter_sylpheed.cxx +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** - filter_sylpheed.hxx - Sylpheed maildir mail import - ------------------- - begin : April 07 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de -***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "filter_sylpheed.hxx" - -#include -#include -#include -#include - -/** Default constructor. */ -FilterSylpheed::FilterSylpheed( void ) : - Filter( i18n( "Import Sylpheed Maildirs and Folder Structure" ), - "Danny Kukawka", - i18n( "

Sylpheed import filter

" - "

Select the base directory of the Sylpheed mailfolder you want to import " - "(usually: ~/Mail ).

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"Sylpheed-Import\" in your local folder.

" - "

This filter also recreates the status of message, e.g. new or forwarded.") ) -{} - -/** Destructor. */ -FilterSylpheed::~FilterSylpheed( void ) -{ -} - -/** Recursive import of Sylpheed maildir. */ -void FilterSylpheed::import( FilterInfo *info ) -{ - - TQString _homeDir = TQDir::homeDirPath(); - - KFileDialog *kfd; - kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); - kfd->setMode( KFile::Directory | KFile::LocalOnly ); - kfd->exec(); - mailDir = kfd->selectedFile(); - delete kfd; - - if ( mailDir.isEmpty() ) { - info->alert( i18n( "No directory selected." ) ); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { - info->addLog( i18n( "No files found for import." ) ); - } else { - info->setOverall(0); - - /** Recursive import of the MailFolders */ - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { - if(info->shouldTerminate()) break; - importDirContents(info, dir.filePath(*filename)); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - } - } - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - count_duplicates = 0; - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterSylpheed::importDirContents( FilterInfo *info, const TQString& dirName) -{ - if(info->shouldTerminate()) return; - - /** Here Import all archives in the current dir */ - importFiles(info, dirName); - - /** If there are subfolders, we import them one by one */ - TQDir subfolders(dirName); - TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - if(info->shouldTerminate()) return; - importDirContents(info, subfolders.filePath(*filename)); - } -} - - -/** - * Import the files within a Folder. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterSylpheed::importFiles( FilterInfo *info, const TQString& dirName) -{ - TQDir dir(dirName); - TQString _path; - bool generatedPath = false; - - TQDict msgflags; - msgflags.setAutoDelete(true); - - TQDir importDir (dirName); - TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); - int currentFile = 1, numFiles = files.size(); - - readMarkFile(info, dir.filePath(".sylpheed_mark"), msgflags); - - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile, ++currentFile) { - if(info->shouldTerminate()) return; - TQString _mfile = *mailFile; - if (!(_mfile.endsWith(".sylpheed_cache") || _mfile.endsWith(".sylpheed_mark") || _mfile.endsWith(".mh_sequences") )) { - if(!generatedPath) { - _path = "Sylpheed-Import/"; - TQString _tmp = dir.filePath(*mailFile); - _tmp = _tmp.remove(_tmp.length() - _mfile.length() -1, _mfile.length()+1); - _path += _tmp.remove( mailDir ,TRUE); - TQString _info = _path; - info->addLog(i18n("Import folder %1...").arg(_info.remove(0,15))); - - info->setFrom(_info); - info->setTo(_path); - generatedPath = true; - } - - TQString flags; - if (msgflags[_mfile]) - flags = msgFlagsToString(*(msgflags[_mfile])); - - if(info->removeDupMsg) { - if(! addMessage( info, _path, dir.filePath(*mailFile), flags )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - info->setCurrent((int) ((float) currentFile / numFiles * 100)); - } else { - if(! addMessage_fastImport( info, _path, dir.filePath(*mailFile), flags )) { - info->addLog( i18n("Could not import %1").arg( *mailFile ) ); - } - info->setCurrent((int) ((float) currentFile / numFiles * 100)); - } - } - } -} - - -void FilterSylpheed::readMarkFile( FilterInfo *info, const TQString &path, TQDict &dict ) -{ - /* Each sylpheed mail directory contains a .sylpheed_mark file which - * contains all the flags for each messages. The layout of this file - * is documented in the source code of sylpheed: in procmsg.h for - * the flag bits, and procmsg.c. - * - * Note that the mark file stores 32 bit unsigned integers in the - * platform's native "endianness". - * - * The mark file starts with a 32 bit unsigned integer with a version - * number. It is then followed by pairs of 32 bit unsigned integers, - * the first one with the message file name (which is a number), - * and the second one with the actual message flags */ - - TQ_UINT32 in, flags; - TQFile file(path); - - if (!file.open(IO_ReadOnly)) - return; - - TQDataStream stream(&file); - - if (Q_BYTE_ORDER == Q_LITTLE_ENDIAN) - stream.setByteOrder(TQDataStream::LittleEndian); - - - - /* Read version; if the value is reasonably too big, we're looking - * at a file created on another platform. I don't have any test - * marks/folders, so just ignoring this case */ - stream >> in; - if (in > (TQ_UINT32) 0xffff) - return; - - while (!stream.atEnd()) { - if(info->shouldTerminate()){ - file.close(); - return; - } - stream >> in; - stream >> flags; - TQString s; - s.setNum((uint) in); - dict.insert(s, new unsigned long(flags)); - } -} - -TQString FilterSylpheed::msgFlagsToString(unsigned long flags) -{ - TQString status; - - /* see sylpheed's procmsg.h */ - if (flags & 1UL) status += 'N'; - if (flags & 2UL) status += 'U'; - if ((flags & 3UL) == 0UL) status += 'R'; - if (flags & 8UL) status += 'D'; - if (flags & 16UL) status += 'A'; - if (flags & 32UL) status += 'F'; - - return status; -} diff --git a/kmailcvt/filter_sylpheed.h b/kmailcvt/filter_sylpheed.h new file mode 100644 index 00000000..1d92adf0 --- /dev/null +++ b/kmailcvt/filter_sylpheed.h @@ -0,0 +1,47 @@ +/*************************************************************************** + filter_sylpheed.h - Sylpheed maildir mail import + ------------------- + begin : April 07 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef FILTER_SYLPHEED_H +#define FILTER_SYLPHEED_H + +#include + +#include "filters.h" + +/** + * Imports Sylpheed mail folder with maildir format recursively, recreating the folder structure. + * @author Danny Kukawka + */ +class FilterSylpheed : public Filter +{ + +public: + FilterSylpheed(void); + ~FilterSylpheed(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + void importDirContents(FilterInfo*, const TQString&); + void importFiles(FilterInfo*, const TQString&); + + void readMarkFile( FilterInfo*, const TQString&, TQDict&); + TQString msgFlagsToString(unsigned long); +}; + +#endif diff --git a/kmailcvt/filter_sylpheed.hxx b/kmailcvt/filter_sylpheed.hxx deleted file mode 100644 index fcc3af85..00000000 --- a/kmailcvt/filter_sylpheed.hxx +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - filter_sylpheed.hxx - Sylpheed maildir mail import - ------------------- - begin : April 07 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef FILTER_SYLPHEED_HXX -#define FILTER_SYLPHEED_HXX - -#include - -#include "filters.hxx" - -/** - * Imports Sylpheed mail folder with maildir format recursively, recreating the folder structure. - * @author Danny Kukawka - */ -class FilterSylpheed : public Filter -{ - -public: - FilterSylpheed(void); - ~FilterSylpheed(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - void importDirContents(FilterInfo*, const TQString&); - void importFiles(FilterInfo*, const TQString&); - - void readMarkFile( FilterInfo*, const TQString&, TQDict&); - TQString msgFlagsToString(unsigned long); -}; - -#endif diff --git a/kmailcvt/filter_thebat.cpp b/kmailcvt/filter_thebat.cpp new file mode 100644 index 00000000..a255f352 --- /dev/null +++ b/kmailcvt/filter_thebat.cpp @@ -0,0 +1,231 @@ +/*************************************************************************** + filter_thebat.h - TheBat! mail import + ------------------- + begin : April 07 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "filter_thebat.h" + +#include + +#include +#include + +#include +#include +#include + +#include + +/** Default constructor. */ +FilterTheBat::FilterTheBat( void ) : + Filter( i18n( "Import The Bat! Mails and Folder Structure" ), + "Danny Kukawka", + i18n( "

The Bat! import filter

" + "

Select the base directory of the \'The Bat!\' local mailfolder you " + "want to import.

" + "

Note: This filter imports the *.tbb-files from \'The Bat!\' " + "local folder, e.g. from POP accounts, and not from IMAP/DIMAP accounts.

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"TheBat-Import\" in your local account.

" ) ) +{} + +/** Destructor. */ +FilterTheBat::~FilterTheBat( void ) +{ +} + +/** Recursive import of The Bat! maildir. */ +void FilterTheBat::import( FilterInfo *info ) +{ + TQString _homeDir = TQDir::homeDirPath(); + + KFileDialog *kfd; + kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); + kfd->setMode( KFile::Directory | KFile::LocalOnly ); + kfd->exec(); + mailDir = kfd->selectedFile(); + delete kfd; + + if ( mailDir.isEmpty() ) { + info->alert( i18n( "No directory selected." ) ); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { + info->addLog( i18n( "No files found for import." ) ); + } else { + info->setOverall(0); + + /** Recursive import of the MailFolders */ + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { + importDirContents(info, dir.filePath(*filename)); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + if(info->shouldTerminate()) break; + } + } + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + + count_duplicates = 0; + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterTheBat::importDirContents( FilterInfo *info, const TQString& dirName) +{ + if(info->shouldTerminate()) return; + + /** Here Import all archives in the current dir */ + TQDir dir(dirName); + TQDir importDir (dirName); + TQStringList files = importDir.entryList("*.[tT][bB][bB]", TQDir::Files, TQDir::Name); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { + TQString temp_mailfile = *mailFile; + importFiles(info, (dirName + "/" + temp_mailfile)); + if(info->shouldTerminate()) return; + } + + /** If there are subfolders, we import them one by one */ + TQDir subfolders(dirName); + TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + importDirContents(info, subfolders.filePath(*filename)); + if(info->shouldTerminate()) return; + } +} + +/** + * Import the files within a Folder. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + */ +void FilterTheBat::importFiles( FilterInfo *info, const TQString& FileName) +{ + + // Format of a tbb-file from The Bat! 3.x + // ---------------------------------------- + // First comes a header of 3K (3128 byte/ 0x00000c38), which we can forget. + // The byte 3129 is the first character of the first message. + // + // The end of a message is marked trough "! p 0" and 43 following characters. + // (within: "_UB", blanks and some other chars.) Together are 48 characters as + // separator. + // ---------------------------------------- + + long l = 0; + TQByteArray input(50); + TQRegExp regexp("!.p.0"); + TQFile tbb(FileName); + int iFound = 0; + int count = 0; + long endOfEmail = 0; + TQValueList offsets; + + if (!tbb.open(IO_ReadOnly)) { + info->alert(i18n("Unable to open %1, skipping").arg(FileName)); + } else { + // BUILD the index of messages : + // We need this really ugly way, because read with tbb.readLine() + // does not work correct. Maybe in come in a continuous loop !!! + // Reason: + // if you use readLine() to read from a file with binary data + // TQFile::at() and TQFile::atEnd() return wrong value. So we + // never get TQFile::atEnd() == true in some cases. This looks + // like a bug in TQt3 maybe fixed in TQt4. + // + while((l = tbb.readBlock(input.data(),50)) ) { + if(info->shouldTerminate()) { + tbb.close(); + return; + } + TQString _tmp = input.data(); + + if (tbb.atEnd()) + break; + + iFound = _tmp.contains(regexp); + if(!iFound) { + iFound = _tmp.findRev("!"); + if (iFound >= 0 && ((l-iFound) < 5) ) { + int _i = tbb.at(); + tbb.at((_i - iFound)); + } + } else { + ++count; + endOfEmail = (tbb.at() - l + _tmp.find(regexp)); + offsets.append(endOfEmail); + } + } + // info->addLog(i18n("--COUNTED: %1").arg(count)); + + // IMPORT the messages: + if(!offsets.empty() || (offsets.empty() && (tbb.size() > 3128))) { + offsets.append(tbb.size()); + tbb.at(3128); + long lastPos = 3128; + long endPos = 0; + + TQString _path = "TheBat-Import/"; + TQString _tmp = FileName; + _tmp = _tmp.remove(_tmp.length() - 13, 13); + _path += _tmp.remove( mailDir ,TRUE); + TQString _info = _path; + info->addLog(i18n("Import folder %1...").arg(_info.remove(0,14))); + info->setTo(_path); + info->setFrom("../" + _info + "/messages.tbb"); + + for(TQValueList::Iterator it = offsets.begin() ; it != offsets.end() ; ++it) { + if(info->shouldTerminate()) { + tbb.close(); + return; + } + endPos = *it; + TQByteArray input(endPos-lastPos); + tbb.readBlock(input.data(), endPos-lastPos); + + KTempFile tmp; + tmp.file()->writeBlock( input, endPos-lastPos ); + tmp.close(); + + //KMessageBox::warningContinueCancel(info->parent(), ""); + if(info->removeDupMsg) + addMessage( info, _path, tmp.name() ); + else + addMessage_fastImport( info, _path, tmp.name() ); + + tmp.unlink(); + lastPos = endPos + 48; + tbb.at(lastPos); + info->setCurrent( (int) ( ( (float) tbb.at() / tbb.size() ) * 100 )); + } + + } + } + tbb.close(); +} diff --git a/kmailcvt/filter_thebat.cxx b/kmailcvt/filter_thebat.cxx deleted file mode 100644 index eaf16461..00000000 --- a/kmailcvt/filter_thebat.cxx +++ /dev/null @@ -1,231 +0,0 @@ -/*************************************************************************** - filter_thebat.hxx - TheBat! mail import - ------------------- - begin : April 07 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de -***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "filter_thebat.hxx" - -#include - -#include -#include - -#include -#include -#include - -#include - -/** Default constructor. */ -FilterTheBat::FilterTheBat( void ) : - Filter( i18n( "Import The Bat! Mails and Folder Structure" ), - "Danny Kukawka", - i18n( "

The Bat! import filter

" - "

Select the base directory of the \'The Bat!\' local mailfolder you " - "want to import.

" - "

Note: This filter imports the *.tbb-files from \'The Bat!\' " - "local folder, e.g. from POP accounts, and not from IMAP/DIMAP accounts.

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"TheBat-Import\" in your local account.

" ) ) -{} - -/** Destructor. */ -FilterTheBat::~FilterTheBat( void ) -{ -} - -/** Recursive import of The Bat! maildir. */ -void FilterTheBat::import( FilterInfo *info ) -{ - TQString _homeDir = TQDir::homeDirPath(); - - KFileDialog *kfd; - kfd = new KFileDialog( _homeDir, "", 0, "tdefiledialog", true ); - kfd->setMode( KFile::Directory | KFile::LocalOnly ); - kfd->exec(); - mailDir = kfd->selectedFile(); - delete kfd; - - if ( mailDir.isEmpty() ) { - info->alert( i18n( "No directory selected." ) ); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == ( TQDir::homeDirPath() + "/" ) ) { - info->addLog( i18n( "No files found for import." ) ); - } else { - info->setOverall(0); - - /** Recursive import of the MailFolders */ - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { - importDirContents(info, dir.filePath(*filename)); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - if(info->shouldTerminate()) break; - } - } - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - - count_duplicates = 0; - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterTheBat::importDirContents( FilterInfo *info, const TQString& dirName) -{ - if(info->shouldTerminate()) return; - - /** Here Import all archives in the current dir */ - TQDir dir(dirName); - TQDir importDir (dirName); - TQStringList files = importDir.entryList("*.[tT][bB][bB]", TQDir::Files, TQDir::Name); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { - TQString temp_mailfile = *mailFile; - importFiles(info, (dirName + "/" + temp_mailfile)); - if(info->shouldTerminate()) return; - } - - /** If there are subfolders, we import them one by one */ - TQDir subfolders(dirName); - TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs , TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - importDirContents(info, subfolders.filePath(*filename)); - if(info->shouldTerminate()) return; - } -} - -/** - * Import the files within a Folder. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - */ -void FilterTheBat::importFiles( FilterInfo *info, const TQString& FileName) -{ - - // Format of a tbb-file from The Bat! 3.x - // ---------------------------------------- - // First comes a header of 3K (3128 byte/ 0x00000c38), which we can forget. - // The byte 3129 is the first character of the first message. - // - // The end of a message is marked trough "! p 0" and 43 following characters. - // (within: "_UB", blanks and some other chars.) Together are 48 characters as - // separator. - // ---------------------------------------- - - long l = 0; - TQByteArray input(50); - TQRegExp regexp("!.p.0"); - TQFile tbb(FileName); - int iFound = 0; - int count = 0; - long endOfEmail = 0; - TQValueList offsets; - - if (!tbb.open(IO_ReadOnly)) { - info->alert(i18n("Unable to open %1, skipping").arg(FileName)); - } else { - // BUILD the index of messages : - // We need this really ugly way, because read with tbb.readLine() - // does not work correct. Maybe in come in a continuous loop !!! - // Reason: - // if you use readLine() to read from a file with binary data - // TQFile::at() and TQFile::atEnd() return wrong value. So we - // never get TQFile::atEnd() == true in some cases. This looks - // like a bug in TQt3 maybe fixed in TQt4. - // - while((l = tbb.readBlock(input.data(),50)) ) { - if(info->shouldTerminate()) { - tbb.close(); - return; - } - TQString _tmp = input.data(); - - if (tbb.atEnd()) - break; - - iFound = _tmp.contains(regexp); - if(!iFound) { - iFound = _tmp.findRev("!"); - if (iFound >= 0 && ((l-iFound) < 5) ) { - int _i = tbb.at(); - tbb.at((_i - iFound)); - } - } else { - ++count; - endOfEmail = (tbb.at() - l + _tmp.find(regexp)); - offsets.append(endOfEmail); - } - } - // info->addLog(i18n("--COUNTED: %1").arg(count)); - - // IMPORT the messages: - if(!offsets.empty() || (offsets.empty() && (tbb.size() > 3128))) { - offsets.append(tbb.size()); - tbb.at(3128); - long lastPos = 3128; - long endPos = 0; - - TQString _path = "TheBat-Import/"; - TQString _tmp = FileName; - _tmp = _tmp.remove(_tmp.length() - 13, 13); - _path += _tmp.remove( mailDir ,TRUE); - TQString _info = _path; - info->addLog(i18n("Import folder %1...").arg(_info.remove(0,14))); - info->setTo(_path); - info->setFrom("../" + _info + "/messages.tbb"); - - for(TQValueList::Iterator it = offsets.begin() ; it != offsets.end() ; ++it) { - if(info->shouldTerminate()) { - tbb.close(); - return; - } - endPos = *it; - TQByteArray input(endPos-lastPos); - tbb.readBlock(input.data(), endPos-lastPos); - - KTempFile tmp; - tmp.file()->writeBlock( input, endPos-lastPos ); - tmp.close(); - - //KMessageBox::warningContinueCancel(info->parent(), ""); - if(info->removeDupMsg) - addMessage( info, _path, tmp.name() ); - else - addMessage_fastImport( info, _path, tmp.name() ); - - tmp.unlink(); - lastPos = endPos + 48; - tbb.at(lastPos); - info->setCurrent( (int) ( ( (float) tbb.at() / tbb.size() ) * 100 )); - } - - } - } - tbb.close(); -} diff --git a/kmailcvt/filter_thebat.h b/kmailcvt/filter_thebat.h new file mode 100644 index 00000000..ef69c231 --- /dev/null +++ b/kmailcvt/filter_thebat.h @@ -0,0 +1,42 @@ +/*************************************************************************** + filter_thebat.h - TheBat! mail import + ------------------- + begin : April 07 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef FILTER_THEBAT_H +#define FILTER_THEBAT_H + +#include "filters.h" + +/** + * Imports The Bat! mail folder recursively, recreating the folder structure. + * @author Danny Kukawka + */ +class FilterTheBat : public Filter +{ + +public: + FilterTheBat(void); + ~FilterTheBat(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + void importDirContents(FilterInfo*, const TQString&); + void importFiles(FilterInfo*, const TQString&); +}; + +#endif diff --git a/kmailcvt/filter_thebat.hxx b/kmailcvt/filter_thebat.hxx deleted file mode 100644 index 7d62018d..00000000 --- a/kmailcvt/filter_thebat.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - filter_thebat.hxx - TheBat! mail import - ------------------- - begin : April 07 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef FILTER_THEBAT_HXX -#define FILTER_THEBAT_HXX - -#include "filters.hxx" - -/** - * Imports The Bat! mail folder recursively, recreating the folder structure. - * @author Danny Kukawka - */ -class FilterTheBat : public Filter -{ - -public: - FilterTheBat(void); - ~FilterTheBat(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - void importDirContents(FilterInfo*, const TQString&); - void importFiles(FilterInfo*, const TQString&); -}; - -#endif diff --git a/kmailcvt/filter_thunderbird.cpp b/kmailcvt/filter_thunderbird.cpp new file mode 100644 index 00000000..e5f21d14 --- /dev/null +++ b/kmailcvt/filter_thunderbird.cpp @@ -0,0 +1,234 @@ +/*************************************************************************** + filter_thunderbird.cpp - Thunderbird mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "filter_thunderbird.h" + +#include +#include +#include +#include + + +/** Default constructor. */ +FilterThunderbird::FilterThunderbird(void) : + Filter(i18n("Import Thunderbird/Mozilla Local Mails and Folder Structure"), + "Danny Kukawka", + i18n("

Thunderbird/Mozilla import filter

" + "

Select your base Thunderbird/Mozilla mailfolder" + " (usually ~/.thunderbird/*.default/Mail/Local Folders/).

" + "

Note: Never choose a Folder which does not contain mbox-files (for example," + " a maildir): if you do, you will get many new folders.

" + "

Since it is possible to recreate the folder structure, the folders " + "will be stored under: \"Thunderbird-Import\".

")) +{} + +/** Destructor. */ +FilterThunderbird::~FilterThunderbird(void) +{ +} + +/** Recursive import of Evolution's mboxes. */ +void FilterThunderbird::import(FilterInfo *info) +{ + /** + * We ask the user to choose Evolution's root directory. + * This should be usually ~/.thunderbird/xxxx.default/Mail/Local Folders/ + */ + TQString thunderDir = TQDir::homeDirPath() + "/.thunderbird/"; + TQDir d( thunderDir ); + if ( !d.exists() ) { + thunderDir = TQDir::homeDirPath(); + } + + KFileDialog *kfd; + kfd = new KFileDialog( thunderDir, "", 0, "tdefiledialog", true ); + kfd->setMode(KFile::Directory | KFile::LocalOnly); + kfd->exec(); + mailDir = kfd->selectedFile(); + delete kfd; + + if (mailDir.isEmpty()) { + info->alert(i18n("No directory selected.")); + } + /** + * If the user only select homedir no import needed because + * there should be no files and we surely import wrong files. + */ + else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { + info->addLog(i18n("No files found for import.")); + } else { + info->setOverall(0); + + /** Recursive import of the MailArchives */ + TQDir dir(mailDir); + TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. + int currentDir = 1, numSubDirs = rootSubDirs.size(); + for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { + if(info->shouldTerminate()) break; + importDirContents(info, dir.filePath(*filename), *filename, *filename); + info->setOverall((int) ((float) currentDir / numSubDirs * 100)); + } + + /** import last but not least all archives from the root-dir */ + TQDir importDir (mailDir); + TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { + if(info->shouldTerminate()) break; + TQString temp_mailfile = *mailFile; + if (temp_mailfile.endsWith(".msf") || temp_mailfile.endsWith("msgFilterRules.dat")) {} + else { + info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); + importMBox(info, mailDir + temp_mailfile , temp_mailfile, TQString()); + } + } + + info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); + if(count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); + } + } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + info->setCurrent(100); + info->setOverall(100); +} + +/** + * Import of a directory contents. + * @param info Information storage for the operation. + * @param dirName The name of the directory to import. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. + */ +void FilterThunderbird::importDirContents(FilterInfo *info, const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) +{ + if(info->shouldTerminate()) return; + /** Here Import all archives in the current dir */ + TQDir dir(dirName); + + TQDir importDir (dirName); + TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); + for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { + if(info->shouldTerminate()) break; + TQString temp_mailfile = *mailFile; + if (temp_mailfile.endsWith(".msf") || temp_mailfile.endsWith("msgFilterRules.dat")) {} + else { + info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); + importMBox(info, (dirName + "/" + temp_mailfile) , KMailRootDir, KMailSubDir); + } + } + + /** If there are subfolders, we import them one by one */ + TQDir subfolders(dirName); + TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); + for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { + if(info->shouldTerminate()) break; + TQString kSubDir; + if(!KMailSubDir.isNull()) { + kSubDir = KMailSubDir + "/" + *filename; + } else { + kSubDir = *filename; + } + importDirContents(info, subfolders.filePath(*filename), KMailRootDir, kSubDir); + } +} + +/** + * Import of a MBox file. + * @param info Information storage for the operation. + * @param dirName The MBox's name. + * @param KMailRootDir The directory's root directory in KMail's folder structure. + * @param KMailSubDir The directory's equivalent in KMail's folder structure. * + */ +void FilterThunderbird::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) +{ + TQFile mbox(mboxName); + bool first_msg = true; + if (!mbox.open(IO_ReadOnly)) { + info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); + } else { + TQFileInfo filenameInfo(mboxName); + + info->setCurrent(0); + if( mboxName.length() > 20 ) { + TQString tmp_info = mboxName; + tmp_info = tmp_info.replace( mailDir, "../" ); + if (tmp_info.contains(".sbd")) + tmp_info.remove(".sbd"); + info->setFrom( tmp_info ); + } else + info->setFrom(mboxName); + if(targetDir.contains(".sbd")) { + TQString tmp_info = targetDir; + tmp_info.remove(".sbd"); + info->setTo(tmp_info); + } else + info->setTo(targetDir); + + TQByteArray input(MAX_LINE); + long l = 0; + + while (!mbox.atEnd()) { + KTempFile tmp; + /** @todo check if the file is really a mbox, maybe search for 'from' string at start */ + /* comment by Danny: + * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + TQCString seperate; + + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " + tmp.file()->writeBlock( input, l ); + + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; + + TQString destFolder; + TQString _targetDir = targetDir; + if(!targetDir.isNull()) { + if(_targetDir.contains(".sbd")) + _targetDir.remove(".sbd"); + destFolder += "Thunderbird-Import/" + _targetDir + "/" + filenameInfo.baseName(TRUE);// mboxName; + } else { + destFolder = "Thunderbird-Import/" + rootDir; + if(destFolder.contains(".sbd")) + destFolder.remove(".sbd"); + } + + if(info->removeDupMsg) + addMessage( info, destFolder, tmp.name() ); + else + addMessage_fastImport( info, destFolder, tmp.name() ); + + tmp.unlink(); + int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); + info->setCurrent(currentPercentage); + if (info->shouldTerminate()) { + mbox.close(); + return; + } + } + mbox.close(); + } +} diff --git a/kmailcvt/filter_thunderbird.cxx b/kmailcvt/filter_thunderbird.cxx deleted file mode 100644 index 50f6355f..00000000 --- a/kmailcvt/filter_thunderbird.cxx +++ /dev/null @@ -1,234 +0,0 @@ -/*************************************************************************** - filter_thunderbird.cxx - Thunderbird mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "filter_thunderbird.hxx" - -#include -#include -#include -#include - - -/** Default constructor. */ -FilterThunderbird::FilterThunderbird(void) : - Filter(i18n("Import Thunderbird/Mozilla Local Mails and Folder Structure"), - "Danny Kukawka", - i18n("

Thunderbird/Mozilla import filter

" - "

Select your base Thunderbird/Mozilla mailfolder" - " (usually ~/.thunderbird/*.default/Mail/Local Folders/).

" - "

Note: Never choose a Folder which does not contain mbox-files (for example," - " a maildir): if you do, you will get many new folders.

" - "

Since it is possible to recreate the folder structure, the folders " - "will be stored under: \"Thunderbird-Import\".

")) -{} - -/** Destructor. */ -FilterThunderbird::~FilterThunderbird(void) -{ -} - -/** Recursive import of Evolution's mboxes. */ -void FilterThunderbird::import(FilterInfo *info) -{ - /** - * We ask the user to choose Evolution's root directory. - * This should be usually ~/.thunderbird/xxxx.default/Mail/Local Folders/ - */ - TQString thunderDir = TQDir::homeDirPath() + "/.thunderbird/"; - TQDir d( thunderDir ); - if ( !d.exists() ) { - thunderDir = TQDir::homeDirPath(); - } - - KFileDialog *kfd; - kfd = new KFileDialog( thunderDir, "", 0, "tdefiledialog", true ); - kfd->setMode(KFile::Directory | KFile::LocalOnly); - kfd->exec(); - mailDir = kfd->selectedFile(); - delete kfd; - - if (mailDir.isEmpty()) { - info->alert(i18n("No directory selected.")); - } - /** - * If the user only select homedir no import needed because - * there should be no files and we surely import wrong files. - */ - else if ( mailDir == TQDir::homeDirPath() || mailDir == (TQDir::homeDirPath() + "/")) { - info->addLog(i18n("No files found for import.")); - } else { - info->setOverall(0); - - /** Recursive import of the MailArchives */ - TQDir dir(mailDir); - TQStringList rootSubDirs = dir.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); // Removal of . and .. - int currentDir = 1, numSubDirs = rootSubDirs.size(); - for(TQStringList::Iterator filename = rootSubDirs.begin() ; filename != rootSubDirs.end() ; ++filename, ++currentDir) { - if(info->shouldTerminate()) break; - importDirContents(info, dir.filePath(*filename), *filename, *filename); - info->setOverall((int) ((float) currentDir / numSubDirs * 100)); - } - - /** import last but not least all archives from the root-dir */ - TQDir importDir (mailDir); - TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { - if(info->shouldTerminate()) break; - TQString temp_mailfile = *mailFile; - if (temp_mailfile.endsWith(".msf") || temp_mailfile.endsWith("msgFilterRules.dat")) {} - else { - info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); - importMBox(info, mailDir + temp_mailfile , temp_mailfile, TQString()); - } - } - - info->addLog( i18n("Finished importing emails from %1").arg( mailDir )); - if(count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported", "%n duplicate messages not imported", count_duplicates)); - } - } - if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); - info->setCurrent(100); - info->setOverall(100); -} - -/** - * Import of a directory contents. - * @param info Information storage for the operation. - * @param dirName The name of the directory to import. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's direct ancestor in KMail's folder structure. - */ -void FilterThunderbird::importDirContents(FilterInfo *info, const TQString& dirName, const TQString& KMailRootDir, const TQString& KMailSubDir) -{ - if(info->shouldTerminate()) return; - /** Here Import all archives in the current dir */ - TQDir dir(dirName); - - TQDir importDir (dirName); - TQStringList files = importDir.entryList("[^\\.]*", TQDir::Files, TQDir::Name); - for ( TQStringList::Iterator mailFile = files.begin(); mailFile != files.end(); ++mailFile) { - if(info->shouldTerminate()) break; - TQString temp_mailfile = *mailFile; - if (temp_mailfile.endsWith(".msf") || temp_mailfile.endsWith("msgFilterRules.dat")) {} - else { - info->addLog( i18n("Start import file %1...").arg( temp_mailfile ) ); - importMBox(info, (dirName + "/" + temp_mailfile) , KMailRootDir, KMailSubDir); - } - } - - /** If there are subfolders, we import them one by one */ - TQDir subfolders(dirName); - TQStringList subDirs = subfolders.entryList("[^\\.]*", TQDir::Dirs, TQDir::Name); - for(TQStringList::Iterator filename = subDirs.begin() ; filename != subDirs.end() ; ++filename) { - if(info->shouldTerminate()) break; - TQString kSubDir; - if(!KMailSubDir.isNull()) { - kSubDir = KMailSubDir + "/" + *filename; - } else { - kSubDir = *filename; - } - importDirContents(info, subfolders.filePath(*filename), KMailRootDir, kSubDir); - } -} - -/** - * Import of a MBox file. - * @param info Information storage for the operation. - * @param dirName The MBox's name. - * @param KMailRootDir The directory's root directory in KMail's folder structure. - * @param KMailSubDir The directory's equivalent in KMail's folder structure. * - */ -void FilterThunderbird::importMBox(FilterInfo *info, const TQString& mboxName, const TQString& rootDir, const TQString& targetDir) -{ - TQFile mbox(mboxName); - bool first_msg = true; - if (!mbox.open(IO_ReadOnly)) { - info->alert(i18n("Unable to open %1, skipping").arg(mboxName)); - } else { - TQFileInfo filenameInfo(mboxName); - - info->setCurrent(0); - if( mboxName.length() > 20 ) { - TQString tmp_info = mboxName; - tmp_info = tmp_info.replace( mailDir, "../" ); - if (tmp_info.contains(".sbd")) - tmp_info.remove(".sbd"); - info->setFrom( tmp_info ); - } else - info->setFrom(mboxName); - if(targetDir.contains(".sbd")) { - TQString tmp_info = targetDir; - tmp_info.remove(".sbd"); - info->setTo(tmp_info); - } else - info->setTo(targetDir); - - TQByteArray input(MAX_LINE); - long l = 0; - - while (!mbox.atEnd()) { - KTempFile tmp; - /** @todo check if the file is really a mbox, maybe search for 'from' string at start */ - /* comment by Danny: - * Don't use TQTextStream to read from mbox, etter use TQDataStream. TQTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the TQTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - TQCString seperate; - - if(!first_msg) - tmp.file()->writeBlock( input, l ); - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; - - TQString destFolder; - TQString _targetDir = targetDir; - if(!targetDir.isNull()) { - if(_targetDir.contains(".sbd")) - _targetDir.remove(".sbd"); - destFolder += "Thunderbird-Import/" + _targetDir + "/" + filenameInfo.baseName(TRUE);// mboxName; - } else { - destFolder = "Thunderbird-Import/" + rootDir; - if(destFolder.contains(".sbd")) - destFolder.remove(".sbd"); - } - - if(info->removeDupMsg) - addMessage( info, destFolder, tmp.name() ); - else - addMessage_fastImport( info, destFolder, tmp.name() ); - - tmp.unlink(); - int currentPercentage = (int) (((float) mbox.at() / filenameInfo.size()) * 100); - info->setCurrent(currentPercentage); - if (info->shouldTerminate()) { - mbox.close(); - return; - } - } - mbox.close(); - } -} diff --git a/kmailcvt/filter_thunderbird.h b/kmailcvt/filter_thunderbird.h new file mode 100644 index 00000000..333e2380 --- /dev/null +++ b/kmailcvt/filter_thunderbird.h @@ -0,0 +1,42 @@ +/*************************************************************************** + filter_thunderbird.h - Thunderbird mail import + ------------------- + begin : Januar 26 2005 + copyright : (C) 2005 by Danny Kukawka + email : danny.kukawka@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTER_THUNDERBIRD_H +#define FILTER_THUNDERBIRD_H + +#include "filters.h" + +/** + * Imports Thinderbird mail folder recursively, keeping the folder structure. + * @author Danny Kukawka + */ +class FilterThunderbird : public Filter +{ +public: + FilterThunderbird(void); + ~FilterThunderbird(void); + + void import(FilterInfo *info); + +private: + TQString mailDir; + + void importDirContents(FilterInfo*, const TQString&, const TQString&, const TQString&); + void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); +}; + +#endif diff --git a/kmailcvt/filter_thunderbird.hxx b/kmailcvt/filter_thunderbird.hxx deleted file mode 100644 index d3bcd7f9..00000000 --- a/kmailcvt/filter_thunderbird.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - filter_thunderbird.hxx - Thunderbird mail import - ------------------- - begin : Januar 26 2005 - copyright : (C) 2005 by Danny Kukawka - email : danny.kukawka@web.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef FILTER_THUNDERBIRD_HXX -#define FILTER_THUNDERBIRD_HXX - -#include "filters.hxx" - -/** - * Imports Thinderbird mail folder recursively, keeping the folder structure. - * @author Danny Kukawka - */ -class FilterThunderbird : public Filter -{ -public: - FilterThunderbird(void); - ~FilterThunderbird(void); - - void import(FilterInfo *info); - -private: - TQString mailDir; - - void importDirContents(FilterInfo*, const TQString&, const TQString&, const TQString&); - void importMBox(FilterInfo*, const TQString&, const TQString&, const TQString&); -}; - -#endif diff --git a/kmailcvt/filters.cpp b/kmailcvt/filters.cpp new file mode 100644 index 00000000..2c43ff43 --- /dev/null +++ b/kmailcvt/filters.cpp @@ -0,0 +1,216 @@ +/*************************************************************************** + filters.cpp - description + ------------------- + begin : Fri Jun 30 2000 + copyright : (C) 2000 by Hans Dijkema + email : kmailcvt@hum.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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "filters.h" +#include "kmailcvt.h" + + +////////////////////////////////////////////////////////////////////////////////// +// +// The API to the kmailcvt dialog --> Gives the import filter access to +// put information on the dialog. +// +////////////////////////////////////////////////////////////////////////////////// + +bool FilterInfo::s_terminateASAP = false; + +FilterInfo::FilterInfo( KImportPageDlg* dlg, TQWidget* parent , bool _removeDupMsg) + : m_dlg( dlg ), + m_parent( parent ) +{ + removeDupMsg = _removeDupMsg; + s_terminateASAP = false; +} + +FilterInfo::~FilterInfo() +{ +} + +void FilterInfo::setStatusMsg( const TQString& status ) +{ + m_dlg->_texStatus->setText( status ); +} + +void FilterInfo::setFrom( const TQString& from ) +{ + m_dlg->_from->setText( from ); +} + +void FilterInfo::setTo( const TQString& to ) +{ + m_dlg->_to->setText( to ); +} + +void FilterInfo::setCurrent( const TQString& current ) +{ + m_dlg->_current->setText( current ); + kapp->processEvents(); +} + +void FilterInfo::setCurrent( int percent ) +{ + m_dlg->_done_current->setProgress( percent ); + kapp->processEvents(); // Be careful - back & finish buttons disabled, so only user event that can happen is cancel/close button +} + +void FilterInfo::setOverall( int percent ) +{ + m_dlg->_done_overall->setProgress( percent ); +} + +void FilterInfo::addLog( const TQString& log ) +{ + m_dlg->_log->insertItem( log ); + m_dlg->_log->setCurrentItem( m_dlg->_log->count() - 1 ); + m_dlg->_log->centerCurrentItem(); + kapp->processEvents(); +} + +void FilterInfo::clear() +{ + m_dlg->_log->clear(); + setCurrent(); + setOverall(); + setCurrent( TQString() ); + setFrom( TQString() ); + setTo( TQString() ); +} + +void FilterInfo::alert( const TQString& message ) +{ + KMessageBox::information( m_parent, message ); +} + +void FilterInfo::terminateASAP() +{ + s_terminateASAP = true; +} + +bool FilterInfo::shouldTerminate() +{ + return s_terminateASAP; +} + +////////////////////////////////////////////////////////////////////////////////// +// +// The generic filter class +// +////////////////////////////////////////////////////////////////////////////////// + + +Filter::Filter( const TQString& name, const TQString& author, + const TQString& info ) + : m_name( name ), + m_author( author ), + m_info( info ) +{ + //public + count_duplicates = 0; +} + +bool Filter::addMessage( FilterInfo* info, const TQString& folderName, + const TQString& msgPath, const TQString & msgStatusFlags) +{ + KURL msgURL; + msgURL.setPath( msgPath ); + + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) + TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started + + DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", folderName, msgURL, msgStatusFlags ); + + if ( !reply.isValid() ) + { + info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " + "Make sure kmail is installed." ) ); + return false; + } + + switch ( int( reply ) ) + { + case -1: + info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) ); + return false; + case -2: + info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) ); + return false; + case -4: + count_duplicates++; + return false; + case 0: + info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) ); + return false; + } + return true; +} + +bool Filter::addMessage_fastImport( FilterInfo* info, const TQString& folderName, + const TQString& msgPath, const TQString& msgStatusFlags ) +{ + KURL msgURL; + msgURL.setPath( msgPath ); + + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) + TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started + + DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage_fastImport", folderName, msgURL, msgStatusFlags ); + if ( !reply.isValid() ) + { + info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " + "Make sure kmail is installed." ) ); + return false; + } + + switch ( int( reply ) ) + { + case -1: + info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) ); + return false; + case -2: + info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) ); + return false; + case 0: + info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) ); + return false; + } + return true; +} + +void Filter::showKMailImportArchiveDialog( FilterInfo* info ) +{ + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) + TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started + + DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "showImportArchiveDialog" ); + if ( !reply.isValid() ) + { + info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " + "Make sure kmail is installed." ) ); + } +} + +bool Filter::needsSecondPage() +{ + return true; +} diff --git a/kmailcvt/filters.cxx b/kmailcvt/filters.cxx deleted file mode 100644 index 6aeb4fde..00000000 --- a/kmailcvt/filters.cxx +++ /dev/null @@ -1,216 +0,0 @@ -/*************************************************************************** - filters.cxx - description - ------------------- - begin : Fri Jun 30 2000 - copyright : (C) 2000 by Hans Dijkema - email : kmailcvt@hum.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 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "filters.hxx" -#include "kmailcvt.h" - - -////////////////////////////////////////////////////////////////////////////////// -// -// The API to the kmailcvt dialog --> Gives the import filter access to -// put information on the dialog. -// -////////////////////////////////////////////////////////////////////////////////// - -bool FilterInfo::s_terminateASAP = false; - -FilterInfo::FilterInfo( KImportPageDlg* dlg, TQWidget* parent , bool _removeDupMsg) - : m_dlg( dlg ), - m_parent( parent ) -{ - removeDupMsg = _removeDupMsg; - s_terminateASAP = false; -} - -FilterInfo::~FilterInfo() -{ -} - -void FilterInfo::setStatusMsg( const TQString& status ) -{ - m_dlg->_texStatus->setText( status ); -} - -void FilterInfo::setFrom( const TQString& from ) -{ - m_dlg->_from->setText( from ); -} - -void FilterInfo::setTo( const TQString& to ) -{ - m_dlg->_to->setText( to ); -} - -void FilterInfo::setCurrent( const TQString& current ) -{ - m_dlg->_current->setText( current ); - kapp->processEvents(); -} - -void FilterInfo::setCurrent( int percent ) -{ - m_dlg->_done_current->setProgress( percent ); - kapp->processEvents(); // Be careful - back & finish buttons disabled, so only user event that can happen is cancel/close button -} - -void FilterInfo::setOverall( int percent ) -{ - m_dlg->_done_overall->setProgress( percent ); -} - -void FilterInfo::addLog( const TQString& log ) -{ - m_dlg->_log->insertItem( log ); - m_dlg->_log->setCurrentItem( m_dlg->_log->count() - 1 ); - m_dlg->_log->centerCurrentItem(); - kapp->processEvents(); -} - -void FilterInfo::clear() -{ - m_dlg->_log->clear(); - setCurrent(); - setOverall(); - setCurrent( TQString() ); - setFrom( TQString() ); - setTo( TQString() ); -} - -void FilterInfo::alert( const TQString& message ) -{ - KMessageBox::information( m_parent, message ); -} - -void FilterInfo::terminateASAP() -{ - s_terminateASAP = true; -} - -bool FilterInfo::shouldTerminate() -{ - return s_terminateASAP; -} - -////////////////////////////////////////////////////////////////////////////////// -// -// The generic filter class -// -////////////////////////////////////////////////////////////////////////////////// - - -Filter::Filter( const TQString& name, const TQString& author, - const TQString& info ) - : m_name( name ), - m_author( author ), - m_info( info ) -{ - //public - count_duplicates = 0; -} - -bool Filter::addMessage( FilterInfo* info, const TQString& folderName, - const TQString& msgPath, const TQString & msgStatusFlags) -{ - KURL msgURL; - msgURL.setPath( msgPath ); - - if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) - TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started - - DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", folderName, msgURL, msgStatusFlags ); - - if ( !reply.isValid() ) - { - info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " - "Make sure kmail is installed." ) ); - return false; - } - - switch ( int( reply ) ) - { - case -1: - info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) ); - return false; - case -2: - info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) ); - return false; - case -4: - count_duplicates++; - return false; - case 0: - info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) ); - return false; - } - return true; -} - -bool Filter::addMessage_fastImport( FilterInfo* info, const TQString& folderName, - const TQString& msgPath, const TQString& msgStatusFlags ) -{ - KURL msgURL; - msgURL.setPath( msgPath ); - - if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) - TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started - - DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage_fastImport", folderName, msgURL, msgStatusFlags ); - if ( !reply.isValid() ) - { - info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " - "Make sure kmail is installed." ) ); - return false; - } - - switch ( int( reply ) ) - { - case -1: - info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) ); - return false; - case -2: - info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) ); - return false; - case 0: - info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) ); - return false; - } - return true; -} - -void Filter::showKMailImportArchiveDialog( FilterInfo* info ) -{ - if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) - TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started - - DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "showImportArchiveDialog" ); - if ( !reply.isValid() ) - { - info->alert( i18n( "Fatal: Unable to start KMail for DCOP communication. " - "Make sure kmail is installed." ) ); - } -} - -bool Filter::needsSecondPage() -{ - return true; -} diff --git a/kmailcvt/filters.h b/kmailcvt/filters.h new file mode 100644 index 00000000..f9261bcb --- /dev/null +++ b/kmailcvt/filters.h @@ -0,0 +1,145 @@ +/*************************************************************************** + filters.h - description + ------------------- + begin : Fri Jun 30 2000 + copyright : (C) 2000 by Hans Dijkema + email : kmailcvt@hum.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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FILTERS_H +#define FILTERS_H + +#ifndef MAX_LINE +#define MAX_LINE 4096 +#endif + +#include +#include +#include +#include +#include + +#include "kimportpagedlg.h" + +class FilterInfo +{ + public: + FilterInfo(KImportPageDlg *dlg, TQWidget *parent, bool _removeDupMsg); + ~FilterInfo(); + + void setStatusMsg( const TQString& status ); + void setFrom( const TQString& from ); + void setTo( const TQString& to ); + void setCurrent( const TQString& current ); + void setCurrent( int percent = 0 ); + void setOverall( int percent = 0 ); + void addLog( const TQString& log ); + void clear(); + void alert( const TQString& message ); + static void terminateASAP(); + bool shouldTerminate(); + + TQWidget *parent() { return m_parent; } + bool removeDupMsg; + + private: + KImportPageDlg *m_dlg; + TQWidget *m_parent; + static bool s_terminateASAP; +}; + +class Filter +{ + public: + Filter( const TQString& name, const TQString& author, + const TQString& info = TQString() ); + virtual ~Filter() {} + virtual void import( FilterInfo* ) = 0; + TQString author() const { return m_author; } + TQString name() const { return m_name; } + TQString info() const { return m_info; } + + virtual bool needsSecondPage(); + + int count_duplicates; //to count all duplicate messages + + protected: + void showKMailImportArchiveDialog( FilterInfo* info ); + bool addMessage( FilterInfo* info, + const TQString& folder, + const TQString& msgFile, + const TQString& msgStatusFlags = TQString()); + bool addMessage_fastImport( FilterInfo* info, + const TQString& folder, + const TQString& msgFile, + const TQString& msgStatusFlags = TQString()); + private: + TQString m_name; + TQString m_author; + TQString m_info; +}; + + + +/** +* Glorified TQString[N] for (a) understandability (b) older gcc compatibility. +*/ +template class FolderStructureBase +{ +public: + typedef TQString NString[size]; + /** Constructor. Need a default constructor for TQValueList. */ + FolderStructureBase() {} ; + + /** Constructor. Turn N TQStrings into a folder structure + * description. + */ + FolderStructureBase(const NString &s) + { + for(unsigned int i=0; i -#include -#include -#include -#include - -#include "kimportpagedlg.h" - -class FilterInfo -{ - public: - FilterInfo(KImportPageDlg *dlg, TQWidget *parent, bool _removeDupMsg); - ~FilterInfo(); - - void setStatusMsg( const TQString& status ); - void setFrom( const TQString& from ); - void setTo( const TQString& to ); - void setCurrent( const TQString& current ); - void setCurrent( int percent = 0 ); - void setOverall( int percent = 0 ); - void addLog( const TQString& log ); - void clear(); - void alert( const TQString& message ); - static void terminateASAP(); - bool shouldTerminate(); - - TQWidget *parent() { return m_parent; } - bool removeDupMsg; - - private: - KImportPageDlg *m_dlg; - TQWidget *m_parent; - static bool s_terminateASAP; -}; - -class Filter -{ - public: - Filter( const TQString& name, const TQString& author, - const TQString& info = TQString() ); - virtual ~Filter() {} - virtual void import( FilterInfo* ) = 0; - TQString author() const { return m_author; } - TQString name() const { return m_name; } - TQString info() const { return m_info; } - - virtual bool needsSecondPage(); - - int count_duplicates; //to count all duplicate messages - - protected: - void showKMailImportArchiveDialog( FilterInfo* info ); - bool addMessage( FilterInfo* info, - const TQString& folder, - const TQString& msgFile, - const TQString& msgStatusFlags = TQString()); - bool addMessage_fastImport( FilterInfo* info, - const TQString& folder, - const TQString& msgFile, - const TQString& msgStatusFlags = TQString()); - private: - TQString m_name; - TQString m_author; - TQString m_info; -}; - - - -/** -* Glorified TQString[N] for (a) understandability (b) older gcc compatibility. -*/ -template class FolderStructureBase -{ -public: - typedef TQString NString[size]; - /** Constructor. Need a default constructor for TQValueList. */ - FolderStructureBase() {} ; - - /** Constructor. Turn N TQStrings into a folder structure - * description. - */ - FolderStructureBase(const NString &s) - { - for(unsigned int i=0; i #include #include -#include "filters.hxx" +#include "filters.h" KMailCVT::KMailCVT(TQWidget *parent, const char *name) : KWizard(parent, name, true) { diff --git a/kmailcvt/kselfilterpage.cpp b/kmailcvt/kselfilterpage.cpp index 7d97fcfd..118124f7 100644 --- a/kmailcvt/kselfilterpage.cpp +++ b/kmailcvt/kselfilterpage.cpp @@ -19,23 +19,23 @@ #include #include #include -#include "filters.hxx" +#include "filters.h" -#include "filter_mbox.hxx" -#include "filter_oe.hxx" -#include "filter_outlook.hxx" -#include "filter_pmail.hxx" -#include "filter_plain.hxx" -#include "filter_evolution.hxx" -#include "filter_mailapp.hxx" -#include "filter_evolution_v2.hxx" -#include "filter_opera.hxx" -#include "filter_thunderbird.hxx" -#include "filter_kmail_maildir.hxx" -#include "filter_kmail_archive.hxx" -#include "filter_sylpheed.hxx" -#include "filter_thebat.hxx" -#include "filter_lnotes.hxx" +#include "filter_mbox.h" +#include "filter_oe.h" +#include "filter_outlook.h" +#include "filter_pmail.h" +#include "filter_plain.h" +#include "filter_evolution.h" +#include "filter_mailapp.h" +#include "filter_evolution_v2.h" +#include "filter_opera.h" +#include "filter_thunderbird.h" +#include "filter_kmail_maildir.h" +#include "filter_kmail_archive.h" +#include "filter_sylpheed.h" +#include "filter_thebat.h" +#include "filter_lnotes.h" #include "kselfilterpage.h" diff --git a/kode/kwsdl/creator.cpp b/kode/kwsdl/creator.cpp index e31808ad..4564c365 100644 --- a/kode/kwsdl/creator.cpp +++ b/kode/kwsdl/creator.cpp @@ -58,7 +58,7 @@ void Creator::create( const KODE::Class::List &list ) } KODE::AutoMakefile::Target libTarget( "bin_PROGRAMS", "kwsdl" ); - libTarget.setSources( "main.cc " + cppFiles.join( " " ) ); + libTarget.setSources( "main.cpp " + cppFiles.join( " " ) ); libTarget.setLdFlags( "$(all_libraries) $(KDE_RPATH)" ); libTarget.setLdAdd( "-ltdecore -ltdeio" ); diff --git a/kode/kwsdl/tests/google/Makefile.am b/kode/kwsdl/tests/google/Makefile.am index 68f084a3..5c706193 100644 --- a/kode/kwsdl/tests/google/Makefile.am +++ b/kode/kwsdl/tests/google/Makefile.am @@ -3,7 +3,7 @@ METASOURCES = AUTO bin_PROGRAMS = googletest -googletest_SOURCES = main.cc googlesearch.cc transport.cpp resultelementarray.cpp directorycategoryarray.cpp googlesearchresult.cpp directorycategory.cpp resultelement.cpp serializer.cpp googlesearchservice.cpp +googletest_SOURCES = main.cpp googlesearch.cpp transport.cpp resultelementarray.cpp directorycategoryarray.cpp googlesearchresult.cpp directorycategory.cpp resultelement.cpp serializer.cpp googlesearchservice.cpp googletest_LDADD = -ltdecore -ltdeio googletest_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor diff --git a/kode/kwsdl/tests/google/README b/kode/kwsdl/tests/google/README index cfe83159..46ef2ff0 100644 --- a/kode/kwsdl/tests/google/README +++ b/kode/kwsdl/tests/google/README @@ -1,7 +1,7 @@ This application shows how easy it is to use a web service with code, generated by kwsdl_compiler. -Only the files main.cc, googlesearch.cc and googlesearch.hh are +Only the files main.cpp, googlesearch.cpp and googlesearch.h are written manually, all other files were created by kwsdl_compiler -d kwsdl/tests/google/ GoogleSearch.wsdl diff --git a/kode/kwsdl/tests/google/googlesearch.cc b/kode/kwsdl/tests/google/googlesearch.cc deleted file mode 100644 index 690b9a11..00000000 --- a/kode/kwsdl/tests/google/googlesearch.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2005 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ - -#include "googlesearch.hh" -#include "resultelement.h" -#include "resultelementarray.h" - -GoogleSearch::GoogleSearch() - : TQObject( 0, "" ) -{ - connect( &mService, TQT_SIGNAL( doGetCachedPageResponse( TQByteArray* ) ), - this, TQT_SLOT( cachedPageResult( TQByteArray* ) ) ); - connect( &mService, TQT_SIGNAL( doSpellingSuggestionResponse( TQString* ) ), - this, TQT_SLOT( spellingSuggestionResult( TQString* ) ) ); - connect( &mService, TQT_SIGNAL( doGoogleSearchResponse( GoogleSearchResult* ) ), - this, TQT_SLOT( googleSearchResult( GoogleSearchResult* ) ) ); - - mKey = ""; -} - -void GoogleSearch::cachedPage( const TQString &url ) -{ - mService.doGetCachedPage( new TQString( mKey ), new TQString( url ) ); -} - -void GoogleSearch::spellingSuggestion( const TQString &phrase ) -{ - mService.doSpellingSuggestion( new TQString( mKey ), new TQString( phrase ) ); -} - -void GoogleSearch::googleSearch( const TQString &query, int start, int maxResults, bool filter, - const TQString &restrict, bool safeSearch, const TQString &lr, const TQString &ie, - const TQString &oe ) -{ - mService.doGoogleSearch( new TQString( mKey ), new TQString( query ), new int( start ), new int( maxResults ), - new bool( filter ), new TQString( restrict ), new bool( safeSearch ), new TQString( lr ), - new TQString( ie ), new TQString( oe ) ); -} - -void GoogleSearch::cachedPageResult( TQByteArray *array ) -{ - tqDebug( "--------------- Cached Page Results ---------------------" ); - tqDebug( "%s", array->data() ); - tqDebug( "---------------------------------------------------------" ); - - delete array; -} - -void GoogleSearch::spellingSuggestionResult( TQString *word ) -{ - tqDebug( "--------------- Spelling Suggestion ---------------------" ); - tqDebug( "%s", word->latin1() ); - tqDebug( "---------------------------------------------------------" ); - - delete word; -} - -void GoogleSearch::googleSearchResult( GoogleSearchResult *result ) -{ - tqDebug( "--------------------- Search Results ---------------------" ); - ResultElementArray *array = result->resultElements(); - TQPtrList *list = array->items(); - TQPtrListIterator it( *list ); - while ( it.current() != 0 ) { - tqDebug( "%s: %s", it.current()->summary()->latin1(), it.current()->uRL()->latin1() ); - ++it; - } - tqDebug( "---------------------------------------------------------" ); - - delete result; -} - -#include "googlesearch.moc" diff --git a/kode/kwsdl/tests/google/googlesearch.cpp b/kode/kwsdl/tests/google/googlesearch.cpp new file mode 100644 index 00000000..fcea9d75 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearch.cpp @@ -0,0 +1,94 @@ +/* + This file is part of KDE. + + Copyright (c) 2005 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#include "googlesearch.h" +#include "resultelement.h" +#include "resultelementarray.h" + +GoogleSearch::GoogleSearch() + : TQObject( 0, "" ) +{ + connect( &mService, TQT_SIGNAL( doGetCachedPageResponse( TQByteArray* ) ), + this, TQT_SLOT( cachedPageResult( TQByteArray* ) ) ); + connect( &mService, TQT_SIGNAL( doSpellingSuggestionResponse( TQString* ) ), + this, TQT_SLOT( spellingSuggestionResult( TQString* ) ) ); + connect( &mService, TQT_SIGNAL( doGoogleSearchResponse( GoogleSearchResult* ) ), + this, TQT_SLOT( googleSearchResult( GoogleSearchResult* ) ) ); + + mKey = ""; +} + +void GoogleSearch::cachedPage( const TQString &url ) +{ + mService.doGetCachedPage( new TQString( mKey ), new TQString( url ) ); +} + +void GoogleSearch::spellingSuggestion( const TQString &phrase ) +{ + mService.doSpellingSuggestion( new TQString( mKey ), new TQString( phrase ) ); +} + +void GoogleSearch::googleSearch( const TQString &query, int start, int maxResults, bool filter, + const TQString &restrict, bool safeSearch, const TQString &lr, const TQString &ie, + const TQString &oe ) +{ + mService.doGoogleSearch( new TQString( mKey ), new TQString( query ), new int( start ), new int( maxResults ), + new bool( filter ), new TQString( restrict ), new bool( safeSearch ), new TQString( lr ), + new TQString( ie ), new TQString( oe ) ); +} + +void GoogleSearch::cachedPageResult( TQByteArray *array ) +{ + tqDebug( "--------------- Cached Page Results ---------------------" ); + tqDebug( "%s", array->data() ); + tqDebug( "---------------------------------------------------------" ); + + delete array; +} + +void GoogleSearch::spellingSuggestionResult( TQString *word ) +{ + tqDebug( "--------------- Spelling Suggestion ---------------------" ); + tqDebug( "%s", word->latin1() ); + tqDebug( "---------------------------------------------------------" ); + + delete word; +} + +void GoogleSearch::googleSearchResult( GoogleSearchResult *result ) +{ + tqDebug( "--------------------- Search Results ---------------------" ); + ResultElementArray *array = result->resultElements(); + TQPtrList *list = array->items(); + TQPtrListIterator it( *list ); + while ( it.current() != 0 ) { + tqDebug( "%s: %s", it.current()->summary()->latin1(), it.current()->uRL()->latin1() ); + ++it; + } + tqDebug( "---------------------------------------------------------" ); + + delete result; +} + +#include "googlesearch.moc" diff --git a/kode/kwsdl/tests/google/googlesearch.h b/kode/kwsdl/tests/google/googlesearch.h new file mode 100644 index 00000000..b6400616 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearch.h @@ -0,0 +1,61 @@ +/* + This file is part of KDE. + + Copyright (c) 2005 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#ifndef GOOGLESEARCH_H +#define GOOGLESEARCH_H + +#include +#include "googlesearchservice.h" + +class GoogleSearch : public TQObject +{ + Q_OBJECT + TQ_OBJECT + + public: + GoogleSearch(); + + void cachedPage( const TQString &url ); + void spellingSuggestion( const TQString &phrase ); + void googleSearch( const TQString &query, + int start, + int maxResults, + bool filter, + const TQString &restrict, + bool safeSearch, + const TQString &lr, + const TQString &ie, + const TQString &oe ); + + private slots: + void cachedPageResult( TQByteArray* ); + void spellingSuggestionResult( TQString* ); + void googleSearchResult( GoogleSearchResult* ); + + private: + TQString mKey; + GoogleSearchService mService; +}; + +#endif diff --git a/kode/kwsdl/tests/google/googlesearch.hh b/kode/kwsdl/tests/google/googlesearch.hh deleted file mode 100644 index b6400616..00000000 --- a/kode/kwsdl/tests/google/googlesearch.hh +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2005 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ - -#ifndef GOOGLESEARCH_H -#define GOOGLESEARCH_H - -#include -#include "googlesearchservice.h" - -class GoogleSearch : public TQObject -{ - Q_OBJECT - TQ_OBJECT - - public: - GoogleSearch(); - - void cachedPage( const TQString &url ); - void spellingSuggestion( const TQString &phrase ); - void googleSearch( const TQString &query, - int start, - int maxResults, - bool filter, - const TQString &restrict, - bool safeSearch, - const TQString &lr, - const TQString &ie, - const TQString &oe ); - - private slots: - void cachedPageResult( TQByteArray* ); - void spellingSuggestionResult( TQString* ); - void googleSearchResult( GoogleSearchResult* ); - - private: - TQString mKey; - GoogleSearchService mService; -}; - -#endif diff --git a/kode/kwsdl/tests/google/main.cc b/kode/kwsdl/tests/google/main.cc deleted file mode 100644 index 38c64594..00000000 --- a/kode/kwsdl/tests/google/main.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -#include "googlesearch.hh" - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "kgooglesearch", "TDE Google Search", "0.1", "", TDEAboutData::License_GPL ); - aboutData.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - - TDEApplication app( false, false ); - - GoogleSearch search; - - search.googleSearch( "foobar", 0, 10, true, "", false, "", "latin1", "latin1" ); - search.spellingSuggestion( "guugel" ); - - return app.exec(); -} diff --git a/kode/kwsdl/tests/google/main.cpp b/kode/kwsdl/tests/google/main.cpp new file mode 100644 index 00000000..130a9cc6 --- /dev/null +++ b/kode/kwsdl/tests/google/main.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +#include "googlesearch.h" + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "kgooglesearch", "TDE Google Search", "0.1", "", TDEAboutData::License_GPL ); + aboutData.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + + TDEApplication app( false, false ); + + GoogleSearch search; + + search.googleSearch( "foobar", 0, 10, true, "", false, "", "latin1", "latin1" ); + search.spellingSuggestion( "guugel" ); + + return app.exec(); +} diff --git a/mimelib/Changes b/mimelib/Changes index ce961cce..4f1d7467 100644 --- a/mimelib/Changes +++ b/mimelib/Changes @@ -97,7 +97,7 @@ o Added utility functions for doing end-of-line marker conversions: Jan 25, 1997 -o Parsers for entities (entity.cc) and bodies (body.cc) changed to handle +o Parsers for entities (entity.cpp) and bodies (body.cpp) changed to handle CR LF end-of-line (DOS and MIME) in addition to LF end-of-line (UNIX and C). @@ -169,7 +169,7 @@ o Added member function CreateFieldBody() to DwField. o Improvements to the wrapper classes used in the examples. -o New wrapper class MessageWithAttachments, used in Example 5 (exampl05.cc). +o New wrapper class MessageWithAttachments, used in Example 5 (exampl05.cpp). o The documentation now includes a tutorial. diff --git a/tdefile-plugins/palm-databases/tdefile_palm.cpp b/tdefile-plugins/palm-databases/tdefile_palm.cpp index e995b136..e0a4db02 100644 --- a/tdefile-plugins/palm-databases/tdefile_palm.cpp +++ b/tdefile-plugins/palm-databases/tdefile_palm.cpp @@ -115,7 +115,7 @@ bool KPalmPlugin::readInfo( KFileMetaInfo& info, uint /*what*/ ) { // int pi_file_set_info((struct pi_file * pf, struct DBInfo * infop)); //info["tuteTextTechnical"].value("An integer").toInt() -// Do the stuff with low-level functions. See lines 1119-1142 of pi-file.cc for writing, 244-273 for reading. +// Do the stuff with low-level functions. See lines 1119-1142 of pi-file.cpp for writing, 244-273 for reading. }*/ #include "tdefile_palm.moc" diff --git a/tdeioslave/imap4/CMakeLists.txt b/tdeioslave/imap4/CMakeLists.txt index 6316fe32..041aeffc 100644 --- a/tdeioslave/imap4/CMakeLists.txt +++ b/tdeioslave/imap4/CMakeLists.txt @@ -38,9 +38,9 @@ tde_create_translated_desktop( tde_add_kpart( tdeio_imap4 SOURCES - imapcommand.cc imaplist.cc mailaddress.cc mimeheader.cc - rfcdecoder.cc imap4.cc imapinfo.cc imapparser.cc - mailheader.cc mimehdrline.cc mimeio.cc + imapcommand.cpp imaplist.cpp mailaddress.cpp mimeheader.cpp + rfcdecoder.cpp imap4.cpp imapinfo.cpp imapparser.cpp + mailheader.cpp mimehdrline.cpp mimeio.cpp LINK emailfunctions-static kmime-shared tdeio-shared ${SASL_LIBRARY} DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/tdeioslave/imap4/Makefile.am b/tdeioslave/imap4/Makefile.am index f52af2c6..34497bf6 100644 --- a/tdeioslave/imap4/Makefile.am +++ b/tdeioslave/imap4/Makefile.am @@ -7,9 +7,9 @@ INCLUDES= -I$(top_srcdir)/libkmime \ kde_module_LTLIBRARIES = tdeio_imap4.la -tdeio_imap4_la_SOURCES = imapcommand.cc imaplist.cc mailaddress.cc \ - mimeheader.cc rfcdecoder.cc imap4.cc imapinfo.cc imapparser.cc mailheader.cc \ - mimehdrline.cc mimeio.cc +tdeio_imap4_la_SOURCES = imapcommand.cpp imaplist.cpp mailaddress.cpp \ + mimeheader.cpp rfcdecoder.cpp imap4.cpp imapinfo.cpp imapparser.cpp mailheader.cpp \ + mimehdrline.cpp mimeio.cpp tdeio_imap4_la_LIBADD = $(LIB_TDEIO) $(SASL2_LIBS) ../../libkmime/libkmime.la \ ../../libemailfunctions/libemailfunctions.la tdeio_imap4_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) @@ -21,6 +21,6 @@ kdelnk_DATA = imap4.protocol imaps.protocol kdelnkdir = $(kde_servicesdir) messages: - $(XGETTEXT) *.cc -o $(podir)/tdeio_imap4.pot + $(XGETTEXT) *.cpp -o $(podir)/tdeio_imap4.pot include $(top_srcdir)/admin/Doxyfile.am diff --git a/tdeioslave/imap4/imap4.cc b/tdeioslave/imap4/imap4.cc deleted file mode 100644 index 7dea2c5d..00000000 --- a/tdeioslave/imap4/imap4.cc +++ /dev/null @@ -1,2746 +0,0 @@ -/********************************************************************** - * - * imap4.cc - IMAP4rev1 KIOSlave - * Copyright (C) 2001-2002 Michael Haeckel - * Copyright (C) 1999 John Corey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to jcorey@fruity.ath.cx - * - *********************************************************************/ - -/** - * @class IMAP4Protocol - * @note References: - * - RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 - * - RFC 2192 - IMAP URL Scheme - September 1997 - * - RFC 1731 - IMAP Authentication Mechanisms - December 1994 - * (Discusses KERBEROSv4, GSSAPI, and S/Key) - * - RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response - * - September 1997 (CRAM-MD5 authentication method) - * - RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 - * - RFC 2086 - IMAP4 ACL extension - January 1997 - * - http://www.ietf.org/internet-drafts/draft-daboo-imap-annotatemore-05.txt - * IMAP ANNOTATEMORE draft - April 2004. - * - * - * Supported URLs: - * \verbatim -imap://server/ -imap://user:pass@server/ -imap://user;AUTH=method:pass@server/ -imap://server/folder/ - * \endverbatim - * These URLs cause the following actions (in order): - * - Prompt for user/pass, list all folders in home directory - * - Uses LOGIN to log in - * - Uses AUTHENTICATE to log in - * - List messages in folder - * - * @note API notes: - * Not receiving the required write access for a folder means - * ERR_CANNOT_OPEN_FOR_WRITING. - * ERR_DOES_NOT_EXIST is reserved for folders. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "imap4.h" - -#include "rfcdecoder.h" - -#include - -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LIBSASL2 -extern "C" { -#include -} -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tdepimmacros.h" - -#define IMAP_PROTOCOL "imap" -#define IMAP_SSL_PROTOCOL "imaps" -const int ImapPort = 143; -const int ImapsPort = 993; - -using namespace TDEIO; - -extern "C" -{ - void sigalrm_handler (int); - KDE_EXPORT int kdemain (int argc, char **argv); -} - -int -kdemain (int argc, char **argv) -{ - kdDebug(7116) << "IMAP4::kdemain" << endl; - - TDEInstance instance ("tdeio_imap4"); - if (argc != 4) - { - fprintf(stderr, "Usage: tdeio_imap4 protocol domain-socket1 domain-socket2\n"); - ::exit (-1); - } - -#ifdef HAVE_LIBSASL2 - if ( sasl_client_init( NULL ) != SASL_OK ) { - fprintf(stderr, "SASL library initialization failed!\n"); - ::exit (-1); - } -#endif - - //set debug handler - - IMAP4Protocol *slave; - if (strcasecmp (argv[1], IMAP_SSL_PROTOCOL) == 0) - slave = new IMAP4Protocol (argv[2], argv[3], true); - else if (strcasecmp (argv[1], IMAP_PROTOCOL) == 0) - slave = new IMAP4Protocol (argv[2], argv[3], false); - else - abort (); - slave->dispatchLoop (); - delete slave; - -#ifdef HAVE_LIBSASL2 - sasl_done(); -#endif - - return 0; -} - -void -sigchld_handler (int signo) -{ - // A signal handler that calls for example waitpid has to save errno - // before and restore it afterwards. - // (cf. https://www.securecoding.cert.org/confluence/display/cplusplus/ERR32-CPP.+Do+not+rely+on+indeterminate+values+of+errno) - const int save_errno = errno; - int pid, status; - - while (signo == SIGCHLD) - { - pid = waitpid (-1, &status, WNOHANG); - if (pid <= 0) - { - // Reinstall signal handler, since Linux resets to default after - // the signal occurred ( BSD handles it different, but it should do - // no harm ). - signal (SIGCHLD, sigchld_handler); - break; - } - } - - errno = save_errno; -} - -IMAP4Protocol::IMAP4Protocol (const TQCString & pool, const TQCString & app, bool isSSL):TCPSlaveBase ((isSSL ? 993 : 143), - (isSSL ? IMAP_SSL_PROTOCOL : IMAP_PROTOCOL), pool, - app, isSSL), imapParser (), mimeIO (), outputBuffer(outputCache) -{ - outputBufferIndex = 0; - mySSL = isSSL; - readBuffer[0] = 0x00; - relayEnabled = false; - readBufferLen = 0; - cacheOutput = false; - decodeContent = false; - mTimeOfLastNoop = TQDateTime(); -} - -IMAP4Protocol::~IMAP4Protocol () -{ - closeDescriptor(); - kdDebug(7116) << "IMAP4: Finishing" << endl; -} - -void -IMAP4Protocol::get (const KURL & _url) -{ - if (!makeLogin()) return; - kdDebug(7116) << "IMAP4::get - " << _url.prettyURL() << endl; - TQString aBox, aSequence, aType, aSection, aValidity, aDelimiter, aInfo; - enum IMAP_TYPE aEnum = - parseURL (_url, aBox, aSection, aType, aSequence, aValidity, aDelimiter, aInfo); - if (aEnum != ITYPE_ATTACH) - mimeType (getMimeType(aEnum)); - if (aInfo == "DECODE") - decodeContent = true; - - if (aSequence == "0:0" && getState() == ISTATE_SELECT) - { - imapCommand *cmd = doCommand (imapCommand::clientNoop()); - completeQueue.removeRef(cmd); - } - - if (aSequence.isEmpty ()) - { - aSequence = "1:*"; - } - - mProcessedSize = 0; - imapCommand *cmd = NULL; - if (!assureBox (aBox, true)) return; - -#ifdef USE_VALIDITY - if (selectInfo.uidValidityAvailable () && !aValidity.isEmpty () - && selectInfo.uidValidity () != aValidity.toULong ()) - { - // this url is stale - error (ERR_COULD_NOT_READ, _url.prettyURL()); - return; - } - else -#endif - { - // The "section" specified by the application can be: - // * empty (which means body, size and flags) - // * a known keyword, like STRUCTURE, ENVELOPE, HEADER, BODY.PEEK[...] - // (in which case the slave has some logic to add the necessary items) - // * Otherwise, it specifies the exact data items to request. In this case, all - // the logic is in the app. - - TQString aUpper = aSection.upper(); - if (aUpper.find ("STRUCTURE") != -1) - { - aSection = "BODYSTRUCTURE"; - } - else if (aUpper.find ("ENVELOPE") != -1) - { - aSection = "UID RFC822.SIZE FLAGS ENVELOPE"; - if (hasCapability("IMAP4rev1")) { - aSection += " BODY.PEEK[HEADER.FIELDS (REFERENCES)]"; - } else { - // imap4 does not know HEADER.FIELDS - aSection += " RFC822.HEADER.LINES (REFERENCES)"; - } - } - else if (aUpper == "HEADER") - { - aSection = "UID RFC822.HEADER RFC822.SIZE FLAGS"; - } - else if (aUpper.find ("BODY.PEEK[") != -1) - { - if (aUpper.find ("BODY.PEEK[]") != -1) - { - if (!hasCapability("IMAP4rev1")) // imap4 does not know BODY.PEEK[] - aSection.replace("BODY.PEEK[]", "RFC822.PEEK"); - } - aSection.prepend("UID RFC822.SIZE FLAGS "); - } - else if (aSection.isEmpty()) - { - aSection = "UID BODY[] RFC822.SIZE FLAGS"; - } - if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) - { - // write the digest header - cacheOutput = true; - outputLine - ("Content-Type: multipart/digest; boundary=\"IMAPDIGEST\"\r\n", 55); - if (selectInfo.recentAvailable ()) - outputLineStr ("X-Recent: " + - TQString::number(selectInfo.recent ()) + "\r\n"); - if (selectInfo.countAvailable ()) - outputLineStr ("X-Count: " + TQString::number(selectInfo.count ()) + - "\r\n"); - if (selectInfo.unseenAvailable ()) - outputLineStr ("X-Unseen: " + - TQString::number(selectInfo.unseen ()) + "\r\n"); - if (selectInfo.uidValidityAvailable ()) - outputLineStr ("X-uidValidity: " + - TQString::number(selectInfo.uidValidity ()) + - "\r\n"); - if (selectInfo.uidNextAvailable ()) - outputLineStr ("X-UidNext: " + - TQString::number(selectInfo.uidNext ()) + "\r\n"); - if (selectInfo.flagsAvailable ()) - outputLineStr ("X-Flags: " + TQString::number(selectInfo.flags ()) + - "\r\n"); - if (selectInfo.permanentFlagsAvailable ()) - outputLineStr ("X-PermanentFlags: " + - TQString::number(selectInfo.permanentFlags ()) + "\r\n"); - if (selectInfo.readWriteAvailable ()) { - if (selectInfo.readWrite()) { - outputLine ("X-Access: Read/Write\r\n", 22); - } else { - outputLine ("X-Access: Read only\r\n", 21); - } - } - outputLine ("\r\n", 2); - flushOutput(TQString()); - cacheOutput = false; - } - - if (aEnum == ITYPE_MSG || (aEnum == ITYPE_ATTACH && !decodeContent)) - relayEnabled = true; // normal mode, relay data - - if (aSequence != "0:0") - { - TQString contentEncoding; - if (aEnum == ITYPE_ATTACH && decodeContent) - { - // get the MIME header and fill getLastHandled() - TQString mySection = aSection; - mySection.replace("]", ".MIME]"); - cmd = sendCommand (imapCommand::clientFetch (aSequence, mySection)); - do - { - while (!parseLoop ()) ; - } - while (!cmd->isComplete ()); - completeQueue.removeRef (cmd); - // get the content encoding now because getLastHandled will be cleared - if (getLastHandled() && getLastHandled()->getHeader()) - contentEncoding = getLastHandled()->getHeader()->getEncoding(); - - // from here on collect the data - // it is send to the client in flushOutput in one go - // needed to decode the content - cacheOutput = true; - } - - cmd = sendCommand (imapCommand::clientFetch (aSequence, aSection)); - int res; - aUpper = aSection.upper(); - do - { - while (!(res = parseLoop())) ; - if (res == -1) break; - - mailHeader *lastone = 0; - imapCache *cache = getLastHandled (); - if (cache) - lastone = cache->getHeader (); - - if (cmd && !cmd->isComplete ()) - { - if ((aUpper.find ("BODYSTRUCTURE") != -1) - || (aUpper.find ("FLAGS") != -1) - || (aUpper.find ("UID") != -1) - || (aUpper.find ("ENVELOPE") != -1) - || (aUpper.find ("BODY.PEEK[0]") != -1 - && (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX))) - { - if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) - { - // write the mime header (default is here message/rfc822) - outputLine ("--IMAPDIGEST\r\n", 14); - cacheOutput = true; - if (cache && cache->getUid () != 0) - outputLineStr ("X-UID: " + - TQString::number(cache->getUid ()) + "\r\n"); - if (cache && cache->getSize () != 0) - outputLineStr ("X-Length: " + - TQString::number(cache->getSize ()) + "\r\n"); - if (cache && !cache->getDate ().isEmpty()) - outputLineStr ("X-Date: " + cache->getDate () + "\r\n"); - if (cache && cache->getFlags () != 0) - outputLineStr ("X-Flags: " + - TQString::number(cache->getFlags ()) + "\r\n"); - } else cacheOutput = true; - if ( lastone && !decodeContent ) - lastone->outputPart (*this); - cacheOutput = false; - flushOutput(contentEncoding); - } - } // if not complete - } - while (cmd && !cmd->isComplete ()); - if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) - { - // write the end boundary - outputLine ("--IMAPDIGEST--\r\n", 16); - } - - completeQueue.removeRef (cmd); - } - } - - // just to keep everybody happy when no data arrived - data (TQByteArray ()); - - finished (); - relayEnabled = false; - cacheOutput = false; - kdDebug(7116) << "IMAP4::get - finished" << endl; -} - -void -IMAP4Protocol::listDir (const KURL & _url) -{ - kdDebug(7116) << " IMAP4::listDir - " << _url.prettyURL() << endl; - - if (_url.path().isEmpty()) - { - KURL url = _url; - url.setPath("/"); - redirection( url ); - finished(); - return; - } - - TQString myBox, mySequence, myLType, mySection, myValidity, myDelimiter, myInfo; - // parseURL with caching - enum IMAP_TYPE myType = - parseURL (_url, myBox, mySection, myLType, mySequence, myValidity, - myDelimiter, myInfo, true); - - if (!makeLogin()) return; - - if (myType == ITYPE_DIR || myType == ITYPE_DIR_AND_BOX) - { - TQString listStr = myBox; - imapCommand *cmd; - - if (!listStr.isEmpty () && !listStr.endsWith(myDelimiter) && - mySection != "FOLDERONLY") - listStr += myDelimiter; - - if (mySection.isEmpty()) - { - listStr += "%"; - } else if (mySection == "COMPLETE") { - listStr += "*"; - } - kdDebug(7116) << "IMAP4Protocol::listDir - listStr=" << listStr << endl; - cmd = - doCommand (imapCommand::clientList ("", listStr, - (myLType == "LSUB" || myLType == "LSUBNOCHECK"))); - if (cmd->result () == "OK") - { - TQString mailboxName; - UDSEntry entry; - UDSAtom atom; - KURL aURL = _url; - if (aURL.path().find(';') != -1) - aURL.setPath(aURL.path().left(aURL.path().find(';'))); - - kdDebug(7116) << "IMAP4Protocol::listDir - got " << listResponses.count () << endl; - - if (myLType == "LSUB") - { - // fire the same command as LIST to check if the box really exists - TQValueList listResponsesSave = listResponses; - doCommand (imapCommand::clientList ("", listStr, false)); - for (TQValueListIterator < imapList > it = listResponsesSave.begin (); - it != listResponsesSave.end (); ++it) - { - bool boxOk = false; - for (TQValueListIterator < imapList > it2 = listResponses.begin (); - it2 != listResponses.end (); ++it2) - { - if ((*it2).name() == (*it).name()) - { - boxOk = true; - // copy the flags from the LIST-command - (*it) = (*it2); - break; - } - } - if (boxOk) - doListEntry (aURL, myBox, (*it), (mySection != "FOLDERONLY")); - else // this folder is dead - kdDebug(7116) << "IMAP4Protocol::listDir - suppress " << (*it).name() << endl; - } - listResponses = listResponsesSave; - } - else // LIST or LSUBNOCHECK - { - for (TQValueListIterator < imapList > it = listResponses.begin (); - it != listResponses.end (); ++it) - { - doListEntry (aURL, myBox, (*it), (mySection != "FOLDERONLY")); - } - } - entry.clear (); - listEntry (entry, true); - } - else - { - error (ERR_CANNOT_ENTER_DIRECTORY, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - if ((myType == ITYPE_BOX || myType == ITYPE_DIR_AND_BOX) - && myLType != "LIST" && myLType != "LSUB" && myLType != "LSUBNOCHECK") - { - KURL aURL = _url; - aURL.setQuery (TQString()); - const TQString encodedUrl = aURL.url(0, 106); // utf-8 - - if (!_url.query ().isEmpty ()) - { - TQString query = KURL::decode_string (_url.query ()); - query = query.right (query.length () - 1); - if (!query.isEmpty()) - { - imapCommand *cmd = NULL; - - if (!assureBox (myBox, true)) return; - - if (!selectInfo.countAvailable() || selectInfo.count()) - { - cmd = doCommand (imapCommand::clientSearch (query)); - if (cmd->result() != "OK") - { - error(ERR_UNSUPPORTED_ACTION, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - - TQStringList list = getResults (); - int stretch = 0; - - if (selectInfo.uidNextAvailable ()) - stretch = TQString::number(selectInfo.uidNext ()).length (); - UDSEntry entry; - imapCache fake; - - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); - ++it) - { - fake.setUid((*it).toULong()); - doListEntry (encodedUrl, stretch, &fake); - } - entry.clear (); - listEntry (entry, true); - } - } - } - else - { - if (!assureBox (myBox, true)) return; - - kdDebug(7116) << "IMAP4: select returned:" << endl; - if (selectInfo.recentAvailable ()) - kdDebug(7116) << "Recent: " << selectInfo.recent () << "d" << endl; - if (selectInfo.countAvailable ()) - kdDebug(7116) << "Count: " << selectInfo.count () << "d" << endl; - if (selectInfo.unseenAvailable ()) - kdDebug(7116) << "Unseen: " << selectInfo.unseen () << "d" << endl; - if (selectInfo.uidValidityAvailable ()) - kdDebug(7116) << "uidValidity: " << selectInfo.uidValidity () << "d" << endl; - if (selectInfo.flagsAvailable ()) - kdDebug(7116) << "Flags: " << selectInfo.flags () << "d" << endl; - if (selectInfo.permanentFlagsAvailable ()) - kdDebug(7116) << "PermanentFlags: " << selectInfo.permanentFlags () << "d" << endl; - if (selectInfo.readWriteAvailable ()) - kdDebug(7116) << "Access: " << (selectInfo.readWrite ()? "Read/Write" : "Read only") << endl; - -#ifdef USE_VALIDITY - if (selectInfo.uidValidityAvailable () - && selectInfo.uidValidity () != myValidity.toULong ()) - { - //redirect - KURL newUrl = _url; - - newUrl.setPath ("/" + myBox + ";UIDVALIDITY=" + - TQString::number(selectInfo.uidValidity ())); - kdDebug(7116) << "IMAP4::listDir - redirecting to " << newUrl.prettyURL() << endl; - redirection (newUrl); - - - } - else -#endif - if (selectInfo.count () > 0) - { - int stretch = 0; - - if (selectInfo.uidNextAvailable ()) - stretch = TQString::number(selectInfo.uidNext ()).length (); - // kdDebug(7116) << selectInfo.uidNext() << "d used to stretch " << stretch << endl; - UDSEntry entry; - - if (mySequence.isEmpty()) mySequence = "1:*"; - - bool withSubject = mySection.isEmpty(); - if (mySection.isEmpty()) mySection = "UID RFC822.SIZE ENVELOPE"; - - bool withFlags = mySection.upper().find("FLAGS") != -1; - imapCommand *fetch = - sendCommand (imapCommand:: - clientFetch (mySequence, mySection)); - imapCache *cache; - do - { - while (!parseLoop ()) ; - - cache = getLastHandled (); - - if (cache && !fetch->isComplete()) - doListEntry (encodedUrl, stretch, cache, withFlags, withSubject); - } - while (!fetch->isComplete ()); - entry.clear (); - listEntry (entry, true); - } - } - } - if ( !selectInfo.alert().isNull() ) { - if ( !myBox.isEmpty() ) { - warning( i18n( "Message from %1 while processing '%2': %3" ).arg( myHost, myBox, selectInfo.alert() ) ); - } else { - warning( i18n( "Message from %1: %2" ).arg( myHost, TQString(selectInfo.alert()) ) ); - } - selectInfo.setAlert( 0 ); - } - - kdDebug(7116) << "IMAP4Protocol::listDir - Finishing listDir" << endl; - finished (); -} - -void -IMAP4Protocol::setHost (const TQString & _host, int _port, - const TQString & _user, const TQString & _pass) -{ - if (myHost != _host || myPort != _port || myUser != _user || myPass != _pass) - { // what's the point of doing 4 string compares to avoid 4 string copies? - // DF: I guess to avoid calling closeConnection() unnecessarily. - if (!myHost.isEmpty ()) - closeConnection (); - myHost = _host; - if (_port == 0) - myPort = (mySSL) ? ImapsPort : ImapPort; - else - myPort = _port; - myUser = _user; - myPass = _pass; - } -} - -void -IMAP4Protocol::parseRelay (const TQByteArray & buffer) -{ - if (relayEnabled) { - // relay data immediately - data( buffer ); - mProcessedSize += buffer.size(); - processedSize( mProcessedSize ); - } else if (cacheOutput) - { - // collect data - if ( !outputBuffer.isOpen() ) { - outputBuffer.open(IO_WriteOnly); - } - outputBuffer.at(outputBufferIndex); - outputBuffer.writeBlock(buffer, buffer.size()); - outputBufferIndex += buffer.size(); - } -} - -void -IMAP4Protocol::parseRelay (ulong len) -{ - if (relayEnabled) - totalSize (len); -} - - -bool IMAP4Protocol::parseRead(TQByteArray & buffer, ulong len, ulong relay) -{ - char buf[8192]; - while (buffer.size() < len) - { - ssize_t readLen = myRead(buf, TQMIN(len - buffer.size(), sizeof(buf) - 1)); - if (readLen == 0) - { - kdDebug(7116) << "parseRead: readLen == 0 - connection broken" << endl; - error (ERR_CONNECTION_BROKEN, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - if (relay > buffer.size()) - { - TQByteArray relayData; - ssize_t relbuf = relay - buffer.size(); - int currentRelay = TQMIN(relbuf, readLen); - relayData.setRawData(buf, currentRelay); - parseRelay(relayData); - relayData.resetRawData(buf, currentRelay); - } - { - TQBuffer stream (buffer); - stream.open (IO_WriteOnly); - stream.at (buffer.size ()); - stream.writeBlock (buf, readLen); - stream.close (); - } - } - return (buffer.size() == len); -} - - -bool IMAP4Protocol::parseReadLine (TQByteArray & buffer, ulong relay) -{ - if (myHost.isEmpty()) return FALSE; - - while (true) { - ssize_t copyLen = 0; - if (readBufferLen > 0) - { - while (copyLen < readBufferLen && readBuffer[copyLen] != '\n') copyLen++; - if (copyLen < readBufferLen) copyLen++; - if (relay > 0) - { - TQByteArray relayData; - - if (copyLen < (ssize_t) relay) - relay = copyLen; - relayData.setRawData (readBuffer, relay); - parseRelay (relayData); - relayData.resetRawData (readBuffer, relay); -// kdDebug(7116) << "relayed : " << relay << "d" << endl; - } - // append to buffer - { - TQBuffer stream (buffer); - - stream.open (IO_WriteOnly); - stream.at (buffer.size ()); - stream.writeBlock (readBuffer, copyLen); - stream.close (); -// kdDebug(7116) << "appended " << copyLen << "d got now " << buffer.size() << endl; - } - - readBufferLen -= copyLen; - if (readBufferLen) - memmove(readBuffer, &readBuffer[copyLen], readBufferLen); - if (buffer[buffer.size() - 1] == '\n') return TRUE; - } - if (!isConnectionValid()) - { - kdDebug(7116) << "parseReadLine - connection broken" << endl; - error (ERR_CONNECTION_BROKEN, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - if (!waitForResponse( responseTimeout() )) - { - error(ERR_SERVER_TIMEOUT, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - readBufferLen = read(readBuffer, IMAP_BUFFER - 1); - if (readBufferLen == 0) - { - kdDebug(7116) << "parseReadLine: readBufferLen == 0 - connection broken" << endl; - error (ERR_CONNECTION_BROKEN, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - } -} - -void -IMAP4Protocol::setSubURL (const KURL & _url) -{ - kdDebug(7116) << "IMAP4::setSubURL - " << _url.prettyURL() << endl; - TDEIO::TCPSlaveBase::setSubURL (_url); -} - -void -IMAP4Protocol::put (const KURL & _url, int, bool, bool) -{ - kdDebug(7116) << "IMAP4::put - " << _url.prettyURL() << endl; -// TDEIO::TCPSlaveBase::put(_url,permissions,overwrite,resume); - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - enum IMAP_TYPE aType = - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - - // see if it is a box - if (aType != ITYPE_BOX && aType != ITYPE_DIR_AND_BOX) - { - if (aBox[aBox.length () - 1] == '/') - aBox = aBox.right (aBox.length () - 1); - imapCommand *cmd = doCommand (imapCommand::clientCreate (aBox)); - - if (cmd->result () != "OK") { - error (ERR_COULD_NOT_WRITE, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - else - { - TQPtrList < TQByteArray > bufferList; - int length = 0; - - int result; - // Loop until we got 'dataEnd' - do - { - TQByteArray *buffer = new TQByteArray (); - dataReq (); // Request for data - result = readData (*buffer); - if (result > 0) - { - bufferList.append (buffer); - length += result; - } else { - delete buffer; - } - } - while (result > 0); - - if (result != 0) - { - error (ERR_ABORTED, _url.prettyURL()); - return; - } - - imapCommand *cmd = - sendCommand (imapCommand::clientAppend (aBox, aSection, length)); - while (!parseLoop ()) ; - - // see if server is waiting - if (!cmd->isComplete () && !getContinuation ().isEmpty ()) - { - bool sendOk = true; - ulong wrote = 0; - - TQByteArray *buffer; - // send data to server - while (!bufferList.isEmpty () && sendOk) - { - buffer = bufferList.take (0); - - sendOk = - (write (buffer->data (), buffer->size ()) == - (ssize_t) buffer->size ()); - wrote += buffer->size (); - processedSize(wrote); - delete buffer; - if (!sendOk) - { - error (ERR_CONNECTION_BROKEN, myHost); - completeQueue.removeRef (cmd); - setState(ISTATE_CONNECT); - closeConnection(); - return; - } - } - parseWriteLine (""); - // Wait until cmd is complete, or connection breaks. - while (!cmd->isComplete () && getState() != ISTATE_NO) - parseLoop (); - if ( getState() == ISTATE_NO ) { - // TODO KDE4: pass cmd->resultInfo() as third argument. - // ERR_CONNECTION_BROKEN expects a host, no way to pass details about the problem. - error( ERR_CONNECTION_BROKEN, myHost ); - completeQueue.removeRef (cmd); - closeConnection(); - return; - } - else if (cmd->result () != "OK") { - error( ERR_SLAVE_DEFINED, cmd->resultInfo() ); - completeQueue.removeRef (cmd); - return; - } - else - { - if (hasCapability("UIDPLUS")) - { - TQString uid = cmd->resultInfo(); - if (uid.find("APPENDUID") != -1) - { - uid = uid.section(" ", 2, 2); - uid.truncate(uid.length()-1); - infoMessage("UID "+uid); - } - } - // MUST reselect to get the new message - else if (aBox == getCurrentBox ()) - { - cmd = - doCommand (imapCommand:: - clientSelect (aBox, !selectInfo.readWrite ())); - completeQueue.removeRef (cmd); - } - } - } - else - { - //error (ERR_COULD_NOT_WRITE, myHost); - // Better ship the error message, e.g. "Over Quota" - error (ERR_SLAVE_DEFINED, cmd->resultInfo()); - completeQueue.removeRef (cmd); - return; - } - - completeQueue.removeRef (cmd); - } - - finished (); -} - -void -IMAP4Protocol::mkdir (const KURL & _url, int) -{ - kdDebug(7116) << "IMAP4::mkdir - " << _url.prettyURL() << endl; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL(_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - kdDebug(7116) << "IMAP4::mkdir - create " << aBox << endl; - imapCommand *cmd = doCommand (imapCommand::clientCreate(aBox)); - - if (cmd->result () != "OK") - { - kdDebug(7116) << "IMAP4::mkdir - " << cmd->resultInfo() << endl; - error (ERR_COULD_NOT_MKDIR, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - - // start a new listing to find the type of the folder - enum IMAP_TYPE type = - parseURL(_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - if (type == ITYPE_BOX) - { - bool ask = ( aInfo.find( "ASKUSER" ) != -1 ); - if ( ask && - messageBox(QuestionYesNo, - i18n("The following folder will be created on the server: %1 " - "What do you want to store in this folder?").arg( aBox ), - i18n("Create Folder"), - i18n("&Messages"), i18n("&Subfolders")) == KMessageBox::No ) - { - cmd = doCommand(imapCommand::clientDelete(aBox)); - completeQueue.removeRef (cmd); - cmd = doCommand(imapCommand::clientCreate(aBox + aDelimiter)); - if (cmd->result () != "OK") - { - error (ERR_COULD_NOT_MKDIR, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - } - - cmd = doCommand(imapCommand::clientSubscribe(aBox)); - completeQueue.removeRef(cmd); - - finished (); -} - -void -IMAP4Protocol::copy (const KURL & src, const KURL & dest, int, bool overwrite) -{ - kdDebug(7116) << "IMAP4::copy - [" << (overwrite ? "Overwrite" : "NoOverwrite") << "] " << src.prettyURL() << " -> " << dest.prettyURL() << endl; - TQString sBox, sSequence, sLType, sSection, sValidity, sDelimiter, sInfo; - TQString dBox, dSequence, dLType, dSection, dValidity, dDelimiter, dInfo; - enum IMAP_TYPE sType = - parseURL (src, sBox, sSection, sLType, sSequence, sValidity, sDelimiter, sInfo); - enum IMAP_TYPE dType = - parseURL (dest, dBox, dSection, dLType, dSequence, dValidity, dDelimiter, dInfo); - - // see if we have to create anything - if (dType != ITYPE_BOX && dType != ITYPE_DIR_AND_BOX) - { - // this might be konqueror - int sub = dBox.find (sBox); - - // might be moving to upper folder - if (sub > 0) - { - KURL testDir = dest; - - TQString subDir = dBox.right (dBox.length () - dBox.findRev ('/')); - TQString topDir = dBox.left (sub); - testDir.setPath ("/" + topDir); - dType = - parseURL (testDir, topDir, dSection, dLType, dSequence, dValidity, - dDelimiter, dInfo); - - kdDebug(7116) << "IMAP4::copy - checking this destination " << topDir << endl; - // see if this is what the user wants - if (dType == ITYPE_BOX || dType == ITYPE_DIR_AND_BOX) - { - kdDebug(7116) << "IMAP4::copy - assuming this destination " << topDir << endl; - dBox = topDir; - } - else - { - - // maybe if we create a new mailbox - topDir = "/" + topDir + subDir; - testDir.setPath (topDir); - kdDebug(7116) << "IMAP4::copy - checking this destination " << topDir << endl; - dType = - parseURL (testDir, topDir, dSection, dLType, dSequence, dValidity, - dDelimiter, dInfo); - if (dType != ITYPE_BOX && dType != ITYPE_DIR_AND_BOX) - { - // ok then we'll create a mailbox - imapCommand *cmd = doCommand (imapCommand::clientCreate (topDir)); - - // on success we'll use it, else we'll just try to create the given dir - if (cmd->result () == "OK") - { - kdDebug(7116) << "IMAP4::copy - assuming this destination " << topDir << endl; - dType = ITYPE_BOX; - dBox = topDir; - } - else - { - completeQueue.removeRef (cmd); - cmd = doCommand (imapCommand::clientCreate (dBox)); - if (cmd->result () == "OK") - dType = ITYPE_BOX; - else - error (ERR_COULD_NOT_WRITE, dest.prettyURL()); - } - completeQueue.removeRef (cmd); - } - } - - } - } - if (sType == ITYPE_MSG || sType == ITYPE_BOX || sType == ITYPE_DIR_AND_BOX) - { - //select the source box - if (!assureBox(sBox, true)) return; - kdDebug(7116) << "IMAP4::copy - " << sBox << " -> " << dBox << endl; - - //issue copy command - imapCommand *cmd = - doCommand (imapCommand::clientCopy (dBox, sSequence)); - if (cmd->result () != "OK") - { - kdError(5006) << "IMAP4::copy - " << cmd->resultInfo() << endl; - error (ERR_COULD_NOT_WRITE, dest.prettyURL()); - completeQueue.removeRef (cmd); - return; - } else { - if (hasCapability("UIDPLUS")) - { - TQString uid = cmd->resultInfo(); - if (uid.find("COPYUID") != -1) - { - uid = uid.section(" ", 2, 3); - uid.truncate(uid.length()-1); - infoMessage("UID "+uid); - } - } - } - completeQueue.removeRef (cmd); - } - else - { - error (ERR_ACCESS_DENIED, src.prettyURL()); - return; - } - finished (); -} - -void -IMAP4Protocol::del (const KURL & _url, bool isFile) -{ - kdDebug(7116) << "IMAP4::del - [" << (isFile ? "File" : "NoFile") << "] " << _url.prettyURL() << endl; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - enum IMAP_TYPE aType = - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - - switch (aType) - { - case ITYPE_BOX: - case ITYPE_DIR_AND_BOX: - if (!aSequence.isEmpty ()) - { - if (aSequence == "*") - { - if (!assureBox (aBox, false)) return; - imapCommand *cmd = doCommand (imapCommand::clientExpunge ()); - if (cmd->result () != "OK") { - error (ERR_CANNOT_DELETE, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - else - { - // if open for read/write - if (!assureBox (aBox, false)) return; - imapCommand *cmd = - doCommand (imapCommand:: - clientStore (aSequence, "+FLAGS.SILENT", "\\DELETED")); - if (cmd->result () != "OK") { - error (ERR_CANNOT_DELETE, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - } - else - { - if (getCurrentBox() == aBox) - { - imapCommand *cmd = doCommand(imapCommand::clientClose()); - completeQueue.removeRef(cmd); - setState(ISTATE_LOGIN); - } - // We unsubscribe, otherwise we get ghost folders on UW-IMAP - imapCommand *cmd = doCommand(imapCommand::clientUnsubscribe(aBox)); - completeQueue.removeRef(cmd); - cmd = doCommand(imapCommand::clientDelete (aBox)); - // If this doesn't work, we try to empty the mailbox first - if (cmd->result () != "OK") - { - completeQueue.removeRef(cmd); - if (!assureBox(aBox, false)) return; - bool stillOk = true; - if (stillOk) - { - imapCommand *cmd = doCommand( - imapCommand::clientStore("1:*", "+FLAGS.SILENT", "\\DELETED")); - if (cmd->result () != "OK") stillOk = false; - completeQueue.removeRef(cmd); - } - if (stillOk) - { - imapCommand *cmd = doCommand(imapCommand::clientClose()); - if (cmd->result () != "OK") stillOk = false; - completeQueue.removeRef(cmd); - setState(ISTATE_LOGIN); - } - if (stillOk) - { - imapCommand *cmd = doCommand (imapCommand::clientDelete(aBox)); - if (cmd->result () != "OK") stillOk = false; - completeQueue.removeRef(cmd); - } - if (!stillOk) - { - error (ERR_COULD_NOT_RMDIR, _url.prettyURL()); - return; - } - } else { - completeQueue.removeRef (cmd); - } - } - break; - - case ITYPE_DIR: - { - imapCommand *cmd = doCommand (imapCommand::clientDelete (aBox)); - if (cmd->result () != "OK") { - error (ERR_COULD_NOT_RMDIR, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - break; - - case ITYPE_MSG: - { - // if open for read/write - if (!assureBox (aBox, false)) return; - imapCommand *cmd = - doCommand (imapCommand:: - clientStore (aSequence, "+FLAGS.SILENT", "\\DELETED")); - if (cmd->result () != "OK") { - error (ERR_CANNOT_DELETE, _url.prettyURL()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - break; - - case ITYPE_UNKNOWN: - case ITYPE_ATTACH: - error (ERR_CANNOT_DELETE, _url.prettyURL()); - break; - } - finished (); -} - -/* - * Copy a mail: data = 'C' + srcURL (KURL) + destURL (KURL) - * Capabilities: data = 'c'. Result shipped in infoMessage() signal - * No-op: data = 'N' - * Namespace: data = 'n'. Result shipped in infoMessage() signal - * The format is: section=namespace=delimiter - * Note that the namespace can be empty - * Unsubscribe: data = 'U' + URL (KURL) - * Subscribe: data = 'u' + URL (KURL) - * Change the status: data = 'S' + URL (KURL) + Flags (TQCString) - * ACL commands: data = 'A' + command + URL (KURL) + command-dependent args - * AnnotateMore commands: data = 'M' + 'G'et/'S'et + URL + entry + command-dependent args - * Search: data = 'E' + URL (KURL) - * Quota commands: data = 'Q' + 'R'oot/'G'et/'S'et + URL + entry + command-dependent args - * Custom command: data = 'X' + 'N'ormal/'E'xtended + command + command-dependent args - */ -void -IMAP4Protocol::special (const TQByteArray & aData) -{ - kdDebug(7116) << "IMAP4Protocol::special" << endl; - if (!makeLogin()) return; - - TQDataStream stream(aData, IO_ReadOnly); - - int tmp; - stream >> tmp; - - switch (tmp) { - case 'C': - { - // copy - KURL src; - KURL dest; - stream >> src >> dest; - copy(src, dest, 0, FALSE); - break; - } - case 'c': - { - // capabilities - infoMessage(imapCapabilities.join(" ")); - finished(); - break; - } - case 'N': - { - // NOOP - imapCommand *cmd = doCommand(imapCommand::clientNoop()); - if (cmd->result () != "OK") - { - kdDebug(7116) << "NOOP did not succeed - connection broken" << endl; - completeQueue.removeRef (cmd); - error (ERR_CONNECTION_BROKEN, myHost); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'n': - { - // namespace in the form "section=namespace=delimiter" - // entries are separated by , - infoMessage( imapNamespaces.join(",") ); - finished(); - break; - } - case 'U': - { - // unsubscribe - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - imapCommand *cmd = doCommand(imapCommand::clientUnsubscribe(aBox)); - if (cmd->result () != "OK") - { - completeQueue.removeRef (cmd); - error(ERR_SLAVE_DEFINED, i18n("Unsubscribe of folder %1 " - "failed. The server returned: %2") - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'u': - { - // subscribe - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - imapCommand *cmd = doCommand(imapCommand::clientSubscribe(aBox)); - if (cmd->result () != "OK") - { - completeQueue.removeRef (cmd); - error(ERR_SLAVE_DEFINED, i18n("Subscribe of folder %1 " - "failed. The server returned: %2") - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'A': - { - // acl - int cmd; - stream >> cmd; - if ( hasCapability( "ACL" ) ) { - specialACLCommand( cmd, stream ); - } else { - error( ERR_UNSUPPORTED_ACTION, "ACL" ); - } - break; - } - case 'M': - { - // annotatemore - int cmd; - stream >> cmd; - if ( hasCapability( "ANNOTATEMORE" ) ) { - specialAnnotateMoreCommand( cmd, stream ); - } else { - error( ERR_UNSUPPORTED_ACTION, "ANNOTATEMORE" ); - } - break; - } - case 'Q': - { - // quota - int cmd; - stream >> cmd; - if ( hasCapability( "QUOTA" ) ) { - specialQuotaCommand( cmd, stream ); - } else { - error( ERR_UNSUPPORTED_ACTION, "QUOTA" ); - } - break; - } - case 'S': - { - // status - KURL _url; - TQCString newFlags; - stream >> _url >> newFlags; - - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - if (!assureBox(aBox, false)) return; - - // make sure we only touch flags we know - TQCString knownFlags = "\\SEEN \\ANSWERED \\FLAGGED \\DRAFT"; - const imapInfo info = getSelected(); - if ( info.permanentFlagsAvailable() && (info.permanentFlags() & imapInfo::User) ) { - knownFlags += " KMAILFORWARDED KMAILTODO KMAILWATCHED KMAILIGNORED $FORWARDED $TODO $WATCHED $IGNORED"; - } - - imapCommand *cmd = doCommand (imapCommand:: - clientStore (aSequence, "-FLAGS.SILENT", knownFlags)); - if (cmd->result () != "OK") - { - completeQueue.removeRef (cmd); - error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " - "failed.").arg(_url.prettyURL())); - return; - } - completeQueue.removeRef (cmd); - if (!newFlags.isEmpty()) - { - cmd = doCommand (imapCommand:: - clientStore (aSequence, "+FLAGS.SILENT", newFlags)); - if (cmd->result () != "OK") - { - completeQueue.removeRef (cmd); - error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " - "failed.").arg(_url.prettyURL())); - return; - } - completeQueue.removeRef (cmd); - } - finished(); - break; - } - case 's': - { - // seen - KURL _url; - bool seen; - TQCString newFlags; - stream >> _url >> seen; - - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - if ( !assureBox(aBox, true) ) // read-only because changing SEEN should be possible even then - return; - - imapCommand *cmd; - if ( seen ) - cmd = doCommand( imapCommand::clientStore( aSequence, "+FLAGS.SILENT", "\\SEEN" ) ); - else - cmd = doCommand( imapCommand::clientStore( aSequence, "-FLAGS.SILENT", "\\SEEN" ) ); - - if (cmd->result () != "OK") - { - completeQueue.removeRef (cmd); - error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " - "failed.").arg(_url.prettyURL())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - - case 'E': - { - // search - specialSearchCommand( stream ); - break; - } - case 'X': - { - // custom command - specialCustomCommand( stream ); - break; - } - default: - kdWarning(7116) << "Unknown command in special(): " << tmp << endl; - error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(tmp)) ); - break; - } -} - -void -IMAP4Protocol::specialACLCommand( int command, TQDataStream& stream ) -{ - // All commands start with the URL to the box - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - - switch( command ) { - case 'S': // SETACL - { - TQString user, acl; - stream >> user >> acl; - kdDebug(7116) << "SETACL " << aBox << " " << user << " " << acl << endl; - imapCommand *cmd = doCommand(imapCommand::clientSetACL(aBox, user, acl)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Setting the Access Control List on folder %1 " - "for user %2 failed. The server returned: %3") - .arg(_url.prettyURL()) - .arg(user) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'D': // DELETEACL - { - TQString user; - stream >> user; - kdDebug(7116) << "DELETEACL " << aBox << " " << user << endl; - imapCommand *cmd = doCommand(imapCommand::clientDeleteACL(aBox, user)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Deleting the Access Control List on folder %1 " - "for user %2 failed. The server returned: %3") - .arg(_url.prettyURL()) - .arg(user) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'G': // GETACL - { - kdDebug(7116) << "GETACL " << aBox << endl; - imapCommand *cmd = doCommand(imapCommand::clientGetACL(aBox)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Retrieving the Access Control List on folder %1 " - "failed. The server returned: %2") - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - // Returning information to the application from a special() command isn't easy. - // I'm reusing the infoMessage trick seen above (for capabilities), but this - // limits me to a string instead of a stringlist. Using DQUOTE as separator, - // because it's forbidden in userids by rfc3501 - kdDebug(7116) << getResults() << endl; - infoMessage(getResults().join( "\"" )); - finished(); - break; - } - case 'L': // LISTRIGHTS - { - // Do we need this one? It basically shows which rights are tied together, but that's all? - error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); - break; - } - case 'M': // MYRIGHTS - { - kdDebug(7116) << "MYRIGHTS " << aBox << endl; - imapCommand *cmd = doCommand(imapCommand::clientMyRights(aBox)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Retrieving the Access Control List on folder %1 " - "failed. The server returned: %2") - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - TQStringList lst = getResults(); - kdDebug(7116) << "myrights results: " << lst << endl; - if ( !lst.isEmpty() ) { - Q_ASSERT( lst.count() == 1 ); - infoMessage( lst.first() ); - } - finished(); - break; - } - default: - kdWarning(7116) << "Unknown special ACL command:" << command << endl; - error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); - } -} - -void -IMAP4Protocol::specialSearchCommand( TQDataStream& stream ) -{ - kdDebug(7116) << "IMAP4Protocol::specialSearchCommand" << endl; - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - if (!assureBox(aBox, true)) return; - - imapCommand *cmd = doCommand (imapCommand::clientSearch( aSection )); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Searching of folder %1 " - "failed. The server returned: %2") - .arg(aBox) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef(cmd); - TQStringList lst = getResults(); - kdDebug(7116) << "IMAP4Protocol::specialSearchCommand '" << aSection << - "' returns " << lst << endl; - infoMessage( lst.join( " " ) ); - - finished(); -} - -void -IMAP4Protocol::specialCustomCommand( TQDataStream& stream ) -{ - kdDebug(7116) << "IMAP4Protocol::specialCustomCommand" << endl; - - TQString command, arguments; - int type; - stream >> type; - stream >> command >> arguments; - - /** - * In 'normal' mode we send the command with all information in one go - * and retrieve the result. - */ - if ( type == 'N' ) { - kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: normal mode" << endl; - imapCommand *cmd = doCommand (imapCommand::clientCustom( command, arguments )); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Custom command %1:%2 " - "failed. The server returned: %3") - .arg(command) - .arg(arguments) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef(cmd); - TQStringList lst = getResults(); - kdDebug(7116) << "IMAP4Protocol::specialCustomCommand '" << command << - ":" << arguments << - "' returns " << lst << endl; - infoMessage( lst.join( " " ) ); - - finished(); - } else - /** - * In 'extended' mode we send a first header and push the data of the request in - * streaming mode. - */ - if ( type == 'E' ) { - kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: extended mode" << endl; - imapCommand *cmd = sendCommand (imapCommand::clientCustom( command, TQString() )); - while ( !parseLoop () ) ; - - // see if server is waiting - if (!cmd->isComplete () && !getContinuation ().isEmpty ()) - { - const TQByteArray buffer = arguments.utf8(); - - // send data to server - bool sendOk = (write (buffer.data (), buffer.size ()) == (ssize_t)buffer.size ()); - processedSize( buffer.size() ); - - if ( !sendOk ) { - error ( ERR_CONNECTION_BROKEN, myHost ); - completeQueue.removeRef ( cmd ); - setState(ISTATE_CONNECT); - closeConnection(); - return; - } - } - parseWriteLine (""); - - do - { - while (!parseLoop ()) ; - } - while (!cmd->isComplete ()); - - completeQueue.removeRef (cmd); - - TQStringList lst = getResults(); - kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: returns " << lst << endl; - infoMessage( lst.join( " " ) ); - - finished (); - } -} - -void -IMAP4Protocol::specialAnnotateMoreCommand( int command, TQDataStream& stream ) -{ - // All commands start with the URL to the box - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - - switch( command ) { - case 'S': // SETANNOTATION - { - // Params: - // KURL URL of the mailbox - // TQString entry (should be an actual entry name, no % or *; empty for server entries) - // TQMap attributes (name and value) - TQString entry; - TQMap attributes; - stream >> entry >> attributes; - kdDebug(7116) << "SETANNOTATION " << aBox << " " << entry << " " << attributes.count() << " attributes" << endl; - imapCommand *cmd = doCommand(imapCommand::clientSetAnnotation(aBox, entry, attributes)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Setting the annotation %1 on folder %2 " - " failed. The server returned: %3") - .arg(entry) - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - completeQueue.removeRef (cmd); - finished(); - break; - } - case 'G': // GETANNOTATION. - { - // Params: - // KURL URL of the mailbox - // TQString entry (should be an actual entry name, no % or *; empty for server entries) - // TQStringList attributes (list of attributes to be retrieved, possibly with % or *) - TQString entry; - TQStringList attributeNames; - stream >> entry >> attributeNames; - kdDebug(7116) << "GETANNOTATION " << aBox << " " << entry << " " << attributeNames << endl; - imapCommand *cmd = doCommand(imapCommand::clientGetAnnotation(aBox, entry, attributeNames)); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Retrieving the annotation %1 on folder %2 " - "failed. The server returned: %3") - .arg(entry) - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - // Returning information to the application from a special() command isn't easy. - // I'm reusing the infoMessage trick seen above (for capabilities and acls), but this - // limits me to a string instead of a stringlist. Let's use \r as separator. - kdDebug(7116) << getResults() << endl; - infoMessage(getResults().join( "\r" )); - finished(); - break; - } - default: - kdWarning(7116) << "Unknown special annotate command:" << command << endl; - error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); - } -} - -void -IMAP4Protocol::specialQuotaCommand( int command, TQDataStream& stream ) -{ - // All commands start with the URL to the box - KURL _url; - stream >> _url; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); - - switch( command ) { - case 'R': // GETQUOTAROOT - { - kdDebug(7116) << "QUOTAROOT " << aBox << endl; - imapCommand *cmd = doCommand(imapCommand::clientGetQuotaroot( aBox ) ); - if (cmd->result () != "OK") - { - error(ERR_SLAVE_DEFINED, i18n("Retrieving the quota root information on folder %1 " - "failed. The server returned: %2") - .arg(_url.prettyURL()) - .arg(cmd->resultInfo())); - return; - } - infoMessage(getResults().join( "\r" )); - finished(); - break; - } - case 'G': // GETQUOTA - { - kdDebug(7116) << "GETQUOTA command" << endl; - kdWarning(7116) << "UNIMPLEMENTED" << endl; - break; - } - case 'S': // SETQUOTA - { - kdDebug(7116) << "SETQUOTA command" << endl; - kdWarning(7116) << "UNIMPLEMENTED" << endl; - break; - } - default: - kdWarning(7116) << "Unknown special quota command:" << command << endl; - error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); - } -} - -void -IMAP4Protocol::rename (const KURL & src, const KURL & dest, bool overwrite) -{ - kdDebug(7116) << "IMAP4::rename - [" << (overwrite ? "Overwrite" : "NoOverwrite") << "] " << src.prettyURL() << " -> " << dest.prettyURL() << endl; - TQString sBox, sSequence, sLType, sSection, sValidity, sDelimiter, sInfo; - TQString dBox, dSequence, dLType, dSection, dValidity, dDelimiter, dInfo; - enum IMAP_TYPE sType = - parseURL (src, sBox, sSection, sLType, sSequence, sValidity, sDelimiter, sInfo, false); - enum IMAP_TYPE dType = - parseURL (dest, dBox, dSection, dLType, dSequence, dValidity, dDelimiter, dInfo, false); - - if (dType == ITYPE_UNKNOWN) - { - switch (sType) - { - case ITYPE_BOX: - case ITYPE_DIR: - case ITYPE_DIR_AND_BOX: - { - if (getState() == ISTATE_SELECT && sBox == getCurrentBox()) - { - kdDebug(7116) << "IMAP4::rename - close " << getCurrentBox() << endl; - // mailbox can only be renamed if it is closed - imapCommand *cmd = doCommand (imapCommand::clientClose()); - bool ok = cmd->result() == "OK"; - completeQueue.removeRef(cmd); - if (!ok) - { - kdWarning(7116) << "Unable to close mailbox!" << endl; - error(ERR_CANNOT_RENAME, src.path()); - return; - } - setState(ISTATE_LOGIN); - } - imapCommand *cmd = doCommand (imapCommand::clientRename (sBox, dBox)); - if (cmd->result () != "OK") { - error (ERR_CANNOT_RENAME, src.path()); - completeQueue.removeRef (cmd); - return; - } - completeQueue.removeRef (cmd); - } - break; - - case ITYPE_MSG: - case ITYPE_ATTACH: - case ITYPE_UNKNOWN: - error (ERR_CANNOT_RENAME, src.path()); - break; - } - } - else - { - error (ERR_CANNOT_RENAME, src.path()); - return; - } - finished (); -} - -void -IMAP4Protocol::slave_status () -{ - bool connected = (getState() != ISTATE_NO) && isConnectionValid(); - kdDebug(7116) << "IMAP4::slave_status " << connected << endl; - slaveStatus ( connected ? myHost : TQString(), connected ); -} - -void -IMAP4Protocol::dispatch (int command, const TQByteArray & data) -{ - kdDebug(7116) << "IMAP4::dispatch - command=" << command << endl; - TDEIO::TCPSlaveBase::dispatch (command, data); -} - -void -IMAP4Protocol::stat (const KURL & _url) -{ - kdDebug(7116) << "IMAP4::stat - " << _url.prettyURL() << endl; - TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; - // parseURL with caching - enum IMAP_TYPE aType = - parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, - aInfo, true); - - UDSEntry entry; - UDSAtom atom; - - atom.m_uds = UDS_NAME; - atom.m_str = aBox; - entry.append (atom); - - if (!aSection.isEmpty()) - { - if (getState() == ISTATE_SELECT && aBox == getCurrentBox()) - { - imapCommand *cmd = doCommand (imapCommand::clientClose()); - bool ok = cmd->result() == "OK"; - completeQueue.removeRef(cmd); - if (!ok) - { - error(ERR_COULD_NOT_STAT, aBox); - return; - } - setState(ISTATE_LOGIN); - } - bool ok = false; - TQString cmdInfo; - if (aType == ITYPE_MSG || aType == ITYPE_ATTACH) - ok = true; - else - { - imapCommand *cmd = doCommand(imapCommand::clienStatus(aBox, aSection)); - ok = cmd->result() == "OK"; - cmdInfo = cmd->resultInfo(); - completeQueue.removeRef(cmd); - } - if (!ok) - { - bool found = false; - imapCommand *cmd = doCommand (imapCommand::clientList ("", aBox)); - if (cmd->result () == "OK") - { - for (TQValueListIterator < imapList > it = listResponses.begin (); - it != listResponses.end (); ++it) - { - if (aBox == (*it).name ()) found = true; - } - } - completeQueue.removeRef (cmd); - if (found) - error(ERR_COULD_NOT_STAT, aBox); - else - error(TDEIO::ERR_DOES_NOT_EXIST, aBox); - return; - } - if ((aSection == "UIDNEXT" && geStatus().uidNextAvailable()) - || (aSection == "UNSEEN" && geStatus().unseenAvailable())) - { - atom.m_uds = UDS_SIZE; - atom.m_str = TQString(); - atom.m_long = (aSection == "UIDNEXT") ? geStatus().uidNext() - : geStatus().unseen(); - entry.append(atom); - } - } else - if (aType == ITYPE_BOX || aType == ITYPE_DIR_AND_BOX || aType == ITYPE_MSG || - aType == ITYPE_ATTACH) - { - ulong validity = 0; - // see if the box is already in select/examine state - if (aBox == getCurrentBox ()) - validity = selectInfo.uidValidity (); - else - { - // do a status lookup on the box - // only do this if the box is not selected - // the server might change the validity for new select/examine - imapCommand *cmd = - doCommand (imapCommand::clienStatus (aBox, "UIDVALIDITY")); - completeQueue.removeRef (cmd); - validity = geStatus ().uidValidity (); - } - validity = 0; // temporary - - if (aType == ITYPE_BOX || aType == ITYPE_DIR_AND_BOX) - { - // has no or an invalid uidvalidity - if (validity > 0 && validity != aValidity.toULong ()) - { - //redirect - KURL newUrl = _url; - - newUrl.setPath ("/" + aBox + ";UIDVALIDITY=" + - TQString::number(validity)); - kdDebug(7116) << "IMAP4::stat - redirecting to " << newUrl.prettyURL() << endl; - redirection (newUrl); - } - } - else if (aType == ITYPE_MSG || aType == ITYPE_ATTACH) - { - //must determine if this message exists - //cause konqueror will check this on paste operations - - // has an invalid uidvalidity - // or no messages in box - if (validity > 0 && validity != aValidity.toULong ()) - { - aType = ITYPE_UNKNOWN; - kdDebug(7116) << "IMAP4::stat - url has invalid validity [" << validity << "d] " << _url.prettyURL() << endl; - } - } - } - - atom.m_uds = UDS_MIME_TYPE; - atom.m_str = getMimeType (aType); - entry.append (atom); - - kdDebug(7116) << "IMAP4: stat: " << atom.m_str << endl; - switch (aType) - { - case ITYPE_DIR: - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFDIR; - entry.append (atom); - break; - - case ITYPE_BOX: - case ITYPE_DIR_AND_BOX: - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFDIR; - entry.append (atom); - break; - - case ITYPE_MSG: - case ITYPE_ATTACH: - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFREG; - entry.append (atom); - break; - - case ITYPE_UNKNOWN: - error (ERR_DOES_NOT_EXIST, _url.prettyURL()); - break; - } - - statEntry (entry); - kdDebug(7116) << "IMAP4::stat - Finishing stat" << endl; - finished (); -} - -void IMAP4Protocol::openConnection() -{ - if (makeLogin()) connected(); -} - -void IMAP4Protocol::closeConnection() -{ - if (getState() == ISTATE_NO) return; - if (getState() == ISTATE_SELECT && metaData("expunge") == "auto") - { - imapCommand *cmd = doCommand (imapCommand::clientExpunge()); - completeQueue.removeRef (cmd); - } - if (getState() != ISTATE_CONNECT) - { - imapCommand *cmd = doCommand (imapCommand::clientLogout()); - completeQueue.removeRef (cmd); - } - closeDescriptor(); - setState(ISTATE_NO); - completeQueue.clear(); - sentQueue.clear(); - lastHandled = 0; - currentBox = TQString(); - readBufferLen = 0; -} - -bool IMAP4Protocol::makeLogin () -{ - if (getState () == ISTATE_LOGIN || getState () == ISTATE_SELECT) - return true; - - kdDebug(7116) << "IMAP4::makeLogin - checking login" << endl; - bool alreadyConnected = getState() == ISTATE_CONNECT; - kdDebug(7116) << "IMAP4::makeLogin - alreadyConnected " << alreadyConnected << endl; - if (alreadyConnected || connectToHost (myHost.latin1(), myPort)) - { -// fcntl (m_iSock, F_SETFL, (fcntl (m_iSock, F_GETFL) | O_NDELAY)); - - setState(ISTATE_CONNECT); - - myAuth = metaData("auth"); - myTLS = metaData("tls"); - kdDebug(7116) << "myAuth: " << myAuth << endl; - - imapCommand *cmd; - - unhandled.clear (); - if (!alreadyConnected) while (!parseLoop ()) ; //get greeting - TQString greeting; - if (!unhandled.isEmpty()) greeting = unhandled.first().stripWhiteSpace(); - unhandled.clear (); //get rid of it - cmd = doCommand (new imapCommand ("CAPABILITY", "")); - - kdDebug(7116) << "IMAP4: setHost: capability" << endl; - for (TQStringList::Iterator it = imapCapabilities.begin (); - it != imapCapabilities.end (); ++it) - { - kdDebug(7116) << "'" << (*it) << "'" << endl; - } - completeQueue.removeRef (cmd); - - if (!hasCapability("IMAP4") && !hasCapability("IMAP4rev1")) - { - error(ERR_COULD_NOT_LOGIN, i18n("The server %1 supports neither " - "IMAP4 nor IMAP4rev1.\nIt identified itself with: %2") - .arg(myHost).arg(greeting)); - closeConnection(); - return false; - } - - if (metaData("nologin") == "on") return TRUE; - - if (myTLS == "on" && !hasCapability(TQString("STARTTLS"))) - { - error(ERR_COULD_NOT_LOGIN, i18n("The server does not support TLS.\n" - "Disable this security feature to connect unencrypted.")); - closeConnection(); - return false; - } - if ((myTLS == "on" || (canUseTLS() && myTLS != "off")) && - hasCapability(TQString("STARTTLS"))) - { - imapCommand *cmd = doCommand (imapCommand::clientStartTLS()); - if (cmd->result () == "OK") - { - completeQueue.removeRef(cmd); - int tlsrc = startTLS(); - if (tlsrc == 1) - { - kdDebug(7116) << "TLS mode has been enabled." << endl; - imapCommand *cmd2 = doCommand (new imapCommand ("CAPABILITY", "")); - for (TQStringList::Iterator it = imapCapabilities.begin (); - it != imapCapabilities.end (); ++it) - { - kdDebug(7116) << "'" << (*it) << "'" << endl; - } - completeQueue.removeRef (cmd2); - } else { - kdWarning(7116) << "TLS mode setup has failed. Aborting." << endl; - error (ERR_COULD_NOT_LOGIN, i18n("Starting TLS failed.")); - closeConnection(); - return false; - } - } else completeQueue.removeRef(cmd); - } - - if (myAuth.isEmpty () || myAuth == "*") { - if (hasCapability (TQString ("LOGINDISABLED"))) { - error (ERR_COULD_NOT_LOGIN, i18n("LOGIN is disabled by the server.")); - closeConnection(); - return false; - } - } - else { - if (!hasCapability (TQString ("AUTH=") + myAuth)) { - error (ERR_COULD_NOT_LOGIN, i18n("The authentication method %1 is not " - "supported by the server.").arg(myAuth)); - closeConnection(); - return false; - } - } - - if ( greeting.contains( TQRegExp( "Cyrus IMAP4 v2.1" ) ) ) { - removeCapability( "ANNOTATEMORE" ); - } - - // starting from Cyrus IMAP 2.3.9, shared seen flags are available - TQRegExp regExp( "Cyrus\\sIMAP[4]{0,1}\\sv(\\d+)\\.(\\d+)\\.(\\d+)", false ); - if ( regExp.search( greeting ) >= 0 ) { - const int major = regExp.cap( 1 ).toInt(); - const int minor = regExp.cap( 2 ).toInt(); - const int patch = regExp.cap( 3 ).toInt(); - if ( major > 2 || (major == 2 && (minor > 3 || (minor == 3 && patch > 9))) ) { - kdDebug(7116) << k_funcinfo << "Cyrus IMAP >= 2.3.9 detected, enabling shared seen flag support" << endl; - imapCapabilities.append( "x-kmail-sharedseen" ); - } - } - - kdDebug(7116) << "IMAP4::makeLogin - attempting login" << endl; - - TDEIO::AuthInfo authInfo; - authInfo.username = myUser; - authInfo.password = myPass; - authInfo.prompt = i18n ("Username and password for your IMAP account:"); - - kdDebug(7116) << "IMAP4::makeLogin - open_PassDlg said user=" << myUser << " pass=xx" << endl; - - TQString resultInfo; - if (myAuth.isEmpty () || myAuth == "*") - { - if (myUser.isEmpty () || myPass.isEmpty ()) { - if(openPassDlg (authInfo)) { - myUser = authInfo.username; - myPass = authInfo.password; - } - } - if (!clientLogin (myUser, myPass, resultInfo)) - error(TDEIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to login. Probably the " - "password is wrong.\nThe server %1 replied:\n%2").arg(myHost).arg(resultInfo)); - } - else - { -#ifdef HAVE_LIBSASL2 - if (!clientAuthenticate (this, authInfo, myHost, myAuth, mySSL, resultInfo)) - error(TDEIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to authenticate via %1.\n" - "The server %2 replied:\n%3").arg(myAuth).arg(myHost).arg(resultInfo)); - else { - myUser = authInfo.username; - myPass = authInfo.password; - } -#else - error(TDEIO::ERR_COULD_NOT_LOGIN, i18n("SASL authentication is not compiled into tdeio_imap4.")); -#endif - } - if ( hasCapability("NAMESPACE") ) - { - // get all namespaces and save the namespace - delimiter association - cmd = doCommand( imapCommand::clientNamespace() ); - if (cmd->result () == "OK") - { - kdDebug(7116) << "makeLogin - registered namespaces" << endl; - } - completeQueue.removeRef (cmd); - } - // get the default delimiter (empty listing) - cmd = doCommand( imapCommand::clientList("", "") ); - if (cmd->result () == "OK") - { - TQValueListIterator < imapList > it = listResponses.begin(); - if ( it == listResponses.end() ) - { - // empty answer - this is a buggy imap server - // as a fallback we fire a normal listing and take the first answer - completeQueue.removeRef (cmd); - cmd = doCommand( imapCommand::clientList("", "%") ); - if (cmd->result () == "OK") - { - it = listResponses.begin(); - } - } - if ( it != listResponses.end() ) - { - namespaceToDelimiter[TQString()] = (*it).hierarchyDelimiter(); - kdDebug(7116) << "makeLogin - delimiter for empty ns='" << - (*it).hierarchyDelimiter() << "'" << endl; - if ( !hasCapability("NAMESPACE") ) - { - // server does not support namespaces - TQString nsentry = TQString::number( 0 ) + "==" - + (*it).hierarchyDelimiter(); - imapNamespaces.append( nsentry ); - } - } - } - completeQueue.removeRef (cmd); - } else { - kdDebug(7116) << "makeLogin - NO login" << endl; - } - - return getState() == ISTATE_LOGIN; -} - -void -IMAP4Protocol::parseWriteLine (const TQString & aStr) -{ - //kdDebug(7116) << "Writing: " << aStr << endl; - TQCString writer = aStr.utf8(); - int len = writer.length(); - - // append CRLF if necessary - if (len == 0 || (writer[len - 1] != '\n')) { - len += 2; - writer += "\r\n"; - } - - // write it - write(writer.data(), len); -} - -TQString -IMAP4Protocol::getMimeType (enum IMAP_TYPE aType) -{ - switch (aType) - { - case ITYPE_DIR: - return "inode/directory"; - break; - - case ITYPE_BOX: - return "message/digest"; - break; - - case ITYPE_DIR_AND_BOX: - return "message/directory"; - break; - - case ITYPE_MSG: - return "message/rfc822"; - break; - - // this should be handled by flushOutput - case ITYPE_ATTACH: - return "application/octet-stream"; - break; - - case ITYPE_UNKNOWN: - default: - return "unknown/unknown"; - } -} - - - -void -IMAP4Protocol::doListEntry (const KURL & _url, int stretch, imapCache * cache, - bool withFlags, bool withSubject) -{ - KURL aURL = _url; - aURL.setQuery (TQString()); - const TQString encodedUrl = aURL.url(0, 106); // utf-8 - doListEntry(encodedUrl, stretch, cache, withFlags, withSubject); -} - - - -void -IMAP4Protocol::doListEntry (const TQString & encodedUrl, int stretch, imapCache * cache, - bool withFlags, bool withSubject) -{ - if (cache) - { - UDSEntry entry; - UDSAtom atom; - - entry.clear (); - - const TQString uid = TQString::number(cache->getUid()); - - atom.m_uds = UDS_NAME; - atom.m_str = uid; - atom.m_long = 0; - if (stretch > 0) - { - atom.m_str = "0000000000000000" + atom.m_str; - atom.m_str = atom.m_str.right (stretch); - } - if (withSubject) - { - mailHeader *header = cache->getHeader(); - if (header) - atom.m_str += " " + header->getSubject(); - } - entry.append (atom); - - atom.m_uds = UDS_URL; - atom.m_str = encodedUrl; // utf-8 - if (atom.m_str[atom.m_str.length () - 1] != '/') - atom.m_str += '/'; - atom.m_str += ";UID=" + uid; - atom.m_long = 0; - entry.append (atom); - - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFREG; - entry.append (atom); - - atom.m_uds = UDS_SIZE; - atom.m_long = cache->getSize(); - entry.append (atom); - - atom.m_uds = UDS_MIME_TYPE; - atom.m_str = "message/rfc822"; - atom.m_long = 0; - entry.append (atom); - - atom.m_uds = UDS_USER; - atom.m_str = myUser; - entry.append (atom); - - atom.m_uds = TDEIO::UDS_ACCESS; - atom.m_long = (withFlags) ? cache->getFlags() : S_IRUSR | S_IXUSR | S_IWUSR; - entry.append (atom); - - listEntry (entry, false); - } -} - -void -IMAP4Protocol::doListEntry (const KURL & _url, const TQString & myBox, - const imapList & item, bool appendPath) -{ - KURL aURL = _url; - aURL.setQuery (TQString()); - UDSEntry entry; - UDSAtom atom; - int hdLen = item.hierarchyDelimiter().length(); - - { - // mailboxName will be appended to the path if appendPath is true - TQString mailboxName = item.name (); - - // some beautification - if (mailboxName.find (myBox) == 0 && mailboxName.length() > myBox.length()) - { - mailboxName = - mailboxName.right (mailboxName.length () - myBox.length ()); - } - if (mailboxName[0] == '/') - mailboxName = mailboxName.right (mailboxName.length () - 1); - if (mailboxName.left(hdLen) == item.hierarchyDelimiter()) - mailboxName = mailboxName.right(mailboxName.length () - hdLen); - if (mailboxName.right(hdLen) == item.hierarchyDelimiter()) - mailboxName.truncate(mailboxName.length () - hdLen); - - atom.m_uds = UDS_NAME; - if (!item.hierarchyDelimiter().isEmpty() && - mailboxName.find(item.hierarchyDelimiter()) != -1) - atom.m_str = mailboxName.section(item.hierarchyDelimiter(), -1); - else - atom.m_str = mailboxName; - - // konqueror will die with an assertion failure otherwise - if (atom.m_str.isEmpty ()) - atom.m_str = ".."; - - if (!atom.m_str.isEmpty ()) - { - atom.m_long = 0; - entry.append (atom); - - if (!item.noSelect ()) - { - atom.m_uds = UDS_MIME_TYPE; - if (!item.noInferiors ()) - { - atom.m_str = "message/directory"; - } else { - atom.m_str = "message/digest"; - } - atom.m_long = 0; - entry.append (atom); - mailboxName += '/'; - - // explicitly set this as a directory for KFileDialog - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFDIR; - entry.append (atom); - } - else if (!item.noInferiors ()) - { - atom.m_uds = UDS_MIME_TYPE; - atom.m_str = "inode/directory"; - atom.m_long = 0; - entry.append (atom); - mailboxName += '/'; - - // explicitly set this as a directory for KFileDialog - atom.m_uds = UDS_FILE_TYPE; - atom.m_str = TQString(); - atom.m_long = S_IFDIR; - entry.append (atom); - } - else - { - atom.m_uds = UDS_MIME_TYPE; - atom.m_str = "unknown/unknown"; - atom.m_long = 0; - entry.append (atom); - } - - atom.m_uds = UDS_URL; - TQString path = aURL.path(); - atom.m_str = aURL.url (0, 106); // utf-8 - if (appendPath) - { - if (path[path.length() - 1] == '/' && !path.isEmpty() && path != "/") - path.truncate(path.length() - 1); - if (!path.isEmpty() && path != "/" - && path.right(hdLen) != item.hierarchyDelimiter()) { - path += item.hierarchyDelimiter(); - } - path += mailboxName; - if (path.upper() == "/INBOX/") { - // make sure the client can rely on INBOX - path = path.upper(); - } - } - aURL.setPath(path); - atom.m_str = aURL.url(0, 106); // utf-8 - atom.m_long = 0; - entry.append (atom); - - atom.m_uds = UDS_USER; - atom.m_str = myUser; - entry.append (atom); - - atom.m_uds = UDS_ACCESS; - atom.m_long = S_IRUSR | S_IXUSR | S_IWUSR; - entry.append (atom); - - atom.m_uds = UDS_EXTRA; - atom.m_str = item.attributesAsString(); - atom.m_long = 0; - entry.append (atom); - - listEntry (entry, false); - } - } -} - -enum IMAP_TYPE -IMAP4Protocol::parseURL (const KURL & _url, TQString & _box, - TQString & _section, TQString & _type, TQString & _uid, - TQString & _validity, TQString & _hierarchyDelimiter, - TQString & _info, bool cache) -{ - enum IMAP_TYPE retVal; - retVal = ITYPE_UNKNOWN; - - imapParser::parseURL (_url, _box, _section, _type, _uid, _validity, _info); -// kdDebug(7116) << "URL: query - '" << KURL::decode_string(_url.query()) << "'" << endl; - - // get the delimiter - TQString myNamespace = namespaceForBox( _box ); - kdDebug(7116) << "IMAP4::parseURL - namespace=" << myNamespace << endl; - if ( namespaceToDelimiter.contains(myNamespace) ) - { - _hierarchyDelimiter = namespaceToDelimiter[myNamespace]; - kdDebug(7116) << "IMAP4::parseURL - delimiter=" << _hierarchyDelimiter << endl; - } - - if (!_box.isEmpty ()) - { - kdDebug(7116) << "IMAP4::parseURL - box=" << _box << endl; - - if (makeLogin ()) - { - if (getCurrentBox () != _box || - _type == "LIST" || _type == "LSUB" || _type == "LSUBNOCHECK") - { - if ( cache ) - { - // assume a normal box - retVal = ITYPE_DIR_AND_BOX; - } else - { - // start a listing for the box to get the type - imapCommand *cmd; - - cmd = doCommand (imapCommand::clientList ("", _box)); - if (cmd->result () == "OK") - { - for (TQValueListIterator < imapList > it = listResponses.begin (); - it != listResponses.end (); ++it) - { - //kdDebug(7116) << "IMAP4::parseURL - checking " << _box << " to " << (*it).name() << endl; - if (_box == (*it).name ()) - { - if ( !(*it).hierarchyDelimiter().isEmpty() ) - _hierarchyDelimiter = (*it).hierarchyDelimiter(); - if ((*it).noSelect ()) - { - retVal = ITYPE_DIR; - } - else if ((*it).noInferiors ()) - { - retVal = ITYPE_BOX; - } - else - { - retVal = ITYPE_DIR_AND_BOX; - } - } - } - // if we got no list response for the box see if it's a prefix - if ( retVal == ITYPE_UNKNOWN && - namespaceToDelimiter.contains(_box) ) { - retVal = ITYPE_DIR; - } - } else { - kdDebug(7116) << "IMAP4::parseURL - got error for " << _box << endl; - } - completeQueue.removeRef (cmd); - } // cache - } - else // current == box - { - retVal = ITYPE_BOX; - } - } - else - kdDebug(7116) << "IMAP4::parseURL: no login!" << endl; - - } - else // empty box - { - // the root is just a dir - kdDebug(7116) << "IMAP4: parseURL: box [root]" << endl; - retVal = ITYPE_DIR; - } - - // see if it is a real sequence or a simple uid - if (retVal == ITYPE_BOX || retVal == ITYPE_DIR_AND_BOX) - { - if (!_uid.isEmpty ()) - { - if (_uid.find (':') == -1 && _uid.find (',') == -1 - && _uid.find ('*') == -1) - retVal = ITYPE_MSG; - } - } - if (retVal == ITYPE_MSG) - { - if ( (_section.find ("BODY.PEEK[", 0, false) != -1 || - _section.find ("BODY[", 0, false) != -1) && - _section.find(".MIME") == -1 && - _section.find(".HEADER") == -1 ) - retVal = ITYPE_ATTACH; - } - if ( _hierarchyDelimiter.isEmpty() && - (_type == "LIST" || _type == "LSUB" || _type == "LSUBNOCHECK") ) - { - // this shouldn't happen but when the delimiter is really empty - // we try to reconstruct it from the URL - if (!_box.isEmpty()) - { - int start = _url.path().findRev(_box); - if (start != -1) - _hierarchyDelimiter = _url.path().mid(start-1, start); - kdDebug(7116) << "IMAP4::parseURL - reconstructed delimiter:" << _hierarchyDelimiter - << " from URL " << _url.path() << endl; - } - if (_hierarchyDelimiter.isEmpty()) - _hierarchyDelimiter = "/"; - } - kdDebug(7116) << "IMAP4::parseURL - return " << retVal << endl; - - return retVal; -} - -int -IMAP4Protocol::outputLine (const TQCString & _str, int len) -{ - if (len == -1) { - len = _str.length(); - } - - if (cacheOutput) - { - if ( !outputBuffer.isOpen() ) { - outputBuffer.open(IO_WriteOnly); - } - outputBuffer.at(outputBufferIndex); - outputBuffer.writeBlock(_str.data(), len); - outputBufferIndex += len; - return 0; - } - - TQByteArray temp; - bool relay = relayEnabled; - - relayEnabled = true; - temp.setRawData (_str.data (), len); - parseRelay (temp); - temp.resetRawData (_str.data (), len); - - relayEnabled = relay; - return 0; -} - -void IMAP4Protocol::flushOutput(TQString contentEncoding) -{ - // send out cached data to the application - if (outputBufferIndex == 0) - return; - outputBuffer.close(); - outputCache.resize(outputBufferIndex); - if (decodeContent) - { - // get the coding from the MIME header - TQByteArray decoded; - if (contentEncoding.find("quoted-printable", 0, false) == 0) - decoded = KCodecs::quotedPrintableDecode(outputCache); - else if (contentEncoding.find("base64", 0, false) == 0) - KCodecs::base64Decode(outputCache, decoded); - else - decoded = outputCache; - - TQString mimetype = KMimeType::findByContent( decoded )->name(); - kdDebug(7116) << "IMAP4::flushOutput - mimeType " << mimetype << endl; - mimeType(mimetype); - decodeContent = false; - data( decoded ); - } else { - data( outputCache ); - } - mProcessedSize += outputBufferIndex; - processedSize( mProcessedSize ); - outputBufferIndex = 0; - outputCache[0] = '\0'; - outputBuffer.setBuffer(outputCache); -} - -ssize_t IMAP4Protocol::myRead(void *data, ssize_t len) -{ - if (readBufferLen) - { - ssize_t copyLen = (len < readBufferLen) ? len : readBufferLen; - memcpy(data, readBuffer, copyLen); - readBufferLen -= copyLen; - if (readBufferLen) memmove(readBuffer, &readBuffer[copyLen], readBufferLen); - return copyLen; - } - if (!isConnectionValid()) return 0; - waitForResponse( responseTimeout() ); - return read(data, len); -} - -bool -IMAP4Protocol::assureBox (const TQString & aBox, bool readonly) -{ - if (aBox.isEmpty()) return false; - - imapCommand *cmd = 0; - - if (aBox != getCurrentBox () || (!getSelected().readWrite() && !readonly)) - { - // open the box with the appropriate mode - kdDebug(7116) << "IMAP4Protocol::assureBox - opening box" << endl; - selectInfo = imapInfo(); - cmd = doCommand (imapCommand::clientSelect (aBox, readonly)); - bool ok = cmd->result() == "OK"; - TQString cmdInfo = cmd->resultInfo(); - completeQueue.removeRef (cmd); - - if (!ok) - { - bool found = false; - cmd = doCommand (imapCommand::clientList ("", aBox)); - if (cmd->result () == "OK") - { - for (TQValueListIterator < imapList > it = listResponses.begin (); - it != listResponses.end (); ++it) - { - if (aBox == (*it).name ()) found = true; - } - } - completeQueue.removeRef (cmd); - if (found) { - if (cmdInfo.find("permission", 0, false) != -1) { - // not allowed to enter this folder - error(ERR_ACCESS_DENIED, cmdInfo); - } else { - error(ERR_SLAVE_DEFINED, i18n("Unable to open folder %1. The server replied: %2").arg(aBox).arg(cmdInfo)); - } - } else { - error(TDEIO::ERR_DOES_NOT_EXIST, aBox); - } - return false; - } - } - else - { - // Give the server a chance to deliver updates every ten seconds. - // Doing this means a server roundtrip and since assureBox is called - // after every mail, we do it with a timeout. - kdDebug(7116) << "IMAP4Protocol::assureBox - reusing box" << endl; - if ( mTimeOfLastNoop.secsTo( TQDateTime::currentDateTime() ) > 10 ) { - cmd = doCommand (imapCommand::clientNoop ()); - completeQueue.removeRef (cmd); - mTimeOfLastNoop = TQDateTime::currentDateTime(); - kdDebug(7116) << "IMAP4Protocol::assureBox - noop timer fired" << endl; - } - } - - // if it is the mode we want - if (!getSelected().readWrite() && !readonly) - { - error(TDEIO::ERR_CANNOT_OPEN_FOR_WRITING, aBox); - return false; - } - - return true; -} diff --git a/tdeioslave/imap4/imap4.cpp b/tdeioslave/imap4/imap4.cpp new file mode 100644 index 00000000..280cbde7 --- /dev/null +++ b/tdeioslave/imap4/imap4.cpp @@ -0,0 +1,2746 @@ +/********************************************************************** + * + * imap4.cpp - IMAP4rev1 KIOSlave + * Copyright (C) 2001-2002 Michael Haeckel + * Copyright (C) 1999 John Corey + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to jcorey@fruity.ath.cx + * + *********************************************************************/ + +/** + * @class IMAP4Protocol + * @note References: + * - RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 + * - RFC 2192 - IMAP URL Scheme - September 1997 + * - RFC 1731 - IMAP Authentication Mechanisms - December 1994 + * (Discusses KERBEROSv4, GSSAPI, and S/Key) + * - RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response + * - September 1997 (CRAM-MD5 authentication method) + * - RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 + * - RFC 2086 - IMAP4 ACL extension - January 1997 + * - http://www.ietf.org/internet-drafts/draft-daboo-imap-annotatemore-05.txt + * IMAP ANNOTATEMORE draft - April 2004. + * + * + * Supported URLs: + * \verbatim +imap://server/ +imap://user:pass@server/ +imap://user;AUTH=method:pass@server/ +imap://server/folder/ + * \endverbatim + * These URLs cause the following actions (in order): + * - Prompt for user/pass, list all folders in home directory + * - Uses LOGIN to log in + * - Uses AUTHENTICATE to log in + * - List messages in folder + * + * @note API notes: + * Not receiving the required write access for a folder means + * ERR_CANNOT_OPEN_FOR_WRITING. + * ERR_DOES_NOT_EXIST is reserved for folders. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "imap4.h" + +#include "rfcdecoder.h" + +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_LIBSASL2 +extern "C" { +#include +} +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tdepimmacros.h" + +#define IMAP_PROTOCOL "imap" +#define IMAP_SSL_PROTOCOL "imaps" +const int ImapPort = 143; +const int ImapsPort = 993; + +using namespace TDEIO; + +extern "C" +{ + void sigalrm_handler (int); + KDE_EXPORT int kdemain (int argc, char **argv); +} + +int +kdemain (int argc, char **argv) +{ + kdDebug(7116) << "IMAP4::kdemain" << endl; + + TDEInstance instance ("tdeio_imap4"); + if (argc != 4) + { + fprintf(stderr, "Usage: tdeio_imap4 protocol domain-socket1 domain-socket2\n"); + ::exit (-1); + } + +#ifdef HAVE_LIBSASL2 + if ( sasl_client_init( NULL ) != SASL_OK ) { + fprintf(stderr, "SASL library initialization failed!\n"); + ::exit (-1); + } +#endif + + //set debug handler + + IMAP4Protocol *slave; + if (strcasecmp (argv[1], IMAP_SSL_PROTOCOL) == 0) + slave = new IMAP4Protocol (argv[2], argv[3], true); + else if (strcasecmp (argv[1], IMAP_PROTOCOL) == 0) + slave = new IMAP4Protocol (argv[2], argv[3], false); + else + abort (); + slave->dispatchLoop (); + delete slave; + +#ifdef HAVE_LIBSASL2 + sasl_done(); +#endif + + return 0; +} + +void +sigchld_handler (int signo) +{ + // A signal handler that calls for example waitpid has to save errno + // before and restore it afterwards. + // (cf. https://www.securecoding.cert.org/confluence/display/cplusplus/ERR32-CPP.+Do+not+rely+on+indeterminate+values+of+errno) + const int save_errno = errno; + int pid, status; + + while (signo == SIGCHLD) + { + pid = waitpid (-1, &status, WNOHANG); + if (pid <= 0) + { + // Reinstall signal handler, since Linux resets to default after + // the signal occurred ( BSD handles it different, but it should do + // no harm ). + signal (SIGCHLD, sigchld_handler); + break; + } + } + + errno = save_errno; +} + +IMAP4Protocol::IMAP4Protocol (const TQCString & pool, const TQCString & app, bool isSSL):TCPSlaveBase ((isSSL ? 993 : 143), + (isSSL ? IMAP_SSL_PROTOCOL : IMAP_PROTOCOL), pool, + app, isSSL), imapParser (), mimeIO (), outputBuffer(outputCache) +{ + outputBufferIndex = 0; + mySSL = isSSL; + readBuffer[0] = 0x00; + relayEnabled = false; + readBufferLen = 0; + cacheOutput = false; + decodeContent = false; + mTimeOfLastNoop = TQDateTime(); +} + +IMAP4Protocol::~IMAP4Protocol () +{ + closeDescriptor(); + kdDebug(7116) << "IMAP4: Finishing" << endl; +} + +void +IMAP4Protocol::get (const KURL & _url) +{ + if (!makeLogin()) return; + kdDebug(7116) << "IMAP4::get - " << _url.prettyURL() << endl; + TQString aBox, aSequence, aType, aSection, aValidity, aDelimiter, aInfo; + enum IMAP_TYPE aEnum = + parseURL (_url, aBox, aSection, aType, aSequence, aValidity, aDelimiter, aInfo); + if (aEnum != ITYPE_ATTACH) + mimeType (getMimeType(aEnum)); + if (aInfo == "DECODE") + decodeContent = true; + + if (aSequence == "0:0" && getState() == ISTATE_SELECT) + { + imapCommand *cmd = doCommand (imapCommand::clientNoop()); + completeQueue.removeRef(cmd); + } + + if (aSequence.isEmpty ()) + { + aSequence = "1:*"; + } + + mProcessedSize = 0; + imapCommand *cmd = NULL; + if (!assureBox (aBox, true)) return; + +#ifdef USE_VALIDITY + if (selectInfo.uidValidityAvailable () && !aValidity.isEmpty () + && selectInfo.uidValidity () != aValidity.toULong ()) + { + // this url is stale + error (ERR_COULD_NOT_READ, _url.prettyURL()); + return; + } + else +#endif + { + // The "section" specified by the application can be: + // * empty (which means body, size and flags) + // * a known keyword, like STRUCTURE, ENVELOPE, HEADER, BODY.PEEK[...] + // (in which case the slave has some logic to add the necessary items) + // * Otherwise, it specifies the exact data items to request. In this case, all + // the logic is in the app. + + TQString aUpper = aSection.upper(); + if (aUpper.find ("STRUCTURE") != -1) + { + aSection = "BODYSTRUCTURE"; + } + else if (aUpper.find ("ENVELOPE") != -1) + { + aSection = "UID RFC822.SIZE FLAGS ENVELOPE"; + if (hasCapability("IMAP4rev1")) { + aSection += " BODY.PEEK[HEADER.FIELDS (REFERENCES)]"; + } else { + // imap4 does not know HEADER.FIELDS + aSection += " RFC822.HEADER.LINES (REFERENCES)"; + } + } + else if (aUpper == "HEADER") + { + aSection = "UID RFC822.HEADER RFC822.SIZE FLAGS"; + } + else if (aUpper.find ("BODY.PEEK[") != -1) + { + if (aUpper.find ("BODY.PEEK[]") != -1) + { + if (!hasCapability("IMAP4rev1")) // imap4 does not know BODY.PEEK[] + aSection.replace("BODY.PEEK[]", "RFC822.PEEK"); + } + aSection.prepend("UID RFC822.SIZE FLAGS "); + } + else if (aSection.isEmpty()) + { + aSection = "UID BODY[] RFC822.SIZE FLAGS"; + } + if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) + { + // write the digest header + cacheOutput = true; + outputLine + ("Content-Type: multipart/digest; boundary=\"IMAPDIGEST\"\r\n", 55); + if (selectInfo.recentAvailable ()) + outputLineStr ("X-Recent: " + + TQString::number(selectInfo.recent ()) + "\r\n"); + if (selectInfo.countAvailable ()) + outputLineStr ("X-Count: " + TQString::number(selectInfo.count ()) + + "\r\n"); + if (selectInfo.unseenAvailable ()) + outputLineStr ("X-Unseen: " + + TQString::number(selectInfo.unseen ()) + "\r\n"); + if (selectInfo.uidValidityAvailable ()) + outputLineStr ("X-uidValidity: " + + TQString::number(selectInfo.uidValidity ()) + + "\r\n"); + if (selectInfo.uidNextAvailable ()) + outputLineStr ("X-UidNext: " + + TQString::number(selectInfo.uidNext ()) + "\r\n"); + if (selectInfo.flagsAvailable ()) + outputLineStr ("X-Flags: " + TQString::number(selectInfo.flags ()) + + "\r\n"); + if (selectInfo.permanentFlagsAvailable ()) + outputLineStr ("X-PermanentFlags: " + + TQString::number(selectInfo.permanentFlags ()) + "\r\n"); + if (selectInfo.readWriteAvailable ()) { + if (selectInfo.readWrite()) { + outputLine ("X-Access: Read/Write\r\n", 22); + } else { + outputLine ("X-Access: Read only\r\n", 21); + } + } + outputLine ("\r\n", 2); + flushOutput(TQString()); + cacheOutput = false; + } + + if (aEnum == ITYPE_MSG || (aEnum == ITYPE_ATTACH && !decodeContent)) + relayEnabled = true; // normal mode, relay data + + if (aSequence != "0:0") + { + TQString contentEncoding; + if (aEnum == ITYPE_ATTACH && decodeContent) + { + // get the MIME header and fill getLastHandled() + TQString mySection = aSection; + mySection.replace("]", ".MIME]"); + cmd = sendCommand (imapCommand::clientFetch (aSequence, mySection)); + do + { + while (!parseLoop ()) ; + } + while (!cmd->isComplete ()); + completeQueue.removeRef (cmd); + // get the content encoding now because getLastHandled will be cleared + if (getLastHandled() && getLastHandled()->getHeader()) + contentEncoding = getLastHandled()->getHeader()->getEncoding(); + + // from here on collect the data + // it is send to the client in flushOutput in one go + // needed to decode the content + cacheOutput = true; + } + + cmd = sendCommand (imapCommand::clientFetch (aSequence, aSection)); + int res; + aUpper = aSection.upper(); + do + { + while (!(res = parseLoop())) ; + if (res == -1) break; + + mailHeader *lastone = 0; + imapCache *cache = getLastHandled (); + if (cache) + lastone = cache->getHeader (); + + if (cmd && !cmd->isComplete ()) + { + if ((aUpper.find ("BODYSTRUCTURE") != -1) + || (aUpper.find ("FLAGS") != -1) + || (aUpper.find ("UID") != -1) + || (aUpper.find ("ENVELOPE") != -1) + || (aUpper.find ("BODY.PEEK[0]") != -1 + && (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX))) + { + if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) + { + // write the mime header (default is here message/rfc822) + outputLine ("--IMAPDIGEST\r\n", 14); + cacheOutput = true; + if (cache && cache->getUid () != 0) + outputLineStr ("X-UID: " + + TQString::number(cache->getUid ()) + "\r\n"); + if (cache && cache->getSize () != 0) + outputLineStr ("X-Length: " + + TQString::number(cache->getSize ()) + "\r\n"); + if (cache && !cache->getDate ().isEmpty()) + outputLineStr ("X-Date: " + cache->getDate () + "\r\n"); + if (cache && cache->getFlags () != 0) + outputLineStr ("X-Flags: " + + TQString::number(cache->getFlags ()) + "\r\n"); + } else cacheOutput = true; + if ( lastone && !decodeContent ) + lastone->outputPart (*this); + cacheOutput = false; + flushOutput(contentEncoding); + } + } // if not complete + } + while (cmd && !cmd->isComplete ()); + if (aEnum == ITYPE_BOX || aEnum == ITYPE_DIR_AND_BOX) + { + // write the end boundary + outputLine ("--IMAPDIGEST--\r\n", 16); + } + + completeQueue.removeRef (cmd); + } + } + + // just to keep everybody happy when no data arrived + data (TQByteArray ()); + + finished (); + relayEnabled = false; + cacheOutput = false; + kdDebug(7116) << "IMAP4::get - finished" << endl; +} + +void +IMAP4Protocol::listDir (const KURL & _url) +{ + kdDebug(7116) << " IMAP4::listDir - " << _url.prettyURL() << endl; + + if (_url.path().isEmpty()) + { + KURL url = _url; + url.setPath("/"); + redirection( url ); + finished(); + return; + } + + TQString myBox, mySequence, myLType, mySection, myValidity, myDelimiter, myInfo; + // parseURL with caching + enum IMAP_TYPE myType = + parseURL (_url, myBox, mySection, myLType, mySequence, myValidity, + myDelimiter, myInfo, true); + + if (!makeLogin()) return; + + if (myType == ITYPE_DIR || myType == ITYPE_DIR_AND_BOX) + { + TQString listStr = myBox; + imapCommand *cmd; + + if (!listStr.isEmpty () && !listStr.endsWith(myDelimiter) && + mySection != "FOLDERONLY") + listStr += myDelimiter; + + if (mySection.isEmpty()) + { + listStr += "%"; + } else if (mySection == "COMPLETE") { + listStr += "*"; + } + kdDebug(7116) << "IMAP4Protocol::listDir - listStr=" << listStr << endl; + cmd = + doCommand (imapCommand::clientList ("", listStr, + (myLType == "LSUB" || myLType == "LSUBNOCHECK"))); + if (cmd->result () == "OK") + { + TQString mailboxName; + UDSEntry entry; + UDSAtom atom; + KURL aURL = _url; + if (aURL.path().find(';') != -1) + aURL.setPath(aURL.path().left(aURL.path().find(';'))); + + kdDebug(7116) << "IMAP4Protocol::listDir - got " << listResponses.count () << endl; + + if (myLType == "LSUB") + { + // fire the same command as LIST to check if the box really exists + TQValueList listResponsesSave = listResponses; + doCommand (imapCommand::clientList ("", listStr, false)); + for (TQValueListIterator < imapList > it = listResponsesSave.begin (); + it != listResponsesSave.end (); ++it) + { + bool boxOk = false; + for (TQValueListIterator < imapList > it2 = listResponses.begin (); + it2 != listResponses.end (); ++it2) + { + if ((*it2).name() == (*it).name()) + { + boxOk = true; + // copy the flags from the LIST-command + (*it) = (*it2); + break; + } + } + if (boxOk) + doListEntry (aURL, myBox, (*it), (mySection != "FOLDERONLY")); + else // this folder is dead + kdDebug(7116) << "IMAP4Protocol::listDir - suppress " << (*it).name() << endl; + } + listResponses = listResponsesSave; + } + else // LIST or LSUBNOCHECK + { + for (TQValueListIterator < imapList > it = listResponses.begin (); + it != listResponses.end (); ++it) + { + doListEntry (aURL, myBox, (*it), (mySection != "FOLDERONLY")); + } + } + entry.clear (); + listEntry (entry, true); + } + else + { + error (ERR_CANNOT_ENTER_DIRECTORY, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + if ((myType == ITYPE_BOX || myType == ITYPE_DIR_AND_BOX) + && myLType != "LIST" && myLType != "LSUB" && myLType != "LSUBNOCHECK") + { + KURL aURL = _url; + aURL.setQuery (TQString()); + const TQString encodedUrl = aURL.url(0, 106); // utf-8 + + if (!_url.query ().isEmpty ()) + { + TQString query = KURL::decode_string (_url.query ()); + query = query.right (query.length () - 1); + if (!query.isEmpty()) + { + imapCommand *cmd = NULL; + + if (!assureBox (myBox, true)) return; + + if (!selectInfo.countAvailable() || selectInfo.count()) + { + cmd = doCommand (imapCommand::clientSearch (query)); + if (cmd->result() != "OK") + { + error(ERR_UNSUPPORTED_ACTION, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + + TQStringList list = getResults (); + int stretch = 0; + + if (selectInfo.uidNextAvailable ()) + stretch = TQString::number(selectInfo.uidNext ()).length (); + UDSEntry entry; + imapCache fake; + + for (TQStringList::ConstIterator it = list.begin(); it != list.end(); + ++it) + { + fake.setUid((*it).toULong()); + doListEntry (encodedUrl, stretch, &fake); + } + entry.clear (); + listEntry (entry, true); + } + } + } + else + { + if (!assureBox (myBox, true)) return; + + kdDebug(7116) << "IMAP4: select returned:" << endl; + if (selectInfo.recentAvailable ()) + kdDebug(7116) << "Recent: " << selectInfo.recent () << "d" << endl; + if (selectInfo.countAvailable ()) + kdDebug(7116) << "Count: " << selectInfo.count () << "d" << endl; + if (selectInfo.unseenAvailable ()) + kdDebug(7116) << "Unseen: " << selectInfo.unseen () << "d" << endl; + if (selectInfo.uidValidityAvailable ()) + kdDebug(7116) << "uidValidity: " << selectInfo.uidValidity () << "d" << endl; + if (selectInfo.flagsAvailable ()) + kdDebug(7116) << "Flags: " << selectInfo.flags () << "d" << endl; + if (selectInfo.permanentFlagsAvailable ()) + kdDebug(7116) << "PermanentFlags: " << selectInfo.permanentFlags () << "d" << endl; + if (selectInfo.readWriteAvailable ()) + kdDebug(7116) << "Access: " << (selectInfo.readWrite ()? "Read/Write" : "Read only") << endl; + +#ifdef USE_VALIDITY + if (selectInfo.uidValidityAvailable () + && selectInfo.uidValidity () != myValidity.toULong ()) + { + //redirect + KURL newUrl = _url; + + newUrl.setPath ("/" + myBox + ";UIDVALIDITY=" + + TQString::number(selectInfo.uidValidity ())); + kdDebug(7116) << "IMAP4::listDir - redirecting to " << newUrl.prettyURL() << endl; + redirection (newUrl); + + + } + else +#endif + if (selectInfo.count () > 0) + { + int stretch = 0; + + if (selectInfo.uidNextAvailable ()) + stretch = TQString::number(selectInfo.uidNext ()).length (); + // kdDebug(7116) << selectInfo.uidNext() << "d used to stretch " << stretch << endl; + UDSEntry entry; + + if (mySequence.isEmpty()) mySequence = "1:*"; + + bool withSubject = mySection.isEmpty(); + if (mySection.isEmpty()) mySection = "UID RFC822.SIZE ENVELOPE"; + + bool withFlags = mySection.upper().find("FLAGS") != -1; + imapCommand *fetch = + sendCommand (imapCommand:: + clientFetch (mySequence, mySection)); + imapCache *cache; + do + { + while (!parseLoop ()) ; + + cache = getLastHandled (); + + if (cache && !fetch->isComplete()) + doListEntry (encodedUrl, stretch, cache, withFlags, withSubject); + } + while (!fetch->isComplete ()); + entry.clear (); + listEntry (entry, true); + } + } + } + if ( !selectInfo.alert().isNull() ) { + if ( !myBox.isEmpty() ) { + warning( i18n( "Message from %1 while processing '%2': %3" ).arg( myHost, myBox, selectInfo.alert() ) ); + } else { + warning( i18n( "Message from %1: %2" ).arg( myHost, TQString(selectInfo.alert()) ) ); + } + selectInfo.setAlert( 0 ); + } + + kdDebug(7116) << "IMAP4Protocol::listDir - Finishing listDir" << endl; + finished (); +} + +void +IMAP4Protocol::setHost (const TQString & _host, int _port, + const TQString & _user, const TQString & _pass) +{ + if (myHost != _host || myPort != _port || myUser != _user || myPass != _pass) + { // what's the point of doing 4 string compares to avoid 4 string copies? + // DF: I guess to avoid calling closeConnection() unnecessarily. + if (!myHost.isEmpty ()) + closeConnection (); + myHost = _host; + if (_port == 0) + myPort = (mySSL) ? ImapsPort : ImapPort; + else + myPort = _port; + myUser = _user; + myPass = _pass; + } +} + +void +IMAP4Protocol::parseRelay (const TQByteArray & buffer) +{ + if (relayEnabled) { + // relay data immediately + data( buffer ); + mProcessedSize += buffer.size(); + processedSize( mProcessedSize ); + } else if (cacheOutput) + { + // collect data + if ( !outputBuffer.isOpen() ) { + outputBuffer.open(IO_WriteOnly); + } + outputBuffer.at(outputBufferIndex); + outputBuffer.writeBlock(buffer, buffer.size()); + outputBufferIndex += buffer.size(); + } +} + +void +IMAP4Protocol::parseRelay (ulong len) +{ + if (relayEnabled) + totalSize (len); +} + + +bool IMAP4Protocol::parseRead(TQByteArray & buffer, ulong len, ulong relay) +{ + char buf[8192]; + while (buffer.size() < len) + { + ssize_t readLen = myRead(buf, TQMIN(len - buffer.size(), sizeof(buf) - 1)); + if (readLen == 0) + { + kdDebug(7116) << "parseRead: readLen == 0 - connection broken" << endl; + error (ERR_CONNECTION_BROKEN, myHost); + setState(ISTATE_CONNECT); + closeConnection(); + return FALSE; + } + if (relay > buffer.size()) + { + TQByteArray relayData; + ssize_t relbuf = relay - buffer.size(); + int currentRelay = TQMIN(relbuf, readLen); + relayData.setRawData(buf, currentRelay); + parseRelay(relayData); + relayData.resetRawData(buf, currentRelay); + } + { + TQBuffer stream (buffer); + stream.open (IO_WriteOnly); + stream.at (buffer.size ()); + stream.writeBlock (buf, readLen); + stream.close (); + } + } + return (buffer.size() == len); +} + + +bool IMAP4Protocol::parseReadLine (TQByteArray & buffer, ulong relay) +{ + if (myHost.isEmpty()) return FALSE; + + while (true) { + ssize_t copyLen = 0; + if (readBufferLen > 0) + { + while (copyLen < readBufferLen && readBuffer[copyLen] != '\n') copyLen++; + if (copyLen < readBufferLen) copyLen++; + if (relay > 0) + { + TQByteArray relayData; + + if (copyLen < (ssize_t) relay) + relay = copyLen; + relayData.setRawData (readBuffer, relay); + parseRelay (relayData); + relayData.resetRawData (readBuffer, relay); +// kdDebug(7116) << "relayed : " << relay << "d" << endl; + } + // append to buffer + { + TQBuffer stream (buffer); + + stream.open (IO_WriteOnly); + stream.at (buffer.size ()); + stream.writeBlock (readBuffer, copyLen); + stream.close (); +// kdDebug(7116) << "appended " << copyLen << "d got now " << buffer.size() << endl; + } + + readBufferLen -= copyLen; + if (readBufferLen) + memmove(readBuffer, &readBuffer[copyLen], readBufferLen); + if (buffer[buffer.size() - 1] == '\n') return TRUE; + } + if (!isConnectionValid()) + { + kdDebug(7116) << "parseReadLine - connection broken" << endl; + error (ERR_CONNECTION_BROKEN, myHost); + setState(ISTATE_CONNECT); + closeConnection(); + return FALSE; + } + if (!waitForResponse( responseTimeout() )) + { + error(ERR_SERVER_TIMEOUT, myHost); + setState(ISTATE_CONNECT); + closeConnection(); + return FALSE; + } + readBufferLen = read(readBuffer, IMAP_BUFFER - 1); + if (readBufferLen == 0) + { + kdDebug(7116) << "parseReadLine: readBufferLen == 0 - connection broken" << endl; + error (ERR_CONNECTION_BROKEN, myHost); + setState(ISTATE_CONNECT); + closeConnection(); + return FALSE; + } + } +} + +void +IMAP4Protocol::setSubURL (const KURL & _url) +{ + kdDebug(7116) << "IMAP4::setSubURL - " << _url.prettyURL() << endl; + TDEIO::TCPSlaveBase::setSubURL (_url); +} + +void +IMAP4Protocol::put (const KURL & _url, int, bool, bool) +{ + kdDebug(7116) << "IMAP4::put - " << _url.prettyURL() << endl; +// TDEIO::TCPSlaveBase::put(_url,permissions,overwrite,resume); + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + enum IMAP_TYPE aType = + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + + // see if it is a box + if (aType != ITYPE_BOX && aType != ITYPE_DIR_AND_BOX) + { + if (aBox[aBox.length () - 1] == '/') + aBox = aBox.right (aBox.length () - 1); + imapCommand *cmd = doCommand (imapCommand::clientCreate (aBox)); + + if (cmd->result () != "OK") { + error (ERR_COULD_NOT_WRITE, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + else + { + TQPtrList < TQByteArray > bufferList; + int length = 0; + + int result; + // Loop until we got 'dataEnd' + do + { + TQByteArray *buffer = new TQByteArray (); + dataReq (); // Request for data + result = readData (*buffer); + if (result > 0) + { + bufferList.append (buffer); + length += result; + } else { + delete buffer; + } + } + while (result > 0); + + if (result != 0) + { + error (ERR_ABORTED, _url.prettyURL()); + return; + } + + imapCommand *cmd = + sendCommand (imapCommand::clientAppend (aBox, aSection, length)); + while (!parseLoop ()) ; + + // see if server is waiting + if (!cmd->isComplete () && !getContinuation ().isEmpty ()) + { + bool sendOk = true; + ulong wrote = 0; + + TQByteArray *buffer; + // send data to server + while (!bufferList.isEmpty () && sendOk) + { + buffer = bufferList.take (0); + + sendOk = + (write (buffer->data (), buffer->size ()) == + (ssize_t) buffer->size ()); + wrote += buffer->size (); + processedSize(wrote); + delete buffer; + if (!sendOk) + { + error (ERR_CONNECTION_BROKEN, myHost); + completeQueue.removeRef (cmd); + setState(ISTATE_CONNECT); + closeConnection(); + return; + } + } + parseWriteLine (""); + // Wait until cmd is complete, or connection breaks. + while (!cmd->isComplete () && getState() != ISTATE_NO) + parseLoop (); + if ( getState() == ISTATE_NO ) { + // TODO KDE4: pass cmd->resultInfo() as third argument. + // ERR_CONNECTION_BROKEN expects a host, no way to pass details about the problem. + error( ERR_CONNECTION_BROKEN, myHost ); + completeQueue.removeRef (cmd); + closeConnection(); + return; + } + else if (cmd->result () != "OK") { + error( ERR_SLAVE_DEFINED, cmd->resultInfo() ); + completeQueue.removeRef (cmd); + return; + } + else + { + if (hasCapability("UIDPLUS")) + { + TQString uid = cmd->resultInfo(); + if (uid.find("APPENDUID") != -1) + { + uid = uid.section(" ", 2, 2); + uid.truncate(uid.length()-1); + infoMessage("UID "+uid); + } + } + // MUST reselect to get the new message + else if (aBox == getCurrentBox ()) + { + cmd = + doCommand (imapCommand:: + clientSelect (aBox, !selectInfo.readWrite ())); + completeQueue.removeRef (cmd); + } + } + } + else + { + //error (ERR_COULD_NOT_WRITE, myHost); + // Better ship the error message, e.g. "Over Quota" + error (ERR_SLAVE_DEFINED, cmd->resultInfo()); + completeQueue.removeRef (cmd); + return; + } + + completeQueue.removeRef (cmd); + } + + finished (); +} + +void +IMAP4Protocol::mkdir (const KURL & _url, int) +{ + kdDebug(7116) << "IMAP4::mkdir - " << _url.prettyURL() << endl; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL(_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + kdDebug(7116) << "IMAP4::mkdir - create " << aBox << endl; + imapCommand *cmd = doCommand (imapCommand::clientCreate(aBox)); + + if (cmd->result () != "OK") + { + kdDebug(7116) << "IMAP4::mkdir - " << cmd->resultInfo() << endl; + error (ERR_COULD_NOT_MKDIR, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + + // start a new listing to find the type of the folder + enum IMAP_TYPE type = + parseURL(_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + if (type == ITYPE_BOX) + { + bool ask = ( aInfo.find( "ASKUSER" ) != -1 ); + if ( ask && + messageBox(QuestionYesNo, + i18n("The following folder will be created on the server: %1 " + "What do you want to store in this folder?").arg( aBox ), + i18n("Create Folder"), + i18n("&Messages"), i18n("&Subfolders")) == KMessageBox::No ) + { + cmd = doCommand(imapCommand::clientDelete(aBox)); + completeQueue.removeRef (cmd); + cmd = doCommand(imapCommand::clientCreate(aBox + aDelimiter)); + if (cmd->result () != "OK") + { + error (ERR_COULD_NOT_MKDIR, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + } + + cmd = doCommand(imapCommand::clientSubscribe(aBox)); + completeQueue.removeRef(cmd); + + finished (); +} + +void +IMAP4Protocol::copy (const KURL & src, const KURL & dest, int, bool overwrite) +{ + kdDebug(7116) << "IMAP4::copy - [" << (overwrite ? "Overwrite" : "NoOverwrite") << "] " << src.prettyURL() << " -> " << dest.prettyURL() << endl; + TQString sBox, sSequence, sLType, sSection, sValidity, sDelimiter, sInfo; + TQString dBox, dSequence, dLType, dSection, dValidity, dDelimiter, dInfo; + enum IMAP_TYPE sType = + parseURL (src, sBox, sSection, sLType, sSequence, sValidity, sDelimiter, sInfo); + enum IMAP_TYPE dType = + parseURL (dest, dBox, dSection, dLType, dSequence, dValidity, dDelimiter, dInfo); + + // see if we have to create anything + if (dType != ITYPE_BOX && dType != ITYPE_DIR_AND_BOX) + { + // this might be konqueror + int sub = dBox.find (sBox); + + // might be moving to upper folder + if (sub > 0) + { + KURL testDir = dest; + + TQString subDir = dBox.right (dBox.length () - dBox.findRev ('/')); + TQString topDir = dBox.left (sub); + testDir.setPath ("/" + topDir); + dType = + parseURL (testDir, topDir, dSection, dLType, dSequence, dValidity, + dDelimiter, dInfo); + + kdDebug(7116) << "IMAP4::copy - checking this destination " << topDir << endl; + // see if this is what the user wants + if (dType == ITYPE_BOX || dType == ITYPE_DIR_AND_BOX) + { + kdDebug(7116) << "IMAP4::copy - assuming this destination " << topDir << endl; + dBox = topDir; + } + else + { + + // maybe if we create a new mailbox + topDir = "/" + topDir + subDir; + testDir.setPath (topDir); + kdDebug(7116) << "IMAP4::copy - checking this destination " << topDir << endl; + dType = + parseURL (testDir, topDir, dSection, dLType, dSequence, dValidity, + dDelimiter, dInfo); + if (dType != ITYPE_BOX && dType != ITYPE_DIR_AND_BOX) + { + // ok then we'll create a mailbox + imapCommand *cmd = doCommand (imapCommand::clientCreate (topDir)); + + // on success we'll use it, else we'll just try to create the given dir + if (cmd->result () == "OK") + { + kdDebug(7116) << "IMAP4::copy - assuming this destination " << topDir << endl; + dType = ITYPE_BOX; + dBox = topDir; + } + else + { + completeQueue.removeRef (cmd); + cmd = doCommand (imapCommand::clientCreate (dBox)); + if (cmd->result () == "OK") + dType = ITYPE_BOX; + else + error (ERR_COULD_NOT_WRITE, dest.prettyURL()); + } + completeQueue.removeRef (cmd); + } + } + + } + } + if (sType == ITYPE_MSG || sType == ITYPE_BOX || sType == ITYPE_DIR_AND_BOX) + { + //select the source box + if (!assureBox(sBox, true)) return; + kdDebug(7116) << "IMAP4::copy - " << sBox << " -> " << dBox << endl; + + //issue copy command + imapCommand *cmd = + doCommand (imapCommand::clientCopy (dBox, sSequence)); + if (cmd->result () != "OK") + { + kdError(5006) << "IMAP4::copy - " << cmd->resultInfo() << endl; + error (ERR_COULD_NOT_WRITE, dest.prettyURL()); + completeQueue.removeRef (cmd); + return; + } else { + if (hasCapability("UIDPLUS")) + { + TQString uid = cmd->resultInfo(); + if (uid.find("COPYUID") != -1) + { + uid = uid.section(" ", 2, 3); + uid.truncate(uid.length()-1); + infoMessage("UID "+uid); + } + } + } + completeQueue.removeRef (cmd); + } + else + { + error (ERR_ACCESS_DENIED, src.prettyURL()); + return; + } + finished (); +} + +void +IMAP4Protocol::del (const KURL & _url, bool isFile) +{ + kdDebug(7116) << "IMAP4::del - [" << (isFile ? "File" : "NoFile") << "] " << _url.prettyURL() << endl; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + enum IMAP_TYPE aType = + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + + switch (aType) + { + case ITYPE_BOX: + case ITYPE_DIR_AND_BOX: + if (!aSequence.isEmpty ()) + { + if (aSequence == "*") + { + if (!assureBox (aBox, false)) return; + imapCommand *cmd = doCommand (imapCommand::clientExpunge ()); + if (cmd->result () != "OK") { + error (ERR_CANNOT_DELETE, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + else + { + // if open for read/write + if (!assureBox (aBox, false)) return; + imapCommand *cmd = + doCommand (imapCommand:: + clientStore (aSequence, "+FLAGS.SILENT", "\\DELETED")); + if (cmd->result () != "OK") { + error (ERR_CANNOT_DELETE, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + } + else + { + if (getCurrentBox() == aBox) + { + imapCommand *cmd = doCommand(imapCommand::clientClose()); + completeQueue.removeRef(cmd); + setState(ISTATE_LOGIN); + } + // We unsubscribe, otherwise we get ghost folders on UW-IMAP + imapCommand *cmd = doCommand(imapCommand::clientUnsubscribe(aBox)); + completeQueue.removeRef(cmd); + cmd = doCommand(imapCommand::clientDelete (aBox)); + // If this doesn't work, we try to empty the mailbox first + if (cmd->result () != "OK") + { + completeQueue.removeRef(cmd); + if (!assureBox(aBox, false)) return; + bool stillOk = true; + if (stillOk) + { + imapCommand *cmd = doCommand( + imapCommand::clientStore("1:*", "+FLAGS.SILENT", "\\DELETED")); + if (cmd->result () != "OK") stillOk = false; + completeQueue.removeRef(cmd); + } + if (stillOk) + { + imapCommand *cmd = doCommand(imapCommand::clientClose()); + if (cmd->result () != "OK") stillOk = false; + completeQueue.removeRef(cmd); + setState(ISTATE_LOGIN); + } + if (stillOk) + { + imapCommand *cmd = doCommand (imapCommand::clientDelete(aBox)); + if (cmd->result () != "OK") stillOk = false; + completeQueue.removeRef(cmd); + } + if (!stillOk) + { + error (ERR_COULD_NOT_RMDIR, _url.prettyURL()); + return; + } + } else { + completeQueue.removeRef (cmd); + } + } + break; + + case ITYPE_DIR: + { + imapCommand *cmd = doCommand (imapCommand::clientDelete (aBox)); + if (cmd->result () != "OK") { + error (ERR_COULD_NOT_RMDIR, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + break; + + case ITYPE_MSG: + { + // if open for read/write + if (!assureBox (aBox, false)) return; + imapCommand *cmd = + doCommand (imapCommand:: + clientStore (aSequence, "+FLAGS.SILENT", "\\DELETED")); + if (cmd->result () != "OK") { + error (ERR_CANNOT_DELETE, _url.prettyURL()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + break; + + case ITYPE_UNKNOWN: + case ITYPE_ATTACH: + error (ERR_CANNOT_DELETE, _url.prettyURL()); + break; + } + finished (); +} + +/* + * Copy a mail: data = 'C' + srcURL (KURL) + destURL (KURL) + * Capabilities: data = 'c'. Result shipped in infoMessage() signal + * No-op: data = 'N' + * Namespace: data = 'n'. Result shipped in infoMessage() signal + * The format is: section=namespace=delimiter + * Note that the namespace can be empty + * Unsubscribe: data = 'U' + URL (KURL) + * Subscribe: data = 'u' + URL (KURL) + * Change the status: data = 'S' + URL (KURL) + Flags (TQCString) + * ACL commands: data = 'A' + command + URL (KURL) + command-dependent args + * AnnotateMore commands: data = 'M' + 'G'et/'S'et + URL + entry + command-dependent args + * Search: data = 'E' + URL (KURL) + * Quota commands: data = 'Q' + 'R'oot/'G'et/'S'et + URL + entry + command-dependent args + * Custom command: data = 'X' + 'N'ormal/'E'xtended + command + command-dependent args + */ +void +IMAP4Protocol::special (const TQByteArray & aData) +{ + kdDebug(7116) << "IMAP4Protocol::special" << endl; + if (!makeLogin()) return; + + TQDataStream stream(aData, IO_ReadOnly); + + int tmp; + stream >> tmp; + + switch (tmp) { + case 'C': + { + // copy + KURL src; + KURL dest; + stream >> src >> dest; + copy(src, dest, 0, FALSE); + break; + } + case 'c': + { + // capabilities + infoMessage(imapCapabilities.join(" ")); + finished(); + break; + } + case 'N': + { + // NOOP + imapCommand *cmd = doCommand(imapCommand::clientNoop()); + if (cmd->result () != "OK") + { + kdDebug(7116) << "NOOP did not succeed - connection broken" << endl; + completeQueue.removeRef (cmd); + error (ERR_CONNECTION_BROKEN, myHost); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'n': + { + // namespace in the form "section=namespace=delimiter" + // entries are separated by , + infoMessage( imapNamespaces.join(",") ); + finished(); + break; + } + case 'U': + { + // unsubscribe + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + imapCommand *cmd = doCommand(imapCommand::clientUnsubscribe(aBox)); + if (cmd->result () != "OK") + { + completeQueue.removeRef (cmd); + error(ERR_SLAVE_DEFINED, i18n("Unsubscribe of folder %1 " + "failed. The server returned: %2") + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'u': + { + // subscribe + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + imapCommand *cmd = doCommand(imapCommand::clientSubscribe(aBox)); + if (cmd->result () != "OK") + { + completeQueue.removeRef (cmd); + error(ERR_SLAVE_DEFINED, i18n("Subscribe of folder %1 " + "failed. The server returned: %2") + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'A': + { + // acl + int cmd; + stream >> cmd; + if ( hasCapability( "ACL" ) ) { + specialACLCommand( cmd, stream ); + } else { + error( ERR_UNSUPPORTED_ACTION, "ACL" ); + } + break; + } + case 'M': + { + // annotatemore + int cmd; + stream >> cmd; + if ( hasCapability( "ANNOTATEMORE" ) ) { + specialAnnotateMoreCommand( cmd, stream ); + } else { + error( ERR_UNSUPPORTED_ACTION, "ANNOTATEMORE" ); + } + break; + } + case 'Q': + { + // quota + int cmd; + stream >> cmd; + if ( hasCapability( "QUOTA" ) ) { + specialQuotaCommand( cmd, stream ); + } else { + error( ERR_UNSUPPORTED_ACTION, "QUOTA" ); + } + break; + } + case 'S': + { + // status + KURL _url; + TQCString newFlags; + stream >> _url >> newFlags; + + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + if (!assureBox(aBox, false)) return; + + // make sure we only touch flags we know + TQCString knownFlags = "\\SEEN \\ANSWERED \\FLAGGED \\DRAFT"; + const imapInfo info = getSelected(); + if ( info.permanentFlagsAvailable() && (info.permanentFlags() & imapInfo::User) ) { + knownFlags += " KMAILFORWARDED KMAILTODO KMAILWATCHED KMAILIGNORED $FORWARDED $TODO $WATCHED $IGNORED"; + } + + imapCommand *cmd = doCommand (imapCommand:: + clientStore (aSequence, "-FLAGS.SILENT", knownFlags)); + if (cmd->result () != "OK") + { + completeQueue.removeRef (cmd); + error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " + "failed.").arg(_url.prettyURL())); + return; + } + completeQueue.removeRef (cmd); + if (!newFlags.isEmpty()) + { + cmd = doCommand (imapCommand:: + clientStore (aSequence, "+FLAGS.SILENT", newFlags)); + if (cmd->result () != "OK") + { + completeQueue.removeRef (cmd); + error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " + "failed.").arg(_url.prettyURL())); + return; + } + completeQueue.removeRef (cmd); + } + finished(); + break; + } + case 's': + { + // seen + KURL _url; + bool seen; + TQCString newFlags; + stream >> _url >> seen; + + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + if ( !assureBox(aBox, true) ) // read-only because changing SEEN should be possible even then + return; + + imapCommand *cmd; + if ( seen ) + cmd = doCommand( imapCommand::clientStore( aSequence, "+FLAGS.SILENT", "\\SEEN" ) ); + else + cmd = doCommand( imapCommand::clientStore( aSequence, "-FLAGS.SILENT", "\\SEEN" ) ); + + if (cmd->result () != "OK") + { + completeQueue.removeRef (cmd); + error(ERR_COULD_NOT_WRITE, i18n("Changing the flags of message %1 " + "failed.").arg(_url.prettyURL())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + + case 'E': + { + // search + specialSearchCommand( stream ); + break; + } + case 'X': + { + // custom command + specialCustomCommand( stream ); + break; + } + default: + kdWarning(7116) << "Unknown command in special(): " << tmp << endl; + error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(tmp)) ); + break; + } +} + +void +IMAP4Protocol::specialACLCommand( int command, TQDataStream& stream ) +{ + // All commands start with the URL to the box + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + + switch( command ) { + case 'S': // SETACL + { + TQString user, acl; + stream >> user >> acl; + kdDebug(7116) << "SETACL " << aBox << " " << user << " " << acl << endl; + imapCommand *cmd = doCommand(imapCommand::clientSetACL(aBox, user, acl)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Setting the Access Control List on folder %1 " + "for user %2 failed. The server returned: %3") + .arg(_url.prettyURL()) + .arg(user) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'D': // DELETEACL + { + TQString user; + stream >> user; + kdDebug(7116) << "DELETEACL " << aBox << " " << user << endl; + imapCommand *cmd = doCommand(imapCommand::clientDeleteACL(aBox, user)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Deleting the Access Control List on folder %1 " + "for user %2 failed. The server returned: %3") + .arg(_url.prettyURL()) + .arg(user) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'G': // GETACL + { + kdDebug(7116) << "GETACL " << aBox << endl; + imapCommand *cmd = doCommand(imapCommand::clientGetACL(aBox)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Retrieving the Access Control List on folder %1 " + "failed. The server returned: %2") + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + // Returning information to the application from a special() command isn't easy. + // I'm reusing the infoMessage trick seen above (for capabilities), but this + // limits me to a string instead of a stringlist. Using DQUOTE as separator, + // because it's forbidden in userids by rfc3501 + kdDebug(7116) << getResults() << endl; + infoMessage(getResults().join( "\"" )); + finished(); + break; + } + case 'L': // LISTRIGHTS + { + // Do we need this one? It basically shows which rights are tied together, but that's all? + error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); + break; + } + case 'M': // MYRIGHTS + { + kdDebug(7116) << "MYRIGHTS " << aBox << endl; + imapCommand *cmd = doCommand(imapCommand::clientMyRights(aBox)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Retrieving the Access Control List on folder %1 " + "failed. The server returned: %2") + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + TQStringList lst = getResults(); + kdDebug(7116) << "myrights results: " << lst << endl; + if ( !lst.isEmpty() ) { + Q_ASSERT( lst.count() == 1 ); + infoMessage( lst.first() ); + } + finished(); + break; + } + default: + kdWarning(7116) << "Unknown special ACL command:" << command << endl; + error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); + } +} + +void +IMAP4Protocol::specialSearchCommand( TQDataStream& stream ) +{ + kdDebug(7116) << "IMAP4Protocol::specialSearchCommand" << endl; + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + if (!assureBox(aBox, true)) return; + + imapCommand *cmd = doCommand (imapCommand::clientSearch( aSection )); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Searching of folder %1 " + "failed. The server returned: %2") + .arg(aBox) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef(cmd); + TQStringList lst = getResults(); + kdDebug(7116) << "IMAP4Protocol::specialSearchCommand '" << aSection << + "' returns " << lst << endl; + infoMessage( lst.join( " " ) ); + + finished(); +} + +void +IMAP4Protocol::specialCustomCommand( TQDataStream& stream ) +{ + kdDebug(7116) << "IMAP4Protocol::specialCustomCommand" << endl; + + TQString command, arguments; + int type; + stream >> type; + stream >> command >> arguments; + + /** + * In 'normal' mode we send the command with all information in one go + * and retrieve the result. + */ + if ( type == 'N' ) { + kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: normal mode" << endl; + imapCommand *cmd = doCommand (imapCommand::clientCustom( command, arguments )); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Custom command %1:%2 " + "failed. The server returned: %3") + .arg(command) + .arg(arguments) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef(cmd); + TQStringList lst = getResults(); + kdDebug(7116) << "IMAP4Protocol::specialCustomCommand '" << command << + ":" << arguments << + "' returns " << lst << endl; + infoMessage( lst.join( " " ) ); + + finished(); + } else + /** + * In 'extended' mode we send a first header and push the data of the request in + * streaming mode. + */ + if ( type == 'E' ) { + kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: extended mode" << endl; + imapCommand *cmd = sendCommand (imapCommand::clientCustom( command, TQString() )); + while ( !parseLoop () ) ; + + // see if server is waiting + if (!cmd->isComplete () && !getContinuation ().isEmpty ()) + { + const TQByteArray buffer = arguments.utf8(); + + // send data to server + bool sendOk = (write (buffer.data (), buffer.size ()) == (ssize_t)buffer.size ()); + processedSize( buffer.size() ); + + if ( !sendOk ) { + error ( ERR_CONNECTION_BROKEN, myHost ); + completeQueue.removeRef ( cmd ); + setState(ISTATE_CONNECT); + closeConnection(); + return; + } + } + parseWriteLine (""); + + do + { + while (!parseLoop ()) ; + } + while (!cmd->isComplete ()); + + completeQueue.removeRef (cmd); + + TQStringList lst = getResults(); + kdDebug(7116) << "IMAP4Protocol::specialCustomCommand: returns " << lst << endl; + infoMessage( lst.join( " " ) ); + + finished (); + } +} + +void +IMAP4Protocol::specialAnnotateMoreCommand( int command, TQDataStream& stream ) +{ + // All commands start with the URL to the box + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + + switch( command ) { + case 'S': // SETANNOTATION + { + // Params: + // KURL URL of the mailbox + // TQString entry (should be an actual entry name, no % or *; empty for server entries) + // TQMap attributes (name and value) + TQString entry; + TQMap attributes; + stream >> entry >> attributes; + kdDebug(7116) << "SETANNOTATION " << aBox << " " << entry << " " << attributes.count() << " attributes" << endl; + imapCommand *cmd = doCommand(imapCommand::clientSetAnnotation(aBox, entry, attributes)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Setting the annotation %1 on folder %2 " + " failed. The server returned: %3") + .arg(entry) + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + completeQueue.removeRef (cmd); + finished(); + break; + } + case 'G': // GETANNOTATION. + { + // Params: + // KURL URL of the mailbox + // TQString entry (should be an actual entry name, no % or *; empty for server entries) + // TQStringList attributes (list of attributes to be retrieved, possibly with % or *) + TQString entry; + TQStringList attributeNames; + stream >> entry >> attributeNames; + kdDebug(7116) << "GETANNOTATION " << aBox << " " << entry << " " << attributeNames << endl; + imapCommand *cmd = doCommand(imapCommand::clientGetAnnotation(aBox, entry, attributeNames)); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Retrieving the annotation %1 on folder %2 " + "failed. The server returned: %3") + .arg(entry) + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + // Returning information to the application from a special() command isn't easy. + // I'm reusing the infoMessage trick seen above (for capabilities and acls), but this + // limits me to a string instead of a stringlist. Let's use \r as separator. + kdDebug(7116) << getResults() << endl; + infoMessage(getResults().join( "\r" )); + finished(); + break; + } + default: + kdWarning(7116) << "Unknown special annotate command:" << command << endl; + error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); + } +} + +void +IMAP4Protocol::specialQuotaCommand( int command, TQDataStream& stream ) +{ + // All commands start with the URL to the box + KURL _url; + stream >> _url; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, aInfo); + + switch( command ) { + case 'R': // GETQUOTAROOT + { + kdDebug(7116) << "QUOTAROOT " << aBox << endl; + imapCommand *cmd = doCommand(imapCommand::clientGetQuotaroot( aBox ) ); + if (cmd->result () != "OK") + { + error(ERR_SLAVE_DEFINED, i18n("Retrieving the quota root information on folder %1 " + "failed. The server returned: %2") + .arg(_url.prettyURL()) + .arg(cmd->resultInfo())); + return; + } + infoMessage(getResults().join( "\r" )); + finished(); + break; + } + case 'G': // GETQUOTA + { + kdDebug(7116) << "GETQUOTA command" << endl; + kdWarning(7116) << "UNIMPLEMENTED" << endl; + break; + } + case 'S': // SETQUOTA + { + kdDebug(7116) << "SETQUOTA command" << endl; + kdWarning(7116) << "UNIMPLEMENTED" << endl; + break; + } + default: + kdWarning(7116) << "Unknown special quota command:" << command << endl; + error( ERR_UNSUPPORTED_ACTION, TQString(TQChar(command)) ); + } +} + +void +IMAP4Protocol::rename (const KURL & src, const KURL & dest, bool overwrite) +{ + kdDebug(7116) << "IMAP4::rename - [" << (overwrite ? "Overwrite" : "NoOverwrite") << "] " << src.prettyURL() << " -> " << dest.prettyURL() << endl; + TQString sBox, sSequence, sLType, sSection, sValidity, sDelimiter, sInfo; + TQString dBox, dSequence, dLType, dSection, dValidity, dDelimiter, dInfo; + enum IMAP_TYPE sType = + parseURL (src, sBox, sSection, sLType, sSequence, sValidity, sDelimiter, sInfo, false); + enum IMAP_TYPE dType = + parseURL (dest, dBox, dSection, dLType, dSequence, dValidity, dDelimiter, dInfo, false); + + if (dType == ITYPE_UNKNOWN) + { + switch (sType) + { + case ITYPE_BOX: + case ITYPE_DIR: + case ITYPE_DIR_AND_BOX: + { + if (getState() == ISTATE_SELECT && sBox == getCurrentBox()) + { + kdDebug(7116) << "IMAP4::rename - close " << getCurrentBox() << endl; + // mailbox can only be renamed if it is closed + imapCommand *cmd = doCommand (imapCommand::clientClose()); + bool ok = cmd->result() == "OK"; + completeQueue.removeRef(cmd); + if (!ok) + { + kdWarning(7116) << "Unable to close mailbox!" << endl; + error(ERR_CANNOT_RENAME, src.path()); + return; + } + setState(ISTATE_LOGIN); + } + imapCommand *cmd = doCommand (imapCommand::clientRename (sBox, dBox)); + if (cmd->result () != "OK") { + error (ERR_CANNOT_RENAME, src.path()); + completeQueue.removeRef (cmd); + return; + } + completeQueue.removeRef (cmd); + } + break; + + case ITYPE_MSG: + case ITYPE_ATTACH: + case ITYPE_UNKNOWN: + error (ERR_CANNOT_RENAME, src.path()); + break; + } + } + else + { + error (ERR_CANNOT_RENAME, src.path()); + return; + } + finished (); +} + +void +IMAP4Protocol::slave_status () +{ + bool connected = (getState() != ISTATE_NO) && isConnectionValid(); + kdDebug(7116) << "IMAP4::slave_status " << connected << endl; + slaveStatus ( connected ? myHost : TQString(), connected ); +} + +void +IMAP4Protocol::dispatch (int command, const TQByteArray & data) +{ + kdDebug(7116) << "IMAP4::dispatch - command=" << command << endl; + TDEIO::TCPSlaveBase::dispatch (command, data); +} + +void +IMAP4Protocol::stat (const KURL & _url) +{ + kdDebug(7116) << "IMAP4::stat - " << _url.prettyURL() << endl; + TQString aBox, aSequence, aLType, aSection, aValidity, aDelimiter, aInfo; + // parseURL with caching + enum IMAP_TYPE aType = + parseURL (_url, aBox, aSection, aLType, aSequence, aValidity, aDelimiter, + aInfo, true); + + UDSEntry entry; + UDSAtom atom; + + atom.m_uds = UDS_NAME; + atom.m_str = aBox; + entry.append (atom); + + if (!aSection.isEmpty()) + { + if (getState() == ISTATE_SELECT && aBox == getCurrentBox()) + { + imapCommand *cmd = doCommand (imapCommand::clientClose()); + bool ok = cmd->result() == "OK"; + completeQueue.removeRef(cmd); + if (!ok) + { + error(ERR_COULD_NOT_STAT, aBox); + return; + } + setState(ISTATE_LOGIN); + } + bool ok = false; + TQString cmdInfo; + if (aType == ITYPE_MSG || aType == ITYPE_ATTACH) + ok = true; + else + { + imapCommand *cmd = doCommand(imapCommand::clienStatus(aBox, aSection)); + ok = cmd->result() == "OK"; + cmdInfo = cmd->resultInfo(); + completeQueue.removeRef(cmd); + } + if (!ok) + { + bool found = false; + imapCommand *cmd = doCommand (imapCommand::clientList ("", aBox)); + if (cmd->result () == "OK") + { + for (TQValueListIterator < imapList > it = listResponses.begin (); + it != listResponses.end (); ++it) + { + if (aBox == (*it).name ()) found = true; + } + } + completeQueue.removeRef (cmd); + if (found) + error(ERR_COULD_NOT_STAT, aBox); + else + error(TDEIO::ERR_DOES_NOT_EXIST, aBox); + return; + } + if ((aSection == "UIDNEXT" && geStatus().uidNextAvailable()) + || (aSection == "UNSEEN" && geStatus().unseenAvailable())) + { + atom.m_uds = UDS_SIZE; + atom.m_str = TQString(); + atom.m_long = (aSection == "UIDNEXT") ? geStatus().uidNext() + : geStatus().unseen(); + entry.append(atom); + } + } else + if (aType == ITYPE_BOX || aType == ITYPE_DIR_AND_BOX || aType == ITYPE_MSG || + aType == ITYPE_ATTACH) + { + ulong validity = 0; + // see if the box is already in select/examine state + if (aBox == getCurrentBox ()) + validity = selectInfo.uidValidity (); + else + { + // do a status lookup on the box + // only do this if the box is not selected + // the server might change the validity for new select/examine + imapCommand *cmd = + doCommand (imapCommand::clienStatus (aBox, "UIDVALIDITY")); + completeQueue.removeRef (cmd); + validity = geStatus ().uidValidity (); + } + validity = 0; // temporary + + if (aType == ITYPE_BOX || aType == ITYPE_DIR_AND_BOX) + { + // has no or an invalid uidvalidity + if (validity > 0 && validity != aValidity.toULong ()) + { + //redirect + KURL newUrl = _url; + + newUrl.setPath ("/" + aBox + ";UIDVALIDITY=" + + TQString::number(validity)); + kdDebug(7116) << "IMAP4::stat - redirecting to " << newUrl.prettyURL() << endl; + redirection (newUrl); + } + } + else if (aType == ITYPE_MSG || aType == ITYPE_ATTACH) + { + //must determine if this message exists + //cause konqueror will check this on paste operations + + // has an invalid uidvalidity + // or no messages in box + if (validity > 0 && validity != aValidity.toULong ()) + { + aType = ITYPE_UNKNOWN; + kdDebug(7116) << "IMAP4::stat - url has invalid validity [" << validity << "d] " << _url.prettyURL() << endl; + } + } + } + + atom.m_uds = UDS_MIME_TYPE; + atom.m_str = getMimeType (aType); + entry.append (atom); + + kdDebug(7116) << "IMAP4: stat: " << atom.m_str << endl; + switch (aType) + { + case ITYPE_DIR: + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFDIR; + entry.append (atom); + break; + + case ITYPE_BOX: + case ITYPE_DIR_AND_BOX: + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFDIR; + entry.append (atom); + break; + + case ITYPE_MSG: + case ITYPE_ATTACH: + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFREG; + entry.append (atom); + break; + + case ITYPE_UNKNOWN: + error (ERR_DOES_NOT_EXIST, _url.prettyURL()); + break; + } + + statEntry (entry); + kdDebug(7116) << "IMAP4::stat - Finishing stat" << endl; + finished (); +} + +void IMAP4Protocol::openConnection() +{ + if (makeLogin()) connected(); +} + +void IMAP4Protocol::closeConnection() +{ + if (getState() == ISTATE_NO) return; + if (getState() == ISTATE_SELECT && metaData("expunge") == "auto") + { + imapCommand *cmd = doCommand (imapCommand::clientExpunge()); + completeQueue.removeRef (cmd); + } + if (getState() != ISTATE_CONNECT) + { + imapCommand *cmd = doCommand (imapCommand::clientLogout()); + completeQueue.removeRef (cmd); + } + closeDescriptor(); + setState(ISTATE_NO); + completeQueue.clear(); + sentQueue.clear(); + lastHandled = 0; + currentBox = TQString(); + readBufferLen = 0; +} + +bool IMAP4Protocol::makeLogin () +{ + if (getState () == ISTATE_LOGIN || getState () == ISTATE_SELECT) + return true; + + kdDebug(7116) << "IMAP4::makeLogin - checking login" << endl; + bool alreadyConnected = getState() == ISTATE_CONNECT; + kdDebug(7116) << "IMAP4::makeLogin - alreadyConnected " << alreadyConnected << endl; + if (alreadyConnected || connectToHost (myHost.latin1(), myPort)) + { +// fcntl (m_iSock, F_SETFL, (fcntl (m_iSock, F_GETFL) | O_NDELAY)); + + setState(ISTATE_CONNECT); + + myAuth = metaData("auth"); + myTLS = metaData("tls"); + kdDebug(7116) << "myAuth: " << myAuth << endl; + + imapCommand *cmd; + + unhandled.clear (); + if (!alreadyConnected) while (!parseLoop ()) ; //get greeting + TQString greeting; + if (!unhandled.isEmpty()) greeting = unhandled.first().stripWhiteSpace(); + unhandled.clear (); //get rid of it + cmd = doCommand (new imapCommand ("CAPABILITY", "")); + + kdDebug(7116) << "IMAP4: setHost: capability" << endl; + for (TQStringList::Iterator it = imapCapabilities.begin (); + it != imapCapabilities.end (); ++it) + { + kdDebug(7116) << "'" << (*it) << "'" << endl; + } + completeQueue.removeRef (cmd); + + if (!hasCapability("IMAP4") && !hasCapability("IMAP4rev1")) + { + error(ERR_COULD_NOT_LOGIN, i18n("The server %1 supports neither " + "IMAP4 nor IMAP4rev1.\nIt identified itself with: %2") + .arg(myHost).arg(greeting)); + closeConnection(); + return false; + } + + if (metaData("nologin") == "on") return TRUE; + + if (myTLS == "on" && !hasCapability(TQString("STARTTLS"))) + { + error(ERR_COULD_NOT_LOGIN, i18n("The server does not support TLS.\n" + "Disable this security feature to connect unencrypted.")); + closeConnection(); + return false; + } + if ((myTLS == "on" || (canUseTLS() && myTLS != "off")) && + hasCapability(TQString("STARTTLS"))) + { + imapCommand *cmd = doCommand (imapCommand::clientStartTLS()); + if (cmd->result () == "OK") + { + completeQueue.removeRef(cmd); + int tlsrc = startTLS(); + if (tlsrc == 1) + { + kdDebug(7116) << "TLS mode has been enabled." << endl; + imapCommand *cmd2 = doCommand (new imapCommand ("CAPABILITY", "")); + for (TQStringList::Iterator it = imapCapabilities.begin (); + it != imapCapabilities.end (); ++it) + { + kdDebug(7116) << "'" << (*it) << "'" << endl; + } + completeQueue.removeRef (cmd2); + } else { + kdWarning(7116) << "TLS mode setup has failed. Aborting." << endl; + error (ERR_COULD_NOT_LOGIN, i18n("Starting TLS failed.")); + closeConnection(); + return false; + } + } else completeQueue.removeRef(cmd); + } + + if (myAuth.isEmpty () || myAuth == "*") { + if (hasCapability (TQString ("LOGINDISABLED"))) { + error (ERR_COULD_NOT_LOGIN, i18n("LOGIN is disabled by the server.")); + closeConnection(); + return false; + } + } + else { + if (!hasCapability (TQString ("AUTH=") + myAuth)) { + error (ERR_COULD_NOT_LOGIN, i18n("The authentication method %1 is not " + "supported by the server.").arg(myAuth)); + closeConnection(); + return false; + } + } + + if ( greeting.contains( TQRegExp( "Cyrus IMAP4 v2.1" ) ) ) { + removeCapability( "ANNOTATEMORE" ); + } + + // starting from Cyrus IMAP 2.3.9, shared seen flags are available + TQRegExp regExp( "Cyrus\\sIMAP[4]{0,1}\\sv(\\d+)\\.(\\d+)\\.(\\d+)", false ); + if ( regExp.search( greeting ) >= 0 ) { + const int major = regExp.cap( 1 ).toInt(); + const int minor = regExp.cap( 2 ).toInt(); + const int patch = regExp.cap( 3 ).toInt(); + if ( major > 2 || (major == 2 && (minor > 3 || (minor == 3 && patch > 9))) ) { + kdDebug(7116) << k_funcinfo << "Cyrus IMAP >= 2.3.9 detected, enabling shared seen flag support" << endl; + imapCapabilities.append( "x-kmail-sharedseen" ); + } + } + + kdDebug(7116) << "IMAP4::makeLogin - attempting login" << endl; + + TDEIO::AuthInfo authInfo; + authInfo.username = myUser; + authInfo.password = myPass; + authInfo.prompt = i18n ("Username and password for your IMAP account:"); + + kdDebug(7116) << "IMAP4::makeLogin - open_PassDlg said user=" << myUser << " pass=xx" << endl; + + TQString resultInfo; + if (myAuth.isEmpty () || myAuth == "*") + { + if (myUser.isEmpty () || myPass.isEmpty ()) { + if(openPassDlg (authInfo)) { + myUser = authInfo.username; + myPass = authInfo.password; + } + } + if (!clientLogin (myUser, myPass, resultInfo)) + error(TDEIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to login. Probably the " + "password is wrong.\nThe server %1 replied:\n%2").arg(myHost).arg(resultInfo)); + } + else + { +#ifdef HAVE_LIBSASL2 + if (!clientAuthenticate (this, authInfo, myHost, myAuth, mySSL, resultInfo)) + error(TDEIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to authenticate via %1.\n" + "The server %2 replied:\n%3").arg(myAuth).arg(myHost).arg(resultInfo)); + else { + myUser = authInfo.username; + myPass = authInfo.password; + } +#else + error(TDEIO::ERR_COULD_NOT_LOGIN, i18n("SASL authentication is not compiled into tdeio_imap4.")); +#endif + } + if ( hasCapability("NAMESPACE") ) + { + // get all namespaces and save the namespace - delimiter association + cmd = doCommand( imapCommand::clientNamespace() ); + if (cmd->result () == "OK") + { + kdDebug(7116) << "makeLogin - registered namespaces" << endl; + } + completeQueue.removeRef (cmd); + } + // get the default delimiter (empty listing) + cmd = doCommand( imapCommand::clientList("", "") ); + if (cmd->result () == "OK") + { + TQValueListIterator < imapList > it = listResponses.begin(); + if ( it == listResponses.end() ) + { + // empty answer - this is a buggy imap server + // as a fallback we fire a normal listing and take the first answer + completeQueue.removeRef (cmd); + cmd = doCommand( imapCommand::clientList("", "%") ); + if (cmd->result () == "OK") + { + it = listResponses.begin(); + } + } + if ( it != listResponses.end() ) + { + namespaceToDelimiter[TQString()] = (*it).hierarchyDelimiter(); + kdDebug(7116) << "makeLogin - delimiter for empty ns='" << + (*it).hierarchyDelimiter() << "'" << endl; + if ( !hasCapability("NAMESPACE") ) + { + // server does not support namespaces + TQString nsentry = TQString::number( 0 ) + "==" + + (*it).hierarchyDelimiter(); + imapNamespaces.append( nsentry ); + } + } + } + completeQueue.removeRef (cmd); + } else { + kdDebug(7116) << "makeLogin - NO login" << endl; + } + + return getState() == ISTATE_LOGIN; +} + +void +IMAP4Protocol::parseWriteLine (const TQString & aStr) +{ + //kdDebug(7116) << "Writing: " << aStr << endl; + TQCString writer = aStr.utf8(); + int len = writer.length(); + + // append CRLF if necessary + if (len == 0 || (writer[len - 1] != '\n')) { + len += 2; + writer += "\r\n"; + } + + // write it + write(writer.data(), len); +} + +TQString +IMAP4Protocol::getMimeType (enum IMAP_TYPE aType) +{ + switch (aType) + { + case ITYPE_DIR: + return "inode/directory"; + break; + + case ITYPE_BOX: + return "message/digest"; + break; + + case ITYPE_DIR_AND_BOX: + return "message/directory"; + break; + + case ITYPE_MSG: + return "message/rfc822"; + break; + + // this should be handled by flushOutput + case ITYPE_ATTACH: + return "application/octet-stream"; + break; + + case ITYPE_UNKNOWN: + default: + return "unknown/unknown"; + } +} + + + +void +IMAP4Protocol::doListEntry (const KURL & _url, int stretch, imapCache * cache, + bool withFlags, bool withSubject) +{ + KURL aURL = _url; + aURL.setQuery (TQString()); + const TQString encodedUrl = aURL.url(0, 106); // utf-8 + doListEntry(encodedUrl, stretch, cache, withFlags, withSubject); +} + + + +void +IMAP4Protocol::doListEntry (const TQString & encodedUrl, int stretch, imapCache * cache, + bool withFlags, bool withSubject) +{ + if (cache) + { + UDSEntry entry; + UDSAtom atom; + + entry.clear (); + + const TQString uid = TQString::number(cache->getUid()); + + atom.m_uds = UDS_NAME; + atom.m_str = uid; + atom.m_long = 0; + if (stretch > 0) + { + atom.m_str = "0000000000000000" + atom.m_str; + atom.m_str = atom.m_str.right (stretch); + } + if (withSubject) + { + mailHeader *header = cache->getHeader(); + if (header) + atom.m_str += " " + header->getSubject(); + } + entry.append (atom); + + atom.m_uds = UDS_URL; + atom.m_str = encodedUrl; // utf-8 + if (atom.m_str[atom.m_str.length () - 1] != '/') + atom.m_str += '/'; + atom.m_str += ";UID=" + uid; + atom.m_long = 0; + entry.append (atom); + + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFREG; + entry.append (atom); + + atom.m_uds = UDS_SIZE; + atom.m_long = cache->getSize(); + entry.append (atom); + + atom.m_uds = UDS_MIME_TYPE; + atom.m_str = "message/rfc822"; + atom.m_long = 0; + entry.append (atom); + + atom.m_uds = UDS_USER; + atom.m_str = myUser; + entry.append (atom); + + atom.m_uds = TDEIO::UDS_ACCESS; + atom.m_long = (withFlags) ? cache->getFlags() : S_IRUSR | S_IXUSR | S_IWUSR; + entry.append (atom); + + listEntry (entry, false); + } +} + +void +IMAP4Protocol::doListEntry (const KURL & _url, const TQString & myBox, + const imapList & item, bool appendPath) +{ + KURL aURL = _url; + aURL.setQuery (TQString()); + UDSEntry entry; + UDSAtom atom; + int hdLen = item.hierarchyDelimiter().length(); + + { + // mailboxName will be appended to the path if appendPath is true + TQString mailboxName = item.name (); + + // some beautification + if (mailboxName.find (myBox) == 0 && mailboxName.length() > myBox.length()) + { + mailboxName = + mailboxName.right (mailboxName.length () - myBox.length ()); + } + if (mailboxName[0] == '/') + mailboxName = mailboxName.right (mailboxName.length () - 1); + if (mailboxName.left(hdLen) == item.hierarchyDelimiter()) + mailboxName = mailboxName.right(mailboxName.length () - hdLen); + if (mailboxName.right(hdLen) == item.hierarchyDelimiter()) + mailboxName.truncate(mailboxName.length () - hdLen); + + atom.m_uds = UDS_NAME; + if (!item.hierarchyDelimiter().isEmpty() && + mailboxName.find(item.hierarchyDelimiter()) != -1) + atom.m_str = mailboxName.section(item.hierarchyDelimiter(), -1); + else + atom.m_str = mailboxName; + + // konqueror will die with an assertion failure otherwise + if (atom.m_str.isEmpty ()) + atom.m_str = ".."; + + if (!atom.m_str.isEmpty ()) + { + atom.m_long = 0; + entry.append (atom); + + if (!item.noSelect ()) + { + atom.m_uds = UDS_MIME_TYPE; + if (!item.noInferiors ()) + { + atom.m_str = "message/directory"; + } else { + atom.m_str = "message/digest"; + } + atom.m_long = 0; + entry.append (atom); + mailboxName += '/'; + + // explicitly set this as a directory for KFileDialog + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFDIR; + entry.append (atom); + } + else if (!item.noInferiors ()) + { + atom.m_uds = UDS_MIME_TYPE; + atom.m_str = "inode/directory"; + atom.m_long = 0; + entry.append (atom); + mailboxName += '/'; + + // explicitly set this as a directory for KFileDialog + atom.m_uds = UDS_FILE_TYPE; + atom.m_str = TQString(); + atom.m_long = S_IFDIR; + entry.append (atom); + } + else + { + atom.m_uds = UDS_MIME_TYPE; + atom.m_str = "unknown/unknown"; + atom.m_long = 0; + entry.append (atom); + } + + atom.m_uds = UDS_URL; + TQString path = aURL.path(); + atom.m_str = aURL.url (0, 106); // utf-8 + if (appendPath) + { + if (path[path.length() - 1] == '/' && !path.isEmpty() && path != "/") + path.truncate(path.length() - 1); + if (!path.isEmpty() && path != "/" + && path.right(hdLen) != item.hierarchyDelimiter()) { + path += item.hierarchyDelimiter(); + } + path += mailboxName; + if (path.upper() == "/INBOX/") { + // make sure the client can rely on INBOX + path = path.upper(); + } + } + aURL.setPath(path); + atom.m_str = aURL.url(0, 106); // utf-8 + atom.m_long = 0; + entry.append (atom); + + atom.m_uds = UDS_USER; + atom.m_str = myUser; + entry.append (atom); + + atom.m_uds = UDS_ACCESS; + atom.m_long = S_IRUSR | S_IXUSR | S_IWUSR; + entry.append (atom); + + atom.m_uds = UDS_EXTRA; + atom.m_str = item.attributesAsString(); + atom.m_long = 0; + entry.append (atom); + + listEntry (entry, false); + } + } +} + +enum IMAP_TYPE +IMAP4Protocol::parseURL (const KURL & _url, TQString & _box, + TQString & _section, TQString & _type, TQString & _uid, + TQString & _validity, TQString & _hierarchyDelimiter, + TQString & _info, bool cache) +{ + enum IMAP_TYPE retVal; + retVal = ITYPE_UNKNOWN; + + imapParser::parseURL (_url, _box, _section, _type, _uid, _validity, _info); +// kdDebug(7116) << "URL: query - '" << KURL::decode_string(_url.query()) << "'" << endl; + + // get the delimiter + TQString myNamespace = namespaceForBox( _box ); + kdDebug(7116) << "IMAP4::parseURL - namespace=" << myNamespace << endl; + if ( namespaceToDelimiter.contains(myNamespace) ) + { + _hierarchyDelimiter = namespaceToDelimiter[myNamespace]; + kdDebug(7116) << "IMAP4::parseURL - delimiter=" << _hierarchyDelimiter << endl; + } + + if (!_box.isEmpty ()) + { + kdDebug(7116) << "IMAP4::parseURL - box=" << _box << endl; + + if (makeLogin ()) + { + if (getCurrentBox () != _box || + _type == "LIST" || _type == "LSUB" || _type == "LSUBNOCHECK") + { + if ( cache ) + { + // assume a normal box + retVal = ITYPE_DIR_AND_BOX; + } else + { + // start a listing for the box to get the type + imapCommand *cmd; + + cmd = doCommand (imapCommand::clientList ("", _box)); + if (cmd->result () == "OK") + { + for (TQValueListIterator < imapList > it = listResponses.begin (); + it != listResponses.end (); ++it) + { + //kdDebug(7116) << "IMAP4::parseURL - checking " << _box << " to " << (*it).name() << endl; + if (_box == (*it).name ()) + { + if ( !(*it).hierarchyDelimiter().isEmpty() ) + _hierarchyDelimiter = (*it).hierarchyDelimiter(); + if ((*it).noSelect ()) + { + retVal = ITYPE_DIR; + } + else if ((*it).noInferiors ()) + { + retVal = ITYPE_BOX; + } + else + { + retVal = ITYPE_DIR_AND_BOX; + } + } + } + // if we got no list response for the box see if it's a prefix + if ( retVal == ITYPE_UNKNOWN && + namespaceToDelimiter.contains(_box) ) { + retVal = ITYPE_DIR; + } + } else { + kdDebug(7116) << "IMAP4::parseURL - got error for " << _box << endl; + } + completeQueue.removeRef (cmd); + } // cache + } + else // current == box + { + retVal = ITYPE_BOX; + } + } + else + kdDebug(7116) << "IMAP4::parseURL: no login!" << endl; + + } + else // empty box + { + // the root is just a dir + kdDebug(7116) << "IMAP4: parseURL: box [root]" << endl; + retVal = ITYPE_DIR; + } + + // see if it is a real sequence or a simple uid + if (retVal == ITYPE_BOX || retVal == ITYPE_DIR_AND_BOX) + { + if (!_uid.isEmpty ()) + { + if (_uid.find (':') == -1 && _uid.find (',') == -1 + && _uid.find ('*') == -1) + retVal = ITYPE_MSG; + } + } + if (retVal == ITYPE_MSG) + { + if ( (_section.find ("BODY.PEEK[", 0, false) != -1 || + _section.find ("BODY[", 0, false) != -1) && + _section.find(".MIME") == -1 && + _section.find(".HEADER") == -1 ) + retVal = ITYPE_ATTACH; + } + if ( _hierarchyDelimiter.isEmpty() && + (_type == "LIST" || _type == "LSUB" || _type == "LSUBNOCHECK") ) + { + // this shouldn't happen but when the delimiter is really empty + // we try to reconstruct it from the URL + if (!_box.isEmpty()) + { + int start = _url.path().findRev(_box); + if (start != -1) + _hierarchyDelimiter = _url.path().mid(start-1, start); + kdDebug(7116) << "IMAP4::parseURL - reconstructed delimiter:" << _hierarchyDelimiter + << " from URL " << _url.path() << endl; + } + if (_hierarchyDelimiter.isEmpty()) + _hierarchyDelimiter = "/"; + } + kdDebug(7116) << "IMAP4::parseURL - return " << retVal << endl; + + return retVal; +} + +int +IMAP4Protocol::outputLine (const TQCString & _str, int len) +{ + if (len == -1) { + len = _str.length(); + } + + if (cacheOutput) + { + if ( !outputBuffer.isOpen() ) { + outputBuffer.open(IO_WriteOnly); + } + outputBuffer.at(outputBufferIndex); + outputBuffer.writeBlock(_str.data(), len); + outputBufferIndex += len; + return 0; + } + + TQByteArray temp; + bool relay = relayEnabled; + + relayEnabled = true; + temp.setRawData (_str.data (), len); + parseRelay (temp); + temp.resetRawData (_str.data (), len); + + relayEnabled = relay; + return 0; +} + +void IMAP4Protocol::flushOutput(TQString contentEncoding) +{ + // send out cached data to the application + if (outputBufferIndex == 0) + return; + outputBuffer.close(); + outputCache.resize(outputBufferIndex); + if (decodeContent) + { + // get the coding from the MIME header + TQByteArray decoded; + if (contentEncoding.find("quoted-printable", 0, false) == 0) + decoded = KCodecs::quotedPrintableDecode(outputCache); + else if (contentEncoding.find("base64", 0, false) == 0) + KCodecs::base64Decode(outputCache, decoded); + else + decoded = outputCache; + + TQString mimetype = KMimeType::findByContent( decoded )->name(); + kdDebug(7116) << "IMAP4::flushOutput - mimeType " << mimetype << endl; + mimeType(mimetype); + decodeContent = false; + data( decoded ); + } else { + data( outputCache ); + } + mProcessedSize += outputBufferIndex; + processedSize( mProcessedSize ); + outputBufferIndex = 0; + outputCache[0] = '\0'; + outputBuffer.setBuffer(outputCache); +} + +ssize_t IMAP4Protocol::myRead(void *data, ssize_t len) +{ + if (readBufferLen) + { + ssize_t copyLen = (len < readBufferLen) ? len : readBufferLen; + memcpy(data, readBuffer, copyLen); + readBufferLen -= copyLen; + if (readBufferLen) memmove(readBuffer, &readBuffer[copyLen], readBufferLen); + return copyLen; + } + if (!isConnectionValid()) return 0; + waitForResponse( responseTimeout() ); + return read(data, len); +} + +bool +IMAP4Protocol::assureBox (const TQString & aBox, bool readonly) +{ + if (aBox.isEmpty()) return false; + + imapCommand *cmd = 0; + + if (aBox != getCurrentBox () || (!getSelected().readWrite() && !readonly)) + { + // open the box with the appropriate mode + kdDebug(7116) << "IMAP4Protocol::assureBox - opening box" << endl; + selectInfo = imapInfo(); + cmd = doCommand (imapCommand::clientSelect (aBox, readonly)); + bool ok = cmd->result() == "OK"; + TQString cmdInfo = cmd->resultInfo(); + completeQueue.removeRef (cmd); + + if (!ok) + { + bool found = false; + cmd = doCommand (imapCommand::clientList ("", aBox)); + if (cmd->result () == "OK") + { + for (TQValueListIterator < imapList > it = listResponses.begin (); + it != listResponses.end (); ++it) + { + if (aBox == (*it).name ()) found = true; + } + } + completeQueue.removeRef (cmd); + if (found) { + if (cmdInfo.find("permission", 0, false) != -1) { + // not allowed to enter this folder + error(ERR_ACCESS_DENIED, cmdInfo); + } else { + error(ERR_SLAVE_DEFINED, i18n("Unable to open folder %1. The server replied: %2").arg(aBox).arg(cmdInfo)); + } + } else { + error(TDEIO::ERR_DOES_NOT_EXIST, aBox); + } + return false; + } + } + else + { + // Give the server a chance to deliver updates every ten seconds. + // Doing this means a server roundtrip and since assureBox is called + // after every mail, we do it with a timeout. + kdDebug(7116) << "IMAP4Protocol::assureBox - reusing box" << endl; + if ( mTimeOfLastNoop.secsTo( TQDateTime::currentDateTime() ) > 10 ) { + cmd = doCommand (imapCommand::clientNoop ()); + completeQueue.removeRef (cmd); + mTimeOfLastNoop = TQDateTime::currentDateTime(); + kdDebug(7116) << "IMAP4Protocol::assureBox - noop timer fired" << endl; + } + } + + // if it is the mode we want + if (!getSelected().readWrite() && !readonly) + { + error(TDEIO::ERR_CANNOT_OPEN_FOR_WRITING, aBox); + return false; + } + + return true; +} diff --git a/tdeioslave/imap4/imapcommand.cc b/tdeioslave/imap4/imapcommand.cc deleted file mode 100644 index e3e68fa8..00000000 --- a/tdeioslave/imap4/imapcommand.cc +++ /dev/null @@ -1,408 +0,0 @@ -/********************************************************************** - * - * imapcommand.cc - IMAP4rev1 command handler - * Copyright (C) 2000 Sven Carstens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to s.carstens@gmx.de - * - *********************************************************************/ - -#include "imapcommand.h" -#include "rfcdecoder.h" - -/*#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include */ - -imapCommand::imapCommand () -{ - mComplete = false; - mId = TQString(); -} - -imapCommand::imapCommand (const TQString & command, const TQString & parameter) -// aCommand(NULL), -// mResult(NULL), -// mParameter(NULL) -{ - mComplete = false; - aCommand = command; - aParameter = parameter; - mId = TQString(); -} - -bool -imapCommand::isComplete () -{ - return mComplete; -} - -const TQString & -imapCommand::result () -{ - return mResult; -} - -const TQString & -imapCommand::resultInfo () -{ - return mResultInfo; -} - -const TQString & -imapCommand::id () -{ - return mId; -} - -const TQString & -imapCommand::parameter () -{ - return aParameter; -} - -const TQString & -imapCommand::command () -{ - return aCommand; -} - -void -imapCommand::setId (const TQString & id) -{ - if (mId.isEmpty ()) - mId = id; -} - -void -imapCommand::setComplete () -{ - mComplete = true; -} - -void -imapCommand::setResult (const TQString & result) -{ - mResult = result; -} - -void -imapCommand::setResultInfo (const TQString & result) -{ - mResultInfo = result; -} - -void -imapCommand::setCommand (const TQString & command) -{ - aCommand = command; -} - -void -imapCommand::setParameter (const TQString & parameter) -{ - aParameter = parameter; -} - -const TQString -imapCommand::getStr () -{ - if (parameter().isEmpty()) - return id() + " " + command() + "\r\n"; - else - return id() + " " + command() + " " + parameter() + "\r\n"; -} - -imapCommand * -imapCommand::clientNoop () -{ - return new imapCommand ("NOOP", ""); -} - -imapCommand * -imapCommand::clientFetch (ulong uid, const TQString & fields, bool nouid) -{ - return clientFetch (uid, uid, fields, nouid); -} - -imapCommand * -imapCommand::clientFetch (ulong fromUid, ulong toUid, const TQString & fields, - bool nouid) -{ - TQString uid = TQString::number(fromUid); - - if (fromUid != toUid) - { - uid += ":"; - if (toUid < fromUid) - uid += "*"; - else - uid += TQString::number(toUid); - } - return clientFetch (uid, fields, nouid); -} - -imapCommand * -imapCommand::clientFetch (const TQString & sequence, const TQString & fields, - bool nouid) -{ - return new imapCommand (nouid ? "FETCH" : "UID FETCH", - sequence + " (" + fields + ")"); -} - -imapCommand * -imapCommand::clientList (const TQString & reference, const TQString & path, - bool lsub) -{ - return new imapCommand (lsub ? "LSUB" : "LIST", - TQString ("\"") + rfcDecoder::toIMAP (reference) + - "\" \"" + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientSelect (const TQString & path, bool examine) -{ - Q_UNUSED(examine); - /** @note We use always SELECT, because UW-IMAP doesn't check for new mail, when - used with the "mbox driver" and the folder is opened with EXAMINE - and Courier can't append to a mailbox that is in EXAMINE state */ - return new imapCommand ("SELECT", - TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientClose() -{ - return new imapCommand("CLOSE", ""); -} - -imapCommand * -imapCommand::clientCopy (const TQString & box, const TQString & sequence, - bool nouid) -{ - return new imapCommand (nouid ? "COPY" : "UID COPY", - sequence + " \"" + rfcDecoder::toIMAP (box) + "\""); -} - -imapCommand * -imapCommand::clientAppend (const TQString & box, const TQString & flags, - ulong size) -{ - return new imapCommand ("APPEND", - "\"" + rfcDecoder::toIMAP (box) + "\" " + - ((flags.isEmpty()) ? "" : ("(" + flags + ") ")) + - "{" + TQString::number(size) + "}"); -} - -imapCommand * -imapCommand::clienStatus (const TQString & path, const TQString & parameters) -{ - return new imapCommand ("STATUS", - TQString ("\"") + rfcDecoder::toIMAP (path) + - "\" (" + parameters + ")"); -} - -imapCommand * -imapCommand::clientCreate (const TQString & path) -{ - return new imapCommand ("CREATE", - TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientDelete (const TQString & path) -{ - return new imapCommand ("DELETE", - TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientSubscribe (const TQString & path) -{ - return new imapCommand ("SUBSCRIBE", - TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientUnsubscribe (const TQString & path) -{ - return new imapCommand ("UNSUBSCRIBE", - TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); -} - -imapCommand * -imapCommand::clientExpunge () -{ - return new imapCommand ("EXPUNGE", TQString ("")); -} - -imapCommand * -imapCommand::clientRename (const TQString & src, const TQString & dest) -{ - return new imapCommand ("RENAME", - TQString ("\"") + rfcDecoder::toIMAP (src) + - "\" \"" + rfcDecoder::toIMAP (dest) + "\""); -} - -imapCommand * -imapCommand::clientSearch (const TQString & search, bool nouid) -{ - return new imapCommand (nouid ? "SEARCH" : "UID SEARCH", search); -} - -imapCommand * -imapCommand::clientStore (const TQString & set, const TQString & item, - const TQString & data, bool nouid) -{ - return new imapCommand (nouid ? "STORE" : "UID STORE", - set + " " + item + " (" + data + ")"); -} - -imapCommand * -imapCommand::clientLogout () -{ - return new imapCommand ("LOGOUT", ""); -} - -imapCommand * -imapCommand::clientStartTLS () -{ - return new imapCommand ("STARTTLS", ""); -} - -imapCommand * -imapCommand::clientSetACL( const TQString& box, const TQString& user, const TQString& acl ) -{ - return new imapCommand ("SETACL", TQString("\"") + rfcDecoder::toIMAP (box) - + "\" \"" + rfcDecoder::toIMAP (user) - + "\" \"" + rfcDecoder::toIMAP (acl) + "\""); -} - -imapCommand * -imapCommand::clientDeleteACL( const TQString& box, const TQString& user ) -{ - return new imapCommand ("DELETEACL", TQString("\"") + rfcDecoder::toIMAP (box) - + "\" \"" + rfcDecoder::toIMAP (user) - + "\""); -} - -imapCommand * -imapCommand::clientGetACL( const TQString& box ) -{ - return new imapCommand ("GETACL", TQString("\"") + rfcDecoder::toIMAP (box) - + "\""); -} - -imapCommand * -imapCommand::clientListRights( const TQString& box, const TQString& user ) -{ - return new imapCommand ("LISTRIGHTS", TQString("\"") + rfcDecoder::toIMAP (box) - + "\" \"" + rfcDecoder::toIMAP (user) - + "\""); -} - -imapCommand * -imapCommand::clientMyRights( const TQString& box ) -{ - return new imapCommand ("MYRIGHTS", TQString("\"") + rfcDecoder::toIMAP (box) - + "\""); -} - -imapCommand * -imapCommand::clientSetAnnotation( const TQString& box, const TQString& entry, const TQMap& attributes ) -{ - TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) - + "\" \"" + rfcDecoder::toIMAP (entry) - + "\" ("; - for( TQMap::ConstIterator it = attributes.begin(); it != attributes.end(); ++it ) { - parameter += "\""; - parameter += rfcDecoder::toIMAP (it.key()); - parameter += "\" \""; - parameter += rfcDecoder::toIMAP (it.data()); - parameter += "\" "; - } - // Turn last space into a ')' - parameter[parameter.length()-1] = ')'; - - return new imapCommand ("SETANNOTATION", parameter); -} - -imapCommand * -imapCommand::clientGetAnnotation( const TQString& box, const TQString& entry, const TQStringList& attributeNames ) -{ - TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) - + "\" \"" + rfcDecoder::toIMAP (entry) - + "\" "; - if ( attributeNames.count() == 1 ) - parameter += "\"" + rfcDecoder::toIMAP (attributeNames.first()) + '"'; - else { - parameter += '('; - for( TQStringList::ConstIterator it = attributeNames.begin(); it != attributeNames.end(); ++it ) { - parameter += "\"" + rfcDecoder::toIMAP (*it) + "\" "; - } - // Turn last space into a ')' - parameter[parameter.length()-1] = ')'; - } - return new imapCommand ("GETANNOTATION", parameter); -} - -imapCommand * -imapCommand::clientNamespace() -{ - return new imapCommand("NAMESPACE", ""); -} - -imapCommand * -imapCommand::clientGetQuotaroot( const TQString& box ) -{ - TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) + '"'; - return new imapCommand ("GETQUOTAROOT", parameter); -} - -imapCommand * -imapCommand::clientCustom( const TQString& command, const TQString& arguments ) -{ - return new imapCommand (command, arguments); -} - diff --git a/tdeioslave/imap4/imapcommand.cpp b/tdeioslave/imap4/imapcommand.cpp new file mode 100644 index 00000000..97d0a91c --- /dev/null +++ b/tdeioslave/imap4/imapcommand.cpp @@ -0,0 +1,408 @@ +/********************************************************************** + * + * imapcommand.cpp - IMAP4rev1 command handler + * Copyright (C) 2000 Sven Carstens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to s.carstens@gmx.de + * + *********************************************************************/ + +#include "imapcommand.h" +#include "rfcdecoder.h" + +/*#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include */ + +imapCommand::imapCommand () +{ + mComplete = false; + mId = TQString(); +} + +imapCommand::imapCommand (const TQString & command, const TQString & parameter) +// aCommand(NULL), +// mResult(NULL), +// mParameter(NULL) +{ + mComplete = false; + aCommand = command; + aParameter = parameter; + mId = TQString(); +} + +bool +imapCommand::isComplete () +{ + return mComplete; +} + +const TQString & +imapCommand::result () +{ + return mResult; +} + +const TQString & +imapCommand::resultInfo () +{ + return mResultInfo; +} + +const TQString & +imapCommand::id () +{ + return mId; +} + +const TQString & +imapCommand::parameter () +{ + return aParameter; +} + +const TQString & +imapCommand::command () +{ + return aCommand; +} + +void +imapCommand::setId (const TQString & id) +{ + if (mId.isEmpty ()) + mId = id; +} + +void +imapCommand::setComplete () +{ + mComplete = true; +} + +void +imapCommand::setResult (const TQString & result) +{ + mResult = result; +} + +void +imapCommand::setResultInfo (const TQString & result) +{ + mResultInfo = result; +} + +void +imapCommand::setCommand (const TQString & command) +{ + aCommand = command; +} + +void +imapCommand::setParameter (const TQString & parameter) +{ + aParameter = parameter; +} + +const TQString +imapCommand::getStr () +{ + if (parameter().isEmpty()) + return id() + " " + command() + "\r\n"; + else + return id() + " " + command() + " " + parameter() + "\r\n"; +} + +imapCommand * +imapCommand::clientNoop () +{ + return new imapCommand ("NOOP", ""); +} + +imapCommand * +imapCommand::clientFetch (ulong uid, const TQString & fields, bool nouid) +{ + return clientFetch (uid, uid, fields, nouid); +} + +imapCommand * +imapCommand::clientFetch (ulong fromUid, ulong toUid, const TQString & fields, + bool nouid) +{ + TQString uid = TQString::number(fromUid); + + if (fromUid != toUid) + { + uid += ":"; + if (toUid < fromUid) + uid += "*"; + else + uid += TQString::number(toUid); + } + return clientFetch (uid, fields, nouid); +} + +imapCommand * +imapCommand::clientFetch (const TQString & sequence, const TQString & fields, + bool nouid) +{ + return new imapCommand (nouid ? "FETCH" : "UID FETCH", + sequence + " (" + fields + ")"); +} + +imapCommand * +imapCommand::clientList (const TQString & reference, const TQString & path, + bool lsub) +{ + return new imapCommand (lsub ? "LSUB" : "LIST", + TQString ("\"") + rfcDecoder::toIMAP (reference) + + "\" \"" + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientSelect (const TQString & path, bool examine) +{ + Q_UNUSED(examine); + /** @note We use always SELECT, because UW-IMAP doesn't check for new mail, when + used with the "mbox driver" and the folder is opened with EXAMINE + and Courier can't append to a mailbox that is in EXAMINE state */ + return new imapCommand ("SELECT", + TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientClose() +{ + return new imapCommand("CLOSE", ""); +} + +imapCommand * +imapCommand::clientCopy (const TQString & box, const TQString & sequence, + bool nouid) +{ + return new imapCommand (nouid ? "COPY" : "UID COPY", + sequence + " \"" + rfcDecoder::toIMAP (box) + "\""); +} + +imapCommand * +imapCommand::clientAppend (const TQString & box, const TQString & flags, + ulong size) +{ + return new imapCommand ("APPEND", + "\"" + rfcDecoder::toIMAP (box) + "\" " + + ((flags.isEmpty()) ? "" : ("(" + flags + ") ")) + + "{" + TQString::number(size) + "}"); +} + +imapCommand * +imapCommand::clienStatus (const TQString & path, const TQString & parameters) +{ + return new imapCommand ("STATUS", + TQString ("\"") + rfcDecoder::toIMAP (path) + + "\" (" + parameters + ")"); +} + +imapCommand * +imapCommand::clientCreate (const TQString & path) +{ + return new imapCommand ("CREATE", + TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientDelete (const TQString & path) +{ + return new imapCommand ("DELETE", + TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientSubscribe (const TQString & path) +{ + return new imapCommand ("SUBSCRIBE", + TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientUnsubscribe (const TQString & path) +{ + return new imapCommand ("UNSUBSCRIBE", + TQString ("\"") + rfcDecoder::toIMAP (path) + "\""); +} + +imapCommand * +imapCommand::clientExpunge () +{ + return new imapCommand ("EXPUNGE", TQString ("")); +} + +imapCommand * +imapCommand::clientRename (const TQString & src, const TQString & dest) +{ + return new imapCommand ("RENAME", + TQString ("\"") + rfcDecoder::toIMAP (src) + + "\" \"" + rfcDecoder::toIMAP (dest) + "\""); +} + +imapCommand * +imapCommand::clientSearch (const TQString & search, bool nouid) +{ + return new imapCommand (nouid ? "SEARCH" : "UID SEARCH", search); +} + +imapCommand * +imapCommand::clientStore (const TQString & set, const TQString & item, + const TQString & data, bool nouid) +{ + return new imapCommand (nouid ? "STORE" : "UID STORE", + set + " " + item + " (" + data + ")"); +} + +imapCommand * +imapCommand::clientLogout () +{ + return new imapCommand ("LOGOUT", ""); +} + +imapCommand * +imapCommand::clientStartTLS () +{ + return new imapCommand ("STARTTLS", ""); +} + +imapCommand * +imapCommand::clientSetACL( const TQString& box, const TQString& user, const TQString& acl ) +{ + return new imapCommand ("SETACL", TQString("\"") + rfcDecoder::toIMAP (box) + + "\" \"" + rfcDecoder::toIMAP (user) + + "\" \"" + rfcDecoder::toIMAP (acl) + "\""); +} + +imapCommand * +imapCommand::clientDeleteACL( const TQString& box, const TQString& user ) +{ + return new imapCommand ("DELETEACL", TQString("\"") + rfcDecoder::toIMAP (box) + + "\" \"" + rfcDecoder::toIMAP (user) + + "\""); +} + +imapCommand * +imapCommand::clientGetACL( const TQString& box ) +{ + return new imapCommand ("GETACL", TQString("\"") + rfcDecoder::toIMAP (box) + + "\""); +} + +imapCommand * +imapCommand::clientListRights( const TQString& box, const TQString& user ) +{ + return new imapCommand ("LISTRIGHTS", TQString("\"") + rfcDecoder::toIMAP (box) + + "\" \"" + rfcDecoder::toIMAP (user) + + "\""); +} + +imapCommand * +imapCommand::clientMyRights( const TQString& box ) +{ + return new imapCommand ("MYRIGHTS", TQString("\"") + rfcDecoder::toIMAP (box) + + "\""); +} + +imapCommand * +imapCommand::clientSetAnnotation( const TQString& box, const TQString& entry, const TQMap& attributes ) +{ + TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) + + "\" \"" + rfcDecoder::toIMAP (entry) + + "\" ("; + for( TQMap::ConstIterator it = attributes.begin(); it != attributes.end(); ++it ) { + parameter += "\""; + parameter += rfcDecoder::toIMAP (it.key()); + parameter += "\" \""; + parameter += rfcDecoder::toIMAP (it.data()); + parameter += "\" "; + } + // Turn last space into a ')' + parameter[parameter.length()-1] = ')'; + + return new imapCommand ("SETANNOTATION", parameter); +} + +imapCommand * +imapCommand::clientGetAnnotation( const TQString& box, const TQString& entry, const TQStringList& attributeNames ) +{ + TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) + + "\" \"" + rfcDecoder::toIMAP (entry) + + "\" "; + if ( attributeNames.count() == 1 ) + parameter += "\"" + rfcDecoder::toIMAP (attributeNames.first()) + '"'; + else { + parameter += '('; + for( TQStringList::ConstIterator it = attributeNames.begin(); it != attributeNames.end(); ++it ) { + parameter += "\"" + rfcDecoder::toIMAP (*it) + "\" "; + } + // Turn last space into a ')' + parameter[parameter.length()-1] = ')'; + } + return new imapCommand ("GETANNOTATION", parameter); +} + +imapCommand * +imapCommand::clientNamespace() +{ + return new imapCommand("NAMESPACE", ""); +} + +imapCommand * +imapCommand::clientGetQuotaroot( const TQString& box ) +{ + TQString parameter = TQString("\"") + rfcDecoder::toIMAP (box) + '"'; + return new imapCommand ("GETQUOTAROOT", parameter); +} + +imapCommand * +imapCommand::clientCustom( const TQString& command, const TQString& arguments ) +{ + return new imapCommand (command, arguments); +} + diff --git a/tdeioslave/imap4/imapinfo.cc b/tdeioslave/imap4/imapinfo.cc deleted file mode 100644 index 3e21ee77..00000000 --- a/tdeioslave/imap4/imapinfo.cc +++ /dev/null @@ -1,239 +0,0 @@ -/********************************************************************** - * - * imapinfo.cc - IMAP4rev1 SELECT / EXAMINE handler - * Copyright (C) 2000 Sven Carstens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to - * - *********************************************************************/ - -/* - References: - RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 - RFC 2192 - IMAP URL Scheme - September 1997 - RFC 1731 - IMAP Authentication Mechanisms - December 1994 - (Discusses KERBEROSv4, GSSAPI, and S/Key) - RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response - - September 1997 (CRAM-MD5 authentication method) - RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 - - Supported URLs: - imap://server/ - Prompt for user/pass, list all folders in home directory - imap://user:pass@server/ - Uses LOGIN to log in - imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in - - imap://server/folder/ - List messages in folder - */ - -#include "imapinfo.h" -#include "imapparser.h" - -#include - -imapInfo::imapInfo ():count_ (0), -recent_ (0), -unseen_ (0), -uidValidity_ (0), -uidNext_ (0), -flags_ (0), -permanentFlags_ (0), -readWrite_ (false), -countAvailable_ (false), -recentAvailable_ (false), -unseenAvailable_ (false), -uidValidityAvailable_ (false), -uidNextAvailable_ (false), -flagsAvailable_ (false), -permanentFlagsAvailable_ (false), readWriteAvailable_ (false) -{ -} - -imapInfo::imapInfo (const imapInfo & mi):count_ (mi.count_), -recent_ (mi.recent_), -unseen_ (mi.unseen_), -uidValidity_ (mi.uidValidity_), -uidNext_ (mi.uidNext_), -flags_ (mi.flags_), -permanentFlags_ (mi.permanentFlags_), -readWrite_ (mi.readWrite_), -countAvailable_ (mi.countAvailable_), -recentAvailable_ (mi.recentAvailable_), -unseenAvailable_ (mi.unseenAvailable_), -uidValidityAvailable_ (mi.uidValidityAvailable_), -uidNextAvailable_ (mi.uidNextAvailable_), -flagsAvailable_ (mi.flagsAvailable_), -permanentFlagsAvailable_ (mi.permanentFlagsAvailable_), -readWriteAvailable_ (mi.readWriteAvailable_) -{ -} - -imapInfo & imapInfo::operator = (const imapInfo & mi) -{ - // Avoid a = a. - if (this == &mi) - return *this; - - count_ = mi.count_; - recent_ = mi.recent_; - unseen_ = mi.unseen_; - uidValidity_ = mi.uidValidity_; - uidNext_ = mi.uidNext_; - flags_ = mi.flags_; - permanentFlags_ = mi.permanentFlags_; - readWrite_ = mi.readWrite_; - countAvailable_ = mi.countAvailable_; - recentAvailable_ = mi.recentAvailable_; - unseenAvailable_ = mi.unseenAvailable_; - uidValidityAvailable_ = mi.uidValidityAvailable_; - uidNextAvailable_ = mi.uidNextAvailable_; - flagsAvailable_ = mi.flagsAvailable_; - permanentFlagsAvailable_ = mi.permanentFlagsAvailable_; - readWriteAvailable_ = mi.readWriteAvailable_; - - return *this; -} - -imapInfo::imapInfo (const TQStringList & list):count_ (0), -recent_ (0), -unseen_ (0), -uidValidity_ (0), -uidNext_ (0), -flags_ (0), -permanentFlags_ (0), -readWrite_ (false), -countAvailable_ (false), -recentAvailable_ (false), -unseenAvailable_ (false), -uidValidityAvailable_ (false), -uidNextAvailable_ (false), -flagsAvailable_ (false), -permanentFlagsAvailable_ (false), readWriteAvailable_ (false) -{ - for (TQStringList::ConstIterator it (list.begin ()); it != list.end (); ++it) - { - TQString line (*it); - - line.truncate(line.length() - 2); - TQStringList tokens(TQStringList::split (' ', line)); - - kdDebug(7116) << "Processing: " << line << endl; - if (tokens[0] != "*") - continue; - - if (tokens[1] == "OK") - { - if (tokens[2] == "[UNSEEN") - setUnseen (tokens[3].left (tokens[3].length () - 1).toULong ()); - - else if (tokens[2] == "[UIDVALIDITY") - setUidValidity (tokens[3].left (tokens[3].length () - 1).toULong ()); - - else if (tokens[2] == "[UIDNEXT") - setUidNext (tokens[3].left (tokens[3].length () - 1).toULong ()); - - else if (tokens[2] == "[PERMANENTFLAGS") - { - int flagsStart = line.find('('); - int flagsEnd = line.find(')'); - - kdDebug(7116) << "Checking permFlags from " << flagsStart << " to " << flagsEnd << endl; - if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd) - setPermanentFlags (_flags (line.mid (flagsStart, flagsEnd).latin1())); - - } - else if (tokens[2] == "[READ-WRITE") - { - setReadWrite (true); - } - else if (tokens[2] == "[READ-ONLY") - { - setReadWrite (false); - } - else - { - kdDebug(7116) << "unknown token2: " << tokens[2] << endl; - } - } - else if (tokens[1] == "FLAGS") - { - int flagsStart = line.find ('('); - int flagsEnd = line.find (')'); - - if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd) - setFlags (_flags (line.mid (flagsStart, flagsEnd).latin1() )); - } - else - { - if (tokens[2] == "EXISTS") - setCount (tokens[1].toULong ()); - - else if (tokens[2] == "RECENT") - setRecent (tokens[1].toULong ()); - - else - kdDebug(7116) << "unknown token1/2: " << tokens[1] << " " << tokens[2] << endl; - } - } - -} - -ulong imapInfo::_flags (const TQCString & inFlags) -{ - ulong flags = 0; - parseString flagsString; - flagsString.data.duplicate(inFlags.data(), inFlags.length()); - if ( flagsString.isEmpty() ) { - return flags; - } - - if (flagsString[0] == '(') - flagsString.pos++; - - while (!flagsString.isEmpty () && flagsString[0] != ')') - { - TQCString entry = imapParser::parseOneWordC(flagsString).upper(); - - if (entry.isEmpty ()) - flagsString.clear(); - else if (0 != entry.contains ("\\SEEN")) - flags ^= Seen; - else if (0 != entry.contains ("\\ANSWERED")) - flags ^= Answered; - else if (0 != entry.contains ("\\FLAGGED")) - flags ^= Flagged; - else if (0 != entry.contains ("\\DELETED")) - flags ^= Deleted; - else if (0 != entry.contains ("\\DRAFT")) - flags ^= Draft; - else if (0 != entry.contains ("\\RECENT")) - flags ^= Recent; - else if (0 != entry.contains ("\\*")) - flags ^= User; - - // non standard kmail falgs - else if ( entry.contains( "KMAILFORWARDED" ) || entry.contains( "$FORWARDED" ) ) - flags = flags | Forwarded; - else if ( entry.contains( "KMAILTODO" ) || entry.contains( "$TODO" ) ) - flags = flags | Todo; - else if ( entry.contains( "KMAILWATCHED" ) || entry.contains( "$WATCHED" ) ) - flags = flags | Watched; - else if ( entry.contains( "KMAILIGNORED" ) || entry.contains( "$IGNORED" ) ) - flags = flags | Ignored; - } - - return flags; -} diff --git a/tdeioslave/imap4/imapinfo.cpp b/tdeioslave/imap4/imapinfo.cpp new file mode 100644 index 00000000..453808e7 --- /dev/null +++ b/tdeioslave/imap4/imapinfo.cpp @@ -0,0 +1,239 @@ +/********************************************************************** + * + * imapinfo.cpp - IMAP4rev1 SELECT / EXAMINE handler + * Copyright (C) 2000 Sven Carstens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to + * + *********************************************************************/ + +/* + References: + RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 + RFC 2192 - IMAP URL Scheme - September 1997 + RFC 1731 - IMAP Authentication Mechanisms - December 1994 + (Discusses KERBEROSv4, GSSAPI, and S/Key) + RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response + - September 1997 (CRAM-MD5 authentication method) + RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 + + Supported URLs: + imap://server/ - Prompt for user/pass, list all folders in home directory + imap://user:pass@server/ - Uses LOGIN to log in + imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in + + imap://server/folder/ - List messages in folder + */ + +#include "imapinfo.h" +#include "imapparser.h" + +#include + +imapInfo::imapInfo ():count_ (0), +recent_ (0), +unseen_ (0), +uidValidity_ (0), +uidNext_ (0), +flags_ (0), +permanentFlags_ (0), +readWrite_ (false), +countAvailable_ (false), +recentAvailable_ (false), +unseenAvailable_ (false), +uidValidityAvailable_ (false), +uidNextAvailable_ (false), +flagsAvailable_ (false), +permanentFlagsAvailable_ (false), readWriteAvailable_ (false) +{ +} + +imapInfo::imapInfo (const imapInfo & mi):count_ (mi.count_), +recent_ (mi.recent_), +unseen_ (mi.unseen_), +uidValidity_ (mi.uidValidity_), +uidNext_ (mi.uidNext_), +flags_ (mi.flags_), +permanentFlags_ (mi.permanentFlags_), +readWrite_ (mi.readWrite_), +countAvailable_ (mi.countAvailable_), +recentAvailable_ (mi.recentAvailable_), +unseenAvailable_ (mi.unseenAvailable_), +uidValidityAvailable_ (mi.uidValidityAvailable_), +uidNextAvailable_ (mi.uidNextAvailable_), +flagsAvailable_ (mi.flagsAvailable_), +permanentFlagsAvailable_ (mi.permanentFlagsAvailable_), +readWriteAvailable_ (mi.readWriteAvailable_) +{ +} + +imapInfo & imapInfo::operator = (const imapInfo & mi) +{ + // Avoid a = a. + if (this == &mi) + return *this; + + count_ = mi.count_; + recent_ = mi.recent_; + unseen_ = mi.unseen_; + uidValidity_ = mi.uidValidity_; + uidNext_ = mi.uidNext_; + flags_ = mi.flags_; + permanentFlags_ = mi.permanentFlags_; + readWrite_ = mi.readWrite_; + countAvailable_ = mi.countAvailable_; + recentAvailable_ = mi.recentAvailable_; + unseenAvailable_ = mi.unseenAvailable_; + uidValidityAvailable_ = mi.uidValidityAvailable_; + uidNextAvailable_ = mi.uidNextAvailable_; + flagsAvailable_ = mi.flagsAvailable_; + permanentFlagsAvailable_ = mi.permanentFlagsAvailable_; + readWriteAvailable_ = mi.readWriteAvailable_; + + return *this; +} + +imapInfo::imapInfo (const TQStringList & list):count_ (0), +recent_ (0), +unseen_ (0), +uidValidity_ (0), +uidNext_ (0), +flags_ (0), +permanentFlags_ (0), +readWrite_ (false), +countAvailable_ (false), +recentAvailable_ (false), +unseenAvailable_ (false), +uidValidityAvailable_ (false), +uidNextAvailable_ (false), +flagsAvailable_ (false), +permanentFlagsAvailable_ (false), readWriteAvailable_ (false) +{ + for (TQStringList::ConstIterator it (list.begin ()); it != list.end (); ++it) + { + TQString line (*it); + + line.truncate(line.length() - 2); + TQStringList tokens(TQStringList::split (' ', line)); + + kdDebug(7116) << "Processing: " << line << endl; + if (tokens[0] != "*") + continue; + + if (tokens[1] == "OK") + { + if (tokens[2] == "[UNSEEN") + setUnseen (tokens[3].left (tokens[3].length () - 1).toULong ()); + + else if (tokens[2] == "[UIDVALIDITY") + setUidValidity (tokens[3].left (tokens[3].length () - 1).toULong ()); + + else if (tokens[2] == "[UIDNEXT") + setUidNext (tokens[3].left (tokens[3].length () - 1).toULong ()); + + else if (tokens[2] == "[PERMANENTFLAGS") + { + int flagsStart = line.find('('); + int flagsEnd = line.find(')'); + + kdDebug(7116) << "Checking permFlags from " << flagsStart << " to " << flagsEnd << endl; + if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd) + setPermanentFlags (_flags (line.mid (flagsStart, flagsEnd).latin1())); + + } + else if (tokens[2] == "[READ-WRITE") + { + setReadWrite (true); + } + else if (tokens[2] == "[READ-ONLY") + { + setReadWrite (false); + } + else + { + kdDebug(7116) << "unknown token2: " << tokens[2] << endl; + } + } + else if (tokens[1] == "FLAGS") + { + int flagsStart = line.find ('('); + int flagsEnd = line.find (')'); + + if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd) + setFlags (_flags (line.mid (flagsStart, flagsEnd).latin1() )); + } + else + { + if (tokens[2] == "EXISTS") + setCount (tokens[1].toULong ()); + + else if (tokens[2] == "RECENT") + setRecent (tokens[1].toULong ()); + + else + kdDebug(7116) << "unknown token1/2: " << tokens[1] << " " << tokens[2] << endl; + } + } + +} + +ulong imapInfo::_flags (const TQCString & inFlags) +{ + ulong flags = 0; + parseString flagsString; + flagsString.data.duplicate(inFlags.data(), inFlags.length()); + if ( flagsString.isEmpty() ) { + return flags; + } + + if (flagsString[0] == '(') + flagsString.pos++; + + while (!flagsString.isEmpty () && flagsString[0] != ')') + { + TQCString entry = imapParser::parseOneWordC(flagsString).upper(); + + if (entry.isEmpty ()) + flagsString.clear(); + else if (0 != entry.contains ("\\SEEN")) + flags ^= Seen; + else if (0 != entry.contains ("\\ANSWERED")) + flags ^= Answered; + else if (0 != entry.contains ("\\FLAGGED")) + flags ^= Flagged; + else if (0 != entry.contains ("\\DELETED")) + flags ^= Deleted; + else if (0 != entry.contains ("\\DRAFT")) + flags ^= Draft; + else if (0 != entry.contains ("\\RECENT")) + flags ^= Recent; + else if (0 != entry.contains ("\\*")) + flags ^= User; + + // non standard kmail falgs + else if ( entry.contains( "KMAILFORWARDED" ) || entry.contains( "$FORWARDED" ) ) + flags = flags | Forwarded; + else if ( entry.contains( "KMAILTODO" ) || entry.contains( "$TODO" ) ) + flags = flags | Todo; + else if ( entry.contains( "KMAILWATCHED" ) || entry.contains( "$WATCHED" ) ) + flags = flags | Watched; + else if ( entry.contains( "KMAILIGNORED" ) || entry.contains( "$IGNORED" ) ) + flags = flags | Ignored; + } + + return flags; +} diff --git a/tdeioslave/imap4/imaplist.cc b/tdeioslave/imap4/imaplist.cc deleted file mode 100644 index f9113bda..00000000 --- a/tdeioslave/imap4/imaplist.cc +++ /dev/null @@ -1,135 +0,0 @@ -/********************************************************************** - * - * imapinfo.cc - IMAP4rev1 EXAMINE / SELECT handler - * Copyright (C) 2000 Sven Carstens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to - * - *********************************************************************/ - -/* - References: - RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 - RFC 2192 - IMAP URL Scheme - September 1997 - RFC 1731 - IMAP Authentication Mechanisms - December 1994 - (Discusses KERBEROSv4, GSSAPI, and S/Key) - RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response - - September 1997 (CRAM-MD5 authentication method) - RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 - - Supported URLs: - imap://server/ - Prompt for user/pass, list all folders in home directory - imap://user:pass@server/ - Uses LOGIN to log in - imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in - - imap://server/folder/ - List messages in folder - */ - -#include "rfcdecoder.h" -#include "imaplist.h" -#include "imapparser.h" - -#include - -imapList::imapList (): parser_(0), noInferiors_ (false), -noSelect_ (false), marked_ (false), unmarked_ (false), -hasChildren_ (false), hasNoChildren_ (false) -{ -} - -imapList::imapList (const imapList & lr):parser_(lr.parser_), -hierarchyDelimiter_ (lr.hierarchyDelimiter_), -name_ (lr.name_), -noInferiors_ (lr.noInferiors_), -noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_), -hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_), -attributes_ (lr.attributes_) -{ -} - -imapList & imapList::operator = (const imapList & lr) -{ - // Avoid a = a. - if (this == &lr) - return *this; - - parser_ = lr.parser_; - hierarchyDelimiter_ = lr.hierarchyDelimiter_; - name_ = lr.name_; - noInferiors_ = lr.noInferiors_; - noSelect_ = lr.noSelect_; - marked_ = lr.marked_; - unmarked_ = lr.unmarked_; - hasChildren_ = lr.hasChildren_; - hasNoChildren_ = lr.hasNoChildren_; - attributes_ = lr.attributes_; - - return *this; -} - -imapList::imapList (const TQString & inStr, imapParser &parser) -: parser_(&parser), -noInferiors_ (false), -noSelect_ (false), -marked_ (false), unmarked_ (false), hasChildren_ (false), -hasNoChildren_ (false) -{ - parseString s; - s.data.duplicate(inStr.latin1(), inStr.length()); - - if (s[0] != '(') - return; //not proper format for us - - s.pos++; // tie off ( - - parseAttributes( s ); - - s.pos++; // tie off ) - parser_->skipWS (s); - - hierarchyDelimiter_ = parser_->parseOneWordC(s); - if (hierarchyDelimiter_ == "NIL") - hierarchyDelimiter_ = TQString(); - name_ = rfcDecoder::fromIMAP (parser_->parseLiteral (s)); // decode modified UTF7 -} - -void imapList::parseAttributes( parseString & str ) -{ - TQCString attribute, orig; - - while ( !str.isEmpty () && str[0] != ')' ) - { - orig = parser_->parseOneWordC(str); - attributes_ << orig; - attribute = orig.lower(); - if (-1 != attribute.find ("\\noinferiors")) - noInferiors_ = true; - else if (-1 != attribute.find ("\\noselect")) - noSelect_ = true; - else if (-1 != attribute.find ("\\marked")) - marked_ = true; - else if (-1 != attribute.find ("\\unmarked")) - unmarked_ = true; - else if (-1 != attribute.find ("\\haschildren")) - hasChildren_ = true; - else if (-1 != attribute.find ("\\hasnochildren")) - hasNoChildren_ = true; - else - kdDebug(7116) << "imapList::imapList: bogus attribute " << attribute << endl; - } -} - diff --git a/tdeioslave/imap4/imaplist.cpp b/tdeioslave/imap4/imaplist.cpp new file mode 100644 index 00000000..51062c47 --- /dev/null +++ b/tdeioslave/imap4/imaplist.cpp @@ -0,0 +1,135 @@ +/********************************************************************** + * + * imapinfo.cpp - IMAP4rev1 EXAMINE / SELECT handler + * Copyright (C) 2000 Sven Carstens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to + * + *********************************************************************/ + +/* + References: + RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996 + RFC 2192 - IMAP URL Scheme - September 1997 + RFC 1731 - IMAP Authentication Mechanisms - December 1994 + (Discusses KERBEROSv4, GSSAPI, and S/Key) + RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response + - September 1997 (CRAM-MD5 authentication method) + RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997 + + Supported URLs: + imap://server/ - Prompt for user/pass, list all folders in home directory + imap://user:pass@server/ - Uses LOGIN to log in + imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in + + imap://server/folder/ - List messages in folder + */ + +#include "rfcdecoder.h" +#include "imaplist.h" +#include "imapparser.h" + +#include + +imapList::imapList (): parser_(0), noInferiors_ (false), +noSelect_ (false), marked_ (false), unmarked_ (false), +hasChildren_ (false), hasNoChildren_ (false) +{ +} + +imapList::imapList (const imapList & lr):parser_(lr.parser_), +hierarchyDelimiter_ (lr.hierarchyDelimiter_), +name_ (lr.name_), +noInferiors_ (lr.noInferiors_), +noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_), +hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_), +attributes_ (lr.attributes_) +{ +} + +imapList & imapList::operator = (const imapList & lr) +{ + // Avoid a = a. + if (this == &lr) + return *this; + + parser_ = lr.parser_; + hierarchyDelimiter_ = lr.hierarchyDelimiter_; + name_ = lr.name_; + noInferiors_ = lr.noInferiors_; + noSelect_ = lr.noSelect_; + marked_ = lr.marked_; + unmarked_ = lr.unmarked_; + hasChildren_ = lr.hasChildren_; + hasNoChildren_ = lr.hasNoChildren_; + attributes_ = lr.attributes_; + + return *this; +} + +imapList::imapList (const TQString & inStr, imapParser &parser) +: parser_(&parser), +noInferiors_ (false), +noSelect_ (false), +marked_ (false), unmarked_ (false), hasChildren_ (false), +hasNoChildren_ (false) +{ + parseString s; + s.data.duplicate(inStr.latin1(), inStr.length()); + + if (s[0] != '(') + return; //not proper format for us + + s.pos++; // tie off ( + + parseAttributes( s ); + + s.pos++; // tie off ) + parser_->skipWS (s); + + hierarchyDelimiter_ = parser_->parseOneWordC(s); + if (hierarchyDelimiter_ == "NIL") + hierarchyDelimiter_ = TQString(); + name_ = rfcDecoder::fromIMAP (parser_->parseLiteral (s)); // decode modified UTF7 +} + +void imapList::parseAttributes( parseString & str ) +{ + TQCString attribute, orig; + + while ( !str.isEmpty () && str[0] != ')' ) + { + orig = parser_->parseOneWordC(str); + attributes_ << orig; + attribute = orig.lower(); + if (-1 != attribute.find ("\\noinferiors")) + noInferiors_ = true; + else if (-1 != attribute.find ("\\noselect")) + noSelect_ = true; + else if (-1 != attribute.find ("\\marked")) + marked_ = true; + else if (-1 != attribute.find ("\\unmarked")) + unmarked_ = true; + else if (-1 != attribute.find ("\\haschildren")) + hasChildren_ = true; + else if (-1 != attribute.find ("\\hasnochildren")) + hasNoChildren_ = true; + else + kdDebug(7116) << "imapList::imapList: bogus attribute " << attribute << endl; + } +} + diff --git a/tdeioslave/imap4/imapparser.cc b/tdeioslave/imap4/imapparser.cc deleted file mode 100644 index eb154cc5..00000000 --- a/tdeioslave/imap4/imapparser.cc +++ /dev/null @@ -1,2094 +0,0 @@ -/********************************************************************** - * - * imapparser.cc - IMAP4rev1 Parser - * Copyright (C) 2001-2002 Michael Haeckel - * Copyright (C) 2000 s.carstens@gmx.de - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to s.carstens@gmx.de - * - *********************************************************************/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "rfcdecoder.h" - -#include "imapparser.h" - -#include "imapinfo.h" - -#include "mailheader.h" -#include "mimeheader.h" -#include "mailaddress.h" - -#include - -#include -#include - -#ifdef HAVE_LIBSASL2 -extern "C" { -#include -} -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#ifdef HAVE_LIBSASL2 -static sasl_callback_t callbacks[] = { - { SASL_CB_ECHOPROMPT, NULL, NULL }, - { SASL_CB_NOECHOPROMPT, NULL, NULL }, - { SASL_CB_GETREALM, NULL, NULL }, - { SASL_CB_USER, NULL, NULL }, - { SASL_CB_AUTHNAME, NULL, NULL }, - { SASL_CB_PASS, NULL, NULL }, - { SASL_CB_CANON_USER, NULL, NULL }, - { SASL_CB_LIST_END, NULL, NULL } -}; -#endif - -imapParser::imapParser () -{ - sentQueue.setAutoDelete (false); - completeQueue.setAutoDelete (true); - currentState = ISTATE_NO; - commandCounter = 0; - lastHandled = 0; -} - -imapParser::~imapParser () -{ - delete lastHandled; - lastHandled = 0; -} - -imapCommand * -imapParser::doCommand (imapCommand * aCmd) -{ - int pl = 0; - sendCommand (aCmd); - while (pl != -1 && !aCmd->isComplete ()) { - while ((pl = parseLoop ()) == 0) - ; - } - - return aCmd; -} - -imapCommand * -imapParser::sendCommand (imapCommand * aCmd) -{ - aCmd->setId (TQString::number(commandCounter++)); - sentQueue.append (aCmd); - - continuation.resize(0); - const TQString& command = aCmd->command(); - - if (command == "SELECT" || command == "EXAMINE") - { - // we need to know which box we are selecting - parseString p; - p.fromString(aCmd->parameter()); - currentBox = parseOneWordC(p); - kdDebug(7116) << "imapParser::sendCommand - setting current box to " << currentBox << endl; - } - else if (command == "CLOSE") - { - // we no longer have a box open - currentBox = TQString(); - } - else if (command.find ("SEARCH") != -1 - || command == "GETACL" - || command == "LISTRIGHTS" - || command == "MYRIGHTS" - || command == "GETANNOTATION" - || command == "NAMESPACE" - || command == "GETQUOTAROOT" - || command == "GETQUOTA" - || command == "X-GET-OTHER-USERS" - || command == "X-GET-DELEGATES" - || command == "X-GET-OUT-OF-OFFICE") - { - lastResults.clear (); - } - else if (command == "LIST" - || command == "LSUB") - { - listResponses.clear (); - } - parseWriteLine (aCmd->getStr ()); - return aCmd; -} - -bool -imapParser::clientLogin (const TQString & aUser, const TQString & aPass, - TQString & resultInfo) -{ - imapCommand *cmd; - bool retVal = false; - - cmd = - doCommand (new - imapCommand ("LOGIN", "\"" + rfcDecoder::quoteIMAP(aUser) - + "\" \"" + rfcDecoder::quoteIMAP(aPass) + "\"")); - - if (cmd->result () == "OK") - { - currentState = ISTATE_LOGIN; - retVal = true; - } - resultInfo = cmd->resultInfo(); - completeQueue.removeRef (cmd); - - return retVal; -} - -#ifdef HAVE_LIBSASL2 -static bool sasl_interact( TDEIO::SlaveBase *slave, TDEIO::AuthInfo &ai, void *in ) -{ - kdDebug(7116) << "sasl_interact" << endl; - sasl_interact_t *interact = ( sasl_interact_t * ) in; - - //some mechanisms do not require username && pass, so it doesn't need a popup - //window for getting this info - for ( ; interact->id != SASL_CB_LIST_END; interact++ ) { - if ( interact->id == SASL_CB_AUTHNAME || - interact->id == SASL_CB_PASS ) { - - if ( ai.username.isEmpty() || ai.password.isEmpty() ) { - if (!slave->openPassDlg(ai)) - return false; - } - break; - } - } - - interact = ( sasl_interact_t * ) in; - while( interact->id != SASL_CB_LIST_END ) { - kdDebug(7116) << "SASL_INTERACT id: " << interact->id << endl; - switch( interact->id ) { - case SASL_CB_USER: - case SASL_CB_AUTHNAME: - kdDebug(7116) << "SASL_CB_[USER|AUTHNAME]: '" << ai.username << "'" << endl; - interact->result = strdup( ai.username.utf8() ); - interact->len = strlen( (const char *) interact->result ); - break; - case SASL_CB_PASS: - kdDebug(7116) << "SASL_CB_PASS: [hidden] " << endl; - interact->result = strdup( ai.password.utf8() ); - interact->len = strlen( (const char *) interact->result ); - break; - default: - interact->result = 0; - interact->len = 0; - break; - } - interact++; - } - return true; -} -#endif - -bool -imapParser::clientAuthenticate ( TDEIO::SlaveBase *slave, TDEIO::AuthInfo &ai, - const TQString & aFTQDN, const TQString & aAuth, bool isSSL, TQString & resultInfo) -{ - bool retVal = false; -#ifdef HAVE_LIBSASL2 - int result; - sasl_conn_t *conn = 0; - sasl_interact_t *client_interact = 0; - const char *out = 0; - uint outlen = 0; - const char *mechusing = 0; - TQByteArray tmp, challenge; - - kdDebug(7116) << "aAuth: " << aAuth << " FTQDN: " << aFTQDN << " isSSL: " << isSSL << endl; - - // see if server supports this authenticator - if (!hasCapability ("AUTH=" + aAuth)) - return false; - -// result = sasl_client_new( isSSL ? "imaps" : "imap", - result = sasl_client_new( "imap", /* FIXME: with cyrus-imapd, even imaps' digest-uri - must be 'imap'. I don't know if it's good or bad. */ - aFTQDN.latin1(), - 0, 0, callbacks, 0, &conn ); - - if ( result != SASL_OK ) { - kdDebug(7116) << "sasl_client_new failed with: " << result << endl; - resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); - return false; - } - - do { - result = sasl_client_start(conn, aAuth.latin1(), &client_interact, - hasCapability("SASL-IR") ? &out : 0, &outlen, &mechusing); - - if ( result == SASL_INTERACT ) { - if ( !sasl_interact( slave, ai, client_interact ) ) { - sasl_dispose( &conn ); - return false; - } - } - } while ( result == SASL_INTERACT ); - - if ( result != SASL_CONTINUE && result != SASL_OK ) { - kdDebug(7116) << "sasl_client_start failed with: " << result << endl; - resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); - sasl_dispose( &conn ); - return false; - } - imapCommand *cmd; - - tmp.setRawData( out, outlen ); - KCodecs::base64Encode( tmp, challenge ); - tmp.resetRawData( out, outlen ); - // then lets try it - TQString firstCommand = aAuth; - if ( !challenge.isEmpty() ) { - firstCommand += " "; - firstCommand += TQString::fromLatin1( challenge.data(), challenge.size() ); - } - cmd = sendCommand (new imapCommand ("AUTHENTICATE", firstCommand.latin1())); - - int pl = 0; - while ( pl != -1 && !cmd->isComplete () ) - { - //read the next line - while ((pl = parseLoop()) == 0) ; - - if (!continuation.isEmpty()) - { -// kdDebug(7116) << "S: " << TQCString(continuation.data(),continuation.size()+1) << endl; - if ( continuation.size() > 4 ) { - tmp.setRawData( continuation.data() + 2, continuation.size() - 4 ); - KCodecs::base64Decode( tmp, challenge ); -// kdDebug(7116) << "S-1: " << TQCString(challenge.data(),challenge.size()+1) << endl; - tmp.resetRawData( continuation.data() + 2, continuation.size() - 4 ); - } - - do { - result = sasl_client_step(conn, challenge.isEmpty() ? 0 : challenge.data(), - challenge.size(), - &client_interact, - &out, &outlen); - - if (result == SASL_INTERACT) { - if ( !sasl_interact( slave, ai, client_interact ) ) { - sasl_dispose( &conn ); - return false; - } - } - } while ( result == SASL_INTERACT ); - - if ( result != SASL_CONTINUE && result != SASL_OK ) { - kdDebug(7116) << "sasl_client_step failed with: " << result << endl; - resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); - sasl_dispose( &conn ); - return false; - } - - tmp.setRawData( out, outlen ); -// kdDebug(7116) << "C-1: " << TQCString(tmp.data(),tmp.size()+1) << endl; - KCodecs::base64Encode( tmp, challenge ); - tmp.resetRawData( out, outlen ); -// kdDebug(7116) << "C: " << TQCString(challenge.data(),challenge.size()+1) << endl; - parseWriteLine (challenge); - continuation.resize(0); - } - } - - if (cmd->result () == "OK") - { - currentState = ISTATE_LOGIN; - retVal = true; - } - resultInfo = cmd->resultInfo(); - completeQueue.removeRef (cmd); - - sasl_dispose( &conn ); //we don't use sasl_en/decode(), so it's safe to dispose the connection. -#endif //HAVE_LIBSASL2 - return retVal; -} - -void -imapParser::parseUntagged (parseString & result) -{ - //kdDebug(7116) << "imapParser::parseUntagged - '" << result.cstr() << "'" << endl; - - parseOneWordC(result); // * - TQByteArray what = parseLiteral (result); // see whats coming next - - if(!what.isEmpty ()) { - switch (what[0]) - { - //the status responses - case 'B': // BAD or BYE - if (tqstrncmp(what, "BAD", what.size()) == 0) - { - parseResult (what, result); - } - else if (tqstrncmp(what, "BYE", what.size()) == 0) - { - parseResult (what, result); - if ( sentQueue.count() ) { - // BYE that interrupts a command -> copy the reason for it - imapCommand *current = sentQueue.at (0); - current->setResultInfo(result.cstr()); - } - currentState = ISTATE_NO; - } - break; - - case 'N': // NO - if (what[1] == 'O' && what.size() == 2) - { - parseResult (what, result); - } - else if (tqstrncmp(what, "NAMESPACE", what.size()) == 0) - { - parseNamespace (result); - } - break; - - case 'O': // OK - if (what[1] == 'K' && what.size() == 2) - { - parseResult (what, result); - } else if (tqstrncmp(what, "OTHER-USER", 10) == 0) { // X-GET-OTHER-USER - parseOtherUser (result); - } else if (tqstrncmp(what, "OUT-OF-OFFICE", 13) == 0) { // X-GET-OUT-OF-OFFICE - parseOutOfOffice (result); - } - break; - case 'D': - if (tqstrncmp(what, "DELEGATE", 8) == 0) { // X-GET-DELEGATES - parseDelegate (result); - } - break; - - case 'P': // PREAUTH - if (tqstrncmp(what, "PREAUTH", what.size()) == 0) - { - parseResult (what, result); - currentState = ISTATE_LOGIN; - } - break; - - // parse the other responses - case 'C': // CAPABILITY - if (tqstrncmp(what, "CAPABILITY", what.size()) == 0) - { - parseCapability (result); - } - break; - - case 'F': // FLAGS - if (tqstrncmp(what, "FLAGS", what.size()) == 0) - { - parseFlags (result); - } - break; - - case 'L': // LIST or LSUB or LISTRIGHTS - if (tqstrncmp(what, "LIST", what.size()) == 0) - { - parseList (result); - } - else if (tqstrncmp(what, "LSUB", what.size()) == 0) - { - parseLsub (result); - } - else if (tqstrncmp(what, "LISTRIGHTS", what.size()) == 0) - { - parseListRights (result); - } - break; - - case 'M': // MYRIGHTS - if (tqstrncmp(what, "MYRIGHTS", what.size()) == 0) - { - parseMyRights (result); - } - break; - case 'S': // SEARCH or STATUS - if (tqstrncmp(what, "SEARCH", what.size()) == 0) - { - parseSearch (result); - } - else if (tqstrncmp(what, "STATUS", what.size()) == 0) - { - parsetStatus (result); - } - break; - - case 'A': // ACL or ANNOTATION - if (tqstrncmp(what, "ACL", what.size()) == 0) - { - parseAcl (result); - } - else if (tqstrncmp(what, "ANNOTATION", what.size()) == 0) - { - parseAnnotation (result); - } - break; - case 'Q': // QUOTA or QUOTAROOT - if ( what.size() > 5 && tqstrncmp(what, "QUOTAROOT", what.size()) == 0) - { - parseQuotaRoot( result ); - } - else if (tqstrncmp(what, "QUOTA", what.size()) == 0) - { - parseQuota( result ); - } - break; - case 'X': // Custom command - { - parseCustom( result ); - } - break; - default: - //better be a number - { - ulong number; - bool valid; - - number = TQCString(what, what.size() + 1).toUInt(&valid); - if (valid) - { - what = parseLiteral (result); - if(!what.isEmpty ()) { - switch (what[0]) - { - case 'E': - if (tqstrncmp(what, "EXISTS", what.size()) == 0) - { - parseExists (number, result); - } - else if (tqstrncmp(what, "EXPUNGE", what.size()) == 0) - { - parseExpunge (number, result); - } - break; - - case 'F': - if (tqstrncmp(what, "FETCH", what.size()) == 0) - { - seenUid = TQString(); - parseFetch (number, result); - } - break; - - case 'S': - if (tqstrncmp(what, "STORE", what.size()) == 0) // deprecated store - { - seenUid = TQString(); - parseFetch (number, result); - } - break; - - case 'R': - if (tqstrncmp(what, "RECENT", what.size()) == 0) - { - parseRecent (number, result); - } - break; - default: - break; - } - } - } - } - break; - } //switch - } -} //func - - -void -imapParser::parseResult (TQByteArray & result, parseString & rest, - const TQString & command) -{ - if (command == "SELECT") - selectInfo.setReadWrite(true); - - if (rest[0] == '[') - { - rest.pos++; - TQCString option = parseOneWordC(rest, TRUE); - - switch (option[0]) - { - case 'A': // ALERT - if (option == "ALERT") - { - rest.pos = rest.data.find(']', rest.pos) + 1; - // The alert text is after [ALERT]. - // Is this correct or do we need to care about litterals? - selectInfo.setAlert( rest.cstr() ); - } - break; - - case 'N': // NEWNAME - if (option == "NEWNAME") - { - } - break; - - case 'P': //PARSE or PERMANENTFLAGS - if (option == "PARSE") - { - } - else if (option == "PERMANENTFLAGS") - { - uint end = rest.data.find(']', rest.pos); - TQCString flags(rest.data.data() + rest.pos, end - rest.pos); - selectInfo.setPermanentFlags (flags); - rest.pos = end; - } - break; - - case 'R': //READ-ONLY or READ-WRITE - if (option == "READ-ONLY") - { - selectInfo.setReadWrite (false); - } - else if (option == "READ-WRITE") - { - selectInfo.setReadWrite (true); - } - break; - - case 'T': //TRYCREATE - if (option == "TRYCREATE") - { - } - break; - - case 'U': //UIDVALIDITY or UNSEEN - if (option == "UIDVALIDITY") - { - ulong value; - if (parseOneNumber (rest, value)) - selectInfo.setUidValidity (value); - } - else if (option == "UNSEEN") - { - ulong value; - if (parseOneNumber (rest, value)) - selectInfo.setUnseen (value); - } - else if (option == "UIDNEXT") - { - ulong value; - if (parseOneNumber (rest, value)) - selectInfo.setUidNext (value); - } - else - break; - - } - if (rest[0] == ']') - rest.pos++; //tie off ] - skipWS (rest); - } - - if (command.isEmpty()) - { - // This happens when parsing an intermediate result line (those that start with '*'). - // No state change involved, so we can stop here. - return; - } - - switch (command[0].latin1 ()) - { - case 'A': - if (command == "AUTHENTICATE") - if (tqstrncmp(result, "OK", result.size()) == 0) - currentState = ISTATE_LOGIN; - break; - - case 'L': - if (command == "LOGIN") - if (tqstrncmp(result, "OK", result.size()) == 0) - currentState = ISTATE_LOGIN; - break; - - case 'E': - if (command == "EXAMINE") - { - if (tqstrncmp(result, "OK", result.size()) == 0) - currentState = ISTATE_SELECT; - else - { - if (currentState == ISTATE_SELECT) - currentState = ISTATE_LOGIN; - currentBox = TQString(); - } - kdDebug(7116) << "imapParser::parseResult - current box is now " << currentBox << endl; - } - break; - - case 'S': - if (command == "SELECT") - { - if (tqstrncmp(result, "OK", result.size()) == 0) - currentState = ISTATE_SELECT; - else - { - if (currentState == ISTATE_SELECT) - currentState = ISTATE_LOGIN; - currentBox = TQString(); - } - kdDebug(7116) << "imapParser::parseResult - current box is now " << currentBox << endl; - } - break; - - default: - break; - } - -} - -void imapParser::parseCapability (parseString & result) -{ - TQCString temp( result.cstr() ); - imapCapabilities = TQStringList::split ( ' ', KPIM::kAsciiToLower( temp.data() ) ); -} - -void imapParser::parseFlags (parseString & result) -{ - selectInfo.setFlags(result.cstr()); -} - -void imapParser::parseList (parseString & result) -{ - imapList this_one; - - if (result[0] != '(') - return; //not proper format for us - - result.pos++; // tie off ( - - this_one.parseAttributes( result ); - - result.pos++; // tie off ) - skipWS (result); - - this_one.setHierarchyDelimiter(parseLiteralC(result)); - this_one.setName (rfcDecoder::fromIMAP(parseLiteralC(result))); // decode modified UTF7 - - listResponses.append (this_one); -} - -void imapParser::parseLsub (parseString & result) -{ - imapList this_one (result.cstr(), *this); - listResponses.append (this_one); -} - -void imapParser::parseListRights (parseString & result) -{ - parseOneWordC (result); // skip mailbox name - parseOneWordC (result); // skip user id - int outlen = 1; - while ( outlen ) { - TQCString word = parseOneWordC (result, false, &outlen); - lastResults.append (word); - } -} - -void imapParser::parseAcl (parseString & result) -{ - parseOneWordC (result); // skip mailbox name - int outlen = 1; - // The result is user1 perm1 user2 perm2 etc. The caller will sort it out. - while ( outlen && !result.isEmpty() ) { - TQCString word = parseLiteralC (result, false, false, &outlen); - lastResults.append (word); - } -} - -void imapParser::parseAnnotation (parseString & result) -{ - parseOneWordC (result); // skip mailbox name - skipWS (result); - parseOneWordC (result); // skip entry name (we know it since we don't allow wildcards in it) - skipWS (result); - if (result.isEmpty() || result[0] != '(') - return; - result.pos++; - skipWS (result); - int outlen = 1; - // The result is name1 value1 name2 value2 etc. The caller will sort it out. - while ( outlen && !result.isEmpty() && result[0] != ')' ) { - TQCString word = parseLiteralC (result, false, false, &outlen); - lastResults.append (word); - } -} - - -void imapParser::parseQuota (parseString & result) -{ - // quota_response ::= "QUOTA" SP astring SP quota_list - // quota_list ::= "(" #quota_resource ")" - // quota_resource ::= atom SP number SP number - TQCString root = parseOneWordC( result ); - if ( root.isEmpty() ) { - lastResults.append( "" ); - } else { - lastResults.append( root ); - } - if (result.isEmpty() || result[0] != '(') - return; - result.pos++; - skipWS (result); - TQStringList triplet; - int outlen = 1; - while ( outlen && !result.isEmpty() && result[0] != ')' ) { - TQCString word = parseLiteralC (result, false, false, &outlen); - triplet.append(word); - } - lastResults.append( triplet.join(" ") ); -} - -void imapParser::parseQuotaRoot (parseString & result) -{ - // quotaroot_response - // ::= "QUOTAROOT" SP astring *(SP astring) - parseOneWordC (result); // skip mailbox name - skipWS (result); - if ( result.isEmpty() ) - return; - TQStringList roots; - int outlen = 1; - while ( outlen && !result.isEmpty() ) { - TQCString word = parseLiteralC (result, false, false, &outlen); - roots.append (word); - } - lastResults.append( roots.isEmpty()? "" : roots.join(" ") ); -} - -void imapParser::parseCustom (parseString & result) -{ - int outlen = 1; - TQCString word = parseLiteralC (result, false, false, &outlen); - lastResults.append( word ); -} - -void imapParser::parseOtherUser (parseString & result) -{ - lastResults.append( parseOneWordC( result ) ); -} - -void imapParser::parseDelegate (parseString & result) -{ - const TQString email = parseOneWordC( result ); - - TQStringList rights; - int outlen = 1; - while ( outlen && !result.isEmpty() ) { - TQCString word = parseLiteralC( result, false, false, &outlen ); - rights.append( word ); - } - - lastResults.append( email + ':' + rights.join( "," ) ); -} - -void imapParser::parseOutOfOffice (parseString & result) -{ - const TQString state = parseOneWordC (result); - parseOneWordC (result); // skip encoding - - int outlen = 1; - TQCString msg = parseLiteralC (result, false, false, &outlen); - - lastResults.append( state + '^' + TQString::fromUtf8( msg ) ); -} - -void imapParser::parseMyRights (parseString & result) -{ - parseOneWordC (result); // skip mailbox name - Q_ASSERT( lastResults.isEmpty() ); // we can only be called once - lastResults.append (parseOneWordC (result) ); -} - -void imapParser::parseSearch (parseString & result) -{ - ulong value; - - while (parseOneNumber (result, value)) - { - lastResults.append (TQString::number(value)); - } -} - -void imapParser::parsetStatus (parseString & inWords) -{ - lasStatus = imapInfo (); - - parseLiteralC(inWords); // swallow the box - if (inWords.isEmpty() || inWords[0] != '(') - return; - - inWords.pos++; - skipWS (inWords); - - while (!inWords.isEmpty() && inWords[0] != ')') - { - ulong value; - - TQCString label = parseOneWordC(inWords); - if (parseOneNumber (inWords, value)) - { - if (label == "MESSAGES") - lasStatus.setCount (value); - else if (label == "RECENT") - lasStatus.setRecent (value); - else if (label == "UIDVALIDITY") - lasStatus.setUidValidity (value); - else if (label == "UNSEEN") - lasStatus.setUnseen (value); - else if (label == "UIDNEXT") - lasStatus.setUidNext (value); - } - } - - if (inWords[0] == ')') - inWords.pos++; - skipWS (inWords); -} - -void imapParser::parseExists (ulong value, parseString & result) -{ - selectInfo.setCount (value); - result.pos = result.data.size(); -} - -void imapParser::parseExpunge (ulong value, parseString & result) -{ - Q_UNUSED(value); - Q_UNUSED(result); -} - -void imapParser::parseAddressList (parseString & inWords, TQPtrList& list) -{ - if (inWords.isEmpty()) - return; - if (inWords[0] != '(') - { - parseOneWordC (inWords); // parse NIL - } - else - { - inWords.pos++; - skipWS (inWords); - - while (!inWords.isEmpty () && inWords[0] != ')') - { - if (inWords[0] == '(') { - mailAddress *addr = new mailAddress; - parseAddress(inWords, *addr); - list.append(addr); - } else { - break; - } - } - - if (!inWords.isEmpty() && inWords[0] == ')') - inWords.pos++; - skipWS (inWords); - } -} - -const mailAddress& imapParser::parseAddress (parseString & inWords, mailAddress& retVal) -{ - inWords.pos++; - skipWS (inWords); - - retVal.setFullName(parseLiteralC(inWords)); - retVal.setCommentRaw(parseLiteralC(inWords)); - retVal.setUser(parseLiteralC(inWords)); - retVal.setHost(parseLiteralC(inWords)); - - if (!inWords.isEmpty() && inWords[0] == ')') - inWords.pos++; - skipWS (inWords); - - return retVal; -} - -mailHeader * imapParser::parseEnvelope (parseString & inWords) -{ - mailHeader *envelope = 0; - - if (inWords[0] != '(') - return envelope; - inWords.pos++; - skipWS (inWords); - - envelope = new mailHeader; - - //date - envelope->setDate(parseLiteralC(inWords)); - - //subject - envelope->setSubject(parseLiteralC(inWords)); - - TQPtrList list; - list.setAutoDelete(true); - - //from - parseAddressList(inWords, list); - if (!list.isEmpty()) { - envelope->setFrom(*list.last()); - list.clear(); - } - - //sender - parseAddressList(inWords, list); - if (!list.isEmpty()) { - envelope->setSender(*list.last()); - list.clear(); - } - - //reply-to - parseAddressList(inWords, list); - if (!list.isEmpty()) { - envelope->setReplyTo(*list.last()); - list.clear(); - } - - //to - parseAddressList (inWords, envelope->to()); - - //cc - parseAddressList (inWords, envelope->cc()); - - //bcc - parseAddressList (inWords, envelope->bcc()); - - //in-reply-to - envelope->setInReplyTo(parseLiteralC(inWords)); - - //message-id - envelope->setMessageId(parseLiteralC(inWords)); - - // see if we have more to come - while (!inWords.isEmpty () && inWords[0] != ')') - { - //eat the extensions to this part - if (inWords[0] == '(') - parseSentence (inWords); - else - parseLiteralC (inWords); - } - - if (!inWords.isEmpty() && inWords[0] == ')') - inWords.pos++; - skipWS (inWords); - - return envelope; -} - -// parse parameter pairs into a dictionary -// caller must clean up the dictionary items -TQAsciiDict < TQString > imapParser::parseDisposition (parseString & inWords) -{ - TQCString disposition; - TQAsciiDict < TQString > retVal (17, false); - - // return value is a shallow copy - retVal.setAutoDelete (false); - - if (inWords[0] != '(') - { - //disposition only - disposition = parseOneWordC (inWords); - } - else - { - inWords.pos++; - skipWS (inWords); - - //disposition - disposition = parseOneWordC (inWords); - retVal = parseParameters (inWords); - if (inWords[0] != ')') - return retVal; - inWords.pos++; - skipWS (inWords); - } - - if (!disposition.isEmpty ()) - { - retVal.insert ("content-disposition", new TQString(disposition)); - } - - return retVal; -} - -// parse parameter pairs into a dictionary -// caller must clean up the dictionary items -TQAsciiDict < TQString > imapParser::parseParameters (parseString & inWords) -{ - TQAsciiDict < TQString > retVal (17, false); - - // return value is a shallow copy - retVal.setAutoDelete (false); - - if (inWords[0] != '(') - { - //better be NIL - parseOneWordC (inWords); - } - else - { - inWords.pos++; - skipWS (inWords); - - while (!inWords.isEmpty () && inWords[0] != ')') - { - TQCString l1 = parseLiteralC(inWords); - TQCString l2 = parseLiteralC(inWords); - retVal.insert (l1, new TQString(l2)); - } - - if (inWords[0] != ')') - return retVal; - inWords.pos++; - skipWS (inWords); - } - - return retVal; -} - -mimeHeader * imapParser::parseSimplePart (parseString & inWords, - TQString & inSection, mimeHeader * localPart) -{ - TQCString subtype; - TQCString typeStr; - TQAsciiDict < TQString > parameters (17, false); - ulong size; - - parameters.setAutoDelete (true); - - if (inWords[0] != '(') - return 0; - - if (!localPart) - localPart = new mimeHeader; - - localPart->setPartSpecifier (inSection); - - inWords.pos++; - skipWS (inWords); - - //body type - typeStr = parseLiteralC(inWords); - - //body subtype - subtype = parseLiteralC(inWords); - - localPart->setType (typeStr + "/" + subtype); - - //body parameter parenthesized list - parameters = parseParameters (inWords); - { - TQAsciiDictIterator < TQString > it (parameters); - - while (it.current ()) - { - localPart->setTypeParm (it.currentKey (), *(it.current ())); - ++it; - } - parameters.clear (); - } - - //body id - localPart->setID (parseLiteralC(inWords)); - - //body description - localPart->setDescription (parseLiteralC(inWords)); - - //body encoding - localPart->setEncoding (parseLiteralC(inWords)); - - //body size - if (parseOneNumber (inWords, size)) - localPart->setLength (size); - - // type specific extensions - if (localPart->getType().upper() == "MESSAGE/RFC822") - { - //envelope structure - mailHeader *envelope = parseEnvelope (inWords); - - //body structure - parseBodyStructure (inWords, inSection, envelope); - - localPart->setNestedMessage (envelope); - - //text lines - ulong lines; - parseOneNumber (inWords, lines); - } - else - { - if (typeStr == "TEXT") - { - //text lines - ulong lines; - parseOneNumber (inWords, lines); - } - - // md5 - parseLiteralC(inWords); - - // body disposition - parameters = parseDisposition (inWords); - { - TQString *disposition = parameters["content-disposition"]; - - if (disposition) - localPart->setDisposition (disposition->ascii ()); - parameters.remove ("content-disposition"); - TQAsciiDictIterator < TQString > it (parameters); - while (it.current ()) - { - localPart->setDispositionParm (it.currentKey (), - *(it.current ())); - ++it; - } - - parameters.clear (); - } - - // body language - parseSentence (inWords); - } - - // see if we have more to come - while (!inWords.isEmpty () && inWords[0] != ')') - { - //eat the extensions to this part - if (inWords[0] == '(') - parseSentence (inWords); - else - parseLiteralC(inWords); - } - if (inWords[0] == ')') - inWords.pos++; - skipWS (inWords); - - return localPart; -} - -mimeHeader * imapParser::parseBodyStructure (parseString & inWords, - TQString & inSection, mimeHeader * localPart) -{ - bool init = false; - if (inSection.isEmpty()) - { - // first run - init = true; - // assume one part - inSection = "1"; - } - int section = 0; - - if (inWords[0] != '(') - { - // skip "" - parseOneWordC (inWords); - return 0; - } - inWords.pos++; - skipWS (inWords); - - if (inWords[0] == '(') - { - TQByteArray subtype; - TQAsciiDict < TQString > parameters (17, false); - TQString outSection; - parameters.setAutoDelete (true); - if (!localPart) - localPart = new mimeHeader; - else - { - // might be filled from an earlier run - localPart->clearNestedParts (); - localPart->clearTypeParameters (); - localPart->clearDispositionParameters (); - // an envelope was passed in so this is the multipart header - outSection = inSection + ".HEADER"; - } - if (inWords[0] == '(' && init) - inSection = "0"; - - // set the section - if ( !outSection.isEmpty() ) { - localPart->setPartSpecifier(outSection); - } else { - localPart->setPartSpecifier(inSection); - } - - // is multipart (otherwise it is a simplepart and handled later) - while (inWords[0] == '(') - { - outSection = TQString::number(++section); - if (!init) - outSection = inSection + "." + outSection; - mimeHeader *subpart = parseBodyStructure (inWords, outSection, 0); - localPart->addNestedPart (subpart); - } - - // fetch subtype - subtype = parseOneWordC (inWords); - - localPart->setType ("MULTIPART/" + b2c(subtype)); - - // fetch parameters - parameters = parseParameters (inWords); - { - TQAsciiDictIterator < TQString > it (parameters); - - while (it.current ()) - { - localPart->setTypeParm (it.currentKey (), *(it.current ())); - ++it; - } - parameters.clear (); - } - - // body disposition - parameters = parseDisposition (inWords); - { - TQString *disposition = parameters["content-disposition"]; - - if (disposition) - localPart->setDisposition (disposition->ascii ()); - parameters.remove ("content-disposition"); - TQAsciiDictIterator < TQString > it (parameters); - while (it.current ()) - { - localPart->setDispositionParm (it.currentKey (), - *(it.current ())); - ++it; - } - parameters.clear (); - } - - // body language - parseSentence (inWords); - - } - else - { - // is simple part - inWords.pos--; - inWords.data[inWords.pos] = '('; //fake a sentence - if ( localPart ) - inSection = inSection + ".1"; - localPart = parseSimplePart (inWords, inSection, localPart); - inWords.pos--; - inWords.data[inWords.pos] = ')'; //remove fake - } - - // see if we have more to come - while (!inWords.isEmpty () && inWords[0] != ')') - { - //eat the extensions to this part - if (inWords[0] == '(') - parseSentence (inWords); - else - parseLiteralC(inWords); - } - - if (inWords[0] == ')') - inWords.pos++; - skipWS (inWords); - - return localPart; -} - -void imapParser::parseBody (parseString & inWords) -{ - // see if we got a part specifier - if (inWords[0] == '[') - { - TQCString specifier; - TQCString label; - inWords.pos++; - - specifier = parseOneWordC (inWords, TRUE); - - if (inWords[0] == '(') - { - inWords.pos++; - - while (!inWords.isEmpty () && inWords[0] != ')') - { - label = parseOneWordC (inWords); - } - - if (!inWords.isEmpty () && inWords[0] == ')') - inWords.pos++; - } - if (!inWords.isEmpty () && inWords[0] == ']') - inWords.pos++; - skipWS (inWords); - - // parse the header - if (specifier == "0") - { - mailHeader *envelope = 0; - if (lastHandled) - envelope = lastHandled->getHeader (); - - if (!envelope || seenUid.isEmpty ()) - { - kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; - // don't know where to put it, throw it away - parseLiteralC(inWords, true); - } - else - { - kdDebug(7116) << "imapParser::parseBody - reading " << envelope << " " << seenUid.ascii () << endl; - // fill it up with data - TQString theHeader = parseLiteralC(inWords, true); - mimeIOTQString myIO; - - myIO.setString (theHeader); - envelope->parseHeader (myIO); - - } - } - else if (specifier == "HEADER.FIELDS") - { - // BODY[HEADER.FIELDS (References)] {n} - //kdDebug(7116) << "imapParser::parseBody - HEADER.FIELDS: " - // << TQCString(label.data(), label.size()+1) << endl; - if (label == "REFERENCES") - { - mailHeader *envelope = 0; - if (lastHandled) - envelope = lastHandled->getHeader (); - - if (!envelope || seenUid.isEmpty ()) - { - kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; - // don't know where to put it, throw it away - parseLiteralC (inWords, true); - } - else - { - TQCString references = parseLiteralC(inWords, true); - int start = references.find ('<'); - int end = references.findRev ('>'); - if (start < end) - references = references.mid (start, end - start + 1); - envelope->setReferences(references.simplifyWhiteSpace()); - } - } - else - { // not a header we care about throw it away - parseLiteralC(inWords, true); - } - } - else - { - if (specifier.find(".MIME") != -1) - { - mailHeader *envelope = new mailHeader; - TQString theHeader = parseLiteralC(inWords, false); - mimeIOTQString myIO; - myIO.setString (theHeader); - envelope->parseHeader (myIO); - if (lastHandled) - lastHandled->setHeader (envelope); - return; - } - // throw it away - kdDebug(7116) << "imapParser::parseBody - discarding " << seenUid.ascii () << endl; - parseLiteralC(inWords, true); - } - - } - else // no part specifier - { - mailHeader *envelope = 0; - if (lastHandled) - envelope = lastHandled->getHeader (); - - if (!envelope || seenUid.isEmpty ()) - { - kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; - // don't know where to put it, throw it away - parseSentence (inWords); - } - else - { - kdDebug(7116) << "imapParser::parseBody - reading " << envelope << " " << seenUid.ascii () << endl; - // fill it up with data - TQString section; - mimeHeader *body = parseBodyStructure (inWords, section, envelope); - if (body != envelope) - delete body; - } - } -} - -void imapParser::parseFetch (ulong /* value */, parseString & inWords) -{ - if (inWords[0] != '(') - return; - inWords.pos++; - skipWS (inWords); - - delete lastHandled; - lastHandled = 0; - - while (!inWords.isEmpty () && inWords[0] != ')') - { - if (inWords[0] == '(') - parseSentence (inWords); - else - { - TQCString word = parseLiteralC(inWords, false, true); - - if(!word.isEmpty()) { - switch (word[0]) - { - case 'E': - if (word == "ENVELOPE") - { - mailHeader *envelope = 0; - - if (lastHandled) - envelope = lastHandled->getHeader (); - else - lastHandled = new imapCache(); - - if (envelope && !envelope->getMessageId ().isEmpty ()) - { - // we have seen this one already - // or don't know where to put it - parseSentence (inWords); - } - else - { - envelope = parseEnvelope (inWords); - if (envelope) - { - envelope->setPartSpecifier (seenUid + ".0"); - lastHandled->setHeader (envelope); - lastHandled->setUid (seenUid.toULong ()); - } - } - } - break; - - case 'B': - if (word == "BODY") - { - parseBody (inWords); - } - else if (word == "BODY[]" ) - { - // Do the same as with "RFC822" - parseLiteralC(inWords, true); - } - else if (word == "BODYSTRUCTURE") - { - mailHeader *envelope = 0; - - if (lastHandled) - envelope = lastHandled->getHeader (); - - // fill it up with data - TQString section; - mimeHeader *body = - parseBodyStructure (inWords, section, envelope); - TQByteArray data; - TQDataStream stream( data, IO_WriteOnly ); - if (body) body->serialize(stream); - parseRelay(data); - - delete body; - } - break; - - case 'U': - if (word == "UID") - { - seenUid = parseOneWordC(inWords); - mailHeader *envelope = 0; - if (lastHandled) - envelope = lastHandled->getHeader (); - else - lastHandled = new imapCache(); - - if (seenUid.isEmpty ()) - { - // unknown what to do - kdDebug(7116) << "imapParser::parseFetch - UID empty" << endl; - } - else - { - lastHandled->setUid (seenUid.toULong ()); - } - if (envelope) - envelope->setPartSpecifier (seenUid); - } - break; - - case 'R': - if (word == "RFC822.SIZE") - { - ulong size; - parseOneNumber (inWords, size); - - if (!lastHandled) lastHandled = new imapCache(); - lastHandled->setSize (size); - } - else if (word.find ("RFC822") == 0) - { - // might be RFC822 RFC822.TEXT RFC822.HEADER - parseLiteralC(inWords, true); - } - break; - - case 'I': - if (word == "INTERNALDATE") - { - TQCString date = parseOneWordC(inWords); - if (!lastHandled) lastHandled = new imapCache(); - lastHandled->setDate(date); - } - break; - - case 'F': - if (word == "FLAGS") - { - //kdDebug(7116) << "GOT FLAGS " << inWords.cstr() << endl; - if (!lastHandled) lastHandled = new imapCache(); - lastHandled->setFlags (imapInfo::_flags (inWords.cstr())); - } - break; - - default: - parseLiteralC(inWords); - break; - } - } else { - parseLiteralC(inWords); - } - } - } - - // see if we have more to come - while (!inWords.isEmpty () && inWords[0] != ')') - { - //eat the extensions to this part - if (inWords[0] == '(') - parseSentence (inWords); - else - parseLiteralC(inWords); - } - - if (inWords.isEmpty() || inWords[0] != ')') - return; - inWords.pos++; - skipWS (inWords); -} - - -// default parser -void imapParser::parseSentence (parseString & inWords) -{ - bool first = true; - int stack = 0; - - //find the first nesting parentheses - - while (!inWords.isEmpty () && (stack != 0 || first)) - { - first = false; - skipWS (inWords); - - unsigned char ch = inWords[0]; - switch (ch) - { - case '(': - inWords.pos++; - ++stack; - break; - case ')': - inWords.pos++; - --stack; - break; - case '[': - inWords.pos++; - ++stack; - break; - case ']': - inWords.pos++; - --stack; - break; - default: - parseLiteralC(inWords); - skipWS (inWords); - break; - } - } - skipWS (inWords); -} - -void imapParser::parseRecent (ulong value, parseString & result) -{ - selectInfo.setRecent (value); - result.pos = result.data.size(); -} - -void imapParser::parseNamespace (parseString & result) -{ - if ( result[0] != '(' ) - return; - - TQString delimEmpty; - if ( namespaceToDelimiter.contains( TQString() ) ) - delimEmpty = namespaceToDelimiter[TQString()]; - - namespaceToDelimiter.clear(); - imapNamespaces.clear(); - - // remember what section we're in (user, other users, shared) - int ns = -1; - bool personalAvailable = false; - while ( !result.isEmpty() ) - { - if ( result[0] == '(' ) - { - result.pos++; // tie off ( - if ( result[0] == '(' ) - { - // new namespace section - result.pos++; // tie off ( - ++ns; - } - // namespace prefix - TQCString prefix = parseOneWordC( result ); - // delimiter - TQCString delim = parseOneWordC( result ); - kdDebug(7116) << "imapParser::parseNamespace ns='" << prefix << - "',delim='" << delim << "'" << endl; - if ( ns == 0 ) - { - // at least one personal ns - personalAvailable = true; - } - TQString nsentry = TQString::number( ns ) + "=" + TQString(prefix) + - "=" + TQString(delim); - imapNamespaces.append( nsentry ); - if ( prefix.right( 1 ) == delim ) { - // strip delimiter to get a correct entry for comparisons - prefix.resize( prefix.length() ); - } - namespaceToDelimiter[prefix] = delim; - - result.pos++; // tie off ) - skipWS( result ); - } else if ( result[0] == ')' ) - { - result.pos++; // tie off ) - skipWS( result ); - } else if ( result[0] == 'N' ) - { - // drop NIL - ++ns; - parseOneWordC( result ); - } else { - // drop whatever it is - parseOneWordC( result ); - } - } - if ( !delimEmpty.isEmpty() ) { - // remember default delimiter - namespaceToDelimiter[TQString()] = delimEmpty; - if ( !personalAvailable ) - { - // at least one personal ns would be nice - kdDebug(7116) << "imapParser::parseNamespace - registering own personal ns" << endl; - TQString nsentry = "0==" + delimEmpty; - imapNamespaces.append( nsentry ); - } - } -} - -int imapParser::parseLoop () -{ - parseString result; - - if (!parseReadLine(result.data)) return -1; - - //kdDebug(7116) << result.cstr(); // includes \n - - if (result.data.isEmpty()) - return 0; - if (!sentQueue.count ()) - { - // maybe greeting or BYE everything else SHOULD not happen, use NOOP or IDLE - kdDebug(7116) << "imapParser::parseLoop - unhandledResponse: \n" << result.cstr() << endl; - unhandled << result.cstr(); - } - else - { - imapCommand *current = sentQueue.at (0); - switch (result[0]) - { - case '*': - result.data.resize(result.data.size() - 2); // tie off CRLF - parseUntagged (result); - break; - case '+': - continuation.duplicate(result.data); - break; - default: - { - TQCString tag = parseLiteralC(result); - if (current->id() == tag.data()) - { - result.data.resize(result.data.size() - 2); // tie off CRLF - TQByteArray resultCode = parseLiteral (result); //the result - current->setResult (resultCode); - current->setResultInfo(result.cstr()); - current->setComplete (); - - sentQueue.removeRef (current); - completeQueue.append (current); - if (result.length()) - parseResult (resultCode, result, current->command()); - } - else - { - kdDebug(7116) << "imapParser::parseLoop - unknown tag '" << tag << "'" << endl; - TQCString cstr = tag + " " + result.cstr(); - result.data = cstr; - result.pos = 0; - result.data.resize(cstr.length()); - } - } - break; - } - } - - return 1; -} - -void -imapParser::parseRelay (const TQByteArray & buffer) -{ - Q_UNUSED(buffer); - tqWarning - ("imapParser::parseRelay - virtual function not reimplemented - data lost"); -} - -void -imapParser::parseRelay (ulong len) -{ - Q_UNUSED(len); - tqWarning - ("imapParser::parseRelay - virtual function not reimplemented - announcement lost"); -} - -bool imapParser::parseRead (TQByteArray & buffer, ulong len, ulong relay) -{ - Q_UNUSED(buffer); - Q_UNUSED(len); - Q_UNUSED(relay); - tqWarning - ("imapParser::parseRead - virtual function not reimplemented - no data read"); - return FALSE; -} - -bool imapParser::parseReadLine (TQByteArray & buffer, ulong relay) -{ - Q_UNUSED(buffer); - Q_UNUSED(relay); - tqWarning - ("imapParser::parseReadLine - virtual function not reimplemented - no data read"); - return FALSE; -} - -void -imapParser::parseWriteLine (const TQString & str) -{ - Q_UNUSED(str); - tqWarning - ("imapParser::parseWriteLine - virtual function not reimplemented - no data written"); -} - -void -imapParser::parseURL (const KURL & _url, TQString & _box, TQString & _section, - TQString & _type, TQString & _uid, TQString & _validity, TQString & _info) -{ - TQStringList parameters; - - _box = _url.path (); - kdDebug(7116) << "imapParser::parseURL " << _box << endl; - int paramStart = _box.find("/;"); - if ( paramStart > -1 ) - { - TQString paramString = _box.right( _box.length() - paramStart-2 ); - parameters = TQStringList::split (';', paramString); //split parameters - _box.truncate( paramStart ); // strip parameters - } - // extract parameters - for (TQStringList::ConstIterator it (parameters.begin ()); - it != parameters.end (); ++it) - { - TQString temp = (*it); - - int pt = temp.find ('/'); - if (pt > 0) - { - if (temp.findRev ('"', pt) == -1 || temp.find('"', pt) == -1) - { - // if we have non-quoted '/' separator we'll just nuke it - temp.truncate(pt); - } - } - if (temp.find ("section=", 0, false) == 0) - _section = temp.right (temp.length () - 8); - else if (temp.find ("type=", 0, false) == 0) - _type = temp.right (temp.length () - 5); - else if (temp.find ("uid=", 0, false) == 0) - _uid = temp.right (temp.length () - 4); - else if (temp.find ("uidvalidity=", 0, false) == 0) - _validity = temp.right (temp.length () - 12); - else if (temp.find ("info=", 0, false) == 0) - _info = temp.right (temp.length () - 5); - } -// kdDebug(7116) << "URL: section= " << _section << ", type= " << _type << ", uid= " << _uid << endl; -// kdDebug(7116) << "URL: user() " << _url.user() << endl; -// kdDebug(7116) << "URL: path() " << _url.path() << endl; -// kdDebug(7116) << "URL: encodedPathAndQuery() " << _url.encodedPathAndQuery() << endl; - - if (!_box.isEmpty ()) - { - // strip / - if (_box[0] == '/') - _box = _box.right (_box.length () - 1); - if (!_box.isEmpty () && _box[_box.length () - 1] == '/') - _box.truncate(_box.length() - 1); - } - kdDebug(7116) << "URL: box= " << _box << ", section= " << _section << ", type= " - << _type << ", uid= " << _uid << ", validity= " << _validity << ", info= " << _info << endl; -} - - -TQCString imapParser::parseLiteralC(parseString & inWords, bool relay, bool stopAtBracket, int *outlen) { - - if (!inWords.isEmpty() && inWords[0] == '{') - { - TQCString retVal; - long srunLen = inWords.find ('}', 1); // Can return -1, so use a signed long - if (srunLen > 0) - { - ulong runLen = (ulong)srunLen; - bool proper; - ulong runLenSave = runLen + 1; - TQCString tmpstr(runLen); - inWords.takeMidNoResize(tmpstr, 1, runLen - 1); - runLen = tmpstr.toULong (&proper); - inWords.pos += runLenSave; - if (proper) - { - //now get the literal from the server - if (relay) - parseRelay (runLen); - TQByteArray rv; - parseRead (rv, runLen, relay ? runLen : 0); - rv.resize(TQMAX(runLen, rv.size())); // what's the point? - retVal = b2c(rv); - inWords.clear(); - parseReadLine (inWords.data); // must get more - - // no duplicate data transfers - relay = false; - } - else - { - kdDebug(7116) << "imapParser::parseLiteral - error parsing {} - " /*<< strLen*/ << endl; - } - } - else - { - inWords.clear(); - kdDebug(7116) << "imapParser::parseLiteral - error parsing unmatched {" << endl; - } - if (outlen) { - *outlen = retVal.length(); // optimize me - } - skipWS (inWords); - return retVal; - } - - return parseOneWordC(inWords, stopAtBracket, outlen); -} - -// does not know about literals ( {7} literal ) -TQCString imapParser::parseOneWordC (parseString & inWords, bool stopAtBracket, int *outLen) -{ - uint retValSize = 0; - uint len = inWords.length(); - if (len == 0) { - return TQCString(); - } - - if (len > 0 && inWords[0] == '"') - { - unsigned int i = 1; - bool quote = FALSE; - while (i < len && (inWords[i] != '"' || quote)) - { - if (inWords[i] == '\\') quote = !quote; - else quote = FALSE; - i++; - } - if (i < len) - { - TQCString retVal(i); - inWords.pos++; - inWords.takeLeftNoResize(retVal, i - 1); - len = i - 1; - int offset = 0; - for (unsigned int j = 0; j <= len; j++) { - if (retVal[j] == '\\') { - offset++; - j++; - } - retVal[j - offset] = retVal[j]; - } - retVal[len - offset] = 0; - retValSize = len - offset; - inWords.pos += i; - skipWS (inWords); - if (outLen) { - *outLen = retValSize; - } - return retVal; - } - else - { - kdDebug(7116) << "imapParser::parseOneWord - error parsing unmatched \"" << endl; - TQCString retVal = inWords.cstr(); - retValSize = len; - inWords.clear(); - if (outLen) { - *outLen = retValSize; - } - return retVal; - } - } - else - { - // not quoted - unsigned int i; - // search for end - for (i = 0; i < len; ++i) { - char ch = inWords[i]; - if (ch <= ' ' || ch == '(' || ch == ')' || - (stopAtBracket && (ch == '[' || ch == ']'))) - break; - } - - TQCString retVal(i+1); - inWords.takeLeftNoResize(retVal, i); - retValSize = i; - inWords.pos += i; - - if (retVal == "NIL") { - retVal.truncate(0); - retValSize = 0; - } - skipWS (inWords); - if (outLen) { - *outLen = retValSize; - } - return retVal; - } -} - -bool imapParser::parseOneNumber (parseString & inWords, ulong & num) -{ - bool valid; - num = parseOneWordC(inWords, TRUE).toULong(&valid); - return valid; -} - -bool imapParser::hasCapability (const TQString & cap) -{ - TQString c = cap.lower(); -// kdDebug(7116) << "imapParser::hasCapability - Looking for '" << cap << "'" << endl; - for (TQStringList::ConstIterator it = imapCapabilities.begin (); - it != imapCapabilities.end (); ++it) - { -// kdDebug(7116) << "imapParser::hasCapability - Examining '" << (*it) << "'" << endl; - if ( !(kasciistricmp(c.ascii(), (*it).ascii())) ) - { - return true; - } - } - return false; -} - -void imapParser::removeCapability (const TQString & cap) -{ - imapCapabilities.remove(cap.lower()); -} - -TQString imapParser::namespaceForBox( const TQString & box ) -{ - kdDebug(7116) << "imapParse::namespaceForBox " << box << endl; - TQString myNamespace; - if ( !box.isEmpty() ) - { - TQValueList list = namespaceToDelimiter.keys(); - TQString cleanPrefix; - for ( TQValueList::Iterator it = list.begin(); it != list.end(); ++it ) - { - if ( !(*it).isEmpty() && box.find( *it ) != -1 ) - return (*it); - } - } - return myNamespace; -} - diff --git a/tdeioslave/imap4/imapparser.cpp b/tdeioslave/imap4/imapparser.cpp new file mode 100644 index 00000000..d833b639 --- /dev/null +++ b/tdeioslave/imap4/imapparser.cpp @@ -0,0 +1,2094 @@ +/********************************************************************** + * + * imapparser.cpp - IMAP4rev1 Parser + * Copyright (C) 2001-2002 Michael Haeckel + * Copyright (C) 2000 s.carstens@gmx.de + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to s.carstens@gmx.de + * + *********************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "rfcdecoder.h" + +#include "imapparser.h" + +#include "imapinfo.h" + +#include "mailheader.h" +#include "mimeheader.h" +#include "mailaddress.h" + +#include + +#include +#include + +#ifdef HAVE_LIBSASL2 +extern "C" { +#include +} +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef HAVE_LIBSASL2 +static sasl_callback_t callbacks[] = { + { SASL_CB_ECHOPROMPT, NULL, NULL }, + { SASL_CB_NOECHOPROMPT, NULL, NULL }, + { SASL_CB_GETREALM, NULL, NULL }, + { SASL_CB_USER, NULL, NULL }, + { SASL_CB_AUTHNAME, NULL, NULL }, + { SASL_CB_PASS, NULL, NULL }, + { SASL_CB_CANON_USER, NULL, NULL }, + { SASL_CB_LIST_END, NULL, NULL } +}; +#endif + +imapParser::imapParser () +{ + sentQueue.setAutoDelete (false); + completeQueue.setAutoDelete (true); + currentState = ISTATE_NO; + commandCounter = 0; + lastHandled = 0; +} + +imapParser::~imapParser () +{ + delete lastHandled; + lastHandled = 0; +} + +imapCommand * +imapParser::doCommand (imapCommand * aCmd) +{ + int pl = 0; + sendCommand (aCmd); + while (pl != -1 && !aCmd->isComplete ()) { + while ((pl = parseLoop ()) == 0) + ; + } + + return aCmd; +} + +imapCommand * +imapParser::sendCommand (imapCommand * aCmd) +{ + aCmd->setId (TQString::number(commandCounter++)); + sentQueue.append (aCmd); + + continuation.resize(0); + const TQString& command = aCmd->command(); + + if (command == "SELECT" || command == "EXAMINE") + { + // we need to know which box we are selecting + parseString p; + p.fromString(aCmd->parameter()); + currentBox = parseOneWordC(p); + kdDebug(7116) << "imapParser::sendCommand - setting current box to " << currentBox << endl; + } + else if (command == "CLOSE") + { + // we no longer have a box open + currentBox = TQString(); + } + else if (command.find ("SEARCH") != -1 + || command == "GETACL" + || command == "LISTRIGHTS" + || command == "MYRIGHTS" + || command == "GETANNOTATION" + || command == "NAMESPACE" + || command == "GETQUOTAROOT" + || command == "GETQUOTA" + || command == "X-GET-OTHER-USERS" + || command == "X-GET-DELEGATES" + || command == "X-GET-OUT-OF-OFFICE") + { + lastResults.clear (); + } + else if (command == "LIST" + || command == "LSUB") + { + listResponses.clear (); + } + parseWriteLine (aCmd->getStr ()); + return aCmd; +} + +bool +imapParser::clientLogin (const TQString & aUser, const TQString & aPass, + TQString & resultInfo) +{ + imapCommand *cmd; + bool retVal = false; + + cmd = + doCommand (new + imapCommand ("LOGIN", "\"" + rfcDecoder::quoteIMAP(aUser) + + "\" \"" + rfcDecoder::quoteIMAP(aPass) + "\"")); + + if (cmd->result () == "OK") + { + currentState = ISTATE_LOGIN; + retVal = true; + } + resultInfo = cmd->resultInfo(); + completeQueue.removeRef (cmd); + + return retVal; +} + +#ifdef HAVE_LIBSASL2 +static bool sasl_interact( TDEIO::SlaveBase *slave, TDEIO::AuthInfo &ai, void *in ) +{ + kdDebug(7116) << "sasl_interact" << endl; + sasl_interact_t *interact = ( sasl_interact_t * ) in; + + //some mechanisms do not require username && pass, so it doesn't need a popup + //window for getting this info + for ( ; interact->id != SASL_CB_LIST_END; interact++ ) { + if ( interact->id == SASL_CB_AUTHNAME || + interact->id == SASL_CB_PASS ) { + + if ( ai.username.isEmpty() || ai.password.isEmpty() ) { + if (!slave->openPassDlg(ai)) + return false; + } + break; + } + } + + interact = ( sasl_interact_t * ) in; + while( interact->id != SASL_CB_LIST_END ) { + kdDebug(7116) << "SASL_INTERACT id: " << interact->id << endl; + switch( interact->id ) { + case SASL_CB_USER: + case SASL_CB_AUTHNAME: + kdDebug(7116) << "SASL_CB_[USER|AUTHNAME]: '" << ai.username << "'" << endl; + interact->result = strdup( ai.username.utf8() ); + interact->len = strlen( (const char *) interact->result ); + break; + case SASL_CB_PASS: + kdDebug(7116) << "SASL_CB_PASS: [hidden] " << endl; + interact->result = strdup( ai.password.utf8() ); + interact->len = strlen( (const char *) interact->result ); + break; + default: + interact->result = 0; + interact->len = 0; + break; + } + interact++; + } + return true; +} +#endif + +bool +imapParser::clientAuthenticate ( TDEIO::SlaveBase *slave, TDEIO::AuthInfo &ai, + const TQString & aFTQDN, const TQString & aAuth, bool isSSL, TQString & resultInfo) +{ + bool retVal = false; +#ifdef HAVE_LIBSASL2 + int result; + sasl_conn_t *conn = 0; + sasl_interact_t *client_interact = 0; + const char *out = 0; + uint outlen = 0; + const char *mechusing = 0; + TQByteArray tmp, challenge; + + kdDebug(7116) << "aAuth: " << aAuth << " FTQDN: " << aFTQDN << " isSSL: " << isSSL << endl; + + // see if server supports this authenticator + if (!hasCapability ("AUTH=" + aAuth)) + return false; + +// result = sasl_client_new( isSSL ? "imaps" : "imap", + result = sasl_client_new( "imap", /* FIXME: with cyrus-imapd, even imaps' digest-uri + must be 'imap'. I don't know if it's good or bad. */ + aFTQDN.latin1(), + 0, 0, callbacks, 0, &conn ); + + if ( result != SASL_OK ) { + kdDebug(7116) << "sasl_client_new failed with: " << result << endl; + resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); + return false; + } + + do { + result = sasl_client_start(conn, aAuth.latin1(), &client_interact, + hasCapability("SASL-IR") ? &out : 0, &outlen, &mechusing); + + if ( result == SASL_INTERACT ) { + if ( !sasl_interact( slave, ai, client_interact ) ) { + sasl_dispose( &conn ); + return false; + } + } + } while ( result == SASL_INTERACT ); + + if ( result != SASL_CONTINUE && result != SASL_OK ) { + kdDebug(7116) << "sasl_client_start failed with: " << result << endl; + resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); + sasl_dispose( &conn ); + return false; + } + imapCommand *cmd; + + tmp.setRawData( out, outlen ); + KCodecs::base64Encode( tmp, challenge ); + tmp.resetRawData( out, outlen ); + // then lets try it + TQString firstCommand = aAuth; + if ( !challenge.isEmpty() ) { + firstCommand += " "; + firstCommand += TQString::fromLatin1( challenge.data(), challenge.size() ); + } + cmd = sendCommand (new imapCommand ("AUTHENTICATE", firstCommand.latin1())); + + int pl = 0; + while ( pl != -1 && !cmd->isComplete () ) + { + //read the next line + while ((pl = parseLoop()) == 0) ; + + if (!continuation.isEmpty()) + { +// kdDebug(7116) << "S: " << TQCString(continuation.data(),continuation.size()+1) << endl; + if ( continuation.size() > 4 ) { + tmp.setRawData( continuation.data() + 2, continuation.size() - 4 ); + KCodecs::base64Decode( tmp, challenge ); +// kdDebug(7116) << "S-1: " << TQCString(challenge.data(),challenge.size()+1) << endl; + tmp.resetRawData( continuation.data() + 2, continuation.size() - 4 ); + } + + do { + result = sasl_client_step(conn, challenge.isEmpty() ? 0 : challenge.data(), + challenge.size(), + &client_interact, + &out, &outlen); + + if (result == SASL_INTERACT) { + if ( !sasl_interact( slave, ai, client_interact ) ) { + sasl_dispose( &conn ); + return false; + } + } + } while ( result == SASL_INTERACT ); + + if ( result != SASL_CONTINUE && result != SASL_OK ) { + kdDebug(7116) << "sasl_client_step failed with: " << result << endl; + resultInfo = TQString::fromUtf8( sasl_errdetail( conn ) ); + sasl_dispose( &conn ); + return false; + } + + tmp.setRawData( out, outlen ); +// kdDebug(7116) << "C-1: " << TQCString(tmp.data(),tmp.size()+1) << endl; + KCodecs::base64Encode( tmp, challenge ); + tmp.resetRawData( out, outlen ); +// kdDebug(7116) << "C: " << TQCString(challenge.data(),challenge.size()+1) << endl; + parseWriteLine (challenge); + continuation.resize(0); + } + } + + if (cmd->result () == "OK") + { + currentState = ISTATE_LOGIN; + retVal = true; + } + resultInfo = cmd->resultInfo(); + completeQueue.removeRef (cmd); + + sasl_dispose( &conn ); //we don't use sasl_en/decode(), so it's safe to dispose the connection. +#endif //HAVE_LIBSASL2 + return retVal; +} + +void +imapParser::parseUntagged (parseString & result) +{ + //kdDebug(7116) << "imapParser::parseUntagged - '" << result.cstr() << "'" << endl; + + parseOneWordC(result); // * + TQByteArray what = parseLiteral (result); // see whats coming next + + if(!what.isEmpty ()) { + switch (what[0]) + { + //the status responses + case 'B': // BAD or BYE + if (tqstrncmp(what, "BAD", what.size()) == 0) + { + parseResult (what, result); + } + else if (tqstrncmp(what, "BYE", what.size()) == 0) + { + parseResult (what, result); + if ( sentQueue.count() ) { + // BYE that interrupts a command -> copy the reason for it + imapCommand *current = sentQueue.at (0); + current->setResultInfo(result.cstr()); + } + currentState = ISTATE_NO; + } + break; + + case 'N': // NO + if (what[1] == 'O' && what.size() == 2) + { + parseResult (what, result); + } + else if (tqstrncmp(what, "NAMESPACE", what.size()) == 0) + { + parseNamespace (result); + } + break; + + case 'O': // OK + if (what[1] == 'K' && what.size() == 2) + { + parseResult (what, result); + } else if (tqstrncmp(what, "OTHER-USER", 10) == 0) { // X-GET-OTHER-USER + parseOtherUser (result); + } else if (tqstrncmp(what, "OUT-OF-OFFICE", 13) == 0) { // X-GET-OUT-OF-OFFICE + parseOutOfOffice (result); + } + break; + case 'D': + if (tqstrncmp(what, "DELEGATE", 8) == 0) { // X-GET-DELEGATES + parseDelegate (result); + } + break; + + case 'P': // PREAUTH + if (tqstrncmp(what, "PREAUTH", what.size()) == 0) + { + parseResult (what, result); + currentState = ISTATE_LOGIN; + } + break; + + // parse the other responses + case 'C': // CAPABILITY + if (tqstrncmp(what, "CAPABILITY", what.size()) == 0) + { + parseCapability (result); + } + break; + + case 'F': // FLAGS + if (tqstrncmp(what, "FLAGS", what.size()) == 0) + { + parseFlags (result); + } + break; + + case 'L': // LIST or LSUB or LISTRIGHTS + if (tqstrncmp(what, "LIST", what.size()) == 0) + { + parseList (result); + } + else if (tqstrncmp(what, "LSUB", what.size()) == 0) + { + parseLsub (result); + } + else if (tqstrncmp(what, "LISTRIGHTS", what.size()) == 0) + { + parseListRights (result); + } + break; + + case 'M': // MYRIGHTS + if (tqstrncmp(what, "MYRIGHTS", what.size()) == 0) + { + parseMyRights (result); + } + break; + case 'S': // SEARCH or STATUS + if (tqstrncmp(what, "SEARCH", what.size()) == 0) + { + parseSearch (result); + } + else if (tqstrncmp(what, "STATUS", what.size()) == 0) + { + parsetStatus (result); + } + break; + + case 'A': // ACL or ANNOTATION + if (tqstrncmp(what, "ACL", what.size()) == 0) + { + parseAcl (result); + } + else if (tqstrncmp(what, "ANNOTATION", what.size()) == 0) + { + parseAnnotation (result); + } + break; + case 'Q': // QUOTA or QUOTAROOT + if ( what.size() > 5 && tqstrncmp(what, "QUOTAROOT", what.size()) == 0) + { + parseQuotaRoot( result ); + } + else if (tqstrncmp(what, "QUOTA", what.size()) == 0) + { + parseQuota( result ); + } + break; + case 'X': // Custom command + { + parseCustom( result ); + } + break; + default: + //better be a number + { + ulong number; + bool valid; + + number = TQCString(what, what.size() + 1).toUInt(&valid); + if (valid) + { + what = parseLiteral (result); + if(!what.isEmpty ()) { + switch (what[0]) + { + case 'E': + if (tqstrncmp(what, "EXISTS", what.size()) == 0) + { + parseExists (number, result); + } + else if (tqstrncmp(what, "EXPUNGE", what.size()) == 0) + { + parseExpunge (number, result); + } + break; + + case 'F': + if (tqstrncmp(what, "FETCH", what.size()) == 0) + { + seenUid = TQString(); + parseFetch (number, result); + } + break; + + case 'S': + if (tqstrncmp(what, "STORE", what.size()) == 0) // deprecated store + { + seenUid = TQString(); + parseFetch (number, result); + } + break; + + case 'R': + if (tqstrncmp(what, "RECENT", what.size()) == 0) + { + parseRecent (number, result); + } + break; + default: + break; + } + } + } + } + break; + } //switch + } +} //func + + +void +imapParser::parseResult (TQByteArray & result, parseString & rest, + const TQString & command) +{ + if (command == "SELECT") + selectInfo.setReadWrite(true); + + if (rest[0] == '[') + { + rest.pos++; + TQCString option = parseOneWordC(rest, TRUE); + + switch (option[0]) + { + case 'A': // ALERT + if (option == "ALERT") + { + rest.pos = rest.data.find(']', rest.pos) + 1; + // The alert text is after [ALERT]. + // Is this correct or do we need to care about litterals? + selectInfo.setAlert( rest.cstr() ); + } + break; + + case 'N': // NEWNAME + if (option == "NEWNAME") + { + } + break; + + case 'P': //PARSE or PERMANENTFLAGS + if (option == "PARSE") + { + } + else if (option == "PERMANENTFLAGS") + { + uint end = rest.data.find(']', rest.pos); + TQCString flags(rest.data.data() + rest.pos, end - rest.pos); + selectInfo.setPermanentFlags (flags); + rest.pos = end; + } + break; + + case 'R': //READ-ONLY or READ-WRITE + if (option == "READ-ONLY") + { + selectInfo.setReadWrite (false); + } + else if (option == "READ-WRITE") + { + selectInfo.setReadWrite (true); + } + break; + + case 'T': //TRYCREATE + if (option == "TRYCREATE") + { + } + break; + + case 'U': //UIDVALIDITY or UNSEEN + if (option == "UIDVALIDITY") + { + ulong value; + if (parseOneNumber (rest, value)) + selectInfo.setUidValidity (value); + } + else if (option == "UNSEEN") + { + ulong value; + if (parseOneNumber (rest, value)) + selectInfo.setUnseen (value); + } + else if (option == "UIDNEXT") + { + ulong value; + if (parseOneNumber (rest, value)) + selectInfo.setUidNext (value); + } + else + break; + + } + if (rest[0] == ']') + rest.pos++; //tie off ] + skipWS (rest); + } + + if (command.isEmpty()) + { + // This happens when parsing an intermediate result line (those that start with '*'). + // No state change involved, so we can stop here. + return; + } + + switch (command[0].latin1 ()) + { + case 'A': + if (command == "AUTHENTICATE") + if (tqstrncmp(result, "OK", result.size()) == 0) + currentState = ISTATE_LOGIN; + break; + + case 'L': + if (command == "LOGIN") + if (tqstrncmp(result, "OK", result.size()) == 0) + currentState = ISTATE_LOGIN; + break; + + case 'E': + if (command == "EXAMINE") + { + if (tqstrncmp(result, "OK", result.size()) == 0) + currentState = ISTATE_SELECT; + else + { + if (currentState == ISTATE_SELECT) + currentState = ISTATE_LOGIN; + currentBox = TQString(); + } + kdDebug(7116) << "imapParser::parseResult - current box is now " << currentBox << endl; + } + break; + + case 'S': + if (command == "SELECT") + { + if (tqstrncmp(result, "OK", result.size()) == 0) + currentState = ISTATE_SELECT; + else + { + if (currentState == ISTATE_SELECT) + currentState = ISTATE_LOGIN; + currentBox = TQString(); + } + kdDebug(7116) << "imapParser::parseResult - current box is now " << currentBox << endl; + } + break; + + default: + break; + } + +} + +void imapParser::parseCapability (parseString & result) +{ + TQCString temp( result.cstr() ); + imapCapabilities = TQStringList::split ( ' ', KPIM::kAsciiToLower( temp.data() ) ); +} + +void imapParser::parseFlags (parseString & result) +{ + selectInfo.setFlags(result.cstr()); +} + +void imapParser::parseList (parseString & result) +{ + imapList this_one; + + if (result[0] != '(') + return; //not proper format for us + + result.pos++; // tie off ( + + this_one.parseAttributes( result ); + + result.pos++; // tie off ) + skipWS (result); + + this_one.setHierarchyDelimiter(parseLiteralC(result)); + this_one.setName (rfcDecoder::fromIMAP(parseLiteralC(result))); // decode modified UTF7 + + listResponses.append (this_one); +} + +void imapParser::parseLsub (parseString & result) +{ + imapList this_one (result.cstr(), *this); + listResponses.append (this_one); +} + +void imapParser::parseListRights (parseString & result) +{ + parseOneWordC (result); // skip mailbox name + parseOneWordC (result); // skip user id + int outlen = 1; + while ( outlen ) { + TQCString word = parseOneWordC (result, false, &outlen); + lastResults.append (word); + } +} + +void imapParser::parseAcl (parseString & result) +{ + parseOneWordC (result); // skip mailbox name + int outlen = 1; + // The result is user1 perm1 user2 perm2 etc. The caller will sort it out. + while ( outlen && !result.isEmpty() ) { + TQCString word = parseLiteralC (result, false, false, &outlen); + lastResults.append (word); + } +} + +void imapParser::parseAnnotation (parseString & result) +{ + parseOneWordC (result); // skip mailbox name + skipWS (result); + parseOneWordC (result); // skip entry name (we know it since we don't allow wildcards in it) + skipWS (result); + if (result.isEmpty() || result[0] != '(') + return; + result.pos++; + skipWS (result); + int outlen = 1; + // The result is name1 value1 name2 value2 etc. The caller will sort it out. + while ( outlen && !result.isEmpty() && result[0] != ')' ) { + TQCString word = parseLiteralC (result, false, false, &outlen); + lastResults.append (word); + } +} + + +void imapParser::parseQuota (parseString & result) +{ + // quota_response ::= "QUOTA" SP astring SP quota_list + // quota_list ::= "(" #quota_resource ")" + // quota_resource ::= atom SP number SP number + TQCString root = parseOneWordC( result ); + if ( root.isEmpty() ) { + lastResults.append( "" ); + } else { + lastResults.append( root ); + } + if (result.isEmpty() || result[0] != '(') + return; + result.pos++; + skipWS (result); + TQStringList triplet; + int outlen = 1; + while ( outlen && !result.isEmpty() && result[0] != ')' ) { + TQCString word = parseLiteralC (result, false, false, &outlen); + triplet.append(word); + } + lastResults.append( triplet.join(" ") ); +} + +void imapParser::parseQuotaRoot (parseString & result) +{ + // quotaroot_response + // ::= "QUOTAROOT" SP astring *(SP astring) + parseOneWordC (result); // skip mailbox name + skipWS (result); + if ( result.isEmpty() ) + return; + TQStringList roots; + int outlen = 1; + while ( outlen && !result.isEmpty() ) { + TQCString word = parseLiteralC (result, false, false, &outlen); + roots.append (word); + } + lastResults.append( roots.isEmpty()? "" : roots.join(" ") ); +} + +void imapParser::parseCustom (parseString & result) +{ + int outlen = 1; + TQCString word = parseLiteralC (result, false, false, &outlen); + lastResults.append( word ); +} + +void imapParser::parseOtherUser (parseString & result) +{ + lastResults.append( parseOneWordC( result ) ); +} + +void imapParser::parseDelegate (parseString & result) +{ + const TQString email = parseOneWordC( result ); + + TQStringList rights; + int outlen = 1; + while ( outlen && !result.isEmpty() ) { + TQCString word = parseLiteralC( result, false, false, &outlen ); + rights.append( word ); + } + + lastResults.append( email + ':' + rights.join( "," ) ); +} + +void imapParser::parseOutOfOffice (parseString & result) +{ + const TQString state = parseOneWordC (result); + parseOneWordC (result); // skip encoding + + int outlen = 1; + TQCString msg = parseLiteralC (result, false, false, &outlen); + + lastResults.append( state + '^' + TQString::fromUtf8( msg ) ); +} + +void imapParser::parseMyRights (parseString & result) +{ + parseOneWordC (result); // skip mailbox name + Q_ASSERT( lastResults.isEmpty() ); // we can only be called once + lastResults.append (parseOneWordC (result) ); +} + +void imapParser::parseSearch (parseString & result) +{ + ulong value; + + while (parseOneNumber (result, value)) + { + lastResults.append (TQString::number(value)); + } +} + +void imapParser::parsetStatus (parseString & inWords) +{ + lasStatus = imapInfo (); + + parseLiteralC(inWords); // swallow the box + if (inWords.isEmpty() || inWords[0] != '(') + return; + + inWords.pos++; + skipWS (inWords); + + while (!inWords.isEmpty() && inWords[0] != ')') + { + ulong value; + + TQCString label = parseOneWordC(inWords); + if (parseOneNumber (inWords, value)) + { + if (label == "MESSAGES") + lasStatus.setCount (value); + else if (label == "RECENT") + lasStatus.setRecent (value); + else if (label == "UIDVALIDITY") + lasStatus.setUidValidity (value); + else if (label == "UNSEEN") + lasStatus.setUnseen (value); + else if (label == "UIDNEXT") + lasStatus.setUidNext (value); + } + } + + if (inWords[0] == ')') + inWords.pos++; + skipWS (inWords); +} + +void imapParser::parseExists (ulong value, parseString & result) +{ + selectInfo.setCount (value); + result.pos = result.data.size(); +} + +void imapParser::parseExpunge (ulong value, parseString & result) +{ + Q_UNUSED(value); + Q_UNUSED(result); +} + +void imapParser::parseAddressList (parseString & inWords, TQPtrList& list) +{ + if (inWords.isEmpty()) + return; + if (inWords[0] != '(') + { + parseOneWordC (inWords); // parse NIL + } + else + { + inWords.pos++; + skipWS (inWords); + + while (!inWords.isEmpty () && inWords[0] != ')') + { + if (inWords[0] == '(') { + mailAddress *addr = new mailAddress; + parseAddress(inWords, *addr); + list.append(addr); + } else { + break; + } + } + + if (!inWords.isEmpty() && inWords[0] == ')') + inWords.pos++; + skipWS (inWords); + } +} + +const mailAddress& imapParser::parseAddress (parseString & inWords, mailAddress& retVal) +{ + inWords.pos++; + skipWS (inWords); + + retVal.setFullName(parseLiteralC(inWords)); + retVal.setCommentRaw(parseLiteralC(inWords)); + retVal.setUser(parseLiteralC(inWords)); + retVal.setHost(parseLiteralC(inWords)); + + if (!inWords.isEmpty() && inWords[0] == ')') + inWords.pos++; + skipWS (inWords); + + return retVal; +} + +mailHeader * imapParser::parseEnvelope (parseString & inWords) +{ + mailHeader *envelope = 0; + + if (inWords[0] != '(') + return envelope; + inWords.pos++; + skipWS (inWords); + + envelope = new mailHeader; + + //date + envelope->setDate(parseLiteralC(inWords)); + + //subject + envelope->setSubject(parseLiteralC(inWords)); + + TQPtrList list; + list.setAutoDelete(true); + + //from + parseAddressList(inWords, list); + if (!list.isEmpty()) { + envelope->setFrom(*list.last()); + list.clear(); + } + + //sender + parseAddressList(inWords, list); + if (!list.isEmpty()) { + envelope->setSender(*list.last()); + list.clear(); + } + + //reply-to + parseAddressList(inWords, list); + if (!list.isEmpty()) { + envelope->setReplyTo(*list.last()); + list.clear(); + } + + //to + parseAddressList (inWords, envelope->to()); + + //cc + parseAddressList (inWords, envelope->cc()); + + //bcc + parseAddressList (inWords, envelope->bcc()); + + //in-reply-to + envelope->setInReplyTo(parseLiteralC(inWords)); + + //message-id + envelope->setMessageId(parseLiteralC(inWords)); + + // see if we have more to come + while (!inWords.isEmpty () && inWords[0] != ')') + { + //eat the extensions to this part + if (inWords[0] == '(') + parseSentence (inWords); + else + parseLiteralC (inWords); + } + + if (!inWords.isEmpty() && inWords[0] == ')') + inWords.pos++; + skipWS (inWords); + + return envelope; +} + +// parse parameter pairs into a dictionary +// caller must clean up the dictionary items +TQAsciiDict < TQString > imapParser::parseDisposition (parseString & inWords) +{ + TQCString disposition; + TQAsciiDict < TQString > retVal (17, false); + + // return value is a shallow copy + retVal.setAutoDelete (false); + + if (inWords[0] != '(') + { + //disposition only + disposition = parseOneWordC (inWords); + } + else + { + inWords.pos++; + skipWS (inWords); + + //disposition + disposition = parseOneWordC (inWords); + retVal = parseParameters (inWords); + if (inWords[0] != ')') + return retVal; + inWords.pos++; + skipWS (inWords); + } + + if (!disposition.isEmpty ()) + { + retVal.insert ("content-disposition", new TQString(disposition)); + } + + return retVal; +} + +// parse parameter pairs into a dictionary +// caller must clean up the dictionary items +TQAsciiDict < TQString > imapParser::parseParameters (parseString & inWords) +{ + TQAsciiDict < TQString > retVal (17, false); + + // return value is a shallow copy + retVal.setAutoDelete (false); + + if (inWords[0] != '(') + { + //better be NIL + parseOneWordC (inWords); + } + else + { + inWords.pos++; + skipWS (inWords); + + while (!inWords.isEmpty () && inWords[0] != ')') + { + TQCString l1 = parseLiteralC(inWords); + TQCString l2 = parseLiteralC(inWords); + retVal.insert (l1, new TQString(l2)); + } + + if (inWords[0] != ')') + return retVal; + inWords.pos++; + skipWS (inWords); + } + + return retVal; +} + +mimeHeader * imapParser::parseSimplePart (parseString & inWords, + TQString & inSection, mimeHeader * localPart) +{ + TQCString subtype; + TQCString typeStr; + TQAsciiDict < TQString > parameters (17, false); + ulong size; + + parameters.setAutoDelete (true); + + if (inWords[0] != '(') + return 0; + + if (!localPart) + localPart = new mimeHeader; + + localPart->setPartSpecifier (inSection); + + inWords.pos++; + skipWS (inWords); + + //body type + typeStr = parseLiteralC(inWords); + + //body subtype + subtype = parseLiteralC(inWords); + + localPart->setType (typeStr + "/" + subtype); + + //body parameter parenthesized list + parameters = parseParameters (inWords); + { + TQAsciiDictIterator < TQString > it (parameters); + + while (it.current ()) + { + localPart->setTypeParm (it.currentKey (), *(it.current ())); + ++it; + } + parameters.clear (); + } + + //body id + localPart->setID (parseLiteralC(inWords)); + + //body description + localPart->setDescription (parseLiteralC(inWords)); + + //body encoding + localPart->setEncoding (parseLiteralC(inWords)); + + //body size + if (parseOneNumber (inWords, size)) + localPart->setLength (size); + + // type specific extensions + if (localPart->getType().upper() == "MESSAGE/RFC822") + { + //envelope structure + mailHeader *envelope = parseEnvelope (inWords); + + //body structure + parseBodyStructure (inWords, inSection, envelope); + + localPart->setNestedMessage (envelope); + + //text lines + ulong lines; + parseOneNumber (inWords, lines); + } + else + { + if (typeStr == "TEXT") + { + //text lines + ulong lines; + parseOneNumber (inWords, lines); + } + + // md5 + parseLiteralC(inWords); + + // body disposition + parameters = parseDisposition (inWords); + { + TQString *disposition = parameters["content-disposition"]; + + if (disposition) + localPart->setDisposition (disposition->ascii ()); + parameters.remove ("content-disposition"); + TQAsciiDictIterator < TQString > it (parameters); + while (it.current ()) + { + localPart->setDispositionParm (it.currentKey (), + *(it.current ())); + ++it; + } + + parameters.clear (); + } + + // body language + parseSentence (inWords); + } + + // see if we have more to come + while (!inWords.isEmpty () && inWords[0] != ')') + { + //eat the extensions to this part + if (inWords[0] == '(') + parseSentence (inWords); + else + parseLiteralC(inWords); + } + if (inWords[0] == ')') + inWords.pos++; + skipWS (inWords); + + return localPart; +} + +mimeHeader * imapParser::parseBodyStructure (parseString & inWords, + TQString & inSection, mimeHeader * localPart) +{ + bool init = false; + if (inSection.isEmpty()) + { + // first run + init = true; + // assume one part + inSection = "1"; + } + int section = 0; + + if (inWords[0] != '(') + { + // skip "" + parseOneWordC (inWords); + return 0; + } + inWords.pos++; + skipWS (inWords); + + if (inWords[0] == '(') + { + TQByteArray subtype; + TQAsciiDict < TQString > parameters (17, false); + TQString outSection; + parameters.setAutoDelete (true); + if (!localPart) + localPart = new mimeHeader; + else + { + // might be filled from an earlier run + localPart->clearNestedParts (); + localPart->clearTypeParameters (); + localPart->clearDispositionParameters (); + // an envelope was passed in so this is the multipart header + outSection = inSection + ".HEADER"; + } + if (inWords[0] == '(' && init) + inSection = "0"; + + // set the section + if ( !outSection.isEmpty() ) { + localPart->setPartSpecifier(outSection); + } else { + localPart->setPartSpecifier(inSection); + } + + // is multipart (otherwise it is a simplepart and handled later) + while (inWords[0] == '(') + { + outSection = TQString::number(++section); + if (!init) + outSection = inSection + "." + outSection; + mimeHeader *subpart = parseBodyStructure (inWords, outSection, 0); + localPart->addNestedPart (subpart); + } + + // fetch subtype + subtype = parseOneWordC (inWords); + + localPart->setType ("MULTIPART/" + b2c(subtype)); + + // fetch parameters + parameters = parseParameters (inWords); + { + TQAsciiDictIterator < TQString > it (parameters); + + while (it.current ()) + { + localPart->setTypeParm (it.currentKey (), *(it.current ())); + ++it; + } + parameters.clear (); + } + + // body disposition + parameters = parseDisposition (inWords); + { + TQString *disposition = parameters["content-disposition"]; + + if (disposition) + localPart->setDisposition (disposition->ascii ()); + parameters.remove ("content-disposition"); + TQAsciiDictIterator < TQString > it (parameters); + while (it.current ()) + { + localPart->setDispositionParm (it.currentKey (), + *(it.current ())); + ++it; + } + parameters.clear (); + } + + // body language + parseSentence (inWords); + + } + else + { + // is simple part + inWords.pos--; + inWords.data[inWords.pos] = '('; //fake a sentence + if ( localPart ) + inSection = inSection + ".1"; + localPart = parseSimplePart (inWords, inSection, localPart); + inWords.pos--; + inWords.data[inWords.pos] = ')'; //remove fake + } + + // see if we have more to come + while (!inWords.isEmpty () && inWords[0] != ')') + { + //eat the extensions to this part + if (inWords[0] == '(') + parseSentence (inWords); + else + parseLiteralC(inWords); + } + + if (inWords[0] == ')') + inWords.pos++; + skipWS (inWords); + + return localPart; +} + +void imapParser::parseBody (parseString & inWords) +{ + // see if we got a part specifier + if (inWords[0] == '[') + { + TQCString specifier; + TQCString label; + inWords.pos++; + + specifier = parseOneWordC (inWords, TRUE); + + if (inWords[0] == '(') + { + inWords.pos++; + + while (!inWords.isEmpty () && inWords[0] != ')') + { + label = parseOneWordC (inWords); + } + + if (!inWords.isEmpty () && inWords[0] == ')') + inWords.pos++; + } + if (!inWords.isEmpty () && inWords[0] == ']') + inWords.pos++; + skipWS (inWords); + + // parse the header + if (specifier == "0") + { + mailHeader *envelope = 0; + if (lastHandled) + envelope = lastHandled->getHeader (); + + if (!envelope || seenUid.isEmpty ()) + { + kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; + // don't know where to put it, throw it away + parseLiteralC(inWords, true); + } + else + { + kdDebug(7116) << "imapParser::parseBody - reading " << envelope << " " << seenUid.ascii () << endl; + // fill it up with data + TQString theHeader = parseLiteralC(inWords, true); + mimeIOTQString myIO; + + myIO.setString (theHeader); + envelope->parseHeader (myIO); + + } + } + else if (specifier == "HEADER.FIELDS") + { + // BODY[HEADER.FIELDS (References)] {n} + //kdDebug(7116) << "imapParser::parseBody - HEADER.FIELDS: " + // << TQCString(label.data(), label.size()+1) << endl; + if (label == "REFERENCES") + { + mailHeader *envelope = 0; + if (lastHandled) + envelope = lastHandled->getHeader (); + + if (!envelope || seenUid.isEmpty ()) + { + kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; + // don't know where to put it, throw it away + parseLiteralC (inWords, true); + } + else + { + TQCString references = parseLiteralC(inWords, true); + int start = references.find ('<'); + int end = references.findRev ('>'); + if (start < end) + references = references.mid (start, end - start + 1); + envelope->setReferences(references.simplifyWhiteSpace()); + } + } + else + { // not a header we care about throw it away + parseLiteralC(inWords, true); + } + } + else + { + if (specifier.find(".MIME") != -1) + { + mailHeader *envelope = new mailHeader; + TQString theHeader = parseLiteralC(inWords, false); + mimeIOTQString myIO; + myIO.setString (theHeader); + envelope->parseHeader (myIO); + if (lastHandled) + lastHandled->setHeader (envelope); + return; + } + // throw it away + kdDebug(7116) << "imapParser::parseBody - discarding " << seenUid.ascii () << endl; + parseLiteralC(inWords, true); + } + + } + else // no part specifier + { + mailHeader *envelope = 0; + if (lastHandled) + envelope = lastHandled->getHeader (); + + if (!envelope || seenUid.isEmpty ()) + { + kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl; + // don't know where to put it, throw it away + parseSentence (inWords); + } + else + { + kdDebug(7116) << "imapParser::parseBody - reading " << envelope << " " << seenUid.ascii () << endl; + // fill it up with data + TQString section; + mimeHeader *body = parseBodyStructure (inWords, section, envelope); + if (body != envelope) + delete body; + } + } +} + +void imapParser::parseFetch (ulong /* value */, parseString & inWords) +{ + if (inWords[0] != '(') + return; + inWords.pos++; + skipWS (inWords); + + delete lastHandled; + lastHandled = 0; + + while (!inWords.isEmpty () && inWords[0] != ')') + { + if (inWords[0] == '(') + parseSentence (inWords); + else + { + TQCString word = parseLiteralC(inWords, false, true); + + if(!word.isEmpty()) { + switch (word[0]) + { + case 'E': + if (word == "ENVELOPE") + { + mailHeader *envelope = 0; + + if (lastHandled) + envelope = lastHandled->getHeader (); + else + lastHandled = new imapCache(); + + if (envelope && !envelope->getMessageId ().isEmpty ()) + { + // we have seen this one already + // or don't know where to put it + parseSentence (inWords); + } + else + { + envelope = parseEnvelope (inWords); + if (envelope) + { + envelope->setPartSpecifier (seenUid + ".0"); + lastHandled->setHeader (envelope); + lastHandled->setUid (seenUid.toULong ()); + } + } + } + break; + + case 'B': + if (word == "BODY") + { + parseBody (inWords); + } + else if (word == "BODY[]" ) + { + // Do the same as with "RFC822" + parseLiteralC(inWords, true); + } + else if (word == "BODYSTRUCTURE") + { + mailHeader *envelope = 0; + + if (lastHandled) + envelope = lastHandled->getHeader (); + + // fill it up with data + TQString section; + mimeHeader *body = + parseBodyStructure (inWords, section, envelope); + TQByteArray data; + TQDataStream stream( data, IO_WriteOnly ); + if (body) body->serialize(stream); + parseRelay(data); + + delete body; + } + break; + + case 'U': + if (word == "UID") + { + seenUid = parseOneWordC(inWords); + mailHeader *envelope = 0; + if (lastHandled) + envelope = lastHandled->getHeader (); + else + lastHandled = new imapCache(); + + if (seenUid.isEmpty ()) + { + // unknown what to do + kdDebug(7116) << "imapParser::parseFetch - UID empty" << endl; + } + else + { + lastHandled->setUid (seenUid.toULong ()); + } + if (envelope) + envelope->setPartSpecifier (seenUid); + } + break; + + case 'R': + if (word == "RFC822.SIZE") + { + ulong size; + parseOneNumber (inWords, size); + + if (!lastHandled) lastHandled = new imapCache(); + lastHandled->setSize (size); + } + else if (word.find ("RFC822") == 0) + { + // might be RFC822 RFC822.TEXT RFC822.HEADER + parseLiteralC(inWords, true); + } + break; + + case 'I': + if (word == "INTERNALDATE") + { + TQCString date = parseOneWordC(inWords); + if (!lastHandled) lastHandled = new imapCache(); + lastHandled->setDate(date); + } + break; + + case 'F': + if (word == "FLAGS") + { + //kdDebug(7116) << "GOT FLAGS " << inWords.cstr() << endl; + if (!lastHandled) lastHandled = new imapCache(); + lastHandled->setFlags (imapInfo::_flags (inWords.cstr())); + } + break; + + default: + parseLiteralC(inWords); + break; + } + } else { + parseLiteralC(inWords); + } + } + } + + // see if we have more to come + while (!inWords.isEmpty () && inWords[0] != ')') + { + //eat the extensions to this part + if (inWords[0] == '(') + parseSentence (inWords); + else + parseLiteralC(inWords); + } + + if (inWords.isEmpty() || inWords[0] != ')') + return; + inWords.pos++; + skipWS (inWords); +} + + +// default parser +void imapParser::parseSentence (parseString & inWords) +{ + bool first = true; + int stack = 0; + + //find the first nesting parentheses + + while (!inWords.isEmpty () && (stack != 0 || first)) + { + first = false; + skipWS (inWords); + + unsigned char ch = inWords[0]; + switch (ch) + { + case '(': + inWords.pos++; + ++stack; + break; + case ')': + inWords.pos++; + --stack; + break; + case '[': + inWords.pos++; + ++stack; + break; + case ']': + inWords.pos++; + --stack; + break; + default: + parseLiteralC(inWords); + skipWS (inWords); + break; + } + } + skipWS (inWords); +} + +void imapParser::parseRecent (ulong value, parseString & result) +{ + selectInfo.setRecent (value); + result.pos = result.data.size(); +} + +void imapParser::parseNamespace (parseString & result) +{ + if ( result[0] != '(' ) + return; + + TQString delimEmpty; + if ( namespaceToDelimiter.contains( TQString() ) ) + delimEmpty = namespaceToDelimiter[TQString()]; + + namespaceToDelimiter.clear(); + imapNamespaces.clear(); + + // remember what section we're in (user, other users, shared) + int ns = -1; + bool personalAvailable = false; + while ( !result.isEmpty() ) + { + if ( result[0] == '(' ) + { + result.pos++; // tie off ( + if ( result[0] == '(' ) + { + // new namespace section + result.pos++; // tie off ( + ++ns; + } + // namespace prefix + TQCString prefix = parseOneWordC( result ); + // delimiter + TQCString delim = parseOneWordC( result ); + kdDebug(7116) << "imapParser::parseNamespace ns='" << prefix << + "',delim='" << delim << "'" << endl; + if ( ns == 0 ) + { + // at least one personal ns + personalAvailable = true; + } + TQString nsentry = TQString::number( ns ) + "=" + TQString(prefix) + + "=" + TQString(delim); + imapNamespaces.append( nsentry ); + if ( prefix.right( 1 ) == delim ) { + // strip delimiter to get a correct entry for comparisons + prefix.resize( prefix.length() ); + } + namespaceToDelimiter[prefix] = delim; + + result.pos++; // tie off ) + skipWS( result ); + } else if ( result[0] == ')' ) + { + result.pos++; // tie off ) + skipWS( result ); + } else if ( result[0] == 'N' ) + { + // drop NIL + ++ns; + parseOneWordC( result ); + } else { + // drop whatever it is + parseOneWordC( result ); + } + } + if ( !delimEmpty.isEmpty() ) { + // remember default delimiter + namespaceToDelimiter[TQString()] = delimEmpty; + if ( !personalAvailable ) + { + // at least one personal ns would be nice + kdDebug(7116) << "imapParser::parseNamespace - registering own personal ns" << endl; + TQString nsentry = "0==" + delimEmpty; + imapNamespaces.append( nsentry ); + } + } +} + +int imapParser::parseLoop () +{ + parseString result; + + if (!parseReadLine(result.data)) return -1; + + //kdDebug(7116) << result.cstr(); // includes \n + + if (result.data.isEmpty()) + return 0; + if (!sentQueue.count ()) + { + // maybe greeting or BYE everything else SHOULD not happen, use NOOP or IDLE + kdDebug(7116) << "imapParser::parseLoop - unhandledResponse: \n" << result.cstr() << endl; + unhandled << result.cstr(); + } + else + { + imapCommand *current = sentQueue.at (0); + switch (result[0]) + { + case '*': + result.data.resize(result.data.size() - 2); // tie off CRLF + parseUntagged (result); + break; + case '+': + continuation.duplicate(result.data); + break; + default: + { + TQCString tag = parseLiteralC(result); + if (current->id() == tag.data()) + { + result.data.resize(result.data.size() - 2); // tie off CRLF + TQByteArray resultCode = parseLiteral (result); //the result + current->setResult (resultCode); + current->setResultInfo(result.cstr()); + current->setComplete (); + + sentQueue.removeRef (current); + completeQueue.append (current); + if (result.length()) + parseResult (resultCode, result, current->command()); + } + else + { + kdDebug(7116) << "imapParser::parseLoop - unknown tag '" << tag << "'" << endl; + TQCString cstr = tag + " " + result.cstr(); + result.data = cstr; + result.pos = 0; + result.data.resize(cstr.length()); + } + } + break; + } + } + + return 1; +} + +void +imapParser::parseRelay (const TQByteArray & buffer) +{ + Q_UNUSED(buffer); + tqWarning + ("imapParser::parseRelay - virtual function not reimplemented - data lost"); +} + +void +imapParser::parseRelay (ulong len) +{ + Q_UNUSED(len); + tqWarning + ("imapParser::parseRelay - virtual function not reimplemented - announcement lost"); +} + +bool imapParser::parseRead (TQByteArray & buffer, ulong len, ulong relay) +{ + Q_UNUSED(buffer); + Q_UNUSED(len); + Q_UNUSED(relay); + tqWarning + ("imapParser::parseRead - virtual function not reimplemented - no data read"); + return FALSE; +} + +bool imapParser::parseReadLine (TQByteArray & buffer, ulong relay) +{ + Q_UNUSED(buffer); + Q_UNUSED(relay); + tqWarning + ("imapParser::parseReadLine - virtual function not reimplemented - no data read"); + return FALSE; +} + +void +imapParser::parseWriteLine (const TQString & str) +{ + Q_UNUSED(str); + tqWarning + ("imapParser::parseWriteLine - virtual function not reimplemented - no data written"); +} + +void +imapParser::parseURL (const KURL & _url, TQString & _box, TQString & _section, + TQString & _type, TQString & _uid, TQString & _validity, TQString & _info) +{ + TQStringList parameters; + + _box = _url.path (); + kdDebug(7116) << "imapParser::parseURL " << _box << endl; + int paramStart = _box.find("/;"); + if ( paramStart > -1 ) + { + TQString paramString = _box.right( _box.length() - paramStart-2 ); + parameters = TQStringList::split (';', paramString); //split parameters + _box.truncate( paramStart ); // strip parameters + } + // extract parameters + for (TQStringList::ConstIterator it (parameters.begin ()); + it != parameters.end (); ++it) + { + TQString temp = (*it); + + int pt = temp.find ('/'); + if (pt > 0) + { + if (temp.findRev ('"', pt) == -1 || temp.find('"', pt) == -1) + { + // if we have non-quoted '/' separator we'll just nuke it + temp.truncate(pt); + } + } + if (temp.find ("section=", 0, false) == 0) + _section = temp.right (temp.length () - 8); + else if (temp.find ("type=", 0, false) == 0) + _type = temp.right (temp.length () - 5); + else if (temp.find ("uid=", 0, false) == 0) + _uid = temp.right (temp.length () - 4); + else if (temp.find ("uidvalidity=", 0, false) == 0) + _validity = temp.right (temp.length () - 12); + else if (temp.find ("info=", 0, false) == 0) + _info = temp.right (temp.length () - 5); + } +// kdDebug(7116) << "URL: section= " << _section << ", type= " << _type << ", uid= " << _uid << endl; +// kdDebug(7116) << "URL: user() " << _url.user() << endl; +// kdDebug(7116) << "URL: path() " << _url.path() << endl; +// kdDebug(7116) << "URL: encodedPathAndQuery() " << _url.encodedPathAndQuery() << endl; + + if (!_box.isEmpty ()) + { + // strip / + if (_box[0] == '/') + _box = _box.right (_box.length () - 1); + if (!_box.isEmpty () && _box[_box.length () - 1] == '/') + _box.truncate(_box.length() - 1); + } + kdDebug(7116) << "URL: box= " << _box << ", section= " << _section << ", type= " + << _type << ", uid= " << _uid << ", validity= " << _validity << ", info= " << _info << endl; +} + + +TQCString imapParser::parseLiteralC(parseString & inWords, bool relay, bool stopAtBracket, int *outlen) { + + if (!inWords.isEmpty() && inWords[0] == '{') + { + TQCString retVal; + long srunLen = inWords.find ('}', 1); // Can return -1, so use a signed long + if (srunLen > 0) + { + ulong runLen = (ulong)srunLen; + bool proper; + ulong runLenSave = runLen + 1; + TQCString tmpstr(runLen); + inWords.takeMidNoResize(tmpstr, 1, runLen - 1); + runLen = tmpstr.toULong (&proper); + inWords.pos += runLenSave; + if (proper) + { + //now get the literal from the server + if (relay) + parseRelay (runLen); + TQByteArray rv; + parseRead (rv, runLen, relay ? runLen : 0); + rv.resize(TQMAX(runLen, rv.size())); // what's the point? + retVal = b2c(rv); + inWords.clear(); + parseReadLine (inWords.data); // must get more + + // no duplicate data transfers + relay = false; + } + else + { + kdDebug(7116) << "imapParser::parseLiteral - error parsing {} - " /*<< strLen*/ << endl; + } + } + else + { + inWords.clear(); + kdDebug(7116) << "imapParser::parseLiteral - error parsing unmatched {" << endl; + } + if (outlen) { + *outlen = retVal.length(); // optimize me + } + skipWS (inWords); + return retVal; + } + + return parseOneWordC(inWords, stopAtBracket, outlen); +} + +// does not know about literals ( {7} literal ) +TQCString imapParser::parseOneWordC (parseString & inWords, bool stopAtBracket, int *outLen) +{ + uint retValSize = 0; + uint len = inWords.length(); + if (len == 0) { + return TQCString(); + } + + if (len > 0 && inWords[0] == '"') + { + unsigned int i = 1; + bool quote = FALSE; + while (i < len && (inWords[i] != '"' || quote)) + { + if (inWords[i] == '\\') quote = !quote; + else quote = FALSE; + i++; + } + if (i < len) + { + TQCString retVal(i); + inWords.pos++; + inWords.takeLeftNoResize(retVal, i - 1); + len = i - 1; + int offset = 0; + for (unsigned int j = 0; j <= len; j++) { + if (retVal[j] == '\\') { + offset++; + j++; + } + retVal[j - offset] = retVal[j]; + } + retVal[len - offset] = 0; + retValSize = len - offset; + inWords.pos += i; + skipWS (inWords); + if (outLen) { + *outLen = retValSize; + } + return retVal; + } + else + { + kdDebug(7116) << "imapParser::parseOneWord - error parsing unmatched \"" << endl; + TQCString retVal = inWords.cstr(); + retValSize = len; + inWords.clear(); + if (outLen) { + *outLen = retValSize; + } + return retVal; + } + } + else + { + // not quoted + unsigned int i; + // search for end + for (i = 0; i < len; ++i) { + char ch = inWords[i]; + if (ch <= ' ' || ch == '(' || ch == ')' || + (stopAtBracket && (ch == '[' || ch == ']'))) + break; + } + + TQCString retVal(i+1); + inWords.takeLeftNoResize(retVal, i); + retValSize = i; + inWords.pos += i; + + if (retVal == "NIL") { + retVal.truncate(0); + retValSize = 0; + } + skipWS (inWords); + if (outLen) { + *outLen = retValSize; + } + return retVal; + } +} + +bool imapParser::parseOneNumber (parseString & inWords, ulong & num) +{ + bool valid; + num = parseOneWordC(inWords, TRUE).toULong(&valid); + return valid; +} + +bool imapParser::hasCapability (const TQString & cap) +{ + TQString c = cap.lower(); +// kdDebug(7116) << "imapParser::hasCapability - Looking for '" << cap << "'" << endl; + for (TQStringList::ConstIterator it = imapCapabilities.begin (); + it != imapCapabilities.end (); ++it) + { +// kdDebug(7116) << "imapParser::hasCapability - Examining '" << (*it) << "'" << endl; + if ( !(kasciistricmp(c.ascii(), (*it).ascii())) ) + { + return true; + } + } + return false; +} + +void imapParser::removeCapability (const TQString & cap) +{ + imapCapabilities.remove(cap.lower()); +} + +TQString imapParser::namespaceForBox( const TQString & box ) +{ + kdDebug(7116) << "imapParse::namespaceForBox " << box << endl; + TQString myNamespace; + if ( !box.isEmpty() ) + { + TQValueList list = namespaceToDelimiter.keys(); + TQString cleanPrefix; + for ( TQValueList::Iterator it = list.begin(); it != list.end(); ++it ) + { + if ( !(*it).isEmpty() && box.find( *it ) != -1 ) + return (*it); + } + } + return myNamespace; +} + diff --git a/tdeioslave/imap4/mailaddress.cc b/tdeioslave/imap4/mailaddress.cc deleted file mode 100644 index 38a1a330..00000000 --- a/tdeioslave/imap4/mailaddress.cc +++ /dev/null @@ -1,324 +0,0 @@ -/********************************************************************** - * - * mailaddress.cc - mail address parser - * Copyright (C) 2000 Sven Carstens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to - * - *********************************************************************/ - - -#include "mailaddress.h" -#include "rfcdecoder.h" -#include "mimehdrline.h" -#include - -mailAddress::mailAddress () -{ -} - -mailAddress::mailAddress (const mailAddress & lr): -user (lr.user), -host (lr.host), -rawFullName (lr.rawFullName), -rawComment (lr.rawComment) -{ -// kdDebug(7116) << "mailAddress::mailAddress - " << getStr() << endl; -} - -mailAddress & mailAddress::operator = (const mailAddress & lr) -{ - // Avoid a = a. - if (this == &lr) - return *this; - - user = lr.user; - host = lr.host; - rawFullName = lr.rawFullName; - rawComment = lr.rawComment; - -// kdDebug(7116) << "mailAddress::operator= - " << getStr() << endl; - - return *this; -} - - - - -mailAddress::~mailAddress () -{ -} - -mailAddress::mailAddress (char *aCStr) -{ - parseAddress (aCStr); -} - -int -mailAddress::parseAddress (char *aCStr) -{ - int retVal = 0; - int skip; - uint len; - int pt; - - if (aCStr) - { - //skip leading white space - skip = mimeHdrLine::skipWS ((const char *) aCStr); - if (skip > 0) - { - aCStr += skip; - retVal += skip; - } - while (*aCStr) - { - int advance; - - switch (*aCStr) - { - case '"': - advance = mimeHdrLine::parseQuoted ('"', '"', aCStr); - rawFullName += TQCString (aCStr, advance + 1); - break; - case '(': - advance = mimeHdrLine::parseQuoted ('(', ')', aCStr); - rawComment += TQCString (aCStr, advance + 1); - break; - case '<': - advance = mimeHdrLine::parseQuoted ('<', '>', aCStr); - user = TQCString (aCStr, advance + 1); // copy it - len = advance; - user = user.mid (1, len - 2); // strip <> - len -= 2; - pt = user.find('@'); - host = user.right (len - pt - 1); // split it into host - user.truncate(pt); // and user - break; - default: - advance = mimeHdrLine::parseWord ((const char *) aCStr); - //if we've seen a FQ mailname the rest must be quoted or is just junk - if (user.isEmpty ()) - { - if (*aCStr != ',') - { - rawFullName += TQCString (aCStr, advance + 1); - if (mimeHdrLine::skipWS ((const char *) &aCStr[advance]) > 0) - { - rawFullName += ' '; - } - } - } - break; - } - if (advance) - { - retVal += advance; - aCStr += advance; - } - else - break; - advance = mimeHdrLine::skipWS ((const char *) aCStr); - if (advance > 0) - { - retVal += advance; - aCStr += advance; - } - //reached end of current address - if (*aCStr == ',') - { - advance++; - break; - } - } - //let's see what we've got - if (rawFullName.isEmpty ()) - { - if (user.isEmpty ()) - retVal = 0; - else - { - if (host.isEmpty ()) - { - rawFullName = user; - user.truncate(0); - } - } - } - else if (user.isEmpty ()) - { - pt = rawFullName.find ('@'); - if (pt >= 0) - { - user = rawFullName; - host = user.right (user.length () - pt - 1); - user.truncate(pt); - rawFullName.truncate(0); - } - } - -#if 0 -// dead - if (!rawFullName.isEmpty ()) - { -// if(fullName[0] == '"') -// fullName = fullName.mid(1,fullName.length()-2); -// fullName = fullName.simplifyWhiteSpace().stripWhiteSpace(); -// fullName = rfcDecoder::decodeRFC2047String(fullName.ascii()); - } -#endif - if (!rawComment.isEmpty ()) - { - if (rawComment[0] == '(') - rawComment = rawComment.mid (1, rawComment.length () - 2); - rawComment = rawComment.stripWhiteSpace (); -// comment = rfcDecoder::decodeRFC2047String(comment.ascii()); - } - } - else - { - //debug(); - } - return retVal; -} - -const TQCString -mailAddress::getStr () const -{ - TQCString retVal(128); // Should be generally big enough - - if (!rawFullName.isEmpty ()) - { - TQCString tmpName( rawFullName ); - KMime::addQuotes( tmpName, false ); - retVal = tmpName + " "; - } - if (!user.isEmpty ()) - { - retVal += '<'; - retVal += user; - if (!host.isEmpty ()) { - retVal += '@'; - retVal += host; - } - retVal += '>'; - } - if (!rawComment.isEmpty ()) - { - retVal += " (" + rawComment + ')'; - } -// kdDebug(7116) << "mailAddress::getStr - '" << retVal << "'" << endl; - return retVal; -} - -bool -mailAddress::isEmpty () const -{ - return user.isEmpty (); -} - -void -mailAddress::setFullName (const TQString & _str) -{ - rawFullName = rfcDecoder::encodeRFC2047String (_str).latin1 (); -} -const TQString -mailAddress::getFullName () const -{ - return rfcDecoder::decodeRFC2047String (rawFullName); -} - -void -mailAddress::setCommentRaw (const TQCString & _str) -{ - rawComment = _str; -} - -void -mailAddress::setComment (const TQString & _str) -{ - rawComment = rfcDecoder::encodeRFC2047String (_str).latin1 (); -} -const TQString -mailAddress::getComment () const -{ - return rfcDecoder::decodeRFC2047String (rawComment); -} - -const TQCString & -mailAddress::getCommentRaw () const -{ - return rawComment; -} - -TQString -mailAddress::emailAddrAsAnchor (const mailAddress & adr, bool shortAdr) -{ - TQString retVal; - if (!adr.getFullName ().isEmpty ()) - { - // should do some umlaut escaping - retVal += adr.getFullName () + " "; - } - if (!adr.getUser ().isEmpty () && !shortAdr) - { - retVal += "<" + adr.getUser (); - if (!adr.getHost ().isEmpty ()) - retVal += "@" + adr.getHost (); - retVal += "> "; - } - if (!adr.getComment ().isEmpty ()) - { - // should do some umlaut escaping - retVal = '(' + adr.getComment () + ')'; - } - - if (!adr.getUser ().isEmpty ()) - { - TQString mail; - mail = adr.getUser (); - if (!mail.isEmpty () && !adr.getHost ().isEmpty ()) - mail += "@" + adr.getHost (); - if (!mail.isEmpty ()) - retVal = "" + retVal + ""; - } - return retVal; -} - -TQString -mailAddress::emailAddrAsAnchor (const TQPtrList < mailAddress > &list, bool value) -{ - TQString retVal; - TQPtrListIterator < mailAddress > it (list); - - while (it.current ()) - { - retVal += emailAddrAsAnchor ((*it.current ()), value) + "

\n"; - ++it; - } - - return retVal; -} - - -void mailAddress::clear() { - user.truncate(0); - host.truncate(0); - rawFullName.truncate(0); - rawComment.truncate(0); -} - diff --git a/tdeioslave/imap4/mailaddress.cpp b/tdeioslave/imap4/mailaddress.cpp new file mode 100644 index 00000000..8bb5831e --- /dev/null +++ b/tdeioslave/imap4/mailaddress.cpp @@ -0,0 +1,324 @@ +/********************************************************************** + * + * mailaddress.cpp - mail address parser + * Copyright (C) 2000 Sven Carstens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to + * + *********************************************************************/ + + +#include "mailaddress.h" +#include "rfcdecoder.h" +#include "mimehdrline.h" +#include + +mailAddress::mailAddress () +{ +} + +mailAddress::mailAddress (const mailAddress & lr): +user (lr.user), +host (lr.host), +rawFullName (lr.rawFullName), +rawComment (lr.rawComment) +{ +// kdDebug(7116) << "mailAddress::mailAddress - " << getStr() << endl; +} + +mailAddress & mailAddress::operator = (const mailAddress & lr) +{ + // Avoid a = a. + if (this == &lr) + return *this; + + user = lr.user; + host = lr.host; + rawFullName = lr.rawFullName; + rawComment = lr.rawComment; + +// kdDebug(7116) << "mailAddress::operator= - " << getStr() << endl; + + return *this; +} + + + + +mailAddress::~mailAddress () +{ +} + +mailAddress::mailAddress (char *aCStr) +{ + parseAddress (aCStr); +} + +int +mailAddress::parseAddress (char *aCStr) +{ + int retVal = 0; + int skip; + uint len; + int pt; + + if (aCStr) + { + //skip leading white space + skip = mimeHdrLine::skipWS ((const char *) aCStr); + if (skip > 0) + { + aCStr += skip; + retVal += skip; + } + while (*aCStr) + { + int advance; + + switch (*aCStr) + { + case '"': + advance = mimeHdrLine::parseQuoted ('"', '"', aCStr); + rawFullName += TQCString (aCStr, advance + 1); + break; + case '(': + advance = mimeHdrLine::parseQuoted ('(', ')', aCStr); + rawComment += TQCString (aCStr, advance + 1); + break; + case '<': + advance = mimeHdrLine::parseQuoted ('<', '>', aCStr); + user = TQCString (aCStr, advance + 1); // copy it + len = advance; + user = user.mid (1, len - 2); // strip <> + len -= 2; + pt = user.find('@'); + host = user.right (len - pt - 1); // split it into host + user.truncate(pt); // and user + break; + default: + advance = mimeHdrLine::parseWord ((const char *) aCStr); + //if we've seen a FQ mailname the rest must be quoted or is just junk + if (user.isEmpty ()) + { + if (*aCStr != ',') + { + rawFullName += TQCString (aCStr, advance + 1); + if (mimeHdrLine::skipWS ((const char *) &aCStr[advance]) > 0) + { + rawFullName += ' '; + } + } + } + break; + } + if (advance) + { + retVal += advance; + aCStr += advance; + } + else + break; + advance = mimeHdrLine::skipWS ((const char *) aCStr); + if (advance > 0) + { + retVal += advance; + aCStr += advance; + } + //reached end of current address + if (*aCStr == ',') + { + advance++; + break; + } + } + //let's see what we've got + if (rawFullName.isEmpty ()) + { + if (user.isEmpty ()) + retVal = 0; + else + { + if (host.isEmpty ()) + { + rawFullName = user; + user.truncate(0); + } + } + } + else if (user.isEmpty ()) + { + pt = rawFullName.find ('@'); + if (pt >= 0) + { + user = rawFullName; + host = user.right (user.length () - pt - 1); + user.truncate(pt); + rawFullName.truncate(0); + } + } + +#if 0 +// dead + if (!rawFullName.isEmpty ()) + { +// if(fullName[0] == '"') +// fullName = fullName.mid(1,fullName.length()-2); +// fullName = fullName.simplifyWhiteSpace().stripWhiteSpace(); +// fullName = rfcDecoder::decodeRFC2047String(fullName.ascii()); + } +#endif + if (!rawComment.isEmpty ()) + { + if (rawComment[0] == '(') + rawComment = rawComment.mid (1, rawComment.length () - 2); + rawComment = rawComment.stripWhiteSpace (); +// comment = rfcDecoder::decodeRFC2047String(comment.ascii()); + } + } + else + { + //debug(); + } + return retVal; +} + +const TQCString +mailAddress::getStr () const +{ + TQCString retVal(128); // Should be generally big enough + + if (!rawFullName.isEmpty ()) + { + TQCString tmpName( rawFullName ); + KMime::addQuotes( tmpName, false ); + retVal = tmpName + " "; + } + if (!user.isEmpty ()) + { + retVal += '<'; + retVal += user; + if (!host.isEmpty ()) { + retVal += '@'; + retVal += host; + } + retVal += '>'; + } + if (!rawComment.isEmpty ()) + { + retVal += " (" + rawComment + ')'; + } +// kdDebug(7116) << "mailAddress::getStr - '" << retVal << "'" << endl; + return retVal; +} + +bool +mailAddress::isEmpty () const +{ + return user.isEmpty (); +} + +void +mailAddress::setFullName (const TQString & _str) +{ + rawFullName = rfcDecoder::encodeRFC2047String (_str).latin1 (); +} +const TQString +mailAddress::getFullName () const +{ + return rfcDecoder::decodeRFC2047String (rawFullName); +} + +void +mailAddress::setCommentRaw (const TQCString & _str) +{ + rawComment = _str; +} + +void +mailAddress::setComment (const TQString & _str) +{ + rawComment = rfcDecoder::encodeRFC2047String (_str).latin1 (); +} +const TQString +mailAddress::getComment () const +{ + return rfcDecoder::decodeRFC2047String (rawComment); +} + +const TQCString & +mailAddress::getCommentRaw () const +{ + return rawComment; +} + +TQString +mailAddress::emailAddrAsAnchor (const mailAddress & adr, bool shortAdr) +{ + TQString retVal; + if (!adr.getFullName ().isEmpty ()) + { + // should do some umlaut escaping + retVal += adr.getFullName () + " "; + } + if (!adr.getUser ().isEmpty () && !shortAdr) + { + retVal += "<" + adr.getUser (); + if (!adr.getHost ().isEmpty ()) + retVal += "@" + adr.getHost (); + retVal += "> "; + } + if (!adr.getComment ().isEmpty ()) + { + // should do some umlaut escaping + retVal = '(' + adr.getComment () + ')'; + } + + if (!adr.getUser ().isEmpty ()) + { + TQString mail; + mail = adr.getUser (); + if (!mail.isEmpty () && !adr.getHost ().isEmpty ()) + mail += "@" + adr.getHost (); + if (!mail.isEmpty ()) + retVal = "" + retVal + ""; + } + return retVal; +} + +TQString +mailAddress::emailAddrAsAnchor (const TQPtrList < mailAddress > &list, bool value) +{ + TQString retVal; + TQPtrListIterator < mailAddress > it (list); + + while (it.current ()) + { + retVal += emailAddrAsAnchor ((*it.current ()), value) + "

\n"; + ++it; + } + + return retVal; +} + + +void mailAddress::clear() { + user.truncate(0); + host.truncate(0); + rawFullName.truncate(0); + rawComment.truncate(0); +} + diff --git a/tdeioslave/imap4/mailheader.cc b/tdeioslave/imap4/mailheader.cc deleted file mode 100644 index c520b909..00000000 --- a/tdeioslave/imap4/mailheader.cc +++ /dev/null @@ -1,203 +0,0 @@ -/*************************************************************************** - mailheader.cc - description - ------------------- - begin : Tue Oct 24 2000 - copyright : (C) 2000 by Sven Carstens - email : s.carstens@gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "mailheader.h" -#include "rfcdecoder.h" - -mailHeader::mailHeader () -{ - toAdr.setAutoDelete (true); - ccAdr.setAutoDelete (true); - bccAdr.setAutoDelete (true); - setType ("text/plain"); - gmt_offset = 0; -} - -mailHeader::~mailHeader () -{ -} - -void -mailHeader::addHdrLine (mimeHdrLine * inLine) -{ - mimeHdrLine *addLine = new mimeHdrLine (inLine); - - const TQCString label(addLine->getLabel()); - TQCString value(addLine->getValue()); - - if (!tqstricmp (label, "Return-Path")) { - returnpathAdr.parseAddress (value.data ()); - goto out; - } - if (!tqstricmp (label, "Sender")) { - senderAdr.parseAddress (value.data ()); - goto out; - } - if (!tqstricmp (label, "From")) { - fromAdr.parseAddress (value.data ()); - goto out; - } - if (!tqstricmp (label, "Reply-To")) { - replytoAdr.parseAddress (value.data ()); - goto out; - } - if (!tqstricmp (label, "To")) { - mailHeader::parseAddressList (value, &toAdr); - goto out; - } - if (!tqstricmp (label, "CC")) { - mailHeader::parseAddressList (value, &ccAdr); - goto out; - } - if (!tqstricmp (label, "BCC")) { - mailHeader::parseAddressList (value, &bccAdr); - goto out; - } - if (!tqstricmp (label, "Subject")) { - _subject = value.simplifyWhiteSpace(); - goto out; - } - if (!tqstricmp (label.data (), "Date")) { - mDate = value; - goto out; - } - if (!tqstricmp (label.data (), "Message-ID")) { - int start = value.findRev ('<'); - int end = value.findRev ('>'); - if (start < end) - messageID = value.mid (start, end - start + 1); - else { - tqWarning("bad Message-ID"); - /* messageID = value; */ - } - goto out; - } - if (!tqstricmp (label.data (), "In-Reply-To")) { - int start = value.findRev ('<'); - int end = value.findRev ('>'); - if (start < end) - inReplyTo = value.mid (start, end - start + 1); - goto out; - } - - // everything else is handled by mimeHeader - mimeHeader::addHdrLine (inLine); - delete addLine; - return; - - out: -// cout << label.data() << ": '" << value.data() << "'" << endl; - - //need only to add this line if not handled by mimeHeader - originalHdrLines.append (addLine); -} - -void -mailHeader::outputHeader (mimeIO & useIO) -{ - static const TQCString __returnPath("Return-Path: ", 14); - static const TQCString __from ("From: ", 7); - static const TQCString __sender ("Sender: ", 9); - static const TQCString __replyTo ("Reply-To: ", 11); - static const TQCString __to ("To: ", 5); - static const TQCString __cc ("CC: ", 5); - static const TQCString __bcc ("BCC: ", 6); - static const TQCString __subject ("Subject: ", 10); - static const TQCString __messageId ("Message-ID: ", 13); - static const TQCString __inReplyTo ("In-Reply-To: ", 14); - static const TQCString __references("References: ", 13); - static const TQCString __date ("Date: ", 7); - - if (!returnpathAdr.isEmpty()) - useIO.outputMimeLine(__returnPath + returnpathAdr.getStr()); - if (!fromAdr.isEmpty()) - useIO.outputMimeLine(__from + fromAdr.getStr()); - if (!senderAdr.isEmpty()) - useIO.outputMimeLine(__sender + senderAdr.getStr()); - if (!replytoAdr.isEmpty()) - useIO.outputMimeLine(__replyTo + replytoAdr.getStr()); - - if (toAdr.count()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__to + - mailHeader::getAddressStr(&toAdr))); - if (ccAdr.count()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__cc + - mailHeader::getAddressStr(&ccAdr))); - if (bccAdr.count()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__bcc + - mailHeader::getAddressStr(&bccAdr))); - if (!_subject.isEmpty()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__subject + _subject)); - if (!messageID.isEmpty()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__messageId + messageID)); - if (!inReplyTo.isEmpty()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__inReplyTo + inReplyTo)); - if (!references.isEmpty()) - useIO.outputMimeLine(mimeHdrLine::truncateLine(__references + references)); - - if (!mDate.isEmpty()) - useIO.outputMimeLine(__date + mDate); - mimeHeader::outputHeader(useIO); -} - -int -mailHeader::parseAddressList (const char *inCStr, - TQPtrList < mailAddress > *aList) -{ - int advance = 0; - int skip = 1; - char *aCStr = (char *) inCStr; - - if (!aCStr || !aList) - return 0; - while (skip > 0) - { - mailAddress *aAddress = new mailAddress; - skip = aAddress->parseAddress (aCStr); - if (skip) - { - aCStr += skip; - if (skip < 0) - advance -= skip; - else - advance += skip; - aList->append (aAddress); - } - else - { - delete aAddress; - break; - } - } - return advance; -} - -TQCString -mailHeader::getAddressStr (TQPtrList < mailAddress > *aList) -{ - TQCString retVal; - - TQPtrListIterator < mailAddress > it = TQPtrListIterator < mailAddress > (*aList); - while (it.current ()) - { - retVal += it.current ()->getStr (); - ++it; - if (it.current ()) - retVal += ", "; - } - return retVal; -} diff --git a/tdeioslave/imap4/mailheader.cpp b/tdeioslave/imap4/mailheader.cpp new file mode 100644 index 00000000..28eec1f0 --- /dev/null +++ b/tdeioslave/imap4/mailheader.cpp @@ -0,0 +1,203 @@ +/*************************************************************************** + mailheader.cpp - description + ------------------- + begin : Tue Oct 24 2000 + copyright : (C) 2000 by Sven Carstens + email : s.carstens@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mailheader.h" +#include "rfcdecoder.h" + +mailHeader::mailHeader () +{ + toAdr.setAutoDelete (true); + ccAdr.setAutoDelete (true); + bccAdr.setAutoDelete (true); + setType ("text/plain"); + gmt_offset = 0; +} + +mailHeader::~mailHeader () +{ +} + +void +mailHeader::addHdrLine (mimeHdrLine * inLine) +{ + mimeHdrLine *addLine = new mimeHdrLine (inLine); + + const TQCString label(addLine->getLabel()); + TQCString value(addLine->getValue()); + + if (!tqstricmp (label, "Return-Path")) { + returnpathAdr.parseAddress (value.data ()); + goto out; + } + if (!tqstricmp (label, "Sender")) { + senderAdr.parseAddress (value.data ()); + goto out; + } + if (!tqstricmp (label, "From")) { + fromAdr.parseAddress (value.data ()); + goto out; + } + if (!tqstricmp (label, "Reply-To")) { + replytoAdr.parseAddress (value.data ()); + goto out; + } + if (!tqstricmp (label, "To")) { + mailHeader::parseAddressList (value, &toAdr); + goto out; + } + if (!tqstricmp (label, "CC")) { + mailHeader::parseAddressList (value, &ccAdr); + goto out; + } + if (!tqstricmp (label, "BCC")) { + mailHeader::parseAddressList (value, &bccAdr); + goto out; + } + if (!tqstricmp (label, "Subject")) { + _subject = value.simplifyWhiteSpace(); + goto out; + } + if (!tqstricmp (label.data (), "Date")) { + mDate = value; + goto out; + } + if (!tqstricmp (label.data (), "Message-ID")) { + int start = value.findRev ('<'); + int end = value.findRev ('>'); + if (start < end) + messageID = value.mid (start, end - start + 1); + else { + tqWarning("bad Message-ID"); + /* messageID = value; */ + } + goto out; + } + if (!tqstricmp (label.data (), "In-Reply-To")) { + int start = value.findRev ('<'); + int end = value.findRev ('>'); + if (start < end) + inReplyTo = value.mid (start, end - start + 1); + goto out; + } + + // everything else is handled by mimeHeader + mimeHeader::addHdrLine (inLine); + delete addLine; + return; + + out: +// cout << label.data() << ": '" << value.data() << "'" << endl; + + //need only to add this line if not handled by mimeHeader + originalHdrLines.append (addLine); +} + +void +mailHeader::outputHeader (mimeIO & useIO) +{ + static const TQCString __returnPath("Return-Path: ", 14); + static const TQCString __from ("From: ", 7); + static const TQCString __sender ("Sender: ", 9); + static const TQCString __replyTo ("Reply-To: ", 11); + static const TQCString __to ("To: ", 5); + static const TQCString __cc ("CC: ", 5); + static const TQCString __bcc ("BCC: ", 6); + static const TQCString __subject ("Subject: ", 10); + static const TQCString __messageId ("Message-ID: ", 13); + static const TQCString __inReplyTo ("In-Reply-To: ", 14); + static const TQCString __references("References: ", 13); + static const TQCString __date ("Date: ", 7); + + if (!returnpathAdr.isEmpty()) + useIO.outputMimeLine(__returnPath + returnpathAdr.getStr()); + if (!fromAdr.isEmpty()) + useIO.outputMimeLine(__from + fromAdr.getStr()); + if (!senderAdr.isEmpty()) + useIO.outputMimeLine(__sender + senderAdr.getStr()); + if (!replytoAdr.isEmpty()) + useIO.outputMimeLine(__replyTo + replytoAdr.getStr()); + + if (toAdr.count()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__to + + mailHeader::getAddressStr(&toAdr))); + if (ccAdr.count()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__cc + + mailHeader::getAddressStr(&ccAdr))); + if (bccAdr.count()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__bcc + + mailHeader::getAddressStr(&bccAdr))); + if (!_subject.isEmpty()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__subject + _subject)); + if (!messageID.isEmpty()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__messageId + messageID)); + if (!inReplyTo.isEmpty()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__inReplyTo + inReplyTo)); + if (!references.isEmpty()) + useIO.outputMimeLine(mimeHdrLine::truncateLine(__references + references)); + + if (!mDate.isEmpty()) + useIO.outputMimeLine(__date + mDate); + mimeHeader::outputHeader(useIO); +} + +int +mailHeader::parseAddressList (const char *inCStr, + TQPtrList < mailAddress > *aList) +{ + int advance = 0; + int skip = 1; + char *aCStr = (char *) inCStr; + + if (!aCStr || !aList) + return 0; + while (skip > 0) + { + mailAddress *aAddress = new mailAddress; + skip = aAddress->parseAddress (aCStr); + if (skip) + { + aCStr += skip; + if (skip < 0) + advance -= skip; + else + advance += skip; + aList->append (aAddress); + } + else + { + delete aAddress; + break; + } + } + return advance; +} + +TQCString +mailHeader::getAddressStr (TQPtrList < mailAddress > *aList) +{ + TQCString retVal; + + TQPtrListIterator < mailAddress > it = TQPtrListIterator < mailAddress > (*aList); + while (it.current ()) + { + retVal += it.current ()->getStr (); + ++it; + if (it.current ()) + retVal += ", "; + } + return retVal; +} diff --git a/tdeioslave/imap4/mimehdrline.cc b/tdeioslave/imap4/mimehdrline.cc deleted file mode 100644 index 9646ed26..00000000 --- a/tdeioslave/imap4/mimehdrline.cc +++ /dev/null @@ -1,521 +0,0 @@ -/*************************************************************************** - mimehdrline.cc - description - ------------------- - begin : Wed Oct 11 2000 - copyright : (C) 2000 by Sven Carstens - email : s.carstens@gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include "mimehdrline.h" -#include "rfcdecoder.h" - -using namespace std; - -const char *wdays[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; - -const char *months[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; - -mimeHdrLine::mimeHdrLine (): -mimeValue ((const char *) NULL), mimeLabel ((const char *) NULL) -{ -} - -mimeHdrLine::mimeHdrLine (const TQCString & aLabel, const TQCString & aValue): -mimeValue (aValue), -mimeLabel (aLabel) -{ -} - -mimeHdrLine::mimeHdrLine (mimeHdrLine * aHdrLine): -mimeValue (aHdrLine->mimeValue), mimeLabel (aHdrLine->mimeLabel) -{ -} - -mimeHdrLine::~mimeHdrLine () -{ -} - -int -mimeHdrLine::appendStr (const char *inCStr) -{ - int retVal = 0; - int skip; - char *aCStr = (char *) inCStr; - - if (aCStr) - { - skip = skipWS (aCStr); - if (skip && !mimeLabel.isEmpty ()) - { - if (skip > 0) - { - mimeValue += TQCString (aCStr, skip + 1); - aCStr += skip; - retVal += skip; - skip = parseFullLine (aCStr); - mimeValue += TQCString (aCStr, skip + 1); - retVal += skip; - aCStr += skip; - } - } - else - { - if (mimeLabel.isEmpty ()) - return setStr (aCStr); - } - } - return retVal; -} - -/** parse a Line into the class -move input ptr accordingly -and report characters slurped */ -int -mimeHdrLine::setStr (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; -// char *begin = aCStr; - mimeLabel = TQCString ((const char *) NULL); - mimeValue = TQCString ((const char *) NULL); - - if (aCStr) - { - // can't have spaces on normal lines - if (!skipWS (aCStr)) - { - int label = 0, advance; - while ((advance = parseWord (&aCStr[label]))) - { - label += advance; - } - if (label && aCStr[label - 1] != ':') - retVal = 0; - else - { - mimeLabel = TQCString (aCStr, label); //length including zero - retVal += label; - aCStr += label; - } - } - if (retVal) - { - int skip; - skip = skipWS (aCStr); - if (skip < 0) - skip *= -1; - aCStr += skip; - retVal += skip; - skip = parseFullLine (aCStr); - mimeValue = TQCString (aCStr, skip + 1); - retVal += skip; - aCStr += skip; - } - else - { - //Skip malformed line - while (*aCStr && *aCStr != '\r' && *aCStr != '\n') - { - retVal--; - aCStr++; - } - if (*aCStr == '\r') - { - retVal--; - aCStr++; - } - if (*aCStr == '\n') - { - retVal--; - aCStr++; - } - } - } - else - { - //debug - } - return retVal; -} - -/** slurp one word*/ -int -mimeHdrLine::parseWord (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - - if (aCStr && *aCStr) - { - if (*aCStr == '"') - return mimeHdrLine::parseQuoted ('"', '"', aCStr); - else - return mimeHdrLine::parseHalfWord (aCStr); - } - else - { - //debug(); - } - return retVal; -} - -/** slurp one word*/ -int -mimeHdrLine::parseQuoted (char startQuote, char endQuote, const char *inCStr) -{ - char *aCStr = (char *) inCStr; - int retVal = 0; - - if (aCStr && *aCStr) - { - if (*aCStr == startQuote) - { - aCStr++; - retVal++; - } - else - return 0; - while (*aCStr && *aCStr != endQuote) - { - //skip over backticks - if (*aCStr == '\\') - { - aCStr++; - retVal++; - } - //eat this - aCStr++; - retVal++; - } - if (*aCStr == endQuote) - { - aCStr++; - retVal++; - } - } - else - { - //debug(); - } - return retVal; -} - -/** slurp one alphanumerical word without continuation*/ -int -mimeHdrLine::parseAlphaNum (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - - if (aCStr) - { - while (*aCStr && isalnum (*aCStr)) - { - //skip over backticks - if (*aCStr == '\\') - { - aCStr++; - retVal++; - } - //eat this - aCStr++; - retVal++; - } - } - else - { - //debug(); - } - return retVal; -} - -int -mimeHdrLine::parseHalfWord (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - - if (aCStr && *aCStr) - { - if (isalnum (*aCStr)) - return mimeHdrLine::parseAlphaNum (aCStr); - //skip over backticks - if (*aCStr == '\\') - { - aCStr++; - retVal++; - } - else if (!isspace (*aCStr)) - { - //eat this - aCStr++; - retVal++; - } - } - else - { - //debug(); - } - return retVal; -} - -/** slurp one line without continuation*/ -int -mimeHdrLine::parseHalfLine (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - - if (aCStr) - { - while (*aCStr && *aCStr != '\n') - { - //skip over backticks - if (*aCStr == '\\') - { - aCStr++; - retVal++; - } - //eat this - aCStr++; - retVal++; - } - if (*aCStr == '\n') - { - aCStr++; - retVal++; - } - } - else - { - //debug(); - } - return retVal; -} - -/** skip all white space characters including continuation*/ -int -mimeHdrLine::skipWS (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - - if (aCStr && *aCStr) - { - while (*aCStr == ' ' || *aCStr == '\t') - { - aCStr++; - retVal++; - } - //check out for continuation lines - if (*aCStr == '\r') - { - aCStr++; - retVal++; - } - if (*aCStr++ == '\n') - if (*aCStr == '\t' || *aCStr == ' ') - { - int skip = mimeHdrLine::skipWS (aCStr); - if (skip < 0) - skip *= -1; - retVal += 1 + skip; - } - else - { - retVal = -retVal - 1; - } - } - else - { - //debug(); - } - return retVal; -} - -/** parses continuated lines */ -int -mimeHdrLine::parseFullLine (const char *inCStr) -{ - int retVal = 0; - char *aCStr = (char *) inCStr; - int skip; - - if (aCStr) - { - //skip leading white space - skip = skipWS (aCStr); - if (skip > 0) - { - aCStr += skip; - retVal += skip; - } - while (*aCStr) - { - int advance; - - if ((advance = parseHalfLine (aCStr))) - { - retVal += advance; - aCStr += advance; - } - else if ((advance = skipWS (aCStr))) - { - if (advance > 0) - { - retVal += advance; - aCStr += advance; - } - else - { - retVal -= advance; - break; - } - } - else - break; - } - } - else - { - //debug(); - } - return retVal; -} - -/** parses continuated lines */ -int -mimeHdrLine::parseSeparator (char separator, const char *inCStr) -{ - char *aCStr = (char *) inCStr; - int retVal = 0; - int skip; - - if (aCStr) - { - //skip leading white space - skip = skipWS (aCStr); - if (skip > 0) - { - aCStr += skip; - retVal += skip; - } - while (*aCStr) - { - int advance; - - if (*aCStr != separator) - { - if ((advance = mimeHdrLine::parseWord (aCStr))) - { - retVal += advance; - aCStr += advance; - } - else if ((advance = mimeHdrLine::skipWS (aCStr))) - { - if (advance > 0) - { - retVal += advance; - aCStr += advance; - } - else - { - retVal -= advance; - break; - } - } - else - break; - } - else - { - //include separator in result - retVal++; - aCStr++; - break; - } - } - } - else - { - //debug(); - } - return retVal; -} - -/** return the label */ - -const TQCString& -mimeHdrLine::getLabel () -{ - return mimeLabel; -} - -/** return the value */ -const TQCString& -mimeHdrLine::getValue () -{ - return mimeValue; -} - - -// FIXME: very inefficient still -TQCString -mimeHdrLine::truncateLine(TQCString aLine, unsigned int truncate) -{ - int cutHere; - TQCString retVal; - uint len = aLine.length(); - - // see if we have a line of the form "key: value" (like "Subject: bla") - // then we do not want to truncate between key and value - int validStart = aLine.find(": "); - if (validStart > -1) { - validStart += 2; - } - while (len > truncate) { - cutHere = aLine.findRev(' ', truncate); - if (cutHere < 1 || cutHere < validStart) { - cutHere = aLine.findRev('\t', truncate); - if (cutHere < 1) { - cutHere = aLine.find(' ', 1); - if (cutHere < 1) { - cutHere = aLine.find('\t', 1); - if (cutHere < 1) { - // simply truncate - return aLine.left(truncate); - } - } - } - } - - retVal += aLine.left(cutHere) + '\n'; - int chop = len - cutHere; - aLine = aLine.right(chop); - len -= chop; - } - retVal += aLine; - - return retVal; -} - diff --git a/tdeioslave/imap4/mimehdrline.cpp b/tdeioslave/imap4/mimehdrline.cpp new file mode 100644 index 00000000..591d3386 --- /dev/null +++ b/tdeioslave/imap4/mimehdrline.cpp @@ -0,0 +1,521 @@ +/*************************************************************************** + mimehdrline.cpp - description + ------------------- + begin : Wed Oct 11 2000 + copyright : (C) 2000 by Sven Carstens + email : s.carstens@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include "mimehdrline.h" +#include "rfcdecoder.h" + +using namespace std; + +const char *wdays[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +const char *months[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; + +mimeHdrLine::mimeHdrLine (): +mimeValue ((const char *) NULL), mimeLabel ((const char *) NULL) +{ +} + +mimeHdrLine::mimeHdrLine (const TQCString & aLabel, const TQCString & aValue): +mimeValue (aValue), +mimeLabel (aLabel) +{ +} + +mimeHdrLine::mimeHdrLine (mimeHdrLine * aHdrLine): +mimeValue (aHdrLine->mimeValue), mimeLabel (aHdrLine->mimeLabel) +{ +} + +mimeHdrLine::~mimeHdrLine () +{ +} + +int +mimeHdrLine::appendStr (const char *inCStr) +{ + int retVal = 0; + int skip; + char *aCStr = (char *) inCStr; + + if (aCStr) + { + skip = skipWS (aCStr); + if (skip && !mimeLabel.isEmpty ()) + { + if (skip > 0) + { + mimeValue += TQCString (aCStr, skip + 1); + aCStr += skip; + retVal += skip; + skip = parseFullLine (aCStr); + mimeValue += TQCString (aCStr, skip + 1); + retVal += skip; + aCStr += skip; + } + } + else + { + if (mimeLabel.isEmpty ()) + return setStr (aCStr); + } + } + return retVal; +} + +/** parse a Line into the class +move input ptr accordingly +and report characters slurped */ +int +mimeHdrLine::setStr (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; +// char *begin = aCStr; + mimeLabel = TQCString ((const char *) NULL); + mimeValue = TQCString ((const char *) NULL); + + if (aCStr) + { + // can't have spaces on normal lines + if (!skipWS (aCStr)) + { + int label = 0, advance; + while ((advance = parseWord (&aCStr[label]))) + { + label += advance; + } + if (label && aCStr[label - 1] != ':') + retVal = 0; + else + { + mimeLabel = TQCString (aCStr, label); //length including zero + retVal += label; + aCStr += label; + } + } + if (retVal) + { + int skip; + skip = skipWS (aCStr); + if (skip < 0) + skip *= -1; + aCStr += skip; + retVal += skip; + skip = parseFullLine (aCStr); + mimeValue = TQCString (aCStr, skip + 1); + retVal += skip; + aCStr += skip; + } + else + { + //Skip malformed line + while (*aCStr && *aCStr != '\r' && *aCStr != '\n') + { + retVal--; + aCStr++; + } + if (*aCStr == '\r') + { + retVal--; + aCStr++; + } + if (*aCStr == '\n') + { + retVal--; + aCStr++; + } + } + } + else + { + //debug + } + return retVal; +} + +/** slurp one word*/ +int +mimeHdrLine::parseWord (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + + if (aCStr && *aCStr) + { + if (*aCStr == '"') + return mimeHdrLine::parseQuoted ('"', '"', aCStr); + else + return mimeHdrLine::parseHalfWord (aCStr); + } + else + { + //debug(); + } + return retVal; +} + +/** slurp one word*/ +int +mimeHdrLine::parseQuoted (char startQuote, char endQuote, const char *inCStr) +{ + char *aCStr = (char *) inCStr; + int retVal = 0; + + if (aCStr && *aCStr) + { + if (*aCStr == startQuote) + { + aCStr++; + retVal++; + } + else + return 0; + while (*aCStr && *aCStr != endQuote) + { + //skip over backticks + if (*aCStr == '\\') + { + aCStr++; + retVal++; + } + //eat this + aCStr++; + retVal++; + } + if (*aCStr == endQuote) + { + aCStr++; + retVal++; + } + } + else + { + //debug(); + } + return retVal; +} + +/** slurp one alphanumerical word without continuation*/ +int +mimeHdrLine::parseAlphaNum (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + + if (aCStr) + { + while (*aCStr && isalnum (*aCStr)) + { + //skip over backticks + if (*aCStr == '\\') + { + aCStr++; + retVal++; + } + //eat this + aCStr++; + retVal++; + } + } + else + { + //debug(); + } + return retVal; +} + +int +mimeHdrLine::parseHalfWord (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + + if (aCStr && *aCStr) + { + if (isalnum (*aCStr)) + return mimeHdrLine::parseAlphaNum (aCStr); + //skip over backticks + if (*aCStr == '\\') + { + aCStr++; + retVal++; + } + else if (!isspace (*aCStr)) + { + //eat this + aCStr++; + retVal++; + } + } + else + { + //debug(); + } + return retVal; +} + +/** slurp one line without continuation*/ +int +mimeHdrLine::parseHalfLine (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + + if (aCStr) + { + while (*aCStr && *aCStr != '\n') + { + //skip over backticks + if (*aCStr == '\\') + { + aCStr++; + retVal++; + } + //eat this + aCStr++; + retVal++; + } + if (*aCStr == '\n') + { + aCStr++; + retVal++; + } + } + else + { + //debug(); + } + return retVal; +} + +/** skip all white space characters including continuation*/ +int +mimeHdrLine::skipWS (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + + if (aCStr && *aCStr) + { + while (*aCStr == ' ' || *aCStr == '\t') + { + aCStr++; + retVal++; + } + //check out for continuation lines + if (*aCStr == '\r') + { + aCStr++; + retVal++; + } + if (*aCStr++ == '\n') + if (*aCStr == '\t' || *aCStr == ' ') + { + int skip = mimeHdrLine::skipWS (aCStr); + if (skip < 0) + skip *= -1; + retVal += 1 + skip; + } + else + { + retVal = -retVal - 1; + } + } + else + { + //debug(); + } + return retVal; +} + +/** parses continuated lines */ +int +mimeHdrLine::parseFullLine (const char *inCStr) +{ + int retVal = 0; + char *aCStr = (char *) inCStr; + int skip; + + if (aCStr) + { + //skip leading white space + skip = skipWS (aCStr); + if (skip > 0) + { + aCStr += skip; + retVal += skip; + } + while (*aCStr) + { + int advance; + + if ((advance = parseHalfLine (aCStr))) + { + retVal += advance; + aCStr += advance; + } + else if ((advance = skipWS (aCStr))) + { + if (advance > 0) + { + retVal += advance; + aCStr += advance; + } + else + { + retVal -= advance; + break; + } + } + else + break; + } + } + else + { + //debug(); + } + return retVal; +} + +/** parses continuated lines */ +int +mimeHdrLine::parseSeparator (char separator, const char *inCStr) +{ + char *aCStr = (char *) inCStr; + int retVal = 0; + int skip; + + if (aCStr) + { + //skip leading white space + skip = skipWS (aCStr); + if (skip > 0) + { + aCStr += skip; + retVal += skip; + } + while (*aCStr) + { + int advance; + + if (*aCStr != separator) + { + if ((advance = mimeHdrLine::parseWord (aCStr))) + { + retVal += advance; + aCStr += advance; + } + else if ((advance = mimeHdrLine::skipWS (aCStr))) + { + if (advance > 0) + { + retVal += advance; + aCStr += advance; + } + else + { + retVal -= advance; + break; + } + } + else + break; + } + else + { + //include separator in result + retVal++; + aCStr++; + break; + } + } + } + else + { + //debug(); + } + return retVal; +} + +/** return the label */ + +const TQCString& +mimeHdrLine::getLabel () +{ + return mimeLabel; +} + +/** return the value */ +const TQCString& +mimeHdrLine::getValue () +{ + return mimeValue; +} + + +// FIXME: very inefficient still +TQCString +mimeHdrLine::truncateLine(TQCString aLine, unsigned int truncate) +{ + int cutHere; + TQCString retVal; + uint len = aLine.length(); + + // see if we have a line of the form "key: value" (like "Subject: bla") + // then we do not want to truncate between key and value + int validStart = aLine.find(": "); + if (validStart > -1) { + validStart += 2; + } + while (len > truncate) { + cutHere = aLine.findRev(' ', truncate); + if (cutHere < 1 || cutHere < validStart) { + cutHere = aLine.findRev('\t', truncate); + if (cutHere < 1) { + cutHere = aLine.find(' ', 1); + if (cutHere < 1) { + cutHere = aLine.find('\t', 1); + if (cutHere < 1) { + // simply truncate + return aLine.left(truncate); + } + } + } + } + + retVal += aLine.left(cutHere) + '\n'; + int chop = len - cutHere; + aLine = aLine.right(chop); + len -= chop; + } + retVal += aLine; + + return retVal; +} + diff --git a/tdeioslave/imap4/mimeheader.cc b/tdeioslave/imap4/mimeheader.cc deleted file mode 100644 index d0916ba5..00000000 --- a/tdeioslave/imap4/mimeheader.cc +++ /dev/null @@ -1,745 +0,0 @@ -/*************************************************************************** - mimeheader.cc - description - ------------------- - begin : Fri Oct 20 2000 - copyright : (C) 2000 by Sven Carstens - email : s.carstens@gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "mimeheader.h" -#include "mimehdrline.h" -#include "mailheader.h" -#include "rfcdecoder.h" - -#include - -// #include -#include -#include -#include -#include -#include -#include -#include - -mimeHeader::mimeHeader (): -typeList (17, false), dispositionList (17, false) -{ - // Case insensitive hashes are killing us. Also are they too small? - originalHdrLines.setAutoDelete (true); - additionalHdrLines.setAutoDelete (false); // is also in original lines - nestedParts.setAutoDelete (true); - typeList.setAutoDelete (true); - dispositionList.setAutoDelete (true); - nestedMessage = NULL; - contentLength = 0; - contentType = "application/octet-stream"; -} - -mimeHeader::~mimeHeader () -{ -} - -/* -TQPtrList mimeHeader::getAllParts() -{ - TQPtrList retVal; - - // caller is responsible for clearing - retVal.setAutoDelete( false ); - nestedParts.setAutoDelete( false ); - - // shallow copy - retVal = nestedParts; - - // can't have duplicate pointers - nestedParts.clear(); - - // restore initial state - nestedParts.setAutoDelete( true ); - - return retVal; -} */ - -void -mimeHeader::addHdrLine (mimeHdrLine * aHdrLine) -{ - mimeHdrLine *addLine = new mimeHdrLine (aHdrLine); - if (addLine) - { - originalHdrLines.append (addLine); - if (tqstrnicmp (addLine->getLabel (), "Content-", 8)) - { - additionalHdrLines.append (addLine); - } - else - { - int skip; - const char *aCStr = addLine->getValue ().data (); - TQDict < TQString > *aList = 0; - - skip = mimeHdrLine::parseSeparator (';', aCStr); - if (skip > 0) - { - int cut = 0; - if (skip >= 2) - { - if (aCStr[skip - 1] == '\r') - cut++; - if (aCStr[skip - 1] == '\n') - cut++; - if (aCStr[skip - 2] == '\r') - cut++; - if (aCStr[skip - 1] == ';') - cut++; - } - TQCString mimeValue = TQCString (aCStr, skip - cut + 1); // cutting of one because of 0x00 - - - if (!tqstricmp (addLine->getLabel (), "Content-Disposition")) - { - aList = &dispositionList; - _contentDisposition = mimeValue; - } - else if (!tqstricmp (addLine->getLabel (), "Content-Type")) - { - aList = &typeList; - contentType = mimeValue; - } - else - if (!tqstricmp (addLine->getLabel (), "Content-Transfer-Encoding")) - { - contentEncoding = mimeValue; - } - else if (!tqstricmp (addLine->getLabel (), "Content-ID")) - { - contentID = mimeValue; - } - else if (!tqstricmp (addLine->getLabel (), "Content-Description")) - { - _contentDescription = mimeValue; - } - else if (!tqstricmp (addLine->getLabel (), "Content-MD5")) - { - contentMD5 = mimeValue; - } - else if (!tqstricmp (addLine->getLabel (), "Content-Length")) - { - contentLength = mimeValue.toULong (); - } - else - { - additionalHdrLines.append (addLine); - } -// cout << addLine->getLabel().data() << ": '" << mimeValue.data() << "'" << endl; - - aCStr += skip; - while ((skip = mimeHdrLine::parseSeparator (';', aCStr))) - { - if (skip > 0) - { - addParameter (TQCString (aCStr, skip).simplifyWhiteSpace(), aList); -// cout << "-- '" << aParm.data() << "'" << endl; - mimeValue = TQCString (addLine->getValue ().data (), skip); - aCStr += skip; - } - else - break; - } - } - } - } -} - -void -mimeHeader::addParameter (const TQCString& aParameter, TQDict < TQString > *aList) -{ - if ( !aList ) - return; - - TQString *aValue; - TQCString aLabel; - int pos = aParameter.find ('='); -// cout << aParameter.left(pos).data(); - aValue = new TQString (); - aValue->setLatin1 (aParameter.right (aParameter.length () - pos - 1)); - aLabel = aParameter.left (pos); - if ((*aValue)[0] == '"') - *aValue = aValue->mid (1, aValue->length () - 2); - - aList->insert (aLabel, aValue); -// cout << "=" << aValue->data() << endl; -} - -TQString -mimeHeader::getDispositionParm (const TQCString& aStr) -{ - return getParameter (aStr, &dispositionList); -} - -TQString -mimeHeader::getTypeParm (const TQCString& aStr) -{ - return getParameter (aStr, &typeList); -} - -void -mimeHeader::setDispositionParm (const TQCString& aLabel, const TQString& aValue) -{ - setParameter (aLabel, aValue, &dispositionList); - return; -} - -void -mimeHeader::setTypeParm (const TQCString& aLabel, const TQString& aValue) -{ - setParameter (aLabel, aValue, &typeList); -} - -TQDictIterator < TQString > mimeHeader::getDispositionIterator () -{ - return TQDictIterator < TQString > (dispositionList); -} - -TQDictIterator < TQString > mimeHeader::getTypeIterator () -{ - return TQDictIterator < TQString > (typeList); -} - -TQPtrListIterator < mimeHdrLine > mimeHeader::getOriginalIterator () -{ - return TQPtrListIterator < mimeHdrLine > (originalHdrLines); -} - -TQPtrListIterator < mimeHdrLine > mimeHeader::getAdditionalIterator () -{ - return TQPtrListIterator < mimeHdrLine > (additionalHdrLines); -} - -void -mimeHeader::outputHeader (mimeIO & useIO) -{ - if (!getDisposition ().isEmpty ()) - { - useIO.outputMimeLine (TQCString ("Content-Disposition: ") - + getDisposition () - + outputParameter (&dispositionList)); - } - - if (!getType ().isEmpty ()) - { - useIO.outputMimeLine (TQCString ("Content-Type: ") - + getType () + outputParameter (&typeList)); - } - if (!getDescription ().isEmpty ()) - useIO.outputMimeLine (TQCString ("Content-Description: ") + - getDescription ()); - if (!getID ().isEmpty ()) - useIO.outputMimeLine (TQCString ("Content-ID: ") + getID ()); - if (!getMD5 ().isEmpty ()) - useIO.outputMimeLine (TQCString ("Content-MD5: ") + getMD5 ()); - if (!getEncoding ().isEmpty ()) - useIO.outputMimeLine (TQCString ("Content-Transfer-Encoding: ") + - getEncoding ()); - - TQPtrListIterator < mimeHdrLine > ait = getAdditionalIterator (); - while (ait.current ()) - { - useIO.outputMimeLine (ait.current ()->getLabel () + ": " + - ait.current ()->getValue ()); - ++ait; - } - useIO.outputMimeLine (TQCString ("")); -} - -TQString -mimeHeader::getParameter (const TQCString& aStr, TQDict < TQString > *aDict) -{ - TQString retVal, *found; - if (aDict) - { - //see if it is a normal parameter - found = aDict->find (aStr); - if (!found) - { - //might be a continuated or encoded parameter - found = aDict->find (aStr + "*"); - if (!found) - { - //continuated parameter - TQString decoded, encoded; - int part = 0; - - do - { - TQCString search; - search.setNum (part); - search = aStr + "*" + search; - found = aDict->find (search); - if (!found) - { - found = aDict->find (search + "*"); - if (found) - encoded += rfcDecoder::encodeRFC2231String (*found); - } - else - { - encoded += *found; - } - part++; - } - while (found); - if (encoded.find ('\'') >= 0) - { - retVal = rfcDecoder::decodeRFC2231String (encoded.local8Bit ()); - } - else - { - retVal = - rfcDecoder::decodeRFC2231String (TQCString ("''") + - encoded.local8Bit ()); - } - } - else - { - //simple encoded parameter - retVal = rfcDecoder::decodeRFC2231String (found->local8Bit ()); - } - } - else - { - retVal = *found; - } - } - return retVal; -} - -void -mimeHeader::setParameter (const TQCString& aLabel, const TQString& aValue, - TQDict < TQString > *aDict) -{ - bool encoded = true; - uint vlen, llen; - TQString val = aValue; - - if (aDict) - { - - //see if it needs to get encoded - if (encoded && aLabel.find ('*') == -1) - { - val = rfcDecoder::encodeRFC2231String (aValue); - } - //kdDebug(7116) << "mimeHeader::setParameter() - val = '" << val << "'" << endl; - //see if it needs to be truncated - vlen = val.length(); - llen = aLabel.length(); - if (vlen + llen + 4 > 80 && llen < 80 - 8 - 2 ) - { - const int limit = 80 - 8 - 2 - (int)llen; - // the -2 is there to allow extending the length of a part of val - // by 1 or 2 in order to prevent an encoded character from being - // split in half - int i = 0; - TQString shortValue; - TQCString shortLabel; - - while (!val.isEmpty ()) - { - int partLen; // the length of the next part of the value - if ( limit >= int(vlen) ) { - // the rest of the value fits completely into one continued header - partLen = vlen; - } - else { - partLen = limit; - // make sure that we don't split an encoded char in half - if ( val[partLen-1] == '%' ) { - partLen += 2; - } - else if ( partLen > 1 && val[partLen-2] == '%' ) { - partLen += 1; - } - // make sure partLen does not exceed vlen (could happen in case of - // an incomplete encoded char) - if ( partLen > int(vlen) ) { - partLen = vlen; - } - } - shortValue = val.left( partLen ); - shortLabel.setNum (i); - shortLabel = aLabel + "*" + shortLabel; - val = val.right( vlen - partLen ); - vlen = vlen - partLen; - if (encoded) - { - if (i == 0) - { - shortValue = "''" + shortValue; - } - shortLabel += "*"; - } - //kdDebug(7116) << "mimeHeader::setParameter() - shortLabel = '" << shortLabel << "'" << endl; - //kdDebug(7116) << "mimeHeader::setParameter() - shortValue = '" << shortValue << "'" << endl; - //kdDebug(7116) << "mimeHeader::setParameter() - val = '" << val << "'" << endl; - aDict->insert (shortLabel, new TQString (shortValue)); - i++; - } - } - else - { - aDict->insert (aLabel, new TQString (val)); - } - } -} - -TQCString -mimeHeader::outputParameter (TQDict < TQString > *aDict) -{ - TQCString retVal; - if (aDict) - { - TQDictIterator < TQString > it (*aDict); - while (it.current ()) - { - retVal += (";\n\t" + it.currentKey () + "=").latin1 (); - if (it.current ()->find (' ') > 0 || it.current ()->find (';') > 0) - { - retVal += '"' + it.current ()->utf8 () + '"'; - } - else - { - retVal += it.current ()->utf8 (); - } - // << it.current()->utf8() << "'"; - ++it; - } - retVal += "\n"; - } - return retVal; -} - -void -mimeHeader::outputPart (mimeIO & useIO) -{ - TQPtrListIterator < mimeHeader > nestedParts = getNestedIterator (); - TQCString boundary; - if (!getTypeParm ("boundary").isEmpty ()) - boundary = getTypeParm ("boundary").latin1 (); - - outputHeader (useIO); - if (!getPreBody ().isEmpty ()) - useIO.outputMimeLine (getPreBody ()); - if (getNestedMessage ()) - getNestedMessage ()->outputPart (useIO); - while (nestedParts.current ()) - { - if (!boundary.isEmpty ()) - useIO.outputMimeLine ("--" + boundary); - nestedParts.current ()->outputPart (useIO); - ++nestedParts; - } - if (!boundary.isEmpty ()) - useIO.outputMimeLine ("--" + boundary + "--"); - if (!getPostBody ().isEmpty ()) - useIO.outputMimeLine (getPostBody ()); -} - -int -mimeHeader::parsePart (mimeIO & useIO, const TQString& boundary) -{ - int retVal = 0; - bool mbox = false; - TQCString preNested, postNested; - mbox = parseHeader (useIO); - - kdDebug(7116) << "mimeHeader::parsePart - parsing part '" << getType () << "'" << endl; - if (!tqstrnicmp (getType (), "Multipart", 9)) - { - retVal = parseBody (useIO, preNested, getTypeParm ("boundary")); //this is a message in mime format stuff - setPreBody (preNested); - int localRetVal; - do - { - mimeHeader *aHeader = new mimeHeader; - - // set default type for multipart/digest - if (!tqstrnicmp (getType (), "Multipart/Digest", 16)) - aHeader->setType ("Message/RFC822"); - - localRetVal = aHeader->parsePart (useIO, getTypeParm ("boundary")); - addNestedPart (aHeader); - } - while (localRetVal); //get nested stuff - } - if (!tqstrnicmp (getType (), "Message/RFC822", 14)) - { - mailHeader *msgHeader = new mailHeader; - retVal = msgHeader->parsePart (useIO, boundary); - setNestedMessage (msgHeader); - } - else - { - retVal = parseBody (useIO, postNested, boundary, mbox); //just a simple part remaining - setPostBody (postNested); - } - return retVal; -} - -int -mimeHeader::parseBody (mimeIO & useIO, TQCString & messageBody, - const TQString& boundary, bool mbox) -{ - TQCString inputStr; - TQCString buffer; - TQString partBoundary; - TQString partEnd; - int retVal = 0; //default is last part - - if (!boundary.isEmpty ()) - { - partBoundary = TQString ("--") + boundary; - partEnd = TQString ("--") + boundary + "--"; - } - - while (useIO.inputLine (inputStr)) - { - //check for the end of all parts - if (!partEnd.isEmpty () - && !tqstrnicmp (inputStr, partEnd.latin1 (), partEnd.length () - 1)) - { - retVal = 0; //end of these parts - break; - } - else if (!partBoundary.isEmpty () - && !tqstrnicmp (inputStr, partBoundary.latin1 (), - partBoundary.length () - 1)) - { - retVal = 1; //continue with next part - break; - } - else if (mbox && inputStr.find ("From ") == 0) - { - retVal = 0; // end of mbox - break; - } - buffer += inputStr; - if (buffer.length () > 16384) - { - messageBody += buffer; - buffer = ""; - } - } - - messageBody += buffer; - return retVal; -} - -bool -mimeHeader::parseHeader (mimeIO & useIO) -{ - bool mbox = false; - bool first = true; - mimeHdrLine my_line; - TQCString inputStr; - - kdDebug(7116) << "mimeHeader::parseHeader - starting parsing" << endl; - while (useIO.inputLine (inputStr)) - { - int appended; - if (inputStr.find ("From ") != 0 || !first) - { - first = false; - appended = my_line.appendStr (inputStr); - if (!appended) - { - addHdrLine (&my_line); - appended = my_line.setStr (inputStr); - } - if (appended <= 0) - break; - } - else - { - mbox = true; - first = false; - } - inputStr = (const char *) NULL; - } - - kdDebug(7116) << "mimeHeader::parseHeader - finished parsing" << endl; - return mbox; -} - -mimeHeader * -mimeHeader::bodyPart (const TQString & _str) -{ - // see if it is nested a little deeper - int pt = _str.find('.'); - if (pt != -1) - { - TQString tempStr = _str; - mimeHeader *tempPart; - - tempStr = _str.right (_str.length () - pt - 1); - if (nestedMessage) - { - kdDebug(7116) << "mimeHeader::bodyPart - recursing message" << endl; - tempPart = nestedMessage->nestedParts.at (_str.left(pt).toULong() - 1); - } - else - { - kdDebug(7116) << "mimeHeader::bodyPart - recursing mixed" << endl; - tempPart = nestedParts.at (_str.left(pt).toULong() - 1); - } - if (tempPart) - tempPart = tempPart->bodyPart (tempStr); - return tempPart; - } - - kdDebug(7116) << "mimeHeader::bodyPart - returning part " << _str << endl; - // or pick just the plain part - if (nestedMessage) - { - kdDebug(7116) << "mimeHeader::bodyPart - message" << endl; - return nestedMessage->nestedParts.at (_str.toULong () - 1); - } - kdDebug(7116) << "mimeHeader::bodyPart - mixed" << endl; - return nestedParts.at (_str.toULong () - 1); -} - -void mimeHeader::serialize(TQDataStream& stream) -{ - int nestedcount = nestedParts.count(); - if (nestedParts.isEmpty() && nestedMessage) - nestedcount = 1; - stream << nestedcount << contentType << TQString (getTypeParm ("name")) << _contentDescription - << _contentDisposition << contentEncoding << contentLength << partSpecifier; - // serialize nested message - if (nestedMessage) - nestedMessage->serialize(stream); - - // serialize nested parts - if (!nestedParts.isEmpty()) - { - TQPtrListIterator < mimeHeader > it(nestedParts); - mimeHeader* part; - while ( (part = it.current()) != 0 ) - { - ++it; - part->serialize(stream); - } - } -} - -#ifdef KMAIL_COMPATIBLE -// compatibility subroutines -TQString -mimeHeader::bodyDecoded () -{ - kdDebug(7116) << "mimeHeader::bodyDecoded" << endl; - TQByteArray temp; - - temp = bodyDecodedBinary (); - return TQString::fromLatin1 (temp.data (), temp.count ()); -} - -TQByteArray -mimeHeader::bodyDecodedBinary () -{ - TQByteArray retVal; - - if (contentEncoding.find ("quoted-printable", 0, false) == 0) - retVal = KCodecs::quotedPrintableDecode(postMultipartBody); - else if (contentEncoding.find ("base64", 0, false) == 0) - KCodecs::base64Decode(postMultipartBody, retVal); - else retVal = postMultipartBody; - - kdDebug(7116) << "mimeHeader::bodyDecodedBinary - size is " << retVal.size () << endl; - return retVal; -} - -void -mimeHeader::setBodyEncodedBinary (const TQByteArray & _arr) -{ - setBodyEncoded (_arr); -} - -void -mimeHeader::setBodyEncoded (const TQByteArray & _arr) -{ - TQByteArray setVal; - - kdDebug(7116) << "mimeHeader::setBodyEncoded - in size " << _arr.size () << endl; - if (contentEncoding.find ("quoted-printable", 0, false) == 0) - setVal = KCodecs::quotedPrintableEncode(_arr); - else if (contentEncoding.find ("base64", 0, false) == 0) - KCodecs::base64Encode(_arr, setVal); - else - setVal.duplicate (_arr); - kdDebug(7116) << "mimeHeader::setBodyEncoded - out size " << setVal.size () << endl; - - postMultipartBody.duplicate (setVal); - kdDebug(7116) << "mimeHeader::setBodyEncoded - out size " << postMultipartBody.size () << endl; -} - -TQString -mimeHeader::iconName () -{ - TQString fileName; - - // FIXME: bug? Why throw away this data? - fileName = - KMimeType::mimeType (contentType.lower ())->icon (TQString(), false); - fileName = - TDEGlobal::instance ()->iconLoader ()->iconPath (fileName, TDEIcon::Desktop); -// if (fileName.isEmpty()) -// fileName = TDEGlobal::instance()->iconLoader()->iconPath( "unknown", TDEIcon::Desktop ); - return fileName; -} - -void -mimeHeader::setNestedMessage (mailHeader * inPart, bool destroy) -{ -// if(nestedMessage && destroy) delete nestedMessage; - nestedMessage = inPart; -} - -TQString -mimeHeader::headerAsString () -{ - mimeIOTQString myIO; - - outputHeader (myIO); - return myIO.getString (); -} - -TQString -mimeHeader::magicSetType (bool aAutoDecode) -{ - TQString mimetype; - TQByteArray body; - KMimeMagicResult *result; - - KMimeMagic::self ()->setFollowLinks (TRUE); // is it necessary ? - - if (aAutoDecode) - body = bodyDecodedBinary (); - else - body = postMultipartBody; - - result = KMimeMagic::self ()->findBufferType (body); - mimetype = result->mimeType (); - contentType = mimetype; - return mimetype; -} -#endif diff --git a/tdeioslave/imap4/mimeheader.cpp b/tdeioslave/imap4/mimeheader.cpp new file mode 100644 index 00000000..d9d2c7d2 --- /dev/null +++ b/tdeioslave/imap4/mimeheader.cpp @@ -0,0 +1,745 @@ +/*************************************************************************** + mimeheader.cpp - description + ------------------- + begin : Fri Oct 20 2000 + copyright : (C) 2000 by Sven Carstens + email : s.carstens@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mimeheader.h" +#include "mimehdrline.h" +#include "mailheader.h" +#include "rfcdecoder.h" + +#include + +// #include +#include +#include +#include +#include +#include +#include +#include + +mimeHeader::mimeHeader (): +typeList (17, false), dispositionList (17, false) +{ + // Case insensitive hashes are killing us. Also are they too small? + originalHdrLines.setAutoDelete (true); + additionalHdrLines.setAutoDelete (false); // is also in original lines + nestedParts.setAutoDelete (true); + typeList.setAutoDelete (true); + dispositionList.setAutoDelete (true); + nestedMessage = NULL; + contentLength = 0; + contentType = "application/octet-stream"; +} + +mimeHeader::~mimeHeader () +{ +} + +/* +TQPtrList mimeHeader::getAllParts() +{ + TQPtrList retVal; + + // caller is responsible for clearing + retVal.setAutoDelete( false ); + nestedParts.setAutoDelete( false ); + + // shallow copy + retVal = nestedParts; + + // can't have duplicate pointers + nestedParts.clear(); + + // restore initial state + nestedParts.setAutoDelete( true ); + + return retVal; +} */ + +void +mimeHeader::addHdrLine (mimeHdrLine * aHdrLine) +{ + mimeHdrLine *addLine = new mimeHdrLine (aHdrLine); + if (addLine) + { + originalHdrLines.append (addLine); + if (tqstrnicmp (addLine->getLabel (), "Content-", 8)) + { + additionalHdrLines.append (addLine); + } + else + { + int skip; + const char *aCStr = addLine->getValue ().data (); + TQDict < TQString > *aList = 0; + + skip = mimeHdrLine::parseSeparator (';', aCStr); + if (skip > 0) + { + int cut = 0; + if (skip >= 2) + { + if (aCStr[skip - 1] == '\r') + cut++; + if (aCStr[skip - 1] == '\n') + cut++; + if (aCStr[skip - 2] == '\r') + cut++; + if (aCStr[skip - 1] == ';') + cut++; + } + TQCString mimeValue = TQCString (aCStr, skip - cut + 1); // cutting of one because of 0x00 + + + if (!tqstricmp (addLine->getLabel (), "Content-Disposition")) + { + aList = &dispositionList; + _contentDisposition = mimeValue; + } + else if (!tqstricmp (addLine->getLabel (), "Content-Type")) + { + aList = &typeList; + contentType = mimeValue; + } + else + if (!tqstricmp (addLine->getLabel (), "Content-Transfer-Encoding")) + { + contentEncoding = mimeValue; + } + else if (!tqstricmp (addLine->getLabel (), "Content-ID")) + { + contentID = mimeValue; + } + else if (!tqstricmp (addLine->getLabel (), "Content-Description")) + { + _contentDescription = mimeValue; + } + else if (!tqstricmp (addLine->getLabel (), "Content-MD5")) + { + contentMD5 = mimeValue; + } + else if (!tqstricmp (addLine->getLabel (), "Content-Length")) + { + contentLength = mimeValue.toULong (); + } + else + { + additionalHdrLines.append (addLine); + } +// cout << addLine->getLabel().data() << ": '" << mimeValue.data() << "'" << endl; + + aCStr += skip; + while ((skip = mimeHdrLine::parseSeparator (';', aCStr))) + { + if (skip > 0) + { + addParameter (TQCString (aCStr, skip).simplifyWhiteSpace(), aList); +// cout << "-- '" << aParm.data() << "'" << endl; + mimeValue = TQCString (addLine->getValue ().data (), skip); + aCStr += skip; + } + else + break; + } + } + } + } +} + +void +mimeHeader::addParameter (const TQCString& aParameter, TQDict < TQString > *aList) +{ + if ( !aList ) + return; + + TQString *aValue; + TQCString aLabel; + int pos = aParameter.find ('='); +// cout << aParameter.left(pos).data(); + aValue = new TQString (); + aValue->setLatin1 (aParameter.right (aParameter.length () - pos - 1)); + aLabel = aParameter.left (pos); + if ((*aValue)[0] == '"') + *aValue = aValue->mid (1, aValue->length () - 2); + + aList->insert (aLabel, aValue); +// cout << "=" << aValue->data() << endl; +} + +TQString +mimeHeader::getDispositionParm (const TQCString& aStr) +{ + return getParameter (aStr, &dispositionList); +} + +TQString +mimeHeader::getTypeParm (const TQCString& aStr) +{ + return getParameter (aStr, &typeList); +} + +void +mimeHeader::setDispositionParm (const TQCString& aLabel, const TQString& aValue) +{ + setParameter (aLabel, aValue, &dispositionList); + return; +} + +void +mimeHeader::setTypeParm (const TQCString& aLabel, const TQString& aValue) +{ + setParameter (aLabel, aValue, &typeList); +} + +TQDictIterator < TQString > mimeHeader::getDispositionIterator () +{ + return TQDictIterator < TQString > (dispositionList); +} + +TQDictIterator < TQString > mimeHeader::getTypeIterator () +{ + return TQDictIterator < TQString > (typeList); +} + +TQPtrListIterator < mimeHdrLine > mimeHeader::getOriginalIterator () +{ + return TQPtrListIterator < mimeHdrLine > (originalHdrLines); +} + +TQPtrListIterator < mimeHdrLine > mimeHeader::getAdditionalIterator () +{ + return TQPtrListIterator < mimeHdrLine > (additionalHdrLines); +} + +void +mimeHeader::outputHeader (mimeIO & useIO) +{ + if (!getDisposition ().isEmpty ()) + { + useIO.outputMimeLine (TQCString ("Content-Disposition: ") + + getDisposition () + + outputParameter (&dispositionList)); + } + + if (!getType ().isEmpty ()) + { + useIO.outputMimeLine (TQCString ("Content-Type: ") + + getType () + outputParameter (&typeList)); + } + if (!getDescription ().isEmpty ()) + useIO.outputMimeLine (TQCString ("Content-Description: ") + + getDescription ()); + if (!getID ().isEmpty ()) + useIO.outputMimeLine (TQCString ("Content-ID: ") + getID ()); + if (!getMD5 ().isEmpty ()) + useIO.outputMimeLine (TQCString ("Content-MD5: ") + getMD5 ()); + if (!getEncoding ().isEmpty ()) + useIO.outputMimeLine (TQCString ("Content-Transfer-Encoding: ") + + getEncoding ()); + + TQPtrListIterator < mimeHdrLine > ait = getAdditionalIterator (); + while (ait.current ()) + { + useIO.outputMimeLine (ait.current ()->getLabel () + ": " + + ait.current ()->getValue ()); + ++ait; + } + useIO.outputMimeLine (TQCString ("")); +} + +TQString +mimeHeader::getParameter (const TQCString& aStr, TQDict < TQString > *aDict) +{ + TQString retVal, *found; + if (aDict) + { + //see if it is a normal parameter + found = aDict->find (aStr); + if (!found) + { + //might be a continuated or encoded parameter + found = aDict->find (aStr + "*"); + if (!found) + { + //continuated parameter + TQString decoded, encoded; + int part = 0; + + do + { + TQCString search; + search.setNum (part); + search = aStr + "*" + search; + found = aDict->find (search); + if (!found) + { + found = aDict->find (search + "*"); + if (found) + encoded += rfcDecoder::encodeRFC2231String (*found); + } + else + { + encoded += *found; + } + part++; + } + while (found); + if (encoded.find ('\'') >= 0) + { + retVal = rfcDecoder::decodeRFC2231String (encoded.local8Bit ()); + } + else + { + retVal = + rfcDecoder::decodeRFC2231String (TQCString ("''") + + encoded.local8Bit ()); + } + } + else + { + //simple encoded parameter + retVal = rfcDecoder::decodeRFC2231String (found->local8Bit ()); + } + } + else + { + retVal = *found; + } + } + return retVal; +} + +void +mimeHeader::setParameter (const TQCString& aLabel, const TQString& aValue, + TQDict < TQString > *aDict) +{ + bool encoded = true; + uint vlen, llen; + TQString val = aValue; + + if (aDict) + { + + //see if it needs to get encoded + if (encoded && aLabel.find ('*') == -1) + { + val = rfcDecoder::encodeRFC2231String (aValue); + } + //kdDebug(7116) << "mimeHeader::setParameter() - val = '" << val << "'" << endl; + //see if it needs to be truncated + vlen = val.length(); + llen = aLabel.length(); + if (vlen + llen + 4 > 80 && llen < 80 - 8 - 2 ) + { + const int limit = 80 - 8 - 2 - (int)llen; + // the -2 is there to allow extending the length of a part of val + // by 1 or 2 in order to prevent an encoded character from being + // split in half + int i = 0; + TQString shortValue; + TQCString shortLabel; + + while (!val.isEmpty ()) + { + int partLen; // the length of the next part of the value + if ( limit >= int(vlen) ) { + // the rest of the value fits completely into one continued header + partLen = vlen; + } + else { + partLen = limit; + // make sure that we don't split an encoded char in half + if ( val[partLen-1] == '%' ) { + partLen += 2; + } + else if ( partLen > 1 && val[partLen-2] == '%' ) { + partLen += 1; + } + // make sure partLen does not exceed vlen (could happen in case of + // an incomplete encoded char) + if ( partLen > int(vlen) ) { + partLen = vlen; + } + } + shortValue = val.left( partLen ); + shortLabel.setNum (i); + shortLabel = aLabel + "*" + shortLabel; + val = val.right( vlen - partLen ); + vlen = vlen - partLen; + if (encoded) + { + if (i == 0) + { + shortValue = "''" + shortValue; + } + shortLabel += "*"; + } + //kdDebug(7116) << "mimeHeader::setParameter() - shortLabel = '" << shortLabel << "'" << endl; + //kdDebug(7116) << "mimeHeader::setParameter() - shortValue = '" << shortValue << "'" << endl; + //kdDebug(7116) << "mimeHeader::setParameter() - val = '" << val << "'" << endl; + aDict->insert (shortLabel, new TQString (shortValue)); + i++; + } + } + else + { + aDict->insert (aLabel, new TQString (val)); + } + } +} + +TQCString +mimeHeader::outputParameter (TQDict < TQString > *aDict) +{ + TQCString retVal; + if (aDict) + { + TQDictIterator < TQString > it (*aDict); + while (it.current ()) + { + retVal += (";\n\t" + it.currentKey () + "=").latin1 (); + if (it.current ()->find (' ') > 0 || it.current ()->find (';') > 0) + { + retVal += '"' + it.current ()->utf8 () + '"'; + } + else + { + retVal += it.current ()->utf8 (); + } + // << it.current()->utf8() << "'"; + ++it; + } + retVal += "\n"; + } + return retVal; +} + +void +mimeHeader::outputPart (mimeIO & useIO) +{ + TQPtrListIterator < mimeHeader > nestedParts = getNestedIterator (); + TQCString boundary; + if (!getTypeParm ("boundary").isEmpty ()) + boundary = getTypeParm ("boundary").latin1 (); + + outputHeader (useIO); + if (!getPreBody ().isEmpty ()) + useIO.outputMimeLine (getPreBody ()); + if (getNestedMessage ()) + getNestedMessage ()->outputPart (useIO); + while (nestedParts.current ()) + { + if (!boundary.isEmpty ()) + useIO.outputMimeLine ("--" + boundary); + nestedParts.current ()->outputPart (useIO); + ++nestedParts; + } + if (!boundary.isEmpty ()) + useIO.outputMimeLine ("--" + boundary + "--"); + if (!getPostBody ().isEmpty ()) + useIO.outputMimeLine (getPostBody ()); +} + +int +mimeHeader::parsePart (mimeIO & useIO, const TQString& boundary) +{ + int retVal = 0; + bool mbox = false; + TQCString preNested, postNested; + mbox = parseHeader (useIO); + + kdDebug(7116) << "mimeHeader::parsePart - parsing part '" << getType () << "'" << endl; + if (!tqstrnicmp (getType (), "Multipart", 9)) + { + retVal = parseBody (useIO, preNested, getTypeParm ("boundary")); //this is a message in mime format stuff + setPreBody (preNested); + int localRetVal; + do + { + mimeHeader *aHeader = new mimeHeader; + + // set default type for multipart/digest + if (!tqstrnicmp (getType (), "Multipart/Digest", 16)) + aHeader->setType ("Message/RFC822"); + + localRetVal = aHeader->parsePart (useIO, getTypeParm ("boundary")); + addNestedPart (aHeader); + } + while (localRetVal); //get nested stuff + } + if (!tqstrnicmp (getType (), "Message/RFC822", 14)) + { + mailHeader *msgHeader = new mailHeader; + retVal = msgHeader->parsePart (useIO, boundary); + setNestedMessage (msgHeader); + } + else + { + retVal = parseBody (useIO, postNested, boundary, mbox); //just a simple part remaining + setPostBody (postNested); + } + return retVal; +} + +int +mimeHeader::parseBody (mimeIO & useIO, TQCString & messageBody, + const TQString& boundary, bool mbox) +{ + TQCString inputStr; + TQCString buffer; + TQString partBoundary; + TQString partEnd; + int retVal = 0; //default is last part + + if (!boundary.isEmpty ()) + { + partBoundary = TQString ("--") + boundary; + partEnd = TQString ("--") + boundary + "--"; + } + + while (useIO.inputLine (inputStr)) + { + //check for the end of all parts + if (!partEnd.isEmpty () + && !tqstrnicmp (inputStr, partEnd.latin1 (), partEnd.length () - 1)) + { + retVal = 0; //end of these parts + break; + } + else if (!partBoundary.isEmpty () + && !tqstrnicmp (inputStr, partBoundary.latin1 (), + partBoundary.length () - 1)) + { + retVal = 1; //continue with next part + break; + } + else if (mbox && inputStr.find ("From ") == 0) + { + retVal = 0; // end of mbox + break; + } + buffer += inputStr; + if (buffer.length () > 16384) + { + messageBody += buffer; + buffer = ""; + } + } + + messageBody += buffer; + return retVal; +} + +bool +mimeHeader::parseHeader (mimeIO & useIO) +{ + bool mbox = false; + bool first = true; + mimeHdrLine my_line; + TQCString inputStr; + + kdDebug(7116) << "mimeHeader::parseHeader - starting parsing" << endl; + while (useIO.inputLine (inputStr)) + { + int appended; + if (inputStr.find ("From ") != 0 || !first) + { + first = false; + appended = my_line.appendStr (inputStr); + if (!appended) + { + addHdrLine (&my_line); + appended = my_line.setStr (inputStr); + } + if (appended <= 0) + break; + } + else + { + mbox = true; + first = false; + } + inputStr = (const char *) NULL; + } + + kdDebug(7116) << "mimeHeader::parseHeader - finished parsing" << endl; + return mbox; +} + +mimeHeader * +mimeHeader::bodyPart (const TQString & _str) +{ + // see if it is nested a little deeper + int pt = _str.find('.'); + if (pt != -1) + { + TQString tempStr = _str; + mimeHeader *tempPart; + + tempStr = _str.right (_str.length () - pt - 1); + if (nestedMessage) + { + kdDebug(7116) << "mimeHeader::bodyPart - recursing message" << endl; + tempPart = nestedMessage->nestedParts.at (_str.left(pt).toULong() - 1); + } + else + { + kdDebug(7116) << "mimeHeader::bodyPart - recursing mixed" << endl; + tempPart = nestedParts.at (_str.left(pt).toULong() - 1); + } + if (tempPart) + tempPart = tempPart->bodyPart (tempStr); + return tempPart; + } + + kdDebug(7116) << "mimeHeader::bodyPart - returning part " << _str << endl; + // or pick just the plain part + if (nestedMessage) + { + kdDebug(7116) << "mimeHeader::bodyPart - message" << endl; + return nestedMessage->nestedParts.at (_str.toULong () - 1); + } + kdDebug(7116) << "mimeHeader::bodyPart - mixed" << endl; + return nestedParts.at (_str.toULong () - 1); +} + +void mimeHeader::serialize(TQDataStream& stream) +{ + int nestedcount = nestedParts.count(); + if (nestedParts.isEmpty() && nestedMessage) + nestedcount = 1; + stream << nestedcount << contentType << TQString (getTypeParm ("name")) << _contentDescription + << _contentDisposition << contentEncoding << contentLength << partSpecifier; + // serialize nested message + if (nestedMessage) + nestedMessage->serialize(stream); + + // serialize nested parts + if (!nestedParts.isEmpty()) + { + TQPtrListIterator < mimeHeader > it(nestedParts); + mimeHeader* part; + while ( (part = it.current()) != 0 ) + { + ++it; + part->serialize(stream); + } + } +} + +#ifdef KMAIL_COMPATIBLE +// compatibility subroutines +TQString +mimeHeader::bodyDecoded () +{ + kdDebug(7116) << "mimeHeader::bodyDecoded" << endl; + TQByteArray temp; + + temp = bodyDecodedBinary (); + return TQString::fromLatin1 (temp.data (), temp.count ()); +} + +TQByteArray +mimeHeader::bodyDecodedBinary () +{ + TQByteArray retVal; + + if (contentEncoding.find ("quoted-printable", 0, false) == 0) + retVal = KCodecs::quotedPrintableDecode(postMultipartBody); + else if (contentEncoding.find ("base64", 0, false) == 0) + KCodecs::base64Decode(postMultipartBody, retVal); + else retVal = postMultipartBody; + + kdDebug(7116) << "mimeHeader::bodyDecodedBinary - size is " << retVal.size () << endl; + return retVal; +} + +void +mimeHeader::setBodyEncodedBinary (const TQByteArray & _arr) +{ + setBodyEncoded (_arr); +} + +void +mimeHeader::setBodyEncoded (const TQByteArray & _arr) +{ + TQByteArray setVal; + + kdDebug(7116) << "mimeHeader::setBodyEncoded - in size " << _arr.size () << endl; + if (contentEncoding.find ("quoted-printable", 0, false) == 0) + setVal = KCodecs::quotedPrintableEncode(_arr); + else if (contentEncoding.find ("base64", 0, false) == 0) + KCodecs::base64Encode(_arr, setVal); + else + setVal.duplicate (_arr); + kdDebug(7116) << "mimeHeader::setBodyEncoded - out size " << setVal.size () << endl; + + postMultipartBody.duplicate (setVal); + kdDebug(7116) << "mimeHeader::setBodyEncoded - out size " << postMultipartBody.size () << endl; +} + +TQString +mimeHeader::iconName () +{ + TQString fileName; + + // FIXME: bug? Why throw away this data? + fileName = + KMimeType::mimeType (contentType.lower ())->icon (TQString(), false); + fileName = + TDEGlobal::instance ()->iconLoader ()->iconPath (fileName, TDEIcon::Desktop); +// if (fileName.isEmpty()) +// fileName = TDEGlobal::instance()->iconLoader()->iconPath( "unknown", TDEIcon::Desktop ); + return fileName; +} + +void +mimeHeader::setNestedMessage (mailHeader * inPart, bool destroy) +{ +// if(nestedMessage && destroy) delete nestedMessage; + nestedMessage = inPart; +} + +TQString +mimeHeader::headerAsString () +{ + mimeIOTQString myIO; + + outputHeader (myIO); + return myIO.getString (); +} + +TQString +mimeHeader::magicSetType (bool aAutoDecode) +{ + TQString mimetype; + TQByteArray body; + KMimeMagicResult *result; + + KMimeMagic::self ()->setFollowLinks (TRUE); // is it necessary ? + + if (aAutoDecode) + body = bodyDecodedBinary (); + else + body = postMultipartBody; + + result = KMimeMagic::self ()->findBufferType (body); + mimetype = result->mimeType (); + contentType = mimetype; + return mimetype; +} +#endif diff --git a/tdeioslave/imap4/mimeio.cc b/tdeioslave/imap4/mimeio.cc deleted file mode 100644 index 757c11a4..00000000 --- a/tdeioslave/imap4/mimeio.cc +++ /dev/null @@ -1,188 +0,0 @@ -/*************************************************************************** - mimeio.cc - description - ------------------- - begin : Wed Oct 25 2000 - copyright : (C) 2000 by Sven Carstens - email : s.carstens@gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -using namespace std; - -#include "mimeio.h" - -mimeIO::mimeIO () -{ - theCRLF = "\r\n"; - crlfLen = 2; -} - -mimeIO::~mimeIO () -{ -} - -int -mimeIO::inputLine (TQCString & aLine) -{ - char input; - - aLine = (const char *) NULL; - while (inputChar (input)) - { - aLine += input; - if (input == '\n') - break; - } -// cout << aLine.length() << " - " << aLine; - return aLine.length (); -} - -int -mimeIO::outputLine (const TQCString & aLine, int len) -{ - int i; - - if (len == -1) { - len = aLine.length(); - } - int start = len; - for (i = 0; i < start; i++) - if (!outputChar (aLine[i])) - break; - return i; -} - -int -mimeIO::outputMimeLine (const TQCString & inLine) -{ - int retVal = 0; - TQCString aLine = inLine; - int len = inLine.length(); - - int theLF = aLine.findRev ('\n'); - if (theLF == len - 1 && theLF != -1) - { - //we have a trailing LF, now check for CR - if (aLine[theLF - 1] == '\r') - theLF--; - //truncate the line - aLine.truncate(theLF); - len = theLF; - theLF = -1; - } - //now truncate the line - { - int start, end, offset; - start = 0; - end = aLine.find ('\n', start); - while (end >= 0) - { - offset = 1; - if (end && aLine[end - 1] == '\r') - { - offset++; - end--; - } - outputLine (aLine.mid (start, end - start) + theCRLF, end - start + crlfLen); - start = end + offset; - end = aLine.find ('\n', start); - } - outputLine (aLine.mid (start, len - start) + theCRLF, len - start + crlfLen); - } - return retVal; -} - -int -mimeIO::inputChar (char &aChar) -{ - if (cin.eof ()) - { -// cout << "EOF" << endl; - return 0; - } - cin.get (aChar); - return 1; -} - -int -mimeIO::outputChar (char aChar) -{ - cout << aChar; - return 1; -} - -void -mimeIO::setCRLF (const char *aCRLF) -{ - theCRLF = aCRLF; - crlfLen = strlen(aCRLF); -} - -mimeIOTQFile::mimeIOTQFile (const TQString & aName): -mimeIO (), -myFile (aName) -{ - myFile.open (IO_ReadOnly); -} - -mimeIOTQFile::~mimeIOTQFile () -{ - myFile.close (); -} - -int -mimeIOTQFile::outputLine (const TQCString &, int) -{ - return 0; -} - -int -mimeIOTQFile::inputLine (TQCString & data) -{ - data.resize( 1024 ); - myFile.readLine (data.data(), 1024); - - return data.length (); -} - -mimeIOTQString::mimeIOTQString () -{ -} - -mimeIOTQString::~mimeIOTQString () -{ -} - -int -mimeIOTQString::outputLine (const TQCString & _str, int len) -{ - if (len == -1) { - len = _str.length(); - } - theString += _str; - return len; -} - -int -mimeIOTQString::inputLine (TQCString & _str) -{ - if (theString.isEmpty ()) - return 0; - - int i = theString.find ('\n'); - - if (i == -1) - return 0; - _str = theString.left (i + 1).latin1 (); - theString = theString.right (theString.length () - i - 1); - return _str.length (); -} diff --git a/tdeioslave/imap4/mimeio.cpp b/tdeioslave/imap4/mimeio.cpp new file mode 100644 index 00000000..a3315c26 --- /dev/null +++ b/tdeioslave/imap4/mimeio.cpp @@ -0,0 +1,188 @@ +/*************************************************************************** + mimeio.cpp - description + ------------------- + begin : Wed Oct 25 2000 + copyright : (C) 2000 by Sven Carstens + email : s.carstens@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +using namespace std; + +#include "mimeio.h" + +mimeIO::mimeIO () +{ + theCRLF = "\r\n"; + crlfLen = 2; +} + +mimeIO::~mimeIO () +{ +} + +int +mimeIO::inputLine (TQCString & aLine) +{ + char input; + + aLine = (const char *) NULL; + while (inputChar (input)) + { + aLine += input; + if (input == '\n') + break; + } +// cout << aLine.length() << " - " << aLine; + return aLine.length (); +} + +int +mimeIO::outputLine (const TQCString & aLine, int len) +{ + int i; + + if (len == -1) { + len = aLine.length(); + } + int start = len; + for (i = 0; i < start; i++) + if (!outputChar (aLine[i])) + break; + return i; +} + +int +mimeIO::outputMimeLine (const TQCString & inLine) +{ + int retVal = 0; + TQCString aLine = inLine; + int len = inLine.length(); + + int theLF = aLine.findRev ('\n'); + if (theLF == len - 1 && theLF != -1) + { + //we have a trailing LF, now check for CR + if (aLine[theLF - 1] == '\r') + theLF--; + //truncate the line + aLine.truncate(theLF); + len = theLF; + theLF = -1; + } + //now truncate the line + { + int start, end, offset; + start = 0; + end = aLine.find ('\n', start); + while (end >= 0) + { + offset = 1; + if (end && aLine[end - 1] == '\r') + { + offset++; + end--; + } + outputLine (aLine.mid (start, end - start) + theCRLF, end - start + crlfLen); + start = end + offset; + end = aLine.find ('\n', start); + } + outputLine (aLine.mid (start, len - start) + theCRLF, len - start + crlfLen); + } + return retVal; +} + +int +mimeIO::inputChar (char &aChar) +{ + if (cin.eof ()) + { +// cout << "EOF" << endl; + return 0; + } + cin.get (aChar); + return 1; +} + +int +mimeIO::outputChar (char aChar) +{ + cout << aChar; + return 1; +} + +void +mimeIO::setCRLF (const char *aCRLF) +{ + theCRLF = aCRLF; + crlfLen = strlen(aCRLF); +} + +mimeIOTQFile::mimeIOTQFile (const TQString & aName): +mimeIO (), +myFile (aName) +{ + myFile.open (IO_ReadOnly); +} + +mimeIOTQFile::~mimeIOTQFile () +{ + myFile.close (); +} + +int +mimeIOTQFile::outputLine (const TQCString &, int) +{ + return 0; +} + +int +mimeIOTQFile::inputLine (TQCString & data) +{ + data.resize( 1024 ); + myFile.readLine (data.data(), 1024); + + return data.length (); +} + +mimeIOTQString::mimeIOTQString () +{ +} + +mimeIOTQString::~mimeIOTQString () +{ +} + +int +mimeIOTQString::outputLine (const TQCString & _str, int len) +{ + if (len == -1) { + len = _str.length(); + } + theString += _str; + return len; +} + +int +mimeIOTQString::inputLine (TQCString & _str) +{ + if (theString.isEmpty ()) + return 0; + + int i = theString.find ('\n'); + + if (i == -1) + return 0; + _str = theString.left (i + 1).latin1 (); + theString = theString.right (theString.length () - i - 1); + return _str.length (); +} diff --git a/tdeioslave/imap4/rfcdecoder.cc b/tdeioslave/imap4/rfcdecoder.cc deleted file mode 100644 index 41a50ec1..00000000 --- a/tdeioslave/imap4/rfcdecoder.cc +++ /dev/null @@ -1,668 +0,0 @@ -/********************************************************************** - * - * rfcdecoder.cc - handler for various rfc/mime encodings - * Copyright (C) 2000 s.carstens@gmx.de - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Send comments and bug fixes to s.carstens@gmx.de - * - *********************************************************************/ -#include "rfcdecoder.h" - -#include -#include - -#include -#include - -#include -#include -#include -#include - -// This part taken from rfc 2192 IMAP URL Scheme. C. Newman. September 1997. -// adapted to QT-Toolkit by Sven Carstens 2000 - -static unsigned char base64chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; -#define UNDEFINED 64 -#define MAXLINE 76 - -/* UTF16 definitions */ -#define UTF16MASK 0x03FFUL -#define UTF16SHIFT 10 -#define UTF16BASE 0x10000UL -#define UTF16HIGHSTART 0xD800UL -#define UTF16HIGHEND 0xDBFFUL -#define UTF16LOSTART 0xDC00UL -#define UTF16LOEND 0xDFFFUL - -/* Convert an IMAP mailbox to a Unicode path - */ -TQString rfcDecoder::fromIMAP (const TQString & inSrc) -{ - unsigned char c, i, bitcount; - unsigned long ucs4, utf16, bitbuf; - unsigned char base64[256], utf8[6]; - unsigned long srcPtr = 0; - TQCString dst; - TQCString src = inSrc.ascii (); - uint srcLen = inSrc.length(); - - /* initialize modified base64 decoding table */ - memset (base64, UNDEFINED, sizeof (base64)); - for (i = 0; i < sizeof (base64chars); ++i) - { - base64[(int)base64chars[i]] = i; - } - - /* loop until end of string */ - while (srcPtr < srcLen) - { - c = src[srcPtr++]; - /* deal with literal characters and &- */ - if (c != '&' || src[srcPtr] == '-') - { - /* encode literally */ - dst += c; - /* skip over the '-' if this is an &- sequence */ - if (c == '&') - srcPtr++; - } - else - { - /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ - bitbuf = 0; - bitcount = 0; - ucs4 = 0; - while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) - { - ++srcPtr; - bitbuf = (bitbuf << 6) | c; - bitcount += 6; - /* enough bits for a UTF-16 character? */ - if (bitcount >= 16) - { - bitcount -= 16; - utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; - /* convert UTF16 to UCS4 */ - if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) - { - ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; - continue; - } - else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) - { - ucs4 += utf16 - UTF16LOSTART + UTF16BASE; - } - else - { - ucs4 = utf16; - } - /* convert UTF-16 range of UCS4 to UTF-8 */ - if (ucs4 <= 0x7fUL) - { - utf8[0] = ucs4; - i = 1; - } - else if (ucs4 <= 0x7ffUL) - { - utf8[0] = 0xc0 | (ucs4 >> 6); - utf8[1] = 0x80 | (ucs4 & 0x3f); - i = 2; - } - else if (ucs4 <= 0xffffUL) - { - utf8[0] = 0xe0 | (ucs4 >> 12); - utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); - utf8[2] = 0x80 | (ucs4 & 0x3f); - i = 3; - } - else - { - utf8[0] = 0xf0 | (ucs4 >> 18); - utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); - utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); - utf8[3] = 0x80 | (ucs4 & 0x3f); - i = 4; - } - /* copy it */ - for (c = 0; c < i; ++c) - { - dst += utf8[c]; - } - } - } - /* skip over trailing '-' in modified UTF-7 encoding */ - if (src[srcPtr] == '-') - ++srcPtr; - } - } - return TQString::fromUtf8 (dst.data ()); -} - -/* replace " with \" and \ with \\ " and \ characters */ -TQString rfcDecoder::quoteIMAP(const TQString &src) -{ - uint len = src.length(); - TQString result; - result.reserve(2 * len); - for (unsigned int i = 0; i < len; i++) - { - if (src[i] == '"' || src[i] == '\\') - result += '\\'; - result += src[i]; - } - //result.squeeze(); - unnecessary and slow - return result; -} - -/* Convert Unicode path to modified UTF-7 IMAP mailbox - */ -TQString rfcDecoder::toIMAP (const TQString & inSrc) -{ - unsigned int utf8pos, utf8total, c, utf7mode, bitstogo, utf16flag; - unsigned long ucs4, bitbuf; - TQCString src = inSrc.utf8 (); - TQString dst; - - ulong srcPtr = 0; - utf7mode = 0; - utf8total = 0; - bitstogo = 0; - utf8pos = 0; - bitbuf = 0; - ucs4 = 0; - while (srcPtr < src.length ()) - { - c = (unsigned char) src[srcPtr++]; - /* normal character? */ - if (c >= ' ' && c <= '~') - { - /* switch out of UTF-7 mode */ - if (utf7mode) - { - if (bitstogo) - { - dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F]; - bitstogo = 0; - } - dst += '-'; - utf7mode = 0; - } - dst += c; - /* encode '&' as '&-' */ - if (c == '&') - { - dst += '-'; - } - continue; - } - /* switch to UTF-7 mode */ - if (!utf7mode) - { - dst += '&'; - utf7mode = 1; - } - /* Encode US-ASCII characters as themselves */ - if (c < 0x80) - { - ucs4 = c; - utf8total = 1; - } - else if (utf8total) - { - /* save UTF8 bits into UCS4 */ - ucs4 = (ucs4 << 6) | (c & 0x3FUL); - if (++utf8pos < utf8total) - { - continue; - } - } - else - { - utf8pos = 1; - if (c < 0xE0) - { - utf8total = 2; - ucs4 = c & 0x1F; - } - else if (c < 0xF0) - { - utf8total = 3; - ucs4 = c & 0x0F; - } - else - { - /* NOTE: can't convert UTF8 sequences longer than 4 */ - utf8total = 4; - ucs4 = c & 0x03; - } - continue; - } - /* loop to split ucs4 into two utf16 chars if necessary */ - utf8total = 0; - do - { - if (ucs4 >= UTF16BASE) - { - ucs4 -= UTF16BASE; - bitbuf = (bitbuf << 16) | ((ucs4 >> UTF16SHIFT) + UTF16HIGHSTART); - ucs4 = (ucs4 & UTF16MASK) + UTF16LOSTART; - utf16flag = 1; - } - else - { - bitbuf = (bitbuf << 16) | ucs4; - utf16flag = 0; - } - bitstogo += 16; - /* spew out base64 */ - while (bitstogo >= 6) - { - bitstogo -= 6; - dst += base64chars[(bitstogo ? (bitbuf >> bitstogo) : bitbuf) & 0x3F]; - } - } - while (utf16flag); - } - /* if in UTF-7 mode, finish in ASCII */ - if (utf7mode) - { - if (bitstogo) - { - dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F]; - } - dst += '-'; - } - return quoteIMAP(dst); -} - -//----------------------------------------------------------------------------- -TQString rfcDecoder::decodeQuoting(const TQString &aStr) -{ - TQString result; - unsigned int strLength(aStr.length()); - for (unsigned int i = 0; i < strLength ; i++) - { - if (aStr[i] == "\\") i++; - result += aStr[i]; - } - return result; -} - -//----------------------------------------------------------------------------- -TQTextCodec * -rfcDecoder::codecForName (const TQString & _str) -{ - if (_str.isEmpty ()) - return NULL; - return TQTextCodec::codecForName (_str.lower (). - replace ("windows", "cp").latin1 ()); -} - -//----------------------------------------------------------------------------- -const TQString -rfcDecoder::decodeRFC2047String (const TQString & _str) -{ - TQString throw_away; - - return decodeRFC2047String (_str, throw_away); -} - -//----------------------------------------------------------------------------- -const TQString -rfcDecoder::decodeRFC2047String (const TQString & _str, TQString & charset) -{ - TQString throw_away; - - return decodeRFC2047String (_str, charset, throw_away); -} - -//----------------------------------------------------------------------------- -const TQString -rfcDecoder::decodeRFC2047String (const TQString & _str, TQString & charset, - TQString & language) -{ - //do we have a rfc string - if (_str.find("=?") < 0) - return _str; - - TQCString aStr = _str.ascii (); // TQString.length() means Unicode chars - TQCString result; - char *pos, *beg, *end, *mid = NULL; - TQCString str; - char encoding = 0, ch; - bool valid; - const int maxLen = 200; - int i; - -// result.truncate(aStr.length()); - for (pos = aStr.data (); *pos; pos++) - { - if (pos[0] != '=' || pos[1] != '?') - { - result += *pos; - continue; - } - beg = pos + 2; - end = beg; - valid = TRUE; - // parse charset name - for (i = 2, pos += 2; - i < maxLen && (*pos != '?' && (ispunct (*pos) || isalnum (*pos))); - i++) - pos++; - if (*pos != '?' || i < 4 || i >= maxLen) - valid = FALSE; - else - { - charset = TQCString (beg, i - 1); // -2 + 1 for the zero - int pt = charset.findRev('*'); - if (pt != -1) - { - // save language for later usage - language = charset.right (charset.length () - pt - 1); - - // tie off language as defined in rfc2047 - charset.truncate(pt); - } - // get encoding and check delimiting question marks - encoding = toupper (pos[1]); - if (pos[2] != '?' - || (encoding != 'Q' && encoding != 'B' && encoding != 'q' - && encoding != 'b')) - valid = FALSE; - pos += 3; - i += 3; -// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - charset " << charset << " - language " << language << " - '" << pos << "'" << endl; - } - if (valid) - { - mid = pos; - // search for end of encoded part - while (i < maxLen && *pos && !(*pos == '?' && *(pos + 1) == '=')) - { - i++; - pos++; - } - end = pos + 2; //end now points to the first char after the encoded string - if (i >= maxLen || !*pos) - valid = FALSE; - } - if (valid) - { - ch = *pos; - *pos = '\0'; - str = TQCString (mid).left ((int) (mid - pos - 1)); - if (encoding == 'Q') - { - // decode quoted printable text - for (i = str.length () - 1; i >= 0; i--) - if (str[i] == '_') - str[i] = ' '; -// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - before QP '" << str << "'" << endl; - - str = KCodecs::quotedPrintableDecode(str); -// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - after QP '" << str << "'" << endl; - } - else - { - // decode base64 text - str = KCodecs::base64Decode(str); - } - *pos = ch; - int len = str.length(); - for (i = 0; i < len; i++) - result += (char) (TQChar) str[i]; - - pos = end - 1; - } - else - { -// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - invalid" << endl; - //result += "=?"; - //pos = beg -1; // because pos gets increased shortly afterwards - pos = beg - 2; - result += *pos++; - result += *pos; - } - } - if (!charset.isEmpty ()) - { - TQTextCodec *aCodec = codecForName (charset.ascii ()); - if (aCodec) - { -// kdDebug(7116) << "Codec is " << aCodec->name() << endl; - return aCodec->toUnicode (result); - } - } - return result; -} - - -//----------------------------------------------------------------------------- -const char especials[17] = "()<>@,;:\"/[]?.= "; - -const TQString -rfcDecoder::encodeRFC2047String (const TQString & _str) -{ - if (_str.isEmpty ()) - return _str; - const signed char *latin = reinterpret_cast(_str.latin1()), *l, *start, *stop; - char hexcode; - int numQuotes, i; - int rptr = 0; - // My stats show this number results in 12 resize() out of 73,000 - int resultLen = 3 * _str.length() / 2; - TQCString result(resultLen); - - while (*latin) - { - l = latin; - start = latin; - while (*l) - { - if (*l == 32) - start = l + 1; - if (*l < 0) - break; - l++; - } - if (*l) - { - numQuotes = 1; - while (*l) - { - /* The encoded word must be limited to 75 character */ - for (i = 0; i < 16; i++) - if (*l == especials[i]) - numQuotes++; - if (*l < 0) - numQuotes++; - /* Stop after 58 = 75 - 17 characters or at "= 58 || *l == 60) - break; - l++; - } - if (*l) - { - stop = l - 1; - while (stop >= start && *stop != 32) - stop--; - if (stop <= start) - stop = l; - } - else - stop = l; - if (resultLen - rptr - 1 <= start - latin + 1 + 16 /* =?iso-88... */) { - resultLen += (start - latin + 1) * 2 + 20; // more space - result.resize(resultLen); - } - while (latin < start) - { - result[rptr++] = *latin; - latin++; - } - strcpy(&result[rptr], "=?iso-8859-1?q?"); rptr += 15; - if (resultLen - rptr - 1 <= 3*(stop - latin + 1)) { - resultLen += (stop - latin + 1) * 4 + 20; // more space - result.resize(resultLen); - } - while (latin < stop) // can add up to 3 chars/iteration - { - numQuotes = 0; - for (i = 0; i < 16; i++) - if (*latin == especials[i]) - numQuotes = 1; - if (*latin < 0) - numQuotes = 1; - if (numQuotes) - { - result[rptr++] = '='; - hexcode = ((*latin & 0xF0) >> 4) + 48; - if (hexcode >= 58) - hexcode += 7; - result[rptr++] = hexcode; - hexcode = (*latin & 0x0F) + 48; - if (hexcode >= 58) - hexcode += 7; - result[rptr++] = hexcode; - } - else - { - result[rptr++] = *latin; - } - latin++; - } - result[rptr++] = '?'; - result[rptr++] = '='; - } - else - { - while (*latin) - { - if (rptr == resultLen - 1) { - resultLen += 30; - result.resize(resultLen); - } - result[rptr++] = *latin; - latin++; - } - } - } - result[rptr] = 0; - //free (latinStart); - return result; -} - - -//----------------------------------------------------------------------------- -const TQString -rfcDecoder::encodeRFC2231String (const TQString & _str) -{ - if (_str.isEmpty ()) - return _str; - signed char *latin = (signed char *) calloc (1, _str.length () + 1); - char *latin_us = (char *) latin; - strcpy (latin_us, _str.latin1 ()); - signed char *l = latin; - char hexcode; - int i; - bool quote; - while (*l) - { - if (*l < 0) - break; - l++; - } - if (!*l) { - free(latin); - return _str; - } - TQCString result; - l = latin; - while (*l) - { - quote = *l < 0; - for (i = 0; i < 16; i++) - if (*l == especials[i]) - quote = true; - if (quote) - { - result += "%"; - hexcode = ((*l & 0xF0) >> 4) + 48; - if (hexcode >= 58) - hexcode += 7; - result += hexcode; - hexcode = (*l & 0x0F) + 48; - if (hexcode >= 58) - hexcode += 7; - result += hexcode; - } - else - { - result += *l; - } - l++; - } - free (latin); - return result; -} - - -//----------------------------------------------------------------------------- -const TQString -rfcDecoder::decodeRFC2231String (const TQString & _str) -{ - int p = _str.find ('\''); - - //see if it is an rfc string - if (p < 0) - return _str; - - int l = _str.findRev ('\''); - - //second is language - if (p >= l) - return _str; - - //first is charset or empty - TQString charset = _str.left (p); - TQString st = _str.mid (l + 1); - TQString language = _str.mid (p + 1, l - p - 1); - - //kdDebug(7116) << "Charset: " << charset << " Language: " << language << endl; - - char ch, ch2; - p = 0; - while (p < (int) st.length ()) - { - if (st.at (p) == 37) - { - ch = st.at (p + 1).latin1 () - 48; - if (ch > 16) - ch -= 7; - ch2 = st.at (p + 2).latin1 () - 48; - if (ch2 > 16) - ch2 -= 7; - st.at (p) = ch * 16 + ch2; - st.remove (p + 1, 2); - } - p++; - } - return st; -} diff --git a/tdeioslave/imap4/rfcdecoder.cpp b/tdeioslave/imap4/rfcdecoder.cpp new file mode 100644 index 00000000..36111bf1 --- /dev/null +++ b/tdeioslave/imap4/rfcdecoder.cpp @@ -0,0 +1,668 @@ +/********************************************************************** + * + * rfcdecoder.cpp - handler for various rfc/mime encodings + * Copyright (C) 2000 s.carstens@gmx.de + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Send comments and bug fixes to s.carstens@gmx.de + * + *********************************************************************/ +#include "rfcdecoder.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include + +// This part taken from rfc 2192 IMAP URL Scheme. C. Newman. September 1997. +// adapted to QT-Toolkit by Sven Carstens 2000 + +static unsigned char base64chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; +#define UNDEFINED 64 +#define MAXLINE 76 + +/* UTF16 definitions */ +#define UTF16MASK 0x03FFUL +#define UTF16SHIFT 10 +#define UTF16BASE 0x10000UL +#define UTF16HIGHSTART 0xD800UL +#define UTF16HIGHEND 0xDBFFUL +#define UTF16LOSTART 0xDC00UL +#define UTF16LOEND 0xDFFFUL + +/* Convert an IMAP mailbox to a Unicode path + */ +TQString rfcDecoder::fromIMAP (const TQString & inSrc) +{ + unsigned char c, i, bitcount; + unsigned long ucs4, utf16, bitbuf; + unsigned char base64[256], utf8[6]; + unsigned long srcPtr = 0; + TQCString dst; + TQCString src = inSrc.ascii (); + uint srcLen = inSrc.length(); + + /* initialize modified base64 decoding table */ + memset (base64, UNDEFINED, sizeof (base64)); + for (i = 0; i < sizeof (base64chars); ++i) + { + base64[(int)base64chars[i]] = i; + } + + /* loop until end of string */ + while (srcPtr < srcLen) + { + c = src[srcPtr++]; + /* deal with literal characters and &- */ + if (c != '&' || src[srcPtr] == '-') + { + /* encode literally */ + dst += c; + /* skip over the '-' if this is an &- sequence */ + if (c == '&') + srcPtr++; + } + else + { + /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ + bitbuf = 0; + bitcount = 0; + ucs4 = 0; + while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) + { + ++srcPtr; + bitbuf = (bitbuf << 6) | c; + bitcount += 6; + /* enough bits for a UTF-16 character? */ + if (bitcount >= 16) + { + bitcount -= 16; + utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; + /* convert UTF16 to UCS4 */ + if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) + { + ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; + continue; + } + else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) + { + ucs4 += utf16 - UTF16LOSTART + UTF16BASE; + } + else + { + ucs4 = utf16; + } + /* convert UTF-16 range of UCS4 to UTF-8 */ + if (ucs4 <= 0x7fUL) + { + utf8[0] = ucs4; + i = 1; + } + else if (ucs4 <= 0x7ffUL) + { + utf8[0] = 0xc0 | (ucs4 >> 6); + utf8[1] = 0x80 | (ucs4 & 0x3f); + i = 2; + } + else if (ucs4 <= 0xffffUL) + { + utf8[0] = 0xe0 | (ucs4 >> 12); + utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); + utf8[2] = 0x80 | (ucs4 & 0x3f); + i = 3; + } + else + { + utf8[0] = 0xf0 | (ucs4 >> 18); + utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); + utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); + utf8[3] = 0x80 | (ucs4 & 0x3f); + i = 4; + } + /* copy it */ + for (c = 0; c < i; ++c) + { + dst += utf8[c]; + } + } + } + /* skip over trailing '-' in modified UTF-7 encoding */ + if (src[srcPtr] == '-') + ++srcPtr; + } + } + return TQString::fromUtf8 (dst.data ()); +} + +/* replace " with \" and \ with \\ " and \ characters */ +TQString rfcDecoder::quoteIMAP(const TQString &src) +{ + uint len = src.length(); + TQString result; + result.reserve(2 * len); + for (unsigned int i = 0; i < len; i++) + { + if (src[i] == '"' || src[i] == '\\') + result += '\\'; + result += src[i]; + } + //result.squeeze(); - unnecessary and slow + return result; +} + +/* Convert Unicode path to modified UTF-7 IMAP mailbox + */ +TQString rfcDecoder::toIMAP (const TQString & inSrc) +{ + unsigned int utf8pos, utf8total, c, utf7mode, bitstogo, utf16flag; + unsigned long ucs4, bitbuf; + TQCString src = inSrc.utf8 (); + TQString dst; + + ulong srcPtr = 0; + utf7mode = 0; + utf8total = 0; + bitstogo = 0; + utf8pos = 0; + bitbuf = 0; + ucs4 = 0; + while (srcPtr < src.length ()) + { + c = (unsigned char) src[srcPtr++]; + /* normal character? */ + if (c >= ' ' && c <= '~') + { + /* switch out of UTF-7 mode */ + if (utf7mode) + { + if (bitstogo) + { + dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F]; + bitstogo = 0; + } + dst += '-'; + utf7mode = 0; + } + dst += c; + /* encode '&' as '&-' */ + if (c == '&') + { + dst += '-'; + } + continue; + } + /* switch to UTF-7 mode */ + if (!utf7mode) + { + dst += '&'; + utf7mode = 1; + } + /* Encode US-ASCII characters as themselves */ + if (c < 0x80) + { + ucs4 = c; + utf8total = 1; + } + else if (utf8total) + { + /* save UTF8 bits into UCS4 */ + ucs4 = (ucs4 << 6) | (c & 0x3FUL); + if (++utf8pos < utf8total) + { + continue; + } + } + else + { + utf8pos = 1; + if (c < 0xE0) + { + utf8total = 2; + ucs4 = c & 0x1F; + } + else if (c < 0xF0) + { + utf8total = 3; + ucs4 = c & 0x0F; + } + else + { + /* NOTE: can't convert UTF8 sequences longer than 4 */ + utf8total = 4; + ucs4 = c & 0x03; + } + continue; + } + /* loop to split ucs4 into two utf16 chars if necessary */ + utf8total = 0; + do + { + if (ucs4 >= UTF16BASE) + { + ucs4 -= UTF16BASE; + bitbuf = (bitbuf << 16) | ((ucs4 >> UTF16SHIFT) + UTF16HIGHSTART); + ucs4 = (ucs4 & UTF16MASK) + UTF16LOSTART; + utf16flag = 1; + } + else + { + bitbuf = (bitbuf << 16) | ucs4; + utf16flag = 0; + } + bitstogo += 16; + /* spew out base64 */ + while (bitstogo >= 6) + { + bitstogo -= 6; + dst += base64chars[(bitstogo ? (bitbuf >> bitstogo) : bitbuf) & 0x3F]; + } + } + while (utf16flag); + } + /* if in UTF-7 mode, finish in ASCII */ + if (utf7mode) + { + if (bitstogo) + { + dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F]; + } + dst += '-'; + } + return quoteIMAP(dst); +} + +//----------------------------------------------------------------------------- +TQString rfcDecoder::decodeQuoting(const TQString &aStr) +{ + TQString result; + unsigned int strLength(aStr.length()); + for (unsigned int i = 0; i < strLength ; i++) + { + if (aStr[i] == "\\") i++; + result += aStr[i]; + } + return result; +} + +//----------------------------------------------------------------------------- +TQTextCodec * +rfcDecoder::codecForName (const TQString & _str) +{ + if (_str.isEmpty ()) + return NULL; + return TQTextCodec::codecForName (_str.lower (). + replace ("windows", "cp").latin1 ()); +} + +//----------------------------------------------------------------------------- +const TQString +rfcDecoder::decodeRFC2047String (const TQString & _str) +{ + TQString throw_away; + + return decodeRFC2047String (_str, throw_away); +} + +//----------------------------------------------------------------------------- +const TQString +rfcDecoder::decodeRFC2047String (const TQString & _str, TQString & charset) +{ + TQString throw_away; + + return decodeRFC2047String (_str, charset, throw_away); +} + +//----------------------------------------------------------------------------- +const TQString +rfcDecoder::decodeRFC2047String (const TQString & _str, TQString & charset, + TQString & language) +{ + //do we have a rfc string + if (_str.find("=?") < 0) + return _str; + + TQCString aStr = _str.ascii (); // TQString.length() means Unicode chars + TQCString result; + char *pos, *beg, *end, *mid = NULL; + TQCString str; + char encoding = 0, ch; + bool valid; + const int maxLen = 200; + int i; + +// result.truncate(aStr.length()); + for (pos = aStr.data (); *pos; pos++) + { + if (pos[0] != '=' || pos[1] != '?') + { + result += *pos; + continue; + } + beg = pos + 2; + end = beg; + valid = TRUE; + // parse charset name + for (i = 2, pos += 2; + i < maxLen && (*pos != '?' && (ispunct (*pos) || isalnum (*pos))); + i++) + pos++; + if (*pos != '?' || i < 4 || i >= maxLen) + valid = FALSE; + else + { + charset = TQCString (beg, i - 1); // -2 + 1 for the zero + int pt = charset.findRev('*'); + if (pt != -1) + { + // save language for later usage + language = charset.right (charset.length () - pt - 1); + + // tie off language as defined in rfc2047 + charset.truncate(pt); + } + // get encoding and check delimiting question marks + encoding = toupper (pos[1]); + if (pos[2] != '?' + || (encoding != 'Q' && encoding != 'B' && encoding != 'q' + && encoding != 'b')) + valid = FALSE; + pos += 3; + i += 3; +// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - charset " << charset << " - language " << language << " - '" << pos << "'" << endl; + } + if (valid) + { + mid = pos; + // search for end of encoded part + while (i < maxLen && *pos && !(*pos == '?' && *(pos + 1) == '=')) + { + i++; + pos++; + } + end = pos + 2; //end now points to the first char after the encoded string + if (i >= maxLen || !*pos) + valid = FALSE; + } + if (valid) + { + ch = *pos; + *pos = '\0'; + str = TQCString (mid).left ((int) (mid - pos - 1)); + if (encoding == 'Q') + { + // decode quoted printable text + for (i = str.length () - 1; i >= 0; i--) + if (str[i] == '_') + str[i] = ' '; +// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - before QP '" << str << "'" << endl; + + str = KCodecs::quotedPrintableDecode(str); +// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - after QP '" << str << "'" << endl; + } + else + { + // decode base64 text + str = KCodecs::base64Decode(str); + } + *pos = ch; + int len = str.length(); + for (i = 0; i < len; i++) + result += (char) (TQChar) str[i]; + + pos = end - 1; + } + else + { +// kdDebug(7116) << "rfcDecoder::decodeRFC2047String - invalid" << endl; + //result += "=?"; + //pos = beg -1; // because pos gets increased shortly afterwards + pos = beg - 2; + result += *pos++; + result += *pos; + } + } + if (!charset.isEmpty ()) + { + TQTextCodec *aCodec = codecForName (charset.ascii ()); + if (aCodec) + { +// kdDebug(7116) << "Codec is " << aCodec->name() << endl; + return aCodec->toUnicode (result); + } + } + return result; +} + + +//----------------------------------------------------------------------------- +const char especials[17] = "()<>@,;:\"/[]?.= "; + +const TQString +rfcDecoder::encodeRFC2047String (const TQString & _str) +{ + if (_str.isEmpty ()) + return _str; + const signed char *latin = reinterpret_cast(_str.latin1()), *l, *start, *stop; + char hexcode; + int numQuotes, i; + int rptr = 0; + // My stats show this number results in 12 resize() out of 73,000 + int resultLen = 3 * _str.length() / 2; + TQCString result(resultLen); + + while (*latin) + { + l = latin; + start = latin; + while (*l) + { + if (*l == 32) + start = l + 1; + if (*l < 0) + break; + l++; + } + if (*l) + { + numQuotes = 1; + while (*l) + { + /* The encoded word must be limited to 75 character */ + for (i = 0; i < 16; i++) + if (*l == especials[i]) + numQuotes++; + if (*l < 0) + numQuotes++; + /* Stop after 58 = 75 - 17 characters or at "= 58 || *l == 60) + break; + l++; + } + if (*l) + { + stop = l - 1; + while (stop >= start && *stop != 32) + stop--; + if (stop <= start) + stop = l; + } + else + stop = l; + if (resultLen - rptr - 1 <= start - latin + 1 + 16 /* =?iso-88... */) { + resultLen += (start - latin + 1) * 2 + 20; // more space + result.resize(resultLen); + } + while (latin < start) + { + result[rptr++] = *latin; + latin++; + } + strcpy(&result[rptr], "=?iso-8859-1?q?"); rptr += 15; + if (resultLen - rptr - 1 <= 3*(stop - latin + 1)) { + resultLen += (stop - latin + 1) * 4 + 20; // more space + result.resize(resultLen); + } + while (latin < stop) // can add up to 3 chars/iteration + { + numQuotes = 0; + for (i = 0; i < 16; i++) + if (*latin == especials[i]) + numQuotes = 1; + if (*latin < 0) + numQuotes = 1; + if (numQuotes) + { + result[rptr++] = '='; + hexcode = ((*latin & 0xF0) >> 4) + 48; + if (hexcode >= 58) + hexcode += 7; + result[rptr++] = hexcode; + hexcode = (*latin & 0x0F) + 48; + if (hexcode >= 58) + hexcode += 7; + result[rptr++] = hexcode; + } + else + { + result[rptr++] = *latin; + } + latin++; + } + result[rptr++] = '?'; + result[rptr++] = '='; + } + else + { + while (*latin) + { + if (rptr == resultLen - 1) { + resultLen += 30; + result.resize(resultLen); + } + result[rptr++] = *latin; + latin++; + } + } + } + result[rptr] = 0; + //free (latinStart); + return result; +} + + +//----------------------------------------------------------------------------- +const TQString +rfcDecoder::encodeRFC2231String (const TQString & _str) +{ + if (_str.isEmpty ()) + return _str; + signed char *latin = (signed char *) calloc (1, _str.length () + 1); + char *latin_us = (char *) latin; + strcpy (latin_us, _str.latin1 ()); + signed char *l = latin; + char hexcode; + int i; + bool quote; + while (*l) + { + if (*l < 0) + break; + l++; + } + if (!*l) { + free(latin); + return _str; + } + TQCString result; + l = latin; + while (*l) + { + quote = *l < 0; + for (i = 0; i < 16; i++) + if (*l == especials[i]) + quote = true; + if (quote) + { + result += "%"; + hexcode = ((*l & 0xF0) >> 4) + 48; + if (hexcode >= 58) + hexcode += 7; + result += hexcode; + hexcode = (*l & 0x0F) + 48; + if (hexcode >= 58) + hexcode += 7; + result += hexcode; + } + else + { + result += *l; + } + l++; + } + free (latin); + return result; +} + + +//----------------------------------------------------------------------------- +const TQString +rfcDecoder::decodeRFC2231String (const TQString & _str) +{ + int p = _str.find ('\''); + + //see if it is an rfc string + if (p < 0) + return _str; + + int l = _str.findRev ('\''); + + //second is language + if (p >= l) + return _str; + + //first is charset or empty + TQString charset = _str.left (p); + TQString st = _str.mid (l + 1); + TQString language = _str.mid (p + 1, l - p - 1); + + //kdDebug(7116) << "Charset: " << charset << " Language: " << language << endl; + + char ch, ch2; + p = 0; + while (p < (int) st.length ()) + { + if (st.at (p) == 37) + { + ch = st.at (p + 1).latin1 () - 48; + if (ch > 16) + ch -= 7; + ch2 = st.at (p + 2).latin1 () - 48; + if (ch2 > 16) + ch2 -= 7; + st.at (p) = ch * 16 + ch2; + st.remove (p + 1, 2); + } + p++; + } + return st; +} diff --git a/tdeioslave/mbox/CMakeLists.txt b/tdeioslave/mbox/CMakeLists.txt index 70da626f..27e51538 100644 --- a/tdeioslave/mbox/CMakeLists.txt +++ b/tdeioslave/mbox/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( tde_add_kpart( tdeio_mbox SOURCES - mbox.cc mboxfile.cc readmbox.cc stat.cc urlinfo.cc + mbox.cpp mboxfile.cpp readmbox.cpp stat.cpp urlinfo.cpp LINK tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/tdeioslave/mbox/Makefile.am b/tdeioslave/mbox/Makefile.am index 4dea4644..ff09d9f9 100644 --- a/tdeioslave/mbox/Makefile.am +++ b/tdeioslave/mbox/Makefile.am @@ -7,11 +7,11 @@ METASOURCES = AUTO kde_module_LTLIBRARIES = tdeio_mbox.la tdeio_mbox_la_SOURCES = \ - mbox.cc \ - mboxfile.cc \ - readmbox.cc \ - stat.cc \ - urlinfo.cc + mbox.cpp \ + mboxfile.cpp \ + readmbox.cpp \ + stat.cpp \ + urlinfo.cpp tdeio_mbox_la_LIBADD = $(LIB_TDEIO) $(LIB_QT) $(LIB_TDECORE) tdeio_mbox_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) diff --git a/tdeioslave/mbox/mbox.cc b/tdeioslave/mbox/mbox.cc deleted file mode 100644 index 5742baff..00000000 --- a/tdeioslave/mbox/mbox.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This is a simple tdeioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) - * - * 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 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 - */ -#include "mbox.h" - -#include "readmbox.h" -#include "stat.h" -#include "urlinfo.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "tdepimmacros.h" - -#include "mbox.h" - -extern "C" { KDE_EXPORT int kdemain(int argc, char* argv[]); } - -int kdemain( int argc, char * argv[] ) -{ - TDELocale::setMainCatalogue("tdelibs"); - TDEInstance instance("tdeio_mbox"); - (void) TDEGlobal::locale(); - - if (argc != 4) { - fprintf(stderr, "Usage: tdeio_mbox protocol " - "domain-socket1 domain-socket2\n"); - exit(-1); - } - - MBoxProtocol slave(argv[2], argv[3]); - slave.dispatchLoop(); - - return 0; -} - -MBoxProtocol::MBoxProtocol( const TQCString& arg1, const TQCString& arg2 ) - : TDEIO::SlaveBase( "mbox2", arg1, arg2 ), - m_errorState( true ) -{ - -} - -MBoxProtocol::~MBoxProtocol() -{ -} - -void MBoxProtocol::get( const KURL& url ) -{ - m_errorState = false; - - UrlInfo info( url, UrlInfo::message ); - TQString line; - TQByteArray ba_line; - - if( info.type() == UrlInfo::invalid && !m_errorState ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); - return; - } - - ReadMBox mbox( &info, this ); - - while( !mbox.atEnd() && !m_errorState) - { - line = mbox.currentLine(); - line += '\n'; - ba_line = TQCString( line.utf8() ); - ba_line.truncate( ba_line.size() - 1 ); //Removing training '\0' - data( ba_line ); - mbox.nextLine(); - }; - - if( !m_errorState ) - { - data( TQByteArray() ); - finished(); - } -} - -void MBoxProtocol::listDir( const KURL& url ) -{ - m_errorState = false; - - TDEIO::UDSEntry entry; - UrlInfo info( url, UrlInfo::directory ); - ReadMBox mbox( &info, this, hasMetaData( "onlynew" ), hasMetaData( "savetime" ) ); - - if( m_errorState ) - return; - - if( info.type() != UrlInfo::directory ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); - return; - } - - while( !mbox.atEnd() && !m_errorState ) - { - entry = Stat::stat( mbox, info ); - if( mbox.inListing() ) - listEntry( entry, false ); - } - - listEntry( TDEIO::UDSEntry(), true ); - finished(); -} - -void MBoxProtocol::stat( const KURL& url ) -{ - UrlInfo info( url ); - if( info.type() == UrlInfo::invalid ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, url.path() ); - return; - } else - { - statEntry( Stat::stat( info ) ); - } - finished(); -} - -void MBoxProtocol::mimetype( const KURL& url ) -{ - m_errorState = false; - - UrlInfo info( url ); - - if( m_errorState ) - return; - - if( info.type() == UrlInfo::invalid ) - error( TDEIO::ERR_DOES_NOT_EXIST, i18n( "Invalid URL" ) ); - else - mimeType( info.mimetype() ); - finished(); -} - -void MBoxProtocol::emitError( int errno, const TQString& arg ) -{ - m_errorState = true; - error( errno, arg ); -} - diff --git a/tdeioslave/mbox/mbox.cpp b/tdeioslave/mbox/mbox.cpp new file mode 100644 index 00000000..5742baff --- /dev/null +++ b/tdeioslave/mbox/mbox.cpp @@ -0,0 +1,168 @@ +/* + * This is a simple tdeioslave to handle mbox-files. + * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) + * + * 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 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 + */ +#include "mbox.h" + +#include "readmbox.h" +#include "stat.h" +#include "urlinfo.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "tdepimmacros.h" + +#include "mbox.h" + +extern "C" { KDE_EXPORT int kdemain(int argc, char* argv[]); } + +int kdemain( int argc, char * argv[] ) +{ + TDELocale::setMainCatalogue("tdelibs"); + TDEInstance instance("tdeio_mbox"); + (void) TDEGlobal::locale(); + + if (argc != 4) { + fprintf(stderr, "Usage: tdeio_mbox protocol " + "domain-socket1 domain-socket2\n"); + exit(-1); + } + + MBoxProtocol slave(argv[2], argv[3]); + slave.dispatchLoop(); + + return 0; +} + +MBoxProtocol::MBoxProtocol( const TQCString& arg1, const TQCString& arg2 ) + : TDEIO::SlaveBase( "mbox2", arg1, arg2 ), + m_errorState( true ) +{ + +} + +MBoxProtocol::~MBoxProtocol() +{ +} + +void MBoxProtocol::get( const KURL& url ) +{ + m_errorState = false; + + UrlInfo info( url, UrlInfo::message ); + TQString line; + TQByteArray ba_line; + + if( info.type() == UrlInfo::invalid && !m_errorState ) + { + error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); + return; + } + + ReadMBox mbox( &info, this ); + + while( !mbox.atEnd() && !m_errorState) + { + line = mbox.currentLine(); + line += '\n'; + ba_line = TQCString( line.utf8() ); + ba_line.truncate( ba_line.size() - 1 ); //Removing training '\0' + data( ba_line ); + mbox.nextLine(); + }; + + if( !m_errorState ) + { + data( TQByteArray() ); + finished(); + } +} + +void MBoxProtocol::listDir( const KURL& url ) +{ + m_errorState = false; + + TDEIO::UDSEntry entry; + UrlInfo info( url, UrlInfo::directory ); + ReadMBox mbox( &info, this, hasMetaData( "onlynew" ), hasMetaData( "savetime" ) ); + + if( m_errorState ) + return; + + if( info.type() != UrlInfo::directory ) + { + error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); + return; + } + + while( !mbox.atEnd() && !m_errorState ) + { + entry = Stat::stat( mbox, info ); + if( mbox.inListing() ) + listEntry( entry, false ); + } + + listEntry( TDEIO::UDSEntry(), true ); + finished(); +} + +void MBoxProtocol::stat( const KURL& url ) +{ + UrlInfo info( url ); + if( info.type() == UrlInfo::invalid ) + { + error( TDEIO::ERR_DOES_NOT_EXIST, url.path() ); + return; + } else + { + statEntry( Stat::stat( info ) ); + } + finished(); +} + +void MBoxProtocol::mimetype( const KURL& url ) +{ + m_errorState = false; + + UrlInfo info( url ); + + if( m_errorState ) + return; + + if( info.type() == UrlInfo::invalid ) + error( TDEIO::ERR_DOES_NOT_EXIST, i18n( "Invalid URL" ) ); + else + mimeType( info.mimetype() ); + finished(); +} + +void MBoxProtocol::emitError( int errno, const TQString& arg ) +{ + m_errorState = true; + error( errno, arg ); +} + diff --git a/tdeioslave/mbox/mboxfile.cc b/tdeioslave/mbox/mboxfile.cc deleted file mode 100644 index 7297457e..00000000 --- a/tdeioslave/mbox/mboxfile.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This is a simple tdeioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) - * - * 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 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 - */ -#include "mboxfile.h" - -#include - -MBoxFile::MBoxFile( const UrlInfo* info, MBoxProtocol* parent ) - : m_info( info ), - m_mbox( parent ) -{ - assert( m_info ); -} - -MBoxFile::~MBoxFile() -{ -} - -bool MBoxFile::lock() -{ - //Not implemented - return true; -} - -void MBoxFile::unlock() -{ - //Not implemented -} - - diff --git a/tdeioslave/mbox/mboxfile.cpp b/tdeioslave/mbox/mboxfile.cpp new file mode 100644 index 00000000..7297457e --- /dev/null +++ b/tdeioslave/mbox/mboxfile.cpp @@ -0,0 +1,45 @@ +/* + * This is a simple tdeioslave to handle mbox-files. + * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) + * + * 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 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 + */ +#include "mboxfile.h" + +#include + +MBoxFile::MBoxFile( const UrlInfo* info, MBoxProtocol* parent ) + : m_info( info ), + m_mbox( parent ) +{ + assert( m_info ); +} + +MBoxFile::~MBoxFile() +{ +} + +bool MBoxFile::lock() +{ + //Not implemented + return true; +} + +void MBoxFile::unlock() +{ + //Not implemented +} + + diff --git a/tdeioslave/mbox/readmbox.cc b/tdeioslave/mbox/readmbox.cc deleted file mode 100644 index 942f369e..00000000 --- a/tdeioslave/mbox/readmbox.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * This is a simple tdeioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) - * - * 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 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 - */ -#include - -#include "readmbox.h" - -#include "mbox.h" -#include "urlinfo.h" - -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#include - -ReadMBox::ReadMBox( const UrlInfo* info, MBoxProtocol* parent, bool onlynew, bool savetime ) - : MBoxFile( info, parent ), - m_file( 0 ), - m_stream( 0 ), - m_current_line( new TQString( TQString() ) ), - m_current_id( new TQString( TQString() ) ), - m_atend( true ), - m_prev_time( 0 ), - m_only_new( onlynew ), - m_savetime( savetime ), - m_status( false ), - m_prev_status( false ), - m_header( true ) - -{ - if( m_info->type() == UrlInfo::invalid ) - m_mbox->emitError( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); - - if( !open( savetime ) ) - m_mbox->emitError( TDEIO::ERR_CANNOT_OPEN_FOR_READING, info->url() ); - - if( m_info->type() == UrlInfo::message ) - if( !searchMessage( m_info->id() ) ) - m_mbox->emitError( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); -} - -ReadMBox::~ReadMBox() -{ - delete m_current_line; - close(); -} - -TQString ReadMBox::currentLine() const -{ - return *m_current_line; -} - -TQString ReadMBox::currentID() const -{ - return *m_current_id; -} - -bool ReadMBox::nextLine() -{ - if( !m_stream ) - return true; - - *m_current_line = m_stream->readLine(); - m_atend = m_current_line->isNull(); - if( m_atend ) // Cursor was at EOF - { - *m_current_id = TQString(); - m_prev_status = m_status; - return true; - } - - //New message - if( m_current_line->left( 5 ) == "From " ) - { - *m_current_id = *m_current_line; - m_prev_status = m_status; - m_status = true; - m_header = true; - return true; - } else if( m_only_new ) - { - if( m_header && m_current_line->left( 7 ) == "Status:" && - ! m_current_line->contains( "U" ) && ! m_current_line->contains( "N" ) ) - { - m_status = false; - } - } - - if( m_current_line->stripWhiteSpace().isEmpty() ) - m_header = false; - - return false; -} - -bool ReadMBox::searchMessage( const TQString& id ) -{ - if( !m_stream ) - return false; - - while( !m_atend && *m_current_id != id ) - nextLine(); - - return *m_current_id == id; -} - -unsigned int ReadMBox::skipMessage() -{ - unsigned int result = m_current_line->length(); - - if( !m_stream ) - return 0; - - while( !nextLine() ) - result += m_current_line->length(); - - return result; -} - -void ReadMBox::rewind() -{ - if( !m_stream ) - return; //Rewinding not possible - - m_stream->device()->reset(); - m_atend = m_stream->atEnd(); -} - -bool ReadMBox::atEnd() const -{ - if( !m_stream ) - return true; - - return m_atend || ( m_info->type() == UrlInfo::message && *m_current_id != m_info->id() ); -} - -bool ReadMBox::inListing() const -{ - return !m_only_new || m_prev_status; -} - -bool ReadMBox::open( bool savetime ) -{ - if( savetime ) - { - TQFileInfo info( m_info->filename() ); - - m_prev_time = new utimbuf; - m_prev_time->actime = info.lastRead().toTime_t(); - m_prev_time->modtime = info.lastModified().toTime_t(); - } - - if( m_file ) - return false; //File already open - - m_file = new TQFile( m_info->filename() ); - if( !m_file->open( IO_ReadOnly ) ) - { - delete m_file; - m_file = 0; - return false; - } - m_stream = new TQTextStream( m_file ); - skipMessage(); - - return true; -} - -void ReadMBox::close() -{ - if( !m_stream ) - return; - - delete m_stream; m_stream = 0; - m_file->close(); - delete m_file; m_file = 0; - - if( m_prev_time ) - utime( TQFile::encodeName( m_info->filename() ), m_prev_time ); -} - diff --git a/tdeioslave/mbox/readmbox.cpp b/tdeioslave/mbox/readmbox.cpp new file mode 100644 index 00000000..942f369e --- /dev/null +++ b/tdeioslave/mbox/readmbox.cpp @@ -0,0 +1,204 @@ +/* + * This is a simple tdeioslave to handle mbox-files. + * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) + * + * 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 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 + */ +#include + +#include "readmbox.h" + +#include "mbox.h" +#include "urlinfo.h" + +#include +#include + +#include +#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#include + +ReadMBox::ReadMBox( const UrlInfo* info, MBoxProtocol* parent, bool onlynew, bool savetime ) + : MBoxFile( info, parent ), + m_file( 0 ), + m_stream( 0 ), + m_current_line( new TQString( TQString() ) ), + m_current_id( new TQString( TQString() ) ), + m_atend( true ), + m_prev_time( 0 ), + m_only_new( onlynew ), + m_savetime( savetime ), + m_status( false ), + m_prev_status( false ), + m_header( true ) + +{ + if( m_info->type() == UrlInfo::invalid ) + m_mbox->emitError( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); + + if( !open( savetime ) ) + m_mbox->emitError( TDEIO::ERR_CANNOT_OPEN_FOR_READING, info->url() ); + + if( m_info->type() == UrlInfo::message ) + if( !searchMessage( m_info->id() ) ) + m_mbox->emitError( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); +} + +ReadMBox::~ReadMBox() +{ + delete m_current_line; + close(); +} + +TQString ReadMBox::currentLine() const +{ + return *m_current_line; +} + +TQString ReadMBox::currentID() const +{ + return *m_current_id; +} + +bool ReadMBox::nextLine() +{ + if( !m_stream ) + return true; + + *m_current_line = m_stream->readLine(); + m_atend = m_current_line->isNull(); + if( m_atend ) // Cursor was at EOF + { + *m_current_id = TQString(); + m_prev_status = m_status; + return true; + } + + //New message + if( m_current_line->left( 5 ) == "From " ) + { + *m_current_id = *m_current_line; + m_prev_status = m_status; + m_status = true; + m_header = true; + return true; + } else if( m_only_new ) + { + if( m_header && m_current_line->left( 7 ) == "Status:" && + ! m_current_line->contains( "U" ) && ! m_current_line->contains( "N" ) ) + { + m_status = false; + } + } + + if( m_current_line->stripWhiteSpace().isEmpty() ) + m_header = false; + + return false; +} + +bool ReadMBox::searchMessage( const TQString& id ) +{ + if( !m_stream ) + return false; + + while( !m_atend && *m_current_id != id ) + nextLine(); + + return *m_current_id == id; +} + +unsigned int ReadMBox::skipMessage() +{ + unsigned int result = m_current_line->length(); + + if( !m_stream ) + return 0; + + while( !nextLine() ) + result += m_current_line->length(); + + return result; +} + +void ReadMBox::rewind() +{ + if( !m_stream ) + return; //Rewinding not possible + + m_stream->device()->reset(); + m_atend = m_stream->atEnd(); +} + +bool ReadMBox::atEnd() const +{ + if( !m_stream ) + return true; + + return m_atend || ( m_info->type() == UrlInfo::message && *m_current_id != m_info->id() ); +} + +bool ReadMBox::inListing() const +{ + return !m_only_new || m_prev_status; +} + +bool ReadMBox::open( bool savetime ) +{ + if( savetime ) + { + TQFileInfo info( m_info->filename() ); + + m_prev_time = new utimbuf; + m_prev_time->actime = info.lastRead().toTime_t(); + m_prev_time->modtime = info.lastModified().toTime_t(); + } + + if( m_file ) + return false; //File already open + + m_file = new TQFile( m_info->filename() ); + if( !m_file->open( IO_ReadOnly ) ) + { + delete m_file; + m_file = 0; + return false; + } + m_stream = new TQTextStream( m_file ); + skipMessage(); + + return true; +} + +void ReadMBox::close() +{ + if( !m_stream ) + return; + + delete m_stream; m_stream = 0; + m_file->close(); + delete m_file; m_file = 0; + + if( m_prev_time ) + utime( TQFile::encodeName( m_info->filename() ), m_prev_time ); +} + diff --git a/tdeioslave/mbox/stat.cc b/tdeioslave/mbox/stat.cc deleted file mode 100644 index 99267ca7..00000000 --- a/tdeioslave/mbox/stat.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This is a simple tdeioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) - * - * 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 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 - */ -#include "stat.h" - -#include "readmbox.h" -#include "urlinfo.h" - -#include -#include - -#include - -TDEIO::UDSEntry Stat::stat( const UrlInfo& info ) -{ - if( info.type() == UrlInfo::message ) - return Stat::statMessage( info ); - else if( info.type() == UrlInfo::directory ) - return Stat::statDirectory( info ); - else - return TDEIO::UDSEntry(); -} - -TDEIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info ) -{ - kdDebug() << "Stat::stat()" << endl; - TDEIO::UDSEntry entry; - TQString url; - - if( info.type() == UrlInfo::invalid ) - return entry; - else if( info.type() == UrlInfo::message ) - mbox.searchMessage( info.id() ); - - Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG ); - Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" ); - - url = TQString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() ); - Stat::addAtom( entry, TDEIO::UDS_URL, url ); - if( mbox.currentID().isEmpty() ) - Stat::addAtom( entry, TDEIO::UDS_NAME, "foobar" ); - else - Stat::addAtom( entry, TDEIO::UDS_NAME, mbox.currentID() ); - - - Stat::addAtom( entry, TDEIO::UDS_SIZE, mbox.skipMessage() ); - - return entry; -} - -TDEIO::UDSEntry Stat::statDirectory( const UrlInfo& info ) -{ - kdDebug() << "statDirectory()" << endl; - TDEIO::UDSEntry entry; - - //Specific things for a directory - Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFDIR ); - Stat::addAtom( entry, TDEIO::UDS_NAME, info.filename() ); - - return entry; -} - -TDEIO::UDSEntry Stat::statMessage( const UrlInfo& info ) -{ - kdDebug() << "statMessage( " << info.url() << " )" << endl; - TDEIO::UDSEntry entry; - TQString url = TQString( "mbox:%1" ).arg( info.url() ); - - //Specific things for a message - Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG ); - Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" ); - - Stat::addAtom( entry, TDEIO::UDS_URL, url ); - url = url.right( url.length() - url.findRev( "/" ) - 1 ); - Stat::addAtom( entry, TDEIO::UDS_NAME, url ); - - return entry; -} - -void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, const TQString& str ) -{ - TDEIO::UDSAtom atom; - atom.m_uds = uds; - atom.m_str = str; - atom.m_long = 0; - - entry.append( atom ); -} - - -void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, long lng ) -{ - TDEIO::UDSAtom atom; - atom.m_uds = uds; - atom.m_str = TQString(); - atom.m_long = lng; - - entry.append( atom ); -} - diff --git a/tdeioslave/mbox/stat.cpp b/tdeioslave/mbox/stat.cpp new file mode 100644 index 00000000..99267ca7 --- /dev/null +++ b/tdeioslave/mbox/stat.cpp @@ -0,0 +1,115 @@ +/* + * This is a simple tdeioslave to handle mbox-files. + * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) + * + * 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 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 + */ +#include "stat.h" + +#include "readmbox.h" +#include "urlinfo.h" + +#include +#include + +#include + +TDEIO::UDSEntry Stat::stat( const UrlInfo& info ) +{ + if( info.type() == UrlInfo::message ) + return Stat::statMessage( info ); + else if( info.type() == UrlInfo::directory ) + return Stat::statDirectory( info ); + else + return TDEIO::UDSEntry(); +} + +TDEIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info ) +{ + kdDebug() << "Stat::stat()" << endl; + TDEIO::UDSEntry entry; + TQString url; + + if( info.type() == UrlInfo::invalid ) + return entry; + else if( info.type() == UrlInfo::message ) + mbox.searchMessage( info.id() ); + + Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG ); + Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" ); + + url = TQString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() ); + Stat::addAtom( entry, TDEIO::UDS_URL, url ); + if( mbox.currentID().isEmpty() ) + Stat::addAtom( entry, TDEIO::UDS_NAME, "foobar" ); + else + Stat::addAtom( entry, TDEIO::UDS_NAME, mbox.currentID() ); + + + Stat::addAtom( entry, TDEIO::UDS_SIZE, mbox.skipMessage() ); + + return entry; +} + +TDEIO::UDSEntry Stat::statDirectory( const UrlInfo& info ) +{ + kdDebug() << "statDirectory()" << endl; + TDEIO::UDSEntry entry; + + //Specific things for a directory + Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFDIR ); + Stat::addAtom( entry, TDEIO::UDS_NAME, info.filename() ); + + return entry; +} + +TDEIO::UDSEntry Stat::statMessage( const UrlInfo& info ) +{ + kdDebug() << "statMessage( " << info.url() << " )" << endl; + TDEIO::UDSEntry entry; + TQString url = TQString( "mbox:%1" ).arg( info.url() ); + + //Specific things for a message + Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG ); + Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" ); + + Stat::addAtom( entry, TDEIO::UDS_URL, url ); + url = url.right( url.length() - url.findRev( "/" ) - 1 ); + Stat::addAtom( entry, TDEIO::UDS_NAME, url ); + + return entry; +} + +void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, const TQString& str ) +{ + TDEIO::UDSAtom atom; + atom.m_uds = uds; + atom.m_str = str; + atom.m_long = 0; + + entry.append( atom ); +} + + +void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, long lng ) +{ + TDEIO::UDSAtom atom; + atom.m_uds = uds; + atom.m_str = TQString(); + atom.m_long = lng; + + entry.append( atom ); +} + diff --git a/tdeioslave/mbox/urlinfo.cc b/tdeioslave/mbox/urlinfo.cc deleted file mode 100644 index 4b359e40..00000000 --- a/tdeioslave/mbox/urlinfo.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This is a simple tdeioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) - * - * 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 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 - */ -#include "urlinfo.h" - -#include -#include - -#include -#include - -UrlInfo::UrlInfo( const KURL& url, const UrlType type ) - : m_type( invalid ), - m_filename( new TQString ), - m_id( new TQString ) -{ - calculateInfo( url, type ); -} - -UrlInfo::~UrlInfo() -{ - delete m_filename; - delete m_id; -} - -TQString UrlInfo::mimetype() const -{ - switch( m_type ) - { - case message: - return "message/rfc822"; - case directory: - return "inode/directory"; - case invalid: - default: - return "invalid"; - } -} - -TQString UrlInfo::filename() const -{ - return *m_filename; -} - -TQString UrlInfo::id() const -{ - return *m_id; -} - -TQString UrlInfo::url() const -{ - return *m_filename + "/" + *m_id; -} - - -void UrlInfo::calculateInfo( const KURL& url, const UrlType type ) -{ - bool found = false; - - if( !found && type & UrlInfo::message ) - found = isMessage( url ); - if( !found && type & UrlInfo::directory ) - found = isDirectory( url ); - if( !found ) - { - m_type = invalid; - *m_filename = ""; - *m_id = ""; - } -} - -bool UrlInfo::isDirectory( const KURL& url ) -{ - //Check is url is in the form mbox://{filename} - TQString filename = url.path(); - TQFileInfo info; - - //Remove ending / - while( filename.length() > 1 && filename.right( 1 ) == "/" ) - filename.remove( filename.length()-2, 1 ); - - //Is this a directory? - info.setFile( filename ); - if( !info.isFile() ) - return false; - - //Setting paramaters - *m_filename = filename; - *m_id = TQString(); - m_type = directory; - kdDebug() << "urlInfo::isDirectory( " << url << " )" << endl; - return true; -} - -bool UrlInfo::isMessage( const KURL& url ) -{ - TQString path = url.path(); - TQFileInfo info; - int cutindex = path.findRev( '/' ); - - //Does it contain at least one /? - if( cutindex < 0 ) - return false; - - //Does the mbox-file exists? - info.setFile( path.left( cutindex ) ); - if( !info.isFile() ) - return false; - - //Settings parameters - kdDebug() << "urlInfo::isMessage( " << url << " )" << endl; - m_type = message; - *m_id = path.right( path.length() - cutindex - 1 ); - *m_filename = path.left( cutindex ); - - return true; -} - diff --git a/tdeioslave/mbox/urlinfo.cpp b/tdeioslave/mbox/urlinfo.cpp new file mode 100644 index 00000000..4b359e40 --- /dev/null +++ b/tdeioslave/mbox/urlinfo.cpp @@ -0,0 +1,133 @@ +/* + * This is a simple tdeioslave to handle mbox-files. + * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) + * + * 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 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 + */ +#include "urlinfo.h" + +#include +#include + +#include +#include + +UrlInfo::UrlInfo( const KURL& url, const UrlType type ) + : m_type( invalid ), + m_filename( new TQString ), + m_id( new TQString ) +{ + calculateInfo( url, type ); +} + +UrlInfo::~UrlInfo() +{ + delete m_filename; + delete m_id; +} + +TQString UrlInfo::mimetype() const +{ + switch( m_type ) + { + case message: + return "message/rfc822"; + case directory: + return "inode/directory"; + case invalid: + default: + return "invalid"; + } +} + +TQString UrlInfo::filename() const +{ + return *m_filename; +} + +TQString UrlInfo::id() const +{ + return *m_id; +} + +TQString UrlInfo::url() const +{ + return *m_filename + "/" + *m_id; +} + + +void UrlInfo::calculateInfo( const KURL& url, const UrlType type ) +{ + bool found = false; + + if( !found && type & UrlInfo::message ) + found = isMessage( url ); + if( !found && type & UrlInfo::directory ) + found = isDirectory( url ); + if( !found ) + { + m_type = invalid; + *m_filename = ""; + *m_id = ""; + } +} + +bool UrlInfo::isDirectory( const KURL& url ) +{ + //Check is url is in the form mbox://{filename} + TQString filename = url.path(); + TQFileInfo info; + + //Remove ending / + while( filename.length() > 1 && filename.right( 1 ) == "/" ) + filename.remove( filename.length()-2, 1 ); + + //Is this a directory? + info.setFile( filename ); + if( !info.isFile() ) + return false; + + //Setting paramaters + *m_filename = filename; + *m_id = TQString(); + m_type = directory; + kdDebug() << "urlInfo::isDirectory( " << url << " )" << endl; + return true; +} + +bool UrlInfo::isMessage( const KURL& url ) +{ + TQString path = url.path(); + TQFileInfo info; + int cutindex = path.findRev( '/' ); + + //Does it contain at least one /? + if( cutindex < 0 ) + return false; + + //Does the mbox-file exists? + info.setFile( path.left( cutindex ) ); + if( !info.isFile() ) + return false; + + //Settings parameters + kdDebug() << "urlInfo::isMessage( " << url << " )" << endl; + m_type = message; + *m_id = path.right( path.length() - cutindex - 1 ); + *m_filename = path.left( cutindex ); + + return true; +} + diff --git a/tderesources/groupwise/soap/ksslsocket.cpp b/tderesources/groupwise/soap/ksslsocket.cpp index 6bf74da5..2f085cf2 100644 --- a/tderesources/groupwise/soap/ksslsocket.cpp +++ b/tderesources/groupwise/soap/ksslsocket.cpp @@ -161,7 +161,7 @@ TQString KSSLSocket::metaData( const TQString &key ) } /* -I basically copied the below from tcpTDEIO::SlaveBase.hpp, with some modificaions and formatting. +I basically copied the below from tcpTDEIO::SlaveBase.h, with some modificaions and formatting. * Copyright (C) 2000 Alex Zepeda diff --git a/tderesources/tvanytime/tvanytime.tdevelop b/tderesources/tvanytime/tvanytime.tdevelop index 4359032f..479d2f50 100644 --- a/tderesources/tvanytime/tvanytime.tdevelop +++ b/tderesources/tvanytime/tvanytime.tdevelop @@ -67,7 +67,7 @@ - + -- cgit v1.2.3