diff options
Diffstat (limited to 'src/fetch/z3950connection.cpp')
-rw-r--r-- | src/fetch/z3950connection.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/src/fetch/z3950connection.cpp b/src/fetch/z3950connection.cpp index 27efe51..5bf77ac 100644 --- a/src/fetch/z3950connection.cpp +++ b/src/fetch/z3950connection.cpp @@ -31,7 +31,7 @@ extern "C" { #include <klocale.h> -#include <qfile.h> +#include <tqfile.h> namespace { static const size_t Z3950_DEFAULT_MAX_RECORDS = 20; @@ -40,8 +40,8 @@ namespace { using Tellico::Fetch::Z3950ResultFound; using Tellico::Fetch::Z3950Connection; -Z3950ResultFound::Z3950ResultFound(const QString& s) : QCustomEvent(uid()) - , m_result(QDeepCopy<QString>(s)) { +Z3950ResultFound::Z3950ResultFound(const TQString& s) : TQCustomEvent(uid()) + , m_result(TQDeepCopy<TQString>(s)) { ++Z3950Connection::resultsLeft; } @@ -69,23 +69,23 @@ int Z3950Connection::resultsLeft = 0; // I'm paranoid about user insertions, so just grab 64 // characters at most Z3950Connection::Z3950Connection(Z3950Fetcher* fetcher, - const QString& host, + const TQString& host, uint port, - const QString& dbname, - const QString& sourceCharSet, - const QString& syntax, - const QString& esn) - : QThread() + const TQString& dbname, + const TQString& sourceCharSet, + const TQString& syntax, + const TQString& esn) + : TQThread() , d(new Private()) , m_connected(false) , m_aborted(false) , m_fetcher(fetcher) - , m_host(QDeepCopy<QString>(host)) + , m_host(TQDeepCopy<TQString>(host)) , m_port(port) - , m_dbname(QDeepCopy<QString>(dbname)) - , m_sourceCharSet(QDeepCopy<QString>(sourceCharSet.left(64))) - , m_syntax(QDeepCopy<QString>(syntax)) - , m_esn(QDeepCopy<QString>(esn)) + , m_dbname(TQDeepCopy<TQString>(dbname)) + , m_sourceCharSet(TQDeepCopy<TQString>(sourceCharSet.left(64))) + , m_syntax(TQDeepCopy<TQString>(syntax)) + , m_esn(TQDeepCopy<TQString>(esn)) , m_start(0) , m_limit(Z3950_DEFAULT_MAX_RECORDS) , m_hasMore(false) { @@ -102,13 +102,13 @@ void Z3950Connection::reset() { m_limit = Z3950_DEFAULT_MAX_RECORDS; } -void Z3950Connection::setQuery(const QString& query_) { - m_pqn = QDeepCopy<QString>(query_); +void Z3950Connection::setQuery(const TQString& query_) { + m_pqn = TQDeepCopy<TQString>(query_); } -void Z3950Connection::setUserPassword(const QString& user_, const QString& pword_) { - m_user = QDeepCopy<QString>(user_); - m_password = QDeepCopy<QString>(pword_); +void Z3950Connection::setUserPassword(const TQString& user_, const TQString& pword_) { + m_user = TQDeepCopy<TQString>(user_); + m_password = TQDeepCopy<TQString>(pword_); } void Z3950Connection::run() { @@ -129,7 +129,7 @@ void Z3950Connection::run() { if(errcode != 0) { myDebug() << "Z3950Connection::run() - query error: " << m_pqn << endl; ZOOM_query_destroy(query); - QString s = i18n("Query error!"); + TQString s = i18n("Query error!"); s += ' ' + m_pqn; done(s, MessageHandler::Error); return; @@ -147,16 +147,16 @@ void Z3950Connection::run() { // to get MODS data, that seems a bit odd... // esn only makes sense for marc and grs-1 // if syntax is mods, set esn to mods too - QCString type = "raw"; + TQCString type = "raw"; if(m_syntax == Latin1Literal("mods")) { - m_syntax = QString::fromLatin1("xml"); + m_syntax = TQString::tqfromLatin1("xml"); ZOOM_resultset_option_set(resultSet, "elementSetName", "mods"); type = "xml"; } else { ZOOM_resultset_option_set(resultSet, "elementSetName", m_esn.latin1()); } - ZOOM_resultset_option_set(resultSet, "start", QCString().setNum(m_start)); - ZOOM_resultset_option_set(resultSet, "count", QCString().setNum(m_limit-m_start)); + ZOOM_resultset_option_set(resultSet, "start", TQCString().setNum(m_start)); + ZOOM_resultset_option_set(resultSet, "count", TQCString().setNum(m_limit-m_start)); // search in default syntax, unless syntax is already set if(!m_syntax.isEmpty()) { ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", m_syntax.latin1()); @@ -170,8 +170,8 @@ void Z3950Connection::run() { ZOOM_query_destroy(query); m_connected = false; - QString s = i18n("Connection search error %1: %2").arg(errcode).arg(toString(errmsg)); - if(!QCString(addinfo).isEmpty()) { + TQString s = i18n("Connection search error %1: %2").tqarg(errcode).tqarg(toString(errmsg)); + if(!TQCString(addinfo).isEmpty()) { s += " (" + toString(addinfo) + ")"; } myDebug() << "Z3950Connection::run() - " << s << endl; @@ -181,7 +181,7 @@ void Z3950Connection::run() { const size_t numResults = ZOOM_resultset_size(resultSet); - QString newSyntax = m_syntax; + TQString newSyntax = m_syntax; if(numResults > 0) { myLog() << "Z3950Connection::run() - current syntax is " << m_syntax << " (" << numResults << " results)" << endl; // so now we know that results exist, might have to check syntax @@ -190,10 +190,10 @@ void Z3950Connection::run() { // want raw unless it's mods ZOOM_record_get(rec, type, &len); if(len > 0 && m_syntax.isEmpty()) { - newSyntax = QString::fromLatin1(ZOOM_record_get(rec, "syntax", &len)).lower(); + newSyntax = TQString::tqfromLatin1(ZOOM_record_get(rec, "syntax", &len)).lower(); myLog() << "Z3950Connection::run() - syntax guess is " << newSyntax << endl; if(newSyntax == Latin1Literal("mods") || newSyntax == Latin1Literal("xml")) { - m_syntax = QString::fromLatin1("xml"); + m_syntax = TQString::tqfromLatin1("xml"); ZOOM_resultset_option_set(resultSet, "elementSetName", "mods"); } else if(newSyntax == Latin1Literal("grs-1")) { // if it's defaulting to grs-1, go ahead and change it to try to get a marc @@ -208,7 +208,7 @@ void Z3950Connection::run() { newSyntax != Latin1Literal("unimarc") && newSyntax != Latin1Literal("grs-1")) { myLog() << "Z3950Connection::run() - changing z39.50 syntax to MODS" << endl; - newSyntax = QString::fromLatin1("xml"); + newSyntax = TQString::tqfromLatin1("xml"); ZOOM_resultset_option_set(resultSet, "elementSetName", "mods"); ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", newSyntax.latin1()); rec = ZOOM_resultset_record(resultSet, 0); @@ -216,28 +216,28 @@ void Z3950Connection::run() { if(len == 0) { // change set name back ZOOM_resultset_option_set(resultSet, "elementSetName", m_esn.latin1()); - newSyntax = QString::fromLatin1("usmarc"); // try usmarc + newSyntax = TQString::tqfromLatin1("usmarc"); // try usmarc myLog() << "Z3950Connection::run() - changing z39.50 syntax to USMARC" << endl; ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", newSyntax.latin1()); rec = ZOOM_resultset_record(resultSet, 0); ZOOM_record_get(rec, "raw", &len); } if(len == 0) { - newSyntax = QString::fromLatin1("marc21"); // try marc21 + newSyntax = TQString::tqfromLatin1("marc21"); // try marc21 myLog() << "Z3950Connection::run() - changing z39.50 syntax to MARC21" << endl; ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", newSyntax.latin1()); rec = ZOOM_resultset_record(resultSet, 0); ZOOM_record_get(rec, "raw", &len); } if(len == 0) { - newSyntax = QString::fromLatin1("unimarc"); // try unimarc + newSyntax = TQString::tqfromLatin1("unimarc"); // try unimarc myLog() << "Z3950Connection::run() - changing z39.50 syntax to UNIMARC" << endl; ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", newSyntax.latin1()); rec = ZOOM_resultset_record(resultSet, 0); ZOOM_record_get(rec, "raw", &len); } if(len == 0) { - newSyntax = QString::fromLatin1("grs-1"); // try grs-1 + newSyntax = TQString::tqfromLatin1("grs-1"); // try grs-1 myLog() << "Z3950Connection::run() - changing z39.50 syntax to GRS-1" << endl; ZOOM_resultset_option_set(resultSet, "preferredRecordSyntax", newSyntax.latin1()); rec = ZOOM_resultset_record(resultSet, 0); @@ -256,10 +256,10 @@ void Z3950Connection::run() { // go back to fooling ourselves and calling it mods if(m_syntax == Latin1Literal("xml")) { - m_syntax = QString::fromLatin1("mods"); + m_syntax = TQString::tqfromLatin1("mods"); } if(newSyntax == Latin1Literal("xml")) { - newSyntax = QString::fromLatin1("mods"); + newSyntax = TQString::tqfromLatin1("mods"); } // save syntax change for next time if(m_syntax != newSyntax) { @@ -268,10 +268,10 @@ void Z3950Connection::run() { } if(m_sourceCharSet.isEmpty()) { - m_sourceCharSet = QString::fromLatin1("marc-8"); + m_sourceCharSet = TQString::tqfromLatin1("marc-8"); } - const size_t realLimit = QMIN(numResults, m_limit); + const size_t realLimit = TQMIN(numResults, m_limit); for(size_t i = m_start; i < realLimit && !m_aborted; ++i) { myLog() << "Z3950Connection::run() - grabbing index " << i << endl; @@ -281,7 +281,7 @@ void Z3950Connection::run() { continue; } int len; - QString data; + TQString data; if(m_syntax == Latin1Literal("mods")) { data = toString(ZOOM_record_get(rec, "xml", &len)); } else if(m_syntax == Latin1Literal("grs-1")) { // grs-1 @@ -291,9 +291,9 @@ void Z3950Connection::run() { #if 0 kdWarning() << "Remove debug from z3950connection.cpp" << endl; { - QFile f1(QString::fromLatin1("/tmp/z3950.raw")); + TQFile f1(TQString::tqfromLatin1("/tmp/z3950.raw")); if(f1.open(IO_WriteOnly)) { - QDataStream t(&f1); + TQDataStream t(&f1); t << ZOOM_record_get(rec, "raw", &len); } f1.close(); @@ -302,7 +302,7 @@ void Z3950Connection::run() { data = toXML(ZOOM_record_get(rec, "raw", &len), m_sourceCharSet); } Z3950ResultFound* ev = new Z3950ResultFound(data); - QApplication::postEvent(m_fetcher, ev); + TQApplication::postEvent(m_fetcher, ev); } ZOOM_resultset_destroy(resultSet); @@ -342,8 +342,8 @@ bool Z3950Connection::makeConnection() { ZOOM_connection_destroy(d->conn); m_connected = false; - QString s = i18n("Connection error %1: %2").arg(errcode).arg(toString(errmsg)); - if(!QCString(addinfo).isEmpty()) { + TQString s = i18n("Connection error %1: %2").tqarg(errcode).tqarg(toString(errmsg)); + if(!TQCString(addinfo).isEmpty()) { s += " (" + toString(addinfo) + ")"; } myDebug() << "Z3950Connection::makeConnection() - " << s << endl; @@ -360,7 +360,7 @@ void Z3950Connection::done() { kapp->postEvent(m_fetcher, new Z3950ConnectionDone(m_hasMore)); } -void Z3950Connection::done(const QString& msg_, int type_) { +void Z3950Connection::done(const TQString& msg_, int type_) { checkPendingEvents(); if(m_aborted) { kapp->postEvent(m_fetcher, new Z3950ConnectionDone(m_hasMore)); @@ -377,17 +377,17 @@ void Z3950Connection::checkPendingEvents() { } inline -QCString Z3950Connection::toCString(const QString& text_) { - return iconvRun(text_.utf8(), QString::fromLatin1("utf-8"), m_sourceCharSet); +TQCString Z3950Connection::toCString(const TQString& text_) { + return iconvRun(text_.utf8(), TQString::tqfromLatin1("utf-8"), m_sourceCharSet); } inline -QString Z3950Connection::toString(const QCString& text_) { - return QString::fromUtf8(iconvRun(text_, m_sourceCharSet, QString::fromLatin1("utf-8"))); +TQString Z3950Connection::toString(const TQCString& text_) { + return TQString::fromUtf8(iconvRun(text_, m_sourceCharSet, TQString::tqfromLatin1("utf-8"))); } // static -QCString Z3950Connection::iconvRun(const QCString& text_, const QString& fromCharSet_, const QString& toCharSet_) { +TQCString Z3950Connection::iconvRun(const TQCString& text_, const TQString& fromCharSet_, const TQString& toCharSet_) { #ifdef HAVE_YAZ if(text_.isEmpty()) { return text_; @@ -400,12 +400,12 @@ QCString Z3950Connection::iconvRun(const QCString& text_, const QString& fromCha yaz_iconv_t cd = yaz_iconv_open(toCharSet_.latin1(), fromCharSet_.latin1()); if(!cd) { // maybe it's iso 5426, which we sorta support - QString charSetLower = fromCharSet_.lower(); + TQString charSetLower = fromCharSet_.lower(); charSetLower.remove('-').remove(' '); if(charSetLower == Latin1Literal("iso5426")) { - return iconvRun(Iso5426Converter::toUtf8(text_).utf8(), QString::fromLatin1("utf-8"), toCharSet_); + return iconvRun(Iso5426Converter::toUtf8(text_).utf8(), TQString::tqfromLatin1("utf-8"), toCharSet_); } else if(charSetLower == Latin1Literal("iso6937")) { - return iconvRun(Iso6937Converter::toUtf8(text_).utf8(), QString::fromLatin1("utf-8"), toCharSet_); + return iconvRun(Iso6937Converter::toUtf8(text_).utf8(), TQString::tqfromLatin1("utf-8"), toCharSet_); } kdWarning() << "Z3950Connection::iconvRun() - conversion from " << fromCharSet_ << " to " << toCharSet_ << " is unsupported" << endl; @@ -416,7 +416,7 @@ QCString Z3950Connection::iconvRun(const QCString& text_, const QString& fromCha size_t inlen = text_.length(); size_t outlen = 2 * inlen; // this is enough, right? - QMemArray<char> result0(outlen); + TQMemArray<char> result0(outlen); char* result = result0.data(); int r = yaz_iconv(cd, const_cast<char**>(&input), &inlen, &result, &outlen); @@ -430,7 +430,7 @@ QCString Z3950Connection::iconvRun(const QCString& text_, const QString& fromCha // length is pointer difference size_t len = result - result0; - QCString output = QCString(result0, len+1); + TQCString output = TQCString(result0, len+1); // myDebug() << "-------------------------------------------" << endl; // myDebug() << output << endl; // myDebug() << "-------------------------------------------" << endl; @@ -440,25 +440,25 @@ QCString Z3950Connection::iconvRun(const QCString& text_, const QString& fromCha return text_; } -QString Z3950Connection::toXML(const QCString& marc_, const QString& charSet_) { +TQString Z3950Connection::toXML(const TQCString& marc_, const TQString& charSet_) { #ifdef HAVE_YAZ if(marc_.isEmpty()) { myDebug() << "Z3950Connection::toXML() - empty string" << endl; - return QString::null; + return TQString(); } yaz_iconv_t cd = yaz_iconv_open("utf-8", charSet_.latin1()); if(!cd) { // maybe it's iso 5426, which we sorta support - QString charSetLower = charSet_.lower(); + TQString charSetLower = charSet_.lower(); charSetLower.remove('-').remove(' '); if(charSetLower == Latin1Literal("iso5426")) { - return toXML(Iso5426Converter::toUtf8(marc_).utf8(), QString::fromLatin1("utf-8")); + return toXML(Iso5426Converter::toUtf8(marc_).utf8(), TQString::tqfromLatin1("utf-8")); } else if(charSetLower == Latin1Literal("iso6937")) { - return toXML(Iso6937Converter::toUtf8(marc_).utf8(), QString::fromLatin1("utf-8")); + return toXML(Iso6937Converter::toUtf8(marc_).utf8(), TQString::tqfromLatin1("utf-8")); } kdWarning() << "Z3950Connection::toXML() - conversion from " << charSet_ << " is unsupported" << endl; - return QString::null; + return TQString(); } yaz_marc_t mt = yaz_marc_create(); @@ -474,7 +474,7 @@ QString Z3950Connection::toXML(const QCString& marc_, const QString& charSet_) { #endif if(ok && (len < 25 || len > 100000)) { myDebug() << "Z3950Connection::toXML() - bad length: " << (ok ? len : -1) << endl; - return QString::null; + return TQString(); } #if YAZ_VERSIONL < 0x030000 @@ -485,12 +485,12 @@ QString Z3950Connection::toXML(const QCString& marc_, const QString& charSet_) { int r = yaz_marc_decode_buf(mt, marc_, -1, &result, &len); if(r <= 0) { myDebug() << "Z3950Connection::toXML() - can't decode buffer" << endl; - return QString::null; + return TQString(); } - QString output = QString::fromLatin1("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - output += QString::fromUtf8(QCString(result, len+1), len+1); -// myDebug() << QCString(result) << endl; + TQString output = TQString::tqfromLatin1("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + output += TQString::fromUtf8(TQCString(result, len+1), len+1); +// myDebug() << TQCString(result) << endl; // myDebug() << "-------------------------------------------" << endl; // myDebug() << output << endl; yaz_iconv_close(cd); @@ -498,6 +498,6 @@ QString Z3950Connection::toXML(const QCString& marc_, const QString& charSet_) { return output; #else // no yaz - return QString::null; + return TQString(); #endif } |