summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-31 12:24:37 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-09-08 09:00:57 +0200
commit4e347170ac31462e447daaccf794000981a68f86 (patch)
treec8ec2acfbc2fcdc1de4a65c812179f8b7353f730 /lib/public
parentd044884cfa8d065c7d784dbc792a7228e0eed46f (diff)
downloadnextcloud-server-4e347170ac31462e447daaccf794000981a68f86.tar.gz
nextcloud-server-4e347170ac31462e447daaccf794000981a68f86.zip
Notification API
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/iservercontainer.php9
-rw-r--r--lib/public/notification/iaction.php96
-rw-r--r--lib/public/notification/iapp.php55
-rw-r--r--lib/public/notification/imanager.php52
-rw-r--r--lib/public/notification/inotification.php237
-rw-r--r--lib/public/notification/inotifier.php38
6 files changed, 486 insertions, 1 deletions
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index 81724cb4967..ea08b5a78ca 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -448,7 +448,6 @@ interface IServerContainer {
*/
public function getMimeTypeLoader();
-
/**
* Get the EventDispatcher
*
@@ -456,4 +455,12 @@ interface IServerContainer {
* @since 8.2.0
*/
public function getEventDispatcher();
+
+ /**
+ * Get the Notification Manager
+ *
+ * @return \OCP\Notification\IManager
+ * @since 8.2.0
+ */
+ public function getNotificationManager();
}
diff --git a/lib/public/notification/iaction.php b/lib/public/notification/iaction.php
new file mode 100644
index 00000000000..f0dfb024961
--- /dev/null
+++ b/lib/public/notification/iaction.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @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\Notification;
+
+/**
+ * Interface IAction
+ *
+ * @package OCP\Notification
+ * @since 8.2.0
+ */
+interface IAction {
+ /**
+ * @param string $label
+ * @return $this
+ * @throws \InvalidArgumentException if the label is invalid
+ * @since 8.2.0
+ */
+ public function setLabel($label);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getLabel();
+
+ /**
+ * @param string $label
+ * @return $this
+ * @throws \InvalidArgumentException if the label is invalid
+ * @since 8.2.0
+ */
+ public function setParsedLabel($label);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getParsedLabel();
+
+ /**
+ * @param string $link
+ * @return $this
+ * @throws \InvalidArgumentException if the link is invalid
+ * @since 8.2.0
+ */
+ public function setLink($link);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getLink();
+
+ /**
+ * @param string $icon
+ * @return $this
+ * @throws \InvalidArgumentException if the icon is invalid
+ * @since 8.2.0
+ */
+ public function setIcon($icon);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getIcon();
+
+ /**
+ * @return bool
+ */
+ public function isValid();
+
+ /**
+ * @return bool
+ */
+ public function isValidParsed();
+}
diff --git a/lib/public/notification/iapp.php b/lib/public/notification/iapp.php
new file mode 100644
index 00000000000..b154efab759
--- /dev/null
+++ b/lib/public/notification/iapp.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @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\Notification;
+
+/**
+ * Interface IApp
+ *
+ * @package OCP\Notification
+ * @since 8.2.0
+ */
+interface IApp {
+ /**
+ * @param INotification $notification
+ * @return null
+ * @throws \InvalidArgumentException When the notification is not valid
+ * @since 8.2.0
+ */
+ public function notify(INotification $notification);
+
+ /**
+ * @param string $objectType
+ * @param int $objectId
+ * @param string $user
+ * @return null
+ * @since 8.2.0
+ */
+ public function markProcessed($objectType, $objectId, $user = '');
+
+ /**
+ * @param string $user
+ * @param string $appId
+ * @return int
+ * @since 8.2.0
+ */
+ public function getCount($user, $appId = '');
+}
diff --git a/lib/public/notification/imanager.php b/lib/public/notification/imanager.php
new file mode 100644
index 00000000000..e68f19e71fd
--- /dev/null
+++ b/lib/public/notification/imanager.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @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\Notification;
+
+/**
+ * Interface IManager
+ *
+ * @package OCP\Notification
+ * @since 8.2.0
+ */
+interface IManager extends IApp, INotifier {
+ /**
+ * @param \Closure $service The service must implement IApp, otherwise a
+ * \InvalidArgumentException is thrown later
+ * @return null
+ * @since 8.2.0
+ */
+ public function registerApp(\Closure $service);
+
+ /**
+ * @param \Closure $service The service must implement INotifier, otherwise a
+ * \InvalidArgumentException is thrown later
+ * @return null
+ * @since 8.2.0
+ */
+ public function registerNotifier(\Closure $service);
+
+ /**
+ * @return INotification
+ * @since 8.2.0
+ */
+ public function createNotification();
+}
diff --git a/lib/public/notification/inotification.php b/lib/public/notification/inotification.php
new file mode 100644
index 00000000000..48204f733c1
--- /dev/null
+++ b/lib/public/notification/inotification.php
@@ -0,0 +1,237 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @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\Notification;
+
+/**
+ * Interface INotification
+ *
+ * @package OCP\Notification
+ * @since 8.2.0
+ */
+interface INotification {
+ /**
+ * @param string $app
+ * @return $this
+ * @throws \InvalidArgumentException if the app id are invalid
+ * @since 8.2.0
+ */
+ public function setApp($app);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getApp();
+
+ /**
+ * @param string $user
+ * @return $this
+ * @throws \InvalidArgumentException if the user id are invalid
+ * @since 8.2.0
+ */
+ public function setUser($user);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getUser();
+
+ /**
+ * @param int $timestamp
+ * @return $this
+ * @throws \InvalidArgumentException if the timestamp are invalid
+ * @since 8.2.0
+ */
+ public function setTimestamp($timestamp);
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getTimestamp();
+
+ /**
+ * @param string $type
+ * @param int $id
+ * @return $this
+ * @throws \InvalidArgumentException if the object type or id are invalid
+ * @since 8.2.0
+ */
+ public function setObject($type, $id);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectType();
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getObjectId();
+
+ /**
+ * @param string $subject
+ * @param array $parameters
+ * @return $this
+ * @throws \InvalidArgumentException if the subject or parameters are invalid
+ * @since 8.2.0
+ */
+ public function setSubject($subject, array $parameters = []);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getSubject();
+
+ /**
+ * @return string[]
+ * @since 8.2.0
+ */
+ public function getSubjectParameters();
+
+ /**
+ * @param string $subject
+ * @return $this
+ * @throws \InvalidArgumentException if the subject are invalid
+ * @since 8.2.0
+ */
+ public function setParsedSubject($subject);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getParsedSubject();
+
+ /**
+ * @param string $message
+ * @param array $parameters
+ * @return $this
+ * @throws \InvalidArgumentException if the message or parameters are invalid
+ * @since 8.2.0
+ */
+ public function setMessage($message, array $parameters = []);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getMessage();
+
+ /**
+ * @return string[]
+ * @since 8.2.0
+ */
+ public function getMessageParameters();
+
+ /**
+ * @param string $message
+ * @return $this
+ * @throws \InvalidArgumentException if the message are invalid
+ * @since 8.2.0
+ */
+ public function setParsedMessage($message);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getParsedMessage();
+
+ /**
+ * @param string $link
+ * @return $this
+ * @throws \InvalidArgumentException if the link are invalid
+ * @since 8.2.0
+ */
+ public function setLink($link);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getLink();
+
+ /**
+ * @param string $icon
+ * @return $this
+ * @throws \InvalidArgumentException if the icon are invalid
+ * @since 8.2.0
+ */
+ public function setIcon($icon);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getIcon();
+
+ /**
+ * @return IAction
+ * @since 8.2.0
+ */
+ public function createAction();
+
+ /**
+ * @param IAction $action
+ * @return $this
+ * @throws \InvalidArgumentException if the action are invalid
+ * @since 8.2.0
+ */
+ public function addAction(IAction $action);
+
+ /**
+ * @return IAction[]
+ * @since 8.2.0
+ */
+ public function getActions();
+
+ /**
+ * @param IAction $action
+ * @return $this
+ * @throws \InvalidArgumentException if the action are invalid
+ * @since 8.2.0
+ */
+ public function addParsedAction(IAction $action);
+
+ /**
+ * @return IAction[]
+ * @since 8.2.0
+ */
+ public function getParsedActions();
+
+ /**
+ * @return bool
+ * @since 8.2.0
+ */
+ public function isValid();
+
+ /**
+ * @return bool
+ * @since 8.2.0
+ */
+ public function isValidParsed();
+}
diff --git a/lib/public/notification/inotifier.php b/lib/public/notification/inotifier.php
new file mode 100644
index 00000000000..32628768ebc
--- /dev/null
+++ b/lib/public/notification/inotifier.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @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\Notification;
+
+/**
+ * Interface INotifier
+ *
+ * @package OCP\Notification
+ * @since 8.2.0
+ */
+interface INotifier {
+ /**
+ * @param INotification $notification
+ * @return INotification
+ * @throws \InvalidArgumentException When the notification was not prepared by a notifier
+ * @since 8.2.0
+ */
+ public function prepare(INotification $notification);
+}