Commit b276bacf authored by mku's avatar mku

ZP-316 #comment Move getBodyPreferenceBestMatch to global Utils #time 10m

git-svn-id: https://z-push.org/svn/z-push/trunk@1561 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent dba9205c
...@@ -2213,23 +2213,6 @@ class MAPIProvider { ...@@ -2213,23 +2213,6 @@ class MAPIProvider {
return $parsedAddress[0]->mailbox.'@'.$parsedAddress[0]->host; return $parsedAddress[0]->mailbox.'@'.$parsedAddress[0]->host;
} }
/**
* Returns the best match of preferred body preference types.
*
* @param array $bpTypes
*
* @access private
* @return int
*/
private function getBodyPreferenceBestMatch($bpTypes) {
// The best choice is RTF, then HTML and then MIME in order to save bandwidth
// because MIME is a complete message including the headers and attachments
if (in_array(SYNC_BODYPREFERENCE_RTF, $bpTypes)) return SYNC_BODYPREFERENCE_RTF;
if (in_array(SYNC_BODYPREFERENCE_HTML, $bpTypes)) return SYNC_BODYPREFERENCE_HTML;
if (in_array(SYNC_BODYPREFERENCE_MIME, $bpTypes)) return SYNC_BODYPREFERENCE_MIME;
return SYNC_BODYPREFERENCE_PLAIN;
}
/** /**
* Returns the message body for a required format * Returns the message body for a required format
* *
...@@ -2335,8 +2318,8 @@ class MAPIProvider { ...@@ -2335,8 +2318,8 @@ class MAPIProvider {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Remove mime body preference type because the device required no mime support. BodyPreference types: %s", implode(', ', $bpTypes))); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Remove mime body preference type because the device required no mime support. BodyPreference types: %s", implode(', ', $bpTypes)));
} }
//get the best fitting preference type //get the best fitting preference type
$bpReturnType = $this->getBodyPreferenceBestMatch($bpTypes); $bpReturnType = Utils::GetBodyPreferenceBestMatch($bpTypes);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("getBodyPreferenceBestMatch: %d", $bpReturnType)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("GetBodyPreferenceBestMatch: %d", $bpReturnType));
$bpo = $contentparameters->BodyPreference($bpReturnType); $bpo = $contentparameters->BodyPreference($bpReturnType);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("bpo: truncation size:'%d', allornone:'%d', preview:'%d'", $bpo->GetTruncationSize(), $bpo->GetAllOrNone(), $bpo->GetPreview())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("bpo: truncation size:'%d', allornone:'%d', preview:'%d'", $bpo->GetTruncationSize(), $bpo->GetAllOrNone(), $bpo->GetPreview()));
......
...@@ -832,6 +832,23 @@ class Utils { ...@@ -832,6 +832,23 @@ class Utils {
} }
return $string; return $string;
} }
/**
* Returns the best match of preferred body preference types.
*
* @param array $bpTypes
*
* @access public
* @return int
*/
public static function GetBodyPreferenceBestMatch($bpTypes) {
// The best choice is RTF, then HTML and then MIME in order to save bandwidth
// because MIME is a complete message including the headers and attachments
if (in_array(SYNC_BODYPREFERENCE_RTF, $bpTypes)) return SYNC_BODYPREFERENCE_RTF;
if (in_array(SYNC_BODYPREFERENCE_HTML, $bpTypes)) return SYNC_BODYPREFERENCE_HTML;
if (in_array(SYNC_BODYPREFERENCE_MIME, $bpTypes)) return SYNC_BODYPREFERENCE_MIME;
return SYNC_BODYPREFERENCE_PLAIN;
}
} }
......
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