[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] importwizard/sylpheed: Now we can get info when local mail is stored (I will move this code
From:       Montel Laurent <montel () kde ! org>
Date:       2012-02-29 21:48:18
Message-ID: 20120229214818.AAE56A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit e89878a55da02bea6460e04052ac5a9053175579 by Montel Laurent.
Committed on 29/02/2012 at 22:47.
Pushed by mlaurent into branch 'master'.

Now we can get info when local mail is stored (I will move this code to mailimporter I think)

M  +29   -4    importwizard/sylpheed/sylpheedimportdata.cpp

http://commits.kde.org/kdepim/e89878a55da02bea6460e04052ac5a9053175579

diff --git a/importwizard/sylpheed/sylpheedimportdata.cpp b/importwizard/sylpheed/sylpheedimportdata.cpp
index 544a1e5..478041e 100644
--- a/importwizard/sylpheed/sylpheedimportdata.cpp
+++ b/importwizard/sylpheed/sylpheedimportdata.cpp
@@ -24,6 +24,8 @@
 
 #include <KLocale>
 
+#include <QDomDocument>
+#include <QDomElement>
 #include <QDir>
 #include <QWidget>
 
@@ -40,9 +42,32 @@ SylpheedImportData::~SylpheedImportData()
 
 QString SylpheedImportData::localMailDirPath()
 {
-  QFile folderlist( mPath + QLatin1String( "/folderlist.xml" ) );
-  if ( folderlist.exists() ) {
-    //TODO
+  QFile folderListFile( mPath + QLatin1String( "/folderlist.xml" ) );
+  if ( folderListFile.exists() ) {
+    QDomDocument doc;
+    QString errorMsg;
+    int errorRow;
+    int errorCol;
+    if ( !doc.setContent( &folderListFile, &errorMsg, &errorRow, &errorCol ) ) {
+      kDebug() << "Unable to load document.Parse error in line " << errorRow
+               << ", col " << errorCol << ": " << errorMsg;
+      return QString();
+    }
+    QDomElement settings = doc.documentElement();
+
+    if ( settings.isNull() ) {
+      return QString();
+    }
+
+    for ( QDomElement e = settings.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) {
+      if ( e.tagName() == QLatin1String( "folder" ) ) {
+        if ( e.hasAttribute( "type" ) ) {
+          if ( e.attribute( "type" ) == QLatin1String( "mh" ) ) {
+            return e.attribute("path" );
+          }   
+        }
+      }
+    }
   }
   return QString();
 }
@@ -74,7 +99,7 @@ bool SylpheedImportData::importMails()
     MailImporter::FilterSylpheed sylpheed;
     sylpheed.setFilterInfo( info );
     info->setStatusMessage(i18n("Import in progress"));
-    const QString mailsPath = mPath  + localMailDirPath();
+    const QString mailsPath = localMailDirPath();
     QDir directory(mailsPath);
     if(directory.exists())
         sylpheed.importMails(mailsPath);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic