[network/libktorrent] src: ABI/API break: use enum class for SocketDevice::State

Jack Hill <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 94b4368ac318a152c9243d63f6dfb5e68a579dc5 by Jack Hill.
Committed on 15/08/2026 at 10:22.
Pushed by jackh into branch 'master'.

ABI/API break: use enum class for SocketDevice::State

No downstream changes required.

M  +1    -1    src/download/httpconnection.cpp
M  +1    -1    src/mse/encryptedpacketsocket.cpp
M  +1    -1    src/net/packetsocket.cpp
M  +10   -10   src/net/socket.cpp
M  +1    -1    src/net/socketdevice.cpp
M  +1    -1    src/net/socketdevice.h
M  +2    -2    src/net/streamsocket.cpp
M  +4    -4    src/utp/utpsocket.cpp

https://invent.kde.org/network/libktorrent/-/commit/94b4368ac318a152c9243d63f6dfb5e68a579dc5

diff --git a/src/download/httpconnection.cpp b/src/download/httpconnection.cpp
index b1524fdd..c209f16e 100644
--- a/src/download/httpconnection.cpp
+++ b/src/download/httpconnection.cpp
@@ -182,7 +182,7 @@ void HttpConnection::hostResolved(net::AddressResolver *ar)
             state = State::ACTIVE;
             net::SocketMonitor::instance().add(sock);
             net::SocketMonitor::instance().signalPacketReady();
-        } else if (sock->socketDevice()->state() == net::SocketDevice::CONNECTING) {
+        } else if (sock->socketDevice()->state() == net::SocketDevice::State::CONNECTING) {
             status = i18n("Connecting");
             state = State::CONNECTING;
             net::SocketMonitor::instance().add(sock);
diff --git a/src/mse/encryptedpacketsocket.cpp b/src/mse/encryptedpacketsocket.cpp
index e22945f9..5fe030e7 100644
--- a/src/mse/encryptedpacketsocket.cpp
+++ b/src/mse/encryptedpacketsocket.cpp
@@ -246,7 +246,7 @@ void EncryptedPacketSocket::reinsert(const Uint8 *d, Uint32 size)
 
 bool EncryptedPacketSocket::connecting() const
 {
-    return sock->state() == net::SocketDevice::CONNECTING;
+    return sock->state() == net::SocketDevice::State::CONNECTING;
 }
 
 bool EncryptedPacketSocket::connectSuccessful() const
diff --git a/src/net/packetsocket.cpp b/src/net/packetsocket.cpp
index 89e5eae4..9e343e2c 100644
--- a/src/net/packetsocket.cpp
+++ b/src/net/packetsocket.cpp
@@ -75,7 +75,7 @@ void PacketSocket::selectPacket()
 
 Uint32 PacketSocket::write(Uint32 max, bt::TimeStamp now)
 {
-    if (sock->state() == net::SocketDevice::CONNECTING && !sock->connectSuccessful()) {
+    if (sock->state() == net::SocketDevice::State::CONNECTING && !sock->connectSuccessful()) {
         return 0;
     }
 
diff --git a/src/net/socket.cpp b/src/net/socket.cpp
index 2411e93a..fd2064bb 100644
--- a/src/net/socket.cpp
+++ b/src/net/socket.cpp
@@ -79,7 +79,7 @@ Socket::Socket(int fd, int ip_version)
         configureFd();
         cacheAddress();
     } else {
-        m_state = CLOSED;
+        m_state = State::CLOSED;
     }
 }
 
@@ -95,7 +95,7 @@ Socket::Socket(bool tcp, int ip_version)
         m_ip_version = 4;
     }
 
-    m_state = CLOSED;
+    m_state = State::CLOSED;
 
     reset();
 }
@@ -119,7 +119,7 @@ void Socket::reset()
 
     configureFd();
 
-    m_state = IDLE;
+    m_state = State::IDLE;
 }
 
 void Socket::configureFd()
@@ -165,7 +165,7 @@ void Socket::close()
         ::close(fd);
 #endif
         m_fd = -1;
-        m_state = CLOSED;
+        m_state = State::CLOSED;
     }
 }
 
@@ -210,14 +210,14 @@ bool Socket::connectTo(const Address &a)
 #endif
         {
             //  Out(SYS_CON|LOG_DEBUG) << "Socket is connecting" << endl;
-            m_state = CONNECTING;
+            m_state = State::CONNECTING;
             return false;
         } else {
             Out(SYS_CON | LOG_NOTICE) << QStringLiteral("Cannot connect to host %1 : %2").arg(a.toString(), QString::fromUtf8(strerror(err))) << endl;
             return false;
         }
     }
-    m_state = CONNECTED;
+    m_state = State::CONNECTED;
     cacheAddress();
     return true;
 }
@@ -257,7 +257,7 @@ bool Socket::bind(const net::Address &addr, bool also_listen)
         return false;
     }
 
-    m_state = BOUND;
+    m_state = State::BOUND;
     return true;
 }
 
@@ -414,7 +414,7 @@ Uint32 Socket::bytesAvailable() const
 
 bool Socket::connectSuccessful()
 {
-    if (m_state != CONNECTING && m_state != CONNECTED) {
+    if (m_state != State::CONNECTING && m_state != State::CONNECTED) {
         return false;
     }
 
@@ -428,7 +428,7 @@ bool Socket::connectSuccessful()
         return false;
 
     if (err == 0) {
-        m_state = CONNECTED;
+        m_state = State::CONNECTED;
         cacheAddress();
     }
 
@@ -461,7 +461,7 @@ int Socket::take()
 {
     const int ret = m_fd;
     m_fd = -1;
-    m_state = CLOSED;
+    m_state = State::CLOSED;
     return ret;
 }
 
diff --git a/src/net/socketdevice.cpp b/src/net/socketdevice.cpp
index 2a900ff8..953956e0 100644
--- a/src/net/socketdevice.cpp
+++ b/src/net/socketdevice.cpp
@@ -9,7 +9,7 @@
 namespace net
 {
 SocketDevice::SocketDevice(bt::TransportProtocol proto)
-    : m_state(IDLE)
+    : m_state(State::IDLE)
     , remote_addr_override(false)
     , transport_protocol(proto)
 {
diff --git a/src/net/socketdevice.h b/src/net/socketdevice.h
index 0d42ff85..e55872d4 100644
--- a/src/net/socketdevice.h
+++ b/src/net/socketdevice.h
@@ -46,7 +46,7 @@ public:
      * \var CLOSED
      * The socket is not open and therefore will not send or receive data.
      */
-    enum State {
+    enum class State {
         IDLE,
         CONNECTING,
         CONNECTED,
diff --git a/src/net/streamsocket.cpp b/src/net/streamsocket.cpp
index 74fd0ee3..f5fec8b4 100644
--- a/src/net/streamsocket.cpp
+++ b/src/net/streamsocket.cpp
@@ -29,7 +29,7 @@ void StreamSocket::addData(const QByteArray &data)
 bool StreamSocket::bytesReadyToWrite() const
 {
     const QMutexLocker lock(&mutex);
-    return !buffer.isEmpty() || sock->state() == net::SocketDevice::CONNECTING;
+    return !buffer.isEmpty() || sock->state() == net::SocketDevice::State::CONNECTING;
 }
 
 bt::Uint32 StreamSocket::write(bt::Uint32 max, bt::TimeStamp now)
@@ -37,7 +37,7 @@ bt::Uint32 StreamSocket::write(bt::Uint32 max, bt::TimeStamp now)
     Q_UNUSED(now);
 
     const QMutexLocker lock(&mutex);
-    if (sock->state() == net::SocketDevice::CONNECTING) {
+    if (sock->state() == net::SocketDevice::State::CONNECTING) {
         const bool ok = sock->connectSuccessful();
         if (listener) {
             listener->connectFinished(ok);
diff --git a/src/utp/utpsocket.cpp b/src/utp/utpsocket.cpp
index caece8b9..7862a3f7 100644
--- a/src/utp/utpsocket.cpp
+++ b/src/utp/utpsocket.cpp
@@ -30,7 +30,7 @@ UTPSocket::UTPSocket(Connection::WPtr conn)
     if (ptr) {
         setRemoteAddress(ptr->remoteAddress());
         ptr->setBlocking(blocking);
-        m_state = CONNECTED;
+        m_state = State::CONNECTED;
     }
 }
 
@@ -67,7 +67,7 @@ bool UTPSocket::connectSuccessful()
     const Connection::Ptr ptr = conn.toStrongRef();
     if (ptr && ptr->connectionState() == ConnectionState::CONNECTED) {
         setRemoteAddress(ptr->remoteAddress());
-        m_state = CONNECTED;
+        m_state = State::CONNECTED;
         return true;
     } else {
         return false;
@@ -89,12 +89,12 @@ bool UTPSocket::connectTo(const net::Address &addr)
         return false;
     }
 
-    m_state = CONNECTING;
+    m_state = State::CONNECTING;
     ptr->setBlocking(blocking);
     if (blocking) {
         const bool ret = ptr->waitUntilConnected();
         if (ret) {
-            m_state = CONNECTED;
+            m_state = State::CONNECTED;
         }
 
         return ret;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.