Skip to content

Commit

Permalink
Move this to MessageBodyData
Browse files Browse the repository at this point in the history
and fix case where body is empty due to now HTML data.
  • Loading branch information
mrubinsk committed Dec 20, 2014
1 parent f1a3cac commit db70f05
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/Imap/Adapter.php
Expand Up @@ -982,7 +982,7 @@ protected function _buildMailMessage(
$eas_message->airsyncbasenativebodytype = Horde_ActiveSync::BODYPREF_TYPE_PLAIN;
}
$airsync_body = Horde_ActiveSync::messageFactory('AirSyncBaseBody');
$body_type_pref = Horde_ActiveSync_Utils_Mime::getBodyTypePref($options, false);
$body_type_pref = $mbd->getBodyTypePreference();

if ($body_type_pref == Horde_ActiveSync::BODYPREF_TYPE_MIME) {
$this->_logger->info(sprintf(
Expand Down
30 changes: 30 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Imap/MessageBodyData.php
Expand Up @@ -88,6 +88,36 @@ public function __set($property, $value)
}
}

public function getBodyTypePreference($save_bandwith = false)
{
// Apparently some clients don't send the MIME_SUPPORT field (thus
// defaulting it to MIME_SUPPORT_NONE), but still request
// BODYPREF_TYPE_MIME. Failure to do this results in NO data being
// sent to the client, so we ignore the MIME_SUPPORT requirement and
// assume it is implied if it is requested in a BODYPREF element.
$bodyprefs = $this->_options['bodyprefs'];
if ($save_bandwidth) {
return !empty($bodyprefs[Horde_ActiveSync::BODYPREF_TYPE_HTML]) && !empty($this->_html)
? Horde_ActiveSync::BODYPREF_TYPE_HTML
: (!empty($bodyprefs[Horde_ActiveSync::BODYPREF_TYPE_MIME])
? Horde_ActiveSync::BODYPREF_TYPE_MIME
: Horde_ActiveSync::BODYPREF_TYPE_PLAIN);
}

// Prefer high bandwidth, full MIME.
return !empty($bodyprefs[Horde_ActiveSync::BODYPREF_TYPE_MIME])
? Horde_ActiveSync::BODYPREF_TYPE_MIME
: (!empty($bodyprefs[Horde_ActiveSync::BODYPREF_TYPE_HTML]) && !empty($this->_html)
? Horde_ActiveSync::BODYPREF_TYPE_HTML
: Horde_ActiveSync::BODYPREF_TYPE_PLAIN);
}


public function hasHtml()
{
return !empty($this->_html);
}

/**
* Determine which parts we need, and fetch them.
*
Expand Down

0 comments on commit db70f05

Please sign in to comment.