Commit 6a48f14e authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-707 Initial implementation. Needs fixing.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 897be774
...@@ -798,7 +798,8 @@ class MAPIProvider { ...@@ -798,7 +798,8 @@ class MAPIProvider {
ZLog::Write(LOGLEVEL_DEBUG, "Attach the transport message headers to a signed message"); ZLog::Write(LOGLEVEL_DEBUG, "Attach the transport message headers to a signed message");
$transportHeaders = array(PR_TRANSPORT_MESSAGE_HEADERS_W); $transportHeaders = array(PR_TRANSPORT_MESSAGE_HEADERS_W);
$messageHeaders = $this->getProps($mapimessage, $transportHeaders); $messageHeaders = $this->getProps($mapimessage, $transportHeaders);
$message->asbody->data = $messageHeaders[PR_TRANSPORT_MESSAGE_HEADERS] ."\r\n\r\n" . $message->asbody->data; // TODO fix, this is ugly as f*ck! Use a prepend filter?
$message->asbody->data = StringStreamWrapper::Open($messageHeaders[PR_TRANSPORT_MESSAGE_HEADERS] ."\r\n\r\n" . stream_get_contents($message->asbody->data));
} }
return $message; return $message;
...@@ -2349,11 +2350,12 @@ class MAPIProvider { ...@@ -2349,11 +2350,12 @@ class MAPIProvider {
$message->asbody = new SyncBaseBody(); $message->asbody = new SyncBaseBody();
$message->asbody->type = $bpReturnType; $message->asbody->type = $bpReturnType;
if ($bpReturnType == SYNC_BODYPREFERENCE_RTF) if ($bpReturnType == SYNC_BODYPREFERENCE_RTF)
$message->asbody->data = base64_encode($body); $message->asbody->data = StringStreamWrapper::Open(base64_encode($body));
elseif (isset($message->internetcpid) && $bpReturnType == SYNC_BODYPREFERENCE_HTML) elseif (isset($message->internetcpid) && $bpReturnType == SYNC_BODYPREFERENCE_HTML)
$message->asbody->data = Utils::ConvertCodepageStringToUtf8($message->internetcpid, $body); $message->asbody->data = StringStreamWrapper::Open(Utils::ConvertCodepageStringToUtf8($message->internetcpid, $body));
else else
$message->asbody->data = w2u($body); $message->asbody->data = StringStreamWrapper::Open($body);
// TODO fix
$message->asbody->estimatedDataSize = strlen($message->asbody->data); $message->asbody->estimatedDataSize = strlen($message->asbody->data);
} }
else { else {
...@@ -2401,8 +2403,7 @@ class MAPIProvider { ...@@ -2401,8 +2403,7 @@ class MAPIProvider {
if (Request::GetProtocolVersion() >= 12.0) { if (Request::GetProtocolVersion() >= 12.0) {
if (!isset($message->asbody)) if (!isset($message->asbody))
$message->asbody = new SyncBaseBody(); $message->asbody = new SyncBaseBody();
//TODO data should be wrapped in a MapiStreamWrapper $message->asbody->data = MapiStreamWrapper::Open($stream);
$message->asbody->data = mapi_stream_read($stream, $streamsize);
$message->asbody->estimatedDataSize = $streamsize; $message->asbody->estimatedDataSize = $streamsize;
$message->asbody->truncated = 0; $message->asbody->truncated = 0;
} }
...@@ -2451,7 +2452,12 @@ class MAPIProvider { ...@@ -2451,7 +2452,12 @@ class MAPIProvider {
$message->asbody->estimatedDataSize > $bpo->GetTruncationSize() && $message->asbody->estimatedDataSize > $bpo->GetTruncationSize() &&
$contentparameters->GetTruncation() != SYNC_TRUNCATION_ALL // do not truncate message if the whole is requested, e.g. on fetch $contentparameters->GetTruncation() != SYNC_TRUNCATION_ALL // do not truncate message if the whole is requested, e.g. on fetch
) { ) {
$message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $bpo->GetTruncationSize());
// read the data from the stream, 10 bytes more than requested
// TODO this should be done better! We could give another parameter (length) to the Stream wrappers so they truncate automatically after X bytes.
$dataChunk = fread($message->asbody->data, $bpo->GetTruncationSize() + 10);
$dataTruncated = Utils::Utf8_truncate($dataChunk, $bpo->GetTruncationSize());
$message->asbody->data = StringStreamWrapper::Open($dataTruncated);
$message->asbody->truncated = 1; $message->asbody->truncated = 1;
} }
...@@ -2610,15 +2616,16 @@ class MAPIProvider { ...@@ -2610,15 +2616,16 @@ class MAPIProvider {
* @return void * @return void
*/ */
private function setASbody($asbody, &$props, $appointmentprops) { private function setASbody($asbody, &$props, $appointmentprops) {
if (isset($asbody->type) && isset($asbody->data) && strlen($asbody->data) > 0) { // TODO: fix checking for the length
if (isset($asbody->type) && isset($asbody->data) /*&& strlen($asbody->data) > 0*/) {
switch ($asbody->type) { switch ($asbody->type) {
case SYNC_BODYPREFERENCE_PLAIN: case SYNC_BODYPREFERENCE_PLAIN:
default: default:
//set plain body if the type is not in valid range //set plain body if the type is not in valid range
$props[$appointmentprops["body"]] = u2w($asbody->data); $props[$appointmentprops["body"]] = stream_get_contents($asbody->data);
break; break;
case SYNC_BODYPREFERENCE_HTML: case SYNC_BODYPREFERENCE_HTML:
$props[$appointmentprops["html"]] = u2w($asbody->data); $props[$appointmentprops["html"]] = stream_get_contents($asbody->data);
break; break;
case SYNC_BODYPREFERENCE_RTF: case SYNC_BODYPREFERENCE_RTF:
break; break;
......
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