Commit 6e951911 authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Add feature to manually setup OFX app version

Since the application version changes from time to time (once a year?)
and we don't monitor this change, I added a feature that allows the user
to manually setup the application version for Quicken and Money. This
entry is marked as "(Expert)" version in the combo box. Once selected,
the edit field for the version becomes visible.
parent e92a54ec
......@@ -102,7 +102,9 @@ bool KOfxDirectConnectDlg::init(void)
d->m_fpTrace.write(data, strlen(data));
d->m_fpTrace.write("\n", 1);
d->m_fpTrace.write("request:\n", 9);
d->m_fpTrace.write(request, request.size());
QByteArray trcData(request); // make local copy
trcData.replace('\r', "");
d->m_fpTrace.write(trcData, trcData.size());
d->m_fpTrace.write("\n", 1);
d->m_fpTrace.write("response:\n", 10);
}
......@@ -158,11 +160,13 @@ void KOfxDirectConnectDlg::slotOfxData(KIO::Job*, const QByteArray& _ba)
QTextStream out(m_tmpfile);
out << QString(_ba);
setDetails(QString("Got %1 bytes").arg(_ba.size()));
if (d->m_fpTrace.isOpen()) {
d->m_fpTrace.write(_ba, _ba.size());
QByteArray trcData(_ba);
trcData.replace('\r', "");
d->m_fpTrace.write(trcData, trcData.size());
}
setDetails(QString("Got %1 bytes").arg(_ba.size()));
}
void KOfxDirectConnectDlg::slotOfxFinished(KJob* /* e */)
......
......@@ -26,6 +26,7 @@
#include <QCheckBox>
#include <QTabWidget>
#include <QTextStream>
#include <QTimer>
// ----------------------------------------------------------------------------
// KDE Includes
......@@ -69,7 +70,10 @@ KOnlineBankingSetupWizard::KOnlineBankingSetupWizard(QWidget *parent):
{
setupUi(this);
m_appId = new OfxAppVersion(m_applicationCombo, "");
m_applicationEdit->hide();
m_headerVersionEdit->hide();
m_appId = new OfxAppVersion(m_applicationCombo, m_applicationEdit, "");
m_headerVersion = new OfxHeaderVersion(m_headerVersionCombo, "");
// fill the list view with banks
......@@ -84,7 +88,10 @@ KOnlineBankingSetupWizard::KOnlineBankingSetupWizard(QWidget *parent):
//set password field according to KDE preferences
m_editPassword->setPasswordMode(true);
vboxLayout1->insertWidget(0, new KListWidgetSearchLine(autoTab, m_listFi));
KListWidgetSearchLine* searchLine = new KListWidgetSearchLine(autoTab, m_listFi);
vboxLayout1->insertWidget(0, searchLine);
QTimer::singleShot(20, searchLine, SLOT(setFocus()));
OfxPartner::setDirectory(KStandardDirs::locateLocal("appdata", ""));
m_listFi->addItems(OfxPartner::BankNames());
m_fInit = true;
......@@ -101,6 +108,8 @@ KOnlineBankingSetupWizard::KOnlineBankingSetupWizard(QWidget *parent):
connect(m_url, SIGNAL(textChanged(QString)), this, SLOT(checkNextButton()));
connect(m_editUsername, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
connect(m_editPassword, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
connect(m_applicationEdit, SIGNAL(userTextChanged(QString)), this, SLOT(checkNextButton()));
connect(m_applicationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(applicationSelectionChanged()));
// setup text on buttons
setButtonText(QWizard::NextButton, i18nc("Go to next page of the wizard", "&Next"));
......@@ -119,6 +128,12 @@ KOnlineBankingSetupWizard::~KOnlineBankingSetupWizard()
delete d;
}
void KOnlineBankingSetupWizard::applicationSelectionChanged()
{
m_applicationEdit->setVisible(m_appId->appId().endsWith(':'));
checkNextButton();
}
void KOnlineBankingSetupWizard::walletOpened(bool ok)
{
if (ok && (d->m_wallet->hasFolder(KWallet::Wallet::PasswordFolder()) ||
......@@ -147,7 +162,8 @@ void KOnlineBankingSetupWizard::checkNextButton(void)
case 1:
enableButton = !(m_editUsername->text().isEmpty()
|| m_editPassword->text().isEmpty());
|| m_editPassword->text().isEmpty()
|| !m_appId->isValid());
break;
case 2:
......@@ -160,6 +176,8 @@ void KOnlineBankingSetupWizard::checkNextButton(void)
void KOnlineBankingSetupWizard::newPage(int id)
{
QWidget* focus = 0;
bool ok = true;
if ((id - d->m_prevPage) == 1) { // one page forward?
switch (d->m_prevPage) {
......@@ -170,16 +188,22 @@ void KOnlineBankingSetupWizard::newPage(int id)
d->m_wallet = Wallet::openWallet(Wallet::NetworkWallet(), winId(), Wallet::Asynchronous);
connect(d->m_wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
}
focus = m_editUsername;
break;
case 1:
ok = finishLoginPage();
focus = m_listAccount;
break;
case 2:
m_fDone = ok = finishAccountPage();
break;
}
if (!ok) {
if (ok) {
if(focus) {
focus->setFocus();
}
} else {
// force to go back to prev page
back();
}
......@@ -311,7 +335,11 @@ bool KOnlineBankingSetupWizard::finishLoginPage(void)
QRegExp exp("(.*):(.*)");
if (exp.indexIn(appId) != -1) {
strncpy(fi.appid, exp.cap(1).toLatin1(), OFX_APPID_LENGTH - 1);
strncpy(fi.appver, exp.cap(2).toLatin1(), OFX_APPVER_LENGTH - 1);
if(exp.cap(2).isEmpty()) {
strncpy(fi.appver, m_applicationEdit->text().toLatin1(), OFX_APPVER_LENGTH - 1);
} else {
strncpy(fi.appver, exp.cap(2).toLatin1(), OFX_APPVER_LENGTH - 1);
}
} else {
strncpy(fi.appid, "QWIN", OFX_APPID_LENGTH - 1);
strncpy(fi.appver, "1700", OFX_APPVER_LENGTH - 1);
......@@ -491,8 +519,12 @@ bool KOnlineBankingSetupWizard::chosenSettings(MyMoneyKeyValueContainer& setting
settings.deletePair("appId");
settings.deletePair("kmmofx-headerVersion");
QString appId = m_appId->appId();
if (!appId.isEmpty())
if (!appId.isEmpty()) {
if(appId.endsWith(':')) {
appId += m_applicationEdit->text();
}
settings.setValue("appId", appId);
}
QString hVer = m_headerVersion->headerVersion();
if (!hVer.isEmpty())
settings.setValue("kmmofx-headerVersion", hVer);
......
......@@ -83,6 +83,7 @@ protected slots:
void checkNextButton(void);
void newPage(int id);
void walletOpened(bool ok);
void applicationSelectionChanged();
protected:
bool finishAccountPage(void);
......
......@@ -18,6 +18,9 @@
<string>Select Financial Institution</string>
</property>
<layout class="QHBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout">
<item>
......@@ -43,6 +46,9 @@
<string comment="@title type of online banking connection">Automatic</string>
</attribute>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="KListWidget" name="m_listFi"/>
</item>
......@@ -53,6 +59,9 @@
<string comment="@title type of online banking connection">Manual</string>
</attribute>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout">
<item row="2" column="1">
......@@ -124,10 +133,79 @@
<property name="title">
<string>Enter Login Details</string>
</property>
<layout class="QHBoxLayout">
<item>
<layout class="QGridLayout">
<item row="4" column="2" rowspan="2">
<layout class="QGridLayout" name="gridLayout1">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="qLabel1">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Please enter the username and password you use to log into this bank for online banking. Please note that many banks require a separate signup, and assign a separate PIN or password just for online banking from home.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel1_4">
<property name="text">
<string comment="@label account username">Username</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KLineEdit" name="m_editUsername"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel2_3">
<property name="text">
<string>Password</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KLineEdit" name="m_editPassword"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="m_storePassword">
<property name="text">
<string>Store password</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel1_2_3">
<property name="text">
<string>Identify as</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
<item>
<widget class="KComboBox" name="m_applicationCombo"/>
</item>
<item>
<widget class="KLineEdit" name="m_applicationEdit">
<property name="whatsThis">
<string>Expert option to enter the four digit version information of the application</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer4_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -137,106 +215,67 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>120</width>
<height>21</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="qLabel1">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Please enter the username and password you use to log into this bank for online banking. Please note that many banks require a separate signup, and assign a separate PIN or password just for online banking from home.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel1_6">
<property name="text">
<string>Header Version</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="KComboBox" name="m_headerVersionCombo"/>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="textLabel3">
<property name="text">
<string>Connection Details</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KComboBox" name="m_applicationCombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel1_4">
<property name="text">
<string comment="@label account username">Username</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel1_6">
<property name="text">
<string>Header Version</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="KLineEdit" name="m_editPassword"/>
</item>
<item row="1" column="1" colspan="2">
<widget class="KLineEdit" name="m_editUsername"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel1_2_3">
<property name="text">
<string>Identify as</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel2_3">
<property name="text">
<string>Password</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
<item>
<widget class="KLineEdit" name="m_headerVersionEdit"/>
</item>
<item row="7" column="0" colspan="3">
<widget class="KTextBrowser" name="m_textDetails">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="m_storePassword">
<property name="text">
<string>Store password</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</item>
<item row="6" 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="7" column="0" colspan="2">
<widget class="KTextBrowser" name="m_textDetails">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWizardPage" name="AccountPage">
......@@ -244,6 +283,9 @@
<string>Select Account</string>
</property>
<layout class="QHBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout">
<item>
......@@ -315,14 +357,14 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
<class>KTextBrowser</class>
<extends>QTextBrowser</extends>
<header>ktextbrowser.h</header>
</customwidget>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
......@@ -330,9 +372,14 @@
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KTabWidget</class>
......@@ -340,11 +387,6 @@
<header>ktabwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KTextBrowser</class>
<extends>QTextBrowser</extends>
<header>ktextbrowser.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_selectionTab</tabstop>
......
......@@ -74,9 +74,12 @@ KOnlineBankingStatus::KOnlineBankingStatus(const MyMoneyAccount& acc, QWidget *p
m_textBank->setText(bank);
m_textOnlineAccount->setText(account);
m_appId = new OfxAppVersion(m_applicationCombo, settings.value("appId"));
m_appId = new OfxAppVersion(m_applicationCombo, m_applicationEdit, settings.value("appId"));
m_headerVersion = new OfxHeaderVersion(m_headerVersionCombo, settings.value("kmmofx-headerVersion"));
connect(m_applicationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(applicationSelectionChanged()));
m_headerVersionEdit->hide();
int numDays = 60;
QString snumDays = settings.value("kmmofx-numRequestDays");
if (!snumDays.isEmpty())
......@@ -118,6 +121,12 @@ KOnlineBankingStatus::~KOnlineBankingStatus()
delete m_appId;
}
void KOnlineBankingStatus::applicationSelectionChanged()
{
m_applicationEdit->setVisible(m_appId->appId().endsWith(':'));
}
const QString KOnlineBankingStatus::appId(void) const
{
if (m_appId)
......
......@@ -57,6 +57,9 @@ public:
~KOnlineBankingStatus();
const QString appId(void) const;
QString headerVersion(void) const;
protected Q_SLOTS:
void applicationSelectionChanged();
private:
OfxAppVersion* m_appId;
OfxHeaderVersion* m_headerVersion;
......
......@@ -14,7 +14,7 @@
<item>
<widget class="KTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="accountTab">
<attribute name="title">
......@@ -197,7 +197,7 @@
<item row="0" column="1">
<widget class="KComboBox" name="m_applicationCombo"/>
</item>
<item row="0" column="2">
<item row="0" column="4">
<spacer name="spacer4_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -226,6 +226,12 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="KLineEdit" name="m_headerVersionEdit"/>
</item>
<item row="0" column="2">
<widget class="KLineEdit" name="m_applicationEdit"/>
</item>
</layout>
</item>
<item>
......@@ -275,7 +281,7 @@
<string>Last &amp;update</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup2</string>
<string notr="true">buttonGroup2</string>
</attribute>
</widget>
</item>
......@@ -298,7 +304,7 @@
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string>buttonGroup2</string>
<string notr="true">buttonGroup2</string>
</attribute>
</widget>
</item>
......@@ -325,7 +331,7 @@
<string>Pi&amp;ck date</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup2</string>
<string notr="true">buttonGroup2</string>
</attribute>
</widget>
</item>
......@@ -421,9 +427,9 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>
<header>kled.h</header>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
......@@ -431,9 +437,9 @@
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
<class>KLed</class>