📄 lxhbci.cc
字号:
// ****************************************************************************// // LxBank - home-banking for Linux using the HBCI standard// // Author: Franz Zimmermann 83043 Bad Aibling// // Copyright (C) 2002-2003 Franz Zimmermann - arafang@users.sourceforge.net// // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.// // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxHbci.cc,v $// Revision 1.9 2003/05/04 10:46:39 arafang// Bugfix: In line 148 and 247 it must be read ios::binary instead of ios::bin//// Revision 1.8 2003/05/03 16:24:04 arafang// New class LxBankSelectionList. Used in LxRemittanceWorkDialog to present information about all banks of one bank code id.//// Revision 1.7 2003/05/01 14:06:19 arafang// Format of bank code data file changed: was blz.txt - ascii, new blz.bin - binary//// Revision 1.6 2003/04/07 22:44:39 arafang// Put all calls of executeQueue into try/catch clause. Check status of jobs in get accounts.//// Revision 1.5 2003/02/20 02:38:03 arafang// Default args in some constructor implementions removed.//// Revision 1.4 2003/02/08 15:25:21 franz// Mail address changed.//// Revision 1.3 2003/01/26 23:09:41 franz// LxAccountSelectDialog: New method to delete accounts (remove).// Class LxAccountStmtPrint adapted to new account statement view layout.// Account update implemented.//// Revision 1.2 2003/01/03 17:15:32 franz// LxUserAddWizard able to create a DDV-Card user.//// Revision 1.1 2003/01/02 15:04:45 franz// Started to use the openHBCI lib.////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <fstream.h>#include "LxHbci.h"LxHbci::LxHbci(string cfd, string cff, bool readOnly) : HBCI::API(readOnly, false), configDir(cfd), configFile(cff){// genBinaryBankData ("blz.txt", "bankdata.bin"); setupBankListBin (BLZFILE, institutes);// dumpBankData (institutes); configFile = configDir + "/" + configFile; load();}LxHbci::~LxHbci( ){ save();}HBCI::Error LxHbci::load (){ return loadEnvironment (configFile);}HBCI::Error LxHbci::save (){ return saveEnvironment (configFile);}string LxHbci::getConfigDir (){ return configDir;}const BankCodeVec& LxHbci::getBanks (const QString &blzstr){ int blz = blzstr.toInt(); return getBanks (blz);}const BankCodeVec& LxHbci::getBanks (int blz){ IntBankCodeMMap::iterator pos; IntBankCodeMMap::iterator pstart = institutes.lower_bound (blz); IntBankCodeMMap::iterator pend = institutes.upper_bound (blz); instituteBranches.clear(); for (pos = pstart; pos != pend; ++pos){ instituteBranches.push_back (pos->second); } return instituteBranches;}void LxHbci::reportError ( HBCI::Error &err, string msg ){ cerr << endl; cerr << msg << endl; cerr << "ErrorCode = " << err.code() << endl; cerr << "ErrorMsg: " << err.message() << endl; cerr << "ErrorInfo: " << err.info() << endl; cerr << "ErrorString: " << err.errorString() << endl; cerr << "ErrorAdvise: "; switch ( err.advise() ){ case ERROR_ADVISE_DONTKNOW: cerr << "Unknown, unspecified" << endl; break; case ERROR_ADVISE_IGNORE: cerr << "Ignore this error" << endl; break; case ERROR_ADVISE_RETRY: cerr << "Retry the last operation" << endl; break; case ERROR_ADVISE_ABORT: cerr << "It does not make sense to continue or retry" << endl; break; case ERROR_ADVISE_SHUTDOWN: cerr << "Stop the program" << endl; break; default: cerr << "Unknown advice code!" << endl; } cerr << endl;}bool LxHbci::setupBankListBin (string fnam, IntBankCodeMMap &banks){ char nl; ifstream blzFile (fnam.c_str(), ios::binary); if ( blzFile ){ while ( blzFile ) { LxBankCodeData abank(blzFile); banks.insert (pair<const int, LxBankCodeData>(abank.getBankCode(), abank)); blzFile.read (&nl, 1); } blzFile.close(); }else{ cerr << "setupInstituteList: Cannot open bank code list file \"" << fnam << "\"" << endl; return false; } return true;}bool LxHbci::setupBankListTxt (string fnam, IntBankCodeMMap &banks){ char tab = '\t'; ifstream blzFile(fnam.c_str()); string::size_type idx1, idx2; string txtLine; string blz, canceldate, succsqeno, name, zipcode, city, btxname, pz, sqeno; if ( blzFile ){ getline (blzFile, txtLine); while ( blzFile ) { // cout << endl; idx1 = 0; idx2 = txtLine.find ( tab, idx1 ); blz.assign (txtLine, idx1, idx2-idx1); // cout << "blz = '" << blz << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); canceldate.assign (txtLine, idx1, idx2-idx1); // cout << "canceldate = '" << canceldate << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); succsqeno.assign (txtLine, idx1, idx2-idx1); // cout << "succsqeno = '" << succsqeno << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); name.assign (txtLine, idx1, idx2-idx1); // cout << "name = '" << name << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); zipcode.assign (txtLine, idx1, idx2-idx1); // cout << "zipcode = '" << zipcode << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); city.assign (txtLine, idx1, idx2-idx1); // cout << "city = '" << city << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); btxname.assign (txtLine, idx1, idx2-idx1); // cout << "btxname = '" <<btxname << "'\n"; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); pz.assign (txtLine, idx1, idx2-idx1); // cout << "pz = '" << pz << "'\n"; idx1 = idx2+1; idx2 = txtLine.size (); // cerr << "idx1 = " << idx1 << ", idx2 = " << idx2 << endl; sqeno.assign (txtLine, idx1, idx2-idx1); // cout << "sqeno = '" << sqeno << "'\n"; LxBankCodeData abank(blz, sqeno, name, zipcode, city, btxname, pz, canceldate, succsqeno); banks.insert (pair<const int, LxBankCodeData>(abank.getBankCode(), abank)); getline (blzFile, txtLine); } blzFile.close(); }else{ cerr << "setupInstituteList: Cannot open bank code list file \"" << fnam << "\"" << endl; return false; } return true;}bool LxHbci::genBinaryBankData (string txtfile, string binfile){ IntBankCodeMMap banks; if ( setupBankListTxt (txtfile, banks) ){// dumpBankData (banks); ofstream bin (binfile.c_str(), ios::binary); if ( bin ){ IntBankCodeMMap::iterator it = banks.begin(); it->second.binaerDump(bin); for (++it; it != banks.end(); ++it){ bin.write ("\n", 1); it->second.binaerDump(bin); } bin.close(); return true; } } return false;}ostream& LxHbci::dumpBankData (IntBankCodeMMap &banks, ostream &out){ int count; IntBankCodeMMap::iterator it; for (it = banks.begin(), count = 1; it != banks.end(); ++it, ++count){ out << count << " " << it->first << ":"; it->second.dump(cout); out << endl; } return out;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -