Commit be0b08a3 authored by Manfred Kutas's avatar Manfred Kutas

ZP-729 Attachments of signed emails are not available on Android 6.

Released under the Affero GNU General Public License (AGPL) version 3.
parent f262bf07
......@@ -513,6 +513,7 @@ class MAPIProvider {
* @return SyncEmail
*/
private function getEmail($mapimessage, $contentparameters) {
MAPIUtils::parseSmime($this->session, $this->store, $this->getAddressbook(), $mapimessage);
$message = new SyncMail();
$this->getPropsFromMAPI($message, $mapimessage, MAPIMapping::GetEmailMapping());
......@@ -707,7 +708,15 @@ class MAPIProvider {
if (strtolower(substr($attach->displayname, -4)) != '.eml')
$attach->displayname .= '.eml';
}
// android devices require attachment size in order to display an attachment properly
if (!isset($attachprops[PR_ATTACH_SIZE])) {
$stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN);
$stat = mapi_stream_stat($stream);
$attach->estimatedDataSize = $stat['cb'];
}
else {
$attach->estimatedDataSize = $attachprops[PR_ATTACH_SIZE];
}
if (isset($attachprops[PR_ATTACH_CONTENT_ID]) && $attachprops[PR_ATTACH_CONTENT_ID])
$attach->contentid = $attachprops[PR_ATTACH_CONTENT_ID];
......
......@@ -582,4 +582,44 @@ class MAPIUtils {
}
return MAPI_E_NOT_FOUND;
}
/**
* Function will be used to decode smime messages and convert it to normal messages.
*
* @param MAPISession $session
* @param MAPIStore $store
* @param MAPIAdressBook $addressBook
* @param MAPIMessage $message smime message
*
* @access public
* @return void
*/
public static function parseSmime($session, $store, $addressBook, &$mapimessage) {
$props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
if (isset($props[PR_MESSAGE_CLASS]) && stripos($props[PR_MESSAGE_CLASS], 'IPM.Note.SMIME.MultipartSigned') !== false) {
// this is a signed message. decode it.
$attachTable = mapi_message_getattachmenttable($mapimessage);
$rows = mapi_table_queryallrows($attachTable, array(PR_ATTACH_MIME_TAG, PR_ATTACH_NUM));
$attnum = false;
foreach($rows as $row) {
if (isset($row[PR_ATTACH_MIME_TAG]) && $row[PR_ATTACH_MIME_TAG] == 'multipart/signed') {
$attnum = $row[PR_ATTACH_NUM];
}
}
mapi_message_deleteattach($mapimessage, $attnum);
if ($attnum !== false) {
$att = mapi_message_openattach($mapimessage, $attnum);
$data = mapi_openproperty($att, PR_ATTACH_DATA_BIN);
mapi_inetmapi_imtomapi($session, $store, $addressBook, $mapimessage, $data, array("parse_smime_signed" => 1));
ZLog::Write(LOGLEVEL_DEBUG, "Convert a smime signed message to a normal message.");
}
mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => 'IPM.Note.SMIME.MultipartSigned'));
}
// TODO check if we need to do this for encrypted (and signed?) message as well
}
}
......@@ -667,6 +667,7 @@ class BackendZarafa implements IBackend, ISearchProvider {
if(!$message)
throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, unable to open item for attachment data for id '%s' with: 0x%X", $attname, $id, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
MAPIUtils::parseSmime($this->session, $this->defaultstore, $this->getAddressbook(), $message);
$attach = mapi_message_openattach($message, $attachnum);
if(!$attach)
throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, unable to open attachment number '%s' with: 0x%X", $attname, $attachnum, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment