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

Merge pull request #499 in ZP/z-push from...

Merge pull request #499 in ZP/z-push from bugfix/ZP-1180-implement-plain-streams-for-caldav to develop

* commit 'a9d432c3':
  ZP-1180 Implement plain streams for CalDav and CardDav backends.
parents b4835d43 a9d432c3
......@@ -704,15 +704,18 @@ class BackendCalDAV extends BackendDiff {
case "DESCRIPTION":
if (Request::GetProtocolVersion() >= 12.0) {
$message->asbody = new SyncBaseBody();
$message->asbody->data = str_replace("\n","\r\n", str_replace("\r","",Utils::ConvertHtmlToText($property->Value())));
$data = str_replace("\n","\r\n", str_replace("\r","",Utils::ConvertHtmlToText($property->Value())));
// truncate body, if requested
if (strlen($message->asbody->data) > $truncsize) {
if (strlen($data) > $truncsize) {
$message->asbody->truncated = 1;
$message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $truncsize);
$data = Utils::Utf8_truncate($data, $truncsize);
}
else {
$message->asbody->truncated = 0;
}
$message->asbody->data = StringStreamWrapper::Open($data);
$message->asbody->estimatedDataSize = strlen($data);
unset($data);
$message->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
}
else {
......@@ -1067,7 +1070,7 @@ class BackendCalDAV extends BackendDiff {
$vevent->AddProperty("DESCRIPTION", $data->body);
}
if (isset($data->asbody->data)) {
$vevent->AddProperty("DESCRIPTION", $data->asbody->data);
$vevent->AddProperty("DESCRIPTION", stream_get_contents($data->asbody->data));
}
if (isset($data->categories) && is_array($data->categories)) {
$vevent->AddProperty("CATEGORIES", implode(",", $data->categories));
......@@ -1336,13 +1339,13 @@ class BackendCalDAV extends BackendDiff {
if (isset($data->asbody->data)) {
if (isset($data->nativebodytype) && $data->nativebodytype == SYNC_BODYPREFERENCE_RTF) {
$rtfparser = new rtf();
$rtfparser->loadrtf(base64_decode($data->asbody->data));
$rtfparser->loadrtf(base64_decode(stream_get_contents($data->asbody->data)));
$rtfparser->output("ascii");
$rtfparser->parse();
$vtodo->AddProperty("DESCRIPTION", $rtfparser->out);
}
else {
$vtodo->AddProperty("DESCRIPTION", $data->asbody->data);
$vtodo->AddProperty("DESCRIPTION", stream_get_contents($data->asbody->data));
}
}
if (isset($data->complete)) {
......
......@@ -1177,16 +1177,17 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
if (Request::GetProtocolVersion() >= 12.0) {
$message->asbody = new SyncBaseBody();
$message->asbody->type = SYNC_BODYPREFERENCE_PLAIN;
$message->asbody->data = $vcard['note'][0]['val'][0];
if ($truncsize > 0 && $truncsize < strlen($message->asbody->data)) {
$data = $vcard['note'][0]['val'][0];
if ($truncsize > 0 && $truncsize < strlen($data)) {
$message->asbody->truncated = 1;
$message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $truncsize);
$data = Utils::Utf8_truncate($data, $truncsize);
}
else {
$message->asbody->truncated = 0;
}
$message->asbody->estimatedDataSize = strlen($message->asbody->data);
$message->asbody->data = StringStreamWrapper::Open($data);
$message->asbody->estimatedDataSize = strlen($data);
unset($data);
}
else {
$message->body = $vcard['note'][0]['val'][0];
......@@ -1261,7 +1262,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
$val.=';';
}
if ($k == 'body' && isset($message->asbody)) {
$val = $message->asbody->data;
$val = stream_get_contents($message->asbody->data);
}
if (empty($val) || preg_match('/^(\;)+$/', $val) == 1)
continue;
......
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