2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
   5  * Music Player Daemon API
 
   9  * LICENSE: This source file is subject to version 3.01 of the PHP license
 
  10  * that is available thorugh the world-wide-web at the following URI:
 
  11  * http://www.php.net/license/3_01.txt. If you did not receive a copy of
 
  12  * the PHP License and are unable to obtain it through the web, please
 
  13  * send a note to license@php.net so we can mail you a copy immediately.
 
  15  * @category  Networking
 
  17  * @author    Graham Christensen <graham.christensen@itrebal.com>
 
  18  * @copyright 2006 Graham Christensen
 
  19  * @license   http://www.php.net/license/3_01.txt
 
  24 require_once 'PEAR/Exception.php';
 
  25 require_once 'MPD/Common.php';
 
  29  * Central class for the Music Player Daemon objects
 
  31  * Used to utilize the functionality of the provided classes
 
  33  * @category  Networking
 
  35  * @author    Graham Christensen <graham.christensen@itrebal.com>
 
  36  * @copyright 2006 Graham Christensen
 
  37  * @license   http://www.php.net/license/3_01.txt
 
  43      * The Net_MPD_Admin object
 
  48      * The Net_MPD_Common object
 
  53      * The Net_MPD_Database object
 
  58      * The Net_MPD_Playback object
 
  63      * The Net_MPD_Playlist object
 
  68      * Creates new instances of objects
 
  69      * @param $host Host to connect to, optional (default: localhost)
 
  70      * @param $port Port to connect to, optional (default: 6600)
 
  71      * @param $pass Pass to connect to, optional (default: null)
 
  72      * @return object or false on failure
 
  74     function __construct($host = 'localhost', $port = 6600, $pass = null)
 
  76         $this->Admin    = self::factory('Admin'   , $host, $port, $pass);
 
  77         $this->Common   = self::factory('Common'  , $host, $port, $pass);
 
  78         $this->Database = self::factory('Database', $host, $port, $pass);
 
  79         $this->Playback = self::factory('Playback', $host, $port, $pass);
 
  80         $this->Playlist = self::factory('Playlist', $host, $port, $pass);
 
  84      * Creates new instances of objects
 
  85      * @param $class Class to initiate, with out Net_MPD_$class
 
  86      * @param $host Host to connect to, optional (default: localhost)
 
  87      * @param $port Port to connect to, optional (default: 6600)
 
  88      * @param $pass Pass to connect to, optional (default: null)
 
  89      * @return object or false on failure
 
  91     public static function factory($class, $host = 'localhost', $port = 6600, $pass = null)
 
  93         $class = ucfirst(strtolower($class));
 
  95         if (!self::_loadClass($class)) {
 
  99         $class = 'Net_MPD_' . $class;
 
 100         $obj = new $class($host, $port, $pass);
 
 107     * @param $class Class to include, with out Net_MPD_
 
 110     protected static function _loadClass($class)
 
 112         if (class_exists('Net_MPD_' . $class)) {
 
 115         require_once 'Net/MPD/' . $class . '.php';