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 124 additions and 96 deletions
...@@ -26,10 +26,12 @@ enum class DccPortSelectionMode( ...@@ -26,10 +26,12 @@ enum class DccPortSelectionMode(
/** /**
* Manually specified port range * Manually specified port range
*/ */
Manual(0x01u); Manual(0x01u),
;
companion object { companion object {
private val values = enumValues<DccPortSelectionMode>() private val values =
enumValues<DccPortSelectionMode>()
.associateBy(DccPortSelectionMode::value) .associateBy(DccPortSelectionMode::value)
/** /**
......
...@@ -24,6 +24,7 @@ enum class NetworkLayerProtocol( ...@@ -24,6 +24,7 @@ enum class NetworkLayerProtocol(
* See [RFC-791](https://tools.ietf.org/html/rfc791) * See [RFC-791](https://tools.ietf.org/html/rfc791)
*/ */
IPv4Protocol(0x00u), IPv4Protocol(0x00u),
/** /**
* Internet Protocol Version 6 * Internet Protocol Version 6
* *
...@@ -40,10 +41,12 @@ enum class NetworkLayerProtocol( ...@@ -40,10 +41,12 @@ enum class NetworkLayerProtocol(
/** /**
* Any other network protocol * Any other network protocol
*/ */
UnknownNetworkLayerProtocol(0xFFu); UnknownNetworkLayerProtocol(0xFFu),
;
companion object { companion object {
private val values = enumValues<NetworkLayerProtocol>() private val values =
enumValues<NetworkLayerProtocol>()
.associateBy(NetworkLayerProtocol::value) .associateBy(NetworkLayerProtocol::value)
/** /**
......
...@@ -13,10 +13,12 @@ enum class TransferDirection( ...@@ -13,10 +13,12 @@ enum class TransferDirection(
val value: Int, val value: Int,
) { ) {
Send(0), Send(0),
Receive(1); Receive(1),
;
companion object { companion object {
private val values = enumValues<TransferDirection>() private val values =
enumValues<TransferDirection>()
.associateBy(TransferDirection::value) .associateBy(TransferDirection::value)
/** /**
......
...@@ -19,10 +19,12 @@ enum class TransferStatus( ...@@ -19,10 +19,12 @@ enum class TransferStatus(
Paused(4), Paused(4),
Completed(5), Completed(5),
Failed(6), Failed(6),
Rejected(7); Rejected(7),
;
companion object { companion object {
private val values = enumValues<TransferStatus>() private val values =
enumValues<TransferStatus>()
.associateBy(TransferStatus::value) .associateBy(TransferStatus::value)
/** /**
......
...@@ -37,10 +37,12 @@ enum class BufferType( ...@@ -37,10 +37,12 @@ enum class BufferType(
/** /**
* Unnamed group between multiple users * Unnamed group between multiple users
*/ */
Group(0x08u); Group(0x08u),
;
companion object : Flags<UShort, BufferType> { companion object : Flags<UShort, BufferType> {
private val values = enumValues<BufferType>() private val values =
enumValues<BufferType>()
.associateBy(BufferType::value) .associateBy(BufferType::value)
override val all: BufferTypes = values.values.toEnumSet() override val all: BufferTypes = values.values.toEnumSet()
} }
......
...@@ -52,10 +52,12 @@ enum class MessageFlag( ...@@ -52,10 +52,12 @@ enum class MessageFlag(
* *
* Message was loaded from history * Message was loaded from history
*/ */
Backlog(0x80u); Backlog(0x80u),
;
companion object : Flags<UInt, MessageFlag> { companion object : Flags<UInt, MessageFlag> {
private val values = enumValues<MessageFlag>() private val values =
enumValues<MessageFlag>()
.associateBy(MessageFlag::value) .associateBy(MessageFlag::value)
override val all: MessageFlags = values.values.toEnumSet() override val all: MessageFlags = values.values.toEnumSet()
} }
......
...@@ -112,10 +112,12 @@ enum class MessageType( ...@@ -112,10 +112,12 @@ enum class MessageType(
/** /**
* Last read marker * Last read marker
*/ */
Markerline(0x40000u); Markerline(0x40000u),
;
companion object : Flags<UInt, MessageType> { companion object : Flags<UInt, MessageType> {
private val values = enumValues<MessageType>() private val values =
enumValues<MessageType>()
.associateBy(MessageType::value) .associateBy(MessageType::value)
override val all: MessageTypes = values.values.toEnumSet() override val all: MessageTypes = values.values.toEnumSet()
} }
......
...@@ -19,7 +19,7 @@ value class BufferId( ...@@ -19,7 +19,7 @@ value class BufferId(
/** /**
* Native value * Native value
*/ */
override val id: BufferIdType override val id: BufferIdType,
) : SignedId<BufferIdType> { ) : SignedId<BufferIdType> {
override fun toString() = "BufferId($id)" override fun toString() = "BufferId($id)"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
package de.justjanne.libquassel.protocol.models.ids package de.justjanne.libquassel.protocol.models.ids
private typealias IdentityIdType = SignedIdType private typealias IdentityIdType = SignedIdType
/** /**
* A [SignedId] for an identity object * A [SignedId] for an identity object
*/ */
...@@ -18,7 +19,7 @@ value class IdentityId( ...@@ -18,7 +19,7 @@ value class IdentityId(
/** /**
* Native value * Native value
*/ */
override val id: IdentityIdType override val id: IdentityIdType,
) : SignedId<IdentityIdType> { ) : SignedId<IdentityIdType> {
override fun toString() = "IdentityId($id)" override fun toString() = "IdentityId($id)"
...@@ -27,6 +28,7 @@ value class IdentityId( ...@@ -27,6 +28,7 @@ value class IdentityId(
* Lower limit for this type * Lower limit for this type
*/ */
val MIN_VALUE = IdentityId(IdentityIdType.MIN_VALUE) val MIN_VALUE = IdentityId(IdentityIdType.MIN_VALUE)
/** /**
* Upper limit for this type * Upper limit for this type
*/ */
......
...@@ -20,7 +20,7 @@ value class MsgId( ...@@ -20,7 +20,7 @@ value class MsgId(
/** /**
* Native value * Native value
*/ */
override val id: MsgIdType override val id: MsgIdType,
) : SignedId<MsgIdType> { ) : SignedId<MsgIdType> {
override fun toString() = "MsgId($id)" override fun toString() = "MsgId($id)"
......
...@@ -19,7 +19,7 @@ value class NetworkId( ...@@ -19,7 +19,7 @@ value class NetworkId(
/** /**
* Native value * Native value
*/ */
override val id: NetworkIdType override val id: NetworkIdType,
) : SignedId<NetworkIdType> { ) : SignedId<NetworkIdType> {
override fun toString() = "NetworkId($id)" override fun toString() = "NetworkId($id)"
......
...@@ -15,6 +15,7 @@ import java.io.Serializable ...@@ -15,6 +15,7 @@ import java.io.Serializable
* Native representation of a SignedId * Native representation of a SignedId
*/ */
typealias SignedIdType = Int typealias SignedIdType = Int
/** /**
* Native representation of a SignedId64 * Native representation of a SignedId64
*/ */
......
...@@ -19,10 +19,12 @@ enum class ChannelModeType( ...@@ -19,10 +19,12 @@ enum class ChannelModeType(
A_CHANMODE(0x01u), A_CHANMODE(0x01u),
B_CHANMODE(0x02u), B_CHANMODE(0x02u),
C_CHANMODE(0x04u), C_CHANMODE(0x04u),
D_CHANMODE(0x08u); D_CHANMODE(0x08u),
;
companion object { companion object {
private val values = enumValues<ChannelModeType>() private val values =
enumValues<ChannelModeType>()
.associateBy(ChannelModeType::value) .associateBy(ChannelModeType::value)
/** /**
......
...@@ -19,7 +19,7 @@ data class ChannelModes( ...@@ -19,7 +19,7 @@ data class ChannelModes(
val a: Map<Char, Set<String>> = emptyMap(), val a: Map<Char, Set<String>> = emptyMap(),
val b: Map<Char, String> = emptyMap(), val b: Map<Char, String> = emptyMap(),
val c: Map<Char, String> = emptyMap(), val c: Map<Char, String> = emptyMap(),
val d: Set<Char> = emptySet() val d: Set<Char> = emptySet(),
) { ) {
fun modeString(): String { fun modeString(): String {
if (b.isEmpty() && c.isEmpty() && d.isEmpty()) { if (b.isEmpty() && c.isEmpty() && d.isEmpty()) {
...@@ -48,43 +48,51 @@ data class ChannelModes( ...@@ -48,43 +48,51 @@ data class ChannelModes(
fun toVariantMap(): QVariantMap { fun toVariantMap(): QVariantMap {
return mapOf( return mapOf(
"A" to qVariant( "A" to
qVariant(
a.map { (key, value) -> a.map { (key, value) ->
key.toString() to qVariant(value.toList(), QtType.QStringList) key.toString() to qVariant(value.toList(), QtType.QStringList)
}.toMap(), }.toMap(),
QtType.QVariantMap QtType.QVariantMap,
), ),
"B" to qVariant( "B" to
qVariant(
b.map { (key, value) -> b.map { (key, value) ->
key.toString() to qVariant(value, QtType.QString) key.toString() to qVariant(value, QtType.QString)
}.toMap(), }.toMap(),
QtType.QVariantMap QtType.QVariantMap,
), ),
"C" to qVariant( "C" to
qVariant(
c.map { (key, value) -> c.map { (key, value) ->
key.toString() to qVariant(value, QtType.QString) key.toString() to qVariant(value, QtType.QString)
}.toMap(), }.toMap(),
QtType.QVariantMap QtType.QVariantMap,
), ),
"D" to qVariant(d.joinToString(), QtType.QString), "D" to qVariant(d.joinToString(), QtType.QString),
) )
} }
companion object { companion object {
fun fromVariantMap(properties: QVariantMap) = ChannelModes( fun fromVariantMap(properties: QVariantMap) =
a = properties["A"].into<QVariantMap>()?.map { (key, value) -> ChannelModes(
key.first() to value.into<QStringList>() a =
properties["A"].into<QVariantMap>()?.map { (key, value) ->
key.first() to
value.into<QStringList>()
?.filterNotNull() ?.filterNotNull()
?.toSet() ?.toSet()
.orEmpty() .orEmpty()
}?.toMap().orEmpty(), }?.toMap().orEmpty(),
b = properties["B"].into<QVariantMap>()?.map { (key, value) -> b =
properties["B"].into<QVariantMap>()?.map { (key, value) ->
key.first() to value.into<String>().orEmpty() key.first() to value.into<String>().orEmpty()
}?.toMap().orEmpty(), }?.toMap().orEmpty(),
c = properties["C"].into<QVariantMap>()?.map { (key, value) -> c =
properties["C"].into<QVariantMap>()?.map { (key, value) ->
key.first() to value.into<String>().orEmpty() key.first() to value.into<String>().orEmpty()
}?.toMap().orEmpty(), }?.toMap().orEmpty(),
d = properties["D"].into<String>()?.toSet().orEmpty() d = properties["D"].into<String>()?.toSet().orEmpty(),
) )
} }
} }
...@@ -20,10 +20,12 @@ enum class ConnectionState( ...@@ -20,10 +20,12 @@ enum class ConnectionState(
Initializing(2), Initializing(2),
Initialized(3), Initialized(3),
Reconnecting(4), Reconnecting(4),
Disconnecting(5); Disconnecting(5),
;
companion object { companion object {
private val values = enumValues<ConnectionState>() private val values =
enumValues<ConnectionState>()
.associateBy(ConnectionState::value) .associateBy(ConnectionState::value)
/** /**
......
/* /*
* libquassel * libquassel
* Copyright (c) 2021 Janne Mareike Koschinski * Copyright (c) 2024 Janne Mareike Koschinski
* *
* This Source Code Form is subject to the terms of the Mozilla Public License, * 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 * 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/. * obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package de.justjanne.libquassel.protocol.syncables.state package de.justjanne.libquassel.protocol.models.network
import de.justjanne.libquassel.protocol.models.ids.IdentityId import de.justjanne.libquassel.protocol.models.ids.IdentityId
data class IdentityState( data class IrcChannelDto(
val name: String,
val topic: String = "",
val password: String = "",
val encrypted: Boolean = false,
val channelModes: ChannelModes = ChannelModes(),
val userModes: Map<String, Set<Char>> = emptyMap(),
)
data class IdentityDto(
val identityId: IdentityId = IdentityId(-1), val identityId: IdentityId = IdentityId(-1),
val identityName: String = "<empty>", val identityName: String = "<empty>",
val realName: String = "", val realName: String = "",
...@@ -30,7 +39,5 @@ data class IdentityState( ...@@ -30,7 +39,5 @@ data class IdentityState(
val ident: String = "quassel", val ident: String = "quassel",
val kickReason: String = "Kindergarten is elsewhere!", val kickReason: String = "Kindergarten is elsewhere!",
val partReason: String = "http://quassel-irc.org - Chat comfortably. Anywhere.", val partReason: String = "http://quassel-irc.org - Chat comfortably. Anywhere.",
val quitReason: String = "http://quassel-irc.org - Chat comfortably. Anywhere." val quitReason: String = "http://quassel-irc.org - Chat comfortably. Anywhere.",
) { )
fun identifier() = "${identityId.id}"
}
/* /*
* libquassel * libquassel
* Copyright (c) 2021 Janne Mareike Koschinski * Copyright (c) 2024 Janne Mareike Koschinski
* *
* This Source Code Form is subject to the terms of the Mozilla Public License, * 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 * 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/. * obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package de.justjanne.libquassel.protocol.syncables.state package de.justjanne.libquassel.protocol.models.network
import de.justjanne.libquassel.protocol.models.ids.NetworkId
import org.threeten.bp.Instant import org.threeten.bp.Instant
data class IrcUserState( data class IrcUserDto(
val network: NetworkId,
val nick: String, val nick: String,
val user: String, val user: String,
val host: String, val host: String,
...@@ -30,14 +28,5 @@ data class IrcUserState( ...@@ -30,14 +28,5 @@ data class IrcUserState(
val suserHost: String = "", val suserHost: String = "",
val encrypted: Boolean = false, val encrypted: Boolean = false,
val channels: Set<String> = emptySet(), val channels: Set<String> = emptySet(),
val userModes: Set<Char> = emptySet() val userModes: Set<Char> = emptySet(),
) { )
fun identifier() = "${network.id}/$nick"
fun verifiedUser() = user.let {
if (it.startsWith("~")) null
else it
}
fun hostMask() = "$nick!$user@$host"
}
/* /*
* libquassel * libquassel
* Copyright (c) 2021 Janne Mareike Koschinski * Copyright (c) 2024 Janne Mareike Koschinski
* *
* This Source Code Form is subject to the terms of the Mozilla Public License, * 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 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
...@@ -12,7 +12,7 @@ package de.justjanne.libquassel.protocol.models.network ...@@ -12,7 +12,7 @@ package de.justjanne.libquassel.protocol.models.network
import de.justjanne.libquassel.protocol.models.ids.IdentityId import de.justjanne.libquassel.protocol.models.ids.IdentityId
import de.justjanne.libquassel.protocol.models.ids.NetworkId import de.justjanne.libquassel.protocol.models.ids.NetworkId
data class NetworkInfo( data class NetworkInfoDto(
val networkId: NetworkId = NetworkId(-1), val networkId: NetworkId = NetworkId(-1),
val networkName: String = "", val networkName: String = "",
val identity: IdentityId = IdentityId(-1), val identity: IdentityId = IdentityId(-1),
...@@ -37,5 +37,5 @@ data class NetworkInfo( ...@@ -37,5 +37,5 @@ data class NetworkInfo(
val useCustomMessageRate: Boolean = false, val useCustomMessageRate: Boolean = false,
val messageRateBurstSize: UInt = 0u, val messageRateBurstSize: UInt = 0u,
val messageRateDelay: UInt = 0u, val messageRateDelay: UInt = 0u,
val unlimitedMessageRate: Boolean = false val unlimitedMessageRate: Boolean = false,
) )
...@@ -17,10 +17,12 @@ enum class NetworkProxy( ...@@ -17,10 +17,12 @@ enum class NetworkProxy(
NoProxy(2), NoProxy(2),
HttpProxy(3), HttpProxy(3),
HttpCachingProxy(4), HttpCachingProxy(4),
FtpCachingProxy(5); FtpCachingProxy(5),
;
companion object { companion object {
private val values = enumValues<NetworkProxy>() private val values =
enumValues<NetworkProxy>()
.associateBy(NetworkProxy::value) .associateBy(NetworkProxy::value)
/** /**
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
package de.justjanne.libquassel.protocol.models.network package de.justjanne.libquassel.protocol.models.network
enum class PortDefaults( enum class PortDefaults(
val port: UInt val port: UInt,
) { ) {
PORT_PLAINTEXT(6667u), PORT_PLAINTEXT(6667u),
PORT_SSL(6697u) PORT_SSL(6697u),
} }