[kmymoney/5.0] kmymoney/plugins/ofx/import: Improve result information for OFX mapping

Thomas Baumgart null at kde.org
Tue Jan 29 08:39:01 GMT 2019


Git commit 778ff2c559552f461a0d30ae60abd68c7f5d55c6 by Thomas Baumgart.
Committed on 29/01/2019 at 08:39.
Pushed by tbaumgart into branch '5.0'.

Improve result information for OFX mapping

The source used to obtain information necessary for OFX mapping
(www.ofxhome.com) also presents information about the availability of
the provided URL and the verification of the SSL/TLS certificate.

Since this information was not interpreted by KMyMoney, URLs were
presented that are known to be broken.

This change shows an error message when a non working URL or an invalid
certificate is found on ofxhome.com.

GUI:

M  +37   -20   kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
M  +72   -35   kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.ui
M  +35   -21   kmymoney/plugins/ofx/import/ofxpartner.cpp
M  +9    -1    kmymoney/plugins/ofx/import/ofxpartner.h

https://commits.kde.org/kmymoney/778ff2c559552f461a0d30ae60abd68c7f5d55c6

diff --git a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
index 48cb3ca8d..899366cbc 100644
--- a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
+++ b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
@@ -128,6 +128,9 @@ KOnlineBankingSetupWizard::KOnlineBankingSetupWizard(QWidget *parent):
   button(QWizard::CancelButton)->setIcon(KStandardGuiItem::cancel().icon());
   button(QWizard::NextButton)->setIcon(KStandardGuiItem::forward(KStandardGuiItem::UseRTL).icon());
   button(QWizard::BackButton)->setIcon(KStandardGuiItem::back(KStandardGuiItem::UseRTL).icon());
+
+  m_problemMessages->setHidden(true);
+  m_problemMessages->setWordWrap(true);
 }
 
 KOnlineBankingSetupWizard::~KOnlineBankingSetupWizard()
@@ -186,6 +189,7 @@ void KOnlineBankingSetupWizard::newPage(int id)
 {
   QWidget* focus = 0;
 
+  m_problemMessages->setHidden(true);
   bool ok = true;
   if ((id - d->m_prevPage) == 1) { // one page forward?
     switch (d->m_prevPage) {
@@ -235,7 +239,7 @@ bool KOnlineBankingSetupWizard::finishFiPage()
   bool result = false;
 
   m_bankInfo.clear();
-  OfxFiServiceInfo info;
+  OfxHomeServiceInfo info;
 
   if (m_selectionTab->currentIndex() == 0) {
 
@@ -255,16 +259,29 @@ bool KOnlineBankingSetupWizard::finishFiPage()
         QString message = QString("<p>Fipid: %1<br/>").arg(*it_fipid);
 
         // If the bank supports retrieving statements
-        if (info.accountlist) {
-          m_bankInfo.push_back(info);
+        if (info.ofxInfo.accountlist) {
+          m_bankInfo.push_back(info.ofxInfo);
+
+          message += QString("URL: %1<br/>Org: %2<br/>Fid: %3<br/>").arg(info.ofxInfo.url, info.ofxInfo.org, info.ofxInfo.fid);
 
-          message += QString("URL: %1<br/>Org: %2<br/>Fid: %3<br/>").arg(info.url, info.org, info.fid);
-          if (info.statements)
+          if (info.ofxInfo.statements)
             message += i18n("Supports online statements<br/>");
-          if (info.investments)
+          if (info.ofxInfo.investments)
             message += i18n("Supports investments<br/>");
-          if (info.billpay)
+          if (info.ofxInfo.billpay)
             message += i18n("Supports bill payment (but not supported by KMyMoney yet)<br/>");
+
+          QString problemMessage;
+          if (!info.ofxValidated)
+            problemMessage += i18n("OFX host failed. Last successful access was on '%1'. ").arg(info.lastOfxValidated);
+          if (!info.sslValidated)
+            problemMessage += i18n("Certificate verification of OFX host failed. Last successful verification was on '%1'.").arg(info.lastSslValidated);
+
+          if (!problemMessage.isEmpty()) {
+            m_problemMessages->setText(problemMessage);
+            m_problemMessages->animatedShow();
+          }
+
         } else {
           message += i18n("Does not support online banking");
         }
@@ -288,24 +305,24 @@ bool KOnlineBankingSetupWizard::finishFiPage()
     m_textDetails->clear();
     m_textDetails->append(i18n("<p>Details for %1:</p>", m_bankName->text()));
 
-    memset(&info, 0, sizeof(OfxFiServiceInfo));
-    strncpy(info.fid, m_fid->text().toLatin1(), OFX_FID_LENGTH - 1);
-    strncpy(info.org, m_bankName->text().toLatin1(), OFX_ORG_LENGTH - 1);
-    strncpy(info.url, m_url->url().url().toLatin1(), OFX_URL_LENGTH - 1);
-    info.accountlist = 1;
-    info.statements = 1;
-    info.billpay = 1;
-    info.investments = 1;
+    memset(&info.ofxInfo, 0, sizeof(OfxFiServiceInfo));
+    strncpy(info.ofxInfo.fid, m_fid->text().toLatin1(), OFX_FID_LENGTH - 1);
+    strncpy(info.ofxInfo.org, m_bankName->text().toLatin1(), OFX_ORG_LENGTH - 1);
+    strncpy(info.ofxInfo.url, m_url->url().url().toLatin1(), OFX_URL_LENGTH - 1);
+    info.ofxInfo.accountlist = 1;
+    info.ofxInfo.statements = 1;
+    info.ofxInfo.billpay = 1;
+    info.ofxInfo.investments = 1;
 
-    m_bankInfo.push_back(info);
+    m_bankInfo.push_back(info.ofxInfo);
 
     QString message;
-    message += QString("<p>URL: %1<br/>Org: %2<br/>Fid: %3<br/>").arg(info.url, info.org, info.fid);
-    if (info.statements)
+    message += QString("<p>URL: %1<br/>Org: %2<br/>Fid: %3<br/>").arg(info.ofxInfo.url, info.ofxInfo.org, info.ofxInfo.fid);
+    if (info.ofxInfo.statements)
       message += i18n("Supports online statements<br/>");
-    if (info.investments)
+    if (info.ofxInfo.investments)
       message += i18n("Supports investments<br/>");
-    if (info.billpay)
+    if (info.ofxInfo.billpay)
       message += i18n("Supports bill payment (but not supported by KMyMoney yet)<br/>");
     message += "</p>";
     m_textDetails->append(message);
diff --git a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.ui b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.ui
index 72f845b5d..03eebf7fb 100644
--- a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.ui
+++ b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.ui
@@ -18,7 +18,16 @@
     <string>Select Financial Institution</string>
    </property>
    <layout class="QHBoxLayout">
-    <property name="margin">
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
      <number>0</number>
     </property>
     <item>
@@ -46,7 +55,16 @@
           <string comment="@title type of online banking connection">Automatic</string>
          </attribute>
          <layout class="QVBoxLayout">
-          <property name="margin">
+          <property name="leftMargin">
+           <number>0</number>
+          </property>
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <property name="rightMargin">
+           <number>0</number>
+          </property>
+          <property name="bottomMargin">
            <number>0</number>
           </property>
           <item>
@@ -59,7 +77,16 @@
           <string comment="@title type of online banking connection">Manual</string>
          </attribute>
          <layout class="QVBoxLayout">
-          <property name="margin">
+          <property name="leftMargin">
+           <number>0</number>
+          </property>
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <property name="rightMargin">
+           <number>0</number>
+          </property>
+          <property name="bottomMargin">
            <number>0</number>
           </property>
           <item>
@@ -134,7 +161,16 @@
     <string>Enter Login Details</string>
    </property>
    <layout class="QGridLayout" name="gridLayout1">
-    <property name="margin">
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
      <number>0</number>
     </property>
     <item row="0" column="0" colspan="2">
@@ -256,17 +292,7 @@
       </item>
      </layout>
     </item>
-    <item row="7" column="0" colspan="2">
-     <widget class="QLabel" name="textLabel3">
-      <property name="text">
-       <string>Connection Details</string>
-      </property>
-      <property name="wordWrap">
-       <bool>false</bool>
-      </property>
-     </widget>
-    </item>
-    <item row="8" column="0" colspan="2">
+    <item row="10" column="0" colspan="2">
      <widget class="QTextBrowser" name="m_textDetails">
       <property name="enabled">
        <bool>true</bool>
@@ -286,6 +312,19 @@
     <item row="3" column="1">
      <widget class="QLineEdit" name="m_editClientUid"/>
     </item>
+    <item row="7" column="0">
+     <widget class="QLabel" name="textLabel3">
+      <property name="text">
+       <string>Connection Details</string>
+      </property>
+      <property name="wordWrap">
+       <bool>false</bool>
+      </property>
+     </widget>
+    </item>
+    <item row="8" column="0" colspan="2">
+     <widget class="KMessageWidget" name="m_problemMessages"/>
+    </item>
    </layout>
   </widget>
   <widget class="QWizardPage" name="AccountPage">
@@ -293,7 +332,16 @@
     <string>Select Account</string>
    </property>
    <layout class="QHBoxLayout">
-    <property name="margin">
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
      <number>0</number>
     </property>
     <item>
@@ -366,36 +414,25 @@
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
-  <customwidget>
-   <class>QTextBrowser</class>
-   <extends>QTextBrowser</extends>
-   <header>ktextbrowser.h</header>
-  </customwidget>
-  <customwidget>
-   <class>KComboBox</class>
-   <extends>QComboBox</extends>
-   <header>kcombobox.h</header>
-  </customwidget>
   <customwidget>
    <class>KLineEdit</class>
    <extends>QLineEdit</extends>
    <header>klineedit.h</header>
   </customwidget>
   <customwidget>
-   <class>QListWidget</class>
-   <extends>QListWidget</extends>
-   <header>klistwidget.h</header>
+   <class>KUrlRequester</class>
+   <extends>QWidget</extends>
+   <header>kurlrequester.h</header>
   </customwidget>
   <customwidget>
-   <class>KUrlRequester</class>
+   <class>KMessageWidget</class>
    <extends>QFrame</extends>
-   <header>kurlrequester.h</header>
+   <header>kmessagewidget.h</header>
   </customwidget>
   <customwidget>
-   <class>QTabWidget</class>
-   <extends>QTabWidget</extends>
-   <header>ktabwidget.h</header>
-   <container>1</container>
+   <class>KComboBox</class>
+   <extends>QComboBox</extends>
+   <header>kcombobox.h</header>
   </customwidget>
  </customwidgets>
  <tabstops>
diff --git a/kmymoney/plugins/ofx/import/ofxpartner.cpp b/kmymoney/plugins/ofx/import/ofxpartner.cpp
index 745432c35..f402a3bad 100644
--- a/kmymoney/plugins/ofx/import/ofxpartner.cpp
+++ b/kmymoney/plugins/ofx/import/ofxpartner.cpp
@@ -197,20 +197,24 @@ QString extractNodeText(QDomDocument& doc, const QString& name)
   return res;
 }
 
-OfxFiServiceInfo ServiceInfo(const QString& fipid)
+OfxHomeServiceInfo ServiceInfo(const QString& fipid)
 {
-  OfxFiServiceInfo result;
-  memset(&result, 0, sizeof(OfxFiServiceInfo));
+  OfxHomeServiceInfo result;
+  memset(&result.ofxInfo, 0, sizeof(result.ofxInfo));
+  result.ofxValidated = true;
+  result.sslValidated = true;
+  result.lastOfxValidated = QDate::currentDate().toString();
+  result.lastSslValidated = result.lastOfxValidated;
 
   // Hard-coded values for Innovision test server
   if (fipid == "1") {
-    strncpy(result.fid, "00000", OFX_FID_LENGTH - 1);
-    strncpy(result.org, "ReferenceFI", OFX_ORG_LENGTH - 1);
-    strncpy(result.url, "http://ofx.innovision.com", OFX_URL_LENGTH - 1);
-    result.accountlist = 1;
-    result.statements = 1;
-    result.billpay = 1;
-    result.investments = 1;
+    strncpy(result.ofxInfo.fid, "00000", OFX_FID_LENGTH - 1);
+    strncpy(result.ofxInfo.org, "ReferenceFI", OFX_ORG_LENGTH - 1);
+    strncpy(result.ofxInfo.url, "http://ofx.innovision.com", OFX_URL_LENGTH - 1);
+    result.ofxInfo.accountlist = 1;
+    result.ofxInfo.statements = 1;
+    result.ofxInfo.billpay = 1;
+    result.ofxInfo.investments = 1;
 
     return result;
   }
@@ -232,21 +236,31 @@ OfxFiServiceInfo ServiceInfo(const QString& fipid)
     int errl, errc;
     QDomDocument doc;
     if (doc.setContent(stream.readAll(), &msg, &errl, &errc)) {
-      QString fid = extractNodeText(doc, "institution/fid");
-      QString org = extractNodeText(doc, "institution/org");
-      QString url = extractNodeText(doc, "institution/url");
-      strncpy(result.fid, fid.toLatin1(), OFX_FID_LENGTH - 1);
-      strncpy(result.org, org.toLatin1(), OFX_ORG_LENGTH - 1);
-      strncpy(result.url, url.toLatin1(), OFX_URL_LENGTH - 1);
-
-      result.accountlist = true;
-      result.statements = true;
-      result.billpay = false;
-      result.investments = true;
+      const auto fid = extractNodeText(doc, "institution/fid");
+      const auto org = extractNodeText(doc, "institution/org");
+      const auto url = extractNodeText(doc, "institution/url");
+      result.ofxValidated = (extractNodeText(doc, "institution/ofxfail").toUInt() == 0);
+      result.sslValidated = (extractNodeText(doc, "institution/sslfail").toUInt() == 0);
+      result.lastOfxValidated = extractNodeText(doc, "institution/lastofxvalidation");
+      result.lastSslValidated = extractNodeText(doc, "institution/lastsslvalidation");
+
+      strncpy(result.ofxInfo.fid, fid.toLatin1(), OFX_FID_LENGTH - 1);
+      strncpy(result.ofxInfo.org, org.toLatin1(), OFX_ORG_LENGTH - 1);
+      strncpy(result.ofxInfo.url, url.toLatin1(), OFX_URL_LENGTH - 1);
+
+      result.ofxInfo.accountlist = true;
+      result.ofxInfo.statements = true;
+      result.ofxInfo.billpay = false;
+      result.ofxInfo.investments = true;
     }
   }
   else
   {
+    memset(&result.ofxInfo, 0, sizeof(result.ofxInfo));
+    result.ofxValidated = false;
+    result.sslValidated = false;
+    result.lastOfxValidated.clear();
+    result.lastSslValidated.clear();
     qDebug() << "OFX ServiceInfo:" << f.errorString();
   }
   return result;
diff --git a/kmymoney/plugins/ofx/import/ofxpartner.h b/kmymoney/plugins/ofx/import/ofxpartner.h
index 63f00d172..c964d2d17 100644
--- a/kmymoney/plugins/ofx/import/ofxpartner.h
+++ b/kmymoney/plugins/ofx/import/ofxpartner.h
@@ -42,6 +42,14 @@ class TransferJob;
 
 #include <libofx/libofx.h>
 
+struct OfxHomeServiceInfo {
+  OfxFiServiceInfo  ofxInfo;
+  bool ofxValidated;
+  bool sslValidated;
+  QString lastOfxValidated;
+  QString lastSslValidated;
+};
+
 namespace OfxPartner
 {
 /**
@@ -54,7 +62,7 @@ namespace OfxPartner
 void setDirectory(const QString& dir);
 
 void ValidateIndexCache();
-OfxFiServiceInfo ServiceInfo(const QString& fipid);
+OfxHomeServiceInfo ServiceInfo(const QString& fipid);
 QStringList BankNames();
 QStringList FipidForBank(const QString& bank);
 


More information about the kde-doc-english mailing list