/** * 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; }
/** * The folder should be considered by the sink. * Folders which were not initialized should not result in a notification * of IBackend->ChangesSink(). * * @param string $folderid * * @access public * @return boolean false if entryid can not be found for that folder */ public function ChangesSinkInitialize($folderid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->ChangesSinkInitialize(): folderid '%s'", $folderid)); $entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid)); if (!$entryid) { return false; } // 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; }