From 06f962fa8724938bb9de9d667fac457688f7897c Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Thu, 9 Jan 2020 18:59:51 +0100
Subject: [PATCH] Improve documentation on RPC calls

---
 docs/protocol/overview.md                     |   4 +
 .../serialization/signalproxy_objects.md      | 134 +++++++++---------
 .../protocol/serialization/signalproxy_rpc.md | 106 ++++++++++++++
 mkdocs.yml                                    |   6 +-
 4 files changed, 181 insertions(+), 69 deletions(-)
 create mode 100644 docs/protocol/overview.md
 create mode 100644 docs/protocol/serialization/signalproxy_rpc.md

diff --git a/docs/protocol/overview.md b/docs/protocol/overview.md
new file mode 100644
index 0000000..74d43cc
--- /dev/null
+++ b/docs/protocol/overview.md
@@ -0,0 +1,4 @@
+# Protocol Overview
+
+!!! danger
+    The documentation is still being worked on.
\ No newline at end of file
diff --git a/docs/protocol/serialization/signalproxy_objects.md b/docs/protocol/serialization/signalproxy_objects.md
index e17dfc5..b7c1b1b 100644
--- a/docs/protocol/serialization/signalproxy_objects.md
+++ b/docs/protocol/serialization/signalproxy_objects.md
@@ -82,7 +82,7 @@ interface AliasManager {
 
     // S->C calls
 
-    addAlias(name: QString | null, expansion: QString | null)
+    addAlias(name: QString, expansion: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -222,7 +222,7 @@ interface BufferSyncer {
     markBufferAsRead(buffer: BufferId)
     mergeBuffersPermanently(buffer1: BufferId, buffer2: BufferId)
     removeBuffer(buffer: BufferId)
-    renameBuffer(buffer: BufferId, newName: QString | null)
+    renameBuffer(buffer: BufferId, newName: QString)
     setBufferActivity(buffer: BufferId, activity: Int)
     setHighlightCount(buffer: BufferId, count: Int)
     setLastSeenMsg(buffer: BufferId, msgId: MsgId)
@@ -298,7 +298,7 @@ interface BufferViewConfig {
     requestMoveBuffer(bufferId: BufferId, pos: Int)
     requestRemoveBuffer(bufferId: BufferId)
     requestRemoveBufferPermanently(bufferId: BufferId)
-    requestSetBufferViewName(bufferViewName: QString | null)
+    requestSetBufferViewName(bufferViewName: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -313,7 +313,7 @@ interface BufferViewConfig {
     removeBufferPermanently(bufferId: BufferId)
     setAddNewBuffersAutomatically(addNewBuffersAutomatically: Bool)
     setAllowedBufferTypes(bufferTypes: Int)
-    setBufferViewName(bufferViewName: QString | null)
+    setBufferViewName(bufferViewName: QString)
     setDisableDecoration(disableDecoration: Bool)
     setHideInactiveBuffers(hideInactiveBuffers: Bool)
     setHideInactiveNetworks(hideInactiveNetworks: Bool)
@@ -565,9 +565,9 @@ interface HighlightRuleManager {
      * Request an HighlightRule to be added to the ignore list
      * Items added to the list with this method, get immediately synced with the core
      */
-    requestAddHighlightRule(id: Int, name: QString | null, isRegEx: Boolean,
+    requestAddHighlightRule(id: Int, name: QString, isRegEx: Boolean,
         isCaseSensitive: Boolean, isEnabled: Boolean, isInverse: Boolean,
-        sender: QString | null, chanName: QString | null)
+        sender: QString, chanName: QString)
     requestSetHighlightNick(highlightNick: Int)
     requestSetNicksCaseSensitive(nicksCaseSensitive: Boolean)
     /**
@@ -581,9 +581,9 @@ interface HighlightRuleManager {
 
     removeHighlightRule(highlightRule: Int)
     toggleHighlightRule(highlightRule: Int)
-    addHighlightRule(id: Int, name: QString | null, isRegEx: Boolean,
+    addHighlightRule(id: Int, name: QString, isRegEx: Boolean,
             isCaseSensitive: Boolean, isEnabled: Boolean, isInverse: Boolean,
-            sender: QString | null, chanName: QString | null)
+            sender: QString, chanName: QString)
     setHighlightNick(highlightNick: Int)
     setNicksCaseSensitive(nicksCaseSensitive: Boolean)
     /**
@@ -680,24 +680,24 @@ interface Identity {
 
     copyFrom(other: Identity)
     setAutoAwayEnabled(enabled: Bool) 
-    setAutoAwayReason(reason: QString | null) 
+    setAutoAwayReason(reason: QString) 
     setAutoAwayReasonEnabled(enabled: Bool) 
     setAutoAwayTime(time: Int) 
-    setAwayNick(awayNick: QString | null) 
+    setAwayNick(awayNick: QString) 
     setAwayNickEnabled(enabled: Bool) 
-    setAwayReason(awayReason: QString | null) 
+    setAwayReason(awayReason: QString) 
     setAwayReasonEnabled(enabled: Bool) 
     setDetachAwayEnabled(enabled: Bool) 
-    setDetachAwayReason(reason: QString | null) 
+    setDetachAwayReason(reason: QString) 
     setDetachAwayReasonEnabled(enabled: Bool) 
     setId(id: IdentityId) 
-    setIdent(ident: QString | null) 
-    setIdentityName(name: QString | null) 
-    setKickReason(reason: QString | null) 
+    setIdent(ident: QString) 
+    setIdentityName(name: QString) 
+    setKickReason(reason: QString) 
     setNicks(nicks: QStringList) 
-    setPartReason(reason: QString | null) 
-    setQuitReason(reason: QString | null) 
-    setRealName(realName: QString | null) 
+    setPartReason(reason: QString) 
+    setQuitReason(reason: QString) 
+    setRealName(realName: QString) 
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -747,11 +747,11 @@ interface IgnoreListManager {
 
     // C->S calls
 
-    requestAddIgnoreListItem(type: Int, ignoreRule: QString | null,
-        isRegEx: Bool, strictness: Int, scope: Int, scopeRule: QString | null,
+    requestAddIgnoreListItem(type: Int, ignoreRule: QString,
+        isRegEx: Bool, strictness: Int, scope: Int, scopeRule: QString,
         isActive: Bool)
-    requestRemoveIgnoreListItem(ignoreRule: QString | null)
-    requestToggleIgnoreRule(ignoreRule: QString | null)
+    requestRemoveIgnoreListItem(ignoreRule: QString)
+    requestToggleIgnoreRule(ignoreRule: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -761,10 +761,10 @@ interface IgnoreListManager {
 
     // S->C calls
 
-    addIgnoreListItem(type: Int, ignoreRule: QString | null, isRegEx: Bool,
-        strictness: Int, scope: Int, scopeRule: QString | null, isActive: Bool)
-    removeIgnoreListItem(ignoreRule: QString | null)
-    toggleIgnoreRule(ignoreRule: QString | null)
+    addIgnoreListItem(type: Int, ignoreRule: QString, isRegEx: Bool,
+        strictness: Int, scope: Int, scopeRule: QString, isActive: Bool)
+    removeIgnoreListItem(ignoreRule: QString)
+    toggleIgnoreRule(ignoreRule: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -852,16 +852,16 @@ interface IrcChannel {
 
     // S->C calls
 
-    addChannelMode(mode: QChar, value: QString | null)
-    addUserMode(nick: QString | null, mode: QString | null)
+    addChannelMode(mode: QChar, value: QString)
+    addUserMode(nick: QString, mode: QString)
     joinIrcUsers(nicks: QStringList, modes: QStringList)
-    part(nick: QString | null)
-    removeChannelMode(mode: QChar, value: QString | null)
-    removeUserMode(nick: QString | null, mode: QString | null)
+    part(nick: QString)
+    removeChannelMode(mode: QChar, value: QString)
+    removeUserMode(nick: QString, mode: QString)
     setEncrypted(encrypted: Bool)
-    setPassword(password: QString | null)
-    setTopic(topic: QString | null)
-    setUserModes(nick: QString | null, modes: QString | null)
+    setPassword(password: QString)
+    setTopic(topic: QString)
+    setUserModes(nick: QString, modes: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -948,29 +948,29 @@ interface IrcUser {
 
     // S->C calls
 
-    addUserModes(modes: QString | null)
-    joinChannel(channelname: QString | null)
-    partChannel(channelname: QString | null)
+    addUserModes(modes: QString)
+    joinChannel(channelname: QString)
+    partChannel(channelname: QString)
     quit()
-    removeUserModes(modes: QString | null)
-    setAccount(account: QString | null)
+    removeUserModes(modes: QString)
+    setAccount(account: QString)
     setAway(away: Boolean)
-    setAwayMessage(awayMessage: QString | null)
+    setAwayMessage(awayMessage: QString)
     setEncrypted(encrypted: Boolean)
-    setHost(host: QString | null)
+    setHost(host: QString)
     setIdleTime(idleTime: QDateTime)
-    setIrcOperator(ircOperator: QString | null)
+    setIrcOperator(ircOperator: QString)
     setLastAwayMessage(lastAwayMessage: Int)
     setLastAwayMessageTime(lastAwayMessageTime: QDateTime)
     setLoginTime(loginTime: Temporal)
-    setNick(nick: QString | null)
-    setRealName(realName: QString | null)
-    setServer(server: QString | null)
-    setSuserHost(suserHost: QString | null)
-    setUser(user: QString | null)
-    setUserModes(modes: QString | null)
-    setWhoisServiceReply(whoisServiceReply: QString | null)
-    updateHostmask(mask: QString | null)
+    setNick(nick: QString)
+    setRealName(realName: QString)
+    setServer(server: QString)
+    setSuserHost(suserHost: QString)
+    setUser(user: QString)
+    setUserModes(modes: QString)
+    setWhoisServiceReply(whoisServiceReply: QString)
+    updateHostmask(mask: QString)
     /**
      * Replaces all properties of the object with the content of the
      * "properties" parameter. This parameter is in network representation.
@@ -1027,7 +1027,7 @@ interface Network {
     ircUsers: Map<QString, IrcUser>,
     ircChannels: Map<QString, IrcChannel>,
     supports: Map<QString, QString>,
-    caps: Map<QString, QString | null>,
+    caps: Map<QString, QString>,
     capsEnabled: [QString],
     networkInfo: NetworkInfo
 
@@ -1041,18 +1041,18 @@ interface Network {
 
     // S->C calls
 
-    acknowledgeCap(capability: QString | null)
-    addCap(capability: String, value: QString | null = null)
-    addIrcChannel(channel: QString | null)
-    addIrcUser(hostmask: QString | null)
-    addSupport(param: QString | null, value: QString | null = null)
+    acknowledgeCap(capability: QString)
+    addCap(capability: String, value: QString)
+    addIrcChannel(channel: QString)
+    addIrcUser(hostmask: QString)
+    addSupport(param: QString, value: QString)
     clearCaps()
-    emitConnectionError(error: QString | null)
-    ircUserNickChanged(before: QString | null, after: QString | null)
-    removeCap(capability: QString | null)
-    removeSupport(param: QString | null)
-    setAutoIdentifyPassword(password: QString | null)
-    setAutoIdentifyService(service: QString | null)
+    emitConnectionError(error: QString)
+    ircUserNickChanged(before: QString, after: QString)
+    removeCap(capability: QString)
+    removeSupport(param: QString)
+    setAutoIdentifyPassword(password: QString)
+    setAutoIdentifyService(service: QString)
     setAutoReconnectInterval(interval: UInt)
     setAutoReconnectRetries(retries: UShort)
     setCodecForDecoding(codecName: QByteBuffer | null)
@@ -1060,18 +1060,18 @@ interface Network {
     setCodecForServer(codecName: QByteBuffer | null)
     setConnected(isConnected: Bool)
     setConnectionState(state: Int)
-    setCurrentServer(currentServer: QString | null)
+    setCurrentServer(currentServer: QString)
     setIdentity(identity: IdentityId)
     setLatency(latency: Int)
     setMessageRateBurstSize(burstSize: UInt)
     setMessageRateDelay(messageDelay: UInt)
-    setMyNick(mynick: QString | null)
-    setNetworkName(networkName: QString | null)
+    setMyNick(mynick: QString)
+    setNetworkName(networkName: QString)
     setNetworkInfo(info: NetworkInfo)
     setPerform(perform: QStringList)
     setRejoinChannels(rejoinChannels: Bool)
-    setSaslAccount(account: QString | null)
-    setSaslPassword(password: QString | null)
+    setSaslAccount(account: QString)
+    setSaslPassword(password: QString)
     setServerList(serverList: QVariantList)
     setActualServerList(serverList: [NetworkServer])
     setUnlimitedMessageRate(unlimitedRate: Bool)
diff --git a/docs/protocol/serialization/signalproxy_rpc.md b/docs/protocol/serialization/signalproxy_rpc.md
new file mode 100644
index 0000000..fc2a46c
--- /dev/null
+++ b/docs/protocol/serialization/signalproxy_rpc.md
@@ -0,0 +1,106 @@
+# SignalProxy RPC calls
+
+## C->S calls
+
+### `2createIdentity(Identity,QVariantMap)`
+
+- `identity`: `Identity`
+- `additional`: `QVariantMap`  
+  Always empty
+
+### `2removeIdentity(IdentityId)`
+
+- `identity`: `IdentityId`
+
+### `2createNetwork(NetworkInfo,QStringList)`
+
+- `networkInfo`: `NetworkInfo`
+- `channels`: `QStringList`
+
+### `2removeNetwork(NetworkId)`
+
+- `network`: `NetworkId`
+
+### `2changePassword(PeerPtr,QString,QString,QString)`
+
+- `peerPtr`: `Long`  
+  Always zero, only has a value within of the core itself.
+- `user`: `QString`
+  Username
+- `before`: `QString`
+  Old password
+- `after`: `QString`
+  New password
+
+### `2kickClient(int)`
+
+- `id`: `Int`  
+  Client id of client to be kicked.  
+  Ids can be found here [CoreInfo](signalproxy_objects.md#coreinfo)
+
+### `2sendInput(BufferInfo,QString)`
+
+- `bufferInfo`: `BufferInfo`
+- `message`: `QString`
+
+## S->C calls
+
+### `__objectRenamed__`
+
+- `classname`: `QByteArray`
+- `newname`: `QString`
+- `oldname`: `QString`
+
+Called whenever an object has been renamed, and the object store should update
+its name. All future sync calls for this object will use the new name instead.
+
+### `2displayMsg(Message)`
+
+- `message`: `Message`
+
+Called when a new IRC message has been received, and the client should display
+or store it.
+
+### `2displayStatusMsg(QString,QString)`
+
+- `network`: `QString`
+- `message`: `QString`
+
+Status message for an IRC network to be shown in the client’s status bar (if
+available).
+
+### `2bufferInfoUpdated(BufferInfo)`
+
+- `bufferInfo`: `BufferInfo`
+
+### `2identityCreated(Identity)`
+
+- `identity`: `Identity`
+
+### `2identityRemoved(IdentityId)`
+
+- `identity`: `IdentityId`
+
+### `2networkCreated(NetworkId)`
+
+- `network`: `NetworkId`
+
+### `2networkRemoved(NetworkId)`
+
+- `network`: `NetworkId`
+
+### `2passwordChanged(PeerPtr,bool)`
+
+- `peerPtr`: `Long`  
+  Always zero, only has a value within of the core itself
+- `success`: `Bool`
+
+Returns if the recent password change attempt has been a success.
+
+This is one of the few responses which only gets sent to the client which sent
+the original request. 
+
+### `2disconnectFromCore()`
+
+Requests the current client to disconnect from the core. Only this client sees
+this message.
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index 5cc1175..8ab0f12 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -12,15 +12,17 @@ nav:
   - "Usage":
     - "Upgrade Guide": usage/upgrade_guide.md
   - "Protocol":
+    - "Overview": protocol/overview.md
     - "Layers":
       - "Framing": protocol/layers/framing.md
       - "Message": protocol/layers/message.md
     - "Serialization":
-      - "Handshake Messages": protocol/serialization/handshake_messages.md
       - "Features": protocol/serialization/features.md
+      - "Primitive Objects": protocol/serialization/primitive_objects.md
+      - "Handshake Messages": protocol/serialization/handshake_messages.md
       - "SignalProxy Messages": protocol/serialization/signalproxy_messages.md
       - "SignalProxy Objects": protocol/serialization/signalproxy_objects.md
-      - "Primitive Objects": protocol/serialization/primitive_objects.md
+      - "SignalProxy RPC calls": protocol/serialization/signalproxy_rpc.md
 
 extra:
   social:
-- 
GitLab