mirror of
https://github.com/ProtonMail/protoncore_android.git
synced 2026-06-14 09:54:49 +00:00
Extract PackageType constant enum
This commit is contained in:
+5
-4
@@ -20,19 +20,20 @@ package me.proton.core.mailmessage.data.extension
|
||||
|
||||
import me.proton.core.mailmessage.data.api.request.EmailPackage
|
||||
import me.proton.core.mailmessage.domain.entity.EncryptedPackage
|
||||
import me.proton.core.util.kotlin.toInt
|
||||
|
||||
fun EncryptedPackage.toEmailPackage(): EmailPackage = EmailPackage(
|
||||
addresses = addresses.mapValues { entry ->
|
||||
when (val address = entry.value) {
|
||||
is EncryptedPackage.Address.Internal -> EmailPackage.Address(
|
||||
type = address.type,
|
||||
signature = address.signature,
|
||||
type = address.packageType.type,
|
||||
signature = address.signed.toInt(),
|
||||
bodyKeyPacket = address.bodyKeyPacket,
|
||||
attachmentKeyPackets = address.attachmentKeyPackets
|
||||
)
|
||||
is EncryptedPackage.Address.External -> EmailPackage.Address(
|
||||
type = address.type,
|
||||
signature = address.signature
|
||||
type = address.packageType.type,
|
||||
signature = address.signed.toInt()
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* This file is part of Proton Technologies AG and ProtonCore.
|
||||
*
|
||||
* ProtonCore is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ProtonCore 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 ProtonCore. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum class PackageType(val type: Int) {
|
||||
ProtonMail(1),
|
||||
EncryptedOutside(2),
|
||||
Cleartext(4),
|
||||
PgpInline(8),
|
||||
PgpMime(16),
|
||||
ClearMime(32)
|
||||
}
|
||||
+5
-3
@@ -18,6 +18,8 @@
|
||||
|
||||
package me.proton.core.mailmessage.domain.entity
|
||||
|
||||
import PackageType
|
||||
|
||||
data class EncryptedPackage(
|
||||
val addresses: Map<String, Address>,
|
||||
val mimeType: String,
|
||||
@@ -27,14 +29,14 @@ data class EncryptedPackage(
|
||||
val bodyKey: Key? = null,
|
||||
) {
|
||||
|
||||
sealed class Address(val type: Int, val signature: Int) {
|
||||
sealed class Address(val packageType: PackageType, val signed: Boolean) {
|
||||
|
||||
data class Internal(
|
||||
val bodyKeyPacket: String,
|
||||
val attachmentKeyPackets: List<String>
|
||||
) : Address(1, 1) // TODO
|
||||
) : Address(PackageType.ProtonMail, true)
|
||||
|
||||
object External : Address(4, 0) // TODO
|
||||
object External : Address(PackageType.Cleartext, false)
|
||||
}
|
||||
|
||||
data class Key(
|
||||
|
||||
Reference in New Issue
Block a user