-
Notifications
You must be signed in to change notification settings - Fork 15
issue #1223 a port of Mime.processDecoded() #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
503c842
issue #1223 a port of Mime.processDecoded()
IvanPizhenko 9c0d6fa
Fixed JUnit tests that relate to Android side.| #1267
DenBond7 5c38d0b
Merge branch 'master' into ip-1223
DenBond7 fb3bc77
Fixed MsgBlockFactory.| #1267
DenBond7 c50d1cd
Fixes after code review
IvanPizhenko 7e46b68
Fix javadoc comment
IvanPizhenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 human@flowcrypt.com | ||
| * 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 human@flowcrypt.com | ||
| * 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 hidden or 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 human@flowcrypt.com | ||
| * 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 hidden or 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 human@flowcrypt.com | ||
| * 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 hidden or 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 human@flowcrypt.com | ||
| * 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.