Re: [PATCH phonesim 6/7] Port to Qt 6

2021-01-25 Thread Denis Kenzior

Hi Jonah,

On 1/18/21 10:46 AM, Jonah BrĂ¼chert wrote:

---
  CMakeLists.txt  | 10 +++---
  src/CMakeLists.txt  |  6 +-
  src/control.cpp |  8 +++-
  src/hardwaremanipulator.cpp |  1 -
  src/phonesim.cpp|  2 +-
  src/qsimcommand.cpp |  2 +-
  src/qwsppdu.cpp | 12 ++--
  7 files changed, 23 insertions(+), 18 deletions(-)



Can the code changes be made standalone, without the build-system bits?

Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[PATCH phonesim 6/7] Port to Qt 6

2021-01-18 Thread Jonah BrĂ¼chert
---
 CMakeLists.txt  | 10 +++---
 src/CMakeLists.txt  |  6 +-
 src/control.cpp |  8 +++-
 src/hardwaremanipulator.cpp |  1 -
 src/phonesim.cpp|  2 +-
 src/qsimcommand.cpp |  2 +-
 src/qwsppdu.cpp | 12 ++--
 7 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9de202a..edff85d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,14 +5,18 @@ set(PHONESIM_VERSION 1.21)
 include(FeatureSummary)
 include(GNUInstallDirs)

-find_package(Qt5 "5.10.0" REQUIRED NO_MODULE COMPONENTS Core Widgets Qml 
Network DBus)
+find_package(Qt6 "6.0.0" NO_MODULE COMPONENTS Core Widgets Qml Network DBus 
Core5Compat)
+
+if(NOT Qt6_FOUND)
+find_package(Qt5 "5.10.0" REQUIRED NO_MODULE COMPONENTS Core Widgets Qml 
Network DBus)
+endif()

 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTOUIC ON)

-# Enable C++14 #
+# Enable C++17 #

-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)

 # build and install #
 add_subdirectory(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6d7ebf5..d17459a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,7 +34,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

 add_executable(phonesim ${PHONESIM_SRCS})
 target_compile_definitions(phonesim PRIVATE -DVERSION=${PHONESIM_VERSION} 
-DQT_NO_FOREACH)
-target_link_libraries(phonesim Qt5::Core Qt5::Widgets Qt5::Qml Qt5::Network 
Qt5::DBus)
+if(Qt6_FOUND)
+target_link_libraries(phonesim Qt6::Core Qt6::Widgets Qt6::Qml 
Qt6::Network Qt6::DBus Qt6::Core5Compat)
+else()
+target_link_libraries(phonesim Qt5::Core Qt5::Widgets Qt5::Qml 
Qt5::Network Qt5::DBus)
+endif()

 install(TARGETS phonesim RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES default.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/phonesim/)
diff --git a/src/control.cpp b/src/control.cpp
index 817a0b2..d45ff91 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -337,7 +336,7 @@ void ControlWidget::sendSMSMessage()
 return;
 }

-if (ui->leSMSServiceCenter->text().isEmpty() || 
ui->leSMSServiceCenter->text().contains(QRegExp("\\D"))) {
+if (ui->leSMSServiceCenter->text().isEmpty() || 
ui->leSMSServiceCenter->text().contains(QRegularExpression(R"(\D)"))) {
 p->warning(tr("Invalid Service Center"),
 tr("Service Center must not be empty and contain "
"only digits"));
@@ -386,14 +385,14 @@ void ControlWidget::selectFile()
 void ControlWidget::sendSMSDatagram()
 {
 QString dstPortStr = ui->leDstPort->text();
-if ( dstPortStr.contains(QRegExp("\\D")) ) {
+if ( dstPortStr.contains(QRegularExpression(R"(\D)")) ) {
 p->warning(tr("Invalid Port"), tr("Port number can contain only 
digits" ));
 return;
 }
 int dst = dstPortStr.toInt();

 QString srcPortStr = ui->leSrcPort->text();
-if ( srcPortStr.contains(QRegExp("\\D")) ) {
+if ( srcPortStr.contains(QRegularExpression(R"(\D)")) ) {
 p->warning(tr("Invalid Port"), tr("Port number can contain only 
digits" ));
 return;
 }
@@ -700,7 +699,6 @@ QString Script::Run(const QString , const QDBusMessage 
)
 }

 QTextStream stream();
-stream.setCodec("UTF-8");
 QString contents = stream.readAll();
 scriptFile.close();

diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index a8a9bfe..7a5d30b 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -18,7 +18,6 @@
 /

 #include "hardwaremanipulator.h"
-#include 
 #include 
 #include 
 #include 
diff --git a/src/phonesim.cpp b/src/phonesim.cpp
index 89d5e9d..1b826ed 100644
--- a/src/phonesim.cpp
+++ b/src/phonesim.cpp
@@ -346,7 +346,7 @@ bool SimChat::command( const QString& cmd )
 else {
 int index = value.indexOf( "${*}" );
 if ( index != -1 ) {
-if ( wild.length() > 0 && wild[wild.length() - 1] == 0x1A ) {
+if ( wild.length() > 0 && wild[wild.length() - 1] == 
QChar(0x1A) ) {
 // Strip the terminating ^Z from SMS PDU's.
 wild = wild.left( wild.length() - 1 );
 }
diff --git a/src/qsimcommand.cpp b/src/qsimcommand.cpp
index 105cffe..45bde63 100644
--- a/src/qsimcommand.cpp
+++ b/src/qsimcommand.cpp
@@ -3626,7 +3626,7 @@ QByteArray QSimCommand::toPdu( QSimCommand::ToPduOptions 
options ) const
 if ( !language().isEmpty() && language().length() == 2 ) {
 data += (char)0xAD;
 data += (char)0x02;
-data += language();
+data += language().toUtf8();
 }
 }
 break;
diff --git a/src/qwsppdu.cpp