Skip to content
Snippets Groups Projects
Verified Commit 31f7e70b authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Further cleanup

parent bc63c1ec
No related branches found
No related tags found
1 merge request!2Draft: Jetpack compose rewrite
Pipeline #572 failed
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.justcode
import java.io.IOException
import java.io.OutputStream
import java.util.*
class NullOutputStream : OutputStream() {
@Volatile
private var closed = false
@Throws(IOException::class)
private fun ensureOpen() {
if (closed) {
throw IOException("Stream closed")
}
}
@Throws(IOException::class)
override fun write(b: Int) {
ensureOpen()
}
@Throws(IOException::class)
override fun write(b: ByteArray, off: Int, len: Int) {
Objects.checkFromIndexSize(off, len, b.size)
ensureOpen()
}
override fun close() {
closed = true
}
}
...@@ -21,7 +21,6 @@ package de.kuschku.justcode ...@@ -21,7 +21,6 @@ package de.kuschku.justcode
import org.gradle.api.Project import org.gradle.api.Project
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.OutputStream
import java.util.* import java.util.*
fun Project.cmd(vararg command: String) = try { fun Project.cmd(vararg command: String) = try {
...@@ -29,7 +28,7 @@ fun Project.cmd(vararg command: String) = try { ...@@ -29,7 +28,7 @@ fun Project.cmd(vararg command: String) = try {
exec { exec {
commandLine(*command) commandLine(*command)
standardOutput = stdOut standardOutput = stdOut
errorOutput = OutputStream.nullOutputStream() errorOutput = NullOutputStream()
} }
stdOut.toString(Charsets.UTF_8.name()).trim() stdOut.toString(Charsets.UTF_8.name()).trim()
} catch (e: Throwable) { } catch (e: Throwable) {
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.types
private typealias BufferIdType = SignedIdType
inline class BufferId(override val id: BufferIdType) : SignedId<BufferIdType> {
override fun toString() = "BufferId($id)"
companion object {
val MIN_VALUE = BufferId(BufferIdType.MIN_VALUE)
val MAX_VALUE = BufferId(BufferIdType.MAX_VALUE)
}
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.types
private typealias IdentityIdType = SignedIdType
inline class IdentityId(override val id: IdentityIdType) : SignedId<IdentityIdType> {
override fun toString() = "IdentityId($id)"
companion object {
val MIN_VALUE = IdentityId(IdentityIdType.MIN_VALUE)
val MAX_VALUE = IdentityId(IdentityIdType.MAX_VALUE)
}
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.types
private typealias MsgIdType = SignedId64Type
inline class MsgId(override val id: MsgIdType) : SignedId<MsgIdType> {
override fun toString() = "MsgId($id)"
companion object {
val MIN_VALUE = MsgId(MsgIdType.MIN_VALUE)
val MAX_VALUE = MsgId(MsgIdType.MAX_VALUE)
}
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.types
private typealias NetworkIdType = SignedIdType
inline class NetworkId(override val id: NetworkIdType) : SignedId<NetworkIdType> {
override fun toString() = "NetworkId($id)"
companion object {
val MIN_VALUE = NetworkId(NetworkIdType.MIN_VALUE)
val MAX_VALUE = NetworkId(NetworkIdType.MAX_VALUE)
}
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.types
import java.io.Serializable
typealias SignedIdType = Int
typealias SignedId64Type = Long
interface SignedId<T> : Serializable, Comparable<SignedId<T>>
where T : Number, T : Comparable<T> {
val id: T
override fun compareTo(other: SignedId<T>): Int {
return id.compareTo(other.id)
}
}
@Suppress("NOTHING_TO_INLINE")
@JvmName("isValidId")
inline fun SignedId<SignedIdType>.isValid() = id > 0
@Suppress("NOTHING_TO_INLINE")
@JvmName("isValidId64")
inline fun SignedId<SignedId64Type>.isValid() = id > 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment