Synchronizing with a remote CardDAV server (#42, #138, #139)

+ Updated contacts sql shema (breaking changes)
+ Fixes
- Removed SabreDAV Server
- Removed Contacts Sharing (awhile, code refactoring)
This commit is contained in:
RainLoop Team 2014-04-26 01:50:17 +04:00
parent 54a4c2657a
commit d29f20789f
78 changed files with 2024 additions and 2317 deletions

View file

@ -719,85 +719,6 @@ class ServiceActions
));
}
public function HostDav()
{
try
{
\set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});
$oPersonalAddressBookProvider = $this->oActions->PersonalAddressBookProvider();
$oAuthBackend = null;
if ($this->Config()->Get('labs', 'sync_dav_digest_auth', false))
{
$oAuthBackend = new \RainLoop\SabreDAV\AuthDigest($oPersonalAddressBookProvider);
}
else
{
$oAuthBackend = new \RainLoop\SabreDAV\AuthBasic($oPersonalAddressBookProvider);
}
$oCarddavBackend = new \RainLoop\SabreDAV\CardDAV($oPersonalAddressBookProvider, $oAuthBackend);
$oPrincipalBackend = new \RainLoop\SabreDAV\Principal($oPersonalAddressBookProvider, $oAuthBackend);
$oPrincipalCollection = new \Sabre\DAVACL\PrincipalCollection($oPrincipalBackend);
$oPrincipalCollection->disableListing = true;
$oAddressBookRoot = new \Sabre\CardDAV\AddressBookRoot($oPrincipalBackend, $oCarddavBackend);
$aTree = array($oPrincipalCollection, $oAddressBookRoot);
$this->Plugins()->RunHook('filter.sabre-dav-tree', array(&$aTree));
$oServer = new \Sabre\DAV\Server($aTree);
$sBaseUri = '/';
if (false !== \strpos($this->oHttp->GetUrl(), '/index.php/dav/'))
{
$aPath = \trim($this->oHttp->GetPath(), '/\\ ');
$sBaseUri = (0 < \strlen($aPath) ? '/'.$aPath : '').'/index.php/dav/';
}
$this->Plugins()->RunHook('filter.sabre-dav-base-url', array(&$sBaseUri));
$oServer->setBaseUri($sBaseUri);
// Plugins
$oServer->addPlugin(new \Sabre\DAV\Auth\Plugin($oAuthBackend, 'RainLoop'));
$oServer->addPlugin(new \Sabre\CardDAV\Plugin());
$oServer->addPlugin(new \Sabre\DAVACL\Plugin());
$oServer->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
$oServer->addPlugin(new \RainLoop\SabreDAV\Logger($this->Logger()));
if ($this->Config()->Get('labs', 'sync_use_dav_browser', false))
{
$oServer->addPlugin(new \Sabre\DAV\Browser\Plugin());
}
$this->Plugins()->RunHook('filter.sabre-dav-before-exec', array(&$oServer));
$oServer->exec();
}
catch (\Exception $oException)
{
$this->Logger()->WriteException($oException);
}
}
/**
* @return string
*/
public function ServiceDav()
{
if ($this->oActions->Config()->Get('contacts', 'allow_sync', false))
{
$this->HostDav();
}
return '';
}
/**
* @return string
*/