diff options
Diffstat (limited to 'lib/public')
34 files changed, 884 insertions, 148 deletions
diff --git a/lib/public/App.php b/lib/public/App.php index 29805df6ace..c731a5085f7 100644 --- a/lib/public/App.php +++ b/lib/public/App.php @@ -95,16 +95,6 @@ class App { } /** - * Check if the app is enabled, redirects to home if not - * @param string $app - * @return void - * @since 4.0.0 - * @deprecated 9.0.0 ownCloud core will handle disabled apps and redirects to valid URLs - */ - public static function checkAppEnabled( $app ) { - } - - /** * Get the last version of the app from appinfo/info.xml * @param string $app * @return string diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index b0d04500f35..6213227bfd1 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -28,6 +28,7 @@ namespace OCP\App; use OCP\IUser; +use OCP\IGroup; /** * Interface IAppManager @@ -158,4 +159,18 @@ interface IAppManager { * @since 9.0.0 */ public function getAlwaysEnabledApps(); + + /** + * @param \OCP\IGroup $group + * @return String[] + * @since 17.0.0 + */ + public function getEnabledAppsForGroup(IGroup $group): array; + + /** + * @param String $appId + * @return string[] + * @since 17.0.0 + */ + public function getAppRestriction(string $appId): array; } diff --git a/lib/public/AppFramework/AuthPublicShareController.php b/lib/public/AppFramework/AuthPublicShareController.php index ffd2bddd24b..37a8cedcd7e 100644 --- a/lib/public/AppFramework/AuthPublicShareController.php +++ b/lib/public/AppFramework/AuthPublicShareController.php @@ -185,6 +185,20 @@ abstract class AuthPublicShareController extends PublicShareController { $route = $params['_route']; unset($params['_route']); } + + // If the token doesn't match the rest of the arguments can't be trusted either + if (isset($params['token']) && $params['token'] !== $this->getToken()) { + $params = [ + 'token' => $this->getToken(), + ]; + } + + // We need a token + if (!isset($params['token'])) { + $params = [ + 'token' => $this->getToken(), + ]; + } } return new RedirectResponse($this->urlGenerator->linkToRoute($route, $params)); diff --git a/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php b/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php new file mode 100644 index 00000000000..8914295d615 --- /dev/null +++ b/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php @@ -0,0 +1,34 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Authentication\TwoFactorAuth; + +use OCP\AppFramework\Controller; + +/** + * @since 17.0.0 + */ +abstract class ALoginSetupController extends Controller { + +} diff --git a/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php b/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php new file mode 100644 index 00000000000..22d5c6d1447 --- /dev/null +++ b/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php @@ -0,0 +1,43 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Authentication\TwoFactorAuth; + +use OCP\IUser; + +/** + * @since 17.0.0 + */ +interface IActivatableAtLogin extends IProvider { + + /** + * @param IUser $user + * + * @return ILoginSetupProvider + * + * @since 17.0.0 + */ + public function getLoginSetup(IUser $user): ILoginSetupProvider; + +} diff --git a/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php new file mode 100644 index 00000000000..7815f60b66a --- /dev/null +++ b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php @@ -0,0 +1,41 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Authentication\TwoFactorAuth; + +use OCP\Template; + +/** + * @since 17.0.0 + */ +interface ILoginSetupProvider { + + /** + * @return Template + * + * @since 17.0.0 + */ + public function getBody(): Template; + +} diff --git a/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php index 9a005c9cd5d..eb6eb5ca9af 100644 --- a/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php +++ b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace OCP\Authentication\TwoFactorAuth; +use OCP\EventDispatcher\Event; use OCP\IUser; -use Symfony\Component\EventDispatcher\Event; /** * @since 15.0.0 @@ -42,6 +42,7 @@ class RegistryEvent extends Event { * @since 15.0.0 */ public function __construct(IProvider $provider, IUser $user) { + parent::__construct(); $this->provider = $provider; $this->user = $user; } diff --git a/lib/public/Comments/IComment.php b/lib/public/Comments/IComment.php index e364d42fe87..c7c846bbe9d 100644 --- a/lib/public/Comments/IComment.php +++ b/lib/public/Comments/IComment.php @@ -127,11 +127,12 @@ interface IComment { * MessageTooLongException shall be thrown. * * @param string $message + * @param int $maxLength * @return IComment * @throws MessageTooLongException - * @since 9.0.0 + * @since 9.0.0 - $maxLength added in 16.0.2 */ - public function setMessage($message); + public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH); /** * returns an array containing mentions that are included in the comment diff --git a/lib/public/EventDispatcher/Event.php b/lib/public/EventDispatcher/Event.php new file mode 100644 index 00000000000..7f8554d7a86 --- /dev/null +++ b/lib/public/EventDispatcher/Event.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\EventDispatcher; + +use Symfony\Component\EventDispatcher\GenericEvent; + +/** + * Base event class for the event dispatcher service + * + * Typically this class isn't instantiated directly but sub classed for specific + * event types + * + * @since 17.0.0 + */ +class Event extends GenericEvent { + +} diff --git a/lib/public/EventDispatcher/IEventDispatcher.php b/lib/public/EventDispatcher/IEventDispatcher.php new file mode 100644 index 00000000000..af4d5316a7b --- /dev/null +++ b/lib/public/EventDispatcher/IEventDispatcher.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\EventDispatcher; + +/** + * Event dispatcher service of Nextcloud + * + * @since 17.0.0 + */ +interface IEventDispatcher { + + /** + * @param string $eventName preferably the fully-qualified class name of the Event sub class + * @param callable $listener the object that is invoked when a matching event is dispatched + * @param int $priority + * + * @since 17.0.0 + */ + public function addListener(string $eventName, callable $listener, int $priority = 0): void; + + /** + * @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for + * @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container + * @param int $priority + * + * @since 17.0.0 + */ + public function addServiceListener(string $eventName, string $className, int $priority = 0): void; + + /** + * @param string $eventName + * @param Event $event + * + * @since 17.0.0 + */ + public function dispatch(string $eventName, Event $event): void; + +} diff --git a/lib/public/EventDispatcher/IEventListener.php b/lib/public/EventDispatcher/IEventListener.php new file mode 100644 index 00000000000..5ecf31abc4a --- /dev/null +++ b/lib/public/EventDispatcher/IEventListener.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\EventDispatcher; + +/** + * @since 17.0.0 + */ +interface IEventListener { + + /** + * @param Event $event + * + * @since 17.0.0 + */ + public function handle(Event $event): void; + +} diff --git a/lib/public/FullTextSearch/Model/ISearchRequest.php b/lib/public/FullTextSearch/Model/ISearchRequest.php index 073b4805f63..6874cf161b6 100644 --- a/lib/public/FullTextSearch/Model/ISearchRequest.php +++ b/lib/public/FullTextSearch/Model/ISearchRequest.php @@ -91,6 +91,28 @@ interface ISearchRequest { */ public function getSearch(): string; + /** + * Set the searched string. + * + * @param string $search + * + * @since 17.0.0 + * + * @return ISearchRequest + */ + public function setSearch(string $search): ISearchRequest; + + /** + * Extends the searched string. + * + * @since 17.0.0 + * + * @param string $search + * + * @return ISearchRequest + */ + public function addSearch(string $search): ISearchRequest; + /** * Get the value of an option (as string). @@ -322,5 +344,25 @@ interface ISearchRequest { public function getFields(): array; + + /** + * Add a MUST search on an extra field + * + * @param ISearchRequestSimpleQuery $query + * + * @return ISearchRequest + * @since 17.0.0 + */ + public function addSimpleQuery(ISearchRequestSimpleQuery $query): ISearchRequest; + + + /** + * Get the list of queries on extra field. + * + * @return ISearchRequestSimpleQuery[] + * @since 17.0.0 + */ + public function getSimpleQueries(): array; + } diff --git a/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php new file mode 100644 index 00000000000..fb390f8fff1 --- /dev/null +++ b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php @@ -0,0 +1,137 @@ +<?php +declare(strict_types=1); + + +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OCP\FullTextSearch\Model; + + +/** + * Interface ISearchRequestSimpleQuery + * + * Add a Query during a Search Request... + * - on a specific field, + * - using a specific value, + * - with a specific comparison + * + * @since 17.0.0 + * + * @package OCP\FullTextSearch\Model + */ +interface ISearchRequestSimpleQuery { + + + const COMPARE_TYPE_TEXT = 1; + const COMPARE_TYPE_KEYWORD = 2; + const COMPARE_TYPE_INT_EQ = 3; + const COMPARE_TYPE_INT_GTE = 4; + const COMPARE_TYPE_INT_GT = 5; + const COMPARE_TYPE_INT_LTE = 6; + const COMPARE_TYPE_INT_LT = 7; + const COMPARE_TYPE_BOOL = 8; + const COMPARE_TYPE_ARRAY = 9; + + + /** + * Get the compare type of the query + * + * @return int + * @since 17.0.0 + */ + public function getType(): int; + + + /** + * Get the field to apply query + * + * @return string + * @since 17.0.0 + */ + public function getField(): string; + + /** + * Set the field to apply query + * + * @param string $field + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function setField(string $field): ISearchRequestSimpleQuery; + + + /** + * Get the all values to compare + * + * @return array + * @since 17.0.0 + */ + public function getValues(): array; + + /** + * Add value to compare (string) + * + * @param string $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValue(string $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (int) + * + * @param int $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueInt(int $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (array) + * + * @param array $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueArray(array $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (bool) + * + * @param bool $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueBool(bool $value): ISearchRequestSimpleQuery; + +} + diff --git a/lib/public/Group/Backend/IGetDisplayNameBackend.php b/lib/public/Group/Backend/IGetDisplayNameBackend.php new file mode 100644 index 00000000000..69d1742a1e5 --- /dev/null +++ b/lib/public/Group/Backend/IGetDisplayNameBackend.php @@ -0,0 +1,36 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Group\Backend; + +/** + * @since 17.0.0 + */ +interface IGetDisplayNameBackend { + /** + * @since 17.0.0 + */ + public function getDisplayName(string $gid): string; + +} diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php index f7ca0697671..558c72291c5 100644 --- a/lib/public/IContainer.php +++ b/lib/public/IContainer.php @@ -61,11 +61,12 @@ interface IContainer { * Look up a service for a given name in the container. * * @param string $name + * @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example * @return mixed * @throws QueryException if the query could not be resolved * @since 6.0.0 */ - public function query($name); + public function query(string $name, bool $autoload = true); /** * A value is stored in the container with it's corresponding name diff --git a/lib/public/IServerContainer.php b/lib/public/IServerContainer.php index a3e494479b7..bcdb6e6c9f5 100644 --- a/lib/public/IServerContainer.php +++ b/lib/public/IServerContainer.php @@ -534,6 +534,7 @@ interface IServerContainer extends IContainer { /** * @return IContentSecurityPolicyManager * @since 9.0.0 + * @deprecated 17.0.0 Use the AddContentSecurityPolicyEvent */ public function getContentSecurityPolicyManager(); diff --git a/lib/public/LDAP/ILDAPProvider.php b/lib/public/LDAP/ILDAPProvider.php index 9e13fb7e796..586481d837e 100644 --- a/lib/public/LDAP/ILDAPProvider.php +++ b/lib/public/LDAP/ILDAPProvider.php @@ -151,7 +151,7 @@ interface ILDAPProvider { /** * Get the LDAP attribute name for the type of association betweeen users and groups * @param string $gid group id - * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber' + * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', '' * @throws \Exception if group id was not found in LDAP * @since 13.0.0 */ diff --git a/lib/public/Notification/AlreadyProcessedException.php b/lib/public/Notification/AlreadyProcessedException.php new file mode 100644 index 00000000000..0ccac25f0fb --- /dev/null +++ b/lib/public/Notification/AlreadyProcessedException.php @@ -0,0 +1,38 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Notification; + + +/** + * @since 17.0.0 + */ +class AlreadyProcessedException extends \RuntimeException { + + /** + * @since 17.0.0 + */ + public function __construct() { + parent::__construct('Notification is processed already'); + } + +} diff --git a/lib/public/Notification/IAction.php b/lib/public/Notification/IAction.php index 6f2b78e3a8d..718a61b2f39 100644 --- a/lib/public/Notification/IAction.php +++ b/lib/public/Notification/IAction.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -29,19 +30,41 @@ namespace OCP\Notification; * @since 9.0.0 */ interface IAction { + + /** + * @since 17.0.0 + */ + public const TYPE_GET = 'GET'; + /** + * @since 17.0.0 + */ + public const TYPE_POST = 'POST'; + /** + * @since 17.0.0 + */ + public const TYPE_PUT = 'PUT'; + /** + * @since 17.0.0 + */ + public const TYPE_DELETE = 'DELETE'; + /** + * @since 17.0.0 + */ + public const TYPE_WEB = 'WEB'; + /** * @param string $label * @return $this * @throws \InvalidArgumentException if the label is invalid * @since 9.0.0 */ - public function setLabel($label); + public function setLabel(string $label): IAction; /** * @return string * @since 9.0.0 */ - public function getLabel(); + public function getLabel(): string; /** * @param string $label @@ -49,27 +72,27 @@ interface IAction { * @throws \InvalidArgumentException if the label is invalid * @since 9.0.0 */ - public function setParsedLabel($label); + public function setParsedLabel(string $label): IAction; /** * @return string * @since 9.0.0 */ - public function getParsedLabel(); + public function getParsedLabel(): string; /** - * @param $primary bool + * @param bool $primary * @return $this * @throws \InvalidArgumentException if $primary is invalid * @since 9.0.0 */ - public function setPrimary($primary); + public function setPrimary(bool $primary): IAction; /** * @return bool * @since 9.0.0 */ - public function isPrimary(); + public function isPrimary(): bool; /** * @param string $link @@ -78,29 +101,29 @@ interface IAction { * @throws \InvalidArgumentException if the link is invalid * @since 9.0.0 */ - public function setLink($link, $requestType); + public function setLink(string $link, string $requestType): IAction; /** * @return string * @since 9.0.0 */ - public function getLink(); + public function getLink(): string; /** * @return string * @since 9.0.0 */ - public function getRequestType(); + public function getRequestType(): string; /** * @return bool * @since 9.0.0 */ - public function isValid(); + public function isValid(): bool; /** * @return bool * @since 9.0.0 */ - public function isValidParsed(); + public function isValidParsed(): bool; } diff --git a/lib/public/Notification/IApp.php b/lib/public/Notification/IApp.php index 8f7b9b3d013..58d2a1fa5b8 100644 --- a/lib/public/Notification/IApp.php +++ b/lib/public/Notification/IApp.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -34,18 +35,18 @@ interface IApp { * @throws \InvalidArgumentException When the notification is not valid * @since 9.0.0 */ - public function notify(INotification $notification); + public function notify(INotification $notification): void; /** * @param INotification $notification * @since 9.0.0 */ - public function markProcessed(INotification $notification); + public function markProcessed(INotification $notification): void; /** * @param INotification $notification * @return int * @since 9.0.0 */ - public function getCount(INotification $notification); + public function getCount(INotification $notification): int; } diff --git a/lib/public/Notification/IManager.php b/lib/public/Notification/IManager.php index 003e5f1bad1..af890594d4c 100644 --- a/lib/public/Notification/IManager.php +++ b/lib/public/Notification/IManager.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -30,48 +31,56 @@ namespace OCP\Notification; */ interface IManager extends IApp, INotifier { /** - * @param \Closure $service The service must implement IApp, otherwise a + * @param string $appClass The service must implement IApp, otherwise a * \InvalidArgumentException is thrown later - * @since 9.0.0 + * @since 17.0.0 */ - public function registerApp(\Closure $service); + public function registerApp(string $appClass): void; /** * @param \Closure $service The service must implement INotifier, otherwise a * \InvalidArgumentException is thrown later * @param \Closure $info An array with the keys 'id' and 'name' containing * the app id and the app name - * @since 9.0.0 + * @deprecated 17.0.0 use registerNotifierService instead. + * @since 8.2.0 - Parameter $info was added in 9.0.0 */ public function registerNotifier(\Closure $service, \Closure $info); /** - * @return array App ID => App Name + * @param string $notifierService The service must implement INotifier, otherwise a + * \InvalidArgumentException is thrown later + * @since 17.0.0 + */ + public function registerNotifierService(string $notifierService): void; + + /** + * @return INotifier[] * @since 9.0.0 */ - public function listNotifiers(); + public function getNotifiers(): array; /** * @return INotification * @since 9.0.0 */ - public function createNotification(); + public function createNotification(): INotification; /** * @return bool * @since 9.0.0 */ - public function hasNotifiers(); + public function hasNotifiers(): bool; /** * @param bool $preparingPushNotification * @since 14.0.0 */ - public function setPreparingPushNotification($preparingPushNotification); + public function setPreparingPushNotification(bool $preparingPushNotification): void; /** * @return bool * @since 14.0.0 */ - public function isPreparingPushNotification(); + public function isPreparingPushNotification(): bool; } diff --git a/lib/public/Notification/INotification.php b/lib/public/Notification/INotification.php index 29f2a0e7943..7261409e355 100644 --- a/lib/public/Notification/INotification.php +++ b/lib/public/Notification/INotification.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -36,13 +37,13 @@ interface INotification { * @throws \InvalidArgumentException if the app id is invalid * @since 9.0.0 */ - public function setApp($app); + public function setApp(string $app): INotification; /** * @return string * @since 9.0.0 */ - public function getApp(); + public function getApp(): string; /** * @param string $user @@ -50,13 +51,13 @@ interface INotification { * @throws \InvalidArgumentException if the user id is invalid * @since 9.0.0 */ - public function setUser($user); + public function setUser(string $user): INotification; /** * @return string * @since 9.0.0 */ - public function getUser(); + public function getUser(): string; /** * @param \DateTime $dateTime @@ -64,13 +65,13 @@ interface INotification { * @throws \InvalidArgumentException if the $dateTime is invalid * @since 9.0.0 */ - public function setDateTime(\DateTime $dateTime); + public function setDateTime(\DateTime $dateTime): INotification; /** * @return \DateTime * @since 9.0.0 */ - public function getDateTime(); + public function getDateTime(): \DateTime; /** * @param string $type @@ -79,19 +80,19 @@ interface INotification { * @throws \InvalidArgumentException if the object type or id is invalid * @since 9.0.0 */ - public function setObject($type, $id); + public function setObject(string $type, string $id): INotification; /** * @return string * @since 9.0.0 */ - public function getObjectType(); + public function getObjectType(): string; /** * @return string * @since 9.0.0 */ - public function getObjectId(); + public function getObjectId(): string; /** * @param string $subject @@ -100,19 +101,19 @@ interface INotification { * @throws \InvalidArgumentException if the subject or parameters are invalid * @since 9.0.0 */ - public function setSubject($subject, array $parameters = []); + public function setSubject(string $subject, array $parameters = []): INotification; /** * @return string * @since 9.0.0 */ - public function getSubject(); + public function getSubject(): string; /** - * @return string[] + * @return array * @since 9.0.0 */ - public function getSubjectParameters(); + public function getSubjectParameters(): array; /** * Set a parsed subject @@ -131,13 +132,13 @@ interface INotification { * @throws \InvalidArgumentException if the subject is invalid * @since 9.0.0 */ - public function setParsedSubject($subject); + public function setParsedSubject(string $subject): INotification; /** * @return string * @since 9.0.0 */ - public function getParsedSubject(); + public function getParsedSubject(): string; /** * Set a RichObjectString subject @@ -156,19 +157,19 @@ interface INotification { * @throws \InvalidArgumentException if the subject or parameters are invalid * @since 11.0.0 */ - public function setRichSubject($subject, array $parameters = []); + public function setRichSubject(string $subject, array $parameters = []): INotification; /** * @return string * @since 11.0.0 */ - public function getRichSubject(); + public function getRichSubject(): string; /** * @return array[] * @since 11.0.0 */ - public function getRichSubjectParameters(); + public function getRichSubjectParameters(): array; /** * @param string $message @@ -177,19 +178,19 @@ interface INotification { * @throws \InvalidArgumentException if the message or parameters are invalid * @since 9.0.0 */ - public function setMessage($message, array $parameters = []); + public function setMessage(string $message, array $parameters = []): INotification; /** * @return string * @since 9.0.0 */ - public function getMessage(); + public function getMessage(): string; /** - * @return string[] + * @return array * @since 9.0.0 */ - public function getMessageParameters(); + public function getMessageParameters(): array; /** * Set a parsed message @@ -208,13 +209,13 @@ interface INotification { * @throws \InvalidArgumentException if the message is invalid * @since 9.0.0 */ - public function setParsedMessage($message); + public function setParsedMessage(string $message): INotification; /** * @return string * @since 9.0.0 */ - public function getParsedMessage(); + public function getParsedMessage(): string; /** * Set a RichObjectString message @@ -233,19 +234,19 @@ interface INotification { * @throws \InvalidArgumentException if the message or parameters are invalid * @since 11.0.0 */ - public function setRichMessage($message, array $parameters = []); + public function setRichMessage(string $message, array $parameters = []): INotification; /** * @return string * @since 11.0.0 */ - public function getRichMessage(); + public function getRichMessage(): string; /** * @return array[] * @since 11.0.0 */ - public function getRichMessageParameters(); + public function getRichMessageParameters(): array; /** * @param string $link @@ -253,13 +254,13 @@ interface INotification { * @throws \InvalidArgumentException if the link is invalid * @since 9.0.0 */ - public function setLink($link); + public function setLink(string $link): INotification; /** * @return string * @since 9.0.0 */ - public function getLink(); + public function getLink(): string; /** * @param string $icon @@ -267,19 +268,19 @@ interface INotification { * @throws \InvalidArgumentException if the icon is invalid * @since 11.0.0 */ - public function setIcon($icon); + public function setIcon(string $icon): INotification; /** * @return string * @since 11.0.0 */ - public function getIcon(); + public function getIcon(): string; /** * @return IAction * @since 9.0.0 */ - public function createAction(); + public function createAction(): IAction; /** * @param IAction $action @@ -287,13 +288,13 @@ interface INotification { * @throws \InvalidArgumentException if the action is invalid * @since 9.0.0 */ - public function addAction(IAction $action); + public function addAction(IAction $action): INotification; /** * @return IAction[] * @since 9.0.0 */ - public function getActions(); + public function getActions(): array; /** * @param IAction $action @@ -301,23 +302,23 @@ interface INotification { * @throws \InvalidArgumentException if the action is invalid * @since 9.0.0 */ - public function addParsedAction(IAction $action); + public function addParsedAction(IAction $action): INotification; /** * @return IAction[] * @since 9.0.0 */ - public function getParsedActions(); + public function getParsedActions(): array; /** * @return bool * @since 9.0.0 */ - public function isValid(); + public function isValid(): bool; /** * @return bool * @since 9.0.0 */ - public function isValidParsed(); + public function isValidParsed(): bool; } diff --git a/lib/public/Notification/INotifier.php b/lib/public/Notification/INotifier.php index 5e2a47266ad..b730b1d8015 100644 --- a/lib/public/Notification/INotifier.php +++ b/lib/public/Notification/INotifier.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -29,12 +30,30 @@ namespace OCP\Notification; * @since 9.0.0 */ interface INotifier { + + /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string; + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string; + /** * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification * @return INotification * @throws \InvalidArgumentException When the notification was not prepared by a notifier + * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted * @since 9.0.0 */ - public function prepare(INotification $notification, $languageCode); + public function prepare(INotification $notification, string $languageCode): INotification; } diff --git a/lib/public/Preview/IProvider.php b/lib/public/Preview/IProvider.php index ca545d8eb76..5d62b3ce6d0 100644 --- a/lib/public/Preview/IProvider.php +++ b/lib/public/Preview/IProvider.php @@ -27,6 +27,7 @@ namespace OCP\Preview; * * @package OCP\Preview * @since 8.1.0 + * @deprecated 17.0.0 use IProviderV2 instead */ interface IProvider { /** diff --git a/lib/public/Preview/IProviderV2.php b/lib/public/Preview/IProviderV2.php new file mode 100644 index 00000000000..97fca21eaf5 --- /dev/null +++ b/lib/public/Preview/IProviderV2.php @@ -0,0 +1,57 @@ +<?php declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Preview; + +use OCP\Files\File; +use OCP\Files\FileInfo; +use OCP\IImage; + +/** + * @since 17.0.0 + */ +interface IProviderV2 { + /** + * @return string Regex with the mimetypes that are supported by this provider + * @since 17.0.0 + */ + public function getMimeType(): string; + + /** + * Check if a preview can be generated for $path + * + * @param FileInfo $file + * @return bool + * @since 17.0.0 + */ + public function isAvailable(FileInfo $file): bool; + + /** + * get thumbnail for file at path $path + * + * @param File $file + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @return null|\OCP\IImage null if no preview was generated + * @since 17.0.0 + */ + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; +} diff --git a/lib/public/Preview/IVersionedPreviewFile.php b/lib/public/Preview/IVersionedPreviewFile.php new file mode 100644 index 00000000000..e4da914da02 --- /dev/null +++ b/lib/public/Preview/IVersionedPreviewFile.php @@ -0,0 +1,39 @@ +<?php declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Preview; + +/** + * Marks files that should keep multiple preview "versions" for the same file id + * + * Examples of this are files where the storage backend provides versioning, for those + * files, we dont have fileids for the different versions but still need to be able to generate + * previews for all versions + * + * @since 17.0.0 + */ +interface IVersionedPreviewFile { + /** + * @return string + * @since 17.0.0 + */ + public function getPreviewVersion(): string; +} diff --git a/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php b/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php new file mode 100644 index 00000000000..9bf1d57e77e --- /dev/null +++ b/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php @@ -0,0 +1,52 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Security\CSP; + +use OC\Security\CSP\ContentSecurityPolicyManager; +use OCP\AppFramework\Http\EmptyContentSecurityPolicy; +use OCP\EventDispatcher\Event; + +/** + * @since 17.0.0 + */ +class AddContentSecurityPolicyEvent extends Event { + + /** @var ContentSecurityPolicyManager */ + private $policyManager; + + /** + * @since 17.0.0 + */ + public function __construct(ContentSecurityPolicyManager $policyManager) { + $this->policyManager = $policyManager; + } + + /** + * @since 17.0.0 + */ + public function addPolicy(EmptyContentSecurityPolicy $csp): void { + $this->policyManager->addDefaultPolicy($csp); + } +} diff --git a/lib/public/Security/IContentSecurityPolicyManager.php b/lib/public/Security/IContentSecurityPolicyManager.php index ebd477f75aa..7e9c019fda7 100644 --- a/lib/public/Security/IContentSecurityPolicyManager.php +++ b/lib/public/Security/IContentSecurityPolicyManager.php @@ -28,6 +28,7 @@ use OCP\AppFramework\Http\EmptyContentSecurityPolicy; * * @package OCP\Security * @since 9.0.0 + * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy */ interface IContentSecurityPolicyManager { /** @@ -46,6 +47,7 @@ interface IContentSecurityPolicyManager { * * @param EmptyContentSecurityPolicy $policy * @since 9.0.0 + * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy */ public function addDefaultPolicy(EmptyContentSecurityPolicy $policy); } diff --git a/lib/public/Security/StringUtils.php b/lib/public/Security/StringUtils.php deleted file mode 100644 index 4ee1f47e836..00000000000 --- a/lib/public/Security/StringUtils.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -declare(strict_types=1); -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - - -namespace OCP\Security; - -/** - * Class StringUtils - * - * @package OCP\Security - * @since 8.0.0 - */ -class StringUtils { - /** - * Compares whether two strings are equal. To prevent guessing of the string - * length this is done by comparing two hashes against each other and afterwards - * a comparison of the real string to prevent against the unlikely chance of - * collisions. - * @param string $expected The expected value - * @param string $input The input to compare against - * @return bool True if the two strings are equal, otherwise false. - * @since 8.0.0 - * @deprecated 9.0.0 Use hash_equals - */ - public static function equals(string $expected, string $input): bool { - return hash_equals($expected, $input); - } -} diff --git a/lib/public/Settings/IManager.php b/lib/public/Settings/IManager.php index 52f12c3a8fb..c0a34f4403f 100644 --- a/lib/public/Settings/IManager.php +++ b/lib/public/Settings/IManager.php @@ -82,10 +82,11 @@ interface IManager { * returns a list of the admin settings * * @param string $section the section id for which to load the settings + * @param bool $subAdminOnly only return settings sub admins are supposed to see (since 17.0.0) * @return array array of IAdmin[] where key is the priority * @since 9.1.0 */ - public function getAdminSettings($section): array; + public function getAdminSettings($section, bool $subAdminOnly = false): array; /** * returns a list of the personal settings diff --git a/lib/public/Settings/ISubAdminSettings.php b/lib/public/Settings/ISubAdminSettings.php new file mode 100644 index 00000000000..3d047d2c872 --- /dev/null +++ b/lib/public/Settings/ISubAdminSettings.php @@ -0,0 +1,35 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\Settings; + +/** + * Tagging interface for settings that should be shown to sub admins + * + * @since 17.0.0 + */ +interface ISubAdminSettings extends ISettings { + +} diff --git a/lib/public/Support/Subscription/IRegistry.php b/lib/public/Support/Subscription/IRegistry.php index 7782f201f28..f13bff597d0 100644 --- a/lib/public/Support/Subscription/IRegistry.php +++ b/lib/public/Support/Subscription/IRegistry.php @@ -54,4 +54,11 @@ interface IRegistry { * @since 17.0.0 */ public function delegateHasValidSubscription(): bool; + + /** + * Indicates if the subscription has extended support + * + * @since 17.0.0 + */ + public function delegateHasExtendedSupport(): bool; } diff --git a/lib/public/Support/Subscription/ISubscription.php b/lib/public/Support/Subscription/ISubscription.php index fc53fe08da3..81333609119 100644 --- a/lib/public/Support/Subscription/ISubscription.php +++ b/lib/public/Support/Subscription/ISubscription.php @@ -34,4 +34,11 @@ interface ISubscription { * @since 17.0.0 */ public function hasValidSubscription(): bool; + + /** + * Indicates if the subscription has extended support + * + * @since 17.0.0 + */ + public function hasExtendedSupport(): bool; } diff --git a/lib/public/Util.php b/lib/public/Util.php index 3a33a10c620..7e9f6b2efbc 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -89,7 +89,19 @@ class Util { public static function getVersion() { return \OC_Util::getVersion(); } - + + /** + * @since 17.0.0 + */ + public static function hasExtendedSupport(): bool { + try { + /** @var \OCP\Support\Subscription\IRegistry */ + $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); + return $subscriptionRegistry->delegateHasExtendedSupport(); + } catch (AppFramework\QueryException $e) {} + return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false); + } + /** * Set current update channel * @param string $channel @@ -98,7 +110,7 @@ class Util { public static function setChannel($channel) { \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); } - + /** * Get current update channel * @return string @@ -361,22 +373,6 @@ class Util { } /** - * Check an ajax get/post call if the request token is valid. exit if not. - * @since 4.5.0 - * @deprecated 9.0.0 Use annotations based on the app framework. - */ - public static function callCheck() { - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { - header('Location: '.\OC::$WEBROOT); - exit(); - } - - if (!\OC::$server->getRequest()->passesCSRFCheck()) { - exit(); - } - } - - /** * Used to sanitize HTML * * This function is used to sanitize HTML and should be applied on any @@ -517,7 +513,7 @@ class Util { public static function needUpgrade() { if (!isset(self::$needUpgradeCache)) { self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); - } + } return self::$needUpgradeCache; } |