|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * @copyright Copyright (c) 2022 Julius Härtl <[email protected]> |
| 7 | + * |
| 8 | + * @author Julius Härtl <[email protected]> |
| 9 | + * |
| 10 | + * @license GNU AGPL version 3 or any later version |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU Affero General Public License as |
| 14 | + * published by the Free Software Foundation, either version 3 of the |
| 15 | + * License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * This program is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU Affero General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU Affero General Public License |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * |
| 25 | + */ |
| 26 | + |
| 27 | +namespace OCP\Files\Lock; |
| 28 | + |
| 29 | +/** |
| 30 | + * @since 24.0.0 |
| 31 | + */ |
| 32 | +interface ILock { |
| 33 | + |
| 34 | + /** |
| 35 | + * User owned manual lock |
| 36 | + * |
| 37 | + * This lock type is initiated by a user manually through the web UI or clients |
| 38 | + * and will limit editing capabilities on the file to the lock owning user. |
| 39 | + * |
| 40 | + * @since 24.0.0 |
| 41 | + */ |
| 42 | + public const TYPE_USER = 0; |
| 43 | + |
| 44 | + /** |
| 45 | + * App owned lock |
| 46 | + * |
| 47 | + * This lock type is created by collaborative apps like Text or Office to avoid |
| 48 | + * outside changes through WevDAV or other apps. |
| 49 | + * @since 24.0.0 |
| 50 | + * |
| 51 | + */ |
| 52 | + public const TYPE_APP = 1; |
| 53 | + |
| 54 | + /** |
| 55 | + * Token owned lock |
| 56 | + * |
| 57 | + * This lock type will bind the ownership to the provided lock token. Any request |
| 58 | + * that aims to modify the file will be required to sent the token, the user |
| 59 | + * itself is not able to write to files without the token. This will allow |
| 60 | + * to limit the locking to an individual client. |
| 61 | + * |
| 62 | + * @since 24.0.0 |
| 63 | + */ |
| 64 | + public const TYPE_TOKEN = 2; |
| 65 | + |
| 66 | + /** |
| 67 | + * WebDAV Lock scope exclusive |
| 68 | + * |
| 69 | + * @since 24.0.0 |
| 70 | + */ |
| 71 | + public const LOCK_EXCLUSIVE = 1; |
| 72 | + |
| 73 | + /** |
| 74 | + * WebDAV Lock scope shared |
| 75 | + * |
| 76 | + * @since 24.0.0 |
| 77 | + */ |
| 78 | + public const LOCK_SHARED = 2; |
| 79 | + |
| 80 | + /** |
| 81 | + * Lock only the resource the lock is applied to |
| 82 | + * |
| 83 | + * @since 24.0.0 |
| 84 | + */ |
| 85 | + public const LOCK_DEPTH_ZERO = 0; |
| 86 | + |
| 87 | + /** |
| 88 | + * Lock app resources under the locked one with infinite depth |
| 89 | + * |
| 90 | + * @since 24.0.0 |
| 91 | + */ |
| 92 | + public const LOCK_DEPTH_INFINITE = -1; |
| 93 | + |
| 94 | + /** |
| 95 | + * Type of the lock |
| 96 | + * |
| 97 | + * @psalm-return ILock::TYPE_* |
| 98 | + * @since 24.0.0 |
| 99 | + */ |
| 100 | + public function getType(): int; |
| 101 | + |
| 102 | + /** |
| 103 | + * Owner that holds the lock |
| 104 | + * |
| 105 | + * Depending on the lock type this is: |
| 106 | + * - ILock::TYPE_USER: A user id |
| 107 | + * - ILock::TYPE_APP: An app id |
| 108 | + * - ILock::TYPE_TOKEN: A user id |
| 109 | + * |
| 110 | + * @since 24.0.0 |
| 111 | + */ |
| 112 | + public function getOwner(): string; |
| 113 | + |
| 114 | + /** |
| 115 | + * File id that the lock is holding |
| 116 | + * |
| 117 | + * @since 24.0.0 |
| 118 | + */ |
| 119 | + public function getFileId(): int; |
| 120 | + |
| 121 | + /** |
| 122 | + * Timeout of the lock in seconds starting from the created at time |
| 123 | + * |
| 124 | + * @since 24.0.0 |
| 125 | + */ |
| 126 | + public function getTimeout(): int; |
| 127 | + |
| 128 | + /** |
| 129 | + * Unix timestamp of the lock creation time |
| 130 | + * |
| 131 | + * @since 24.0.0 |
| 132 | + */ |
| 133 | + public function getCreatedAt(): int; |
| 134 | + |
| 135 | + /** |
| 136 | + * Token string as a unique identifier for the lock, usually a UUID |
| 137 | + * |
| 138 | + * @since 24.0.0 |
| 139 | + */ |
| 140 | + public function getToken(): string; |
| 141 | + |
| 142 | + /** |
| 143 | + * Lock depth to apply the lock to child resources |
| 144 | + * |
| 145 | + * @since 24.0.0 |
| 146 | + */ |
| 147 | + public function getDepth(): int; |
| 148 | + |
| 149 | + /** |
| 150 | + * WebDAV lock scope |
| 151 | + * |
| 152 | + * @since 24.0.0 |
| 153 | + * @psalm-return ILock::LOCK_EXCLUSIVE|ILock::LOCK_SHARED |
| 154 | + */ |
| 155 | + public function getScope(): int; |
| 156 | + |
| 157 | + /** |
| 158 | + * String representation of the lock to identify it through logging |
| 159 | + * |
| 160 | + * @since 24.0.0 |
| 161 | + */ |
| 162 | + public function __toString(): string; |
| 163 | +} |
0 commit comments