#1530 networking XML-RPC dummy methods added

This commit is contained in:
tomash 2006-04-19 00:55:46 +00:00
parent 40fa38627c
commit c0cffd4953
9 changed files with 974 additions and 885 deletions

View file

@ -1623,7 +1623,7 @@ class BasicStor extends Alib{
if($filesOnly) $this->deleteFiles(); if($filesOnly) $this->deleteFiles();
else $this->deleteData(); else $this->deleteData();
if(!$this->config['isArchive']){ if(!$this->config['isArchive']){
$tr =& new Transport($this->dbc, $this, $this->config); $tr =& new Transport($this);
$tr->resetData(); $tr->resetData();
} }
$res = array( $res = array(

View file

@ -1133,35 +1133,19 @@ class GreenBox extends BasicStor{
* *
* @param trtok: string - transport token * @param trtok: string - transport token
* @return struct/hasharray with fields: * @return struct/hasharray with fields:
* trtype: string - audioclip | playlist | search | file
* state: string - transport state * state: string - transport state
* expectedSize: int - file size in bytes * direction: string - up | down
* realSize: int - currently transported bytes * expectedsize: int - file size in bytes
* expectedChsum: string - orginal file checksum * realsize: int - currently transported bytes
* realChsum: string - transported file checksum * expectedchsum: string - orginal file checksum
* realchsum: string - transported file checksum
* ... ? * ... ?
*/ */
// DUMMY function getTransportInfo($trtok) {
function getTransportInfo($trtok) require_once"Transport.php";
{ $tr =& new Transport($this);
switch($trtok){ return $tr->getTransportInfo($trtok);
case'123456789abcdeff'; // upload/download
return array(
'state' => 'finished',
'expectedSize' => 1024,
'realSize' => 1024,
'expectedChsum' => '12dd9137a855cf600881dd6d3ffa7517',
'realChsum' => '12dd9137a855cf600881dd6d3ffa7517',
);
case'123456789abcdefe'; // search
return array(
'state' => 'finished',
);
default:
return PEAR::raiseError(
"GreenBox::getTransportInfo:".
" invalid transport token ($trtok)"
);
}
} }
/** /**
@ -1170,10 +1154,10 @@ class GreenBox extends BasicStor{
* @param onOff: boolean optional (if not used, current state is returned) * @param onOff: boolean optional (if not used, current state is returned)
* @return boolean - previous state * @return boolean - previous state
*/ */
// DUMMY function turnOnOffTransports($onOff) {
function turnOnOffTransports($onOff) require_once"Transport.php";
{ $tr =& new Transport($this);
return TRUE; return $tr->turnOnOffTransports($onOff);
} }
/* ------------------------ methods for ls-archive-format file transports */ /* ------------------------ methods for ls-archive-format file transports */
@ -1184,15 +1168,10 @@ class GreenBox extends BasicStor{
* @param filePath string - local path to uploaded file * @param filePath string - local path to uploaded file
* @return string - transport token * @return string - transport token
*/ */
// DUMMY function uploadFile2Hub($filePath) {
function uploadFile2Hub($filePath) require_once"Transport.php";
{ $tr =& new Transport($this);
if(!file_exists($filePath)){ return $tr->uploadFile2Hub($filePath);
return PEAR::raiseError(
"GreenBox::uploadFile2Hub: file not found ($filePath)"
);
}
return '123456789abcdeff';
} }
/** /**
@ -1202,14 +1181,10 @@ class GreenBox extends BasicStor{
* trtok: string transport token * trtok: string transport token
* ... ? * ... ?
*/ */
// DUMMY function getHubInitiatedTransfers() {
function getHubInitiatedTransfers() require_once"Transport.php";
{ $tr =& new Transport($this);
return array( return $tr->getHubInitiatedTransfers();
array(
'trtok' => '123456789abcdeff',
),
);
} }
/** /**
@ -1219,16 +1194,10 @@ class GreenBox extends BasicStor{
* the getHubInitiatedTransfers method * the getHubInitiatedTransfers method
* @return string - transport token * @return string - transport token
*/ */
// DUMMY function startHubInitiatedTransfer($trtok) {
function startHubInitiatedTransfer($trtok) require_once"Transport.php";
{ $tr =& new Transport($this);
if($trtok != '123456789abcdeff'){ return $tr->startHubInitiatedTransfer($trtok);
return PEAR::raiseError(
"GreenBox::startHubInitiatedTransfer:".
" invalid transport token ($trtok)"
);
}
return $trtok;
} }
/* ------------- special methods for audioClip/webstream object transport */ /* ------------- special methods for audioClip/webstream object transport */
@ -1237,28 +1206,24 @@ class GreenBox extends BasicStor{
* Start upload of audioClip/webstream from local storageServer to hub * Start upload of audioClip/webstream from local storageServer to hub
* *
* @param gunid: string - global unique id of object being transported * @param gunid: string - global unique id of object being transported
* @return boolean true - status * @return string - transport token
*/ */
// DUMMY function uploadAudioClip2Hub($gunid) {
function uploadAudioClip2Hub($gunid) require_once"Transport.php";
{ $tr =& new Transport($this);
$ac = StoredFile::recallByGunid($this, $gunid); return $tr->uploadAudioClip2Hub($gunid);
if(PEAR::isError($ac)){ return $ac; }
return TRUE;
} }
/** /**
* Start download of audioClip/webstream from hub to local storageServer * Start download of audioClip/webstream from hub to local storageServer
* *
* @param gunid: string - global unique id of object being transported * @param gunid: string - global unique id of object being transported
* @return boolean true - status * @return string - transport token
*/ */
// DUMMY function downloadAudioClipFromHub($gunid) {
function downloadAudioClipFromHub($gunid) require_once"Transport.php";
{ $tr =& new Transport($this);
$ac = StoredFile::recallByGunid($this, $gunid); return $tr->downloadAudioClipFromHub($gunid);
if(PEAR::isError($ac)){ return $ac; }
return TRUE;
} }
/* ------------------------------- special methods for playlist transport */ /* ------------------------------- special methods for playlist transport */
@ -1267,14 +1232,12 @@ class GreenBox extends BasicStor{
* *
* @param plid: string - global unique id of playlist being transported * @param plid: string - global unique id of playlist being transported
* @param withContent: boolean - if true, transport playlist content too * @param withContent: boolean - if true, transport playlist content too
* @return boolean true - status * @return string - transport token
*/ */
// DUMMY function uploadPlaylist2Hub($plid, $withContent) {
function uploadPlaylist2Hub($plid, $withContent) require_once"Transport.php";
{ $tr =& new Transport($this);
$pl = Playlist::recallByGunid($this, $plid); return $tr->uploadPlaylist2Hub($plid, $withContent);
if(PEAR::isError($pl)){ return $pl; }
return TRUE;
} }
/** /**
@ -1282,14 +1245,12 @@ class GreenBox extends BasicStor{
* *
* @param plid: string - global unique id of playlist being transported * @param plid: string - global unique id of playlist being transported
* @param withContent: boolean - if true, transport playlist content too * @param withContent: boolean - if true, transport playlist content too
* @return boolean true - status * @return string - transport token
*/ */
// DUMMY function downloadPlaylistFromHub($plid, $withContent) {
function downloadPlaylistFromHub($plid, $withContent) require_once"Transport.php";
{ $tr =& new Transport($this);
$pl = Playlist::recallByGunid($this, $plid); return $tr->downloadPlaylistFromHub($plid, $withContent);
if(PEAR::isError($pl)){ return $pl; }
return TRUE;
} }
/* ------------------------------------------------ global-search methods */ /* ------------------------------------------------ global-search methods */
@ -1299,10 +1260,10 @@ class GreenBox extends BasicStor{
* @param criteria: LS criteria format (see localSearch) * @param criteria: LS criteria format (see localSearch)
* @return string - transport token * @return string - transport token
*/ */
// DUMMY function globalSearch($criteria) {
function globalSearch($criteria) require_once"Transport.php";
{ $tr =& new Transport($this);
return '123456789abcdefe'; return $tr->globalSearch($criteria);
} }
/** /**
@ -1311,28 +1272,11 @@ class GreenBox extends BasicStor{
* @param trtok: string - transport token * @param trtok: string - transport token
* @return : LS search result format (see localSearch) * @return : LS search result format (see localSearch)
*/ */
// DUMMY function getSearchResults($trtok) {
function getSearchResults($trtok) require_once"Transport.php";
{ $tr =& new Transport($this);
if($trtok != '123456789abcdefe'){ return $tr->getSearchResults($trtok);
return PEAR::raiseError(
"GreenBox::getSearchResults: invalid transport token ($trtok)"
);
} }
return array(
'results' => array('0000000000010001', '0000000000010002'),
'cnt' => 2,
);
}
/**
*
* @param
* @return
function ()
{
}
*/
/* ========================================================= info methods */ /* ========================================================= info methods */
/** /**

File diff suppressed because it is too large Load diff

View file

@ -73,7 +73,7 @@ if(PEAR::isError($dbc)){
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb =& new GreenBox($dbc, $config); $gb =& new GreenBox($dbc, $config);
$tr =& new Transport($dbc, $gb, $config); $tr =& new Transport($gb);
$pr =& new Prefs($gb); $pr =& new Prefs($gb);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

@ -66,7 +66,7 @@ if(PEAR::isError($dbc)){
echo "#StorageServer uninstall:\n"; echo "#StorageServer uninstall:\n";
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config); $gb = &new GreenBox($dbc, $config);
$tr =& new Transport($dbc, $gb, $config); $tr =& new Transport($gb);
$pr =& new Prefs($gb); $pr =& new Prefs($gb);
$dbc->setErrorHandling(PEAR_ERROR_RETURN); $dbc->setErrorHandling(PEAR_ERROR_RETURN);

View file

@ -1773,6 +1773,9 @@ class XR_LocStor extends LocStor{
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
# return new XML_RPC_Response(XML_RPC_encode(var_export($this, TRUE)));
$res = $this->createBackupOpen($r['sessid'], $r['criteria']); $res = $this->createBackupOpen($r['sessid'], $r['criteria']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, return new XML_RPC_Response(0, 805,
@ -2210,7 +2213,7 @@ class XR_LocStor extends LocStor{
* *
* @param input XMLRPC struct * @param input XMLRPC struct
* @return XMLRPC struct * @return XMLRPC struct
* @see Pref::browseCategory * @see LocStor::browseCategory
*/ */
function xr_browseCategory($input) function xr_browseCategory($input)
{ {
@ -2237,7 +2240,7 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response($xv); return new XML_RPC_Response($xv);
} }
/* ---------------------------------------------- methods for preferences */ /* ============================================== methods for preferences */
/** /**
* Load user preference value * Load user preference value
* *
@ -2497,8 +2500,586 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
} }
/* -------------------------------------------- remote repository methods */ /* =============================== remote repository (networking) methods */
/* ------------------------------------------------------- common methods */
/** /**
* Common "check" method for transports
*
* The XML-RPC name of this method is "locstor.getTransportInfo".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li>trtype: string - audioclip | playlist | search | file</li>
* <li>direction: string - up | down</li>
* <li>state: string - transport state</li>
* <li>expectedsize: int - expected size</li>
* <li>realsize: int - size of transported file</li>
* <li>expectedchsum: string - expected checksum</li>
* <li>realchsum: string - checksum of transported file</li>
* <li>title: string - file title</li>
* <li>errmsg: string - error message from failed transports</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_getTransportInfo:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::getTransportInfo
*/
function xr_getTransportInfo($input)
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->getTransportInfo($r['trtok']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getTransportInfo: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
* Turn transports on/off, optionaly return current state.
*
* The XML-RPC name of this method is "locstor.turnOnOffTransports".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> onOff: boolean optional
* (if not used, current state is returned)</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> state : boolean - previous state</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_turnOnOffTransports:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::turnOnOffTransports
*/
function xr_turnOnOffTransports($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->turnOnOffTransports($r['onOff']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_turnOnOffTransports: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('state'=>$res)));
}
/* ------------------------ methods for ls-archive-format file transports */
/**
* Open async file transfer from local storageServer to network hub,
* file should be ls-archive-format file.
*
* The XML-RPC name of this method is "locstor.uploadFile2Hub".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> filePath string - local path to uploaded file</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_uploadFile2Hub:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::uploadFile2Hub
*/
function xr_uploadFile2Hub($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :(
// there should be something as uploadFile2storageServer
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_uploadFile2Hub: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/**
* Get list of prepared transfers initiated by hub
*
* The XML-RPC name of this method is "locstor.getHubInitiatedTransfers".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> results : array of structs with fields:
* <ul>
* <li> trtok : string - transport token</li>
* <li> ... ? </li>
* </ul>
* </li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_getHubInitiatedTransfers:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::getHubInitiatedTransfers
*/
function xr_getHubInitiatedTransfers($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->getHubInitiatedTransfers();
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getHubInitiatedTransfers: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
* Start of download initiated by hub
*
* The XML-RPC name of this method is "locstor.startHubInitiatedTransfer".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> trtok : string - transport token obtained from
* the getHubInitiatedTransfers method</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_startHubInitiatedTransfer:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::startHubInitiatedTransfer
*/
function xr_startHubInitiatedTransfer($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->startHubInitiatedTransfer($r['trtok']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_startHubInitiatedTransfer: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/* ------------- special methods for audioClip/webstream object transport */
/**
* Common "check" method for transports
*
* The XML-RPC name of this method is "locstor.uploadAudioClip2Hub".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> gunid: string - global unique id of object being transported
* </li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_uploadAudioClip2Hub:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::uploadAudioClip2Hub
*/
function xr_uploadAudioClip2Hub($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->uploadAudioClip2Hub($r['gunid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_uploadAudioClip2Hub: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/**
* Start download of audioClip/webstream from hub to local storageServer
*
* The XML-RPC name of this method is "locstor.downloadAudioClipFromHub".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> gunid: string - global unique id of object being transported
* </li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_downloadAudioClipFromHub:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::downloadAudioClipFromHub
*/
function xr_downloadAudioClipFromHub($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->downloadAudioClipFromHub($r['gunid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_downloadAudioClipFromHub: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/* ------------------------------- special methods for playlist transport */
/**
* Start upload of playlist from local storageServer to hub
*
* The XML-RPC name of this method is "locstor.uploadPlaylist2Hub".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> plid: string - global unique id of playlist being transported
* </li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_uploadPlaylist2Hub:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::uploadPlaylist2Hub
*/
function xr_uploadPlaylist2Hub($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->uploadPlaylist2Hub($r['plid'], $r['withContent']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_uploadPlaylist2Hub: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/**
* Start download of playlist from hub to local storageServer
*
* The XML-RPC name of this method is "locstor.downloadPlaylistFromHub".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> plid: string - global unique id of playlist being transported
* </li>
* <li> withContent: boolean - if true, transport playlist content too
* </li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_downloadPlaylistFromHub:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::downloadPlaylistFromHub
*/
function xr_downloadPlaylistFromHub($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->downloadPlaylistFromHub($r['plid'], $r['withContent']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_downloadPlaylistFromHub: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/* ------------------------------------------------ global-search methods */
/**
* Start search job on network hub
*
* The XML-RPC name of this method is "locstor.globalSearch".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> criteria: LS criteria format (see localSearch)</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_globalSearch:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::globalSearch
*/
function xr_globalSearch($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->globalSearch($r['criteria']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_globalSearch: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
}
/**
* Get results from search job on network hub
*
* The XML-RPC name of this method is "locstor.getSearchResults".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> trtok : string - transport token</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li>audioClipResults : array with gunid strings
* of audioClips have been found</li>
* <li>audioClipCnt : int - number of audioClips matching
* the criteria</li>
* <li>webstreamResults : array with gunid strings
* of webstreams have been found</li>
* <li>webstreamCnt : int - number of webstreams matching
* the criteria</li>
* <li>playlistResults : array with gunid strings
* of playlists have been found</li>
* <li>playlistCnt : int - number of playlists matching
* the criteria</li>
* </ul>
* (cnt values may be greater than size of arrays - see limit param)
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_getSearchResults:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Transport::getSearchResults
*/
function xr_getSearchResults($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
$tr =& new Transport($this);
$res = $tr->getSearchResults($r['trtok']); // *** search results format differs between GB and XML_RPC ifaces
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getSearchResults: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/**
* OBSOLETE
* Starts upload audioclip to remote archive * Starts upload audioclip to remote archive
* *
* The XML-RPC name of this method is "locstor.uploadToArchive". * The XML-RPC name of this method is "locstor.uploadToArchive".
@ -2528,14 +3109,14 @@ class XR_LocStor extends LocStor{
* *
* @param input XMLRPC struct * @param input XMLRPC struct
* @return XMLRPC struct * @return XMLRPC struct
* @see Pref::uploadToArchive * @see Transport::uploadToArchive
*/ */
function xr_uploadToArchive($input) function xr_uploadToArchive($input)
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php'; require_once dirname(__FILE__).'/../Transport.php';
$tr =& new Transport($this->dbc, $this, $this->config); $tr =& new Transport($this);
$res = $tr->uploadToArchive($r['gunid'], $r['sessid']); $res = $tr->uploadToArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2548,6 +3129,7 @@ class XR_LocStor extends LocStor{
} }
/** /**
* OBSOLETE
* Starts download audioclip from remote archive * Starts download audioclip from remote archive
* *
* The XML-RPC name of this method is "locstor.downloadFromArchive". * The XML-RPC name of this method is "locstor.downloadFromArchive".
@ -2577,14 +3159,14 @@ class XR_LocStor extends LocStor{
* *
* @param input XMLRPC struct * @param input XMLRPC struct
* @return XMLRPC struct * @return XMLRPC struct
* @see Pref::downloadFromArchive * @see Transport::downloadFromArchive
*/ */
function xr_downloadFromArchive($input) function xr_downloadFromArchive($input)
{ {
list($ok, $r) = $this->_xr_getPars($input); list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r; if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php'; require_once dirname(__FILE__).'/../Transport.php';
$tr =& new Transport($this->dbc, $this, $this->config); $tr =& new Transport($this);
$res = $tr->downloadFromArchive($r['gunid'], $r['sessid']); $res = $tr->downloadFromArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){ if(PEAR::isError($res)){
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
@ -2596,64 +3178,7 @@ class XR_LocStor extends LocStor{
return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res)));
} }
/** /* ================================================ methods for debugging */
* Checking status of transported file
*
* The XML-RPC name of this method is "locstor.getTransportInfo".
*
* The input parameters are an XML-RPC struct with the following
* fields:
* <ul>
* <li> sessid : string - session id </li>
* <li> trtok : string - transport token</li>
* </ul>
*
* On success, returns a XML-RPC struct with the following fields:
* <ul>
* <li>trtype: string - audioclip | playlist</li>
* <li>direction: string - up | down</li>
* <li>status: boolean - true if file have been
* succesfully transported</li>
* <li>expectedsize: int - expected size</li>
* <li>realsize: int - size of transported file</li>
* <li>expectedsum: string - expected checksum</li>
* <li>realsum: string - checksum of transported file</li>
* </ul>
*
* On errors, returns an XML-RPC error response.
* The possible error codes and error message are:
* <ul>
* <li> 3 - Incorrect parameters passed to method:
* Wanted ... , got ... at param </li>
* <li> 801 - wrong 1st parameter, struct expected.</li>
* <li> 805 - xr_getTransportInfo:
* &lt;message from lower layer&gt; </li>
* <li> 848 - invalid session id.</li>
* <li> 872 - invalid tranport token.</li>
* </ul>
*
* @param input XMLRPC struct
* @return XMLRPC struct
* @see Pref::getTransportInfo
*/
function xr_getTransportInfo($input)
{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php';
$tr =& new Transport($this->dbc, $this, $this->config);
$res = $tr->getTransportInfo($r['trtok'], $r['sessid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
$ec = ($ec0 == GBERR_SESS || $ec0 == TRERR_TOK ? 800+$ec0 : 805 );
return new XML_RPC_Response(0, $ec,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
);
}
return new XML_RPC_Response(XML_RPC_encode($res));
}
/* ------------------------------------------------ methods for debugging */
/** /**
* Reset storageServer for debugging. * Reset storageServer for debugging.
* *
@ -2768,7 +3293,7 @@ class XR_LocStor extends LocStor{
))); )));
} }
/* ---------------------------------------------------- "private" methods */ /* ==================================================== "private" methods */
/** /**
* Check and convert struct of parameters * Check and convert struct of parameters
* *

View file

@ -306,13 +306,18 @@ importPlaylist() {
unset URL unset URL
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
echo $TOKEN echo $TOKEN
echo -n "# curl (PUT): " echo -n "# curl (PUT $URL): "
curl -C 0 -T $ARCHIVE $URL || { ERN=$?; echo "curl error"; exit $ERN; } curl -C 0 -T $ARCHIVE $URL || { ERN=$?; echo "curl error"; exit $ERN; }
echo "status: $?" echo "status: $?"
echo -n "# importPlaylistClose (${TOKEN}): " echo -n "# importPlaylistClose (${TOKEN}): "
RES=`$XR_CLI importPlaylistClose $TOKEN` || \ RES=`$XR_CLI importPlaylistClose $TOKEN` || \
{ ERN=$?; echo $RES; exit $ERN; } { ERN=$?; echo $RES; exit $ERN; }
echo $RES echo $RES
GUNID=0000000000010001; existsAudioClip;
GUNID=0000000000010002; existsAudioClip;
GUNID=0000000000010003; existsAudioClip;
PLID=0000000000000001; existsPlaylist;
PLID=0000000000000003; existsPlaylist;
} }
prefTest() { prefTest() {

View file

@ -157,9 +157,21 @@ $methods = array(
'loadGroupPref' => 'Read group preference record.', 'loadGroupPref' => 'Read group preference record.',
'saveGroupPref' => 'Delete user preference record.', 'saveGroupPref' => 'Delete user preference record.',
'uploadToArchive' => 'Starts upload audioclip to remote archive.', 'getTransportInfo' => 'Common "check" method for transports',
'downloadFromArchive' => 'Starts download audioclip from remote archive.', 'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state',
'getTransportInfo' => 'Checking status of transported file.', 'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub',
'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub',
'startHubInitiatedTransfer' => 'Start of download initiated by hub',
'uploadAudioClip2Hub' => 'Common "check" method for transports',
'downloadAudioClipFromHub' => 'Start download of audioClip/webstream from hub to local storageServer',
'uploadPlaylist2Hub' => 'Start upload of playlist from local storageServer to hub',
'downloadPlaylistFromHub' => 'Start download of playlist from hub to local storageServer',
'globalSearch' => 'Start search job on network hub',
'getSearchResults' => 'Get results from search job on network hub',
# 'uploadToArchive' => 'Starts upload audioclip to remote archive.',
# 'downloadFromArchive' => 'Starts download audioclip from remote archive.',
# 'getTransportInfo' => 'Checking status of transported file.',
); );
$defs = array(); $defs = array();

View file

@ -182,13 +182,36 @@ $infos = array(
"saveGroupPref" => array('m'=>"locstor.saveGroupPref", "saveGroupPref" => array('m'=>"locstor.saveGroupPref",
'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'), 'p'=>array('sessid', 'group', 'key', 'value'), 'r'=>'status'),
"getTransportInfo" => array('m'=>"locstor.getTransportInfo",
'p'=>array('trtok'),
'r'=>array('state', 'realsize', 'expectedsize', 'realchsum', 'expectedchsum')),
"turnOnOffTransports" => array('m'=>"locstor.turnOnOffTransports",
'p'=>array('sessid', 'onOff'), 'r'=>array('state')),
"uploadFile2Hub" => array('m'=>"locstor.uploadFile2Hub",
'p'=>array('sessid', 'filePath'), 'r'=>array('trtok')),
"getHubInitiatedTransfers" => array('m'=>"locstor.getHubInitiatedTransfers",
'p'=>array('sessid'), 'r'=>array()),
"startHubInitiatedTransfer" => array('m'=>"locstor.startHubInitiatedTransfer",
'p'=>array('trtok'), 'r'=>array()),
"uploadAudioClip2Hub" => array('m'=>"locstor.uploadAudioClip2Hub",
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
"downloadAudioClipFromHub" => array('m'=>"locstor.downloadAudioClipFromHub",
'p'=>array('sessid', 'gunid'), 'r'=>array('trtok')),
"uploadPlaylist2Hub" => array('m'=>"locstor.uploadPlaylist2Hub",
'p'=>array('sessid', 'plid', 'withContent'), 'r'=>array('trtok')),
"downloadPlaylistFromHub" => array('m'=>"locstor.downloadPlaylistFromHub",
'p'=>array('plid', 'withContent'), 'r'=>array('trtok')),
"globalSearch" => array('m'=>"locstor.globalSearch",
'p'=>array('sessid', 'criteria'), 'r'=>array('trtok')),
"getSearchResults" => array('m'=>"locstor.getSearchResults",
'p'=>array('trtok'), 'r'=>array()),
/*
"uploadToArchive" => array('m'=>"locstor.uploadToArchive", "uploadToArchive" => array('m'=>"locstor.uploadToArchive",
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'), 'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
"downloadFromArchive" => array('m'=>"locstor.downloadFromArchive", "downloadFromArchive" => array('m'=>"locstor.downloadFromArchive",
'p'=>array('sessid', 'gunid'), 'r'=>'trtok'), 'p'=>array('sessid', 'gunid'), 'r'=>'trtok'),
"getTransportInfo" => array('m'=>"locstor.getTransportInfo", */
'p'=>array('sessid', 'trtok'),
'r'=>array('state', 'realsize', 'realsum', 'expectedsize', 'expectedsum')),
"openPut" => array('m'=>"locstor.openPut", 'p'=>array()), "openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()), "closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
@ -197,6 +220,7 @@ $infos = array(
switch($method){ switch($method){
case"searchMetadata": case"searchMetadata":
case"createBackupOpen":
$parr = array( $parr = array(
'sessid'=>$pars[0], 'sessid'=>$pars[0],
'criteria'=>array( 'criteria'=>array(