Version: 1.9.3 (using KDE 3.5.3, compiled sources) Compiler: Target: i686-pc-linux-gnu OS: Linux (i686) release 2.4.22-3Thiz Iām trying to select "Import From OS X Mail" in kmailcvt and click next.In next step,I pressed "cancel" when folder selection dialog has opened.Now...the kmailcvt UI window freezed completely,nothing you can do but "xkill" it. P.S:If you run kmailcvt alone from terminal,you won't encounter the problem.Only when you call kmailcvt from KMail's File menu it did.
I also see that cancel does not work as for the other import filters. I take a look at this issue. Btw. sounds strange that start kmailcvt from terminal make a difference. If the UI freeze: could you check the CPU consumtion of the process? Is there any load?
The CPU consumtion of the process looks no difference from common when UI freezing. Btw. When I run kmailcvt from terminal and cancel the OS X Mail import filter,nothing will happen.But after canceling any of other import filter,it will appear a dialog,it says:No directory selected.It looks a differentia exists here... Thnaks for your replying.
SVN commit 586087 by dkukawka: Fixed handling if the KFileDialog is canceled by the user and added some more checks if the user cancel the import to get a better interactivity and a faster stop of import. BUG:130892 M +80 -63 filter_mailapp.cxx M +1 -1 filter_mailapp.hxx --- branches/KDE/3.5/kdepim/kmailcvt/filter_mailapp.cxx #586086:586087 @@ -47,86 +47,100 @@ bool first_msg = true; QString directory = KFileDialog::getExistingDirectory( QDir::homeDirPath(), info->parent() ); - info->setOverall(0); - // kdDebug() << "starting by looking in directory " << directory << endl; - traverseDirectory(directory); + //qDebug("starting by looking in directory: %s", directory.latin1()); + if ( directory.isEmpty() ) { + info->addLog( i18n("No directory selected.")); + info->addLog( i18n("No files found for import.")); + } else { + info->setOverall(0); + traverseDirectory(info, directory); - for ( QStringList::Iterator filename = mMboxFiles.begin(); filename != mMboxFiles.end(); ++filename, ++currentFile) { - if ( info->shouldTerminate() ) break; - QFile mbox( *filename ); - if (! mbox.open( IO_ReadOnly ) ) { - info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); - } else { - QFileInfo filenameInfo( *filename ); - kdDebug() << "importing filename " << *filename << endl; - QStringList name = QStringList::split("/", *filename); - QString folderName(name[name.count() - 2]); + for ( QStringList::Iterator filename = mMboxFiles.begin(); filename != mMboxFiles.end(); ++filename, ++currentFile) { + if ( info->shouldTerminate() ) break; + QFile mbox( *filename ); + if (! mbox.open( IO_ReadOnly ) ) { + info->alert( i18n("Unable to open %1, skipping").arg( *filename ) ); + } else { + QFileInfo filenameInfo( *filename ); + kdDebug() << "importing filename " << *filename << endl; + QStringList name = QStringList::split("/", *filename); + QString folderName(name[name.count() - 2]); - info->setCurrent(0); - info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); - info->setFrom( *filename ); - info->setTo( folderName ); + info->setCurrent(0); + info->addLog( i18n("Importing emails from %1...").arg( *filename ) ); + info->setFrom( *filename ); + info->setTo( folderName ); - QByteArray input(MAX_LINE); - long l = 0; + QByteArray input(MAX_LINE); + long l = 0; - while ( ! mbox.atEnd() ) { - KTempFile tmp; - /* comment by Danny: - * Don't use QTextStream to read from mbox, etter use QDataStream. QTextStream only - * support Unicode/Latin1/Locale. So you lost information from emails with - * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 - * (e.g. 8Bit). It also not help to convert the QTextStream to Unicode. By this you - * get Unicode/UTF-email but KMail can't detect the correct charset. - */ - QCString seperate; + while ( ! mbox.atEnd() ) { + KTempFile tmp; + /* comment by Danny: + * Don't use QTextStream to read from mbox, etter use QDataStream. QTextStream only + * support Unicode/Latin1/Locale. So you lost information from emails with + * charset!=Unicode/Latin1/Locale (e.g. KOI8-R) and Content-Transfer-Encoding != base64 + * (e.g. 8Bit). It also not help to convert the QTextStream to Unicode. By this you + * get Unicode/UTF-email but KMail can't detect the correct charset. + */ + QCString seperate; - if(!first_msg) + if(!first_msg) + tmp.file()->writeBlock( input, l ); + l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " tmp.file()->writeBlock( input, l ); - l = mbox.readLine( input.data(),MAX_LINE); // read the first line, prevent "From " - tmp.file()->writeBlock( input, l ); - while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { - tmp.file()->writeBlock( input, l ); - } - tmp.close(); - first_msg = false; + while ( ! mbox.atEnd() && (l = mbox.readLine(input.data(),MAX_LINE)) && ((seperate = input.data()).left(5) != "From ")) { + tmp.file()->writeBlock( input, l ); + } + tmp.close(); + first_msg = false; - /* 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() ); + // force stop if user chancel the import + if ( info->shouldTerminate() ) { + tmp.unlink(); + break; + } - tmp.unlink(); + /* 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() ); - int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); - info->setCurrent( currentPercentage ); - 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() ) break; - } + tmp.unlink(); - info->addLog( i18n("Finished importing emails from %1").arg( *filename ) ); - if (count_duplicates > 0) { - info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", - "%n duplicate messages not imported to folder %1 in KMail", count_duplicates).arg(folderName)); + int currentPercentage = (int) ( ( (float) mbox.at() / filenameInfo.size() ) * 100 ); + info->setCurrent( currentPercentage ); + 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() ) break; + } + + info->addLog( i18n("Finished importing emails from %1").arg( *filename ) ); + if (count_duplicates > 0) { + info->addLog( i18n("1 duplicate message not imported to folder %1 in KMail", + "%n duplicate messages not imported to folder %1 in KMail", count_duplicates).arg(folderName)); + } + count_duplicates = 0; + mbox.close(); } - count_duplicates = 0; - mbox.close(); } } + if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user.")); + info->setCurrent(100); + info->setOverall(100); } -void FilterMailApp::traverseDirectory(const QString &dirName) +void FilterMailApp::traverseDirectory(FilterInfo *info, const QString &dirName) { QDir dir(dirName); dir.setFilter(QDir::Dirs | QDir::Files); @@ -134,13 +148,16 @@ const QFileInfoList *fileinfolist = dir.entryInfoList(); QFileInfoListIterator it(*fileinfolist); QFileInfo *fi; + + if ( info->shouldTerminate() ) return; + while ((fi = it.current())) { if (fi->fileName() == "." || fi->fileName() == "..") { ++it; continue; } if (fi->isDir() && fi->isReadable()) { - traverseDirectory(fi->filePath()); + traverseDirectory(info, fi->filePath()); } else { if (!fi->isDir() && fi->fileName() == "mbox") { kdDebug() << "adding the file " << fi->filePath() << endl; --- branches/KDE/3.5/kdepim/kmailcvt/filter_mailapp.hxx #586086:586087 @@ -30,7 +30,7 @@ private: QStringList mMboxFiles; - void traverseDirectory(const QString &); + void traverseDirectory(FilterInfo *info, const QString &); }; #endif