1 | <?php |
---|
2 | /*********************************************** |
---|
3 | * File : istatemachine.php |
---|
4 | * Project : Z-Push |
---|
5 | * Descr : Interface called from the Device and |
---|
6 | * StateManager to save states for a user/device/folder. |
---|
7 | * Z-Push implements the FileStateMachine which |
---|
8 | * saves states to disk. |
---|
9 | * Backends provide their own IStateMachine |
---|
10 | implementation of this interface and return |
---|
11 | * an IStateMachine instance with IBackend->GetStateMachine(). |
---|
12 | * Old sync states are not deleted until a new sync state |
---|
13 | * is requested. |
---|
14 | * At that moment, the PIM is apparently requesting an update |
---|
15 | * since sync key X, so any sync states before X are already on |
---|
16 | * the PIM, and can therefore be removed. This algorithm should be |
---|
17 | * automatically enforced by the IStateMachine implementation. |
---|
18 | * |
---|
19 | * Created : 02.01.2012 |
---|
20 | * |
---|
21 | * Copyright 2007 - 2012 Zarafa Deutschland GmbH |
---|
22 | * |
---|
23 | * This program is free software: you can redistribute it and/or modify |
---|
24 | * it under the terms of the GNU Affero General Public License, version 3, |
---|
25 | * as published by the Free Software Foundation with the following additional |
---|
26 | * term according to sec. 7: |
---|
27 | * |
---|
28 | * According to sec. 7 of the GNU Affero General Public License, version 3, |
---|
29 | * the terms of the AGPL are supplemented with the following terms: |
---|
30 | * |
---|
31 | * "Zarafa" is a registered trademark of Zarafa B.V. |
---|
32 | * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH |
---|
33 | * The licensing of the Program under the AGPL does not imply a trademark license. |
---|
34 | * Therefore any rights, title and interest in our trademarks remain entirely with us. |
---|
35 | * |
---|
36 | * However, if you propagate an unmodified version of the Program you are |
---|
37 | * allowed to use the term "Z-Push" to indicate that you distribute the Program. |
---|
38 | * Furthermore you may use our trademarks where it is necessary to indicate |
---|
39 | * the intended purpose of a product or service provided you use it in accordance |
---|
40 | * with honest practices in industrial or commercial matters. |
---|
41 | * If you want to propagate modified versions of the Program under the name "Z-Push", |
---|
42 | * you may only do so if you have a written permission by Zarafa Deutschland GmbH |
---|
43 | * (to acquire a permission please contact Zarafa at trademark@zarafa.com). |
---|
44 | * |
---|
45 | * This program is distributed in the hope that it will be useful, |
---|
46 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
47 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
48 | * GNU Affero General Public License for more details. |
---|
49 | * |
---|
50 | * You should have received a copy of the GNU Affero General Public License |
---|
51 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
52 | * |
---|
53 | * Consult LICENSE file for details |
---|
54 | ************************************************/ |
---|
55 | |
---|
56 | interface IStateMachine { |
---|
57 | const DEFTYPE = ""; |
---|
58 | const DEVICEDATA = "devicedata"; |
---|
59 | const FOLDERDATA = "fd"; |
---|
60 | const FAILSAVE = "fs"; |
---|
61 | const HIERARCHY = "hc"; |
---|
62 | const BACKENDSTORAGE = "bs"; |
---|
63 | |
---|
64 | /** |
---|
65 | * Constructor |
---|
66 | * @throws FatalMisconfigurationException |
---|
67 | */ |
---|
68 | |
---|
69 | /** |
---|
70 | * Gets a hash value indicating the latest dataset of the named |
---|
71 | * state with a specified key and counter. |
---|
72 | * If the state is changed between two calls of this method |
---|
73 | * the returned hash should be different |
---|
74 | * |
---|
75 | * @param string $devid the device id |
---|
76 | * @param string $type the state type |
---|
77 | * @param string $key (opt) |
---|
78 | * @param string $counter (opt) |
---|
79 | * |
---|
80 | * @access public |
---|
81 | * @return string |
---|
82 | * @throws StateNotFoundException, StateInvalidException |
---|
83 | */ |
---|
84 | public function GetStateHash($devid, $type, $key = false, $counter = false); |
---|
85 | |
---|
86 | /** |
---|
87 | * Gets a state for a specified key and counter. |
---|
88 | * This method sould call IStateMachine->CleanStates() |
---|
89 | * to remove older states (same key, previous counters) |
---|
90 | * |
---|
91 | * @param string $devid the device id |
---|
92 | * @param string $type the state type |
---|
93 | * @param string $key (opt) |
---|
94 | * @param string $counter (opt) |
---|
95 | * @param string $cleanstates (opt) |
---|
96 | * |
---|
97 | * @access public |
---|
98 | * @return mixed |
---|
99 | * @throws StateNotFoundException, StateInvalidException |
---|
100 | */ |
---|
101 | public function GetState($devid, $type, $key = false, $counter = false, $cleanstates = true); |
---|
102 | |
---|
103 | /** |
---|
104 | * Writes ta state to for a key and counter |
---|
105 | * |
---|
106 | * @param mixed $state |
---|
107 | * @param string $devid the device id |
---|
108 | * @param string $type the state type |
---|
109 | * @param string $key (opt) |
---|
110 | * @param int $counter (opt) |
---|
111 | * |
---|
112 | * @access public |
---|
113 | * @return boolean |
---|
114 | * @throws StateInvalidException |
---|
115 | */ |
---|
116 | public function SetState($state, $devid, $type, $key = false, $counter = false); |
---|
117 | |
---|
118 | /** |
---|
119 | * Cleans up all older states |
---|
120 | * If called with a $counter, all states previous state counter can be removed |
---|
121 | * If called without $counter, all keys (independently from the counter) can be removed |
---|
122 | * |
---|
123 | * @param string $devid the device id |
---|
124 | * @param string $type the state type |
---|
125 | * @param string $key |
---|
126 | * @param string $counter (opt) |
---|
127 | * |
---|
128 | * @access public |
---|
129 | * @return |
---|
130 | * @throws StateInvalidException |
---|
131 | */ |
---|
132 | public function CleanStates($devid, $type, $key, $counter = false); |
---|
133 | |
---|
134 | /** |
---|
135 | * Links a user to a device |
---|
136 | * |
---|
137 | * @param string $username |
---|
138 | * @param string $devid |
---|
139 | * |
---|
140 | * @access public |
---|
141 | * @return array |
---|
142 | */ |
---|
143 | public function LinkUserDevice($username, $devid); |
---|
144 | |
---|
145 | /** |
---|
146 | * Unlinks a device from a user |
---|
147 | * |
---|
148 | * @param string $username |
---|
149 | * @param string $devid |
---|
150 | * |
---|
151 | * @access public |
---|
152 | * @return array |
---|
153 | */ |
---|
154 | public function UnLinkUserDevice($username, $devid); |
---|
155 | |
---|
156 | /** |
---|
157 | * Returns an array with all device ids for a user. |
---|
158 | * If no user is set, all device ids should be returned |
---|
159 | * |
---|
160 | * @param string $username (opt) |
---|
161 | * |
---|
162 | * @access public |
---|
163 | * @return array |
---|
164 | */ |
---|
165 | public function GetAllDevices($username = false); |
---|
166 | } |
---|
167 | |
---|
168 | ?> |
---|