Hi all,
I have made an ugly hack for czech bank "FIO banka" to plugin ofximport. It
was possible to use most of the code as is. Unfortunatelly the bank does not
use standard login procedure and everything is made in URL. Patch is included.
Petr Bravenec
diff --git a/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlg.cpp b/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlg.cpp
index 5dfa65a..2fef405 100644
--- a/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlg.cpp
+++ b/kmymoney/plugins/ofximport/dialogs/kofxdirectconnectdlg.cpp
@@ -110,7 +110,11 @@ bool KOfxDirectConnectDlg::init(void)
}
qDebug("creating job");
- m_job = KIO::http_post(m_connector.url(), request, KIO::HideProgressInfo);
+ if (m_connector.url().startsWith("https://www.fio.cz/ib_api",Qt::CaseInsensitive)) {
+ m_job = KIO::get(m_connector.url(), KIO::NoReload, KIO::HideProgressInfo);
+ } else {
+ m_job = KIO::http_post(m_connector.url(), request, KIO::HideProgressInfo);
+ }
// open the temp file. We come around here twice if init() is called twice
if (m_tmpfile) {
diff --git a/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.cpp b/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.cpp
index 8739ad4..1ed24a4 100644
--- a/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.cpp
+++ b/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.cpp
@@ -102,6 +102,7 @@ KOnlineBankingSetupWizard::KOnlineBankingSetupWizard(QWidget *parent):
connect(m_bankName, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
connect(m_url, SIGNAL(textChanged(QString)), this, SLOT(checkNextButton()));
connect(m_editUsername, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
+ connect(m_editUsername, SIGNAL(userTextChanged(QString)), this, SLOT(usernameChanged()));
connect(m_editPassword, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
// setup text on buttons
@@ -133,6 +134,13 @@ void KOnlineBankingSetupWizard::walletOpened(bool ok)
m_storePassword->setEnabled(d->m_walletIsOpen);
}
+void KOnlineBankingSetupWizard::usernameChanged()
+{
+ if (m_fiobanka) {
+ finishFiPage();
+ }
+}
+
void KOnlineBankingSetupWizard::checkNextButton(void)
{
bool enableButton = false;
@@ -224,6 +232,22 @@ bool KOnlineBankingSetupWizard::finishFiPage(void)
// Print them to the text browser
QString message = QString("<p>Fipid: %1<br/>").arg(*it_fipid);
+ // Hack for FIO Banka
+ if (QString(info.org) == "FIO Banka") {
+ m_fiobanka = true;
+ QString username = m_editUsername->text();
+ QString url = QString("https://www.fio.cz/ib_api/rest/last/%1/transactions.ofx").arg(username);
+ strncpy(info.url, url.toLatin1().data(), OFX_URL_LENGTH - 1);
+ m_applicationCombo->setEnabled(false);
+ m_headerVersionCombo->setEnabled(false);
+ m_editPassword->setEnabled(false);
+ m_editPassword->setText("password");
+ } else {
+ m_applicationCombo->setEnabled(false);
+ m_headerVersionCombo->setEnabled(false);
+ m_editPassword->setEnabled(false);
+ }
+
// If the bank supports retrieving statements
if (info.accountlist) {
m_bankInfo.push_back(info);
diff --git a/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.h b/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.h
index ac1a28d..f6aee86 100644
--- a/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.h
+++ b/kmymoney/plugins/ofximport/dialogs/konlinebankingsetupwizard.h
@@ -83,6 +83,7 @@ protected slots:
void checkNextButton(void);
void newPage(int id);
void walletOpened(bool ok);
+ void usernameChanged();
protected:
bool finishAccountPage(void);
@@ -103,6 +104,7 @@ private:
QList<OfxFiServiceInfo>::const_iterator m_it_info;
bool m_fDone;
bool m_fInit;
+ bool m_fiobanka;
OfxAppVersion* m_appId;
OfxHeaderVersion* m_headerVersion;
};
diff --git a/kmymoney/plugins/ofximport/ofxpartner.cpp b/kmymoney/plugins/ofximport/ofxpartner.cpp
index 038d989..757b8a9 100644
--- a/kmymoney/plugins/ofximport/ofxpartner.cpp
+++ b/kmymoney/plugins/ofximport/ofxpartner.cpp
@@ -198,6 +198,7 @@ QStringList BankNames(void)
// Add Innovision
result["Innovision"].clear();
+ result["FIO Banka"].clear();
return QStringList() << result.keys();
}
@@ -216,6 +217,10 @@ QStringList FipidForBank(const QString& bank)
if (bank == "Innovision")
result["1"].clear();
+ // the fipid for FIO Banka is 2.
+ if (bank == "FIO Banka")
+ result["2"].clear();
+
return QStringList() << result.keys();
}
@@ -279,6 +284,20 @@ OfxFiServiceInfo ServiceInfo(const QString& fipid)
return result;
}
+
+ // Hard-coded values for FIO Banka
+ if (fipid == "2") {
+ strncpy(result.fid, "00000", OFX_FID_LENGTH - 1);
+ strncpy(result.org, "FIO Banka", OFX_ORG_LENGTH - 1);
+ strncpy(result.url, "https://www.fio.cz/ib_api/rest/last/%1/transactions.ofx", OFX_URL_LENGTH - 1);
+ result.accountlist = 1;
+ result.statements = 1;
+ result.billpay = 0;
+ result.investments = 0;
+
+ return result;
+ }
+
QMap<QString, QString> attr;
KUrl guidFile(QString("%1fipid-%2.xml").arg(directory).arg(fipid));
@@ -392,7 +411,11 @@ OfxHttpsRequest::OfxHttpsRequest(const QString& type, const KUrl &url, const QBy
if (!showProgressInfo)
jobFlags = KIO::HideProgressInfo;
- m_job = KIO::http_post(url, postData, jobFlags);
+ if (url.host() == "www.fio.cz") {
+ m_job = KIO::get(url, KIO::NoReload, jobFlags);
+ } else {
+ m_job = KIO::http_post(url, postData, jobFlags);
+ }
m_job->addMetaData("content-type", "Content-type: application/x-ofx");
if (d->m_fpTrace.isOpen()) {
_______________________________________________
KMyMoney-devel mailing list
KMyMoney-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmymoney-devel