1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/***************************************************************************
kmailcvt.cpp - description
-------------------
copyright : (C) 2003 by Laurence Anderson
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 "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)
: KWizard(parent, name, true) {
setCaption( i18n( "KMailCVT Import Tool" ) );
selfilterpage = new KSelFilterPage(this);
addPage( selfilterpage, i18n( "Step 1: Select Filter" ) );
importpage = new KImportPage(this);
addPage( importpage, i18n( "Step 2: Importing..." ) );
}
KMailCVT::~KMailCVT() {
endImport();
}
void KMailCVT::endImport() {
if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
KApplication::startServiceByDesktopName( "kmail", TQString() ); // Will wait until kmail is started
DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", TQString(), TQString(), TQString());
if ( !reply.isValid() )
return;
reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopResetAddMessage" );
if ( !reply.isValid() )
return;
}
void KMailCVT::next() {
if( currentPage() == selfilterpage ){
// Save selected filter
Filter *selectedFilter = selfilterpage->getSelectedFilter();
// without filter don't go next
if ( !selectedFilter )
return;
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->seStatusMsg(i18n("Import in progress"));
info->clear(); // Clear info from last time
selectedFilter->import(info);
info->seStatusMsg(i18n("Import finished"));
// Cleanup
delete info;
// Enable finish & back buttons
setFinishEnabled( currentPage(), true );
setBackEnabled( currentPage(), true );
}
} else KWizard::next();
}
void KMailCVT::reject() {
if ( currentPage() == importpage && ! finishButton()->isEnabled() ) FilterInfo::terminateASAP(); // ie. import in progress
else KWizard::reject();
}
void KMailCVT::help()
{
KAboutApplication a( this );
a.exec();
}
#include "kmailcvt.moc"
|