diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-10 20:23:24 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-10 20:23:24 +0000 |
commit | c335b93d9513023efa4e1d5c89f3c289739285f5 (patch) | |
tree | 36e6a1587ab1efd14f21432cb5d7d9a32eb467d0 /lib | |
parent | bdddcc8892aacf3baeafb0b2f25db43f86df7655 (diff) | |
download | ampache-c335b93d9513023efa4e1d5c89f3c289739285f5.tar.gz ampache-c335b93d9513023efa4e1d5c89f3c289739285f5.tar.bz2 ampache-c335b93d9513023efa4e1d5c89f3c289739285f5.zip |
new xmlrpc mojo
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/catalog.class.php | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 01ca1a6f..6703ae98 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -922,7 +922,7 @@ class Catalog { $client = new xmlrpc_client("/$path/server.php", $server, 80); } - $f = new xmlrpcmsg('remote_server_query', array(new xmlrpcval( conf('web_path'), "string")) ); + $f = new xmlrpcmsg('remote_catalog_query', array(new xmlrpcval( conf('web_path'), "string")) ); if (conf('debug')) { $client->setDebug(1); } @@ -937,6 +937,7 @@ class Catalog { $catalog_name = $vars[0]; $count = $vars[1]; print("<b>Reading Remote Catalog: $catalog_name ($count Songs)</b> [$this->path]<br />\n"); + $total += $count; } // Flush the output flush(); @@ -949,29 +950,61 @@ class Catalog { return; } - $f = new xmlrpcmsg('remote_song_query'); - - /* Depending upon the size of the target catalog this can be a very slow/long process */ - set_time_limit(0); + // Hardcoded for now + $step = '500'; + $current = '0'; - // No Timeout on this one because it can be flipping huge - $response = $client->send($f); - $value = $response->value(); + while ($total >= $current) { + $start = $current; + $current += $step; + $this->get_remote_song($client,$start,$step); + } - if ( !$response->faultCode() ) { - $data = php_xmlrpc_decode($value); - $this->update_remote_catalog($data,$this->path); - } - else { + echo "<p>" . _("Completed updating remote catalog(s)") . ".</p><hr>\n"; + flush(); + + return true; + + } // get_remote_catalog + + /** + * get_remote_song + * This functions takes a start and end point for gathering songs from a remote server. It is broken up + * in attempt to get around the problem of very large target catalogs + * @package XMLRPC + * @catagory Client + * @todo Allow specificion of single catalog + */ + function get_remote_song($client,$start,$end) { + + $query_array = array(new xmlrpcval($start, "int"),new xmlrpcval($end,"int")); + + $f = new xmlrpcmsg('remote_song_query',$query_array); + + /* Depending upon the size of the target catalog this can be a very slow/long process */ + set_time_limit(0); + + // Sixty Second time out per chunk + $response = $client->send($f,60); + $value = $response->value(); + + if ( !$response->faultCode() ) { + $data = php_xmlrpc_decode($value); + $this->update_remote_catalog($data,$this->path); + $total = $start + $end; + echo "Added $total...<br />"; + flush(); + } + else { $error_msg = _("Error connecting to") . " " . $server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString(); log_event($_SESSION['userdata']['username'],'xmlrpc',$error_msg); echo "<p class=\"error\">$error_msg</p>"; - } + } - echo "<p>" . _("Completed updating remote catalog(s)") . ".</p><hr>\n"; + return; + } // get_remote_song - } // get_remote_catalog /** * update_remote_catalog |