class ContactFormController extends BasicController {

    @Override
    public void event(final UserRequest ureq, final Controller source, final Event event) {
        if (source == noUsersErrorCtr) {
            if (event.equals(Event.CANCELLED_EVENT)) {
                // user has clicked the close button in the top-right corner
                fireEvent(ureq, Event.CANCELLED_EVENT);
            } else {
                // user has clicked the cancel button
                final int pos = DialogBoxUIFactory.getButtonPos(event);
                if (pos == 0) {
                    // cancel button has been pressed, fire event to parent
                    fireEvent(ureq, Event.CANCELLED_EVENT);
                }
            }
        } else if (contactView.is(source)) {
            if (event == Event.DONE_EVENT) {

                ContactMessage newContactMessage = createContactMessageFromViewData();

                contactUIModel.setContactMessage(newContactMessage);
                contactUIModel.setAttachements(contactView.getAttachments());

                MessageSendStatus sendMessageStatus = contactUIModel.sendCurrentMessageToRecipients();
                if (contactView.isTcpFrom()) {
                    // TODO:Discuss: if copy to sender is checked, the sendMessageStatus of the recipient sending is cleared
                    sendMessageStatus = contactUIModel.sendCurrentMessageAsCopyToSender();
                }

                MessageSendStatusCode sendMessageStatusCode = sendMessageStatus.getStatusCode();
                boolean isAddressFailure = sendMessageStatusCode.isAddressFailedCase();
                boolean isSendFailed = sendMessageStatusCode.isSendFailedCase();
                boolean isMessageContentProblem = sendMessageStatusCode.isMessageFailedCase();
                boolean isWarn = sendMessageStatus.isSeverityWarn();
                boolean isError = sendMessageStatus.isSeverityError();
                //
                if (isAddressFailure) {
                    showFeedbackToUserAndAddToLogFile(isWarn, isError, sendMessageStatus);
                    // continue and send events depending on success
                } else if (isSendFailed) {
                    showFeedbackToUserAndAddToLogFile(isWarn, isError, sendMessageStatus);
                    fireEvent(ureq, Event.FAILED_EVENT);
                    return;
                } else if (isMessageContentProblem) {
                    showFeedbackToUserAndAddToLogFile(isWarn, isError, sendMessageStatus);
                    return;
                }

                boolean success = sendMessageStatusCode.isSuccessfullSentMails();
                contactView.setDisplayOnly(true);
                if (success) {
                    showInfo("msg.send.ok");
                    // do logging
                    ThreadLocalUserActivityLogger.log(MailLoggingAction.MAIL_SENT, getClass());
                    fireEvent(ureq, Event.DONE_EVENT);
                } else {
                    showInfo("error.msg.send.nok");
                    fireEvent(ureq, Event.FAILED_EVENT);
                }
            } else if (event == Event.CANCELLED_EVENT) {
                fireEvent(ureq, Event.CANCELLED_EVENT);
            }
        }
    }

    public  ContactFormController(final UserRequest ureq, final WindowControl windowControl, final boolean useDefaultTitle, final boolean isCanceable,
            final boolean isReadonly, final boolean hasRecipientsEditable, final ContactMessage cmsg);
    public  ContactFormController(final ContactFormView contactFormView, final ContactUIModel contactUIModel);

}