summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2018-10-16 01:30:23 +0200
committerSlávek Banko <slavek.banko@axis.cz>2018-10-16 01:30:23 +0200
commit54bb877d9058412680ae04433ebd34cadfa1e78e (patch)
tree37523819c737b465777bb8ca3b334e842b4bf167
parent8eb947399e931423ebcd97988f3b4d4a3618b466 (diff)
downloadknutclient-54bb877d9058412680ae04433ebd34cadfa1e78e.tar.gz
knutclient-54bb877d9058412680ae04433ebd34cadfa1e78e.zip
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>
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/knutmainwindow.cpp4
-rw-r--r--src/knutnet.cpp63
3 files changed, 38 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2aa9310..253701c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,7 @@ include( ConfigureChecks.cmake )
###### 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_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
diff --git a/src/knutmainwindow.cpp b/src/knutmainwindow.cpp
index 8e09747..a043c4e 100644
--- a/src/knutmainwindow.cpp
+++ b/src/knutmainwindow.cpp
@@ -403,14 +403,14 @@ void KNutMainWindow::showUpsData (void) {
m_existLowHighXfer = false;
}
else {
- m_lowXfer = atof(nutStringVar);
+ m_lowXfer = nutStringVar.toFloat();
nutStringVar = m_activeUpsInfo->upsNet->readStringVar(m_activeUpsInfo->highxferVar);
if (nutStringVar.isEmpty()) {
m_highXfer = -1;
m_existLowHighXfer = false;
}
else {
- m_highXfer = atof(nutStringVar);
+ m_highXfer = nutStringVar.toFloat();
m_existLowHighXfer = true;
}
}
diff --git a/src/knutnet.cpp b/src/knutnet.cpp
index 064578d..f049a52 100644
--- a/src/knutnet.cpp
+++ b/src/knutnet.cpp
@@ -1023,7 +1023,7 @@ int KNutNet::getDescription1 (bool always) {
TQValueVector<upsICommDef>::iterator itc;
for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) {
//nacteme promenou
- inBuffer = "VARDESC " + (*itv).upsVarName + "\n";
+ inBuffer = "VARDESC " + (*itv).upsVarName.local8Bit() + "\n";
if ((m_error = newDescription (inBuffer, (*itv).upsDescription))) {
//netMutex.unlock();
// netMutex=false;
@@ -1032,7 +1032,7 @@ int KNutNet::getDescription1 (bool always) {
}
for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) {
//nacteme promenou
- inBuffer = "INSTCMDDESC "+(*itc).upsCommName+"\n";
+ inBuffer = "INSTCMDDESC "+(*itc).upsCommName.local8Bit()+"\n";
if ((m_error = newDescription (inBuffer, (*itc).upsDescription))) {
//netMutex.unlock();
//netMutex=false;
@@ -1062,7 +1062,7 @@ int KNutNet::getDescription2 (bool always) {
TQValueVector<upsICommDef>::iterator itc;
for (itv = m_listVars.begin(); itv != m_listVars.end(); itv++) {
//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))) {
outBuffer=outBuffer.stripWhiteSpace ();
@@ -1091,7 +1091,7 @@ int KNutNet::getDescription2 (bool always) {
}
for (itc = m_listIComms.begin(); itc != m_listIComms.end(); itc++) {
//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))) {
outBuffer=outBuffer.stripWhiteSpace ();
if ( !outBuffer.isEmpty() ) {
@@ -1136,7 +1136,7 @@ int KNutNet::getUpsVars1 ( void) {
// init vars and lists
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTVARS ";
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n");
}
else inBuffer ="LISTVARS\n";
@@ -1184,7 +1184,7 @@ int KNutNet::getUpsVars1 ( void) {
// *********** RW VARIABLES
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTRW ";
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n");
}
else inBuffer ="LISTRW\n";
@@ -1220,10 +1220,10 @@ int KNutNet::getUpsVars1 ( void) {
// Zpracujeme polozku v tabulce
// zjistime informaci o promene
inBuffer="VARTYPE ";
- inBuffer.append(word);
+ inBuffer.append(word.local8Bit());
if (!m_upsName.isEmpty()) {
inBuffer.append("@"); // pokud upsName neni je vzdy nastaveno na null
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
}
inBuffer.append("\n");
if (!(m_error=getUpsData (inBuffer,varOutBuffer))) {
@@ -1271,11 +1271,11 @@ int KNutNet::getUpsVars1 ( void) {
if (!valueType) {
// nacteme enum hodnoty
inBuffer="ENUM ";
- inBuffer.append(word);
+ inBuffer.append(word.local8Bit());
// pokud existuje pridame jmeno UPS-ky
if (!m_upsName.isEmpty()) {
inBuffer.append("@");
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
}
inBuffer.append("\n");
if (!(m_error=getUpsData (inBuffer,varOutBuffer,"END\n"))) {
@@ -1343,7 +1343,7 @@ int KNutNet::getUpsVars1 ( void) {
// *************** INSTANT COMMAND
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer="LISTINSTCMD ";
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
inBuffer.append("\n");
}
else inBuffer ="LISTINSTCMD\n";
@@ -1403,7 +1403,7 @@ int KNutNet::getUpsVars2 ( void) {
int varMax=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"))) {
TQString inLine, upsNameRet, varName, varNameRet, value;
bool beginList = false;
@@ -1420,7 +1420,7 @@ int KNutNet::getUpsVars2 ( void) {
upsSetType(upsVar, varName, 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))) {
key = parseLine (varOutBuffer, upsNameRet, varNameRet, value, typeValue, lenString);
switch (key) {
@@ -1431,7 +1431,7 @@ int KNutNet::getUpsVars2 ( void) {
if (typeValue & ENUM_FLAG) {
upsVar.upsValueType=false;
// 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"))) {
bool beginEnumList = false;
TQTextIStream varInputStream(&varOutBuffer);
@@ -1500,7 +1500,7 @@ int KNutNet::getUpsVars2 ( void) {
else { return m_error; }
// INSTANT COMMANDS
- inBuffer = "LIST CMD " + m_upsName + "\n";
+ inBuffer = "LIST CMD " + m_upsName.local8Bit() + "\n";
if (!(m_error=getUpsData (inBuffer,outBuffer,"END LIST CMD"))) {
TQString inLine, upsNameRet, varName, value;
@@ -1562,10 +1562,10 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars
if ((allVars) || ((*it).upsVarActivate)) {
//nacteme promenou
inBuffer = "REQ ";
- inBuffer.append((*it).upsVarName);
+ inBuffer.append((*it).upsVarName.local8Bit());
if (!m_upsName.isEmpty()) { // pokud upsName neni je vzdy nastaveno na null
inBuffer.append("@");
- inBuffer.append(m_upsName);
+ inBuffer.append(m_upsName.local8Bit());
}
inBuffer.append("\n");
// if (!(error=getUpsData (inBuffer,outBuffer))) {
@@ -1660,7 +1660,7 @@ int KNutNet::getUpsValues2 (const bool allVars ) {// allVars = true vse; allVars
numberVar++;
if ((allVars) || ((*it).upsVarActivate)) {
//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))) {
m_error=getUpsData (inBuffer,outBuffer);
// when outBuffer is empty sends and reads date again, but only the only time
@@ -1712,17 +1712,24 @@ int KNutNet::sendComm (const TQString command, const TQString arg1, const TQStri
switch (m_nutProtocol) {
case 1:
- inBuffer=command + " " + arg1;
- if (useUpsName && (!m_upsName.isEmpty())) // pokud upsName neni je vzdy prazdne
- inBuffer += "@"+m_upsName;
- if (!arg2.isEmpty()) inBuffer += " " + arg2;
- break;
+ inBuffer=command.local8Bit() + " " + arg1.local8Bit();
+ if (useUpsName && (!m_upsName.isEmpty())) { // pokud upsName neni je vzdy prazdne
+ inBuffer += "@"+m_upsName.local8Bit();
+ }
+ if (!arg2.isEmpty()) {
+ inBuffer += " " + arg2.local8Bit();
+ }
+ break;
case 2:
- inBuffer = command + " ";
- if (useUpsName) inBuffer += m_upsName + " ";
- inBuffer.append(arg1);
- if (!arg2.isEmpty()) inBuffer += " \"" + arg2 +"\"";
- break;
+ inBuffer = command.local8Bit() + " ";
+ if (useUpsName) {
+ inBuffer += m_upsName.local8Bit() + " ";
+ }
+ inBuffer.append(arg1.local8Bit());
+ if (!arg2.isEmpty()) {
+ inBuffer += " \"" + arg2.local8Bit() +"\"";
+ }
+ break;
}
inBuffer.append("\n");