$sync->init($this->_state, null, $collection);
} catch (Horde_ActiveSync_Exception $e) {
/* Stop ping if exporter cannot be configured */
- $this->_logger->err('Ping error: Exporter can not be configured. Waiting 30 seconds before ping is retried.');
+ $this->_logger->err('Ping error: Exporter can not be configured. ' . $e->getMessage() . ' Waiting 30 seconds before ping is retried.');
sleep(30);
break;
}
/**
* Const'r
*
- * @param array $params Must contain 'stateDir' entry
+ * @param array $params Must contain 'directory' entry
*
* @return Horde_ActiveSync_StateMachine_File
*/
{
parent::__construct($params);
- if (empty($this->_params['stateDir'])) {
+ if (empty($this->_params['directory'])) {
throw new InvalidArgumentException('Missing required "stateDir" parameter.');
}
- $this->_stateDir = $this->_params['stateDir'];
+ $this->_stateDir = $this->_params['directory'];
}
/**
*/
protected $_db;
- /* TODO - config these */
- protected $_syncStateTable = 'horde_activesync_state';
- protected $_syncMapTable = 'horde_activesync_map';
- protected $_syncDeviceTable = 'horde_activesync_device';
+ /* Table names */
+ protected $_syncStateTable;
+ protected $_syncMapTable;
+ protected $_syncDeviceTable;
/**
* Const'r
throw new InvalidArgumentException('Missing or invalid Horde_Db parameter.');
}
- $this->_params = $params;
+ $this->_syncStateTable = $params['statetable'];
+ $this->_syncMapTable = $params['maptable'];
+ $this->_syncDeviceTable = $params['devicetable'];
$this->_db = $params['db'];
}
$unique_folders[Horde_ActiveSync::FOLDER_TYPE_CONTACT] = Horde_ActiveSync::FOLDER_TYPE_DUMMY;
}
/* Storage to SQL? */
-//
-// if (!file_put_contents($this->_stateDir . '/compat-' . $devId, serialize($unique_folders))) {
-// $this->logError('_saveFolderData: Data could not be saved!');
-// throw new Horde_ActiveSync_Exception('Folder data could not be saved');
-// }
}
/**
}
/* Need to get the last sync time for this collection */
- return $this->_pingState['collections'];
+ return !empty($this->_pingState['collections']);
}
/**
$this->_deviceInfo->userAgent = '';
$this->_deviceInfo->id = $devId;
$this->setDeviceInfo($devId, $this->_deviceInfo);
+ $this->resetPingState();
}
return $this->_deviceInfo;
->method('contacts_getActionTimestamp')
->will($this->returnValue($fixture['contacts_getActionTimestamp']));
- $state = new Horde_ActiveSync_State_File(array('stateDir' => './'));
+ $state = new Horde_ActiveSync_State_File(array('directory' => './'));
$driver = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
'state_basic' => $state));
/* ...and check that it contains the serialized state data
* by reading it into a new object and performing another diff */
- $newstate = new Horde_ActiveSync_State_File(array('stateDir' => './'));
+ $newstate = new Horde_ActiveSync_State_File(array('directory' => './'));
$newstate->init(array('id' => 'Contacts',
'class' => 'Contacts'));
$newstate->setBackend($driver);
--- /dev/null
+a:1:{i:0;a:3:{s:2:"id";s:52:"20070112030611.62g1lg5nry80@test.theupstairsroom.com";s:3:"mod";i:0;s:5:"flags";i:1;}}
\ No newline at end of file
<case name="true" desc="Enabled">
<configsection name="state">
<configheader>State Storage Settings</configheader>
- <configstring name="directory" desc="Directory to hold state files (this
- directory should be writeable by the webserver):">/tmp</configstring>
+ <configswitch name="driver" desc="Choose the state driver to use.">history
+ <case name="history" desc="Native Horde history driver">
+ <configsection name="params">
+ <configstring name="devicetable" desc="Name of table to hold device
+ information:">horde_activesync_device</configstring>
+ <configstring name="statetable" desc="Name of table to hold state
+ data:">horde_activesync_state</configstring>
+ <configstring name="maptable" desc="Name of table to hold mapping data
+ for device-sent changes.">horde_activesync_map</configstring>
+ </configsection>
+ </case>
+ <case name="file" desc="Generic file based driver">
+ <configsection name="params">
+ <configstring name="directory" desc="Directory to hold state files (this
+ directory should be writeable by the webserver):">/tmp</configstring>
+ </configsection>
+ </case>
+ </configswitch>
</configsection>
<configheader>Logging</configheader>
<configsection name="logging">
/* Check if we are even enabled for AS */
if (!empty($GLOBALS['conf']['activesync']['enabled'])) {
$request = new Horde_Controller_Request_Http(array('session_control' => $session_control));
- if ($conf['activesync']['logging']['type'] == 'custom') {
+ if ($GLOBALS['conf']['activesync']['logging']['type'] == 'custom') {
$params['logger'] = new Horde_Log_Logger(new Horde_Log_Handler_Stream(fopen($conf['activesync']['logging']['path'], 'a')));
} else {
$params['logger'] = $GLOBALS['injector']->getInstance('Horde_Log_Logger');
/* TODO: Probably want to bind a factory to injector for this? */
$params['registry'] = $GLOBALS['registry'];
$connector = new Horde_ActiveSync_Driver_Horde_Connector_Registry($params);
- $stateMachine = new Horde_ActiveSync_State_File(array('stateDir' => $GLOBALS['conf']['activesync']['state']['directory']));
+ switch ($GLOBALS['conf']['activesync']['state']['driver']) {
+ case 'file':
+ $stateMachine = new Horde_ActiveSync_State_File($GLOBALS['conf']['activesync']['state']['params']);
+ break;
+ case 'history':
+ $state_params = $GLOBALS['conf']['activesync']['state']['params'];
+ $state_params['db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base');
+ $stateMachine = new Horde_ActiveSync_State_History($state_params);
+ }
+
$driver_params = array('connector' => $connector,
'state_basic' => $stateMachine,
'mail' => $mailer,
'ping' => $GLOBALS['conf']['activesync']['ping']);
+
if ($params['provisioning'] = $GLOBALS['conf']['activesync']['securitypolicies']['provisioning']) {
$driver_params['policies'] = $GLOBALS['conf']['activesync']['securitypolicies'];
}