[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: patch for kmailcvt and kmail
From: Danny Kukawka <dkukawka () suse ! de>
Date: 2005-01-31 20:08:40
Message-ID: 200501312108.41942.dkukawka () suse ! de
[Download RAW message or body]
Hi,
there was a little problem with the patch. Here the new corrected version.
Danny
--
Danny Kukawka
(private mail: danny.kukawka@web.de)
["fix-49939_kmail_and_kmailcvt_againstCVS_20050130.diff" (text/x-diff)]
Index: kmailIface.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmailIface.h,v
retrieving revision 1.37
diff -U3 -r1.37 kmailIface.h
--- kmail/kmailIface.h 17 Sep 2004 16:22:16 -0000 1.37
+++ kmail/kmailIface.h 29 Jan 2005 19:45:41 -0000
@@ -92,12 +92,21 @@
=-2, couldn't read messageFile.
=-3, Can't allocate memory.
=-4, Message already exists in folder.
+ =100 cleaned up static variable msgIds and lastFolder
*/
virtual int dcopAddMessage(const QString & foldername,
const QString & messagefile) = 0;
virtual int dcopAddMessage(const QString & foldername,
const KURL & messagefile) = 0;
-
+
+ /** by danny.kukawka@web.de: to import without search duplicates */
+ //---START ---
+ virtual int dcopAddMessage_fastImport(const QString & foldername,
+ const QString & messagefile) = 0;
+ virtual int dcopAddMessage_fastImport(const QString & foldername,
+ const KURL & messagefile) = 0;
+ //---END ---
+
virtual QStringList folderList() const =0;
virtual DCOPRef getFolder( const QString& vpath ) =0;
virtual void selectFolder( QString folder ) =0;
Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.cpp,v
retrieving revision 1.319
diff -U3 -r1.319 kmkernel.cpp
--- kmail/kmkernel.cpp 8 Jan 2005 02:27:02 -0000 1.319
+++ kmail/kmkernel.cpp 29 Jan 2005 19:45:41 -0000
@@ -597,10 +597,22 @@
static QString lastFolder = "";
bool readFolderMsgIds = false;
+ if(foldername.startsWith( "_CLEANUP_dcopAddmessage_NOW_" )) {
+ if ( msgIds != 0 ) {
+ msgIds->clear();
+ delete msgIds;
+ msgIds = 0;
+ }
+ if(!lastFolder.isEmpty()) {
+ lastFolder = "";
+ }
+ return 100;
+ }
//kdDebug(5006) << "KMKernel::dcopAddMessage called" << endl;
if ( foldername != lastFolder ) {
if ( msgIds != 0 ) {
+ msgIds->clear();
delete msgIds;
msgIds = 0;
}
@@ -630,30 +642,48 @@
if ( folder ) {
if (readFolderMsgIds) {
+ // OLD COMMENT:
// Try to determine if a message already exists in
// the folder. The message id that is searched for, is
// the subject line + the date. This should be quite
// unique. The change that a given date with a given
// subject is in the folder twice is very small.
-
// If the subject is empty, the fromStrip string
// is taken.
+
+ // NEW COMMENT from Danny Kukawka (danny.kukawka@web.de):
+ // subject line + the date is only unique if the following
+ // return a correct unique value:
+ // time_t DT = mb->date();
+ // QString dt = ctime(&DT);
+ // But if the datestring in the Header isn't RFC conform
+ // subject line + the date isn't unique.
+ //
+ // The only uique headerfield is the Message-ID. In some
+ // cases this could be empty. I then I use the
+ // subject line + dateStr .
+
int i;
folder->open();
for( i=0; i<folder->count(); i++) {
KMMsgBase *mb = folder->getMsgBase(i);
- time_t DT = mb->date();
- QString dt = ctime(&DT);
- QString id = mb->subject();
-
- if (id.isEmpty())
- id = mb->fromStrip();
- if (id.isEmpty())
- id = mb->toStrip();
-
- id+=dt;
-
+ QString msgIdMD5 = mb->msgIdMD5();
+ QString id = msgIdMD5;
+
+ if ( id.isEmpty()) {
+ QString dt = mb->dateStr();
+ id = mb->subject();
+
+ if ( id.isEmpty() )
+ id = mb->fromStrip();
+ if ( id.isEmpty() )
+ id = mb->toStrip();
+
+ id = mb->subject();
+ id+=dt;
+ }
+
//fprintf(stderr,"%s\n",(const char *) id);
if (!id.isEmpty()) {
msgIds->append(id);
@@ -662,16 +692,20 @@
folder->close();
}
- time_t DT = msg->date();
- QString dt = ctime( &DT );
- QString msgId = msg->subject();
-
- if ( msgId.isEmpty() )
- msgId = msg->fromStrip();
- if ( msgId.isEmpty() )
- msgId = msg->toStrip();
-
- msgId += dt;
+ QString msgIdMD5 = msg->msgIdMD5();
+ QString msgId = msgIdMD5;
+
+ if ( msgId.isEmpty()) {
+ QString dt = msg->dateStr();
+ msgId = msg->subject();
+
+ if ( msgId.isEmpty() )
+ msgId = msg->fromStrip();
+ if ( msgId.isEmpty() )
+ msgId = msg->toStrip();
+
+ msgId+=dt;
+ }
int k = msgIds->findIndex( msgId );
//fprintf(stderr,"find %s = %d\n",(const char *) msgId,k);
@@ -688,7 +722,8 @@
msg = 0;
}
} else {
- retval = -4;
+ //qDebug( "duplicate: " + msgId + "; subj: " + msg->subject() + ", from: " + \
msgId = msg->fromStrip()); + retval = -4;
}
} else {
retval = -1;
@@ -699,6 +734,55 @@
return retval;
}
+int KMKernel::dcopAddMessage_fastImport(const QString & foldername,const QString & \
msgUrlString) +{
+ return dcopAddMessage_fastImport(foldername, KURL(msgUrlString));
+}
+
+int KMKernel::dcopAddMessage_fastImport(const QString & foldername,const KURL & \
msgUrl) +{
+ // This is a proposed change by Danny Kukawka
+ // Use this function to import messages without
+ // search for already existing emails.
+ // If you would like to import your own messages,
+ // you don't want to loose messages in the most
+ // cases
+
+ if ( foldername.isEmpty() )
+ return -1;
+
+ int retval;
+ QCString messageText;
+
+ if (!msgUrl.isEmpty() && msgUrl.isLocalFile()) {
+
+ messageText = KPIM::kFileToString( msgUrl.path(), true, false);
+ if ( messageText.isNull() )
+ return -2;
+
+ KMMessage *msg = new KMMessage();
+ msg->fromString( messageText );
+
+ KMFolder *folder = the_folderMgr->findOrCreate(foldername, false);
+
+ if ( folder ) {
+ if ( folder->addMsg( msg ) == 0 ) {
+ retval = 1;
+ } else {
+ retval =- 2;
+ delete msg;
+ msg = 0;
+ }
+ } else {
+ retval = -1;
+ }
+
+ } else {
+ retval = -2;
+ }
+ return retval;
+}
+
QStringList KMKernel::folderList() const
{
QStringList folders;
Index: kmkernel.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.h,v
retrieving revision 1.128
diff -U3 -r1.128 kmkernel.h
--- kmail/kmkernel.h 9 Jan 2005 21:10:07 -0000 1.128
+++ kmail/kmkernel.h 29 Jan 2005 19:45:41 -0000
@@ -134,6 +134,11 @@
void openReader() { openReader( false ); }
int dcopAddMessage(const QString & foldername, const QString & messageFile);
int dcopAddMessage(const QString & foldername, const KURL & messageFile);
+ /** by danny.kukawka@web.de: to import without search for duplicates */
+ //---START ---
+ int dcopAddMessage_fastImport(const QString & foldername, const QString & \
messageFile); + int dcopAddMessage_fastImport(const QString & foldername, const KURL \
& messageFile); + //---END ---
QStringList folderList() const;
DCOPRef getFolder( const QString& vpath );
void selectFolder( QString folder );
Index: filter_evolution.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_evolution.cxx,v
retrieving revision 1.2
diff -U3 -r1.2 filter_evolution.cxx
--- kmailcvt/filter_evolution.cxx 27 Jun 2004 14:57:52 -0000 1.2
+++ kmailcvt/filter_evolution.cxx 31 Jan 2005 18:55:44 -0000
@@ -28,8 +28,8 @@
/** Default constructor. */
FilterEvolution::FilterEvolution(void) :
- Filter(i18n("Import Evolution Mails and Folder Structure"),
- "Simon MARTIN",
+ Filter(i18n("Import Evolution 1.x Mails and Folder Structure"),
+ "Simon MARTIN <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p>Select the base directory of Evolution's mails (usually \
~/evolution/local).</p>"
"<p>As it is currently impossible to recreate the folder structure, it \
will be " "\"contained\" in the generated folder's names.</p>"
@@ -38,7 +38,9 @@
{}
/** Destructor. */
-FilterEvolution::~FilterEvolution(void) {}
+FilterEvolution::~FilterEvolution(void) {
+ endImport();
+}
/** Recursive import of Evolution's mboxes. */
void FilterEvolution::import(FilterInfo *info)
@@ -118,7 +120,14 @@
QString destFolder = rootDir;
if(!targetDir.isNull())
destFolder = destFolder + "-" + targetDir;
- addMessage(info, destFolder, tmp.name());
+
+ /* 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);
@@ -126,6 +135,11 @@
}
info->addLog(i18n("Finished importing emails from %1").arg(mboxName));
+ if (count_duplicates > 0)
+ {
+ info->addLog( i18n("%1 Duplicate messages not imported").arg(count_duplicates));
+ }
+ count_duplicates = 0;
mbox.close();
}
}
Index: filter_mailapp.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_mailapp.cxx,v
retrieving revision 1.1
diff -U3 -r1.1 filter_mailapp.cxx
--- kmailcvt/filter_mailapp.cxx 25 Aug 2004 20:26:28 -0000 1.1
+++ kmailcvt/filter_mailapp.cxx 29 Jan 2005 19:27:52 -0000
@@ -30,7 +30,7 @@
FilterMailApp::FilterMailApp() :
Filter( i18n("Import From OS X Mail"),
- "Chris Howells",
+ "Chris Howells <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p><b>OS X Mail Import Filter</b></p>"
"<p>This filter imports e-mails from the Mail client in Apple Mac OS X.</p>"
))
@@ -39,11 +39,14 @@
FilterMailApp::~FilterMailApp()
{
+ endImport();
}
void FilterMailApp::import(FilterInfo *info)
{
int currentFile = 1;
+ int overall_status = 0;
+
QString directory = KFileDialog::getExistingDirectory( QDir::homeDirPath(), \
info->parent() ); info->setOverall(0);
@@ -55,34 +58,52 @@
if (! mbox.open( IO_ReadOnly ) ) {
info->alert( i18n("Unable to open %1, skipping").arg( *filename ) );
}
-
- QFileInfo filenameInfo( *filename );
- kdDebug() << "importing filename " << *filename << endl;
- QStringList name = QStringList::split("/", *filename);
- QString folderName(name[name.count() - 2]);
- QTextStream mboxFile( &mbox );
- QString mboxLine = mboxFile.readLine();
-
- info->setCurrent(0);
- info->addLog( i18n("Importing emails from %1...").arg( *filename ) );
- info->setFrom( *filename );
- info->setTo( folderName );
-
- while ( ! mboxFile.atEnd() ) {
+ else {
+ QFileInfo filenameInfo( *filename );
+ kdDebug() << "importing filename " << *filename << endl;
+ QStringList name = QStringList::split("/", *filename);
+ QString folderName(name[name.count() - 2]);
+ QTextStream mboxFile( &mbox );
+ QString mboxLine = mboxFile.readLine();
+
+ info->setCurrent(0);
+ info->addLog( i18n("Importing emails from %1...").arg( *filename ) );
+ info->setFrom( *filename );
+ info->setTo( folderName );
+
+ while ( ! mboxFile.atEnd() ) {
KTempFile tmp;
*tmp.textStream() << mboxLine << endl; // Not really needed (the From line)
while ( !( mboxLine = mboxFile.readLine() ).isNull() && mboxLine.left(5) != \
"From " )
- *tmp.textStream() << mboxLine << endl;
+ *tmp.textStream() << mboxLine << endl;
tmp.close();
- addMessage( info, folderName, tmp.name() );
+
+ /* 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 );
- info->setOverall( (int) ( currentPercentage * ( (float) currentFile / \
mMboxFiles.count() ) ) ); + 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() ) return;
+ }
+
+ info->addLog( i18n("Finished importing emails from %1").arg( *filename ) );
+ if (count_duplicates > 0) {
+ info->addLog( i18n("%1 Duplicate messages not imported to folder %2 in \
KMail").arg(count_duplicates).arg(folderName)); + }
+ count_duplicates = 0;
+ mbox.close();
}
-
- info->addLog( i18n("Finished importing emails from %1").arg( *filename ) );
}
}
@@ -94,21 +115,16 @@
const QFileInfoList *fileinfolist = dir.entryInfoList();
QFileInfoListIterator it(*fileinfolist);
QFileInfo *fi;
- while ((fi = it.current()))
- {
- if (fi->fileName() == "." || fi->fileName() == "..")
- {
+ while ((fi = it.current())) {
+ if (fi->fileName() == "." || fi->fileName() == "..") {
++it;
continue;
}
- if (fi->isDir() && fi->isReadable())
- {
+ if (fi->isDir() && fi->isReadable()) {
traverseDirectory(fi->filePath());
}
- else
- {
- if (!fi->isDir() && fi->fileName() == "mbox")
- {
+ else {
+ if (!fi->isDir() && fi->fileName() == "mbox") {
kdDebug() << "adding the file " << fi->filePath() << endl;
mMboxFiles.append(fi->filePath());
}
Index: filter_mbox.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_mbox.cxx,v
retrieving revision 1.6
diff -U3 -r1.6 filter_mbox.cxx
--- kmailcvt/filter_mbox.cxx 27 Jun 2004 14:57:52 -0000 1.6
+++ kmailcvt/filter_mbox.cxx 29 Jan 2005 19:27:52 -0000
@@ -26,7 +26,7 @@
FilterMBox::FilterMBox() :
Filter( i18n("Import mbox Files (UNIX, Evolution)"),
- "Laurence Anderson",
+ "Laurence Anderson <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p><b>mbox import filter</b></p>"
"<p>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.</p>" @@ -36,46 +36,70 @@
}
FilterMBox::~FilterMBox()
-{
+{
+ endImport();
}
void FilterMBox::import(FilterInfo *info)
{
int currentFile = 1;
+ int overall_status = 0;
+
QStringList filenames = KFileDialog::getOpenFileNames( QDir::homeDirPath(), "*|" + \
i18n("mbox Files (*)"), info->parent() ); info->setOverall(0);
-
+
for ( QStringList::Iterator filename = filenames.begin(); filename != \
filenames.end(); ++filename, ++currentFile) { QFile mbox( *filename );
if (! mbox.open( IO_ReadOnly ) ) {
info->alert( i18n("Unable to open %1, skipping").arg( *filename ) );
}
-
- QFileInfo filenameInfo( *filename );
- QString folderName( "MBOX-" + filenameInfo.baseName(TRUE) );
- QTextStream mboxFile( &mbox );
- QString mboxLine = mboxFile.readLine();
-
- info->setCurrent(0);
- info->addLog( i18n("Importing emails from %1...").arg( *filename ) );
- info->setFrom( *filename );
- info->setTo( folderName );
-
- while ( ! mboxFile.atEnd() ) {
- KTempFile tmp;
- *tmp.textStream() << mboxLine << endl; // Not really needed (the From line)
- while ( !( mboxLine = mboxFile.readLine() ).isNull() && mboxLine.left(5) != \
"From " )
- *tmp.textStream() << mboxLine << endl;
- tmp.close();
- addMessage( info, folderName, tmp.name() );
- tmp.unlink();
- int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * \
100 );
- info->setCurrent( currentPercentage );
- info->setOverall( (int) ( currentPercentage * ( (float) currentFile / \
filenames.count() ) ) );
- if ( info->shouldTerminate() ) return;
- }
+ else {
+ QFileInfo filenameInfo( *filename );
+ QString folderName( "MBOX-" + filenameInfo.baseName(TRUE) );
+ QTextStream mboxFile( &mbox );
+
+ QString mboxLine = mboxFile.readLine();
- info->addLog( i18n("Finished importing emails from %1").arg( *filename ) );
+ info->setCurrent(0);
+ info->addLog( i18n("Importing emails from %1...").arg( *filename ) );
+
+ info->setFrom( *filename );
+ info->setTo( folderName );
+
+ while ( ! mboxFile.atEnd() ) {
+ KTempFile tmp;
+ *tmp.textStream() << mboxLine << endl; // Not really needed (the From line)
+ while ( !( mboxLine = mboxFile.readLine() ).isNull() && mboxLine.left(5) != "From " \
) + *tmp.textStream() << mboxLine << endl;
+ 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();
+ 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() ) return;
+ }
+
+ info->addLog( i18n("Finished importing emails from %1").arg( *filename ));
+ if (count_duplicates > 0) {
+ info->addLog( i18n("%1 Duplicate messages not imported to folder %2 in \
KMail").arg(count_duplicates).arg(folderName)); + }
+ count_duplicates = 0;
+ // don't forget to close the file !!!
+ mbox.close();
+ }
}
}
Index: filter_oe.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_oe.cxx,v
retrieving revision 1.15
diff -U3 -r1.15 filter_oe.cxx
--- kmailcvt/filter_oe.cxx 12 Jun 2004 18:17:02 -0000 1.15
+++ kmailcvt/filter_oe.cxx 29 Jan 2005 19:27:52 -0000
@@ -36,7 +36,7 @@
FilterOE::FilterOE() :
Filter( i18n("Import Outlook Express Emails"),
- "Laurence Anderson",
+ "Laurence Anderson <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p><b>Outlook Express 4/5/6 import filter</b></p>"
"<p>You will need to locate the folder where the mailbox has been stored by \
searching for .dbx or .mbx files under " "<ul><li><i>C:\\Windows\\Application \
Data</i> in Windows 9x" @@ -48,6 +48,7 @@
FilterOE::~FilterOE()
{
+ endImport();
}
void FilterOE::import(FilterInfo *info)
@@ -67,6 +68,7 @@
info->alert(i18n("No Outlook Express mailboxes found in directory \
%1.").arg(mailDir)); return;
}
+
totalFiles = files.count();
currentFile = 0;
@@ -152,7 +154,13 @@
} while ( !ds.atEnd() );
tmp.close();
- addMessage(inf, folderName, tmp.name());
+ /* 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, folderName, tmp.name() );
+ else addMessage_fastImport( inf, folderName, tmp.name() );
+
tmp.unlink();
}
}
@@ -251,7 +259,10 @@
ds.device()->at(nextAddress);
} while (nextAddress != 0);
tmp.close();
- addMessage(inf, folderName, tmp.name());
+
+ if(inf->removeDupMsg) addMessage( inf, folderName, tmp.name() );
+ else addMessage_fastImport( inf, folderName, tmp.name() );
+
inf->setCurrent( ++currentEmail / totalEmails * 100);
tmp.unlink();
Index: filter_oe.hxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_oe.hxx,v
retrieving revision 1.3
diff -U3 -r1.3 filter_oe.hxx
--- kmailcvt/filter_oe.hxx 1 Sep 2003 07:15:21 -0000 1.3
+++ kmailcvt/filter_oe.hxx 29 Jan 2005 19:27:52 -0000
@@ -49,7 +49,7 @@
int totalEmails;
/** which email (of totalFiles) is now in the work? */
int currentEmail;
-
+
QString folderName;
};
Index: filter_plain.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_plain.cxx,v
retrieving revision 1.20
diff -U3 -r1.20 filter_plain.cxx
--- kmailcvt/filter_plain.cxx 23 Jun 2004 12:53:33 -0000 1.20
+++ kmailcvt/filter_plain.cxx 29 Jan 2005 19:27:52 -0000
@@ -25,7 +25,7 @@
FilterPlain::FilterPlain() :
Filter(i18n("Import Plain Text Emails"),
- "Laurence Anderson",
+ "Laurence Anderson <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p>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-</p>"
@@ -35,6 +35,7 @@
FilterPlain::~FilterPlain()
{
+ endImport();
}
void FilterPlain::import(FilterInfo *info)
@@ -58,7 +59,22 @@
info->setFrom(*mailFile);
info->setTo(dir.dirName());
info->setCurrent(0);
- if( ! addMessage(info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile)) ) \
info->addLog( i18n("Could not import %1").arg( *mailFile ) ); +
+ /* 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() ) return;
Index: filter_pmail.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filter_pmail.cxx,v
retrieving revision 1.33
diff -U3 -r1.33 filter_pmail.cxx
--- kmailcvt/filter_pmail.cxx 6 Oct 2003 13:26:44 -0000 1.33
+++ kmailcvt/filter_pmail.cxx 29 Jan 2005 19:27:52 -0000
@@ -27,7 +27,7 @@
FilterPMail::FilterPMail() :
Filter(i18n("Import Folders From Pegasus-Mail"),
- "Holger Schurig",
+ "Holger Schurig <p>( Filter accelerated by Danny Kukawka )</p>",
i18n("<p>Select the Pegasus-Mail directory on your system (containing CNM, PMM \
and MBX files). " "On many systems this is stored in C:\\PMail\\mail</p>"
"<p><b>Note:</b> This import filter will import your folders, but not \
" @@ -39,6 +39,7 @@
FilterPMail::~FilterPMail()
{
+ endImport();
}
void FilterPMail::import(FilterInfo *info)
@@ -96,7 +97,13 @@
{
QString destFolder("PMail-New Messages");
inf->setTo(destFolder);
- addMessage(inf, destFolder, file);
+
+ /* 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 );
}
@@ -168,7 +175,10 @@
if (ch == 0x1a) {
// close file, send it
tempfile->close();
- addMessage(inf, folder, tempfile->name());
+
+ if(inf->removeDupMsg) addMessage( inf, folder, tempfile->name() );
+ else addMessage_fastImport( inf, folder, tempfile->name() );
+
tempfile->unlink();
delete tempfile;
state = 0;
@@ -185,7 +195,9 @@
// did Folder end without 0x1a at the end?
if (state != 0) {
tempfile->close();
- addMessage(inf, folder, tempfile->name());
+ if(inf->removeDupMsg) addMessage( inf, folder, tempfile->name() );
+ else addMessage_fastImport( inf, folder, tempfile->name() );
+
tempfile->unlink();
delete tempfile;
}
@@ -242,7 +254,10 @@
regexp.search(line) >= 0)) // slower regexp
{
tempfile->close();
- addMessage(inf, folder, tempfile->name());
+
+ if(inf->removeDupMsg) addMessage( inf, folder, tempfile->name() );
+ else addMessage_fastImport( inf, folder, tempfile->name() );
+
tempfile->unlink();
delete tempfile;
tempfile = 0;
@@ -261,7 +276,10 @@
if (tempfile) {
tempfile->close();
- addMessage(inf, folder, tempfile->name());
+
+ if(inf->removeDupMsg) addMessage( inf, folder, tempfile->name() );
+ else addMessage_fastImport( inf, folder, tempfile->name() );
+
tempfile->unlink();
delete tempfile;
}
Index: filters.cxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filters.cxx,v
retrieving revision 1.44
diff -U3 -r1.44 filters.cxx
--- kmailcvt/filters.cxx 25 Aug 2004 16:47:34 -0000 1.44
+++ kmailcvt/filters.cxx 29 Jan 2005 19:27:52 -0000
@@ -33,10 +33,11 @@
bool FilterInfo::s_terminateASAP = false;
-FilterInfo::FilterInfo( KImportPageDlg* dlg, QWidget* parent )
+FilterInfo::FilterInfo( KImportPageDlg* dlg, QWidget* parent , bool _removeDupMsg)
: m_dlg( dlg ),
m_parent( parent )
{
+ removeDupMsg = _removeDupMsg;
s_terminateASAP = false;
}
@@ -120,6 +121,8 @@
m_author( author ),
m_info( info )
{
+ //public
+ count_duplicates = 0;
}
bool Filter::addMessage( FilterInfo* info, const QString& folderName,
@@ -131,8 +134,8 @@
if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
KApplication::startServiceByDesktopName( "kmail", QString::null ); // Will wait \
until kmail is started
- DCOPReply reply = DCOPRef( "kmail", "KMailIface" )
- .call( "dcopAddMessage", folderName, msgURL );
+ DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", \
folderName, msgURL ); +
if ( !reply.isValid() )
{
info->alert( i18n( "<b>Fatal:</b> Unable to start KMail for DCOP communication. \
" @@ -148,17 +151,60 @@
case -2:
info->alert( i18n( "Cannot add message to folder %1 in KMail" ).arg( \
folderName ) ); return false;
- /* chowells -- disabled. Checking for a duplicate subject seems to be totally \
bogus, of course you
- will get duplicate subjects in any normal import
- case -4:
- info->alert( i18n( "Duplicate message subject error when adding 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 QString& folderName,
+ const QString& msgPath )
+{
+ KURL msgURL;
+ msgURL.setPath( msgPath );
+
+ if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
+ KApplication::startServiceByDesktopName( "kmail", QString::null ); // Will wait \
until kmail is started
+ DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( \
"dcopAddMessage_fastImport", folderName, msgURL ); +
+ 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:
+ 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;
}
+bool Filter::endImport()
+{
+ if ( !kapp->dcopClient()->isApplicationRegistered( "kmail" ) )
+ KApplication::startServiceByDesktopName( "kmail", QString::null ); // Will wait \
until kmail is started +
+ DCOPReply reply = DCOPRef( "kmail", "KMailIface" ).call( "dcopAddMessage", \
"_CLEANUP_dcopAddmessage_NOW_", QString::null); +
+ if ( !reply.isValid() )
+ {
+ return false;
+ }
+ return true;
+}
// vim: ts=2 sw=2 et
Index: filters.hxx
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/filters.hxx,v
retrieving revision 1.29
diff -U3 -r1.29 filters.hxx
--- kmailcvt/filters.hxx 1 Sep 2003 07:15:21 -0000 1.29
+++ kmailcvt/filters.hxx 29 Jan 2005 19:27:52 -0000
@@ -29,7 +29,7 @@
class FilterInfo
{
public:
- FilterInfo(KImportPageDlg *dlg, QWidget *parent);
+ FilterInfo(KImportPageDlg *dlg, QWidget *parent, bool _removeDupMsg);
~FilterInfo();
void setStatusMsg( const QString& status );
@@ -45,8 +45,8 @@
bool shouldTerminate();
QWidget *parent() { return m_parent; }
+ bool removeDupMsg;
-
private:
KImportPageDlg *m_dlg;
QWidget *m_parent;
@@ -63,11 +63,17 @@
QString author() const { return m_author; }
QString name() const { return m_name; }
QString info() const { return m_info; }
-
+
+ int count_duplicates; //to count all duplicate messages
+
protected:
bool addMessage( FilterInfo* info,
const QString& folder,
const QString& msgFile );
+ bool addMessage_fastImport( FilterInfo* info,
+ const QString& folder,
+ const QString& msgFile );
+ bool endImport();
private:
QString m_name;
QString m_author;
Index: kmailcvt.cpp
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/kmailcvt.cpp,v
retrieving revision 1.31
diff -U3 -r1.31 kmailcvt.cpp
--- kmailcvt/kmailcvt.cpp 1 Sep 2003 07:15:21 -0000 1.31
+++ kmailcvt/kmailcvt.cpp 29 Jan 2005 19:27:52 -0000
@@ -49,7 +49,7 @@
setBackEnabled( currentPage(), false );
setFinishEnabled( currentPage(), false );
// Start import
- FilterInfo *info = new FilterInfo(importpage, this);
+ 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);
Index: kselfilterpage.cpp
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/kselfilterpage.cpp,v
retrieving revision 1.10
diff -U3 -r1.10 kselfilterpage.cpp
--- kmailcvt/kselfilterpage.cpp 25 Aug 2004 20:26:28 -0000 1.10
+++ kmailcvt/kselfilterpage.cpp 29 Jan 2005 19:27:52 -0000
@@ -17,6 +17,7 @@
#include <kstandarddirs.h>
#include <qtextedit.h>
+#include <qcheckbox.h>
#include <klocale.h>
#include "filters.hxx"
@@ -67,6 +70,11 @@
if (mFilterCombo->count() == 1) filterSelected(0); // Setup description box with \
fist filter selected }
+bool KSelFilterPage::removeDupMsg_checked()
+{
+ return remDupMsg->isChecked();
+}
+
Filter * KSelFilterPage::getSelectedFilter(void)
{
return mFilterList.at(mFilterCombo->currentItem());
Index: kselfilterpage.h
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/kselfilterpage.h,v
retrieving revision 1.6
diff -U3 -r1.6 kselfilterpage.h
--- kmailcvt/kselfilterpage.h 1 Sep 2003 07:15:21 -0000 1.6
+++ kmailcvt/kselfilterpage.h 29 Jan 2005 19:27:52 -0000
@@ -31,6 +31,7 @@
public:
void addFilter(Filter *f);
Filter *getSelectedFilter(void);
+ bool removeDupMsg_checked();
private:
QPtrList<Filter> mFilterList;
private slots:
Index: kselfilterpagedlg.ui
===================================================================
RCS file: /home/kde/kdepim/kmailcvt/kselfilterpagedlg.ui,v
retrieving revision 1.7
diff -U3 -r1.7 kselfilterpagedlg.ui
--- kmailcvt/kselfilterpagedlg.ui 15 Oct 2003 22:06:54 -0000 1.7
+++ kmailcvt/kselfilterpagedlg.ui 29 Jan 2005 19:27:52 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>KSelFilterPageDlg</class>
<widget class="QWidget">
<property name="name">
@@ -9,44 +9,16 @@
<x>0</x>
<y>0</y>
<width>532</width>
- <height>452</height>
+ <height>461</height>
</rect>
</property>
+ <property name="caption">
+ <string>KSelFilterPageDlg</string>
+ </property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
- <widget class="QLabel" row="0" column="0" rowspan="3" colspan="1">
- <property name="name">
- <cstring>mIntroSidebar</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>170</width>
- <height>430</height>
- </size>
- </property>
- <property name="frameShape">
- <enum>Panel</enum>
- </property>
- <property name="frameShadow">
- <enum>Sunken</enum>
- </property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- <property name="indent">
- <number>0</number>
- </property>
- </widget>
<widget class="QComboBox" row="1" column="1">
<property name="name">
<cstring>mFilterCombo</cstring>
@@ -97,6 +69,48 @@
<bool>true</bool>
</property>
</widget>
+ <widget class="QLabel" row="0" column="0" rowspan="4" colspan="1">
+ <property name="name">
+ <cstring>mIntroSidebar</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>170</width>
+ <height>430</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>Panel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ <property name="indent">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="1">
+ <property name="name">
+ <cstring>remDupMsg</cstring>
+ </property>
+ <property name="text">
+ <string>Remove duplicate messages during import.</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
</grid>
</widget>
<layoutdefaults spacing="6" margin="11"/>
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic