You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
217 lines
6.2 KiB
217 lines
6.2 KiB
15 years ago
|
/***************************************************************************
|
||
4 years ago
|
filters.cpp - description
|
||
15 years ago
|
-------------------
|
||
|
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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <dcopclient.h>
|
||
|
#include <dcopref.h>
|
||
|
#include <kurl.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
4 years ago
|
#include "filters.h"
|
||
15 years ago
|
#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;
|
||
|
|
||
13 years ago
|
FilterInfo::FilterInfo( KImportPageDlg* dlg, TQWidget* parent , bool _removeDupMsg)
|
||
15 years ago
|
: m_dlg( dlg ),
|
||
13 years ago
|
m_parent( parent )
|
||
15 years ago
|
{
|
||
|
removeDupMsg = _removeDupMsg;
|
||
|
s_terminateASAP = false;
|
||
|
}
|
||
|
|
||
|
FilterInfo::~FilterInfo()
|
||
|
{
|
||
|
}
|
||
|
|
||
13 years ago
|
void FilterInfo::setStatusMsg( const TQString& status )
|
||
15 years ago
|
{
|
||
13 years ago
|
m_dlg->_texStatus->setText( status );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void FilterInfo::setFrom( const TQString& from )
|
||
15 years ago
|
{
|
||
|
m_dlg->_from->setText( from );
|
||
|
}
|
||
|
|
||
14 years ago
|
void FilterInfo::setTo( const TQString& to )
|
||
15 years ago
|
{
|
||
|
m_dlg->_to->setText( to );
|
||
|
}
|
||
|
|
||
14 years ago
|
void FilterInfo::setCurrent( const TQString& current )
|
||
15 years ago
|
{
|
||
|
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 );
|
||
|
}
|
||
|
|
||
14 years ago
|
void FilterInfo::addLog( const TQString& log )
|
||
15 years ago
|
{
|
||
|
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();
|
||
14 years ago
|
setCurrent( TQString() );
|
||
|
setFrom( TQString() );
|
||
|
setTo( TQString() );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void FilterInfo::alert( const TQString& message )
|
||
15 years ago
|
{
|
||
13 years ago
|
KMessageBox::information( m_parent, message );
|
||
15 years ago
|
}
|
||
|
|
||
|
void FilterInfo::terminateASAP()
|
||
|
{
|
||
|
s_terminateASAP = true;
|
||
|
}
|
||
|
|
||
|
bool FilterInfo::shouldTerminate()
|
||
|
{
|
||
|
return s_terminateASAP;
|
||
|
}
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//
|
||
|
// The generic filter class
|
||
|
//
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
|
||
14 years ago
|
Filter::Filter( const TQString& name, const TQString& author,
|
||
|
const TQString& info )
|
||
15 years ago
|
: m_name( name ),
|
||
|
m_author( author ),
|
||
|
m_info( info )
|
||
|
{
|
||
|
//public
|
||
|
count_duplicates = 0;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool Filter::addMessage( FilterInfo* info, const TQString& folderName,
|
||
|
const TQString& msgPath, const TQString & msgStatusFlags)
|
||
15 years ago
|
{
|
||
|
KURL msgURL;
|
||
|
msgURL.setPath( msgPath );
|
||
14 years ago
|
|
||
15 years ago
|
if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
|
||
12 years ago
|
TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started
|
||
15 years ago
|
|
||
|
DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", folderName, msgURL, msgStatusFlags );
|
||
14 years ago
|
|
||
15 years ago
|
if ( !reply.isValid() )
|
||
|
{
|
||
|
info->alert( i18n( "<b>Fatal:</b> Unable to start KMail for DCOP communication. "
|
||
|
"Make sure <i>kmail</i> is installed." ) );
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
switch ( int( reply ) )
|
||
|
{
|
||
|
case -1:
|
||
13 years ago
|
info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
case -2:
|
||
13 years ago
|
info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
case -4:
|
||
|
count_duplicates++;
|
||
|
return false;
|
||
|
case 0:
|
||
13 years ago
|
info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool Filter::addMessage_fastImport( FilterInfo* info, const TQString& folderName,
|
||
|
const TQString& msgPath, const TQString& msgStatusFlags )
|
||
15 years ago
|
{
|
||
|
KURL msgURL;
|
||
|
msgURL.setPath( msgPath );
|
||
14 years ago
|
|
||
15 years ago
|
if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
|
||
12 years ago
|
TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started
|
||
15 years ago
|
|
||
|
DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage_fastImport", folderName, msgURL, msgStatusFlags );
|
||
|
if ( !reply.isValid() )
|
||
|
{
|
||
|
info->alert( i18n( "<b>Fatal:</b> Unable to start KMail for DCOP communication. "
|
||
|
"Make sure <i>kmail</i> is installed." ) );
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
switch ( int( reply ) )
|
||
|
{
|
||
|
case -1:
|
||
13 years ago
|
info->alert( i18n( "Cannot make folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
case -2:
|
||
13 years ago
|
info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
case 0:
|
||
13 years ago
|
info->alert( i18n( "Error while adding message to folder %1 in KMail" ).arg( folderName ) );
|
||
15 years ago
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
void Filter::showKMailImportArchiveDialog( FilterInfo* info )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
|
||
12 years ago
|
TDEApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started
|
||
15 years ago
|
|
||
14 years ago
|
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." ) );
|
||
|
}
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
bool Filter::needsSecondPage()
|
||
|
{
|
||
|
return true;
|
||
15 years ago
|
}
|