Search in sources :

Example 1 with Attr

use of net.freeutils.tnef.Attr in project zm-mailbox by Zimbra.

the class MapiPropertyId method getProp.

public MAPIProp getProp(SchedulingViewOfTnef schedView) throws IOException {
    MAPIProp mp;
    List<?> attribs = schedView.getAttributes();
    for (Object thisObj : attribs) {
        if (!(thisObj instanceof Attr)) {
            continue;
        }
        Attr thisAtt = (Attr) thisObj;
        Object o = thisAtt.getValue();
        if (o == null) {
            continue;
        }
        if (thisAtt.getID() != (Attr.attMAPIProps)) {
            continue;
        }
        if (!(o instanceof MAPIProps)) {
            return null;
        }
        MAPIProps thisPropset = (MAPIProps) o;
        if (this.mapiPropName == null) {
            mp = thisPropset.getProp(id);
        } else {
            mp = thisPropset.getProp(this.mapiPropName);
        }
        if (mp != null) {
            return mp;
        }
    }
    return null;
}
Also used : MAPIProps(net.freeutils.tnef.MAPIProps) MAPIProp(net.freeutils.tnef.MAPIProp) Attr(net.freeutils.tnef.Attr)

Example 2 with Attr

use of net.freeutils.tnef.Attr in project zm-mailbox by Zimbra.

the class SchedulingViewOfTnef method getMessageClass.

/**
     * @return the value of the attMessageClass TNEF attribute
     * @throws IOException
     */
public String getMessageClass() throws IOException {
    if (messageClass != null) {
        return messageClass;
    }
    Attr attMsgClass = getAttr(Attr.attMessageClass);
    if (attMsgClass == null) {
        return null;
    }
    messageClass = attMsgClass.getValue().toString();
    return messageClass;
}
Also used : Attr(net.freeutils.tnef.Attr)

Example 3 with Attr

use of net.freeutils.tnef.Attr in project zm-mailbox by Zimbra.

the class SchedulingViewOfTnef method read.

/**
     * Gathers scheduling related information from the TNEFInputStream.
     *
     * @param in the TNEFInputStream containing message data
     * @throws IOException if an I/O error occurs
     */
@Override
protected void read(TNEFInputStream in) throws IOException {
    Attr attr;
    Attachment attachmnt = null;
    while ((attr = in.readAttr()) != null) {
        switch(attr.getLevel()) {
            case Attr.LVL_ATTACHMENT:
                switch(attr.getID()) {
                    case Attr.attAttachRenddata:
                        if (attachmnt != null) {
                            super.addAttachment(attachmnt);
                        }
                        attachmnt = new Attachment();
                        attachmnt.addAttribute(attr);
                        break;
                    case Attr.attAttachment:
                        MAPIProps mps = new MAPIProps((RawInputStream) attr.getValue());
                        attachmnt.setMAPIProps(mps);
                        break;
                    case Attr.attAttachData:
                        RawInputStream ris = (RawInputStream) attr.getValue();
                        attachmnt.setRawData(ris);
                        break;
                    case Attr.attAttachTransportFilename:
                        RawInputStream data = (RawInputStream) attr.getValue();
                        String filename = TNEFUtils.removeTerminatingNulls(new String(data.toByteArray(), super.getOEMCodePage()));
                        attachmnt.setFilename(filename);
                        break;
                    default:
                        attachmnt.addAttribute(attr);
                        break;
                }
                // switching on ID for LVL_ATTACHMENT
                break;
            case Attr.LVL_MESSAGE:
                super.addAttribute(attr);
                break;
            default:
                throw new IOException("Invalid attribute level: " + attr.getLevel());
        }
    // switch level
    }
    if (attachmnt != null) {
        super.addAttachment(attachmnt);
    }
}
Also used : MAPIProps(net.freeutils.tnef.MAPIProps) RawInputStream(net.freeutils.tnef.RawInputStream) Attachment(net.freeutils.tnef.Attachment) IOException(java.io.IOException) Attr(net.freeutils.tnef.Attr)

Aggregations

Attr (net.freeutils.tnef.Attr)3 MAPIProps (net.freeutils.tnef.MAPIProps)2 IOException (java.io.IOException)1 Attachment (net.freeutils.tnef.Attachment)1 MAPIProp (net.freeutils.tnef.MAPIProp)1 RawInputStream (net.freeutils.tnef.RawInputStream)1