*/
public function getFolderList()
{
+ Horde::startBuffer();
+
$this->_logger->debug('Horde::getFolderList()');
/* Make sure we have the APIs needed for each folder class */
try {
$supported = $this->_connector->horde_listApis();
} catch (Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
$folders = array();
$folders[] = $this->statFolder(self::TASKS_FOLDER);
}
+ if ($errors = Horde::endBuffer()) {
+ $this->_logger->err('Unexpected output: ' . $errors);
+ }
+ $this->_endBuffer();
+
return $folders;
}
public function getMessageList($folderid, $cutoffdate)
{
$this->_logger->debug('Horde::getMessageList(' . $folderid . ', ' . $cutoffdate . ')');
-
+ Horde::startBuffer();
$messages = array();
+
switch ($folderid) {
case self::APPOINTMENTS_FOLDER:
$startstamp = (int)$cutoffdate;
$events = $this->_connector->calendar_listUids($startstamp, $endstamp);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
foreach ($events as $uid) {
$contacts = $this->_connector->contacts_listUids();
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
$tasks = $this->_connector->tasks_listUids();
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
foreach ($tasks as $task)
break;
default:
+ $this->_endBuffer();
return array();
}
+ $this->_endBuffer();
return $messages;
}
$this->_logger->debug("Horde_ActiveSync_Driver_Horde::getServerChanges($folderId, $from_ts, $to_ts, $cutoffdate)");
$adds = array();
+ Horde::startBuffer();
switch ($folderId) {
case self::APPOINTMENTS_FOLDER:
if ($from_ts == 0) {
$adds = $this->_connector->calendar_listUids($startstamp, $endstamp);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
$edits = $deletes = array();
$deletes = $changes['delete'];
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
}
$adds = $this->_connector->contacts_listUids();
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
$edits = $deletes = array();
$deletes = $this->_connector->contacts_listBy('delete', $from_ts, $to_ts);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
}
$adds = $this->_connector->tasks_listUids();
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
$edits = $deletes = array();
$deletes = $this->_connector->tasks_listBy('delete', $from_ts, $to_ts);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array();
}
}
$changes[] = array(
'id' => $change,
'type' => 'change');
-
}
/* Server Deletions */
'type' => 'delete');
}
+ $this->_endBuffer();
return $changes;
}
public function getMessage($folderid, $id, $truncsize, $mimesupport = 0)
{
$this->_logger->debug('Horde::getMessage(' . $folderid . ', ' . $id . ')');
-
+ Horde::startBuffer();
$message = false;
switch ($folderid) {
case self::APPOINTMENTS_FOLDER:
}
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
$message = $this->_connector->contacts_export($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
$message = $this->_connector->tasks_export($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
default:
+ $this->_endBuffer();
return false;
}
if (strlen($message->body) > $truncsize) {
$message->bodytruncated = 0;
}
+ $this->_endBuffer();
return $message;
}
public function deleteMessage($folderid, $id)
{
$this->_logger->debug('Horde::deleteMessage(' . $folderid . ', ' . $id . ')');
-
+ Horde::startBuffer();
$status = false;
switch ($folderid) {
case self::APPOINTMENTS_FOLDER:
$status = $this->_connector->calendar_delete($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
$status = $this->_connector->contacts_delete($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
$status = $this->_connector->tasks_delete($id);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
break;
default:
+ $this->_endBuffer();
return false;
}
+ $this->_endBuffer();
return $status;
}
public function changeMessage($folderid, $id, $message, $device)
{
$this->_logger->debug('Horde::changeMessage(' . $folderid . ', ' . $id . ')');
-
+ Horde::startBuffer();
$stat = false;
switch ($folderid) {
case self::APPOINTMENTS_FOLDER:
$id = $this->_connector->calendar_import($message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
- /* There is no history entry for new messages, so use the
- * current time for purposes of remembering this is from the PIM
- */
+ // There is no history entry for new messages, so use the
+ // current time for purposes of remembering this is from the PIM
$stat = $this->_smartStatMessage($folderid, $id, false);
$stat['mod'] = time();
} else {
$this->_connector->calendar_replace($id, $message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
$stat = $this->_smartStatMessage($folderid, $id, false);
$id = $this->_connector->contacts_import($message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
$stat = $this->_smartStatMessage($folderid, $id, false);
$this->_connector->contacts_replace($id, $message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
$stat = $this->_smartStatMessage($folderid, $id, false);
$id = $this->_connector->tasks_import($message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
$stat = $this->_smartStatMessage($folderid, $id, false);
$this->_connector->tasks_replace($id, $message);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return false;
}
$stat = $this->_smartStatMessage($folderid, $id, false);
}
-
break;
+
default:
+ $this->_endBuffer();
return false;
}
+ $this->_endBuffer();
return $stat;
}
*/
public function getSearchResults($query, $range)
{
- /* Get results */
$return = array('rows' => array(),
'range' => $range);
+
+ Horde::startBuffer();
try {
$results = $this->_connector->contacts_search($query);
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return $return;
}
);
}
+ $this->_endBuffer();
return $return;
}
*/
private function _smartStatMessage($folderid, $id, $hint)
{
+ Horde::startBuffer();
$this->_logger->debug('ActiveSync_Driver_Horde::_smartStatMessage:' . $folderid . ':' . $id);
$statKey = $folderid . $id;
$mod = false;
+
if ($hint !== false && isset($this->_modCache[$statKey])) {
$mod = $this->_modCache[$statKey];
} elseif (is_int($hint)) {
case self::APPOINTMENTS_FOLDER:
$mod = $this->_connector->calendar_getActionTimestamp($id, 'modify');
break;
+
case self::CONTACTS_FOLDER:
$mod = $this->_connector->contacts_getActionTimestamp($id, 'modify');
break;
+
case self::TASKS_FOLDER:
$mod = $this->_connector->tasks_getActionTimestamp($id, 'modify');
-
break;
+
default:
+ $this->_endBuffer();
return false;
}
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
+ $this->_endBuffer();
return array('id' => '', 'mod' => 0, 'flags' => 1);
}
$this->_modCache[$statKey] = $mod;
}
+
$message = array();
$message['id'] = $id;
$message['mod'] = $mod;
$message['flags'] = 1;
+ $this->_endBuffer();
return $message;
}
+ private function _endBuffer()
+ {
+ if ($output = Horde::endBuffer()) {
+ $this->_logger->err('Unexpected output: ' . $output);
+ }
+ }
+
}