diff options
-rw-r--r-- | lib/class/catalog.class.php | 43 | ||||
-rw-r--r-- | modules/ampacheapi/AmpacheApi.lib.php | 24 |
2 files changed, 27 insertions, 40 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index c3f487b3..5a7921c2 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1298,47 +1298,10 @@ class Catalog extends database_object { return false; } - // Handshake and get our token for this little conversation - $token = xmlRpcClient::ampache_handshake($this->path,$this->key); - - if (!$token) { - debug_event('XMLCLIENT','Error No Token returned', 2); - Error::display('general'); - return; - } else { - debug_event('xmlrpc',"token returned",'4'); - } - - // Figure out the host etc - preg_match("/http:\/\/([^\/\:]+):?(\d*)\/*(.*)/", $this->path, $match); - $server = $match['1']; - $port = $match['2'] ? intval($match['2']) : '80'; - $path = $match['3']; - - $full_url = "/" . ltrim($path . "/server/xmlrpc.server.php",'/'); - if(Config::get('proxy_host') AND Config::get('proxy_port')) { - $proxy_host = Config::get('proxy_host'); - $proxy_port = Config::get('proxy_port'); - $proxy_user = Config::get('proxy_user'); - $proxy_pass = Config::get('proxy_pass'); - } - $client = new XML_RPC_Client($full_url,$server,$port,$proxy_host,$proxy_port,$proxy_user,$proxy_pass); - - /* encode the variables we need to send over */ - $encoded_key = new XML_RPC_Value($token,'string'); - $encoded_path = new XML_RPC_Value(Config::get('web_path'),'string'); + // Figure out how many songs, more information etc + $remote_catalog_info = $remote_handle->info(); - $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.get_catalogs', array($encoded_key,$encoded_path)); - $response = $client->send($xmlrpc_message,30); - - if ($response->faultCode() ) { - $error_msg = _("Error connecting to") . " " . $server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString(); - debug_event('XMLCLIENT(get_remote_catalog)',$error_msg,'1'); - echo "<p class=\"error\">$error_msg</p>"; - return; - } - - $data = XML_RPC_Decode($response->value()); + // Print out the catalogs we are going to sync foreach ($data as $vars) { diff --git a/modules/ampacheapi/AmpacheApi.lib.php b/modules/ampacheapi/AmpacheApi.lib.php index c234eb19..5f34170d 100644 --- a/modules/ampacheapi/AmpacheApi.lib.php +++ b/modules/ampacheapi/AmpacheApi.lib.php @@ -28,6 +28,10 @@ class AmpacheApi { private $password; private $api_secure; + // Handshake variables + private $handshake; + private $handshake_time; // Used to figure out how stale our data is + // Response variables private $api_session; @@ -93,6 +97,10 @@ class AmpacheApi { $results = array_shift($this->get_response()); $this->api_auth = $results['auth']; + // Define when we pulled this, it is not wine, it does + // not get better with age + $this->handshake_time = time(); + $this->handshake = $results; } // connect @@ -161,6 +169,22 @@ class AmpacheApi { } // state /** + * info + * Returns the information gathered by the handshake + * not raw so we can formated it if we wanted? + */ + public function info() { + + if ($this->state() != 'READY') { + trigger_error('AmpacheApi::info API in non-ready state, unable to return info'); + return false; + } + + return $this->handshake; + + } // info + + /** * send_command * This sends an API command, with options to the currently connected * host, and returns a nice clean keyed array |