diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 19:37:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 19:37:06 +0000 |
commit | 968af1d235ac30d737991b269156bee5dc99d318 (patch) | |
tree | 19b118fa5380087e10cb728be545760791ce0676 /src/knutnet.cpp | |
parent | aea4882f3b37f17c5b56bc77667e683c52254c30 (diff) | |
download | knutclient-968af1d235ac30d737991b269156bee5dc99d318.tar.gz knutclient-968af1d235ac30d737991b269156bee5dc99d318.zip |
TQt4 port knutclient
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knutclient@1238881 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/knutnet.cpp')
-rwxr-xr-x | src/knutnet.cpp | 352 |
1 files changed, 176 insertions, 176 deletions
diff --git a/src/knutnet.cpp b/src/knutnet.cpp index 71bc315..50d9f5c 100755 --- a/src/knutnet.cpp +++ b/src/knutnet.cpp @@ -17,10 +17,10 @@ #include "knutnet.h" -#include <qtextstream.h> -#include <qstring.h> -#include <qcstring.h> -#include <qtimer.h> +#include <tqtextstream.h> +#include <tqstring.h> +#include <tqcstring.h> +#include <tqtimer.h> #include <unistd.h> // for function sleep @@ -31,12 +31,12 @@ /****** CONSTS ***********/ -//const Q_ULONG rBufferLen = 1024; +//const TQ_ULONG rBufferLen = 1024; -KNutNet::KNutNet (const QString upsAddress, const QString upsName, const unsigned short port, unsigned int countRepeat, const unsigned int delay) - : QObject(), m_upsAddress(upsAddress), m_upsName(upsName), m_countRepeat(countRepeat), m_port(port), m_delay(delay) { +KNutNet::KNutNet (const TQString upsAddress, const TQString upsName, const unsigned short port, unsigned int countRepeat, const unsigned int delay) + : TQObject(), m_upsAddress(upsAddress), m_upsName(upsName), m_countRepeat(countRepeat), m_port(port), m_delay(delay) { //qDebug ("KNutNet::KNutNet"); @@ -52,22 +52,22 @@ KNutNet::KNutNet (const QString upsAddress, const QString upsName, const unsigne m_description = false; // popis neni natazen - description is not loaded - m_unConnectTimer = new QTimer( this ); - connect( m_unConnectTimer, SIGNAL(timeout()), this, SLOT(slotTimerReconnect()) ); + m_unConnectTimer = new TQTimer( this ); + connect( m_unConnectTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimerReconnect()) ); m_error = NoError; - m_commandSocket = new QSocket( this ); - connect( m_commandSocket, SIGNAL( hostFound()),this, SLOT( slotHostFound())); - connect( m_commandSocket, SIGNAL( connected()),this,SLOT( slotConnected())); - connect( m_commandSocket, SIGNAL( connectionClosed()),this, SLOT( slotConnectionClosed())); - connect( m_commandSocket, SIGNAL( error(int)),this, SLOT( slotConnectionError(int))); + m_commandSocket = new TQSocket( this ); + connect( m_commandSocket, TQT_SIGNAL( hostFound()),this, TQT_SLOT( slotHostFound())); + connect( m_commandSocket, TQT_SIGNAL( connected()),this,TQT_SLOT( slotConnected())); + connect( m_commandSocket, TQT_SIGNAL( connectionClosed()),this, TQT_SLOT( slotConnectionClosed())); + connect( m_commandSocket, TQT_SIGNAL( error(int)),this, TQT_SLOT( slotConnectionError(int))); } KNutNet::~KNutNet(){ - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; close(); // close connetion when is existed while (m_state == Closing ) { @@ -79,8 +79,8 @@ KNutNet::~KNutNet(){ void KNutNet::close (void) { // std::cout << "--KNutNet::close" << std::endl; - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; m_unConnectTimer->stop(); deleteVars(); @@ -96,8 +96,8 @@ void KNutNet::close (void) { m_commandSocket->clearPendingData (); // data in output buffer will be errased m_commandSocket->close(); // closes the socket - if ( m_commandSocket->state() == QSocket::Closing ) { - connect( m_commandSocket, SIGNAL(delayedCloseFinished()),this,SLOT(slotClosed()) ); + if ( m_commandSocket->state() == TQSocket::Closing ) { + connect( m_commandSocket, TQT_SIGNAL(delayedCloseFinished()),this,TQT_SLOT(slotClosed()) ); } else { slotClosed(); @@ -107,15 +107,15 @@ void KNutNet::close (void) { void KNutNet::slotClosed (void) { - disconnect( m_commandSocket,SIGNAL(delayedCloseFinished()),this, SLOT(slotClosed()) ); + disconnect( m_commandSocket,TQT_SIGNAL(delayedCloseFinished()),this, TQT_SLOT(slotClosed()) ); m_state = Idle; } void KNutNet::open (void) { - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; if ((m_state == Connected) || (m_state == Connecting)) close(); // close connetion when is existed else { @@ -124,7 +124,7 @@ void KNutNet::open (void) { } } if (m_upsAddress != "") { - if ( m_commandSocket->state() != QSocket::Connecting ) { + if ( m_commandSocket->state() != TQSocket::Connecting ) { m_firstConnect=true; m_numberConnection=0; m_state = HostLookup; @@ -136,7 +136,7 @@ void KNutNet::open (void) { } -void KNutNet::newUPS (const QString upsAddress, const QString upsName, const unsigned short port) { +void KNutNet::newUPS (const TQString upsAddress, const TQString upsName, const unsigned short port) { if ((m_state == Connected) || (m_state == Connecting)) { close(); @@ -201,7 +201,7 @@ int KNutNet::getUpsVars ( void) { default: return 0; } - if ( readStatus() != KNutNet::WAIT) return returnValue; + if ( readtqStatus() != KNutNet::WAIT) return returnValue; countWaitRevision--; if (countWaitRevision) sleep (2); } @@ -256,11 +256,11 @@ int KNutNet::getDescription (bool always) { } -int KNutNet::instantCommand (const QString command, const QString userName, const QString password, const bool onlyCommand) { +int KNutNet::instantCommand (const TQString command, const TQString userName, const TQString password, const bool onlyCommand) { m_error=0; // vynulujeme chyby if (m_state == Connected) { - QString outBuffer; + TQString outBuffer; // funkce sendComm sama mastavi promenou error if (onlyCommand) { @@ -301,11 +301,11 @@ int KNutNet::instantCommand (const QString command, const QString userName, cons } -int KNutNet::setVariable (const QString variable, const QString value, const QString userName, const QString password, const bool onlyVariable) { +int KNutNet::setVariable (const TQString variable, const TQString value, const TQString userName, const TQString password, const bool onlyVariable) { m_error=0; // vynulujeme chyby if (m_state == Connected) { - QString outBuffer; - QString setCommand; + TQString outBuffer; + TQString setCommand; switch (m_nutProtocol) { case 1: setCommand = "SET"; @@ -387,10 +387,10 @@ int KNutNet::readIComm (const int seqNumber, upsICommDef& upsIComm) { } -int KNutNet::readVars (const QString name, struct upsVarDef& allVar) { +int KNutNet::readVars (const TQString name, struct upsVarDef& allVar) { m_error =0; if (m_state == Connected) { - QValueVector<upsVarDef>::const_iterator it; + TQValueVector<upsVarDef>::const_iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsVarName == name) { allVar = (*it); @@ -408,7 +408,7 @@ int KNutNet::readVars (const QString name, struct upsVarDef& allVar) { m_error =0; if (m_state == Connected) { int n = 1; - QValueVector<upsVarDef>::const_iterator it; + TQValueVector<upsVarDef>::const_iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((typVar== AllVars) || ((typVar==ROVars) && ((*it).upsVarType)) || @@ -427,11 +427,11 @@ int KNutNet::readVars (const QString name, struct upsVarDef& allVar) { } -QString KNutNet::readStringVar (const QString name) { +TQString KNutNet::readStringVar (const TQString name) { m_error =0; if (m_state == Connected) { - QValueVector<upsVarDef>::const_iterator it; + TQValueVector<upsVarDef>::const_iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsVarName == name) return (*it).upsValue; } @@ -442,18 +442,18 @@ QString KNutNet::readStringVar (const QString name) { } -QString KNutNet::readEnumValueVar (const QString name, const int valueNumber) { +TQString KNutNet::readEnumValueVar (const TQString name, const int valueNumber) { m_error =0; if (m_state == Connected) { // #if defined (KDE_VERSION_MAJOR) // #if KDE_VERSION_MAJOR >= 3 - QValueVector<upsVarDef>::const_iterator it; + TQValueVector<upsVarDef>::const_iterator it; // #else -// QValueList<upsVar>::ConstIterator it; +// TQValueList<upsVar>::ConstIterator it; // #endif // #else -// QValueList<upsVar>::ConstIterator it; +// TQValueList<upsVar>::ConstIterator it; // #endif @@ -474,19 +474,19 @@ QString KNutNet::readEnumValueVar (const QString name, const int valueNumber) { } -int KNutNet::readStatus(void) { +int KNutNet::readtqStatus(void) { m_error=0; return m_upsStatusVar; } -int KNutNet::setActivate ( const QString name ) { +int KNutNet::setActivate ( const TQString name ) { return activate (name,true); } -int KNutNet::unSetActivate ( const QString name ) { +int KNutNet::unSetActivate ( const TQString name ) { return activate (name,false); } @@ -496,11 +496,11 @@ int KNutNet::unSetActivateAll ( void ) { } -int KNutNet::existName ( const QString name ) { +int KNutNet::existName ( const TQString name ) { m_error =0; if (m_state == Connected) { - QValueVector<upsVarDef>::const_iterator it; + TQValueVector<upsVarDef>::const_iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsVarName == name) return 0; } @@ -518,8 +518,8 @@ int KNutNet::existName ( const QString name ) { int KNutNet::version (int countRepeat, const int delay) { - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; m_error =0; do { @@ -528,12 +528,12 @@ int KNutNet::version (int countRepeat, const int delay) { outBuffer=outBuffer.stripWhiteSpace (); if (outBuffer.length() > 0) { - outBuffer = outBuffer.mid(outBuffer.find("upsd")+4); - int n = outBuffer.find("."); + outBuffer = outBuffer.mid(outBuffer.tqfind("upsd")+4); + int n = outBuffer.tqfind("."); if (n > 0) { - QString firstNumber= outBuffer.left(n); - QString secondNumber= outBuffer.mid(n+1); - int n = secondNumber.find("."); + TQString firstNumber= outBuffer.left(n); + TQString secondNumber= outBuffer.mid(n+1); + int n = secondNumber.tqfind("."); if (n > 0) { bool ok; secondNumber = secondNumber.left(n); @@ -567,20 +567,20 @@ int KNutNet::version (int countRepeat, const int delay) { -int KNutNet::getFirstUpsName (QString& firstUpsName) { - QCString inBuffer; - QString outBuffer; - QString varOutBuffer; +int KNutNet::getFirstUpsName (TQString& firstUpsName) { + TQCString inBuffer; + TQString outBuffer; + TQString varOutBuffer; int lenString; m_error=0; inBuffer = "LIST UPS\n"; if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST UPS"))) { - QString inLine, upsNameRet, varName, value; + TQString inLine, upsNameRet, varName, value; int key, typeValue; bool beginList = false; - QTextIStream varInputStream(&outBuffer); + TQTextIStream varInputStream(&outBuffer); while (!(inLine = varInputStream.readLine()).isNull()) { key = parseLine (inLine, upsNameRet, varName, value, typeValue, lenString); switch (key) { @@ -612,9 +612,9 @@ int KNutNet::getFirstUpsName (QString& firstUpsName) { -int KNutNet::setKey (const QString line) { +int KNutNet::setKey (const TQString line) { - QString myLine=line.stripWhiteSpace(); + TQString myLine=line.stripWhiteSpace(); if (myLine == "OK") return OK; if (myLine == "ERR") return ERR; if (myLine == "BEGIN") return BEGIN; @@ -633,16 +633,16 @@ int KNutNet::setKey (const QString line) { return NONE; } -QString KNutNet::parseValue (const QString line) { +TQString KNutNet::parseValue (const TQString line) { if (line.isEmpty()) return ""; if (line[0] != "\"") { - if ((m_posChar=line.find(' ')) == -1) return line; + if ((m_posChar=line.tqfind(' ')) == -1) return line; else return line.left(m_posChar+1); } else { int len = line.length(); - QString outString = ""; + TQString outString = ""; for (int i=1; i < len; i++) { if ( line[i] == "\\") { if ((i+1) <len) { @@ -665,18 +665,18 @@ QString KNutNet::parseValue (const QString line) { return ""; } -int KNutNet::parseTypeValue (QString line, int& lenString ) { +int KNutNet::parseTypeValue (TQString line, int& lenString ) { int ret=0; - QString word; + TQString word; lenString = 0; if (line.isEmpty()) return 0; - QTextIStream inputStream(&line); + TQTextIStream inputStream(&line); while (!inputStream.atEnd()) { inputStream >> word; if (word == "RW") ret += RW_FLAG; if (word == "ENUM") ret += ENUM_FLAG; - if (word.find("STRING:") != -1) { + if (word.tqfind("STRING:") != -1) { word = word.mid(7); ret += STRING_FLAG; lenString = word.toInt(); @@ -686,9 +686,9 @@ int KNutNet::parseTypeValue (QString line, int& lenString ) { } -int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QString& value, int& typeValue, int& lenString) { +int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQString& value, int& typeValue, int& lenString) { int posChar; - QString word1, word2, word3; + TQString word1, word2, word3; int key1, key2, key3; line = line.stripWhiteSpace(); @@ -700,7 +700,7 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin if (line.isEmpty()) return NONE; - if ((posChar=line.find(' ')) == -1) { + if ((posChar=line.tqfind(' ')) == -1) { if (setKey(line) == OK) return OK; else return NONE; } @@ -718,7 +718,7 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin value = parseValue(line); return key1; default: - if ((posChar=line.find(' ')) == -1) return NONE; + if ((posChar=line.tqfind(' ')) == -1) return NONE; word2 = line.left(posChar); key2 = setKey( word2); line = line.mid(posChar+1); @@ -740,7 +740,7 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin return key1; } - if ((posChar=line.find(' ')) == -1) return NONE; + if ((posChar=line.tqfind(' ')) == -1) return NONE; word3 = line.left(posChar); key3 = setKey( word3); @@ -787,7 +787,7 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin return BEGIN_LIST_CMD; } if (key3 == ENUM) { - if ((posChar=line.find(' ')) == -1) return NONE; + if ((posChar=line.tqfind(' ')) == -1) return NONE; upsName = line.left(posChar); line=line.mid(posChar+1); varName = line.stripWhiteSpace(); @@ -809,7 +809,7 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin return END_LIST_CMD; } if (key3 == ENUM) { - if ((posChar=line.find(' ')) == -1) return NONE; + if ((posChar=line.tqfind(' ')) == -1) return NONE; upsName = line.left(posChar); line=line.mid(posChar+1); varName = line.stripWhiteSpace(); @@ -824,25 +824,25 @@ int KNutNet::parseLine(QString& line, QString& upsName ,QString& varName, QStrin } -int KNutNet::newDescription (const QCString inBuffer, QString& upsDescription) { - QString outBuffer; +int KNutNet::newDescription (const TQCString inBuffer, TQString& upsDescription) { + TQString outBuffer; if (!(m_error=getUpsData (inBuffer,outBuffer))) { outBuffer=outBuffer.stripWhiteSpace (); - QString word1, word2, word3; + TQString word1, word2, word3; - if ((m_posChar = outBuffer.find(' ')) == -1) + if ((m_posChar = outBuffer.tqfind(' ')) == -1) word1 = outBuffer; else { word1 = outBuffer.left(m_posChar); word2 = outBuffer.mid(m_posChar+1); } if (word1 == "DESC") { - if ((m_posChar = word2.find('\"')) == -1) word3=""; + if ((m_posChar = word2.tqfind('\"')) == -1) word3=""; else { word3 = word2.mid(m_posChar+1); - if ((m_posChar = word3.find('\"')) != -1) word3=word3.left(m_posChar); + if ((m_posChar = word3.tqfind('\"')) != -1) word3=word3.left(m_posChar); } if (!word3.isEmpty()) upsDescription=word3; } @@ -857,9 +857,9 @@ int KNutNet::newDescription (const QCString inBuffer, QString& upsDescription) void KNutNet::cleanConnecting (void) { - Q_ULONG rMaxLen; - QCString recvBuffer(rBufferLen); - Q_LONG lengthInputData; + TQ_ULONG rMaxLen; + TQCString recvBuffer(rBufferLen); + TQ_LONG lengthInputData; int n = 0; while (m_commandSocket->bytesAvailable() > 0) { @@ -876,15 +876,15 @@ void KNutNet::cleanConnecting (void) { } -int KNutNet::getUpsData (const QCString sBuffer, QString& rBuffer, const QCString endString) { +int KNutNet::getUpsData (const TQCString sBuffer, TQString& rBuffer, const TQCString endString) { //rbufferLen a sbufferLen are maximal value of buffers - QCString recvBuffer(rBufferLen); - Q_LONG lengthInputData; - Q_ULONG dataAvailable; + TQCString recvBuffer(rBufferLen); + TQ_LONG lengthInputData; + TQ_ULONG dataAvailable; - QMutexLocker getUpsDataLocker( &m_getUpsDataMutex ); + TQMutexLocker getUpsDataLocker( &m_getUpsDataMutex ); cleanConnecting(); // first we clean input TCP buffer @@ -911,8 +911,8 @@ int KNutNet::getUpsData (const QCString sBuffer, QString& rBuffer, const QCStrin // recvBuffer[lengthInputData]='\0'; //Problem is that - //for 64bit environment is Q_LONG defined like _int64 and - //for other environments is Q_LONG defined like long + //for 64bit environment is TQ_LONG defined like _int64 and + //for other environments is TQ_LONG defined like long @@ -920,14 +920,14 @@ int KNutNet::getUpsData (const QCString sBuffer, QString& rBuffer, const QCStrin rBuffer.append(recvBuffer.data()); // adds reading data to main input buffer if (endString.isEmpty()) endRecv = false; else { - if (recvBuffer.findRev(endString) == -1) { + if (recvBuffer.tqfindRev(endString.data()) == -1) { //doesn't find right end of input data if (m_commandSocket->bytesAvailable() == 0) m_commandSocket->waitForMore(1000); if (m_commandSocket->bytesAvailable() > 0) endRecv=true; // makes other cyckle og while else endRecv=false; } //finds right end of input data - else endRecv = false; // we have found what we want to find + else endRecv = false; // we have found what we want to tqfind } } while (endRecv); return 0; // all is OK @@ -935,8 +935,8 @@ int KNutNet::getUpsData (const QCString sBuffer, QString& rBuffer, const QCStrin - void KNutNet::setRWVars (const QString varName, const bool valueType, const int varMax, QValueVector<QString>* enumValues) { - QValueVector<upsVarDef>::iterator it; + void KNutNet::setRWVars (const TQString varName, const bool valueType, const int varMax, TQValueVector<TQString>* enumValues) { + TQValueVector<upsVarDef>::iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsVarName == varName) { @@ -949,7 +949,7 @@ int KNutNet::getUpsData (const QCString sBuffer, QString& rBuffer, const QCStrin } } -void KNutNet::upsSetType (struct upsVarDef& upsVar, const QString name, const QString value) { +void KNutNet::upsSetType (struct upsVarDef& upsVar, const TQString name, const TQString value) { if (((m_nutVariables = 2) && (name == "STATUS")) || ((m_nutVariables = 2) && (name == "ups.status"))) upsVar.upsVarActivate=true; @@ -968,12 +968,12 @@ void KNutNet::upsSetType (struct upsVarDef& upsVar, const QString name, const QS void KNutNet::deleteVars (void) { // #if defined (KDE_VERSION_MAJOR) // #if KDE_VERSION_MAJOR >= 3 - QValueVector<upsVarDef>::iterator it; + TQValueVector<upsVarDef>::iterator it; // #else -// QValueList<upsVar>::Iterator it; +// TQValueList<upsVar>::Iterator it; // #endif // #else -// QValueList<upsVar>::Iterator it; +// TQValueList<upsVar>::Iterator it; // #endif for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsEnumValues != 0) { @@ -985,10 +985,10 @@ void KNutNet::deleteVars (void) { m_listIComms.clear(); } -void KNutNet::genStatusFlags (QString value) { +void KNutNet::genStatusFlags (TQString value) { m_upsStatusVar = 0; - QTextIStream inputStream(&value); - QString word; + TQTextIStream inputStream(&value); + TQString word; while (!inputStream.atEnd()) { inputStream >> word; if (word == "OFF") m_upsStatusVar +=OFF; @@ -1016,11 +1016,11 @@ void KNutNet::genStatusFlags (QString value) { int KNutNet::getDescription1 (bool always) { if (always || (! m_description)) { - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; - QValueVector<upsVarDef>::iterator itv; - QValueVector<upsICommDef>::iterator itc; + TQValueVector<upsVarDef>::iterator itv; + TQValueVector<upsICommDef>::iterator itc; for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) { //nacteme promenou inBuffer = "VARDESC " + (*itv).upsVarName + "\n"; @@ -1050,16 +1050,16 @@ int KNutNet::getDescription1 (bool always) { int KNutNet::getDescription2 (bool always) { if (always || (! m_description)) { - QCString inBuffer; - QString outBuffer; - QString upsNameRet; - QString varName; - QString value; + TQCString inBuffer; + TQString outBuffer; + TQString upsNameRet; + TQString varName; + TQString value; int typeValue; int lenString; - QValueVector<upsVarDef>::iterator itv; - QValueVector<upsICommDef>::iterator itc; + TQValueVector<upsVarDef>::iterator itv; + TQValueVector<upsICommDef>::iterator itc; for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) { //nacteme promenou inBuffer = "GET DESC " + m_upsName + " " + (*itv).upsVarName+"\n"; @@ -1127,9 +1127,9 @@ int KNutNet::getDescription2 (bool always) { int KNutNet::getUpsVars1 ( void) { // getUpsVars nacte promene a jejich typ // vraci kod chyby nebo 0 pokud je vse v poradku - QCString inBuffer; - QString outBuffer; - QString varOutBuffer; + TQCString inBuffer; + TQString outBuffer; + TQString varOutBuffer; upsVarDef upsVar; upsICommDef upsIComm; @@ -1145,8 +1145,8 @@ int KNutNet::getUpsVars1 ( void) { outBuffer=outBuffer.stripWhiteSpace (); if (outBuffer.length() > 0) { // precteme data - QTextIStream inputStream(&outBuffer); - QString word; + TQTextIStream inputStream(&outBuffer); + TQString word; int count =1 ; while (!inputStream.atEnd()) { inputStream >> word; @@ -1193,8 +1193,8 @@ int KNutNet::getUpsVars1 ( void) { outBuffer=outBuffer.stripWhiteSpace(); if (!outBuffer.isEmpty()) { // precteme data - QTextIStream inputStream(&outBuffer); - QString word; + TQTextIStream inputStream(&outBuffer); + TQString word; int count =1 ; bool valueType; int varMax; @@ -1229,8 +1229,8 @@ int KNutNet::getUpsVars1 ( void) { if (!(m_error=getUpsData (inBuffer,varOutBuffer))) { varOutBuffer=varOutBuffer.stripWhiteSpace(); if ( !outBuffer.isEmpty() ) { - QTextIStream varInputStream(&varOutBuffer); - QString word1, word2, word3; + TQTextIStream varInputStream(&varOutBuffer); + TQString word1, word2, word3; varInputStream >> word1; varInputStream >> word2; varInputStream >> word3; @@ -1267,7 +1267,7 @@ int KNutNet::getUpsVars1 ( void) { else return m_error; // ********** ENUM / STRING ****************** - QValueVector<QString>* enumString=0; + TQValueVector<TQString>* enumString=0; if (!valueType) { // nacteme enum hodnoty inBuffer="ENUM "; @@ -1281,26 +1281,26 @@ int KNutNet::getUpsVars1 ( void) { if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END\n"))) { // varOutBuffer.stripWhiteSpace(); nemuze provest protoze bychom si odstranili konce radek if (!varOutBuffer.isEmpty()) { - QString inLine, word1, word2; - QTextIStream varInputStream(&varOutBuffer); + TQString inLine, word1, word2; + TQTextIStream varInputStream(&varOutBuffer); int inCountLine=1; while (!(inLine = varInputStream.readLine()).isNull()) { inLine=inLine.stripWhiteSpace(); - if ((m_posChar=inLine.find(' ')) == -1) word1=inLine; + if ((m_posChar=inLine.tqfind(' ')) == -1) word1=inLine; else { word1=inLine.left(m_posChar); inLine = inLine.mid(m_posChar+1); } if (word1.isEmpty()) { m_error = UnknownFormat; return m_error; } if (inCountLine == 1) { - if ((m_posChar=inLine.find(' ')) == -1) word2=inLine; + if ((m_posChar=inLine.tqfind(' ')) == -1) word2=inLine; else word2=inLine.left(m_posChar); if (word1 =="ENUM") { if (word2 != word) { m_error = UnknownFormat; return m_error; } varMax=0; inCountLine++; - enumString = new QValueVector<QString>; + enumString = new TQValueVector<TQString>; enumString->clear(); } else { @@ -1313,10 +1313,10 @@ int KNutNet::getUpsVars1 ( void) { else { if (word1 == "END") break; if (word1 != "OPTION") { m_error = UnknownFormat; return m_error; } - if ((m_posChar = inLine.find('\"')) == -1) word2 = ""; + if ((m_posChar = inLine.tqfind('\"')) == -1) word2 = ""; else { word2 = inLine.mid(m_posChar+1); - if ((m_posChar=word2.find('\"')) != -1) word2 = word2.left(m_posChar); + if ((m_posChar=word2.tqfind('\"')) != -1) word2 = word2.left(m_posChar); } enumString->push_back(word2); varMax++; @@ -1352,8 +1352,8 @@ int KNutNet::getUpsVars1 ( void) { outBuffer=outBuffer.stripWhiteSpace (); if ( !outBuffer.isEmpty() ) { // precteme data - QTextIStream inputStream(&outBuffer); - QString word; + TQTextIStream inputStream(&outBuffer); + TQString word; int count =1 ; while (!inputStream.atEnd()) { inputStream >> word; @@ -1392,9 +1392,9 @@ int KNutNet::getUpsVars1 ( void) { int KNutNet::getUpsVars2 ( void) { - QCString inBuffer; - QString outBuffer; - QString varOutBuffer; + TQCString inBuffer; + TQString outBuffer; + TQString varOutBuffer; upsVarDef upsVar; upsICommDef upsIComm; int key; @@ -1402,12 +1402,12 @@ int KNutNet::getUpsVars2 ( void) { int lenString; int varMax=0; - QValueVector<QString>* enumString=0; + TQValueVector<TQString>* enumString=0; inBuffer = "LIST VAR " + m_upsName + "\n"; if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST VAR"))) { - QString inLine, upsNameRet, varName, varNameRet, value; + TQString inLine, upsNameRet, varName, varNameRet, value; bool beginList = false; - QTextIStream varInputStream(&outBuffer); + TQTextIStream varInputStream(&outBuffer); while (!(inLine = varInputStream.readLine()).isNull()) { key = parseLine (inLine, upsNameRet, varName, value, typeValue, lenString); @@ -1434,14 +1434,14 @@ int KNutNet::getUpsVars2 ( void) { inBuffer = "LIST ENUM " + m_upsName + " " + varName +"\n"; if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END LIST ENUM"))) { bool beginEnumList = false; - QTextIStream varInputStream(&varOutBuffer); + TQTextIStream varInputStream(&varOutBuffer); while (!(inLine = varInputStream.readLine()).isNull()) { key = parseLine (inLine, upsNameRet, varName, value, typeValue, lenString); switch (key) { case BEGIN_LIST_ENUM: beginEnumList = true; varMax=0; - enumString = new QValueVector<QString>; + enumString = new TQValueVector<TQString>; enumString->clear(); upsVar.upsEnumValues=enumString; break; @@ -1503,12 +1503,12 @@ int KNutNet::getUpsVars2 ( void) { inBuffer = "LIST CMD " + m_upsName + "\n"; if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST CMD"))) { - QString inLine, upsNameRet, varName, value; + TQString inLine, upsNameRet, varName, value; int key, typeValue; bool beginList = false; //std::cout << "CMD Buffer " << outBuffer << std::endl; - QTextIStream varInputStream(&outBuffer); + TQTextIStream varInputStream(&outBuffer); while (!(inLine = varInputStream.readLine()).isNull()) { key = parseLine (inLine, upsNameRet, varName, value, typeValue, lenString); //std::cout << "CMD Line " << inLine << std::endl; @@ -1545,10 +1545,10 @@ int KNutNet::getUpsVars2 ( void) { int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars = false jen activate - QString endChar; - QCString inBuffer; - QString outBuffer; - QValueVector<upsVarDef>::iterator it; + TQString endChar; + TQCString inBuffer; + TQString outBuffer; + TQValueVector<upsVarDef>::iterator it; // Nacte hodnotu promenych // reads value of variables @@ -1582,8 +1582,8 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars emit getVarDesc (m_numberVars, numberVar); if ( !outBuffer.isEmpty() ) { - QTextIStream inputStream(&outBuffer); - QString word1, word2, word3 ; + TQTextIStream inputStream(&outBuffer); + TQString word1, word2, word3 ; inputStream >> word1; inputStream >> word2; if (inputStream.atEnd()) { // neexistuje treti cast VALUE @@ -1604,7 +1604,7 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars if (word1 == "ANS") { // answer - odpoved // odstranime pripadne jmeno upsky - if ((m_posChar = word2.find('@')) != -1) word2 = word2.left(m_posChar); + if ((m_posChar = word2.tqfind('@')) != -1) word2 = word2.left(m_posChar); if ( word2 != (*it).upsVarName ) { m_error=UnknownAnswer; return m_error;// neni to odpoved na spravnou promennou @@ -1643,16 +1643,16 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars int KNutNet::getUpsValues2 (const bool allVars ) {// allVars = true vse; allVars = false jen activate - QString varName; - QString upsNameRet; - QString value; + TQString varName; + TQString upsNameRet; + TQString value; int typeValue; int lenString; // reads value of variables - QCString inBuffer; - QString outBuffer; - QValueVector<upsVarDef>::iterator it; + TQCString inBuffer; + TQString outBuffer; + TQValueVector<upsVarDef>::iterator it; emit getVarDesc (m_numberVars, 0); int numberVar = 0; @@ -1704,11 +1704,11 @@ int KNutNet::getUpsValues2 (const bool allVars ) {// allVars = true vse; allVars } -int KNutNet::sendComm (const QString command, const QString arg1, const QString arg2, const bool useUpsName) { +int KNutNet::sendComm (const TQString command, const TQString arg1, const TQString arg2, const bool useUpsName) { int localError; // nenastavi promenou error ale nenuluje ji - QCString inBuffer; - QString outBuffer; + TQCString inBuffer; + TQString outBuffer; switch (m_nutProtocol) { case 1: @@ -1728,8 +1728,8 @@ int KNutNet::sendComm (const QString command, const QString arg1, const QString if (!(localError=getUpsData (inBuffer,outBuffer))) { outBuffer=outBuffer.stripWhiteSpace(); - QTextIStream inputStream(&outBuffer); - QString word1, word2; + TQTextIStream inputStream(&outBuffer); + TQString word1, word2; inputStream >> word1; inputStream >> word2; if (word1.isEmpty()) return UnknownAnswer; // zadna odpoved @@ -1744,10 +1744,10 @@ int KNutNet::sendComm (const QString command, const QString arg1, const QString } -int KNutNet::activate ( const QString name, const bool setActivate ) { +int KNutNet::activate ( const TQString name, const bool setActivate ) { m_error =0; if (m_state == Connected) { - QValueVector<upsVarDef>::iterator it; + TQValueVector<upsVarDef>::iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { if ((*it).upsVarName == name) { (*it).upsVarActivate = setActivate; @@ -1763,7 +1763,7 @@ int KNutNet::activate ( const QString name, const bool setActivate ) { int KNutNet::activateAll ( const bool setActivate ) { m_error =0; if (m_state == Connected) { - QValueVector<upsVarDef>::iterator it; + TQValueVector<upsVarDef>::iterator it; for (it = m_listVars.begin(); it != m_listVars.end(); it++) { (*it).upsVarActivate = setActivate; } @@ -1773,12 +1773,12 @@ int KNutNet::activateAll ( const bool setActivate ) { } -int KNutNet::upsTranslateError (const QString string) { +int KNutNet::upsTranslateError (const TQString string) { if (string == "VAR-NOT-SUPPORTED") return VarNotSupported; if (string == "VAR-UNKNOWN") return VarUnknown; if (string == "ACCESS-DENIED") return AccessDenied; - if (string == "PASSWORD-REQUIRED") return PasswordRequired; + if (string == "PASSWORD-RETQUIRED") return PasswordRequired; if (string == "PASSWORD-INCORRECT") return PasswordIncorrect; if (string == "UNKNOWN-UPS") return UnknownUps; if (string == "ALREADY-LOGGED_IN") return AlreadyLoggedIn; @@ -1807,7 +1807,7 @@ int KNutNet::upsTranslateError (const QString string) { return UnknownErr; } -int KNutNet::upsOldTranslateError (const QString string) { +int KNutNet::upsOldTranslateError (const TQString string) { if (string == "NOT-SUPPORTED") return VarNotSupported; if (string == "UNKNOWN") return VarUnknown; if (string == "DATA-STALE") return DataStale; @@ -1823,13 +1823,13 @@ void KNutNet::slotConnectionError(int error) { m_state = ConnectError; m_unConnectTimer->stop(); - if (error == QSocket::ErrHostNotFound) { + if (error == TQSocket::ErrHostNotFound) { error = NoSuchHost; emit connectionError(error); return; } //connection was refused // no connection - if ((error == QSocket::ErrConnectionRefused) && (m_commandSocket->state()==QSocket::Idle)) { + if ((error == TQSocket::ErrConnectionRefused) && (m_commandSocket->state()==TQSocket::Idle)) { if (m_firstConnect) { if (m_numberConnection < m_countRepeat) { m_numberConnection++; @@ -1852,15 +1852,15 @@ void KNutNet::slotConnectionError(int error) { } return; } - if (error == QSocket::ErrConnectionRefused) { + if (error == TQSocket::ErrConnectionRefused) { error = ConnectionRefused; -// std::cout << "--KNutNet::connection error ErrConnectionRefused " << QSocket::Idle << " - " << error << std::endl; +// std::cout << "--KNutNet::connection error ErrConnectionRefused " << TQSocket::Idle << " - " << error << std::endl; emit connectionError(error); return; } - if (error == QSocket::ErrSocketRead) { + if (error == TQSocket::ErrSocketRead) { error = SocketReadErr; -// std::cout << "--KNutNet::connection error QSocket::ErrSocketRead " << error << std::endl; +// std::cout << "--KNutNet::connection error TQSocket::ErrSocketRead " << error << std::endl; emit connectionError(error); return; } @@ -1875,7 +1875,7 @@ void KNutNet::slotConnected(void) { m_error=NutProtocolVarErr; m_state = Closing; m_commandSocket->close(); - while (m_commandSocket->state() == QSocket::Closing) { + while (m_commandSocket->state() == TQSocket::Closing) { sleep (100); } m_state = ConnectError; @@ -1888,7 +1888,7 @@ void KNutNet::slotConnected(void) { // upsd server doesn't support any ups m_state = Closing; m_commandSocket->close(); - while (m_commandSocket->state() == QSocket::Closing) { + while (m_commandSocket->state() == TQSocket::Closing) { sleep (100); } m_state = ConnectError; @@ -1927,12 +1927,12 @@ void KNutNet::slotTimerReconnect(void) { // std::cout << "--KNutNet::slotTimerReconnect" << std::endl; m_unConnectTimer->stop(); - if (m_commandSocket->state()==QSocket::Idle) { - //std::cout << "--KNutNet::slotTimerReconnect QSOcket::Idle" << std::endl; + if (m_commandSocket->state()==TQSocket::Idle) { + //std::cout << "--KNutNet::slotTimerReconnect TQSOcket::Idle" << std::endl; emit tryRepeatFirstConnection(m_numberConnection); // std::cout << "KNutNet::emit-tryRepeatFirstConnection" << std::endl; m_state=Connecting; - if ( m_commandSocket->state() != QSocket::Connecting ) + if ( m_commandSocket->state() != TQSocket::Connecting ) m_commandSocket->connectToHost(m_upsAddress,m_port); } } |