diff options
Diffstat (limited to 'src/z3950connection.cpp')
-rw-r--r-- | src/z3950connection.cpp | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/z3950connection.cpp b/src/z3950connection.cpp index ada2a1d..567253e 100644 --- a/src/z3950connection.cpp +++ b/src/z3950connection.cpp @@ -28,7 +28,7 @@ #include "iso5426converter.h" #include "iso6937converter.h" -#include <qapplication.h> +#include <ntqapplication.h> #include <config.h> @@ -43,7 +43,7 @@ extern "C" #include <klocale.h> -#include <qfile.h> +#include <ntqfile.h> namespace { @@ -53,8 +53,8 @@ namespace using KBibTeX::Z3950ResultFound; using KBibTeX::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; } @@ -85,24 +85,24 @@ int Z3950Connection::resultsLeft = 0; // since the character set goes into a yaz api call // I'm paranoid about user insertions, so just grab 64 // characters at most -Z3950Connection::Z3950Connection( QObject* fetcher, - const QString& host, +Z3950Connection::Z3950Connection( TQObject* fetcher, + 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 ) @@ -122,16 +122,16 @@ void Z3950Connection::reset() m_limit = Z3950_DEFAULT_MAX_RECORDS; } -void Z3950Connection::setQuery( const QString& query_, unsigned int numHits ) +void Z3950Connection::setQuery( const TQString& query_, unsigned int numHits ) { - m_pqn = QDeepCopy<QString>( query_ ); + m_pqn = TQDeepCopy<TQString>( query_ ); m_limit = Z3950_DEFAULT_MAX_RECORDS < numHits ? Z3950_DEFAULT_MAX_RECORDS : numHits; } -void Z3950Connection::setUserPassword( const QString& user_, const QString& pword_ ) +void Z3950Connection::setUserPassword( const TQString& user_, const TQString& pword_ ) { - m_user = QDeepCopy<QString>( user_ ); - m_password = QDeepCopy<QString>( pword_ ); + m_user = TQDeepCopy<TQString>( user_ ); + m_password = TQDeepCopy<TQString>( pword_ ); } void Z3950Connection::run() @@ -155,7 +155,7 @@ void Z3950Connection::run() { kdDebug() << "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; @@ -174,10 +174,10 @@ 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::fromLatin1( "xml" ); ZOOM_resultset_option_set( resultSet, "elementSetName", "mods" ); type = "xml"; } @@ -185,8 +185,8 @@ void Z3950Connection::run() { 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() ) { @@ -202,8 +202,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" ).arg( errcode ).arg( toString( errmsg ) ); + if ( !TQCString( addinfo ).isEmpty() ) { s += " (" + toString( addinfo ) + ")"; } @@ -214,7 +214,7 @@ void Z3950Connection::run() const size_t numResults = ZOOM_resultset_size( resultSet ); - QString newSyntax = m_syntax; + TQString newSyntax = m_syntax; if ( numResults > 0 ) { kdDebug() << "Z3950Connection::run() - current syntax is " << m_syntax << " (" << numResults << " results)" << endl; @@ -225,11 +225,11 @@ void Z3950Connection::run() ZOOM_record_get( rec, type, &len ); if ( len > 0 && m_syntax.isEmpty() ) { - newSyntax = QString::fromLatin1( ZOOM_record_get( rec, "syntax", &len ) ).lower(); + newSyntax = TQString::fromLatin1( ZOOM_record_get( rec, "syntax", &len ) ).lower(); kdDebug() << "Z3950Connection::run() - syntax guess is " << newSyntax << endl; if ( newSyntax == Latin1Literal( "mods" ) || newSyntax == Latin1Literal( "xml" ) ) { - m_syntax = QString::fromLatin1( "xml" ); + m_syntax = TQString::fromLatin1( "xml" ); ZOOM_resultset_option_set( resultSet, "elementSetName", "mods" ); } else if ( newSyntax == Latin1Literal( "grs-1" ) ) @@ -247,7 +247,7 @@ void Z3950Connection::run() newSyntax != Latin1Literal( "grs-1" ) ) { kdDebug() << "Z3950Connection::run() - changing z39.50 syntax to MODS" << endl; - newSyntax = QString::fromLatin1( "xml" ); + newSyntax = TQString::fromLatin1( "xml" ); ZOOM_resultset_option_set( resultSet, "elementSetName", "mods" ); ZOOM_resultset_option_set( resultSet, "preferredRecordSyntax", newSyntax.latin1() ); rec = ZOOM_resultset_record( resultSet, 0 ); @@ -256,7 +256,7 @@ void Z3950Connection::run() { // change set name back ZOOM_resultset_option_set( resultSet, "elementSetName", m_esn.latin1() ); - newSyntax = QString::fromLatin1( "usmarc" ); // try usmarc + newSyntax = TQString::fromLatin1( "usmarc" ); // try usmarc kdDebug() << "Z3950Connection::run() - changing z39.50 syntax to USMARC" << endl; ZOOM_resultset_option_set( resultSet, "preferredRecordSyntax", newSyntax.latin1() ); rec = ZOOM_resultset_record( resultSet, 0 ); @@ -264,7 +264,7 @@ void Z3950Connection::run() } if ( len == 0 ) { - newSyntax = QString::fromLatin1( "marc21" ); // try marc21 + newSyntax = TQString::fromLatin1( "marc21" ); // try marc21 kdDebug() << "Z3950Connection::run() - changing z39.50 syntax to MARC21" << endl; ZOOM_resultset_option_set( resultSet, "preferredRecordSyntax", newSyntax.latin1() ); rec = ZOOM_resultset_record( resultSet, 0 ); @@ -272,7 +272,7 @@ void Z3950Connection::run() } if ( len == 0 ) { - newSyntax = QString::fromLatin1( "unimarc" ); // try unimarc + newSyntax = TQString::fromLatin1( "unimarc" ); // try unimarc kdDebug() << "Z3950Connection::run() - changing z39.50 syntax to UNIMARC" << endl; ZOOM_resultset_option_set( resultSet, "preferredRecordSyntax", newSyntax.latin1() ); rec = ZOOM_resultset_record( resultSet, 0 ); @@ -280,7 +280,7 @@ void Z3950Connection::run() } if ( len == 0 ) { - newSyntax = QString::fromLatin1( "grs-1" ); // try grs-1 + newSyntax = TQString::fromLatin1( "grs-1" ); // try grs-1 kdDebug() << "Z3950Connection::run() - changing z39.50 syntax to GRS-1" << endl; ZOOM_resultset_option_set( resultSet, "preferredRecordSyntax", newSyntax.latin1() ); rec = ZOOM_resultset_record( resultSet, 0 ); @@ -301,25 +301,25 @@ 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::fromLatin1( "mods" ); } if ( newSyntax == Latin1Literal( "xml" ) ) { - newSyntax = QString::fromLatin1( "mods" ); + newSyntax = TQString::fromLatin1( "mods" ); } // save syntax change for next time if ( m_syntax != newSyntax ) { - qApp->postEvent( m_fetcher, new Z3950SyntaxChange( newSyntax ) ); + tqApp->postEvent( m_fetcher, new Z3950SyntaxChange( newSyntax ) ); m_syntax = newSyntax; } if ( m_sourceCharSet.isEmpty() ) { - m_sourceCharSet = QString::fromLatin1( "marc-8" ); + m_sourceCharSet = TQString::fromLatin1( "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 ) { @@ -331,7 +331,7 @@ void Z3950Connection::run() continue; } int len; - QString data; + TQString data; if ( m_syntax == Latin1Literal( "mods" ) ) { data = toString( ZOOM_record_get( rec, "xml", &len ) ); @@ -346,10 +346,10 @@ void Z3950Connection::run() #if 0 kdWarning() << "Remove debug from z3950connection.cpp" << endl; { - QFile f1( QString::fromLatin1( "/tmp/z3950.raw" ) ); + TQFile f1( TQString::fromLatin1( "/tmp/z3950.raw" ) ); if ( f1.open( IO_WriteOnly ) ) { - QDataStream t( &f1 ); + TQDataStream t( &f1 ); t << ZOOM_record_get( rec, "raw", &len ); } f1.close(); @@ -358,7 +358,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 ); @@ -402,8 +402,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" ).arg( errcode ).arg( toString( errmsg ) ); + if ( !TQCString( addinfo ).isEmpty() ) { s += " (" + toString( addinfo ) + ")"; } @@ -419,19 +419,19 @@ bool Z3950Connection::makeConnection() void Z3950Connection::done() { checkPendingEvents(); - qApp->postEvent( m_fetcher, new Z3950ConnectionDone( m_hasMore ) ); + tqApp->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 ) { - qApp->postEvent( m_fetcher, new Z3950ConnectionDone( m_hasMore ) ); + tqApp->postEvent( m_fetcher, new Z3950ConnectionDone( m_hasMore ) ); } else { - qApp->postEvent( m_fetcher, new Z3950ConnectionDone( m_hasMore, msg_, type_ ) ); + tqApp->postEvent( m_fetcher, new Z3950ConnectionDone( m_hasMore, msg_, type_ ) ); } } @@ -445,19 +445,19 @@ void Z3950Connection::checkPendingEvents() } inline -QCString Z3950Connection::toCString( const QString& text_ ) +TQCString Z3950Connection::toCString( const TQString& text_ ) { - return iconvRun( text_.utf8(), QString::fromLatin1( "utf-8" ), m_sourceCharSet ); + return iconvRun( text_.utf8(), TQString::fromLatin1( "utf-8" ), m_sourceCharSet ); } inline -QString Z3950Connection::toString( const QCString& text_ ) +TQString Z3950Connection::toString( const TQCString& text_ ) { - return QString::fromUtf8( iconvRun( text_, m_sourceCharSet, QString::fromLatin1( "utf-8" ) ) ); + return TQString::fromUtf8( iconvRun( text_, m_sourceCharSet, TQString::fromLatin1( "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() ) @@ -474,15 +474,15 @@ QCString Z3950Connection::iconvRun( const QCString& text_, const QString& fromCh 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::fromLatin1( "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::fromLatin1( "utf-8" ), toCharSet_ ); } kdWarning() << "Z3950Connection::iconvRun() - conversion from " << fromCharSet_ << " to " << toCharSet_ << " is unsupported" << endl; @@ -493,7 +493,7 @@ QCString Z3950Connection::iconvRun( const QCString& text_, const QString& fromCh 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 ); @@ -508,7 +508,7 @@ QCString Z3950Connection::iconvRun( const QCString& text_, const QString& fromCh // length is pointer difference size_t len = result - result0; - QCString output = QCString( result0, len + 1 ); + TQCString output = TQCString( result0, len + 1 ); // kdDebug() << "-------------------------------------------" << endl; // kdDebug() << output << endl; // kdDebug() << "-------------------------------------------" << endl; @@ -518,31 +518,31 @@ QCString Z3950Connection::iconvRun( const QCString& text_, const QString& fromCh 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() ) { kdDebug() << "Z3950Connection::toXML() - empty string" << endl; - return QString::null; + return TQString::null; } 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::fromLatin1( "utf-8" ) ); } else if ( charSetLower == Latin1Literal( "iso6937" ) ) { - return toXML( Iso6937Converter::toUtf8( marc_ ).utf8(), QString::fromLatin1( "utf-8" ) ); + return toXML( Iso6937Converter::toUtf8( marc_ ).utf8(), TQString::fromLatin1( "utf-8" ) ); } kdWarning() << "Z3950Connection::toXML() - conversion from " << charSet_ << " is unsupported" << endl; - return QString::null; + return TQString::null; } yaz_marc_t mt = yaz_marc_create(); @@ -559,7 +559,7 @@ QString Z3950Connection::toXML( const QCString& marc_, const QString& charSet_ ) if ( ok && ( len < 25 || len > 100000 ) ) { kdDebug() << "Z3950Connection::toXML() - bad length: " << ( ok ? len : -1 ) << endl; - return QString::null; + return TQString::null; } #if YAZ_VERSIONL < 0x030000 @@ -571,12 +571,12 @@ QString Z3950Connection::toXML( const QCString& marc_, const QString& charSet_ ) if ( r <= 0 ) { kdDebug() << "Z3950Connection::toXML() - can't decode buffer" << endl; - return QString::null; + return TQString::null; } - QString output = QString::fromLatin1( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); - output += QString::fromUtf8( QCString( result, len + 1 ), len + 1 ); -// kdDebug() << QCString(result) << endl; + TQString output = TQString::fromLatin1( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); + output += TQString::fromUtf8( TQCString( result, len + 1 ), len + 1 ); +// kdDebug() << TQCString(result) << endl; // kdDebug() << "-------------------------------------------" << endl; // kdDebug() << output << endl; yaz_iconv_close( cd ); @@ -584,6 +584,6 @@ QString Z3950Connection::toXML( const QCString& marc_, const QString& charSet_ ) return output; #else // no yaz - return QString::null; + return TQString::null; #endif } |