From 6536a4dda3b96201f7f5551dc5d42559cf8b453d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 24 Apr 2010 01:43:47 +0000 Subject: [PATCH] Incomplete SocketRegistry class added, code cosmetics applied --- .gitattributes | 1 + .../actions/class_InvalidActionException.php | 2 +- .../auth/class_UserAuthorizationException.php | 2 +- .../class_DefaultControllerException.php | 2 +- .../class_InvalidControllerException.php | 2 +- .../class_EncryptInvalidLengthException.php | 2 +- .../crypto/class_EncryptMissingException.php | 2 +- .../filter/class_FilterChainException.php | 2 +- .../class_InvalidFilterChainException.php | 2 +- .../class_InvalidDatabaseResultException.php | 2 +- .../result/class_ResultUpdateException.php | 2 +- .../class_InvalidServerSocketException.php | 2 +- .../socket/class_InvalidSocketException.php | 2 +- .../class_NoSocketRegisteredException.php | 44 ++ ...ass_AlreadyInitializedStackerException.php | 2 +- .../stacker/class_EmptyStackerException.php | 2 +- .../stacker/class_FullStackerException.php | 2 +- .../stacker/class_NoStackerException.php | 2 +- .../state/class_InvalidStateException.php | 402 +----------------- ...class_AccountPasswordMismatchException.php | 2 +- .../user/class_UserEmailMissingException.php | 2 +- .../class_UserPasswordMismatchException.php | 2 +- .../user/class_UsernameMissingException.php | 2 +- .../interfaces/registry/socket/.htaccess | 1 + .../socket/class_RegisterableSocket.php | 56 +++ .../dataset/class_DataSetCriteria.php | 2 +- .../databases/class_LocalFileDatabase.php | 2 +- .../wrapper/class_NewsDatabaseWrapper.php | 4 +- .../wrapper/class_PaymentsDatabaseWrapper.php | 4 +- .../wrapper/class_UserDatabaseWrapper.php | 14 +- .../class_UserPointsDatabaseWrapper.php | 8 +- .../registry/socket/class_SocketRegistry.php | 53 ++- .../database/class_DatabaseConnection.php | 2 +- 33 files changed, 192 insertions(+), 441 deletions(-) create mode 100644 inc/classes/exceptions/socket/class_NoSocketRegisteredException.php create mode 100644 inc/classes/interfaces/registry/socket/.htaccess create mode 100644 inc/classes/interfaces/registry/socket/class_RegisterableSocket.php diff --git a/.gitattributes b/.gitattributes index 29969e49..dfeeab0b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -195,6 +195,7 @@ inc/classes/interfaces/registration/class_UserRegister.php -text inc/classes/interfaces/registry/.htaccess -text inc/classes/interfaces/registry/class_Register.php -text inc/classes/interfaces/registry/class_Registerable.php -text +inc/classes/interfaces/registry/socket/.htaccess -text inc/classes/interfaces/request/.htaccess -text inc/classes/interfaces/request/class_Requestable.php -text inc/classes/interfaces/resolver/.htaccess -text diff --git a/inc/classes/exceptions/actions/class_InvalidActionException.php b/inc/classes/exceptions/actions/class_InvalidActionException.php index 63eee545..aee6676e 100644 --- a/inc/classes/exceptions/actions/class_InvalidActionException.php +++ b/inc/classes/exceptions/actions/class_InvalidActionException.php @@ -29,7 +29,7 @@ class InvalidActionException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code) { + public function __construct (array $msgArray, $code) { // Prepare the message $message = sprintf("[%s:%d] Cannot resolve action %s (%s).", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/auth/class_UserAuthorizationException.php b/inc/classes/exceptions/auth/class_UserAuthorizationException.php index 24959a07..a7af5b95 100644 --- a/inc/classes/exceptions/auth/class_UserAuthorizationException.php +++ b/inc/classes/exceptions/auth/class_UserAuthorizationException.php @@ -29,7 +29,7 @@ class UserAuthorizationException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(Filterable $filterInstance, $code) { + public function __construct (Filterable $filterInstance, $code) { // Construct the message $message = sprintf("[%s:%d] Authorization has failed. Error code %s", $filterInstance->__toString(), diff --git a/inc/classes/exceptions/controller/class_DefaultControllerException.php b/inc/classes/exceptions/controller/class_DefaultControllerException.php index 3dfeb1c8..0415afbd 100644 --- a/inc/classes/exceptions/controller/class_DefaultControllerException.php +++ b/inc/classes/exceptions/controller/class_DefaultControllerException.php @@ -29,7 +29,7 @@ class DefaultControllerException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(ControllerResolver $resolverInstance, $code) { + public function __construct (ControllerResolver $resolverInstance, $code) { // Prepare the message $message = sprintf("[%s:%d] Cannot resolve default controller (%s). Maybe missing?", $resolverInstance->__toString(), diff --git a/inc/classes/exceptions/controller/class_InvalidControllerException.php b/inc/classes/exceptions/controller/class_InvalidControllerException.php index ab798acb..c13e63e9 100644 --- a/inc/classes/exceptions/controller/class_InvalidControllerException.php +++ b/inc/classes/exceptions/controller/class_InvalidControllerException.php @@ -29,7 +29,7 @@ class InvalidControllerException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code) { + public function __construct (array $msgArray, $code) { // Prepare the message $message = sprintf("[%s:%d] Cannot resolve controller %s (class name: %s).", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php index d70b5e77..47741840 100644 --- a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php +++ b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php @@ -29,7 +29,7 @@ class EncryptInvalidLengthException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(Filterable $filterInstance, $code) { + public function __construct (Filterable $filterInstance, $code) { // Get length $length = $filterInstance->getConfigInstance()->getConfigEntry('captcha_string_length'); diff --git a/inc/classes/exceptions/crypto/class_EncryptMissingException.php b/inc/classes/exceptions/crypto/class_EncryptMissingException.php index 360a1f13..1f846108 100644 --- a/inc/classes/exceptions/crypto/class_EncryptMissingException.php +++ b/inc/classes/exceptions/crypto/class_EncryptMissingException.php @@ -29,7 +29,7 @@ class EncryptMissingException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(Filterable $filterInstance, $code) { + public function __construct (Filterable $filterInstance, $code) { // Construct message $message = sprintf("[%s:%d] Encrypt string is missing.", $filterInstance->__toString(), diff --git a/inc/classes/exceptions/filter/class_FilterChainException.php b/inc/classes/exceptions/filter/class_FilterChainException.php index 85f2c91e..7f3b4d8d 100644 --- a/inc/classes/exceptions/filter/class_FilterChainException.php +++ b/inc/classes/exceptions/filter/class_FilterChainException.php @@ -29,7 +29,7 @@ class FilterChainException extends FrameworkException { * @param $code Exception code for better debugging * @return void */ - public function __construct(Filterable $filterInstance, $code) { + public function __construct (Filterable $filterInstance, $code) { // Construct the message $message = sprintf("[%s:%d] Filter chain interruppted by fatal error in filter.", $filterInstance->__toString(), diff --git a/inc/classes/exceptions/filter/class_InvalidFilterChainException.php b/inc/classes/exceptions/filter/class_InvalidFilterChainException.php index d5c6f9ae..ad93ac8c 100644 --- a/inc/classes/exceptions/filter/class_InvalidFilterChainException.php +++ b/inc/classes/exceptions/filter/class_InvalidFilterChainException.php @@ -29,7 +29,7 @@ class InvalidFilterChainException extends FrameworkException { * @param $code Exception code for better debugging * @return void */ - public function __construct(array $filterArray, $code) { + public function __construct (array $filterArray, $code) { // Construct the message $message = sprintf("[%s:%d] Filter chain %s is not initialized.", $filterArray[0]->__toString(), diff --git a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php index d532ca13..9125b921 100644 --- a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php +++ b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php @@ -29,7 +29,7 @@ class InvalidDatabaseResultException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $msgArray, $code) { + public function __construct (array $msgArray, $code) { // Construct the message $message = sprintf("[%s:%d] Database instance %s contains invalid entries.", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/result/class_ResultUpdateException.php b/inc/classes/exceptions/result/class_ResultUpdateException.php index baa15f85..87d741c2 100644 --- a/inc/classes/exceptions/result/class_ResultUpdateException.php +++ b/inc/classes/exceptions/result/class_ResultUpdateException.php @@ -29,7 +29,7 @@ class ResultUpdateException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(UpdateableResult $resultInstance, $code) { + public function __construct (UpdateableResult $resultInstance, $code) { // Construct the message $message = sprintf("[%s:%d] Update of result instance has nothing changed.", $resultInstance->__toString(), diff --git a/inc/classes/exceptions/socket/class_InvalidServerSocketException.php b/inc/classes/exceptions/socket/class_InvalidServerSocketException.php index 0bf9268e..c0e3ceef 100644 --- a/inc/classes/exceptions/socket/class_InvalidServerSocketException.php +++ b/inc/classes/exceptions/socket/class_InvalidServerSocketException.php @@ -29,7 +29,7 @@ class InvalidServerSocketException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageData, $code) { + public function __construct (array $messageData, $code) { // Construct the message $message = sprintf("[%s:] Socket resource %s is not a server socket!", $messageData[0]->__toString(), diff --git a/inc/classes/exceptions/socket/class_InvalidSocketException.php b/inc/classes/exceptions/socket/class_InvalidSocketException.php index e9463618..d8f87970 100644 --- a/inc/classes/exceptions/socket/class_InvalidSocketException.php +++ b/inc/classes/exceptions/socket/class_InvalidSocketException.php @@ -30,7 +30,7 @@ class InvalidSocketException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageData, $code) { + public function __construct (array $messageData, $code) { // Construct the message $message = sprintf("[%s:] Invalid socket (type %s != resource). errno=%s, errstr=%s", $messageData[0]->__toString(), diff --git a/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php b/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php new file mode 100644 index 00000000..fbd5daa8 --- /dev/null +++ b/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoSocketRegisteredException extends FrameworkException { + /** + * A Constructor for this exception + * + * @param $listenerInstance An instance of a Listenable class + * @param $code Error code + * @return void + */ + public function __construct (Listenable $listenerInstance, $code) { + // Construct the message + $message = sprintf("[%s:] Requested socket is not yet registered.", + $listenerInstance->__toString() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php b/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php index 24b5ab88..0d13dd31 100644 --- a/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php +++ b/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php @@ -29,7 +29,7 @@ class AlreadyInitializedStackerException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageArray, $code) { + public function __construct (array $messageArray, $code) { // Construct message $message = sprintf("[%s:%d] Stacker %s already initialized.", $messageArray[0]->__toString(), diff --git a/inc/classes/exceptions/stacker/class_EmptyStackerException.php b/inc/classes/exceptions/stacker/class_EmptyStackerException.php index 19f94239..dbadfbbb 100644 --- a/inc/classes/exceptions/stacker/class_EmptyStackerException.php +++ b/inc/classes/exceptions/stacker/class_EmptyStackerException.php @@ -29,7 +29,7 @@ class EmptyStackerException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageArray, $code) { + public function __construct (array $messageArray, $code) { // Construct message $message = sprintf("[%s:%d] Stacker %s is empty.", $messageArray[0]->__toString(), diff --git a/inc/classes/exceptions/stacker/class_FullStackerException.php b/inc/classes/exceptions/stacker/class_FullStackerException.php index 6bce7304..71a2f897 100644 --- a/inc/classes/exceptions/stacker/class_FullStackerException.php +++ b/inc/classes/exceptions/stacker/class_FullStackerException.php @@ -29,7 +29,7 @@ class FullStackerException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageArray, $code) { + public function __construct (array $messageArray, $code) { // Construct message $message = sprintf("[%s:%d] Stacker %s is full.", $messageArray[0]->__toString(), diff --git a/inc/classes/exceptions/stacker/class_NoStackerException.php b/inc/classes/exceptions/stacker/class_NoStackerException.php index 77fa89f3..accc7ce8 100644 --- a/inc/classes/exceptions/stacker/class_NoStackerException.php +++ b/inc/classes/exceptions/stacker/class_NoStackerException.php @@ -29,7 +29,7 @@ class NoStackerException extends FrameworkException { * @param $code Error code * @return void */ - public function __construct(array $messageArray, $code) { + public function __construct (array $messageArray, $code) { // Construct message $message = sprintf("[%s:%d] Stacker %s is not initialized.", $messageArray[0]->__toString(), diff --git a/inc/classes/exceptions/state/class_InvalidStateException.php b/inc/classes/exceptions/state/class_InvalidStateException.php index 60f791ff..9bcbbeb4 100644 --- a/inc/classes/exceptions/state/class_InvalidStateException.php +++ b/inc/classes/exceptions/state/class_InvalidStateException.php @@ -29,407 +29,7 @@ class InvalidStateException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { - // Prepare the message - $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct(array $msgArray, $code) { + public function __construct (array $msgArray, $code) { // Prepare the message $message = sprintf("[%s:%d] Cannot resolve state %s (class name: %s).", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php index 93e539ab..6fbfe321 100644 --- a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php +++ b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php @@ -29,7 +29,7 @@ class AccountPasswordMismatchException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(Filterable $filterInstance, $code) { + public function __construct (Filterable $filterInstance, $code) { // Create the message $message = sprintf("[%s:%d] Supplied account password did not match with stored.", $filterInstance->__toString(), diff --git a/inc/classes/exceptions/user/class_UserEmailMissingException.php b/inc/classes/exceptions/user/class_UserEmailMissingException.php index 9f49a9ad..56698ac0 100644 --- a/inc/classes/exceptions/user/class_UserEmailMissingException.php +++ b/inc/classes/exceptions/user/class_UserEmailMissingException.php @@ -29,7 +29,7 @@ class UserEmailMissingException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code = 0) { + public function __construct (array $msgArray, $code = 0) { // Create the message $message = sprintf("[%s:%d] User email %s was not found.", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php index 3e4b1318..d3b9d195 100644 --- a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php +++ b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php @@ -29,7 +29,7 @@ class UserPasswordMismatchException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code = 0) { + public function __construct (array $msgArray, $code = 0) { // Create the message $message = sprintf("[%s:%d] Supplied password for user %s did not match with stored password.", $msgArray[0]->__toString(), diff --git a/inc/classes/exceptions/user/class_UsernameMissingException.php b/inc/classes/exceptions/user/class_UsernameMissingException.php index d23b1863..46a9b873 100644 --- a/inc/classes/exceptions/user/class_UsernameMissingException.php +++ b/inc/classes/exceptions/user/class_UsernameMissingException.php @@ -29,7 +29,7 @@ class UsernameMissingException extends FrameworkException { * @param $code An optional code for better debugging * @return void */ - public function __construct(array $msgArray, $code = 0) { + public function __construct (array $msgArray, $code = 0) { // Create the message $message = sprintf("[%s:%d] Username %s was not found.", $msgArray[0]->__toString(), diff --git a/inc/classes/interfaces/registry/socket/.htaccess b/inc/classes/interfaces/registry/socket/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/classes/interfaces/registry/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php b/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php new file mode 100644 index 00000000..a9757483 --- /dev/null +++ b/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface RegisterableSocket extends Registerable { + /** + * Checks wether given socket resource is registered. If $socketResource is + * false only the instance will be checked. + * + * @param $listenerInstance An instance of a Listenable class + * @param $socketResource A valid socket resource + * @return $isRegistered Wether the given socket resource is registered + */ + function isSocketRegistered (Listenable $listenerInstance, $socketResource); + + /** + * Registeres given socket for listener or throws an exception if it is already registered + * + * @param $listenerInstance An instance of a Listenable class + * @param $socketResource A valid socket resource + * @return void + * @throws SocketAlreadyRegisteredException If the given socket is already registered + */ + function registerSocket (Listenable $listenerInstance, $socketResource); + + /** + * Getter for given listener's socket resource + * + * @param $listenerInstance An instance of a Listenable class + * @return $socketResource A valid socket resource + * @throws NoSocketRegisteredException If the requested socket is not registered + */ + function getSocketResource (Listenable $listenerInstance); +} + +// [EOF] +?> diff --git a/inc/classes/main/criteria/dataset/class_DataSetCriteria.php b/inc/classes/main/criteria/dataset/class_DataSetCriteria.php index da22ede8..8ae131df 100644 --- a/inc/classes/main/criteria/dataset/class_DataSetCriteria.php +++ b/inc/classes/main/criteria/dataset/class_DataSetCriteria.php @@ -48,7 +48,7 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria { * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 64101115..0eb8f91b 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -83,7 +83,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php index 2f75fc98..58a7aeeb 100644 --- a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php @@ -23,14 +23,14 @@ */ class NewsDatabaseWrapper extends BaseDatabaseWrapper { // Constants for database table names - const DB_TABLE_NEWS = "news"; + const DB_TABLE_NEWS = 'news'; /** * Protected constructor * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php index 68281da5..9c1a37d7 100644 --- a/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_PaymentsDatabaseWrapper.php @@ -26,14 +26,14 @@ class PaymentsDatabaseWrapper extends BaseDatabaseWrapper { const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database table names - const DB_TABLE_PAYMENTS = "payments"; + const DB_TABLE_PAYMENTS = 'payments'; /** * Protected constructor * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index f2cc0449..7f9f5910 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -26,21 +26,21 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccou const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database columns - const DB_COLUMN_USERID = "userid"; - const DB_COLUMN_USERNAME = "username"; - const DB_COLUMN_EMAIL = "email"; - const DB_COLUMN_CONFIRM_HASH = "confirm_hash"; - const DB_COLUMN_USER_STATUS = "user_status"; + const DB_COLUMN_USERID = 'userid'; + const DB_COLUMN_USERNAME = 'username'; + const DB_COLUMN_EMAIL = 'email'; + const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; + const DB_COLUMN_USER_STATUS = 'user_status'; // Constants for database table names - const DB_TABLE_USER = "user"; + const DB_TABLE_USER = 'user'; /** * Protected constructor * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php index dbf00434..33f24dde 100644 --- a/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserPointsDatabaseWrapper.php @@ -25,24 +25,24 @@ class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookableP /** * Constants for database table names */ - const DB_TABLE_USER_POINTS = "user_points"; + const DB_TABLE_USER_POINTS = 'user_points'; /** * Name of the user->points column */ - const DB_COLUMN_POINTS_UID = "points_uid"; + const DB_COLUMN_POINTS_UID = 'points_uid'; /** * Name of the points column */ - const DB_COLUMN_POINTS = "points"; + const DB_COLUMN_POINTS = 'points'; /** * Protected constructor * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } diff --git a/inc/classes/main/registry/socket/class_SocketRegistry.php b/inc/classes/main/registry/socket/class_SocketRegistry.php index a1eea99f..b23086f8 100644 --- a/inc/classes/main/registry/socket/class_SocketRegistry.php +++ b/inc/classes/main/registry/socket/class_SocketRegistry.php @@ -21,7 +21,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class SocketRegistry extends BaseRegistry implements Register { +class SocketRegistry extends BaseRegistry implements Register, RegisterableSocket { + // Exception constants + const SOCKET_NOT_REGISTERED = 0xd00; + /** * Instance of this class */ @@ -53,8 +56,54 @@ class SocketRegistry extends BaseRegistry implements Register { // Return the instance return self::$registryInstance; } + + /** + * Checks wether given socket resource is registered. If $socketResource is + * false only the instance will be checked. + * + * @param $listenerInstance An instance of a Listenable class + * @param $socketResource A valid socket resource + * @return $isRegistered Wether the given socket resource is registered + */ + public function isSocketRegistered (Listenable $listenerInstance, $socketResource) { + $this->partialStub('Not yet implemented.'); + } + + /** + * Registeres given socket for listener or throws an exception if it is already registered + * + * @param $listenerInstance An instance of a Listenable class + * @param $socketResource A valid socket resource + * @throws SocketAlreadyRegisteredException If the given socket is already registered + * @return void + */ + public function registerSocket (Listenable $listenerInstance, $socketResource) { + // Is the socket already registered? + if ($this->isSocketRegistered($listenerInstance, $socketResource)) { + // Throw the exception + throw new SocketAlreadyRegisteredException($listenerInstance, BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED); + } // END - if + + $this->partialStub('Not yet implemented.'); + } + + /** + * Getter for given listener's socket resource + * + * @param $listenerInstance An instance of a Listenable class + * @return $socketResource A valid socket resource + * @throws NoSocketRegisteredException If the requested socket is not registered + */ + public function getSocketResource (Listenable $listenerInstance) { + // The socket must be registered before we can return it + if (!$this->isSocketRegistered($listenerInstance, false)) { + // Throw the exception + throw new NoSocketRegisteredException ($listenerInstance, self::SOCKET_NOT_REGISTERED); + } // END - if + + $this->partialStub('Not yet implemented.'); + } } // [EOF] ?> - diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index 2f61bfa5..de4f5a02 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -43,7 +43,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re * * @return void */ - protected function __construct() { + protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } -- 2.30.2