Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • api-redesign
  • main
  • 0.10.0
  • 0.10.1
  • 0.10.2
  • 0.7.0
  • 0.8.0
  • 0.8.1
  • 0.9.0
  • 0.9.1
  • 0.9.2
11 results

Target

Select target project
  • justJanne/libquassel
1 result
Select Git revision
  • api-redesign
  • main
  • 0.10.0
  • 0.10.1
  • 0.10.2
  • 0.7.0
  • 0.8.0
  • 0.8.1
  • 0.9.0
  • 0.9.1
  • 0.9.2
11 results
Show changes
Showing
with 238 additions and 249 deletions
...@@ -14,10 +14,12 @@ enum class HighlightNickType( ...@@ -14,10 +14,12 @@ enum class HighlightNickType(
) { ) {
NoNick(0), NoNick(0),
CurrentNick(1), CurrentNick(1),
AllNicks(2); AllNicks(2),
;
companion object { companion object {
private val values = enumValues<HighlightNickType>() private val values =
enumValues<HighlightNickType>()
.associateBy(HighlightNickType::value) .associateBy(HighlightNickType::value)
/** /**
......
/*
* libquassel
* Copyright (c) 2021 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.protocol.models.rules
import de.justjanne.libquassel.protocol.util.expression.ExpressionMatch
data class HighlightRule(
val id: Int,
val content: String,
val isRegEx: Boolean = false,
val isCaseSensitive: Boolean = false,
val isEnabled: Boolean = true,
val isInverse: Boolean = false,
val sender: String,
val channel: String
) {
val contentMatch = ExpressionMatch(
content,
if (isRegEx) ExpressionMatch.MatchMode.MatchRegEx
else ExpressionMatch.MatchMode.MatchPhrase,
isCaseSensitive
)
val senderMatch = ExpressionMatch(
sender,
if (isRegEx) ExpressionMatch.MatchMode.MatchRegEx
else ExpressionMatch.MatchMode.MatchMultiWildcard,
isCaseSensitive
)
val channelMatch = ExpressionMatch(
channel,
if (isRegEx) ExpressionMatch.MatchMode.MatchRegEx
else ExpressionMatch.MatchMode.MatchMultiWildcard,
isCaseSensitive
)
}
/*
* libquassel
* Copyright (c) 2021 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.protocol.models.rules
import de.justjanne.libquassel.protocol.util.expression.ExpressionMatch
data class IgnoreRule(
val type: IgnoreType,
val ignoreRule: String,
val isRegEx: Boolean = false,
val strictness: StrictnessType,
val isEnabled: Boolean = true,
val scope: ScopeType,
val scopeRule: String
) {
val ignoreMatch = ExpressionMatch(
ignoreRule,
if (isRegEx) ExpressionMatch.MatchMode.MatchRegEx
else ExpressionMatch.MatchMode.MatchWildcard,
false
)
val scopeMatch = ExpressionMatch(
scopeRule,
ExpressionMatch.MatchMode.MatchMultiWildcard,
false
)
}
...@@ -10,14 +10,16 @@ ...@@ -10,14 +10,16 @@
package de.justjanne.libquassel.protocol.models.rules package de.justjanne.libquassel.protocol.models.rules
enum class IgnoreType( enum class IgnoreType(
val value: Int val value: Int,
) { ) {
SenderIgnore(0), SenderIgnore(0),
MessageIgnore(1), MessageIgnore(1),
CtcpIgnore(2); CtcpIgnore(2),
;
companion object { companion object {
private val values = enumValues<IgnoreType>() private val values =
enumValues<IgnoreType>()
.associateBy(IgnoreType::value) .associateBy(IgnoreType::value)
/** /**
......
...@@ -10,14 +10,16 @@ ...@@ -10,14 +10,16 @@
package de.justjanne.libquassel.protocol.models.rules package de.justjanne.libquassel.protocol.models.rules
enum class ScopeType( enum class ScopeType(
val value: Int val value: Int,
) { ) {
GlobalScope(0), GlobalScope(0),
NetworkScope(1), NetworkScope(1),
ChannelScope(2); ChannelScope(2),
;
companion object { companion object {
private val values = enumValues<ScopeType>() private val values =
enumValues<ScopeType>()
.associateBy(ScopeType::value) .associateBy(ScopeType::value)
/** /**
......
...@@ -10,14 +10,16 @@ ...@@ -10,14 +10,16 @@
package de.justjanne.libquassel.protocol.models.rules package de.justjanne.libquassel.protocol.models.rules
enum class StrictnessType( enum class StrictnessType(
val value: Int val value: Int,
) { ) {
UnmatchedStrictness(0), UnmatchedStrictness(0),
SoftStrictness(1), SoftStrictness(1),
HardStrictness(2); HardStrictness(2),
;
companion object { companion object {
private val values = enumValues<StrictnessType>() private val values =
enumValues<StrictnessType>()
.associateBy(StrictnessType::value) .associateBy(StrictnessType::value)
/** /**
......
...@@ -25,61 +25,72 @@ object BackendInfoSerializer { ...@@ -25,61 +25,72 @@ object BackendInfoSerializer {
/** /**
* Serialize backend info into a [QVariantMap] (for further serialization) * Serialize backend info into a [QVariantMap] (for further serialization)
*/ */
fun serialize(data: BackendInfo): QVariantMap = mapOf( fun serialize(data: BackendInfo): QVariantMap =
"SetupKeys" to qVariant<QStringList>( mapOf(
"SetupKeys" to
qVariant<QStringList>(
data.entries.map(SetupEntry::key), data.entries.map(SetupEntry::key),
QtType.QStringList QtType.QStringList,
), ),
"SetupDefaults" to qVariant<QVariantMap>( "SetupDefaults" to
qVariant<QVariantMap>(
data.entries.map { it.key to it.defaultValue }.toMap<String, QVariant_>(), data.entries.map { it.key to it.defaultValue }.toMap<String, QVariant_>(),
QtType.QVariantMap QtType.QVariantMap,
), ),
"SetupData" to qVariant<QVariantList>( "SetupData" to
qVariant<QVariantList>(
data.entries.flatMap { data.entries.flatMap {
listOf<QVariant_>( listOf<QVariant_>(
qVariant(it.key, QtType.QString), qVariant(it.key, QtType.QString),
qVariant(it.displayName, QtType.QString), qVariant(it.displayName, QtType.QString),
it.defaultValue it.defaultValue,
) )
}, },
QtType.QVariantList QtType.QVariantList,
), ),
"IsDefault" to qVariant( "IsDefault" to
qVariant(
data.isDefault, data.isDefault,
QtType.Bool QtType.Bool,
), ),
"DisplayName" to qVariant( "DisplayName" to
qVariant(
data.displayName, data.displayName,
QtType.QString QtType.QString,
), ),
"Description" to qVariant( "Description" to
qVariant(
data.description, data.description,
QtType.QString QtType.QString,
), ),
"BackendId" to qVariant( "BackendId" to
qVariant(
data.backendId, data.backendId,
QtType.QString QtType.QString,
), ),
) )
private fun parseSetupEntries( private fun parseSetupEntries(
data: QVariantList?, data: QVariantList?,
defaults: QVariantMap defaults: QVariantMap,
): List<SetupEntry> = data?.triples { key, displayName, defaultValue -> ): List<SetupEntry> =
data?.triples { key, displayName, defaultValue ->
SetupEntry(key.into(""), displayName.into(""), defaultValue) SetupEntry(key.into(""), displayName.into(""), defaultValue)
} ?: defaults.map { (key, value) -> SetupEntry(key, key, value) } } ?: defaults.map { (key, value) -> SetupEntry(key, key, value) }
/** /**
* Deserialize backend info from a [QVariantMap] * Deserialize backend info from a [QVariantMap]
*/ */
fun deserialize(data: QVariantMap) = BackendInfo( fun deserialize(data: QVariantMap) =
entries = parseSetupEntries( BackendInfo(
entries =
parseSetupEntries(
data["SetupData"].into<QVariantList>(), data["SetupData"].into<QVariantList>(),
data["SetupDefaults"].into<QVariantMap>().orEmpty() data["SetupDefaults"].into<QVariantMap>().orEmpty(),
), ),
isDefault = data["IsDefault"].into<Boolean>(false), isDefault = data["IsDefault"].into<Boolean>(false),
displayName = data["DisplayName"].into<String>(""), displayName = data["DisplayName"].into<String>(""),
description = data["Description"].into<String>(""), description = data["Description"].into<String>(""),
backendId = data["BackendId"].into<String>("") backendId = data["BackendId"].into<String>(""),
) )
} }
...@@ -47,7 +47,7 @@ enum class QtType( ...@@ -47,7 +47,7 @@ enum class QtType(
* Serializer for data described by this type * Serializer for data described by this type
*/ */
@PublishedApi @PublishedApi
internal val serializer: PrimitiveSerializer<*>? = null internal val serializer: PrimitiveSerializer<*>? = null,
) { ) {
/** /**
* Void, no data at all * Void, no data at all
...@@ -186,7 +186,8 @@ enum class QtType( ...@@ -186,7 +186,8 @@ enum class QtType(
* Custom data with a special (de-)serializer * Custom data with a special (de-)serializer
* See [QuasselType] * See [QuasselType]
*/ */
UserType(127); UserType(127),
;
/** /**
* Obtain a serializer for this type (type safe) * Obtain a serializer for this type (type safe)
...@@ -201,7 +202,8 @@ enum class QtType( ...@@ -201,7 +202,8 @@ enum class QtType(
} }
companion object { companion object {
private val values = enumValues<QtType>() private val values =
enumValues<QtType>()
.associateBy(QtType::id) .associateBy(QtType::id)
/** /**
......
...@@ -149,7 +149,8 @@ enum class QuasselType( ...@@ -149,7 +149,8 @@ enum class QuasselType(
* This is used in the core to return responses to the same client that made * This is used in the core to return responses to the same client that made
* a request. * a request.
*/ */
PeerPtr("PeerPtr", PeerPtrSerializer); PeerPtr("PeerPtr", PeerPtrSerializer),
;
/** /**
* Obtain a serializer for this type (type safe) * Obtain a serializer for this type (type safe)
...@@ -164,7 +165,8 @@ enum class QuasselType( ...@@ -164,7 +165,8 @@ enum class QuasselType(
} }
companion object { companion object {
private val values = enumValues<QuasselType>() private val values =
enumValues<QuasselType>()
.associateBy(QuasselType::typeName) .associateBy(QuasselType::typeName)
/** /**
......
...@@ -83,11 +83,18 @@ object HandshakeMessageSerializer : PrimitiveSerializer<HandshakeMessage> { ...@@ -83,11 +83,18 @@ object HandshakeMessageSerializer : PrimitiveSerializer<HandshakeMessage> {
throw NoSerializerForTypeException.Handshake(type) throw NoSerializerForTypeException.Handshake(type)
} }
override fun serialize(buffer: ChainedByteBuffer, data: HandshakeMessage, featureSet: FeatureSet) { override fun serialize(
buffer: ChainedByteBuffer,
data: HandshakeMessage,
featureSet: FeatureSet,
) {
HandshakeMapSerializer.serialize(buffer, serializeToMap(data), featureSet) HandshakeMapSerializer.serialize(buffer, serializeToMap(data), featureSet)
} }
override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): HandshakeMessage { override fun deserialize(
buffer: ByteBuffer,
featureSet: FeatureSet,
): HandshakeMessage {
return deserializeFromMap(HandshakeMapSerializer.deserialize(buffer, featureSet)) return deserializeFromMap(HandshakeMapSerializer.deserialize(buffer, featureSet))
} }
} }
...@@ -21,11 +21,11 @@ sealed class NoSerializerForTypeException : Exception() { ...@@ -21,11 +21,11 @@ sealed class NoSerializerForTypeException : Exception() {
*/ */
data class Qt( data class Qt(
private val type: Int, private val type: Int,
private val javaType: Class<*>? = null private val javaType: Class<*>? = null,
) : NoSerializerForTypeException() { ) : NoSerializerForTypeException() {
constructor( constructor(
type: QtType, type: QtType,
javaType: Class<*>? = null javaType: Class<*>? = null,
) : this(type.id, javaType) ) : this(type.id, javaType)
override fun toString(): String { override fun toString(): String {
...@@ -39,17 +39,17 @@ sealed class NoSerializerForTypeException : Exception() { ...@@ -39,17 +39,17 @@ sealed class NoSerializerForTypeException : Exception() {
data class Quassel( data class Quassel(
private val type: Int, private val type: Int,
private val typename: String?, private val typename: String?,
private val javaType: Class<*>? = null private val javaType: Class<*>? = null,
) : NoSerializerForTypeException() { ) : NoSerializerForTypeException() {
constructor( constructor(
type: QtType, type: QtType,
typename: String?, typename: String?,
javaType: Class<*>? = null javaType: Class<*>? = null,
) : this(type.id, typename, javaType) ) : this(type.id, typename, javaType)
constructor( constructor(
type: QuasselType, type: QuasselType,
javaType: Class<*>? = null javaType: Class<*>? = null,
) : this(type.qtType, type.typeName, javaType) ) : this(type.qtType, type.typeName, javaType)
override fun toString(): String { override fun toString(): String {
...@@ -62,7 +62,7 @@ sealed class NoSerializerForTypeException : Exception() { ...@@ -62,7 +62,7 @@ sealed class NoSerializerForTypeException : Exception() {
*/ */
data class Handshake( data class Handshake(
private val type: String, private val type: String,
private val javaType: Class<*>? = null private val javaType: Class<*>? = null,
) : NoSerializerForTypeException() { ) : NoSerializerForTypeException() {
override fun toString(): String { override fun toString(): String {
return "NoSerializerForTypeException.Handshake(type='$type', javaType=$javaType)" return "NoSerializerForTypeException.Handshake(type='$type', javaType=$javaType)"
...@@ -74,7 +74,7 @@ sealed class NoSerializerForTypeException : Exception() { ...@@ -74,7 +74,7 @@ sealed class NoSerializerForTypeException : Exception() {
*/ */
data class SignalProxy( data class SignalProxy(
private val type: Int, private val type: Int,
private val javaType: Class<*>? = null private val javaType: Class<*>? = null,
) : NoSerializerForTypeException() { ) : NoSerializerForTypeException() {
override fun toString(): String { override fun toString(): String {
return "NoSerializerForTypeException.SignalProxy(type='$type', javaType=$javaType)" return "NoSerializerForTypeException.SignalProxy(type='$type', javaType=$javaType)"
......
...@@ -24,6 +24,7 @@ interface PrimitiveSerializer<T> { ...@@ -24,6 +24,7 @@ interface PrimitiveSerializer<T> {
* Used for type-safe serializer autodiscovery. * Used for type-safe serializer autodiscovery.
*/ */
val javaType: Class<out T> val javaType: Class<out T>
/** /**
* Serialize data with the Quassel protocol to a buffer * Serialize data with the Quassel protocol to a buffer
* @param buffer target buffer to serialize to * @param buffer target buffer to serialize to
...@@ -31,7 +32,11 @@ interface PrimitiveSerializer<T> { ...@@ -31,7 +32,11 @@ interface PrimitiveSerializer<T> {
* @param featureSet features to use when serializing, usually the featureset * @param featureSet features to use when serializing, usually the featureset
* of the currently negotiated connection * of the currently negotiated connection
*/ */
fun serialize(buffer: ChainedByteBuffer, data: T, featureSet: FeatureSet) fun serialize(
buffer: ChainedByteBuffer,
data: T,
featureSet: FeatureSet,
)
/** /**
* Deserialize Quassel protocol data from a buffer * Deserialize Quassel protocol data from a buffer
...@@ -39,5 +44,8 @@ interface PrimitiveSerializer<T> { ...@@ -39,5 +44,8 @@ interface PrimitiveSerializer<T> {
* @param featureSet features to use when deserializing, usually the * @param featureSet features to use when deserializing, usually the
* featureset of the currently negotiated connection * featureset of the currently negotiated connection
*/ */
fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): T fun deserialize(
buffer: ByteBuffer,
featureSet: FeatureSet,
): T
} }
...@@ -63,11 +63,18 @@ object SignalProxyMessageSerializer : PrimitiveSerializer<SignalProxyMessage> { ...@@ -63,11 +63,18 @@ object SignalProxyMessageSerializer : PrimitiveSerializer<SignalProxyMessage> {
throw NoSerializerForTypeException.SignalProxy(type) throw NoSerializerForTypeException.SignalProxy(type)
} }
override fun serialize(buffer: ChainedByteBuffer, data: SignalProxyMessage, featureSet: FeatureSet) { override fun serialize(
buffer: ChainedByteBuffer,
data: SignalProxyMessage,
featureSet: FeatureSet,
) {
QVariantListSerializer.serialize(buffer, serializeToList(data), featureSet) QVariantListSerializer.serialize(buffer, serializeToList(data), featureSet)
} }
override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): SignalProxyMessage { override fun deserialize(
buffer: ByteBuffer,
featureSet: FeatureSet,
): SignalProxyMessage {
return deserializeFromList(QVariantListSerializer.deserialize(buffer, featureSet)) return deserializeFromList(QVariantListSerializer.deserialize(buffer, featureSet))
} }
} }
...@@ -30,47 +30,55 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -30,47 +30,55 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientInitAckSerializer : HandshakeSerializer<HandshakeMessage.ClientInitAck> { object ClientInitAckSerializer : HandshakeSerializer<HandshakeMessage.ClientInitAck> {
override val type: String = "ClientInitAck" override val type: String = "ClientInitAck"
override fun serialize(data: HandshakeMessage.ClientInitAck) = mapOf( override fun serialize(data: HandshakeMessage.ClientInitAck) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
"CoreFeatures" to qVariant(data.featureSet.legacyFeatures().toBits(), QtType.UInt), "CoreFeatures" to qVariant(data.featureSet.legacyFeatures().toBits(), QtType.UInt),
"StorageBackends" to qVariant<QVariantList>( "StorageBackends" to
qVariant<QVariantList>(
data.backendInfo.map { data.backendInfo.map {
qVariant<QVariantMap>( qVariant<QVariantMap>(
BackendInfoSerializer.serialize(it), BackendInfoSerializer.serialize(it),
QtType.QVariantMap QtType.QVariantMap,
) )
}, },
QtType.QVariantList QtType.QVariantList,
), ),
"Authenticator" to qVariant<QVariantList>( "Authenticator" to
qVariant<QVariantList>(
data.authenticatorInfo.map { data.authenticatorInfo.map {
qVariant<QVariantMap>( qVariant<QVariantMap>(
BackendInfoSerializer.serialize(it), BackendInfoSerializer.serialize(it),
QtType.QVariantMap QtType.QVariantMap,
) )
}, },
QtType.QVariantList QtType.QVariantList,
), ),
"Configured" to qVariant(data.coreConfigured, QtType.Bool), "Configured" to qVariant(data.coreConfigured, QtType.Bool),
"FeatureList" to qVariant( "FeatureList" to
qVariant(
data.featureSet.featureList().map(QuasselFeatureName::name), data.featureSet.featureList().map(QuasselFeatureName::name),
QtType.QStringList QtType.QStringList,
) ),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.ClientInitAck( override fun deserialize(data: QVariantMap) =
HandshakeMessage.ClientInitAck(
coreConfigured = data["Configured"].into(), coreConfigured = data["Configured"].into(),
backendInfo = data["StorageBackends"].into<QVariantList>()?.mapNotNull { backendInfo =
data["StorageBackends"].into<QVariantList>()?.mapNotNull {
it.into<QVariantMap>() it.into<QVariantMap>()
}?.map(BackendInfoSerializer::deserialize).orEmpty(), }?.map(BackendInfoSerializer::deserialize).orEmpty(),
authenticatorInfo = data["Authenticator"].into<QVariantList>()?.mapNotNull { authenticatorInfo =
data["Authenticator"].into<QVariantList>()?.mapNotNull {
it.into<QVariantMap>() it.into<QVariantMap>()
}?.map(BackendInfoSerializer::deserialize).orEmpty(), }?.map(BackendInfoSerializer::deserialize).orEmpty(),
featureSet = FeatureSet.build( featureSet =
FeatureSet.build(
LegacyFeature.of(data["CoreFeatures"].into<UInt>()), LegacyFeature.of(data["CoreFeatures"].into<UInt>()),
data["FeatureList"].into<QStringList>(emptyList()) data["FeatureList"].into<QStringList>(emptyList())
.filterNotNull() .filterNotNull()
.map(::QuasselFeatureName) .map(::QuasselFeatureName),
) ),
) )
} }
...@@ -22,12 +22,14 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -22,12 +22,14 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientInitRejectSerializer : HandshakeSerializer<HandshakeMessage.ClientInitReject> { object ClientInitRejectSerializer : HandshakeSerializer<HandshakeMessage.ClientInitReject> {
override val type: String = "ClientInitReject" override val type: String = "ClientInitReject"
override fun serialize(data: HandshakeMessage.ClientInitReject) = mapOf( override fun serialize(data: HandshakeMessage.ClientInitReject) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
"Error" to qVariant(data.errorString, QtType.QString) "Error" to qVariant(data.errorString, QtType.QString),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.ClientInitReject( override fun deserialize(data: QVariantMap) =
errorString = data["Error"].into() HandshakeMessage.ClientInitReject(
errorString = data["Error"].into(),
) )
} }
...@@ -28,25 +28,29 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -28,25 +28,29 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientInitSerializer : HandshakeSerializer<HandshakeMessage.ClientInit> { object ClientInitSerializer : HandshakeSerializer<HandshakeMessage.ClientInit> {
override val type: String = "ClientInit" override val type: String = "ClientInit"
override fun serialize(data: HandshakeMessage.ClientInit) = mapOf( override fun serialize(data: HandshakeMessage.ClientInit) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
"ClientVersion" to qVariant(data.clientVersion, QtType.QString), "ClientVersion" to qVariant(data.clientVersion, QtType.QString),
"ClientDate" to qVariant(data.buildDate, QtType.QString), "ClientDate" to qVariant(data.buildDate, QtType.QString),
"Features" to qVariant(data.featureSet.legacyFeatures().toBits(), QtType.UInt), "Features" to qVariant(data.featureSet.legacyFeatures().toBits(), QtType.UInt),
"FeatureList" to qVariant( "FeatureList" to
qVariant(
data.featureSet.featureList().map(QuasselFeatureName::name), data.featureSet.featureList().map(QuasselFeatureName::name),
QtType.QStringList QtType.QStringList,
), ),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.ClientInit( override fun deserialize(data: QVariantMap) =
HandshakeMessage.ClientInit(
clientVersion = data["ClientVersion"].into(), clientVersion = data["ClientVersion"].into(),
buildDate = data["ClientDate"].into(), buildDate = data["ClientDate"].into(),
featureSet = FeatureSet.build( featureSet =
FeatureSet.build(
LegacyFeature.of(data["Features"].into<UInt>()), LegacyFeature.of(data["Features"].into<UInt>()),
data["FeatureList"].into<QStringList>(emptyList()) data["FeatureList"].into<QStringList>(emptyList())
.filterNotNull() .filterNotNull()
.map(::QuasselFeatureName) .map(::QuasselFeatureName),
) ),
) )
} }
...@@ -21,7 +21,8 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -21,7 +21,8 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientLoginAckSerializer : HandshakeSerializer<HandshakeMessage.ClientLoginAck> { object ClientLoginAckSerializer : HandshakeSerializer<HandshakeMessage.ClientLoginAck> {
override val type: String = "ClientLoginAck" override val type: String = "ClientLoginAck"
override fun serialize(data: HandshakeMessage.ClientLoginAck) = mapOf( override fun serialize(data: HandshakeMessage.ClientLoginAck) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
) )
......
...@@ -22,12 +22,14 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -22,12 +22,14 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientLoginRejectSerializer : HandshakeSerializer<HandshakeMessage.ClientLoginReject> { object ClientLoginRejectSerializer : HandshakeSerializer<HandshakeMessage.ClientLoginReject> {
override val type: String = "ClientLoginReject" override val type: String = "ClientLoginReject"
override fun serialize(data: HandshakeMessage.ClientLoginReject) = mapOf( override fun serialize(data: HandshakeMessage.ClientLoginReject) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
"Error" to qVariant(data.errorString, QtType.QString) "Error" to qVariant(data.errorString, QtType.QString),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.ClientLoginReject( override fun deserialize(data: QVariantMap) =
errorString = data["Error"].into() HandshakeMessage.ClientLoginReject(
errorString = data["Error"].into(),
) )
} }
...@@ -22,13 +22,15 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -22,13 +22,15 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object ClientLoginSerializer : HandshakeSerializer<HandshakeMessage.ClientLogin> { object ClientLoginSerializer : HandshakeSerializer<HandshakeMessage.ClientLogin> {
override val type: String = "ClientLogin" override val type: String = "ClientLogin"
override fun serialize(data: HandshakeMessage.ClientLogin) = mapOf( override fun serialize(data: HandshakeMessage.ClientLogin) =
mapOf(
"MsgType" to qVariant(type, QtType.QString), "MsgType" to qVariant(type, QtType.QString),
"User" to qVariant(data.user, QtType.QString), "User" to qVariant(data.user, QtType.QString),
"Password" to qVariant(data.password, QtType.QString) "Password" to qVariant(data.password, QtType.QString),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.ClientLogin( override fun deserialize(data: QVariantMap) =
HandshakeMessage.ClientLogin(
user = data["User"].into(), user = data["User"].into(),
password = data["Password"].into(), password = data["Password"].into(),
) )
......
...@@ -21,8 +21,9 @@ import de.justjanne.libquassel.protocol.variant.qVariant ...@@ -21,8 +21,9 @@ import de.justjanne.libquassel.protocol.variant.qVariant
object CoreSetupAckSerializer : HandshakeSerializer<HandshakeMessage.CoreSetupAck> { object CoreSetupAckSerializer : HandshakeSerializer<HandshakeMessage.CoreSetupAck> {
override val type: String = "CoreSetupAck" override val type: String = "CoreSetupAck"
override fun serialize(data: HandshakeMessage.CoreSetupAck) = mapOf( override fun serialize(data: HandshakeMessage.CoreSetupAck) =
"MsgType" to qVariant(type, QtType.QString) mapOf(
"MsgType" to qVariant(type, QtType.QString),
) )
override fun deserialize(data: QVariantMap) = HandshakeMessage.CoreSetupAck override fun deserialize(data: QVariantMap) = HandshakeMessage.CoreSetupAck
......