diff --git a/src/main/webapp/src/app.ts b/src/main/webapp/src/app.ts index fa97f36fa..15bd80305 100644 --- a/src/main/webapp/src/app.ts +++ b/src/main/webapp/src/app.ts @@ -1,5 +1,6 @@ import { NgModule, enableProdMode } from '@angular/core' import { RouterModule } from '@angular/router'; +import { FormsModule } from '@angular/forms'; import { rootRouterConfig } from './app/simple-java-mail-routes'; import { SimpleJavaMailApp } from './app/simple-java-mail-app'; import { BrowserModule } from '@angular/platform-browser'; @@ -37,6 +38,7 @@ require('./index.html'); imports: [ BrowserModule, HttpModule, + FormsModule, RouterModule.forRoot(rootRouterConfig, { useHash: true }), Ng2SimplePageScrollModule.forRoot() ], diff --git a/src/main/webapp/src/app/components/rfc/Email.ts b/src/main/webapp/src/app/components/rfc/Email.ts new file mode 100644 index 000000000..0aacb3412 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/Email.ts @@ -0,0 +1,10 @@ +export class Email { + constructor(readonly usePlainText: boolean, + readonly useHTMLText: boolean, + readonly useEmbeddedContent: boolean, + readonly useCalendarEvent: boolean, + readonly useAttachments: boolean, + readonly useEmailForward: boolean, + ) { + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategy.ts b/src/main/webapp/src/app/components/rfc/MessageStrategy.ts new file mode 100644 index 000000000..ae691a73f --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategy.ts @@ -0,0 +1,22 @@ +import {Email} from "./Email"; + +export abstract class MessageStrategy { + + abstract compatibleWithEmail(email: Email): boolean; + + abstract determineMessageStructure(email: Email): string; + + protected static emailContainsMixedContent(email: Email): boolean { + return email.useAttachments || email.useEmailForward; + } + + protected static emailContainsRelatedContent(email: Email): boolean { + return email.useEmbeddedContent; + } + + protected static emailContainsAlternativeContent(email: Email): boolean { + return (email.usePlainText ? 1 : 0) + + (email.useHTMLText ? 1 : 0) + + (email.useCalendarEvent ? 1 : 0) > 1; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts new file mode 100644 index 000000000..99c3fd889 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts @@ -0,0 +1,22 @@ +import {MessageStrategy} from "./MessageStrategy"; +import {Email} from "./Email"; + +export class MessageStrategyAlternative extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return !MessageStrategy.emailContainsMixedContent(email) && + !MessageStrategy.emailContainsRelatedContent(email) && + MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts new file mode 100644 index 000000000..818a8a8f0 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts @@ -0,0 +1,24 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyMixed extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return MessageStrategy.emailContainsMixedContent(email) && + !MessageStrategy.emailContainsRelatedContent(email) && + !MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts new file mode 100644 index 000000000..c92d1e985 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts @@ -0,0 +1,28 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyMixedAlternative extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return MessageStrategy.emailContainsMixedContent(email) && + !MessageStrategy.emailContainsRelatedContent(email) && + MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts new file mode 100644 index 000000000..90affae87 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts @@ -0,0 +1,27 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyMixedRelated extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return MessageStrategy.emailContainsMixedContent(email) && + MessageStrategy.emailContainsRelatedContent(email) && + !MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts new file mode 100644 index 000000000..3cf47445b --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts @@ -0,0 +1,34 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyMixedRelatedAlternative extends MessageStrategy { + + compatibleWithEmail(email: Email): boolean { + return MessageStrategy.emailContainsMixedContent(email) && + MessageStrategy.emailContainsRelatedContent(email) && + MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts new file mode 100644 index 000000000..08a0978df --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts @@ -0,0 +1,21 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyRelated extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return !MessageStrategy.emailContainsMixedContent(email) && + MessageStrategy.emailContainsRelatedContent(email) && + !MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return ""; + } +} diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts new file mode 100644 index 000000000..53644b5b6 --- /dev/null +++ b/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts @@ -0,0 +1,25 @@ +import {Email} from "./Email"; +import {MessageStrategy} from "./MessageStrategy"; + +export class MessageStrategyRelatedAlternative extends MessageStrategy { + compatibleWithEmail(email: Email): boolean { + return !MessageStrategy.emailContainsMixedContent(email) && + MessageStrategy.emailContainsRelatedContent(email) && + MessageStrategy.emailContainsAlternativeContent(email); + } + + public determineMessageStructure(email: Email): string { + return "