Commit 7f7170fd authored by skummer's avatar skummer

ZP-160

- fixed: check mapi_last_result() when advising store
- added: advise main store after initializing the sink so we know if the connection supports the sink
- changed: refactored store advising

git-svn-id: https://z-push.org/svn/z-push/trunk@1365 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent bbc75182
......@@ -900,13 +900,15 @@ class BackendZarafa implements IBackend, ISearchProvider {
$this->changesSink = @mapi_sink_create();
if (! $this->changesSink) {
ZLog::Write(LOGLEVEL_DEBUG, "ZarafaBackend->HasChangesSink(): sink could not be created");
if (! $this->changesSink || mapi_last_hresult()) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->HasChangesSink(): sink could not be created with 0x%X", mapi_last_hresult()));
return false;
}
ZLog::Write(LOGLEVEL_DEBUG, "ZarafaBackend->HasChangesSink(): created");
return true;
// advise the main store and also to check if the connection supports it
return $this->adviseStoreToSink($this->defaultstore);
}
/**
......@@ -929,13 +931,8 @@ class BackendZarafa implements IBackend, ISearchProvider {
// add entryid to the monitored folders
$this->changesSinkFolders[$entryid] = $folderid;
// check if this store is already monitored, else advise it
if (!in_array($this->store, $this->changesSinkStores)) {
mapi_msgstore_advise($this->store, null, fnevObjectModified | fnevObjectCreated | fnevObjectMoved | fnevObjectDeleted, $this->changesSink);
$this->changesSinkStores[] = $this->store;
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->ChangesSinkInitialize(): advised store '%s'", $this->store));
}
return true;
// advise the current store to the sink
return $this->adviseStoreToSink($this->store);
}
/**
......@@ -1237,6 +1234,30 @@ class BackendZarafa implements IBackend, ISearchProvider {
* Private methods
*/
/**
* Advises a store to the changes sink
*
* @param mapistore $store store to be advised
*
* @access private
* @return boolean
*/
private function adviseStoreToSink($store) {
// check if we already advised the store
if (!in_array($store, $this->changesSinkStores)) {
mapi_msgstore_advise($this->store, null, fnevObjectModified | fnevObjectCreated | fnevObjectMoved | fnevObjectDeleted, $this->changesSink);
$this->changesSinkStores[] = $store;
if (mapi_last_hresult()) {
ZLog::Write(LOGLEVEL_WARN, sprintf("ZarafaBackend->adviseStoreToSink(): failed to advised store '%s' with code 0x%X. Polling will be performed.", $this->store, mapi_last_hresult()));
return false;
}
else
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->adviseStoreToSink(): advised store '%s'", $this->store));
}
return true;
}
/**
* Open the store marked with PR_DEFAULT_STORE = TRUE
* if $return_public is set, the public store is opened
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment