/**
  * create new message for the cache
  * 
  * @param array $_message
  * @param Felamimail_Model_Folder $_folder
  * @return Felamimail_Model_Message
  */
 protected function _createModelMessage(array $_message, Felamimail_Model_Folder $_folder = NULL)
 {
     // Optimization!!!
     if ($_folder == NULL) {
         if (isset($_message['folder_id'])) {
             $_folder = array_key_exists($_message['folder_id'], $this->_folderMap) ? $this->_folderMap[$_message['folder_id']] : ($this->_folderMap[$_message['folder_id']] = Felamimail_Controller_Folder::getInstance()->get($_message['folder_id']));
         } else {
             return NULL;
         }
     }
     $message = new Felamimail_Model_Message(array('id' => self::createMessageId($_folder->account_id, $_folder->getId(), $_message['uid']), 'account_id' => $_folder->account_id, 'messageuid' => $_message['uid'], 'folder_id' => $_folder->getId(), 'timestamp' => Tinebase_DateTime::now(), 'received' => Felamimail_Message::convertDate($_message['received']), 'size' => $_message['size'], 'flags' => $_message['flags']), true);
     $message->parseStructure($_message['structure']);
     $message->parseHeaders($_message['header']);
     $message->fixToListModel();
     $message->parseBodyParts();
     $message->parseSmime($_message['structure']);
     $attachments = Felamimail_Controller_Message::getInstance()->getAttachments($message);
     $message->has_attachment = count($attachments) > 0 ? true : false;
     return $message;
 }
 /**
  * create new message for the cache
  * 
  * @param array $_message
  * @param Felamimail_Model_Folder $_folder
  * @return Felamimail_Model_Message
  */
 protected function _createMessageToCache(array $_message, Felamimail_Model_Folder $_folder)
 {
     $message = new Felamimail_Model_Message(array('account_id' => $_folder->account_id, 'messageuid' => $_message['uid'], 'folder_id' => $_folder->getId(), 'timestamp' => Tinebase_DateTime::now(), 'received' => Felamimail_Message::convertDate($_message['received']), 'size' => $_message['size'], 'flags' => $_message['flags']));
     $message->parseStructure($_message['structure']);
     $message->parseHeaders($_message['header']);
     $message->parseBodyParts();
     $attachments = $this->getAttachments($message);
     $message->has_attachment = count($attachments) > 0 ? true : false;
     return $message;
 }