Back to index

d-push  2.0
backend.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   backend.php
00004 * Project   :   Z-Push
00005 * Descr     :   This is what C++ people
00006 *               (and PHP5) would call an
00007 *               abstract class. The
00008 *               backend module itself is
00009 *               responsible for converting any
00010 *               necessary types and formats.
00011 *
00012 *               If you wish to implement a new
00013 *               backend, all you need to do is
00014 *               to subclass the following class
00015 *               (or implement an IBackend)
00016 *               and place the subclassed file in
00017 *               the backend/yourBackend directory. You can
00018 *               then use your backend by
00019 *               specifying it in the config.php file
00020 *
00021 * Created   :   01.10.2007
00022 *
00023 * Copyright 2007 - 2011 Zarafa Deutschland GmbH
00024 *
00025 * This program is free software: you can redistribute it and/or modify
00026 * it under the terms of the GNU Affero General Public License, version 3,
00027 * as published by the Free Software Foundation with the following additional
00028 * term according to sec. 7:
00029 *
00030 * According to sec. 7 of the GNU Affero General Public License, version 3,
00031 * the terms of the AGPL are supplemented with the following terms:
00032 *
00033 * "Zarafa" is a registered trademark of Zarafa B.V.
00034 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00035 * The licensing of the Program under the AGPL does not imply a trademark license.
00036 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00037 *
00038 * However, if you propagate an unmodified version of the Program you are
00039 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00040 * Furthermore you may use our trademarks where it is necessary to indicate
00041 * the intended purpose of a product or service provided you use it in accordance
00042 * with honest practices in industrial or commercial matters.
00043 * If you want to propagate modified versions of the Program under the name "Z-Push",
00044 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00045 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00046 *
00047 * This program is distributed in the hope that it will be useful,
00048 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00049 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00050 * GNU Affero General Public License for more details.
00051 *
00052 * You should have received a copy of the GNU Affero General Public License
00053 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00054 *
00055 * Consult LICENSE file for details
00056 ************************************************/
00057 
00058 abstract class Backend implements IBackend {
00059     protected $permanentStorage;
00060     protected $stateStorage;
00061 
00067     public function Backend() {
00068     }
00069 
00077     public function GetStateMachine() {
00078         return false;
00079     }
00080 
00088     public function GetSearchProvider() {
00089         return new SearchProvider();
00090     }
00091 
00100     public function GetSupportedASVersion() {
00101         return ZPush::ASV_25;
00102     }
00103 
00104     /*********************************************************************
00105      * Methods to be implemented
00106      *
00107      * public function Logon($username, $domain, $password);
00108      * public function Setup($store, $checkACLonly = false, $folderid = false);
00109      * public function Logoff();
00110      * public function GetHierarchy();
00111      * public function GetImporter($folderid = false);
00112      * public function GetExporter($folderid = false);
00113      * public function SendMail($sm);
00114      * public function Fetch($folderid, $id, $contentparameters);
00115      * public function GetWasteBasket();
00116      * public function GetAttachmentData($attname);
00117      * public function MeetingResponse($requestid, $folderid, $response);
00118      *
00119      */
00120 
00133     public function EmptyFolder($folderid, $includeSubfolders = true) {
00134         return false;
00135     }
00136 
00144     public function HasChangesSink() {
00145         return false;
00146     }
00147 
00158      public function ChangesSinkInitialize($folderid) {
00159          return false;
00160      }
00161 
00173     public function ChangesSink($timeout = 30) {
00174         return array();
00175     }
00176 
00185     public function Settings($settings) {
00186         if ($settings instanceof SyncOOF || $settings instanceof SyncUserInformation)
00187             $settings->Status = SYNC_SETTINGSSTATUS_SUCCESS;
00188         return $settings;
00189     }
00190 
00191 
00218     protected function InitializePermanentStorage() {
00219         if (!isset($this->permanentStorage)) {
00220             try {
00221                 $this->permanentStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_PERMANENT);
00222             }
00223             catch (StateNotYetAvailableException $snyae) {
00224                 $this->permanentStorage = new StateObject();
00225             }
00226             catch(StateNotFoundException $snfe) {
00227                 $this->permanentStorage = new StateObject();
00228             }
00229         }
00230     }
00231 
00239     protected function InitializeStateStorage() {
00240         if (!isset($this->stateStorage)) {
00241             try {
00242                 $this->stateStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_STATE);
00243             }
00244             catch (StateNotYetAvailableException $snyae) {
00245                 $this->stateStorage = new StateObject();
00246             }
00247             catch(StateNotFoundException $snfe) {
00248                 $this->stateStorage = new StateObject();
00249             }
00250         }
00251     }
00252 
00261     protected function SaveStorages() {
00262         if (isset($this->permanentStorage)) {
00263             try {
00264                 ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->permanentStorage, StateManager::BACKENDSTORAGE_PERMANENT);
00265             }
00266             catch (StateNotYetAvailableException $snyae) { }
00267             catch(StateNotFoundException $snfe) { }
00268         }
00269         if (isset($this->stateStorage)) {
00270             try {
00271                 $this->storage_state = ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->stateStorage, StateManager::BACKENDSTORAGE_STATE);
00272             }
00273             catch (StateNotYetAvailableException $snyae) { }
00274             catch(StateNotFoundException $snfe) { }
00275         }
00276     }
00277 
00278 }
00279 ?>