Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6d30ce3c

Von cstim vor fast 20 Jahren hinzugefügt

  • ID 6d30ce3cb6496bc7f3957c990662f690a3016d27
  • Vorgänger fe7fb822
  • Nachfolger b02e0d5e

2005-09-16 Christian Stimming <>

  • src/frontends/qbanking/qbanking.cpp: Add static
    QBanking::isPure7BitAscii() to check QStrings for that. Improve
    header documentation. Do not yet fix potentially errorneous latin1
    conversion in QBanking::inputBox but add a huge FIXME comment.
  • src/frontends/qbanking/widgets/qbinputbox.cpp
    (QBInputBox::Validator::validate): Improve checking for digits by
    using only Qt methods on the QString.

git-svn-id: https://devel.aqbanking.de/svn/aqbanking/trunk@614 5c42a225-8b10-0410-9873-89b7810ad06e

Unterschiede anzeigen:

ChangeLog
! remember to do SO_CURRENT++ and SO_AGE++ before next release !
------------------------------------------------------------------------
2005-09-16 Christian Stimming <stimming@tuhh.de>
* src/frontends/qbanking/qbanking.cpp: Add static
QBanking::isPure7BitAscii() to check QStrings for that. Improve
header documentation. Do not yet fix potentially errorneous latin1
conversion in QBanking::inputBox but add a huge FIXME comment.
* src/frontends/qbanking/widgets/qbinputbox.cpp
(QBInputBox::Validator::validate): Improve checking for digits by
using only Qt methods on the QString.
2005/09/09: Martin Preuss<martin@libchipcard.de>
-------------------------------------------------
- implemented job HKUMB (InternalTransfer)
src/frontends/qbanking/qbanking.cpp
GWEN_Buffer_free(buf);
if (ib.exec()==QDialog::Accepted) {
QString s;
int l;
s=ib.getInput();
l=s.length();
if (l && l<maxLen-1) {
memmove(buffer, s.latin1(), l);
buffer[l]=0;
int len=s.length();
if (len && len<maxLen-1) {
// FIXME: QString::latin1() is most probably wrong here!
// This means that the entered string will be passed into
// AQ_BANKING in latin1 encoding, not in utf8. This should
// probably be replaced by s.utf8()! But we need to watch
// out for potentially breaking some people's PINs. For
// those who had Umlauts in their PIN there should at least
// be a commandline-tool available that will accept PINs in
// a configurable encoding for reading, and a different PIN
// for writing. -- cstim, 2005-09-15
memmove(buffer, s.latin1(), len);
buffer[len]=0;
}
else {
DBG_ERROR(0, "Bad pin length");
......
QString text(QString::fromUtf8(chartext));
// Necessary when passing this QString into the macros
const char *latin1text = text.local8Bit();
const char *local8Bit = text.local8Bit();
if (level>_logLevel) {
DBG_NOTICE(0, "Not logging this: %02d: %s (we are at %d)",
level, latin1text, _logLevel);
level, local8Bit, _logLevel);
/* don't log this */
return 0;
}
DBG_INFO(0, "%02d: %s", level, latin1text);
DBG_INFO(0, "%02d: %s", level, local8Bit);
pr=_findProgressWidget(id);
if (pr) {
return pr->log(level, text);
......
int len;
int i;
// FIXME: Is there a specific reason for this extra copying? I
// don't see one. The std::string contains "char", not "unsigned
// char", so the right side below will be converted back to
// "char" when it is appended to the std::char on the left
// side. You should simply return the "utfData" and that's
// it. -- cstim, 2005-09-15
len=utfData.length();
for (i=0; i<len; i++)
result+=(unsigned char)utfData[i];
......
}
bool QBanking::isPure7BitAscii(const QString &input)
{
unsigned stringlength = input.length();
for (unsigned k = 0; k < stringlength; ++k) {
if (input[k].unicode() > 0x7f) {
const char *local8Bit = input.local8Bit();
DBG_DEBUG(0, "String \"%s\" is not pure-7bit-ascii at character %d.\n",
local8Bit, k);
return false;
}
}
return true;
}
src/frontends/qbanking/qbanking.h
const QString &bankName="",
const QString &location="");
/** Convenience function to convert a QString into a std::string
* that will contain UTF-8 encoded characters, as necessary when
* passing strings into aqbanking.
*
* Watch out with the correct encodings! String passed into and
* out of aqbanking are expected in UTF-8, but NOT in Latin-1 or
* similar! */
static std::string QStringToUtf8String(const QString &qs);
/** Convenience function for extracting the GUI part of the
* HTML/cleartext-combi-strings from aqbanking.
*
* If the given string contains a
* &lt;html>html-part...&lt;/html> section, then the "html-part"
* section will be returned. If the given string does not
* contain a section like this, then the string will be returned
* unchanged. */
static std::string guiString(const char *s);
/** Convenience function that returns true if the given string
* consists of pure 7-bit ASCII characters, and false
* otherwise.
*
* In particular, if the given string contains Umlauts, accents,
* or similar, then this will return false. */
static bool isPure7BitAscii(const QString &s);
};
src/frontends/qbanking/widgets/qbinputbox.cpp
QValidator::State
QBInputBox::Validator::validate(QString &input, int &pos) const{
QBInputBox::Validator::validate(QString& input, int &pos) const{
int i;
// The input argument "pos" is unused, but due to the abstract
// function in the parent class it has to be declared anyway.
if (_flags & AB_BANKING_INPUT_FLAGS_NUMERIC) {
const char *p;
p=input.latin1();
if (p) {
while(*p) {
if (!isdigit(*(p++))) {
DBG_DEBUG(0, "Not a digit.\n");
unsigned stringlength = input.length();
for (unsigned k = 0; k < stringlength; ++k) {
if (!(input[k].isDigit())) {
DBG_DEBUG(0, "Not a digit.\n");
return QValidator::Invalid;
}
}
} /* if there is input */
}

Auch abrufbar als: Unified diff