Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.sourceforge.MSGViewer.factory;

import com.auxilii.msgparser.Message;
import com.auxilii.msgparser.MsgWriter;
import net.sourceforge.MSGViewer.AttachmentRepository;
import net.sourceforge.MSGViewer.factory.mbox.EMLWriterViaJavaMail;
import net.sourceforge.MSGViewer.factory.mbox.MBoxWriterViaJavaMail;
import net.sourceforge.MSGViewer.factory.msg.MsgWriter;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,23 @@
public class MSTimeConvert {

/**
* difference between 1-1-1601 and 1-1-1970 in millisecond
* difference between 1-1-1601 and 1-1-1970 in milliseconds
*/
public static final long MS_EPOCH_OFFSET = 11644473600000L;

/**
* convert a 64 bit Integer value to a normal time field.
* MS hat here nanoseconds since 1601
* convert a 64-bit Integer value to a normal time field.
* MS time counts hundreds of nanoseconds since 1601.
*
* @return the time in millis since 1970 same as System.currentTime() does
* this is the value in UTC timezone!
*/
public static long PtypeTime2Millis(long time) {
time /= 10L; // micro
time /= 1000L; // milli
time /= 10L; // micros
time /= 1000L; // millis

time -= MS_EPOCH_OFFSET; // offset since 1601

return time;
}


/**
* convert a 64 bit Integer value to a normal time field.
* MS hat here nanoseconds since 1601
*
* @return returns the time in nabos since 1.1.1601
*/
public static long Millis2PtypeTime(long time) {
time += MS_EPOCH_OFFSET; // offset since 1601

time *= 10L; // micro
time *= 1000L; // milli

return time;
}
}

This file was deleted.

142 changes: 0 additions & 142 deletions MSGViewer/src/test/resources/issue129/test.eml

This file was deleted.

12 changes: 12 additions & 0 deletions msgparser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,17 @@
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
32 changes: 12 additions & 20 deletions msgparser/src/main/java/com/auxilii/msgparser/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
Expand All @@ -59,11 +58,7 @@ public class Message {
public static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("[EEE, ]d MMM y HH:mm[:ss] Z").toFormatter(Locale.US);

/**
* The message class as defined in the .msg file.
*/
private String messageClass = "IPM.Note";
/**
* The message Id.
* The message ID.
*/
private String messageId;
/**
Expand All @@ -74,7 +69,7 @@ public class Message {
private String fromSMTPAddress;

/**
* The name part of the From: mail address
* The name part of the "From:" mail address
*/
private String fromName;
private String fromAddressType;
Expand Down Expand Up @@ -125,7 +120,7 @@ public class Message {
/**
* Contains all properties that are not covered by the special properties.
*/
private final Collection<Property> properties = new ArrayList<>();
private final List<Property> properties = new ArrayList<>();
/**
* A list containing all recipients for this message (which can be set in the
* 'to:', 'cc:' and 'bcc:' field, respectively).
Expand All @@ -140,12 +135,9 @@ public void addRecipient(RecipientEntry recipient) {
this.recipients.add(recipient);
}

void setProperty(Property property) {
void addProperty(Property property) {
this.properties.add(property);
switch (property.getPid()) {
case PidTagMessageClass:
this.setMessageClass((String) property.getValue());
break;
case PidTagInternetMessageId:
this.setMessageId((String) property.getValue());
break;
Expand Down Expand Up @@ -208,6 +200,13 @@ void setProperty(Property property) {
}
}

/**
* The properties in the order they were added to the message.
*/
public List<Property> getProperties() {
return properties;
}

/**
* Provides a short representation of this .msg object.
*
Expand Down Expand Up @@ -362,13 +361,6 @@ private void setDisplayBcc(String displayBcc) {
this.displayBcc = displayBcc;
}

/**
* @param messageClass the messageClass to set
*/
private void setMessageClass(String messageClass) {
this.messageClass = messageClass;
}

/**
* @return the messageId
*/
Expand Down Expand Up @@ -499,7 +491,7 @@ private static ZonedDateTime toDate(String dateValue) {
try {
return ZonedDateTime.from(DATE_TIME_FORMATTER.parse(dateValue));
} catch (Exception e) {
LOGGER.info("Could not parse date " + dateValue, e);
LOGGER.info("Could not parse date {}", dateValue, e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package net.sourceforge.MSGViewer.factory.msg;
package com.auxilii.msgparser;

import com.auxilii.msgparser.Message;
import com.auxilii.msgparser.Ptyp;
import com.auxilii.msgparser.RecipientEntry;
import com.auxilii.msgparser.attachment.Attachment;
import com.auxilii.msgparser.attachment.FileAttachment;
import com.auxilii.msgparser.attachment.MsgAttachment;
import net.sourceforge.MSGViewer.factory.msg.entries.*;
import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypInteger32;
import net.sourceforge.MSGViewer.factory.msg.properties.PropPtypTime;
import net.sourceforge.MSGViewer.factory.msg.properties.PropType;
import com.auxilii.msgparser.entries.*;
import com.auxilii.msgparser.properties.PropPtypInteger32;
import com.auxilii.msgparser.properties.PropPtypTime;
import com.auxilii.msgparser.properties.PropType;
import org.apache.poi.poifs.filesystem.DirectoryEntry;

import java.io.ByteArrayInputStream;
Expand Down
6 changes: 3 additions & 3 deletions msgparser/src/main/java/com/auxilii/msgparser/MsgParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static Message parseMsg(DirectoryEntry dir) throws IOException {
msg.addAttachment(parseAttachment(entry));
}
while (propertyStream.available() > 0) {
msg.setProperty(new Property(propertyStream, dir));
msg.addProperty(new Property(propertyStream, dir));
}
return msg;
}
Expand All @@ -90,7 +90,7 @@ private static RecipientEntry parseRecipient(DirectoryEntry dir) throws IOExcept
try (DocumentInputStream propertyStream = new DocumentInputStream(propertyEntry)) {
propertyStream.skip(8);
while (propertyStream.available() > 0) {
recipient.setProperty(new Property(propertyStream, dir));
recipient.addProperty(new Property(propertyStream, dir));
}
}
return recipient;
Expand Down Expand Up @@ -135,7 +135,7 @@ private static FileAttachment createAttachmentWithProperties(DirectoryEntry dir,
FileAttachment fileAttachment = new FileAttachment();
while (propertyStream.available() > 0) {
Property property = new Property(propertyStream, dir);
fileAttachment.setProperty(property);
fileAttachment.addProperty(property);
}
return fileAttachment;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.sourceforge.MSGViewer.factory.msg;
package com.auxilii.msgparser;

import com.auxilii.msgparser.Message;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

Expand Down
Loading