Commit 47fc0fd1 authored by mku's avatar mku

ZP-391 #comment Downloading embedded attachment does not work #time 4h

git-svn-id: https://z-push.org/svn/z-push/trunk@1694 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent a5e552ff
...@@ -601,19 +601,29 @@ class BackendZarafa implements IBackend, ISearchProvider { ...@@ -601,19 +601,29 @@ class BackendZarafa implements IBackend, ISearchProvider {
if(!$attach) 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); 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);
$stream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN); // get necessary attachment props
$attprops = mapi_getprops($attach, array(PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W, PR_ATTACH_METHOD));
$attachment = new SyncItemOperationsAttachment();
// check if it's an embedded message and open it in such a case
if (isset($attprops[PR_ATTACH_METHOD]) && $attprops[PR_ATTACH_METHOD] == ATTACH_EMBEDDED_MSG) {
$embMessage = mapi_attach_openobj($attach);
$addrbook = $this->getAddressbook();
$stream = mapi_inetmapi_imtoinet($this->session, $addrbook, $embMessage, array('use_tnef' => -1));
// set the default contenttype for this kind of messages
$attachment->contenttype = "message/rfc822";
}
else
$stream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
if(!$stream) if(!$stream)
throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, unable to open attachment data stream: 0x%X", $attname, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, unable to open attachment data stream: 0x%X", $attname, mapi_last_hresult()), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
//get the mime type of the attachment
$contenttype = mapi_getprops($attach, array(PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W));
$attachment = new SyncItemOperationsAttachment();
// put the mapi stream into a wrapper to get a standard stream // put the mapi stream into a wrapper to get a standard stream
$attachment->data = MapiStreamWrapper::Open($stream); $attachment->data = MapiStreamWrapper::Open($stream);
if (isset($contenttype[PR_ATTACH_MIME_TAG])) if (isset($attprops[PR_ATTACH_MIME_TAG]))
$attachment->contenttype = $contenttype[PR_ATTACH_MIME_TAG]; $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG];
elseif (isset($contenttype[PR_ATTACH_MIME_TAG_W])) elseif (isset($attprops[PR_ATTACH_MIME_TAG_W]))
$attachment->contenttype = $contenttype[PR_ATTACH_MIME_TAG_W]; $attachment->contenttype = $attprops[PR_ATTACH_MIME_TAG_W];
//TODO default contenttype //TODO default contenttype
return $attachment; return $attachment;
} }
......
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