You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

567 lines
11 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  9. * @author Maxence Lange <maxence@nextcloud.com>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OCP\Share;
  29. use OCP\Files\Cache\ICacheEntry;
  30. use OCP\Files\File;
  31. use OCP\Files\Folder;
  32. use OCP\Files\Node;
  33. use OCP\Files\NotFoundException;
  34. use OCP\Share\Exceptions\IllegalIDChangeException;
  35. /**
  36. * Interface IShare
  37. *
  38. * @since 9.0.0
  39. */
  40. interface IShare {
  41. /**
  42. * @since 17.0.0
  43. */
  44. public const TYPE_USER = 0;
  45. /**
  46. * @since 17.0.0
  47. */
  48. public const TYPE_GROUP = 1;
  49. /**
  50. * @internal
  51. * @since 18.0.0
  52. */
  53. public const TYPE_USERGROUP = 2;
  54. /**
  55. * @since 17.0.0
  56. */
  57. public const TYPE_LINK = 3;
  58. /**
  59. * @since 17.0.0
  60. */
  61. public const TYPE_EMAIL = 4;
  62. /**
  63. * ToDo Check if it is still in use otherwise remove it
  64. * @since 17.0.0
  65. */
  66. // public const TYPE_CONTACT = 5;
  67. /**
  68. * @since 17.0.0
  69. */
  70. public const TYPE_REMOTE = 6;
  71. /**
  72. * @since 17.0.0
  73. */
  74. public const TYPE_CIRCLE = 7;
  75. /**
  76. * @since 17.0.0
  77. */
  78. public const TYPE_GUEST = 8;
  79. /**
  80. * @since 17.0.0
  81. */
  82. public const TYPE_REMOTE_GROUP = 9;
  83. /**
  84. * @since 17.0.0
  85. */
  86. public const TYPE_ROOM = 10;
  87. /**
  88. * Internal type used by RoomShareProvider
  89. * @since 17.0.0
  90. */
  91. // const TYPE_USERROOM = 11;
  92. /**
  93. * @since 18.0.0
  94. */
  95. public const STATUS_PENDING = 0;
  96. /**
  97. * @since 18.0.0
  98. */
  99. public const STATUS_ACCEPTED = 1;
  100. /**
  101. * @since 18.0.0
  102. */
  103. public const STATUS_REJECTED = 2;
  104. /**
  105. * Set the internal id of the share
  106. * It is only allowed to set the internal id of a share once.
  107. * Attempts to override the internal id will result in an IllegalIDChangeException
  108. *
  109. * @param string $id
  110. * @return \OCP\Share\IShare
  111. * @throws IllegalIDChangeException
  112. * @throws \InvalidArgumentException
  113. * @since 9.1.0
  114. */
  115. public function setId($id);
  116. /**
  117. * Get the internal id of the share.
  118. *
  119. * @return string
  120. * @since 9.0.0
  121. */
  122. public function getId();
  123. /**
  124. * Get the full share id. This is the <providerid>:<internalid>.
  125. * The full id is unique in the system.
  126. *
  127. * @return string
  128. * @since 9.0.0
  129. * @throws \UnexpectedValueException If the fullId could not be constructed
  130. */
  131. public function getFullId();
  132. /**
  133. * Set the provider id of the share
  134. * It is only allowed to set the provider id of a share once.
  135. * Attempts to override the provider id will result in an IllegalIDChangeException
  136. *
  137. * @param string $id
  138. * @return \OCP\Share\IShare
  139. * @throws IllegalIDChangeException
  140. * @throws \InvalidArgumentException
  141. * @since 9.1.0
  142. */
  143. public function setProviderId($id);
  144. /**
  145. * Set the node of the file/folder that is shared
  146. *
  147. * @param Node $node
  148. * @return \OCP\Share\IShare The modified object
  149. * @since 9.0.0
  150. */
  151. public function setNode(Node $node);
  152. /**
  153. * Get the node of the file/folder that is shared
  154. *
  155. * @return File|Folder
  156. * @since 9.0.0
  157. * @throws NotFoundException
  158. */
  159. public function getNode();
  160. /**
  161. * Set file id for lazy evaluation of the node
  162. * @param int $fileId
  163. * @return \OCP\Share\IShare The modified object
  164. * @since 9.0.0
  165. */
  166. public function setNodeId($fileId);
  167. /**
  168. * Get the fileid of the node of this share
  169. * @return int
  170. * @since 9.0.0
  171. * @throws NotFoundException
  172. */
  173. public function getNodeId();
  174. /**
  175. * Set the type of node (file/folder)
  176. *
  177. * @param string $type
  178. * @return \OCP\Share\IShare The modified object
  179. * @since 9.0.0
  180. */
  181. public function setNodeType($type);
  182. /**
  183. * Get the type of node (file/folder)
  184. *
  185. * @return string
  186. * @since 9.0.0
  187. * @throws NotFoundException
  188. */
  189. public function getNodeType();
  190. /**
  191. * Set the shareType
  192. *
  193. * @param int $shareType
  194. * @return \OCP\Share\IShare The modified object
  195. * @since 9.0.0
  196. */
  197. public function setShareType($shareType);
  198. /**
  199. * Get the shareType
  200. *
  201. * @return int
  202. * @since 9.0.0
  203. */
  204. public function getShareType();
  205. /**
  206. * Set the receiver of this share.
  207. *
  208. * @param string $sharedWith
  209. * @return \OCP\Share\IShare The modified object
  210. * @since 9.0.0
  211. */
  212. public function setSharedWith($sharedWith);
  213. /**
  214. * Get the receiver of this share.
  215. *
  216. * @return string
  217. * @since 9.0.0
  218. */
  219. public function getSharedWith();
  220. /**
  221. * Set the display name of the receiver of this share.
  222. *
  223. * @param string $displayName
  224. * @return \OCP\Share\IShare The modified object
  225. * @since 14.0.0
  226. */
  227. public function setSharedWithDisplayName($displayName);
  228. /**
  229. * Get the display name of the receiver of this share.
  230. *
  231. * @return string
  232. * @since 14.0.0
  233. */
  234. public function getSharedWithDisplayName();
  235. /**
  236. * Set the avatar of the receiver of this share.
  237. *
  238. * @param string $src
  239. * @return \OCP\Share\IShare The modified object
  240. * @since 14.0.0
  241. */
  242. public function setSharedWithAvatar($src);
  243. /**
  244. * Get the avatar of the receiver of this share.
  245. *
  246. * @return string
  247. * @since 14.0.0
  248. */
  249. public function getSharedWithAvatar();
  250. /**
  251. * Set the permissions.
  252. * See \OCP\Constants::PERMISSION_*
  253. *
  254. * @param int $permissions
  255. * @return \OCP\Share\IShare The modified object
  256. * @since 9.0.0
  257. */
  258. public function setPermissions($permissions);
  259. /**
  260. * Get the share permissions
  261. * See \OCP\Constants::PERMISSION_*
  262. *
  263. * @return int
  264. * @since 9.0.0
  265. */
  266. public function getPermissions();
  267. /**
  268. * Set the accepted status
  269. * See self::STATUS_*
  270. *
  271. * @param int $status
  272. * @return IShare The modified object
  273. * @since 18.0.0
  274. */
  275. public function setStatus(int $status): IShare;
  276. /**
  277. * Get the accepted status
  278. * See self::STATUS_*
  279. *
  280. * @return int
  281. * @since 18.0.0
  282. */
  283. public function getStatus(): int;
  284. /**
  285. * Attach a note to a share
  286. *
  287. * @param string $note
  288. * @return \OCP\Share\IShare The modified object
  289. * @since 14.0.0
  290. */
  291. public function setNote($note);
  292. /**
  293. * Get note attached to a share
  294. *
  295. * @return string
  296. * @since 14.0.0
  297. */
  298. public function getNote();
  299. /**
  300. * Set the expiration date
  301. *
  302. * @param null|\DateTime $expireDate
  303. * @return \OCP\Share\IShare The modified object
  304. * @since 9.0.0
  305. */
  306. public function setExpirationDate($expireDate);
  307. /**
  308. * Get the expiration date
  309. *
  310. * @return \DateTime
  311. * @since 9.0.0
  312. */
  313. public function getExpirationDate();
  314. /**
  315. * Is the share expired ?
  316. *
  317. * @return boolean
  318. * @since 18.0.0
  319. */
  320. public function isExpired();
  321. /**
  322. * set a label for a share, some shares, e.g. public links can have a label
  323. *
  324. * @param string $label
  325. * @return \OCP\Share\IShare The modified object
  326. * @since 15.0.0
  327. */
  328. public function setLabel($label);
  329. /**
  330. * get label for the share, some shares, e.g. public links can have a label
  331. *
  332. * @return string
  333. * @since 15.0.0
  334. */
  335. public function getLabel();
  336. /**
  337. * Set the sharer of the path.
  338. *
  339. * @param string $sharedBy
  340. * @return \OCP\Share\IShare The modified object
  341. * @since 9.0.0
  342. */
  343. public function setSharedBy($sharedBy);
  344. /**
  345. * Get share sharer
  346. *
  347. * @return string
  348. * @since 9.0.0
  349. */
  350. public function getSharedBy();
  351. /**
  352. * Set the original share owner (who owns the path that is shared)
  353. *
  354. * @param string $shareOwner
  355. * @return \OCP\Share\IShare The modified object
  356. * @since 9.0.0
  357. */
  358. public function setShareOwner($shareOwner);
  359. /**
  360. * Get the original share owner (who owns the path that is shared)
  361. *
  362. * @return string
  363. * @since 9.0.0
  364. */
  365. public function getShareOwner();
  366. /**
  367. * Set the password for this share.
  368. * When the share is passed to the share manager to be created
  369. * or updated the password will be hashed.
  370. *
  371. * @param string $password
  372. * @return \OCP\Share\IShare The modified object
  373. * @since 9.0.0
  374. */
  375. public function setPassword($password);
  376. /**
  377. * Get the password of this share.
  378. * If this share is obtained via a shareprovider the password is
  379. * hashed.
  380. *
  381. * @return string
  382. * @since 9.0.0
  383. */
  384. public function getPassword();
  385. /**
  386. * Set if the recipient can start a conversation with the owner to get the
  387. * password using Nextcloud Talk.
  388. *
  389. * @param bool $sendPasswordByTalk
  390. * @return \OCP\Share\IShare The modified object
  391. * @since 14.0.0
  392. */
  393. public function setSendPasswordByTalk(bool $sendPasswordByTalk);
  394. /**
  395. * Get if the recipient can start a conversation with the owner to get the
  396. * password using Nextcloud Talk.
  397. * The returned value does not take into account other factors, like Talk
  398. * being enabled for the owner of the share or not; it just cover whether
  399. * the option is enabled for the share itself or not.
  400. *
  401. * @return bool
  402. * @since 14.0.0
  403. */
  404. public function getSendPasswordByTalk(): bool;
  405. /**
  406. * Set the public link token.
  407. *
  408. * @param string $token
  409. * @return \OCP\Share\IShare The modified object
  410. * @since 9.0.0
  411. */
  412. public function setToken($token);
  413. /**
  414. * Get the public link token.
  415. *
  416. * @return string
  417. * @since 9.0.0
  418. */
  419. public function getToken();
  420. /**
  421. * Set the target path of this share relative to the recipients user folder.
  422. *
  423. * @param string $target
  424. * @return \OCP\Share\IShare The modified object
  425. * @since 9.0.0
  426. */
  427. public function setTarget($target);
  428. /**
  429. * Get the target path of this share relative to the recipients user folder.
  430. *
  431. * @return string
  432. * @since 9.0.0
  433. */
  434. public function getTarget();
  435. /**
  436. * Set the time this share was created
  437. *
  438. * @param \DateTime $shareTime
  439. * @return \OCP\Share\IShare The modified object
  440. * @since 9.0.0
  441. */
  442. public function setShareTime(\DateTime $shareTime);
  443. /**
  444. * Get the timestamp this share was created
  445. *
  446. * @return \DateTime
  447. * @since 9.0.0
  448. */
  449. public function getShareTime();
  450. /**
  451. * Set if the recipient is informed by mail about the share.
  452. *
  453. * @param bool $mailSend
  454. * @return \OCP\Share\IShare The modified object
  455. * @since 9.0.0
  456. */
  457. public function setMailSend($mailSend);
  458. /**
  459. * Get if the recipient informed by mail about the share.
  460. *
  461. * @return bool
  462. * @since 9.0.0
  463. */
  464. public function getMailSend();
  465. /**
  466. * Set the cache entry for the shared node
  467. *
  468. * @param ICacheEntry $entry
  469. * @since 11.0.0
  470. */
  471. public function setNodeCacheEntry(ICacheEntry $entry);
  472. /**
  473. * Get the cache entry for the shared node
  474. *
  475. * @return null|ICacheEntry
  476. * @since 11.0.0
  477. */
  478. public function getNodeCacheEntry();
  479. /**
  480. * Sets a shares hide download state
  481. * This is mainly for public shares. It will signal that the share page should
  482. * hide download buttons etc.
  483. *
  484. * @param bool $hide
  485. * @return IShare
  486. * @since 15.0.0
  487. */
  488. public function setHideDownload(bool $hide): IShare;
  489. /**
  490. * Gets a shares hide download state
  491. * This is mainly for public shares. It will signal that the share page should
  492. * hide download buttons etc.
  493. *
  494. * @return bool
  495. * @since 15.0.0
  496. */
  497. public function getHideDownload(): bool;
  498. }