abstract public function statMessage($folderId, $id);
/**
+ * Obtain an ActiveSync message from the backend.
*
- * @param $folderid
- * @param $id
- * @param $truncsize
- * @param $mimesupport
+ * @param string $folderid The server's folder id this message is from
+ * @param string $id The server's message id
+ * @param integer $truncsize A TRUNCATION_* constant
+ * @param integer $mimesupport Mime support for this message
*
* @return Horde_ActiveSync_Message_Base The message data
*/
* @param $flags
* @return unknown_type
*/
- function setReadFlag($folderid, $id, $flags)
+ public function setReadFlag($folderid, $id, $flags)
{
return false;
}
. '</wap-provisioningdoc>';
}
+ /**
+ * Truncate an UTF-8 encoded sting correctly
+ *
+ * If it's not possible to truncate properly, an empty string is returned
+ *
+ * @param string $string The string to truncate
+ * @param string $length The length of the returned string
+ *
+ * @return string The truncated string
+ */
+ static public function truncate($string, $length)
+ {
+ if (strlen($string) <= $length) {
+ return $string;
+ }
+ while($length >= 0) {
+ if ((ord($string[$length]) < 0x80) || (ord($string[$length]) >= 0xC0)) {
+ return substr($string, 0, $length);
+ }
+ $length--;
+ }
+
+ return "";
+ }
+
}
\ No newline at end of file
/**
* Get a message from the backend
*
- * @see framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde_ActiveSync_Driver_Base#getMessage($folderid, $id, $truncsize, $mimesupport)
+ * @see framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde_ActiveSync_Driver_Base#getMessage
*/
public function getMessage($folderid, $id, $truncsize, $mimesupport = 0)
{
switch ($folderid) {
case self::APPOINTMENTS_FOLDER:
try {
- return $this->_connector->calendar_export($id);
+ $message = $this->_connector->calendar_export($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
return false;
case self::CONTACTS_FOLDER:
try {
- return $this->_connector->contacts_export($id);
+ $message = $this->_connector->contacts_export($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
return false;
}
-
break;
case self::TASKS_FOLDER:
try {
- return $this->_connector->tasks_export($id);
+ $message = $this->_connector->tasks_export($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
return false;
default:
return false;
}
+ if (strlen($message->body) > $truncsize) {
+ $message->body = self::truncate($message->body, $truncsize);
+ $message->bodytruncated = 1;
+ } else {
+ // Be certain this is set.
+ $message->bodytruncated = 0;
+ }
+
+ return $message;
}
/**
}
/**
- * Decodes a wbxml string into this object's properties.
- *
- * @param string $wbxml
- */
- public function decode($wbxml)
- {
- throw new Horde_ActiveSync_Exception('Not implemented.');
- }
-
- /**
- * Encodes this message object into a wbxml string.
- *
- * @return string wbxml string
- */
- public function encode()
- {
- throw new Horde_ActiveSync_Exception('Not Implemented.');
- }
-
- /**
* Encodes this object (and any sub-objects) as wbxml to the output stream.
* Output is ordered according to $_mapping
*