use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class SchedulingViewOfTnef method getRecurrenceDefinition.
public RecurrenceDefinition getRecurrenceDefinition(TimeZoneDefinition tzDef) throws IOException, TNEFtoIcalendarServiceException {
RawInputStream tzRis;
if (this.getIcalType() == ICALENDAR_TYPE.VTODO) {
tzRis = MapiPropertyId.PidLidTaskRecurrence.getRawInputStreamValue(this);
} else {
tzRis = MapiPropertyId.PidLidAppointmentRecur.getRawInputStreamValue(this);
}
if (tzRis == null) {
return null;
}
String oemCodePage = super.getOEMCodePage();
RecurrenceDefinition recurDef = new RecurrenceDefinition(tzRis, tzDef, oemCodePage);
return recurDef;
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class SchedulingViewOfTnef method getRTF.
/**
* Useful for X-ALT-DESC? Would need to convert to HTML, which, even for wrapped HTML
* which isn't necessarily common place, isn't 100% straight forward.
*
* @return
* @throws IOException
*/
public String getRTF() throws IOException {
RawInputStream ris = MapiPropertyId.PidTagRtfCompressed.getRawInputStreamValue(this);
if (ris == null) {
sLog.debug("No PR_RTF_COMPRESSED property found");
return null;
}
// Question - does the OEMCodePage for the TNEF need to be factored in
String rtfTxt = new String(CompressedRTFInputStream.decompressRTF(ris.toByteArray()));
if (sLog.isDebugEnabled()) {
sLog.debug("RTF from PR_RTF_COMPRESSED\n%s\n", rtfTxt);
}
return rtfTxt;
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class SchedulingViewOfTnef method initTZinfo.
/**
* Initialise timezone related fields.
* Replies from Outlook 2007 related to a recurrence or an instance
* of a recurrence had :
* PidLidTimeZoneDescription,PidLidTimeZoneStruct,
* PidLidAppointmentTimeZoneDefinitionStartDisplay and
* PidLidAppointmentTimeZoneDefinitionEndDisplay present but NOT
* PidLidAppointmentTimeZoneDefinitionRecur
* further, the StartDisplay/EndDisplay properties were appropriate to the
* Outlook client replying and were NOT related to the originally sent ICAL.
*
* The Outlook originated TimeZone names associated with
* StartDisplay/EndDisplay/Recur props seem "nicer" than the names
* used in PidLidTimeZoneDescription - so, tend to prefer those.
*
* @throws IOException
*/
private void initTZinfo() {
if (tzinfoInitialized) {
return;
}
try {
RawInputStream tzRis;
MapiPropertyId mpi;
mpi = MapiPropertyId.PidLidAppointmentTimeZoneDefinitionStartDisplay;
tzRis = mpi.getRawInputStreamValue(this);
if (tzRis != null) {
startTimeTZinfo = new TimeZoneDefinition(mpi, tzRis);
}
mpi = MapiPropertyId.PidLidAppointmentTimeZoneDefinitionEndDisplay;
tzRis = mpi.getRawInputStreamValue(this);
if (tzRis != null) {
endTimeTZinfo = new TimeZoneDefinition(mpi, tzRis);
}
mpi = MapiPropertyId.PidLidAppointmentTimeZoneDefinitionRecur;
tzRis = mpi.getRawInputStreamValue(this);
if (tzRis != null) {
recurrenceTZinfo = new TimeZoneDefinition(mpi, tzRis);
}
String tzDesc = this.getTimeZoneDescription();
if (null != tzDesc) {
TimeZoneDefinition tzStructInfo = this.getTimeZoneStructInfo(tzDesc);
if (tzStructInfo != null) {
// We know we have a recurrence related TZ definition. Make
// sure we have the most appropriate/nice definition for that.
TZRule tzsRule = tzStructInfo.getEffectiveRule();
if (recurrenceTZinfo == null) {
if ((startTimeTZinfo != null) && (tzsRule.equivalentRule(startTimeTZinfo.getEffectiveRule()))) {
recurrenceTZinfo = startTimeTZinfo;
sLog.debug("Using %s for TZ info", "PidLidAppointmentTimeZoneDefinitionStart");
} else if ((endTimeTZinfo != null) && (tzsRule.equivalentRule(endTimeTZinfo.getEffectiveRule()))) {
recurrenceTZinfo = endTimeTZinfo;
sLog.debug("Using %s for TZ info", "PidLidAppointmentTimeZoneDefinitionEnd");
} else {
recurrenceTZinfo = tzStructInfo;
sLog.debug("Using %s for TZ info", "PidLidTimeZoneStruct");
}
} else if (!tzsRule.equivalentRule(recurrenceTZinfo.getEffectiveRule())) {
recurrenceTZinfo = tzStructInfo;
sLog.debug("Using %s for TZ info", "PidLidAppointmentTimeZoneDefinitionRecur");
}
}
}
} catch (IOException e) {
sLog.debug("Problem encountered initialising timezone information", e);
}
if (recurrenceTZinfo != null) {
// For recurrences, we want just one TZ for consistency
if (endTimeTZinfo == null) {
endTimeTZinfo = recurrenceTZinfo;
} else if (recurrenceTZinfo.getEffectiveRule().equivalentRule(endTimeTZinfo.getEffectiveRule())) {
endTimeTZinfo = recurrenceTZinfo;
} else if (startTimeTZinfo != null) {
// for cancel/request, even when related to an exception.
if (startTimeTZinfo.getEffectiveRule().equivalentRule(endTimeTZinfo.getEffectiveRule())) {
endTimeTZinfo = recurrenceTZinfo;
}
}
startTimeTZinfo = recurrenceTZinfo;
}
if (endTimeTZinfo == null) {
endTimeTZinfo = startTimeTZinfo;
} else if (startTimeTZinfo == null) {
startTimeTZinfo = endTimeTZinfo;
} else if (startTimeTZinfo.getEffectiveRule().equivalentRule(endTimeTZinfo.getEffectiveRule())) {
endTimeTZinfo = startTimeTZinfo;
}
}
use of net.freeutils.tnef.RawInputStream 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);
}
}
Aggregations