1
0

IShare.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Share;
  8. use OCP\Files\Cache\ICacheEntry;
  9. use OCP\Files\File;
  10. use OCP\Files\Folder;
  11. use OCP\Files\Node;
  12. use OCP\Files\NotFoundException;
  13. use OCP\Share\Exceptions\IllegalIDChangeException;
  14. /**
  15. * This interface allows to represent a share object.
  16. *
  17. * This interface must not be implemented in your application.
  18. *
  19. * @since 9.0.0
  20. */
  21. interface IShare {
  22. /**
  23. * @since 17.0.0
  24. */
  25. public const TYPE_USER = 0;
  26. /**
  27. * @since 17.0.0
  28. */
  29. public const TYPE_GROUP = 1;
  30. /**
  31. * @internal
  32. * @since 18.0.0
  33. */
  34. public const TYPE_USERGROUP = 2;
  35. /**
  36. * @since 17.0.0
  37. */
  38. public const TYPE_LINK = 3;
  39. /**
  40. * @since 17.0.0
  41. */
  42. public const TYPE_EMAIL = 4;
  43. /**
  44. * ToDo Check if it is still in use otherwise remove it
  45. * @since 17.0.0
  46. */
  47. // public const TYPE_CONTACT = 5;
  48. /**
  49. * @since 17.0.0
  50. */
  51. public const TYPE_REMOTE = 6;
  52. /**
  53. * @since 17.0.0
  54. */
  55. public const TYPE_CIRCLE = 7;
  56. /**
  57. * @since 17.0.0
  58. */
  59. public const TYPE_GUEST = 8;
  60. /**
  61. * @since 17.0.0
  62. */
  63. public const TYPE_REMOTE_GROUP = 9;
  64. /**
  65. * @since 17.0.0
  66. */
  67. public const TYPE_ROOM = 10;
  68. /**
  69. * Internal type used by RoomShareProvider
  70. * @since 17.0.0
  71. */
  72. // const TYPE_USERROOM = 11;
  73. /**
  74. * @since 21.0.0
  75. */
  76. public const TYPE_DECK = 12;
  77. /**
  78. * @internal
  79. * @since 21.0.0
  80. */
  81. public const TYPE_DECK_USER = 13;
  82. /**
  83. * @since 26.0.0
  84. */
  85. public const TYPE_SCIENCEMESH = 15;
  86. /**
  87. * @since 18.0.0
  88. */
  89. public const STATUS_PENDING = 0;
  90. /**
  91. * @since 18.0.0
  92. */
  93. public const STATUS_ACCEPTED = 1;
  94. /**
  95. * @since 18.0.0
  96. */
  97. public const STATUS_REJECTED = 2;
  98. /**
  99. * Set the internal id of the share
  100. * It is only allowed to set the internal id of a share once.
  101. * Attempts to override the internal id will result in an IllegalIDChangeException
  102. *
  103. * @param string $id
  104. * @return \OCP\Share\IShare
  105. * @throws IllegalIDChangeException
  106. * @throws \InvalidArgumentException
  107. * @since 9.1.0
  108. */
  109. public function setId($id);
  110. /**
  111. * Get the internal id of the share.
  112. *
  113. * @return string
  114. * @since 9.0.0
  115. */
  116. public function getId();
  117. /**
  118. * Get the full share id. This is the <providerid>:<internalid>.
  119. * The full id is unique in the system.
  120. *
  121. * @return string
  122. * @since 9.0.0
  123. * @throws \UnexpectedValueException If the fullId could not be constructed
  124. */
  125. public function getFullId();
  126. /**
  127. * Set the provider id of the share
  128. * It is only allowed to set the provider id of a share once.
  129. * Attempts to override the provider id will result in an IllegalIDChangeException
  130. *
  131. * @param string $id
  132. * @return \OCP\Share\IShare
  133. * @throws IllegalIDChangeException
  134. * @throws \InvalidArgumentException
  135. * @since 9.1.0
  136. */
  137. public function setProviderId($id);
  138. /**
  139. * Set the node of the file/folder that is shared
  140. *
  141. * @param Node $node
  142. * @return \OCP\Share\IShare The modified object
  143. * @since 9.0.0
  144. */
  145. public function setNode(Node $node);
  146. /**
  147. * Get the node of the file/folder that is shared
  148. *
  149. * @return File|Folder
  150. * @since 9.0.0
  151. * @throws NotFoundException
  152. */
  153. public function getNode();
  154. /**
  155. * Set file id for lazy evaluation of the node
  156. * @param int $fileId
  157. * @return \OCP\Share\IShare The modified object
  158. * @since 9.0.0
  159. */
  160. public function setNodeId($fileId);
  161. /**
  162. * Get the fileid of the node of this share
  163. * @return int
  164. * @since 9.0.0
  165. * @throws NotFoundException
  166. */
  167. public function getNodeId(): int;
  168. /**
  169. * Set the type of node (file/folder)
  170. *
  171. * @param string $type
  172. * @return \OCP\Share\IShare The modified object
  173. * @since 9.0.0
  174. */
  175. public function setNodeType($type);
  176. /**
  177. * Get the type of node (file/folder)
  178. *
  179. * @return string
  180. * @since 9.0.0
  181. * @throws NotFoundException
  182. */
  183. public function getNodeType();
  184. /**
  185. * Set the shareType
  186. *
  187. * @param int $shareType
  188. * @return \OCP\Share\IShare The modified object
  189. * @since 9.0.0
  190. */
  191. public function setShareType($shareType);
  192. /**
  193. * Get the shareType
  194. *
  195. * @return int
  196. * @since 9.0.0
  197. */
  198. public function getShareType();
  199. /**
  200. * Set the receiver of this share.
  201. *
  202. * @param string $sharedWith
  203. * @return \OCP\Share\IShare The modified object
  204. * @since 9.0.0
  205. */
  206. public function setSharedWith($sharedWith);
  207. /**
  208. * Get the receiver of this share.
  209. *
  210. * @return string
  211. * @since 9.0.0
  212. */
  213. public function getSharedWith();
  214. /**
  215. * Set the display name of the receiver of this share.
  216. *
  217. * @param string $displayName
  218. * @return \OCP\Share\IShare The modified object
  219. * @since 14.0.0
  220. */
  221. public function setSharedWithDisplayName($displayName);
  222. /**
  223. * Get the display name of the receiver of this share.
  224. *
  225. * @return string
  226. * @since 14.0.0
  227. */
  228. public function getSharedWithDisplayName();
  229. /**
  230. * Set the avatar of the receiver of this share.
  231. *
  232. * @param string $src
  233. * @return \OCP\Share\IShare The modified object
  234. * @since 14.0.0
  235. */
  236. public function setSharedWithAvatar($src);
  237. /**
  238. * Get the avatar of the receiver of this share.
  239. *
  240. * @return string
  241. * @since 14.0.0
  242. */
  243. public function getSharedWithAvatar();
  244. /**
  245. * Set the permissions.
  246. * See \OCP\Constants::PERMISSION_*
  247. *
  248. * @param int $permissions
  249. * @return IShare The modified object
  250. * @since 9.0.0
  251. */
  252. public function setPermissions($permissions);
  253. /**
  254. * Get the share permissions
  255. * See \OCP\Constants::PERMISSION_*
  256. *
  257. * @return int
  258. * @since 9.0.0
  259. */
  260. public function getPermissions();
  261. /**
  262. * Create share attributes object
  263. *
  264. * @since 25.0.0
  265. * @return IAttributes
  266. */
  267. public function newAttributes(): IAttributes;
  268. /**
  269. * Set share attributes
  270. *
  271. * @param ?IAttributes $attributes
  272. * @since 25.0.0
  273. * @return IShare The modified object
  274. */
  275. public function setAttributes(?IAttributes $attributes);
  276. /**
  277. * Get share attributes
  278. *
  279. * @since 25.0.0
  280. * @return ?IAttributes
  281. */
  282. public function getAttributes(): ?IAttributes;
  283. /**
  284. * Set the accepted status
  285. * See self::STATUS_*
  286. *
  287. * @param int $status
  288. * @return IShare The modified object
  289. * @since 18.0.0
  290. */
  291. public function setStatus(int $status): IShare;
  292. /**
  293. * Get the accepted status
  294. * See self::STATUS_*
  295. *
  296. * @return int
  297. * @since 18.0.0
  298. */
  299. public function getStatus(): int;
  300. /**
  301. * Attach a note to a share
  302. *
  303. * @param string $note
  304. * @return \OCP\Share\IShare The modified object
  305. * @since 14.0.0
  306. */
  307. public function setNote($note);
  308. /**
  309. * Get note attached to a share
  310. *
  311. * @return string
  312. * @since 14.0.0
  313. */
  314. public function getNote();
  315. /**
  316. * Set the expiration date
  317. *
  318. * @param \DateTime|null $expireDate
  319. * @return \OCP\Share\IShare The modified object
  320. * @since 9.0.0
  321. */
  322. public function setExpirationDate(?\DateTime $expireDate);
  323. /**
  324. * Get the expiration date
  325. *
  326. * @return \DateTime|null
  327. * @since 9.0.0
  328. */
  329. public function getExpirationDate();
  330. /**
  331. * Set overwrite flag for falsy expiry date vavlues
  332. *
  333. * @param bool $noExpirationDate
  334. * @return \OCP\Share\IShare The modified object
  335. * @since 30.0.0
  336. */
  337. public function setNoExpirationDate(bool $noExpirationDate);
  338. /**
  339. * Get value of overwrite falsy expiry date flag
  340. *
  341. * @return bool
  342. * @since 30.0.0
  343. */
  344. public function getNoExpirationDate();
  345. /**
  346. * Is the share expired ?
  347. *
  348. * @return boolean
  349. * @since 18.0.0
  350. */
  351. public function isExpired();
  352. /**
  353. * set a label for a share, some shares, e.g. public links can have a label
  354. *
  355. * @param string $label
  356. * @return \OCP\Share\IShare The modified object
  357. * @since 15.0.0
  358. */
  359. public function setLabel($label);
  360. /**
  361. * get label for the share, some shares, e.g. public links can have a label
  362. *
  363. * @return string
  364. * @since 15.0.0
  365. */
  366. public function getLabel();
  367. /**
  368. * Set the sharer of the path.
  369. *
  370. * @param string $sharedBy
  371. * @return \OCP\Share\IShare The modified object
  372. * @since 9.0.0
  373. */
  374. public function setSharedBy($sharedBy);
  375. /**
  376. * Get share sharer
  377. *
  378. * @return string
  379. * @since 9.0.0
  380. */
  381. public function getSharedBy();
  382. /**
  383. * Set the original share owner (who owns the path that is shared)
  384. *
  385. * @param string $shareOwner
  386. * @return \OCP\Share\IShare The modified object
  387. * @since 9.0.0
  388. */
  389. public function setShareOwner($shareOwner);
  390. /**
  391. * Get the original share owner (who owns the path that is shared)
  392. *
  393. * @return string
  394. * @since 9.0.0
  395. */
  396. public function getShareOwner();
  397. /**
  398. * Set the password for this share.
  399. * When the share is passed to the share manager to be created
  400. * or updated the password will be hashed.
  401. *
  402. * @param string|null $password
  403. * @return \OCP\Share\IShare The modified object
  404. * @since 9.0.0
  405. */
  406. public function setPassword($password);
  407. /**
  408. * Get the password of this share.
  409. * If this share is obtained via a shareprovider the password is
  410. * hashed.
  411. *
  412. * @return string|null
  413. * @since 9.0.0
  414. */
  415. public function getPassword();
  416. /**
  417. * Set the password's expiration time of this share.
  418. *
  419. * @return self The modified object
  420. * @since 24.0.0
  421. */
  422. public function setPasswordExpirationTime(?\DateTimeInterface $passwordExpirationTime = null): IShare;
  423. /**
  424. * Get the password's expiration time of this share.
  425. * @since 24.0.0
  426. */
  427. public function getPasswordExpirationTime(): ?\DateTimeInterface;
  428. /**
  429. * Set if the recipient can start a conversation with the owner to get the
  430. * password using Nextcloud Talk.
  431. *
  432. * @param bool $sendPasswordByTalk
  433. * @return \OCP\Share\IShare The modified object
  434. * @since 14.0.0
  435. */
  436. public function setSendPasswordByTalk(bool $sendPasswordByTalk);
  437. /**
  438. * Get if the recipient can start a conversation with the owner to get the
  439. * password using Nextcloud Talk.
  440. * The returned value does not take into account other factors, like Talk
  441. * being enabled for the owner of the share or not; it just cover whether
  442. * the option is enabled for the share itself or not.
  443. *
  444. * @return bool
  445. * @since 14.0.0
  446. */
  447. public function getSendPasswordByTalk(): bool;
  448. /**
  449. * Set the public link token.
  450. *
  451. * @param string $token
  452. * @return \OCP\Share\IShare The modified object
  453. * @since 9.0.0
  454. */
  455. public function setToken($token);
  456. /**
  457. * Get the public link token.
  458. *
  459. * @return string
  460. * @since 9.0.0
  461. */
  462. public function getToken();
  463. /**
  464. * Set the target path of this share relative to the recipients user folder.
  465. *
  466. * @param string $target
  467. * @return \OCP\Share\IShare The modified object
  468. * @since 9.0.0
  469. */
  470. public function setTarget($target);
  471. /**
  472. * Get the target path of this share relative to the recipients user folder.
  473. *
  474. * @return string
  475. * @since 9.0.0
  476. */
  477. public function getTarget();
  478. /**
  479. * Set the time this share was created
  480. *
  481. * @param \DateTime $shareTime
  482. * @return \OCP\Share\IShare The modified object
  483. * @since 9.0.0
  484. */
  485. public function setShareTime(\DateTime $shareTime);
  486. /**
  487. * Get the timestamp this share was created
  488. *
  489. * @return \DateTime
  490. * @since 9.0.0
  491. */
  492. public function getShareTime();
  493. /**
  494. * Set if the recipient should be informed by mail about the share.
  495. *
  496. * @param bool $mailSend
  497. * @return \OCP\Share\IShare The modified object
  498. * @since 9.0.0
  499. */
  500. public function setMailSend($mailSend);
  501. /**
  502. * Get if the recipient should be informed by mail about the share.
  503. *
  504. * @return bool
  505. * @since 9.0.0
  506. */
  507. public function getMailSend();
  508. /**
  509. * Set the cache entry for the shared node
  510. *
  511. * @param ICacheEntry $entry
  512. * @return void
  513. * @since 11.0.0
  514. */
  515. public function setNodeCacheEntry(ICacheEntry $entry);
  516. /**
  517. * Get the cache entry for the shared node
  518. *
  519. * @return null|ICacheEntry
  520. * @since 11.0.0
  521. */
  522. public function getNodeCacheEntry();
  523. /**
  524. * Sets a shares hide download state
  525. * This is mainly for public shares. It will signal that the share page should
  526. * hide download buttons etc.
  527. *
  528. * @param bool $hide
  529. * @return IShare
  530. * @since 15.0.0
  531. */
  532. public function setHideDownload(bool $hide): IShare;
  533. /**
  534. * Gets a shares hide download state
  535. * This is mainly for public shares. It will signal that the share page should
  536. * hide download buttons etc.
  537. *
  538. * @return bool
  539. * @since 15.0.0
  540. */
  541. public function getHideDownload(): bool;
  542. /**
  543. * Sets a flag that stores whether a reminder via email has been sent
  544. *
  545. * @return self The modified object
  546. * @since 31.0.0
  547. */
  548. public function setReminderSent(bool $reminderSent): IShare;
  549. /**
  550. * Gets a flag that stores whether a reminder via email has been sent
  551. *
  552. * @return bool
  553. * @since 31.0.0
  554. */
  555. public function getReminderSent(): bool;
  556. }