Search in sources :

Example 1 with RawInputStream

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

the class MapiPropertyId method getByteArrayValue.

public byte[] getByteArrayValue(SchedulingViewOfTnef schedView) throws IOException {
    MAPIValue mpValue = getFirstValue(schedView);
    if (mpValue == null) {
        return null;
    }
    Object obj = mpValue.getValue();
    if (obj == null) {
        return null;
    }
    if (obj instanceof byte[]) {
        return (byte[]) obj;
    } else if (obj instanceof RawInputStream) {
        RawInputStream ris = (RawInputStream) obj;
        return ris.toByteArray();
    }
    return null;
}
Also used : RawInputStream(net.freeutils.tnef.RawInputStream) MAPIValue(net.freeutils.tnef.MAPIValue)

Example 2 with RawInputStream

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

the class MapiPropertyId method getStringValue.

public String getStringValue(SchedulingViewOfTnef schedView) throws IOException {
    MAPIValue mpValue = getFirstValue(schedView);
    if (mpValue == null) {
        return null;
    }
    Object obj;
    if (mpValue.getType() == MAPIProp.PT_STRING) {
        // Assume the value is in the OEM Code Page
        // The current MAPIValue code does not take account of that.
        RawInputStream ris = mpValue.getRawData();
        return IcalUtil.readString(ris, (int) ris.getLength(), schedView.getOEMCodePage());
    } else {
        // Probably PT_UNICODE_STRING but will accept anything whose value is
        // a String.
        obj = mpValue.getValue();
    }
    if (obj == null) {
        return null;
    }
    if (obj instanceof String) {
        return (String) obj;
    }
    return null;
}
Also used : RawInputStream(net.freeutils.tnef.RawInputStream) MAPIValue(net.freeutils.tnef.MAPIValue)

Example 3 with RawInputStream

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

the class TestTnefTimeZone method testTnefTimeZoneFromInputStream.

@Test
public void testTnefTimeZoneFromInputStream() throws IOException {
    TimeZone tz = null;
    RawInputStream ris = null;
    ris = new RawInputStream(intToleByteArray(13), 0, 4);
    tz = TnefTimeZone.getTimeZone(ris);
    Assert.assertFalse(tz == null);
    Assert.assertTrue(tz.getRawOffset() == -28800000);
    Assert.assertTrue(tz.getDSTSavings() == 3600000);
    // don't observe daylight saving bit is set!!
    ris = new RawInputStream(new byte[] { 13, 0, 0, (byte) 128 }, 0, 4);
    tz = TnefTimeZone.getTimeZone(ris);
    Assert.assertFalse(tz == null);
    Assert.assertTrue(tz.getRawOffset() == -28800000);
    Assert.assertTrue(tz.getID().equals("Etc/GMT+8"));
}
Also used : TimeZone(java.util.TimeZone) RawInputStream(net.freeutils.tnef.RawInputStream) Test(org.junit.Test)

Example 4 with RawInputStream

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

the class SchedulingViewOfTnef method getTimeZoneStructInfo.

/**
     * PidLidTimeZoneStruct Specifies time zone information for a recurring meeting.
     *
     * @param tzName
     * @return
     * @throws IOException
     */
private TimeZoneDefinition getTimeZoneStructInfo(String tzName) throws IOException {
    RawInputStream tzRis = MapiPropertyId.PidLidTimeZoneStruct.getRawInputStreamValue(this);
    if (tzRis == null) {
        return null;
    }
    TimeZoneDefinition tzDef = new TimeZoneDefinition(tzRis, tzName);
    if (tzDef == null) {
        if (sLog.isDebugEnabled()) {
            sLog.debug("Failed to load TimeZoneDefinition from PidLidTimeZoneStruct and " + tzName);
        }
    }
    return tzDef;
}
Also used : RawInputStream(net.freeutils.tnef.RawInputStream) TimeZoneDefinition(com.zimbra.cs.util.tnef.mapi.TimeZoneDefinition)

Example 5 with RawInputStream

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

the class SchedulingViewOfTnef method getGlobalObjectIdType.

private GlobalObjectId getGlobalObjectIdType(MapiPropertyId mpi) {
    GlobalObjectId gid = null;
    RawInputStream ris;
    try {
        ris = mpi.getRawInputStreamValue(this);
        if (ris != null) {
            gid = new GlobalObjectId(ris);
        }
    } catch (IOException e) {
        sLog.debug("Problem getting value of MAPI property " + mpi.toString() + " from TNEF", e);
    }
    return gid;
}
Also used : RawInputStream(net.freeutils.tnef.RawInputStream) GlobalObjectId(com.zimbra.cs.util.tnef.mapi.GlobalObjectId) IOException(java.io.IOException)

Aggregations

RawInputStream (net.freeutils.tnef.RawInputStream)9 IOException (java.io.IOException)3 TimeZoneDefinition (com.zimbra.cs.util.tnef.mapi.TimeZoneDefinition)2 MAPIValue (net.freeutils.tnef.MAPIValue)2 GlobalObjectId (com.zimbra.cs.util.tnef.mapi.GlobalObjectId)1 MapiPropertyId (com.zimbra.cs.util.tnef.mapi.MapiPropertyId)1 RecurrenceDefinition (com.zimbra.cs.util.tnef.mapi.RecurrenceDefinition)1 TZRule (com.zimbra.cs.util.tnef.mapi.TZRule)1 TimeZone (java.util.TimeZone)1 Attachment (net.freeutils.tnef.Attachment)1 Attr (net.freeutils.tnef.Attr)1 MAPIProps (net.freeutils.tnef.MAPIProps)1 Test (org.junit.Test)1