// What if the server id contains another '/' ?
//String[] messageID = new StringUtil().split(locURI, "/");
String messageID = locURI.substring(2);
MessageIDStore messageIDStore = new MessageIDStore();
if (! (messageIDStore.checkIsDataThere(locURI) ||
checkIsDataThere(messageID, Constants.ITEMSKEY)) ) {
Message msg = mailParser.parseMessage(mail, locURI);
// Set the message flags depending on the message type
switch(type) {
case 'I': // Inbox
/*
* Sets the message status as an inbound (received) message:
* without using this method, the incoming message is shown
* in the Outbox instead of the Inbox
*/
msg.setInbound(true);
/*
* Indicates that the message has been received successfully
*/
msg.setStatus(Message.Status.RX_RECEIVED, 1);
/*
* This lets the user to answer to the message
*/
msg.setFlag(Message.Flag.REPLY_ALLOWED, true);
break;
case 'S': // Sent
msg.setStatus(Message.Status.TX_SENT, 1);
break;
case 'D': // Draft
msg.setFlag(Message.Flag.SAVED_THEN_ORPHANED, true);
break;
case 'T': // Trash
// FIXME: is it possible to store a message in the trash?
// Shall we just silently discard this?
break;
}
// Save the message to the correct folder
folder.appendMessage(msg);
// XXX: why this conversion?
Integer msgId = new Integer(msg.getMessageId());
String key = new String(type + "/" + msgId.toString());
// Set record key
record.setKey(key);
// Add GUID/LUID mapping
messageIDStore.add(locURI, msgId.toString());
// Append msg id to this DataStore
appendData(type + ":" + msgId.toString(), Constants.ITEMSKEY);
}
return record;
}