diff options
Diffstat (limited to 'kmailcvt')
-rw-r--r-- | kmailcvt/Makefile.am | 5 | ||||
-rw-r--r-- | kmailcvt/filter_evolution.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_evolution_v2.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_kmail_archive.cxx | 35 | ||||
-rw-r--r-- | kmailcvt/filter_kmail_archive.hxx | 32 | ||||
-rw-r--r-- | kmailcvt/filter_kmail_maildir.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_lnotes.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_mailapp.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_mbox.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_oe.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_opera.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_outlook.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_plain.cxx | 1 | ||||
-rw-r--r-- | kmailcvt/filter_pmail.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_sylpheed.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_thebat.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filter_thunderbird.cxx | 2 | ||||
-rw-r--r-- | kmailcvt/filters.cxx | 27 | ||||
-rw-r--r-- | kmailcvt/filters.hxx | 10 | ||||
-rw-r--r-- | kmailcvt/kmailcvt.cpp | 60 | ||||
-rw-r--r-- | kmailcvt/kmailcvt.h | 3 | ||||
-rw-r--r-- | kmailcvt/kselfilterpage.cpp | 4 | ||||
-rw-r--r-- | kmailcvt/main.cpp | 6 |
23 files changed, 150 insertions, 53 deletions
diff --git a/kmailcvt/Makefile.am b/kmailcvt/Makefile.am index 2ae9b9169..b5e48e83c 100644 --- a/kmailcvt/Makefile.am +++ b/kmailcvt/Makefile.am @@ -6,7 +6,7 @@ kmailcvt_SOURCES = kimportpagedlg.ui kimportpage.cpp kselfilterpagedlg.ui \ 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_lnotes.cxx filter_kmail_archive.cxx kmailcvt_LDADD = $(LIB_KFILE) @@ -25,7 +25,8 @@ EXTRA_DIST = main.cpp kmailcvt.cpp kimportpage.cpp kimportpage.h \ 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_thebat.hxx filter_thebat.cxx filter_lnotes.hxx filter_lnotes.cxx \ + filter_kmail_archive.cxx fitler_kmail_archive.hxx install-data-local: uninstall.desktop $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Utilities diff --git a/kmailcvt/filter_evolution.cxx b/kmailcvt/filter_evolution.cxx index abc602a21..a07a6f084 100644 --- a/kmailcvt/filter_evolution.cxx +++ b/kmailcvt/filter_evolution.cxx @@ -39,7 +39,6 @@ FilterEvolution::FilterEvolution(void) : /** Destructor. */ FilterEvolution::~FilterEvolution(void) { - endImport(); } /** Recursive import of Evolution's mboxes. */ diff --git a/kmailcvt/filter_evolution_v2.cxx b/kmailcvt/filter_evolution_v2.cxx index 16c3093a6..dd69ee7b5 100644 --- a/kmailcvt/filter_evolution_v2.cxx +++ b/kmailcvt/filter_evolution_v2.cxx @@ -39,7 +39,6 @@ FilterEvolution_v2::FilterEvolution_v2(void) : /** Destructor. */ FilterEvolution_v2::~FilterEvolution_v2(void) { - endImport(); } /** Recursive import of Evolution's mboxes. */ @@ -61,6 +60,7 @@ void FilterEvolution_v2::import(FilterInfo *info) kfd->setMode(KFile::Directory | KFile::LocalOnly); kfd->exec(); mailDir = kfd->selectedFile(); + delete kfd; if (mailDir.isEmpty()) { info->alert(i18n("No directory selected.")); diff --git a/kmailcvt/filter_kmail_archive.cxx b/kmailcvt/filter_kmail_archive.cxx new file mode 100644 index 000000000..2fca99bdc --- /dev/null +++ b/kmailcvt/filter_kmail_archive.cxx @@ -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 <http://www.gnu.org/licenses/>. +*/ +#include "filter_kmail_archive.hxx" + +#include <klocale.h> + +FilterKMailArchive::FilterKMailArchive() + : Filter( i18n( "Import KMail Archive File" ), + "Klar\xE4lvdalens Datakonsult AB", + i18n( "<p><b>KMail Archive File Import Filter</b></p>" + "<p>This filter will import archives files previously exported by KMail.</p>" + "<p>Archive files contain a complete folder subtree compressed into a single file.</p>" ) ) +{ +} + +void FilterKMailArchive::import( FilterInfo *info ) +{ + showKMailImportArchiveDialog( info ); +} diff --git a/kmailcvt/filter_kmail_archive.hxx b/kmailcvt/filter_kmail_archive.hxx new file mode 100644 index 000000000..755d3cc28 --- /dev/null +++ b/kmailcvt/filter_kmail_archive.hxx @@ -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 <http://www.gnu.org/licenses/>. +*/ +#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.cxx b/kmailcvt/filter_kmail_maildir.cxx index 5ea7d4fc7..2a1961567 100644 --- a/kmailcvt/filter_kmail_maildir.cxx +++ b/kmailcvt/filter_kmail_maildir.cxx @@ -38,7 +38,6 @@ FilterKMail_maildir::FilterKMail_maildir( void ) : /** Destructor. */ FilterKMail_maildir::~FilterKMail_maildir( void ) { - endImport(); } /** Recursive import of KMail maildir. */ @@ -52,6 +51,7 @@ void FilterKMail_maildir::import( FilterInfo *info ) kfd->setMode( KFile::Directory | KFile::LocalOnly ); kfd->exec(); mailDir = kfd->selectedFile(); + delete kfd; if ( mailDir.isEmpty() ) { info->alert( i18n( "No directory selected." ) ); diff --git a/kmailcvt/filter_lnotes.cxx b/kmailcvt/filter_lnotes.cxx index 69a48167a..4bd3c423f 100644 --- a/kmailcvt/filter_lnotes.cxx +++ b/kmailcvt/filter_lnotes.cxx @@ -40,7 +40,6 @@ FilterLNotes::FilterLNotes() : /** Destructor. */ FilterLNotes::~FilterLNotes() { - endImport(); } /** diff --git a/kmailcvt/filter_mailapp.cxx b/kmailcvt/filter_mailapp.cxx index 2121badb0..901fa6982 100644 --- a/kmailcvt/filter_mailapp.cxx +++ b/kmailcvt/filter_mailapp.cxx @@ -37,7 +37,6 @@ FilterMailApp::FilterMailApp() : FilterMailApp::~FilterMailApp() { - endImport(); } void FilterMailApp::import(FilterInfo *info) diff --git a/kmailcvt/filter_mbox.cxx b/kmailcvt/filter_mbox.cxx index 3777cd7e9..76b376683 100644 --- a/kmailcvt/filter_mbox.cxx +++ b/kmailcvt/filter_mbox.cxx @@ -37,7 +37,6 @@ FilterMBox::FilterMBox() : FilterMBox::~FilterMBox() { - endImport(); } void FilterMBox::import(FilterInfo *info) diff --git a/kmailcvt/filter_oe.cxx b/kmailcvt/filter_oe.cxx index e1465d141..bde399b62 100644 --- a/kmailcvt/filter_oe.cxx +++ b/kmailcvt/filter_oe.cxx @@ -50,7 +50,6 @@ FilterOE::FilterOE() : FilterOE::~FilterOE() { - endImport(); } void FilterOE::import(FilterInfo *info) diff --git a/kmailcvt/filter_opera.cxx b/kmailcvt/filter_opera.cxx index 3b2fff176..65e2eae4b 100644 --- a/kmailcvt/filter_opera.cxx +++ b/kmailcvt/filter_opera.cxx @@ -37,7 +37,6 @@ FilterOpera::FilterOpera() : FilterOpera::~FilterOpera() { - endImport(); } void FilterOpera::import(FilterInfo *info) @@ -55,6 +54,7 @@ void FilterOpera::import(FilterInfo *info) kfd->setMode(KFile::Directory | KFile::LocalOnly); kfd->exec(); TQString operaDir = kfd->selectedFile(); + delete kfd; if (operaDir.isEmpty()) { info->alert(i18n("No directory selected.")); diff --git a/kmailcvt/filter_outlook.cxx b/kmailcvt/filter_outlook.cxx index 0dad8fde7..a5a9f407c 100644 --- a/kmailcvt/filter_outlook.cxx +++ b/kmailcvt/filter_outlook.cxx @@ -37,7 +37,6 @@ FilterOutlook::FilterOutlook() : FilterOutlook::~FilterOutlook() { - endImport(); } void FilterOutlook::import(FilterInfo *info) diff --git a/kmailcvt/filter_plain.cxx b/kmailcvt/filter_plain.cxx index 0246c8c63..04abea3d3 100644 --- a/kmailcvt/filter_plain.cxx +++ b/kmailcvt/filter_plain.cxx @@ -34,7 +34,6 @@ FilterPlain::FilterPlain() : FilterPlain::~FilterPlain() { - endImport(); } void FilterPlain::import(FilterInfo *info) diff --git a/kmailcvt/filter_pmail.cxx b/kmailcvt/filter_pmail.cxx index 5fcc1256e..23617f912 100644 --- a/kmailcvt/filter_pmail.cxx +++ b/kmailcvt/filter_pmail.cxx @@ -38,7 +38,6 @@ FilterPMail::FilterPMail() : FilterPMail::~FilterPMail() { - endImport(); } void FilterPMail::import(FilterInfo *info) @@ -51,6 +50,7 @@ void FilterPMail::import(FilterInfo *info) kfd->setMode(KFile::Directory | KFile::LocalOnly); kfd->exec(); chosenDir = kfd->selectedFile(); + delete kfd; if (chosenDir.isEmpty()) { info->alert(i18n("No directory selected.")); diff --git a/kmailcvt/filter_sylpheed.cxx b/kmailcvt/filter_sylpheed.cxx index fcf53f74a..489083f04 100644 --- a/kmailcvt/filter_sylpheed.cxx +++ b/kmailcvt/filter_sylpheed.cxx @@ -37,7 +37,6 @@ FilterSylpheed::FilterSylpheed( void ) : /** Destructor. */ FilterSylpheed::~FilterSylpheed( void ) { - endImport(); } /** Recursive import of Sylpheed maildir. */ @@ -51,6 +50,7 @@ void FilterSylpheed::import( FilterInfo *info ) kfd->setMode( KFile::Directory | KFile::LocalOnly ); kfd->exec(); mailDir = kfd->selectedFile(); + delete kfd; if ( mailDir.isEmpty() ) { info->alert( i18n( "No directory selected." ) ); diff --git a/kmailcvt/filter_thebat.cxx b/kmailcvt/filter_thebat.cxx index fa00b915d..de6e5c6b3 100644 --- a/kmailcvt/filter_thebat.cxx +++ b/kmailcvt/filter_thebat.cxx @@ -44,7 +44,6 @@ FilterTheBat::FilterTheBat( void ) : /** Destructor. */ FilterTheBat::~FilterTheBat( void ) { - endImport(); } /** Recursive import of The Bat! maildir. */ @@ -57,6 +56,7 @@ void FilterTheBat::import( FilterInfo *info ) kfd->setMode( KFile::Directory | KFile::LocalOnly ); kfd->exec(); mailDir = kfd->selectedFile(); + delete kfd; if ( mailDir.isEmpty() ) { info->alert( i18n( "No directory selected." ) ); diff --git a/kmailcvt/filter_thunderbird.cxx b/kmailcvt/filter_thunderbird.cxx index a9e091d9b..6ada68098 100644 --- a/kmailcvt/filter_thunderbird.cxx +++ b/kmailcvt/filter_thunderbird.cxx @@ -39,7 +39,6 @@ FilterThunderbird::FilterThunderbird(void) : /** Destructor. */ FilterThunderbird::~FilterThunderbird(void) { - endImport(); } /** Recursive import of Evolution's mboxes. */ @@ -60,6 +59,7 @@ void FilterThunderbird::import(FilterInfo *info) kfd->setMode(KFile::Directory | KFile::LocalOnly); kfd->exec(); mailDir = kfd->selectedFile(); + delete kfd; if (mailDir.isEmpty()) { info->alert(i18n("No directory selected.")); diff --git a/kmailcvt/filters.cxx b/kmailcvt/filters.cxx index 5e163e191..56e69d371 100644 --- a/kmailcvt/filters.cxx +++ b/kmailcvt/filters.cxx @@ -134,12 +134,12 @@ bool Filter::addMessage( FilterInfo* info, const TQString& folderName, { KURL msgURL; msgURL.setPath( msgPath ); - + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) KApplication::startServiceByDesktopName( "kmail", TQString::null ); // Will wait until kmail is started DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", folderName, msgURL, msgStatusFlags ); - + if ( !reply.isValid() ) { info->alert( i18n( "<b>Fatal:</b> Unable to start KMail for DCOP communication. " @@ -170,7 +170,7 @@ bool Filter::addMessage_fastImport( FilterInfo* info, const TQString& folderName { KURL msgURL; msgURL.setPath( msgPath ); - + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) KApplication::startServiceByDesktopName( "kmail", TQString::null ); // Will wait until kmail is started @@ -197,17 +197,22 @@ bool Filter::addMessage_fastImport( FilterInfo* info, const TQString& folderName return true; } -bool Filter::endImport() +void Filter::showKMailImportArchiveDialog( FilterInfo* info ) { - if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) KApplication::startServiceByDesktopName( "kmail", TQString::null ); // Will wait until kmail is started - DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", TQString::null, TQString::null); - if ( !reply.isValid() ) return false; - - reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopResetAddMessage" ); - if ( !reply.isValid() ) return false; + DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "showImportArchiveDialog" ); + if ( !reply.isValid() ) + { + info->alert( i18n( "<b>Fatal:</b> Unable to start KMail for DCOP communication. " + "Make sure <i>kmail</i> is installed." ) ); + } +} - return true; +bool Filter::needsSecondPage() +{ + return true; } + // vim: ts=2 sw=2 et diff --git a/kmailcvt/filters.hxx b/kmailcvt/filters.hxx index 203f3d7bb..dc51f8c94 100644 --- a/kmailcvt/filters.hxx +++ b/kmailcvt/filters.hxx @@ -67,10 +67,13 @@ class Filter 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, @@ -79,7 +82,6 @@ class Filter const TQString& folder, const TQString& msgFile, const TQString& msgStatusFlags = TQString()); - bool endImport(); private: TQString m_name; TQString m_author; @@ -112,7 +114,7 @@ public: for(unsigned int i=0; i<size; i++) d[i]=s[i]; } ; - /** Assignment operator. Does the same thing as + /** Assignment operator. Does the same thing as * the copy constructor. */ FolderStructureBase &operator =(const FolderStructureBase &s) diff --git a/kmailcvt/kmailcvt.cpp b/kmailcvt/kmailcvt.cpp index 08dabe830..d56577f4d 100644 --- a/kmailcvt/kmailcvt.cpp +++ b/kmailcvt/kmailcvt.cpp @@ -17,7 +17,9 @@ #include "kmailcvt.h" #include <kaboutapplication.h> #include <tqpushbutton.h> - +#include <dcopclient.h> +#include <dcopref.h> +#include <kdebug.h> #include "filters.hxx" KMailCVT::KMailCVT(TQWidget *parent, const char *name) @@ -34,6 +36,19 @@ KMailCVT::KMailCVT(TQWidget *parent, const char *name) } KMailCVT::~KMailCVT() { + endImport(); +} + +void KMailCVT::endImport() { + if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) ) + KApplication::startServiceByDesktopName( "kmail", TQString::null ); // Will wait until kmail is started + + DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", TQString::null, TQString::null, TQString::null); + if ( !reply.isValid() ) + return; + reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopResetAddMessage" ); + if ( !reply.isValid() ) + return; } void KMailCVT::next() { @@ -41,24 +56,33 @@ void KMailCVT::next() { // Save selected filter Filter *selectedFilter = selfilterpage->getSelectedFilter(); // without filter don't go next - if (!selectedFilter) + if ( !selectedFilter ) return; - // Goto next page - KWizard::next(); - // Disable back & finish - setBackEnabled( currentPage(), false ); - setFinishEnabled( currentPage(), false ); - // Start import - FilterInfo *info = new FilterInfo(importpage, this, selfilterpage->removeDupMsg_checked()); - info->setStatusMsg(i18n("Import in progress")); - info->clear(); // Clear info from last time - selectedFilter->import(info); - info->setStatusMsg(i18n("Import finished")); - // Cleanup - delete info; - // Enable finish & back buttons - setFinishEnabled( currentPage(), true ); - setBackEnabled( currentPage(), true ); + + if ( !selectedFilter->needsSecondPage() ) { + FilterInfo *info = new FilterInfo( importpage, this, selfilterpage->removeDupMsg_checked() ); + selectedFilter->import( info ); + accept(); + delete info; + } + else { + // Goto next page + KWizard::next(); + // Disable back & finish + setBackEnabled( currentPage(), false ); + setFinishEnabled( currentPage(), false ); + // Start import + FilterInfo *info = new FilterInfo(importpage, this, selfilterpage->removeDupMsg_checked()); + info->setStatusMsg(i18n("Import in progress")); + info->clear(); // Clear info from last time + selectedFilter->import(info); + info->setStatusMsg(i18n("Import finished")); + // Cleanup + delete info; + // Enable finish & back buttons + setFinishEnabled( currentPage(), true ); + setBackEnabled( currentPage(), true ); + } } else KWizard::next(); } diff --git a/kmailcvt/kmailcvt.h b/kmailcvt/kmailcvt.h index b4ff16ac5..34907bcc8 100644 --- a/kmailcvt/kmailcvt.h +++ b/kmailcvt/kmailcvt.h @@ -23,7 +23,7 @@ #include "kimportpage.h" #include "kselfilterpage.h" - + /** KMailCVT is the base class of the project */ class KMailCVT : public KWizard { Q_OBJECT @@ -36,6 +36,7 @@ public: public slots: void help(); private: + void endImport(); KSelFilterPage* selfilterpage; KImportPage* importpage; }; diff --git a/kmailcvt/kselfilterpage.cpp b/kmailcvt/kselfilterpage.cpp index a3f1a9b9d..b8af0d0b3 100644 --- a/kmailcvt/kselfilterpage.cpp +++ b/kmailcvt/kselfilterpage.cpp @@ -32,6 +32,7 @@ #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" @@ -49,6 +50,8 @@ KSelFilterPage::KSelFilterPage(TQWidget *parent, const char *name ) : KSelFilter // For now, we have to live without the warm and fuzzy feeling a refactoring might give. // Patches appreciated. (danimo) + addFilter(new FilterKMailArchive); + addFilter(new FilterMBox); addFilter(new FilterEvolution); addFilter(new FilterEvolution_v2); addFilter(new FilterKMail_maildir); @@ -60,7 +63,6 @@ KSelFilterPage::KSelFilterPage(TQWidget *parent, const char *name ) : KSelFilter addFilter(new FilterOE); // addFilter(new FilterOutlook); addFilter(new FilterPMail); - addFilter(new FilterMBox); addFilter(new FilterLNotes); addFilter(new FilterPlain); } diff --git a/kmailcvt/main.cpp b/kmailcvt/main.cpp index aea1edde5..87ab0c819 100644 --- a/kmailcvt/main.cpp +++ b/kmailcvt/main.cpp @@ -48,8 +48,10 @@ int main(int argc, char *argv[]) DCOPClient *client=a.dcopClient(); if (!client->attach()) { + delete kmailcvt; return 1; } - - return a.exec(); + int ret = a.exec(); + delete kmailcvt; + return ret; } |