Added controlled conversions to char* instead of automatic ascii conversions.

The definition of -UTQT_NO_ASCII_CAST is no longer needed.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/2/head
Slávek Banko 6 years ago
parent 8eb947399e
commit 54bb877d90
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -58,7 +58,7 @@ include( ConfigureChecks.cmake )
###### global compiler settings ###### global compiler settings
add_definitions( -DHAVE_CONFIG_H -UTQT_NO_ASCII_CAST ) add_definitions( -DHAVE_CONFIG_H )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )

@ -403,14 +403,14 @@ void KNutMainWindow::showUpsData (void) {
m_existLowHighXfer = false; m_existLowHighXfer = false;
} }
else { else {
m_lowXfer = atof(nutStringVar); m_lowXfer = nutStringVar.toFloat();
nutStringVar = m_activeUpsInfo->upsNet->readStringVar(m_activeUpsInfo->highxferVar); nutStringVar = m_activeUpsInfo->upsNet->readStringVar(m_activeUpsInfo->highxferVar);
if (nutStringVar.isEmpty()) { if (nutStringVar.isEmpty()) {
m_highXfer = -1; m_highXfer = -1;
m_existLowHighXfer = false; m_existLowHighXfer = false;
} }
else { else {
m_highXfer = atof(nutStringVar); m_highXfer = nutStringVar.toFloat();
m_existLowHighXfer = true; m_existLowHighXfer = true;
} }
} }

@ -1023,7 +1023,7 @@ int KNutNet::getDescription1 (bool always) {
TQValueVector<upsICommDef>::iterator itc; TQValueVector<upsICommDef>::iterator itc;
for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) { for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) {
//nacteme promenou //nacteme promenou
inBuffer = "VARDESC " + (*itv).upsVarName + "\n"; inBuffer = "VARDESC " + (*itv).upsVarName.local8Bit() + "\n";
if ((m_error = newDescription (inBuffer, (*itv).upsDescription))) { if ((m_error = newDescription (inBuffer, (*itv).upsDescription))) {
//netMutex.unlock(); //netMutex.unlock();
// netMutex=false; // netMutex=false;
@ -1032,7 +1032,7 @@ int KNutNet::getDescription1 (bool always) {
} }
for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) { for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) {
//nacteme promenou //nacteme promenou
inBuffer = "INSTCMDDESC "+(*itc).upsCommName+"\n"; inBuffer = "INSTCMDDESC "+(*itc).upsCommName.local8Bit()+"\n";
if ((m_error = newDescription (inBuffer, (*itc).upsDescription))) { if ((m_error = newDescription (inBuffer, (*itc).upsDescription))) {
//netMutex.unlock(); //netMutex.unlock();
//netMutex=false; //netMutex=false;
@ -1062,7 +1062,7 @@ int KNutNet::getDescription2 (bool always) {
TQValueVector<upsICommDef>::iterator itc; TQValueVector<upsICommDef>::iterator itc;
for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) { for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) {
//nacteme promenou //nacteme promenou
inBuffer = "GET DESC " + m_upsName + " " + (*itv).upsVarName+"\n"; inBuffer = "GET DESC " + m_upsName.local8Bit() + " " + (*itv).upsVarName.local8Bit()+"\n";
if (!(m_error=getUpsData (inBuffer,outBuffer))) { if (!(m_error=getUpsData (inBuffer,outBuffer))) {
outBuffer=outBuffer.stripWhiteSpace (); outBuffer=outBuffer.stripWhiteSpace ();
@ -1091,7 +1091,7 @@ int KNutNet::getDescription2 (bool always) {
} }
for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) { for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) {
//nacteme promenou //nacteme promenou
inBuffer = "GET CMDDESC " + m_upsName + " " + (*itc).upsCommName+"\n"; inBuffer = "GET CMDDESC " + m_upsName.local8Bit() + " " + (*itc).upsCommName.local8Bit()+"\n";
if (!(m_error=getUpsData (inBuffer,outBuffer))) { if (!(m_error=getUpsData (inBuffer,outBuffer))) {
outBuffer=outBuffer.stripWhiteSpace (); outBuffer=outBuffer.stripWhiteSpace ();
if ( !outBuffer.isEmpty() ) { if ( !outBuffer.isEmpty() ) {
@ -1136,7 +1136,7 @@ int KNutNet::getUpsVars1 ( void) {
// init vars and lists // init vars and lists
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTVARS "; inBuffer="LISTVARS ";
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n"); inBuffer.append("\n");
} }
else inBuffer ="LISTVARS\n"; else inBuffer ="LISTVARS\n";
@ -1184,7 +1184,7 @@ int KNutNet::getUpsVars1 ( void) {
// *********** RW VARIABLES // *********** RW VARIABLES
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTRW "; inBuffer="LISTRW ";
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n"); inBuffer.append("\n");
} }
else inBuffer ="LISTRW\n"; else inBuffer ="LISTRW\n";
@ -1220,10 +1220,10 @@ int KNutNet::getUpsVars1 ( void) {
// Zpracujeme polozku v tabulce // Zpracujeme polozku v tabulce
// zjistime informaci o promene // zjistime informaci o promene
inBuffer="VARTYPE "; inBuffer="VARTYPE ";
inBuffer.append(word); inBuffer.append(word.local8Bit());
if (!m_upsName.isEmpty()) { if (!m_upsName.isEmpty()) {
inBuffer.append("@"); // pokud upsName neni je vzdy nastaveno na null inBuffer.append("@"); // pokud upsName neni je vzdy nastaveno na null
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
} }
inBuffer.append("\n"); inBuffer.append("\n");
if (!(m_error=getUpsData (inBuffer,varOutBuffer))) { if (!(m_error=getUpsData (inBuffer,varOutBuffer))) {
@ -1271,11 +1271,11 @@ int KNutNet::getUpsVars1 ( void) {
if (!valueType) { if (!valueType) {
// nacteme enum hodnoty // nacteme enum hodnoty
inBuffer="ENUM "; inBuffer="ENUM ";
inBuffer.append(word); inBuffer.append(word.local8Bit());
// pokud existuje pridame jmeno UPS-ky // pokud existuje pridame jmeno UPS-ky
if (!m_upsName.isEmpty()) { if (!m_upsName.isEmpty()) {
inBuffer.append("@"); inBuffer.append("@");
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
} }
inBuffer.append("\n"); inBuffer.append("\n");
if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END\n"))) { if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END\n"))) {
@ -1343,7 +1343,7 @@ int KNutNet::getUpsVars1 ( void) {
// *************** INSTANT COMMAND // *************** INSTANT COMMAND
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTINSTCMD "; inBuffer="LISTINSTCMD ";
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n"); inBuffer.append("\n");
} }
else inBuffer ="LISTINSTCMD\n"; else inBuffer ="LISTINSTCMD\n";
@ -1403,7 +1403,7 @@ int KNutNet::getUpsVars2 ( void) {
int varMax=0; int varMax=0;
TQValueVector<TQString>* enumString=0; TQValueVector<TQString>* enumString=0;
inBuffer = "LIST VAR " + m_upsName + "\n"; inBuffer = "LIST VAR " + m_upsName.local8Bit() + "\n";
if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST VAR"))) { if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST VAR"))) {
TQString inLine, upsNameRet, varName, varNameRet, value; TQString inLine, upsNameRet, varName, varNameRet, value;
bool beginList = false; bool beginList = false;
@ -1420,7 +1420,7 @@ int KNutNet::getUpsVars2 ( void) {
upsSetType(upsVar, varName, value); upsSetType(upsVar, varName, value);
if (varName == "ups.status") genStatusFlags(value); if (varName == "ups.status") genStatusFlags(value);
inBuffer = "GET TYPE " + m_upsName + " " + varName +"\n"; inBuffer = "GET TYPE " + m_upsName.local8Bit() + " " + varName.local8Bit() +"\n";
if (!(m_error=getUpsData (inBuffer,varOutBuffer))) { if (!(m_error=getUpsData (inBuffer,varOutBuffer))) {
key = parseLine (varOutBuffer, upsNameRet, varNameRet, value, typeValue, lenString); key = parseLine (varOutBuffer, upsNameRet, varNameRet, value, typeValue, lenString);
switch (key) { switch (key) {
@ -1431,7 +1431,7 @@ int KNutNet::getUpsVars2 ( void) {
if (typeValue & ENUM_FLAG) { if (typeValue & ENUM_FLAG) {
upsVar.upsValueType=false; upsVar.upsValueType=false;
// nacteme enumValues // nacteme enumValues
inBuffer = "LIST ENUM " + m_upsName + " " + varName +"\n"; inBuffer = "LIST ENUM " + m_upsName.local8Bit() + " " + varName.local8Bit() +"\n";
if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END LIST ENUM"))) { if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END LIST ENUM"))) {
bool beginEnumList = false; bool beginEnumList = false;
TQTextIStream varInputStream(&varOutBuffer); TQTextIStream varInputStream(&varOutBuffer);
@ -1500,7 +1500,7 @@ int KNutNet::getUpsVars2 ( void) {
else { return m_error; } else { return m_error; }
// INSTANT COMMANDS // INSTANT COMMANDS
inBuffer = "LIST CMD " + m_upsName + "\n"; inBuffer = "LIST CMD " + m_upsName.local8Bit() + "\n";
if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST CMD"))) { if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST CMD"))) {
TQString inLine, upsNameRet, varName, value; TQString inLine, upsNameRet, varName, value;
@ -1562,10 +1562,10 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars
if ((allVars) || ((*it).upsVarActivate)) { if ((allVars) || ((*it).upsVarActivate)) {
//nacteme promenou //nacteme promenou
inBuffer = "REQ "; inBuffer = "REQ ";
inBuffer.append((*it).upsVarName); inBuffer.append((*it).upsVarName.local8Bit());
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer.append("@"); inBuffer.append("@");
inBuffer.append(m_upsName); inBuffer.append(m_upsName.local8Bit());
} }
inBuffer.append("\n"); inBuffer.append("\n");
// if (!(error=getUpsData (inBuffer,outBuffer))) { // if (!(error=getUpsData (inBuffer,outBuffer))) {
@ -1660,7 +1660,7 @@ int KNutNet::getUpsValues2 (const bool allVars ) {// allVars = true vse; allVars
numberVar++; numberVar++;
if ((allVars) || ((*it).upsVarActivate)) { if ((allVars) || ((*it).upsVarActivate)) {
//reads variable //reads variable
inBuffer = "GET VAR "+m_upsName+" "+(*it).upsVarName+"\n"; inBuffer = "GET VAR "+m_upsName.local8Bit()+" "+(*it).upsVarName.local8Bit()+"\n";
// if (!(error=getUpsData (inBuffer,outBuffer))) { // if (!(error=getUpsData (inBuffer,outBuffer))) {
m_error=getUpsData (inBuffer,outBuffer); m_error=getUpsData (inBuffer,outBuffer);
// when outBuffer is empty sends and reads date again, but only the only time // when outBuffer is empty sends and reads date again, but only the only time
@ -1712,16 +1712,23 @@ int KNutNet::sendComm (const TQString command, const TQString arg1, const TQStri
switch (m_nutProtocol) { switch (m_nutProtocol) {
case 1: case 1:
inBuffer=command + " " + arg1; inBuffer=command.local8Bit() + " " + arg1.local8Bit();
if (useUpsName && (!m_upsName.isEmpty())) // pokud upsName neni je vzdy prazdne if (useUpsName && (!m_upsName.isEmpty())) { // pokud upsName neni je vzdy prazdne
inBuffer += "@"+m_upsName; inBuffer += "@"+m_upsName.local8Bit();
if (!arg2.isEmpty()) inBuffer += " " + arg2; }
if (!arg2.isEmpty()) {
inBuffer += " " + arg2.local8Bit();
}
break; break;
case 2: case 2:
inBuffer = command + " "; inBuffer = command.local8Bit() + " ";
if (useUpsName) inBuffer += m_upsName + " "; if (useUpsName) {
inBuffer.append(arg1); inBuffer += m_upsName.local8Bit() + " ";
if (!arg2.isEmpty()) inBuffer += " \"" + arg2 +"\""; }
inBuffer.append(arg1.local8Bit());
if (!arg2.isEmpty()) {
inBuffer += " \"" + arg2.local8Bit() +"\"";
}
break; break;
} }
inBuffer.append("\n"); inBuffer.append("\n");

Loading…
Cancel
Save