summaryrefslogtreecommitdiffstats
path: root/kmymoney2/plugins/ofximport/ofxpartner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/plugins/ofximport/ofxpartner.cpp')
-rw-r--r--kmymoney2/plugins/ofximport/ofxpartner.cpp224
1 files changed, 112 insertions, 112 deletions
diff --git a/kmymoney2/plugins/ofximport/ofxpartner.cpp b/kmymoney2/plugins/ofximport/ofxpartner.cpp
index d36fbb2..9605e5a 100644
--- a/kmymoney2/plugins/ofximport/ofxpartner.cpp
+++ b/kmymoney2/plugins/ofximport/ofxpartner.cpp
@@ -23,15 +23,15 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qdatetime.h>
-#include <qeventloop.h>
-#include <qfileinfo.h>
-#include <qvaluelist.h>
-#include <qapplication.h>
-#include <qdom.h>
-#include <qregexp.h>
-#include <qdir.h>
-#include <qtextstream.h>
+#include <tqdatetime.h>
+#include <tqeventloop.h>
+#include <tqfileinfo.h>
+#include <tqvaluelist.h>
+#include <tqapplication.h>
+#include <tqdom.h>
+#include <tqregexp.h>
+#include <tqdir.h>
+#include <tqtextstream.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -48,26 +48,26 @@
namespace OfxPartner
{
-bool post(const QString& request, const QMap<QString, QString>& attr, const KURL& url, const KURL& filename);
-bool get(const QString& request, const QMap<QString, QString>& attr, const KURL& url, const KURL& filename);
+bool post(const TQString& request, const TQMap<TQString, TQString>& attr, const KURL& url, const KURL& filename);
+bool get(const TQString& request, const TQMap<TQString, TQString>& attr, const KURL& url, const KURL& filename);
-const QString kBankFilename = "ofx-bank-index.xml";
-const QString kCcFilename = "ofx-cc-index.xml";
-const QString kInvFilename = "ofx-inv-index.xml";
+const TQString kBankFilename = "ofx-bank-index.xml";
+const TQString kCcFilename = "ofx-cc-index.xml";
+const TQString kInvFilename = "ofx-inv-index.xml";
#define VER "9"
-static QString directory;
+static TQString directory;
-void setDirectory(const QString& dir)
+void setDirectory(const TQString& dir)
{
directory = dir;
}
-bool needReload(const QFileInfo& i)
+bool needReload(const TQFileInfo& i)
{
return ((!i.isReadable())
- || (i.lastModified().addDays(7) < QDateTime::currentDateTime())
+ || (i.lastModified().addDays(7) < TQDateTime::tqcurrentDateTime())
|| (i.size() < 1024));
}
@@ -78,55 +78,55 @@ void ValidateIndexCache(void)
struct stat filestats;
KURL fname;
- QMap<QString, QString> attr;
+ TQMap<TQString, TQString> attr;
attr["content-type"] = "application/x-www-form-urlencoded";
attr["accept"] = "*/*";
fname = directory + kBankFilename;
- QFileInfo i(fname.path());
+ TQFileInfo i(fname.path());
if(needReload(i))
post("T=1&S=*&R=1&O=0&TEST=0", attr, KURL("http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=" VER), fname);
fname = directory + kCcFilename;
- i = QFileInfo(fname.path());
+ i = TQFileInfo(fname.path());
if(needReload(i))
post("T=2&S=*&R=1&O=0&TEST=0", attr, KURL("http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=" VER) ,fname);
fname = directory + kInvFilename;
- i = QFileInfo(fname.path());
+ i = TQFileInfo(fname.path());
if(needReload(i))
post("T=3&S=*&R=1&O=0&TEST=0", attr, KURL("http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=" VER), fname);
}
-static void ParseFile(QMap<QString, QString>& result, const QString& fileName, const QString& bankName)
+static void ParseFile(TQMap<TQString, TQString>& result, const TQString& fileName, const TQString& bankName)
{
- QFile f(fileName);
+ TQFile f(fileName);
if(f.open(IO_ReadOnly)) {
- QTextStream stream(&f);
- stream.setEncoding(QTextStream::Unicode);
- QString msg;
+ TQTextStream stream(&f);
+ stream.setEncoding(TQTextStream::Unicode);
+ TQString msg;
int errl, errc;
- QDomDocument doc;
+ TQDomDocument doc;
if(doc.setContent(stream.read(), &msg, &errl, &errc)) {
- QDomNodeList olist = doc.elementsByTagName("prov");
+ TQDomNodeList olist = doc.elementsByTagName("prov");
for(int i = 0; i < olist.count(); ++i) {
- QDomNode onode = olist.item(i);
+ TQDomNode onode = olist.item(i);
if(onode.isElement()) {
bool collectGuid = false;
- QDomElement elo = onode.toElement();
- QDomNodeList ilist = onode.childNodes();
+ TQDomElement elo = onode.toElement();
+ TQDomNodeList ilist = onode.childNodes();
for(int j = 0; j < ilist.count(); ++j) {
- QDomNode inode = ilist.item(j);
- QDomElement el = inode.toElement();
+ TQDomNode inode = ilist.item(j);
+ TQDomElement el = inode.toElement();
if(el.tagName() == "name") {
if(bankName.isEmpty())
- result[el.text()] = QString();
+ result[el.text()] = TQString();
else if(el.text() == bankName) {
collectGuid = true;
}
}
if(el.tagName() == "guid" && collectGuid) {
- result[el.text()] = QString();
+ result[el.text()] = TQString();
}
}
}
@@ -136,26 +136,26 @@ static void ParseFile(QMap<QString, QString>& result, const QString& fileName, c
}
}
-QValueList<QString> BankNames(void)
+TQValueList<TQString> BankNames(void)
{
- QMap<QString, QString> result;
+ TQMap<TQString, TQString> result;
// Make sure the index files are up to date
ValidateIndexCache();
- ParseFile(result, directory + kBankFilename, QString());
- ParseFile(result, directory + kCcFilename, QString());
- ParseFile(result, directory + kInvFilename, QString());
+ ParseFile(result, directory + kBankFilename, TQString());
+ ParseFile(result, directory + kCcFilename, TQString());
+ ParseFile(result, directory + kInvFilename, TQString());
// Add Innovision
- result["Innovision"] = QString();
+ result["Innovision"] = TQString();
return result.keys();
}
-QValueList<QString> FipidForBank(const QString& bank)
+TQValueList<TQString> FipidForBank(const TQString& bank)
{
- QMap<QString, QString> result;
+ TQMap<TQString, TQString> result;
ParseFile(result, directory + kBankFilename, bank);
ParseFile(result, directory + kCcFilename, bank);
@@ -163,21 +163,21 @@ QValueList<QString> FipidForBank(const QString& bank)
// the fipid for Innovision is 1.
if ( bank == "Innovision" )
- result["1"] = QString();
+ result["1"] = TQString();
return result.keys();
}
-QString extractNodeText(QDomElement& node, const QString& name)
+TQString extractNodeText(TQDomElement& node, const TQString& name)
{
- QString res;
- QRegExp exp("([^/]+)/?([^/].*)?");
+ TQString res;
+ TQRegExp exp("([^/]+)/?([^/].*)?");
if(exp.search(name) != -1) {
- QDomNodeList olist = node.elementsByTagName(exp.cap(1));
+ TQDomNodeList olist = node.elementsByTagName(exp.cap(1));
if(olist.count()) {
- QDomNode onode = olist.item(0);
+ TQDomNode onode = olist.item(0);
if(onode.isElement()) {
- QDomElement elo = onode.toElement();
+ TQDomElement elo = onode.toElement();
if(exp.cap(2).isEmpty()) {
res = elo.text();
} else {
@@ -189,16 +189,16 @@ QString extractNodeText(QDomElement& node, const QString& name)
return res;
}
-QString extractNodeText(QDomDocument& doc, const QString& name)
+TQString extractNodeText(TQDomDocument& doc, const TQString& name)
{
- QString res;
- QRegExp exp("([^/]+)/?([^/].*)?");
+ TQString res;
+ TQRegExp exp("([^/]+)/?([^/].*)?");
if(exp.search(name) != -1) {
- QDomNodeList olist = doc.elementsByTagName(exp.cap(1));
+ TQDomNodeList olist = doc.elementsByTagName(exp.cap(1));
if(olist.count()) {
- QDomNode onode = olist.item(0);
+ TQDomNode onode = olist.item(0);
if(onode.isElement()) {
- QDomElement elo = onode.toElement();
+ TQDomElement elo = onode.toElement();
if(exp.cap(2).isEmpty()) {
res = elo.text();
} else {
@@ -210,7 +210,7 @@ QString extractNodeText(QDomDocument& doc, const QString& name)
return res;
}
-OfxFiServiceInfo ServiceInfo(const QString& fipid)
+OfxFiServiceInfo ServiceInfo(const TQString& fipid)
{
OfxFiServiceInfo result;
memset(&result, 0, sizeof(OfxFiServiceInfo));
@@ -229,31 +229,31 @@ OfxFiServiceInfo ServiceInfo(const QString& fipid)
return result;
}
- QMap<QString, QString> attr;
+ TQMap<TQString, TQString> attr;
attr["content-type"] = "application/x-www-form-urlencoded";
attr["accept"] = "*/*";
- KURL guidFile(QString("%1fipid-%2.xml").arg(directory).arg(fipid));
+ KURL guidFile(TQString("%1fipid-%2.xml").tqarg(directory).tqarg(fipid));
- // Apparently at some point in time, for VER=6 msn returned an online URL
+ // Aptqparently at some point in time, for VER=6 msn returned an online URL
// to a static error page (http://moneycentral.msn.com/cust404.htm).
// Increasing to VER=9 solved the problem. This may happen again in the
// future.
- QFileInfo i(guidFile.path());
- if(!i.isReadable() || i.lastModified().addDays(7) < QDateTime::currentDateTime())
- get("", attr, KURL(QString("http://moneycentral.msn.com/money/2005/mnynet/service/olsvcupd/OnlSvcBrandInfo.aspx?MSNGUID=&GUID=%1&SKU=3&VER=" VER).arg(fipid)), guidFile);
+ TQFileInfo i(guidFile.path());
+ if(!i.isReadable() || i.lastModified().addDays(7) < TQDateTime::tqcurrentDateTime())
+ get("", attr, KURL(TQString("http://moneycentral.msn.com/money/2005/mnynet/service/olsvcupd/OnlSvcBrandInfo.aspx?MSNGUID=&GUID=%1&SKU=3&VER=" VER).tqarg(fipid)), guidFile);
- QFile f(guidFile.path());
+ TQFile f(guidFile.path());
if(f.open(IO_ReadOnly)) {
- QTextStream stream(&f);
- stream.setEncoding(QTextStream::Unicode);
- QString msg;
+ TQTextStream stream(&f);
+ stream.setEncoding(TQTextStream::Unicode);
+ TQString msg;
int errl, errc;
- QDomDocument doc;
+ TQDomDocument doc;
if(doc.setContent(stream.read(), &msg, &errl, &errc)) {
- QString fid = extractNodeText(doc, "ProviderSettings/FID");
- QString org = extractNodeText(doc, "ProviderSettings/Org");
- QString url = extractNodeText(doc, "ProviderSettings/ProviderURL");
+ TQString fid = extractNodeText(doc, "ProviderSettings/FID");
+ TQString org = extractNodeText(doc, "ProviderSettings/Org");
+ TQString url = extractNodeText(doc, "ProviderSettings/ProviderURL");
strncpy(result.fid, fid.latin1(), OFX_FID_LENGTH-1);
strncpy(result.org, org.latin1(), OFX_ORG_LENGTH-1);
strncpy(result.url, url.latin1(), OFX_URL_LENGTH-1);
@@ -267,22 +267,22 @@ OfxFiServiceInfo ServiceInfo(const QString& fipid)
return result;
}
-bool get(const QString& request, const QMap<QString, QString>& attr, const KURL& url, const KURL& filename)
+bool get(const TQString& request, const TQMap<TQString, TQString>& attr, const KURL& url, const KURL& filename)
{
- QByteArray req(0);
+ TQByteArray req(0);
OfxHttpRequest job("GET", url, req, attr, filename, true);
- return job.error() == QHttp::NoError;
+ return job.error() == TQHttp::NoError;
}
-bool post(const QString& request, const QMap<QString, QString>& attr, const KURL& url, const KURL& filename)
+bool post(const TQString& request, const TQMap<TQString, TQString>& attr, const KURL& url, const KURL& filename)
{
- QByteArray req;
+ TQByteArray req;
req.fill(0, request.length()+1);
req.duplicate(request.ascii(), request.length());
OfxHttpRequest job("POST", url, req, attr, filename, true);
- return job.error() == QHttp::NoError;
+ return job.error() == TQHttp::NoError;
}
} // namespace OfxPartner
@@ -290,16 +290,16 @@ bool post(const QString& request, const QMap<QString, QString>& attr, const KURL
class OfxHttpsRequest::Private
{
public:
- QFile m_fpTrace;
+ TQFile m_fpTrace;
};
-OfxHttpsRequest::OfxHttpsRequest(const QString& type, const KURL &url, const QByteArray &postData, const QMap<QString, QString>& metaData, const KURL& dst, bool showProgressInfo) :
+OfxHttpsRequest::OfxHttpsRequest(const TQString& type, const KURL &url, const TQByteArray &postData, const TQMap<TQString, TQString>& metaData, const KURL& dst, bool showProgressInfo) :
d(new Private),
m_dst(dst)
{
- QDir homeDir(QDir::home());
+ TQDir homeDir(TQDir::home());
if(homeDir.exists("ofxlog.txt")) {
- d->m_fpTrace.setName(QString("%1/ofxlog.txt").arg(QDir::homeDirPath()));
+ d->m_fpTrace.setName(TQString("%1/ofxlog.txt").tqarg(TQDir::homeDirPath()));
d->m_fpTrace.open(IO_WriteOnly | IO_Append);
}
@@ -307,16 +307,16 @@ OfxHttpsRequest::OfxHttpsRequest(const QString& type, const KURL &url, const QBy
m_job->addMetaData("content-type", "Content-type: application/x-ofx" );
if(d->m_fpTrace.isOpen()) {
- QTextStream ts(&d->m_fpTrace);
+ TQTextStream ts(&d->m_fpTrace);
ts << "url: " << url.prettyURL() << "\n";
- ts << "request:\n" << QString(postData) << "\n" << "response:\n";
+ ts << "request:\n" << TQString(postData) << "\n" << "response:\n";
}
- connect(m_job,SIGNAL(result(KIO::Job*)),this,SLOT(slotOfxFinished(KIO::Job*)));
- connect(m_job,SIGNAL(data(KIO::Job*, const QByteArray&)),this,SLOT(slotOfxData(KIO::Job*,const QByteArray&)));
- connect(m_job,SIGNAL(connected(KIO::Job*)),this,SLOT(slotOfxConnected(KIO::Job*)));
+ connect(m_job,TQT_SIGNAL(result(KIO::Job*)),this,TQT_SLOT(slotOfxFinished(KIO::Job*)));
+ connect(m_job,TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)),this,TQT_SLOT(slotOfxData(KIO::Job*,const TQByteArray&)));
+ connect(m_job,TQT_SIGNAL(connected(KIO::Job*)),this,TQT_SLOT(slotOfxConnected(KIO::Job*)));
- qApp->enter_loop();
+ tqApp->enter_loop();
}
OfxHttpsRequest::~OfxHttpsRequest()
@@ -332,11 +332,11 @@ void OfxHttpsRequest::slotOfxConnected(KIO::Job*)
m_file.open(IO_WriteOnly);
}
-void OfxHttpsRequest::slotOfxData(KIO::Job*,const QByteArray& _ba)
+void OfxHttpsRequest::slotOfxData(KIO::Job*,const TQByteArray& _ba)
{
if(m_file.isOpen()) {
- QTextStream ts(&m_file);
- ts << QString(_ba);
+ TQTextStream ts(&m_file);
+ ts << TQString(_ba);
if(d->m_fpTrace.isOpen()) {
d->m_fpTrace.writeBlock(_ba, _ba.size());
@@ -361,11 +361,11 @@ void OfxHttpsRequest::slotOfxFinished(KIO::Job* /* e */)
unlink(m_dst.path());
} else if ( m_job->isErrorPage() ) {
- QString details;
- QFile f( m_dst.path() );
+ TQString details;
+ TQFile f( m_dst.path() );
if ( f.open( IO_ReadOnly ) ) {
- QTextStream stream( &f );
- QString line;
+ TQTextStream stream( &f );
+ TQString line;
while ( !stream.atEnd() ) {
details += stream.readLine(); // line of text excluding '\n'
}
@@ -375,42 +375,42 @@ void OfxHttpsRequest::slotOfxFinished(KIO::Job* /* e */)
unlink(m_dst.path());
}
- qApp->exit_loop();
+ tqApp->exit_loop();
}
-OfxHttpRequest::OfxHttpRequest(const QString& type, const KURL &url, const QByteArray &postData, const QMap<QString, QString>& metaData, const KURL& dst, bool showProgressInfo)
+OfxHttpRequest::OfxHttpRequest(const TQString& type, const KURL &url, const TQByteArray &postData, const TQMap<TQString, TQString>& metaData, const KURL& dst, bool showProgressInfo)
{
- QFile f(dst.path());
- m_error = QHttp::NoError;
- QString errorMsg;
+ TQFile f(dst.path());
+ m_error = TQHttp::NoError;
+ TQString errorMsg;
if(f.open(IO_WriteOnly)) {
- m_job = new QHttp(url.host());
- QHttpRequestHeader header(type, url.encodedPathAndQuery());
+ m_job = new TQHttp(url.host());
+ TQHttpRequestHeader header(type, url.encodedPathAndQuery());
header.setValue("Host", url.host());
- QMap<QString, QString>::const_iterator it;
+ TQMap<TQString, TQString>::const_iterator it;
for(it = metaData.begin(); it != metaData.end(); ++it) {
header.setValue(it.key(), *it);
}
- m_job->request(header, postData, &f);
+ m_job->request(header, postData, TQT_TQIODEVICE(&f));
- connect(m_job, SIGNAL(requestFinished(int, bool)),
- this, SLOT(slotOfxFinished(int, bool)));
+ connect(m_job, TQT_SIGNAL(requestFinished(int, bool)),
+ this, TQT_SLOT(slotOfxFinished(int, bool)));
- qApp->enter_loop();
+ tqApp->enter_loop();
- if(m_error != QHttp::NoError)
+ if(m_error != TQHttp::NoError)
errorMsg = m_job->errorString();
delete m_job;
} else {
- m_error = QHttp::Aborted;
- errorMsg = i18n("Cannot open file %1 for writing").arg(dst.path());
+ m_error = TQHttp::Aborted;
+ errorMsg = i18n("Cannot open file %1 for writing").tqarg(dst.path());
}
- if(m_error != QHttp::NoError) {
+ if(m_error != TQHttp::NoError) {
KMessageBox::error(0, errorMsg, i18n("OFX setup error"));
unlink(dst.path());
}
@@ -421,7 +421,7 @@ void OfxHttpRequest::slotOfxFinished(int, bool rc)
if(rc) {
m_error = m_job->error();
}
- qApp->exit_loop();
+ tqApp->exit_loop();
}
#include "ofxpartner.moc"