Package com.cubusmail.gwtui.client.model

Examples of com.cubusmail.gwtui.client.model.GWTMessage


   * @return
   * @throws MessagingException
   */
  public static GWTMessage convert( Message msg ) throws MessagingException {

    GWTMessage result = new GWTMessage();
    result.setId( msg.getMessageNumber() );
    result.setSubject( msg.getSubject() );
    result.setFrom( MessageUtils.getMailAdressString( msg.getFrom(), AddressStringType.COMPLETE ) );
    result.setTo( MessageUtils.getMailAdressString( msg.getRecipients( Message.RecipientType.TO ),
        AddressStringType.COMPLETE ) );
    result.setCc( MessageUtils.getMailAdressString( msg.getRecipients( Message.RecipientType.CC ),
        AddressStringType.COMPLETE ) );
    result.setDate( msg.getSentDate() );
    result.setSize( MessageUtils.calculateAttachmentSize( msg.getSize() ) );

    return result;
  }
View Full Code Here


    }
  }

  public GWTMessage getMessage() {

    GWTMessage message = this.message;
    if ( message == null ) {
      message = new GWTMessage();
    }
    message.setTo( this.toText.getValueAsString() );
    message.setCc( this.ccText.getValueAsString() );
    message.setBcc( this.bccText.getValueAsString() );
    message.setSubject( this.subjectText.getValueAsString() );
    message.setMessageText( getMessageText() );
    message.setHtmlMessage( this.htmlCheck.getValue() );
    message.setIdentityId( Long.parseLong( this.fromCombo.getValue() ) );
    message.setAcknowledgement( this.acknowledgementCheck.getValue() );
    message.setPriority( Integer.parseInt( this.priorityCombo.getValue() ) );

    return message;
  }
View Full Code Here

   * @throws MessagingException
   * @throws IOException
   */
  public GWTMessage getGWTMessage() throws MessagingException, IOException {

    GWTMessage gwtMsg = new GWTMessage();
    gwtMsg.setFrom( getFrom() );
    gwtMsg.setFromArray( ConvertUtil.convertAddress( this.message.getFrom() ) );
    gwtMsg.setTo( getTo() );
    gwtMsg.setToArray( ConvertUtil.convertAddress( this.message.getRecipients( RecipientType.TO ) ) );
    gwtMsg.setCc( getCc() );
    gwtMsg.setCcArray( ConvertUtil.convertAddress( this.message.getRecipients( RecipientType.CC ) ) );
    gwtMsg.setBcc( getBcc() );
    gwtMsg.setReplyTo( getReplyTo() );
    gwtMsg.setReplyToArray( getReplyToArray() );
    gwtMsg.setSubject( getSubject() );
    gwtMsg.setDate( this.message.getSentDate() );
    if ( isHtmlMessage() ) {
      gwtMsg.setMessageText( getMessageTextHtml() );
    }
    else {
      gwtMsg.setMessageText( getMessageTextPlain() );
    }
    gwtMsg.setHtmlMessage( isHtmlMessage() );
    gwtMsg.setHasImages( isHasImages() );
    gwtMsg.setTrustImages( isTrustImages() );
    gwtMsg.setAcknowledgement( isAcknowledgement() );

    gwtMsg.setReadBefore( this.readBefore );
    gwtMsg.setRead( isRead() );
    gwtMsg.setDraft( isDraftMessage() );

    long id = getId();
    gwtMsg.setId( id );
    List<MimePart> parts = MessageUtils.attachmentsFromPart( this.message );
    if ( parts.size() > 0 ) {
      GWTAttachment[] attachments = new GWTAttachment[parts.size()];

      for (int i = 0; i < parts.size(); i++) {
        attachments[i] = new GWTAttachment();
        String fileName = parts.get( i ).getFileName();
        if ( StringUtils.isEmpty( fileName ) ) {
          fileName = this.applicationContext.getMessage( "message.unknown.attachment", null, SessionManager
              .get().getLocale() );
        }
        attachments[i].setFileName( fileName );
        int size = parts.get( i ).getSize();
        if ( parts.get( i ).getSize() == -1 ) {
          try {
            size = parts.get( i ).getInputStream().available();
          }
          catch (IOException e) {
            size = -1;
          }
        }

        NumberFormat sizeFormat = MessageUtils.createSizeFormat( SessionManager.get().getLocale() );
        size = MessageUtils.calculateAttachmentSize( size );
        attachments[i].setSize( size );
        attachments[i].setSizeText( MessageUtils.formatPartSize( attachments[i].getSize(), sizeFormat ) );
        attachments[i].setMessageId( id );
        attachments[i].setIndex( i );

        String extension = StringUtils.substringAfterLast( parts.get( i ).getFileName(), "." );
        if ( extension != null ) {
          extension = extension.toLowerCase();
          if ( ArrayUtils.contains( PREVIEW_EXTENSIONS, extension ) ) {
            attachments[i].setPreview( true );
          }
        }
      }
      gwtMsg.setAttachments( attachments );
    }

    return gwtMsg;
  }
View Full Code Here

      IMailFolder selectedFolder = mailbox.getCurrentFolder();
      Message msg = selectedFolder.getMessageById( messageId );

      MessageHandler handler = MessageHandler.getInstance( mailbox.getJavaMailSession(), (MimeMessage) msg );
      handler.readBodyContent( loadImages, MessageTextMode.DISPLAY );
      GWTMessage result = handler.getGWTMessage();

      return result;
    }
    catch (MessagingException e) {
      log.error( e.getMessage(), e );
View Full Code Here

      MessageHandler readHandler = MessageHandler.getInstance( mailbox.getJavaMailSession(), (MimeMessage) msg );
      readHandler.readBodyContent( true, MessageTextMode.DRAFT );
      prepareNewMessage();

      GWTMessage result = readHandler.getGWTMessage();

      return result;
    }
    catch (MessagingException e) {
      log.error( e.getMessage(), e );
View Full Code Here

      MessageHandler forardMessageHandler = MessageHandler.getInstance( mailbox.getJavaMailSession() );
      forardMessageHandler.createForwardMessage( msg );

      SessionManager.get().setCurrentComposeMessage( forardMessageHandler );

      GWTMessage result = forardMessageHandler.getGWTMessage();
      result.setAttachments( forardMessageHandler.getGWTComposeAttachments() );

      return result;
    }
    catch (MessagingException e) {
      log.error( e.getMessage(), e );
View Full Code Here

  @Override
  public void execute() {

    if ( validate() ) {
      WindowRegistry.COMPOSE_MESSAGE_WINDOW.mask();
      GWTMessage message = WindowRegistry.COMPOSE_MESSAGE_WINDOW.get( ComposeMessageWindow.class ).getMessage();
      message.setDraft( true );
      ServiceProvider.getMailboxService().saveMessageAsDraft( message, this );
    }
  }
View Full Code Here

  }

  @Override
  public void execute() {

    GWTMessage message = GWTSessionManager.get().getCurrentMessage();
    PrintManager.print( message );
  }
View Full Code Here

  @Override
  public void execute() {

    if ( WindowRegistry.COMPOSE_MESSAGE_WINDOW.validate() ) {
      WindowRegistry.COMPOSE_MESSAGE_WINDOW.mask();
      GWTMessage message = WindowRegistry.COMPOSE_MESSAGE_WINDOW.get( ComposeMessageWindow.class ).getMessage();
      ServiceProvider.getMailboxService().sendMessage( message, this );
    }
  }
View Full Code Here

TOP

Related Classes of com.cubusmail.gwtui.client.model.GWTMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.