From ca6e280ada4757cf36423fe91dae85a916802863 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Sat, 5 Mar 2022 17:00:44 +0100
Subject: [PATCH] =?UTF-8?q?fix:=20correct=20bug=20where=20method=20paramet?=
 =?UTF-8?q?ers=20weren=E2=80=99t=20correctly=20specified?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../libquassel/quassel/syncables/Network.kt   | 28 +++++++++----------
 .../quassel/syncables/interfaces/INetwork.kt  | 14 +++++-----
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/Network.kt b/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/Network.kt
index 25099393f..6368f3726 100644
--- a/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/Network.kt
+++ b/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/Network.kt
@@ -449,10 +449,10 @@ class Network constructor(
     _networkName = networkName
   }
 
-  override fun setCurrentServer(currentServer: String) {
+  override fun setCurrentServer(currentServer: String?) {
     if (_currentServer == currentServer)
       return
-    _currentServer = currentServer
+    _currentServer = currentServer ?: ""
   }
 
   override fun setConnected(isConnected: Boolean) {
@@ -461,7 +461,7 @@ class Network constructor(
     _connected = isConnected
     if (!isConnected) {
       setMyNick("")
-      setCurrentServer("")
+      setCurrentServer(null)
       removeChansAndUsers()
     }
   }
@@ -473,10 +473,10 @@ class Network constructor(
     live_connectionState.onNext(_connectionState)
   }
 
-  override fun setMyNick(myNick: String) {
-    if (_myNick == myNick)
+  override fun setMyNick(myNick: String?) {
+    if (_myNick == myNick ?: "")
       return
-    _myNick = myNick
+    _myNick = myNick ?: ""
     if (_myNick.isEmpty() && ircUser(myNick()) == null) {
       newIrcUser(myNick())
     }
@@ -614,19 +614,19 @@ class Network constructor(
     _unlimitedMessageRate = unlimitedMessageRate
   }
 
-  override fun setCodecForDecoding(codecForDecoding: ByteBuffer) {
-    setCodecForDecoding(Charsets.ISO_8859_1.decode(codecForDecoding).toString())
+  override fun setCodecForDecoding(codecForDecoding: ByteBuffer?) {
+    setCodecForDecoding(codecForDecoding?.let(Charsets.ISO_8859_1::decode)?.toString() ?: "")
   }
 
-  override fun setCodecForEncoding(codecForEncoding: ByteBuffer) {
-    setCodecForEncoding(Charsets.ISO_8859_1.decode(codecForEncoding).toString())
+  override fun setCodecForEncoding(codecForEncoding: ByteBuffer?) {
+    setCodecForEncoding(codecForEncoding?.let(Charsets.ISO_8859_1::decode)?.toString() ?: "")
   }
 
-  override fun setCodecForServer(codecForServer: ByteBuffer) {
-    setCodecForServer(Charsets.ISO_8859_1.decode(codecForServer).toString())
+  override fun setCodecForServer(codecForServer: ByteBuffer?) {
+    setCodecForServer(codecForServer?.let(Charsets.ISO_8859_1::decode)?.toString() ?: "")
   }
 
-  override fun addSupport(param: String, value: String) {
+  override fun addSupport(param: String, value: String?) {
     _supports[param] = value
   }
 
@@ -636,7 +636,7 @@ class Network constructor(
     _supports.remove(param)
   }
 
-  override fun addCap(capability: String, value: String) {
+  override fun addCap(capability: String, value: String?) {
     _caps[capability.lowercase(Locale.ROOT)] = value
   }
 
diff --git a/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/interfaces/INetwork.kt b/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/interfaces/INetwork.kt
index fbc92fe92..ee24a0213 100644
--- a/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/interfaces/INetwork.kt
+++ b/lib/src/main/java/de/kuschku/libquassel/quassel/syncables/interfaces/INetwork.kt
@@ -67,7 +67,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun setCurrentServer(currentServer: String) {
+  fun setCurrentServer(currentServer: String?) {
     sync(
       target = ProtocolSide.CLIENT,
       "setCurrentServer",
@@ -76,7 +76,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun setMyNick(myNick: String) {
+  fun setMyNick(myNick: String?) {
     sync(
       target = ProtocolSide.CLIENT,
       "setMyNick",
@@ -94,7 +94,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun setCodecForServer(codecForServer: ByteBuffer) {
+  fun setCodecForServer(codecForServer: ByteBuffer?) {
     sync(
       target = ProtocolSide.CLIENT,
       "setCodecForServer",
@@ -103,7 +103,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun setCodecForEncoding(codecForEncoding: ByteBuffer) {
+  fun setCodecForEncoding(codecForEncoding: ByteBuffer?) {
     sync(
       target = ProtocolSide.CLIENT,
       "setCodecForEncoding",
@@ -112,7 +112,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun setCodecForDecoding(codecForDecoding: ByteBuffer) {
+  fun setCodecForDecoding(codecForDecoding: ByteBuffer?) {
     sync(
       target = ProtocolSide.CLIENT,
       "setCodecForDecoding",
@@ -323,7 +323,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun addSupport(param: String, value: String = "") {
+  fun addSupport(param: String, value: String? = null) {
     sync(
       target = ProtocolSide.CLIENT,
       "addSupport",
@@ -342,7 +342,7 @@ interface INetwork : ISyncableObject {
   }
 
   @SyncedCall(target = ProtocolSide.CLIENT)
-  fun addCap(capability: String, value: String = "") {
+  fun addCap(capability: String, value: String? = null) {
     sync(
       target = ProtocolSide.CLIENT,
       "addCap",
-- 
GitLab