Commit 28ba3a33 authored by mku's avatar mku

ZP-555 #comment Do not change PR_BODY for an email sent via mobile device as...

ZP-555 #comment Do not change PR_BODY for an email sent via mobile device as PR_BODY is always unicode. Only convert PR_HTML property to unicode if this property is set and the encoding of the email sent via mobile is not UTF-8.

git-svn-id: https://z-push.org/svn/z-push/trunk@1973 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent ee966766
...@@ -519,6 +519,8 @@ class MAPIMapping { ...@@ -519,6 +519,8 @@ class MAPIMapping {
"attachnum" => PR_ATTACH_NUM, "attachnum" => PR_ATTACH_NUM,
"attachdatabin" => PR_ATTACH_DATA_BIN, "attachdatabin" => PR_ATTACH_DATA_BIN,
"internetcpid" => PR_INTERNET_CPID, "internetcpid" => PR_INTERNET_CPID,
"rtf" => PR_RTF_COMPRESSED,
"rtfinsync" => PR_RTF_IN_SYNC,
); );
} }
} }
......
...@@ -482,6 +482,106 @@ class MAPIUtils { ...@@ -482,6 +482,106 @@ class MAPIUtils {
); );
} }
/**
* Calculates the native body type of a message using available properties. Refer to oxbbody.
*
* @param array $messageprops
*
* @access public
* @return int
*/
public static function GetNativeBodyType($messageprops) {
//check if the properties are set and get the error code if needed
if (!isset($messageprops[PR_BODY])) $messageprops[PR_BODY] = self::getError(PR_BODY, $messageprops);
if (!isset($messageprops[PR_RTF_COMPRESSED])) $messageprops[PR_RTF_COMPRESSED] = self::getError(PR_RTF_COMPRESSED, $messageprops);
if (!isset($messageprops[PR_HTML])) $messageprops[PR_HTML] = self::getError(PR_HTML, $messageprops);
if (!isset($messageprops[PR_RTF_IN_SYNC])) $messageprops[PR_RTF_IN_SYNC] = self::getError(PR_RTF_IN_SYNC, $messageprops);
if ( // 1
($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_PLAIN;
elseif ( // 2
($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_PLAIN;
elseif ( // 3
($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_RTF;
elseif ( // 4
($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_RTF;
elseif ( // 5
($messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
(!$messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_HTML;
elseif ( // 6
($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_RTF;
elseif ( // 7
($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
(!$messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_HTML;
elseif ( // 8
($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_RTF;
elseif ( // 9.1
($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
(!$messageprops[PR_RTF_IN_SYNC]))
return SYNC_BODYPREFERENCE_PLAIN;
elseif ( // 9.2
($messageprops[PR_RTF_COMPRESSED] != MAPI_E_NOT_FOUND || $messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_RTF;
elseif ( // 9.3
($messageprops[PR_BODY] != MAPI_E_NOT_FOUND || $messageprops[PR_BODY] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_HTML] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_PLAIN;
elseif ( // 9.4
($messageprops[PR_HTML] != MAPI_E_NOT_FOUND || $messageprops[PR_HTML] == MAPI_E_NOT_ENOUGH_MEMORY) &&
($messageprops[PR_BODY] == MAPI_E_NOT_FOUND) &&
($messageprops[PR_RTF_COMPRESSED] == MAPI_E_NOT_FOUND))
return SYNC_BODYPREFERENCE_HTML;
else // 10
return SYNC_BODYPREFERENCE_PLAIN;
}
/**
* Returns the error code for a given property. Helper for getNativeBodyType function.
*
* @param int $tag
* @param array $messageprops
*
* @access private
* @return int (MAPI_ERROR_CODE)
*/
private static function getError($tag, $messageprops) {
$prBodyError = mapi_prop_tag(PT_ERROR, mapi_prop_id($tag));
if(isset($messageprops[$prBodyError]) && mapi_is_error($messageprops[$prBodyError])) {
if($messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_32BIT ||
$messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_64BIT) {
return MAPI_E_NOT_ENOUGH_MEMORY;
}
}
return MAPI_E_NOT_FOUND;
}
} }
?> ?>
\ No newline at end of file
...@@ -461,18 +461,14 @@ class BackendZarafa implements IBackend, ISearchProvider { ...@@ -461,18 +461,14 @@ class BackendZarafa implements IBackend, ISearchProvider {
// @see http://jira.zarafa.com/browse/ZP-68 // @see http://jira.zarafa.com/browse/ZP-68
$meetingRequestProps = MAPIMapping::GetMeetingRequestProperties(); $meetingRequestProps = MAPIMapping::GetMeetingRequestProperties();
$meetingRequestProps = getPropIdsFromStrings($this->store, $meetingRequestProps); $meetingRequestProps = getPropIdsFromStrings($this->store, $meetingRequestProps);
$props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS, $meetingRequestProps["goidtag"], $sendMailProps["internetcpid"])); $props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS, $meetingRequestProps["goidtag"], $sendMailProps["internetcpid"], $sendMailProps["body"], $sendMailProps["html"], $sendMailProps["rtf"], $sendMailProps["rtfinsync"]));
// Convert sent message's body to UTF-8. // Convert sent message's body to UTF-8 if it was a HTML message.
// @see http://jira.zarafa.com/browse/ZP-505 // @see http://jira.zarafa.com/browse/ZP-505 and http://jira.zarafa.com/browse/ZP-555
if (isset($props[$sendMailProps["internetcpid"]]) && $props[$sendMailProps["internetcpid"]] != INTERNET_CPID_UTF8) { if (isset($props[$sendMailProps["internetcpid"]]) && $props[$sendMailProps["internetcpid"]] != INTERNET_CPID_UTF8 && MAPIUtils::GetNativeBodyType($props) == SYNC_BODYPREFERENCE_HTML) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sent email cpid is not unicode (%d). Set it to unicode and convert email body.", $props[$sendMailProps["internetcpid"]])); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Sent email cpid is not unicode (%d). Set it to unicode and convert email html body.", $props[$sendMailProps["internetcpid"]]));
$mapiprops[$sendMailProps["internetcpid"]] = INTERNET_CPID_UTF8; $mapiprops[$sendMailProps["internetcpid"]] = INTERNET_CPID_UTF8;
$body = MAPIUtils::readPropStream($mapimessage, PR_BODY);
$body = Utils::ConvertCodepageStringToUtf8($props[$sendMailProps["internetcpid"]], $body);
$mapiprops[$sendMailProps["body"]] = $body;
$bodyHtml = MAPIUtils::readPropStream($mapimessage, PR_HTML); $bodyHtml = MAPIUtils::readPropStream($mapimessage, PR_HTML);
$bodyHtml = Utils::ConvertCodepageStringToUtf8($props[$sendMailProps["internetcpid"]], $bodyHtml); $bodyHtml = Utils::ConvertCodepageStringToUtf8($props[$sendMailProps["internetcpid"]], $bodyHtml);
$mapiprops[$sendMailProps["html"]] = $bodyHtml; $mapiprops[$sendMailProps["html"]] = $bodyHtml;
......
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