-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* issue #1223 a port of Mime.processDecoded() * Fixed JUnit tests that relate to Android side.| #1267 * Fixed MsgBlockFactory.| #1267 * Fixes after code review * Fix javadoc comment Co-authored-by: Ivan Pizhenko <[email protected]> Co-authored-by: DenBond7 <[email protected]>
- Loading branch information
1 parent
e336f06
commit 8266be3
Showing
25 changed files
with
1,549 additions
and
16 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...rc/main/java/com/flowcrypt/email/api/retrofit/response/model/node/EncryptedAttMsgBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: | ||
* Ivan Pizhenko | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.response.model.node | ||
|
||
import android.net.Uri | ||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.google.gson.annotations.Expose | ||
|
||
data class EncryptedAttMsgBlock(@Expose override val content: String?, | ||
@Expose val attMeta: AttMeta) : MsgBlock { | ||
|
||
var fileUri: Uri? = null | ||
|
||
@Expose | ||
override val complete: Boolean = true | ||
@Expose | ||
override val type: MsgBlock.Type = MsgBlock.Type.ENCRYPTED_ATT | ||
|
||
constructor(source: Parcel) : this( | ||
source.readString(), | ||
source.readParcelable<AttMeta>(AttMeta::class.java.classLoader)!! | ||
) { | ||
fileUri = source.readParcelable<Uri>(Uri::class.java.classLoader) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
override fun writeToParcel(dest: Parcel, flags: Int) = | ||
with(dest) { | ||
writeParcelable(type, flags) | ||
writeString(content) | ||
writeParcelable(attMeta, flags) | ||
writeParcelable(fileUri, flags) | ||
} | ||
|
||
companion object { | ||
@JvmField | ||
val CREATOR: Parcelable.Creator<EncryptedAttMsgBlock> = object : Parcelable.Creator<EncryptedAttMsgBlock> { | ||
override fun createFromParcel(source: Parcel): EncryptedAttMsgBlock { | ||
source.readParcelable<MsgBlock.Type>(MsgBlock.Type::class.java.classLoader) | ||
return EncryptedAttMsgBlock(source) | ||
} | ||
|
||
override fun newArray(size: Int): Array<EncryptedAttMsgBlock?> = arrayOfNulls(size) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...pt/src/main/java/com/flowcrypt/email/api/retrofit/response/model/node/PlainAttMsgBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: | ||
* Ivan Pizhenko | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.response.model.node | ||
|
||
import android.net.Uri | ||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.google.gson.annotations.Expose | ||
|
||
data class PlainAttMsgBlock( | ||
@Expose override val content: String?, | ||
@Expose val attMeta: AttMeta | ||
) : MsgBlock { | ||
|
||
var fileUri: Uri? = null | ||
|
||
@Expose | ||
override val complete: Boolean = true | ||
|
||
@Expose | ||
override val type: MsgBlock.Type = MsgBlock.Type.PLAIN_ATT | ||
|
||
constructor(source: Parcel) : this( | ||
source.readString(), | ||
source.readParcelable<AttMeta>(AttMeta::class.java.classLoader)!! | ||
) { | ||
fileUri = source.readParcelable(Uri::class.java.classLoader) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
override fun writeToParcel(dest: Parcel, flags: Int) = | ||
with(dest) { | ||
writeParcelable(type, flags) | ||
writeString(content) | ||
writeParcelable(attMeta, flags) | ||
writeParcelable(fileUri, flags) | ||
} | ||
|
||
companion object { | ||
@JvmField | ||
val CREATOR: Parcelable.Creator<PlainAttMsgBlock> = object : Parcelable.Creator<PlainAttMsgBlock> { | ||
override fun createFromParcel(source: Parcel): PlainAttMsgBlock { | ||
source.readParcelable<MsgBlock.Type>(MsgBlock.Type::class.java.classLoader) | ||
return PlainAttMsgBlock(source) | ||
} | ||
|
||
override fun newArray(size: Int): Array<PlainAttMsgBlock?> = arrayOfNulls(size) | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
FlowCrypt/src/main/java/com/flowcrypt/email/api/retrofit/response/model/node/SignedBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: | ||
* Ivan Pizhenko | ||
*/ | ||
|
||
package com.flowcrypt.email.api.retrofit.response.model.node | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.google.gson.annotations.Expose | ||
|
||
/** | ||
* Message block which represents content with a signature. | ||
*/ | ||
data class SignedBlock( | ||
@Expose val signedType: Type, | ||
@Expose override val content: String?, | ||
@Expose override val complete: Boolean, | ||
@Expose val signature: String? | ||
) : MsgBlock { | ||
|
||
@Expose | ||
override val type: MsgBlock.Type = when (signedType) { | ||
Type.SIGNED_MSG -> MsgBlock.Type.SIGNED_MSG | ||
Type.SIGNED_TEXT -> MsgBlock.Type.SIGNED_TEXT | ||
Type.SIGNED_HTML -> MsgBlock.Type.SIGNED_HTML | ||
} | ||
|
||
constructor(source: Parcel) : this( | ||
source.readParcelable<Type>(Type::class.java.classLoader) | ||
?: throw IllegalArgumentException("Undefined type"), | ||
source.readString(), | ||
1 == source.readInt(), | ||
source.readString() | ||
) | ||
|
||
override fun describeContents() = 0 | ||
|
||
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) { | ||
writeParcelable(type, flags) | ||
writeParcelable(signedType, flags) | ||
writeString(content) | ||
writeInt(if (complete) 1 else 0) | ||
writeString(signature) | ||
} | ||
|
||
enum class Type : Parcelable { | ||
SIGNED_MSG, | ||
SIGNED_TEXT, | ||
SIGNED_HTML; | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
override fun writeToParcel(dest: Parcel, flags: Int) { | ||
dest.writeInt(ordinal) | ||
} | ||
|
||
companion object { | ||
@JvmField | ||
val CREATOR: Parcelable.Creator<Type> = object : Parcelable.Creator<Type> { | ||
override fun createFromParcel(source: Parcel): Type = values()[source.readInt()] | ||
override fun newArray(size: Int): Array<Type?> = arrayOfNulls(size) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmField | ||
val CREATOR: Parcelable.Creator<MsgBlock> = object : Parcelable.Creator<MsgBlock> { | ||
override fun createFromParcel(source: Parcel): MsgBlock { | ||
val partType = source.readParcelable<MsgBlock.Type>(MsgBlock.Type::class.java.classLoader)!! | ||
return MsgBlockFactory.fromParcel(partType, source) | ||
} | ||
|
||
override fun newArray(size: Int): Array<MsgBlock?> = arrayOfNulls(size) | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
FlowCrypt/src/main/java/com/flowcrypt/email/extensions/javax/mail/BodyPartExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: | ||
* Ivan Pizhenko | ||
*/ | ||
|
||
package com.flowcrypt.email.extensions.javax.mail | ||
|
||
import javax.mail.BodyPart | ||
import javax.mail.MessagingException | ||
|
||
fun BodyPart.hasFileName(): Boolean { | ||
return try { | ||
this.fileName != null | ||
} catch (ex: MessagingException) { | ||
false | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
FlowCrypt/src/main/java/com/flowcrypt/email/extensions/javax/mail/PartExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: | ||
* Ivan Pizhenko | ||
*/ | ||
|
||
package com.flowcrypt.email.extensions.javax.mail | ||
|
||
import java.util.Locale | ||
import javax.mail.Part | ||
|
||
fun Part.isInline(): Boolean { | ||
return (this.disposition?.toLowerCase(Locale.getDefault()) ?: "") == Part.INLINE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.