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) --- kmailcvt/filters.cpp | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 kmailcvt/filters.cpp (limited to 'kmailcvt/filters.cpp') 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; +} -- cgit v1.2.3