diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-02-18 18:31:33 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-02-18 18:31:33 +0100 |
commit | c6f4f85e27a10459422ab9789c894d13f0cd34c7 (patch) | |
tree | 6b4cf7a304242c5891952b428b3bca950924f309 /lib/public | |
parent | 9fac95c2ab46a734607657bbad6f164aaa61286f (diff) | |
parent | 8991e4505adba2dae8afe7b7941ec744bfe78712 (diff) | |
download | nextcloud-server-c6f4f85e27a10459422ab9789c894d13f0cd34c7.tar.gz nextcloud-server-c6f4f85e27a10459422ab9789c894d13f0cd34c7.zip |
Merge branch 'master' into scrutinizer_documentation_patches
Conflicts:
lib/private/migration/content.php
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/backgroundjob.php | 14 | ||||
-rw-r--r-- | lib/public/backgroundjob/ijob.php | 42 | ||||
-rw-r--r-- | lib/public/backgroundjob/ijoblist.php | 77 | ||||
-rw-r--r-- | lib/public/config.php | 4 | ||||
-rw-r--r-- | lib/public/iconfig.php | 4 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 7 |
6 files changed, 137 insertions, 11 deletions
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index dcf67da9570..bcd27c1d198 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -33,7 +33,7 @@ use \OC\BackgroundJob\JobList; /** * This class provides functions to register backgroundjobs in ownCloud * - * To create a new backgroundjob create a new class that inharits from either \OC\BackgroundJob\Job, + * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job, * \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using * \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function * of the job when the job is executed. @@ -73,7 +73,7 @@ class BackgroundJob { * @param mixed $argument */ public static function registerJob($job, $argument = null) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $jobList->add($job, $argument); } @@ -99,7 +99,7 @@ class BackgroundJob { * key is string "$klass-$method", value is array( $klass, $method ) */ static public function allRegularTasks() { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $regularJobs = array(); foreach ($allJobs as $job) { @@ -118,7 +118,7 @@ class BackgroundJob { * @return \OC\BackgroundJob\Job|null array */ public static function findQueuedTask($id) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); return $jobList->getById($id); } @@ -128,7 +128,7 @@ class BackgroundJob { * @return array with associative arrays */ public static function allQueuedTasks() { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $queuedJobs = array(); foreach ($allJobs as $job) { @@ -148,7 +148,7 @@ class BackgroundJob { * @return array with associative arrays */ public static function queuedTaskWhereAppIs($app) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $queuedJobs = array(); foreach ($allJobs as $job) { @@ -186,7 +186,7 @@ class BackgroundJob { * Deletes a report */ public static function deleteQueuedTask($id) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $job = $jobList->getById($id); if ($job) { $jobList->remove($job); diff --git a/lib/public/backgroundjob/ijob.php b/lib/public/backgroundjob/ijob.php new file mode 100644 index 00000000000..5231e9537a9 --- /dev/null +++ b/lib/public/backgroundjob/ijob.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\BackgroundJob; + +interface IJob { + /** + * Run the background job with the registered argument + * + * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job + * @param \OC\Log $logger + */ + public function execute($jobList, $logger = null); + + /** + * Get the id of the background job + * This id is determined by the job list when a job is added to the list + * + * @return int + */ + public function getId(); + + /** + * Get the last time this job was run as unix timestamp + * + * @return int + */ + public function getLastRun(); + + /** + * Get the argument associated with the background job + * This is the argument that will be passed to the background job + * + * @return mixed + */ + public function getArgument(); +} diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php new file mode 100644 index 00000000000..72f3fe863da --- /dev/null +++ b/lib/public/backgroundjob/ijoblist.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\BackgroundJob; + +interface IJobList { + /** + * Add a job to the list + * + * @param \OCP\BackgroundJob\IJob |string $job + * @param mixed $argument The argument to be passed to $job->run() when the job is exectured + */ + public function add($job, $argument = null); + + /** + * Remove a job from the list + * + * @param \OCP\BackgroundJob\IJob|string $job + * @param mixed $argument + */ + public function remove($job, $argument = null); + + /** + * check if a job is in the list + * + * @param $job + * @param mixed $argument + * @return bool + */ + public function has($job, $argument); + + /** + * get all jobs in the list + * + * @return \OCP\BackgroundJob\IJob[] + */ + public function getAll(); + + /** + * get the next job in the list + * + * @return \OCP\BackgroundJob\IJob + */ + public function getNext(); + + /** + * @param int $id + * @return \OCP\BackgroundJob\IJob + */ + public function getById($id); + + /** + * set the job that was last ran to the current time + * + * @param \OCP\BackgroundJob\IJob $job + */ + public function setLastJob($job); + + /** + * get the id of the last ran job + * + * @return int + */ + public function getLastJob(); + + /** + * set the lastRun of $job to now + * + * @param \OCP\BackgroundJob\IJob $job + */ + public function setLastRun($job); +} diff --git a/lib/public/config.php b/lib/public/config.php index 2d450e0d0d2..bb973939f44 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -42,7 +42,7 @@ class Config { /** * Gets a value from config.php * @param string $key key - * @param string $default = null default value + * @param mixed $default = null default value * @return string the value or $default * * This function gets the value from config.php. If it does not exist, @@ -55,7 +55,7 @@ class Config { /** * Sets a value * @param string $key key - * @param string $value value + * @param mixed $value value * @return bool * * This function sets the value and writes the config.php. If the file can diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php index f1124a2dd0b..8944e660780 100644 --- a/lib/public/iconfig.php +++ b/lib/public/iconfig.php @@ -38,7 +38,7 @@ interface IConfig { * Sets a new system wide value * * @param string $key the key of the value, under which will be saved - * @param string $value the value that should be stored + * @param mixed $value the value that should be stored * @todo need a use case for this */ // public function setSystemValue($key, $value); @@ -47,7 +47,7 @@ interface IConfig { * Looks up a system wide defined value * * @param string $key the key of the value, under which it was saved - * @param string $default the default value to be returned if the value isn't set + * @param mixed $default the default value to be returned if the value isn't set * @return string the saved value */ public function getSystemValue($key, $default = ''); diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index dcb00caf496..5fb51f9ecd5 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -183,4 +183,11 @@ interface IServerContainer { */ function getAvatarManager(); + /** + * Returns an job list for controlling background jobs + * + * @return \OCP\BackgroundJob\IJobList + */ + function getJobList(); + } |