Commit f4273900 authored by mku's avatar mku

ZP-445 #comment S/MIME Mails with larger attachments are not able to be fully...

ZP-445 #comment  S/MIME Mails with larger attachments are not able to be fully downloaded (on IOS)   #time 4h

git-svn-id: https://z-push.org/svn/z-push/trunk@1716 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 784d96f8
......@@ -636,6 +636,10 @@ class MAPIProvider {
$mapiattach = mapi_message_openattach($mapimessage, $row[PR_ATTACH_NUM]);
$attachprops = mapi_getprops($mapiattach, array(PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_ATTACH_CONTENT_ID, PR_ATTACH_CONTENT_ID_W, PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W, PR_ATTACH_METHOD, PR_DISPLAY_NAME, PR_DISPLAY_NAME_W, PR_ATTACH_SIZE));
if ((isset($attachprops[PR_ATTACH_MIME_TAG]) && strpos(strtolower($attachprops[PR_ATTACH_MIME_TAG]), 'signed') !== false) ||
(isset($attachprops[PR_ATTACH_MIME_TAG_W]) && strpos(strtolower($attachprops[PR_ATTACH_MIME_TAG_W]), 'signed') !== false)) {
continue;
}
// the displayname is handled equaly for all AS versions
$attach->displayname = w2u((isset($attachprops[PR_ATTACH_LONG_FILENAME])) ? $attachprops[PR_ATTACH_LONG_FILENAME] : ((isset($attachprops[PR_ATTACH_FILENAME])) ? $attachprops[PR_ATTACH_FILENAME] : ((isset($attachprops[PR_DISPLAY_NAME])) ? $attachprops[PR_DISPLAY_NAME] : "attachment.bin")));
......@@ -2305,30 +2309,53 @@ class MAPIProvider {
* @return boolean
*/
private function imtoinet($mapimessage, &$message) {
if (function_exists("mapi_inetmapi_imtoinet")) {
// if it is a signed message get a full attachment generated by ZCP
$props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
if (isset($props[PR_MESSAGE_CLASS]) && $props[PR_MESSAGE_CLASS] && strpos(strtolower($props[PR_MESSAGE_CLASS]), 'multipartsigned')) {
// find the required attachment
$attachtable = mapi_message_getattachmenttable($mapimessage);
mapi_table_restrict($attachtable, MAPIUtils::GetSignedAttachmentRestriction());
if (mapi_table_getrowcount($attachtable) == 1) {
$rows = mapi_table_queryrows($attachtable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE), 0, 1);
if (isset($rows[0][PR_ATTACH_NUM])) {
$mapiattach = mapi_message_openattach($mapimessage, $rows[0][PR_ATTACH_NUM]);
$stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN);
$streamsize = $rows[0][PR_ATTACH_SIZE];
}
}
}
elseif (function_exists("mapi_inetmapi_imtoinet")) {
$addrbook = $this->getAddressbook();
$mstream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array('use_tnef' => -1));
$stream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array('use_tnef' => -1));
$mstreamstat = mapi_stream_stat($stream);
$streamsize = $mstreamstat["cb"];
}
$mstreamstat = mapi_stream_stat($mstream);
if ($mstreamstat['cb'] < MAX_EMBEDDED_SIZE) {
if (isset($stream) && isset($streamsize)) {
if ($streamsize < MAX_EMBEDDED_SIZE) {
if (Request::GetProtocolVersion() >= 12.0) {
if (!isset($message->asbody))
$message->asbody = new SyncBaseBody();
//TODO data should be wrapped in a MapiStreamWrapper
$message->asbody->data = mapi_stream_read($mstream, MAX_EMBEDDED_SIZE);
$message->asbody->estimatedDataSize = $mstreamstat["cb"];
$message->asbody->data = mapi_stream_read($stream, MAX_EMBEDDED_SIZE);
$message->asbody->estimatedDataSize = $streamsize;
$message->asbody->truncated = 0;
}
else {
$message->mimetruncated = 0;
//TODO mimedata should be a wrapped in a MapiStreamWrapper
$message->mimedata = mapi_stream_read($mstream, MAX_EMBEDDED_SIZE);
$message->mimesize = $mstreamstat["cb"];
$message->mimedata = mapi_stream_read($stream, MAX_EMBEDDED_SIZE);
$message->mimesize = $streamsize;
}
unset($message->body, $message->bodytruncated);
return true;
}
ZLog::Write(LOGLEVEL_WARN, sprintf("Your request (%d bytes) exceeds the value for inline attachments (%d bytes). You can change the value of MAX_EMBEDDED_SIZE in config.php", $mstreamstat['cb'], MAX_EMBEDDED_SIZE));
else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Your request (%d bytes) exceeds the value for inline attachments (%d bytes). You can change the value of MAX_EMBEDDED_SIZE in config.php", $mstreamstat['cb'], MAX_EMBEDDED_SIZE));
}
}
else {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Error opening attachment for imtoinet"));
}
return false;
}
......
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