IShare.php 12 KB

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