*
* @return mixed The server message id or false
*/
- public function importMessageChange($id, $message)
+ public function importMessageChange($id, $message, $device)
{
/* do nothing if it is in a dummy folder */
if ($this->_folderId == Horde_ActiveSync::FOLDER_TYPE_DUMMY) {
}
/* Tell the backend about the change */
- $stat = $this->_backend->changeMessage($this->_folderId, $id, $message);
+ $stat = $this->_backend->changeMessage($this->_folderId, $id, $message, $device);
$stat['parent'] = $this->_folderId;
if (!is_array($stat)) {
return $stat;
abstract public function deleteMessage($folderid, $id);
/**
- * Change (i.e. add or edit) a message on the backend
+ * Add/Edit a message
*
- * @param string $folderId Folderid
- * @param string $id Message id (maybe reorder parameteres since this may be null)
- * @param Horde_ActiveSync_Message_Base $message
- *
- * @return a stat array of the new message
+ * @param string $folderid The server id for the folder the message belongs
+ * to.
+ * @param string $id The server's uid for the message if this is a
+ * change to an existing message.
+ * @param Horde_ActiveSync_Message_Base $message The activesync message
+ * @param stdClass $device The device information
*/
- abstract public function changeMessage($folderid, $id, $message);
+ abstract public function changeMessage($folderid, $id, $message, $device);
/**
* Any code needed to authenticate to backend as the actual user.
/**
* Add/Edit a message
*
- * @param string $folderid
- * @param string $id
- * @param Horde_ActiveSync_Message_Base $message
+ * @param string $folderid The server id for the folder the message belongs
+ * to.
+ * @param string $id The server's uid for the message if this is a
+ * change to an existing message.
+ * @param Horde_ActiveSync_Message_Base $message The activesync message
+ * @param stdClass $device The device information
*
* @see framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde_ActiveSync_Driver_Base#changeMessage($folderid, $id, $message)
*/
- public function changeMessage($folderid, $id, $message)
+ public function changeMessage($folderid, $id, $message, $device)
{
$this->_logger->debug('Horde::changeMessage(' . $folderid . ', ' . $id . ')');
// ActiveSync messages do NOT contain the serverUID value, put
// it in ourselves so we can have it during import/change.
$message->setServerUID($id);
+ if (!empty($device->supported[self::APPOINTMENTS_FOLDER])) {
+ $message->setSupported($device->supported[self::APPOINTMENTS_FOLDER]);
+ }
try {
$this->_connector->calendar_replace($id, $message);
} catch (Horde_Exception $e) {
$stat = $this->_smartStatMessage($folderid, $id, false);
$stat['mod'] = time();
} else {
+ if (!empty($device->supported[self::CONTACTS_FOLDER])) {
+ $message->setSupported($device->supported[self::CONTACTS_FOLDER]);
+ }
try {
$this->_connector->contacts_replace($id, $message);
} catch (Horde_Exception $e) {
$stat = $this->_smartStatMessage($folderid, $id, false);
$stat['mod'] = time();
} else {
+ if (!empty($device->supported[self::TASKS_FOLDER])) {
+ $message->setSupported($device->supported[self::TASKS_FOLDER]);
+ }
try {
$this->_connector->tasks_replace($id, $message);
} catch (Horde_Exception $e) {
protected $_logger;
/**
+ * An array describing the non-ghosted elements this message supports.
+ *
+ * @var array
+ */
+ protected $_supported = array();
+ protected $_exists = array();
+
+ /**
* Const'r
*
* @param array $mapping A mapping array from constants -> property names
throw new InvalidArgumentException('Unknown property: ' . $property);
}
$this->_properties[$property] = $value;
+ $this->_exists[$property] = true;
}
public function __call($method, $arg)
throw new BadMethodCallException('Unknown method: ' . $method . ' in class: ' . __CLASS__);
}
-
-
public function __isset($property)
{
return !empty($this->_properties[$property]);
}
/**
+ * Set the list of non-ghosted fields for this message.
+ *
+ * @param array $fields The array of fields.
+ */
+ public function setSupported($fields)
+ {
+ $this->_supported = array();
+ foreach ($fields as $field) {
+ $this->_supported[] = $this->_mapping[$field][self::KEY_ATTRIBUTE];
+ }
+ }
+
+ /**
+ * Get the list of non-ghosted properties for this message.
+ *
+ * @return array The array of non-ghosted properties
+ */
+ public function getSupported()
+ {
+ return $this->_supported;
+ }
+
+ public function isGhosted($property)
+ {
+ if (array_search($property, $this->_supported) !== false) {
+ return false;
+ } elseif (empty($this->_exists[$property])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Recursively decodes the WBXML from input stream. This means that if this
* message contains complex types (like Appointment.Recuurence for example)
* the sub-objects are auto-instantiated and decoded as well. Places the
exit;
}
while (1) {
- $el = $this->_decoder->getElementContent();
- $collection['supported'][] = $el;
+ $el = $this->_decoder->getElement();
if ($el[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_ENDTAG) {
break;
}
+ $collection['supported'][] = $el[2];
}
}
if (isset($appdata->read)) {
$importer->importMessageReadFlag($serverid, $appdata->read);
} else {
- $importer->importMessageChange($serverid, $appdata);
+ $importer->importMessageChange($serverid, $appdata, $device);
}
$collection['importedchanges'] = true;
}
break;
case Horde_ActiveSync::SYNC_ADD:
if (isset($appdata)) {
- $id = $importer->importMessageChange(false, $appdata);
+ $id = $importer->importMessageChange(false, $appdata, $device);
if ($clientid && $id) {
$collection['clientids'][$clientid] = $id;
$collection['importedchanges'] = true;
$data->rwstatus,
$devId,
$data->user,
- (!empty($data->supported) ? $data->supported : ''));
+ (!empty($data->supported) ? serialize($data->supported) : ''));
$this->_devId = $devId;