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