*
  • version : string
  • * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Subjects::getVersion */ // public function xr_getVersion($input) // { // list($ok, $r) = XR_LocStor::xr_getParams($input); // if (!$ok) { // return $r; // } // $res = $this->getVersion(); // if (PEAR::isError($res)) { // return new XML_RPC_Response(0, 805, // "xr_getVersion: ".$res->getMessage(). // " ".$res->getUserInfo() // ); // } // return new XML_RPC_Response( // XML_RPC_encode(array('version'=>$res)) // ); // } public function xr_getVersion() { // list($ok, $r) = XR_LocStor::xr_getParams($input); // if (!$ok) { // return $r; // } $res = $this->getVersion(); // if (PEAR::isError($res)) { // return new XML_RPC_Response(0, 805, // "xr_getVersion: ".$res->getMessage(). // " ".$res->getUserInfo() // ); // } return new XML_RPC_Response( XML_RPC_encode(array('version'=>$res)) ); } /* ------------------------------------------------------- authentication */ /** * Checks the login name and password of the user and return * true if login data are correct, othervise return false. * * The XML-RPC name of this method is "locstor.authenticate". * * Input parameters: XML-RPC struct with the following fields: * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Subjects::authenticate */ public function xr_authenticate($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->authenticate($r['login'], $r['pass']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 804, "xr_authenticate: ".$res->getMessage(). " ".$res->getUserInfo() ); } $retval = ($res !== FALSE); return new XML_RPC_Response( XML_RPC_encode(array('authenticate'=>$retval)) ); } /** * Checks the login name and password of the user. If the login is * correct, a new session ID string is generated, to be used in all * subsequent XML-RPC calls as the "sessid" field of the * parameters. * * The XML-RPC name of this method is "locstor.login". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Alib::login */ public function xr_login($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = Alib::Login($r['login'], $r['pass']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 804, "xr_login: ".$res->getMessage(). " ".$res->getUserInfo() ); } if ($res === FALSE) { return new XML_RPC_Response(0, 802, "xr_login: login failed - incorrect username or password." ); } else { return new XML_RPC_Response(XML_RPC_encode(array('sessid'=>$res))); } } /** * Logout, destroy session and return status. * If session is not valid error message is returned. * * The XML-RPC name of this method is "locstor.logout". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response */ public function xr_logout($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = Alib::Logout($r['sessid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 803, "xr_logout: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /* ---------------------------------------------------------------- store */ /** * Open writable URL for store new AudioClip or replace existing one. * Writing to returned URL is possible using HTTP PUT method * (as e.g. curl -T <filename> command does) * * The XML-RPC name of this method is "locstor.storeAudioClipOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::storeAudioClipOpen */ public function xr_storeAudioClipOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->storeAudioClipOpen($r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['chsum']); if (PEAR::isError($res)) { $code = 805; if ($res->getCode() == 888) { $code = 888; } return new XML_RPC_Response(0, $code, "xr_storeAudioClipOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Close writable URL for store new AudioClip or replace existing one. * * The XML-RPC name of this method is "locstor.storeAudioClipClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::storeAudioClipClose */ public function xr_storeAudioClipClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->storeAudioClipClose($r['sessid'], $r['token']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_TOKEN ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_storeAudioClipClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); } /** * Store audio stream identified by URL - no raw audio data * * The XML-RPC name of this method is "locstor.storeWebstream". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::storeWebstream */ public function xr_storeWebstream($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->storeWebstream( $r['sessid'], $r['gunid'], $r['metadata'], $r['fname'], $r['url'] ); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_storeWebstream: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); } /* ------------------------------------------------ access raw audio data */ /** * Make access to audio clip. * * The XML-RPC name of this method is "locstor.accessRawAudioData". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::accessRawAudioData */ public function xr_accessRawAudioData($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->accessRawAudioData($r['sessid'], $r['gunid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_accessRawAudioData: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Release access to audio clip * * The XML-RPC name of this method is "locstor.releaseRawAudioData". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::releaseRawAudioData */ public function xr_releaseRawAudioData($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->releaseRawAudioData(NULL, $r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_releaseRawAudioData: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /* ---------------------------------------------- download raw audio data */ /** * Create downlodable URL for stored file * * The XML-RPC name of this method is "locstor.downloadRawAudioDataOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::downloadRawAudioDataOpen */ public function xr_downloadRawAudioDataOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->downloadRawAudioDataOpen($r['sessid'], $r['gunid']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_downloadRawAudioDataOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Delete downlodable URL with media file. * * The XML-RPC name of this method is "locstor.downloadRawAudioDataClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::downloadRawAudioDataClose */ public function xr_downloadRawAudioDataClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->downloadRawAudioDataClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_downloadRawAudioDataClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); } /* ---------------------------------------------------- download metadata */ /** * Create downlodable URL for metadata part of stored file * * The XML-RPC name of this method is "locstor.downloadMetadataOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::downloadRawAudioDataOpen */ public function xr_downloadMetadataOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } #$this->debugLog("{$r['sessid']}, {$r['gunid']}"); $res = $this->downloadMetadataOpen($r['sessid'], $r['gunid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_downloadMetadataOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Delete downlodable URL with metadata. * * The XML-RPC name of this method is "locstor.downloadMetadataClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::downloadRawAudioDataClose */ public function xr_downloadMetadataClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->downloadMetadataClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_downloadMetadataClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('gunid'=>$res))); } /* --------------------------------------------------------------- delete */ /** * Delete existing audio clip - DISABLED now! * * The XML-RPC name of this method is "locstor.deleteAudioClip". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::deleteAudioClip */ public function xr_deleteAudioClip($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } if (!isset($r['forced'])) { $r['forced']=FALSE; } $res = $this->deleteAudioClip($r['sessid'], $r['gunid'], $r['forced']); if (!$r['forced']) { return new XML_RPC_Response(0, 805, "xr_deleteAudioClip: method disabled"); } if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_deleteAudioClip: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /*====================================================== playlist methods */ /** * Create a new Playlist metafile. * * The XML-RPC name of this method is "locstor.createPlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::createPlaylist */ public function xr_createPlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->createPlaylist($r['sessid'], $r['plid'], $r['fname']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_createPlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); } /** * Open a Playlist metafile for editing. * Open readable URL and mark file as beeing edited. * * The XML-RPC name of this method is "locstor.editPlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::editPlaylist */ public function xr_editPlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->editPlaylist($r['sessid'], $r['plid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_editPlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Store a new Playlist metafile in place of the old one. * * The XML-RPC name of this method is "locstor.savePlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::savePlaylist */ public function xr_savePlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->savePlaylist($r['sessid'], $r['token'], $r['newPlaylist']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_savePlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); } /** * RollBack playlist changes to the locked state * * The XML-RPC name of this method is "locstor.revertEditedPlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::revertEditedPlaylist */ public function xr_revertEditedPlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->revertEditedPlaylist($r['token'], $r['sessid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_revertEditedPlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); } /* ------------------------------------------------------- delete playlist*/ /** * Delete a Playlist metafile - DISABLED now! * * The XML-RPC name of this method is "locstor.deletePlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::deletePlaylist */ public function xr_deletePlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } if (!isset($r['forced'])) { $r['forced']=FALSE; } $res = $this->deletePlaylist($r['sessid'], $r['plid'], $r['forced']); if (! $r['forced']) { return new XML_RPC_Response(0, 805,"xr_deletePlaylist: method disabled"); } if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_FILENEX ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_deletePlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /* ------------------------------------------------------- access playlist*/ /** * Access (read) a Playlist metafile. * * The XML-RPC name of this method is "locstor.accessPlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns an XML-RPC struct with the following fields: * * * The content field contains a struct for each playlist * element contained in the playlist. For audio clips, this struct is * of type {url, token}; for sub-playlists, it is of type * {url, token, chsum, content}. * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::accessPlaylist */ public function xr_accessPlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } if (!isset($r['recursive']) || is_null($r['recursive'])) { $r['recursive']=FALSE; } $res = $this->accessPlaylist($r['sessid'], $r['plid'], (boolean)$r['recursive']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_NOTF ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_accessPlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Release the resources obtained earlier by accessPlaylist(). * * The XML-RPC name of this method is "locstor.releasePlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::releasePlaylist */ public function xr_releasePlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } //if (!isset($r['recursive']) || is_null($r['recursive'])) $r['recursive']=FALSE; $res = $this->releasePlaylist(NULL, $r['token'], TRUE); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_releasePlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('plid'=>$res))); } /* -------------------------------------------------------- playlist info */ /** * Check whether a Playlist metafile with the given playlist ID exists. * * The XML-RPC name of this method is "locstor.existsPlaylist". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::existsPlaylist */ public function xr_existsPlaylist($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->existsPlaylist($r['sessid'], $r['plid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_existsPlaylist: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); } /** * Check whether a Playlist metafile with the given playlist ID * is available for editing, i.e., exists and is not marked as * beeing edited. * * The XML-RPC name of this method is "locstor.playlistIsAvailable". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::playlistIsAvailable */ public function xr_playlistIsAvailable($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->playlistIsAvailable($r['sessid'], $r['plid'], TRUE); $ownerId = ($res === TRUE ? NULL : $res); $ownerLogin = (is_null($ownerId) ? NULL : Subjects::GetSubjName($ownerId)); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_playlistIsAvailable: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'available' => ($res === TRUE), 'ownerid' => $ownerId, 'ownerlogin' => $ownerLogin, ))); } /* ------------------------------------------------------ export playlist */ /** * Create a tarfile with playlist export - playlist and all matching * sub-playlists and media files (if desired) * * The XML-RPC name of this method is "locstor.exportPlaylistOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::exportPlaylistOpen */ public function xr_exportPlaylistOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } if (!isset($r['standalone']) || empty($r['standalone'])) { $r['standalone']=FALSE; } $res = $this->exportPlaylistOpen( $r['sessid'], $r['plids'], $r['type'], $r['standalone'] ); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_exportPlaylistOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'url' => $res['url'], 'token' => $res['token'], ))); } /** * Close playlist export previously opened by the exportPlaylistOpen method * * The XML-RPC name of this method is "locstor.exportPlaylistClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::exportPlaylistClose */ public function xr_exportPlaylistClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->exportPlaylistClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_exportPlaylistClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>TRUE))); } /* ------------------------------------------------------ import playlist */ /** * Open writable URL for import playlist in LS Archive format * * The XML-RPC name of this method is "locstor.importPlaylistOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::importPlaylistOpen */ public function xr_importPlaylistOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->importPlaylistOpen($r['sessid'], $r['chsum']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_importPlaylistOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'url'=>$res['url'], 'token'=>$res['token'], ))); } /** * Open writable URL for import playlist in LS Archive format * * The XML-RPC name of this method is "locstor.importPlaylistClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::importPlaylistClose */ public function xr_importPlaylistClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->importPlaylistClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_importPlaylistClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'gunid'=>$res, ))); } /* ---------------------------------------------- render playlist to file */ /** * Render playlist to ogg file (open handle) * * The XML-RPC name of this method is "locstor.renderPlaylistToFileOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToFileOpen */ public function xr_renderPlaylistToFileOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToFileOpen($r['sessid'], $r['plid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToFileOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'token'=>$res['token'], ))); } /** * Render playlist to ogg file (check results) * * The XML-RPC name of this method is "locstor.renderPlaylistToFileCheck". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToFileCheck */ public function xr_renderPlaylistToFileCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToFileCheck($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToFileCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'url'=>$res['url'], 'status'=>$res['status'], ))); } /** * Render playlist to ogg file (close handle) * * The XML-RPC name of this method is "locstor.renderPlaylistToFileClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToFileClose */ public function xr_renderPlaylistToFileClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToFileClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToFileClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'status'=>$res['status'], ))); } /* ------------------------------------------- render playlist to storage */ /** * Render playlist to storage media clip (open handle) * * The XML-RPC name of this method is "locstor.renderPlaylistToStorageOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToStorageOpen */ public function xr_renderPlaylistToStorageOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToStorageOpen($r['sessid'], $r['plid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToStorageOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'token'=>$res['token'], ))); } /** * Render playlist to storage media clip (check results) * * The XML-RPC name of this method is "locstor.renderPlaylistToStorageCheck". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToStorageCheck */ public function xr_renderPlaylistToStorageCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToStorageCheck($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToStorageCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'status'=>$res['status'], 'gunid'=>$res['gunid'], ))); } /* ----------------------------------------------- render playlist to RSS */ /** * Render playlist to RSS file (open handle) * * The XML-RPC name of this method is "locstor.renderPlaylistToRSSOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToRSSOpen */ public function xr_renderPlaylistToRSSOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToRSSOpen($r['sessid'], $r['plid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToRSSOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'token'=>$res['token'], ))); } /** * Render playlist to RSS file (check results) * * The XML-RPC name of this method is "locstor.renderPlaylistToRSSCheck". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToRSSCheck */ public function xr_renderPlaylistToRSSCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToRSSCheck($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToRSSCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'url'=>$res['url'], 'status'=>$res['status'], ))); } /** * Render playlist to RSS file (close handle) * * The XML-RPC name of this method is "locstor.renderPlaylistToRSSClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::renderPlaylistToRSSClose */ public function xr_renderPlaylistToRSSClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->renderPlaylistToRSSClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_renderPlaylistToRSSClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'status'=>$res['status'], ))); } /*==================================================storage admin methods */ /* ------------------------------------------------------- backup methods */ /** * Create backup of storage (open handle) * * The XML-RPC name of this method is "locstor.createBackupOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::createBackupOpen */ public function xr_createBackupOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } # return new XML_RPC_Response(XML_RPC_encode(var_export($this, TRUE))); $res = $this->createBackupOpen($r['sessid'], $r['criteria']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_createBackupOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'token'=>$res['token'], ))); } /** * Create backup of storage (check results) * * The XML-RPC name of this method is "locstor.createBackupCheck". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::createBackupCheck */ //
  • 854 - backup process fault
  • public function xr_createBackupCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->createBackupCheck($r['token']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_BGERR ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_createBackupCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Create backup of storage (list results) * * The XML-RPC name of this method is "locstor.createBackupList". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC array of struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::createBackupCheck */ //
  • 854 - backup process fault
  • public function xr_createBackupList($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } if (!isset($r['stat']) || is_null($r['stat'])) { $r['stat']=''; } $res = $this->createBackupList($r['stat']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_BGERR ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_createBackupCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Create backup of storage (close handle) * * The XML-RPC name of this method is "locstor.createBackupClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::createBackupClose */ public function xr_createBackupClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->createBackupClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_createBackupClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'status'=>$res['status'], ))); } /* ------------------------------------------------------ restore methods */ /** * Open restore a backup file * * The XML-RPC name of this method is "locstor.restoreBackupOpen". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::restoreBackupOpen */ public function xr_restoreBackupOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->restoreBackupOpen($r['sessid'], $r['chsum']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_restoreBackupOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); } unset($res['fname']); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Close writable URL for restore a backup file and start the restore * process * * The XML-RPC name of this method is "locstor.restoreBackupClosePut". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::restoreBackupClosePut */ public function xr_restoreBackupClosePut($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->restoreBackupClosePut($r['sessid'], $r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_restoreBackupClosePut: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Check the state of restore procedure * * The XML-RPC name of this method is "locstor.restoreBackupCheck". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::restoreBackupCheck */ public function xr_restoreBackupCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->restoreBackupCheck($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_restoreBackupCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); } # return new XML_RPC_Response(XML_RPC_encode(array( # 'status'=>$res, # ))); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Close the restore process * * The XML-RPC name of this method is "locstor.restoreBackupClose". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::restoreBackupClose */ public function xr_restoreBackupClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->restoreBackupClose($r['token']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_restoreBackupClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } # return new XML_RPC_Response(XML_RPC_encode(array( # 'gunid'=>$res, # ))); return new XML_RPC_Response(XML_RPC_encode($res)); } /*========================================================== info methods */ /** * Check if audio clip exists and return TRUE/FALSE * * The XML-RPC name of this method is "locstor.existsAudioClip". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::existsAudioClip */ public function xr_existsAudioClip($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } #$this->debugLog(join(', ', $r)); $res = $this->existsAudioClip($r['sessid'], $r['gunid']); #$this->debugLog($res); if (PEAR::isError($res)) return new XML_RPC_Response(0, 805, "xr_existsAudioClip: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode(array('exists'=>$res))); } /*====================================================== metadata methods */ /** * Return all file's metadata as XML string * * The XML-RPC name of this method is "locstor.getAudioClip". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::getAudioClip */ public function xr_getAudioClip($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->getAudioClip($r['sessid'], $r['gunid']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('metadata'=>$res))); } /** * Update existing audio clip metadata * * The XML-RPC name of this method is "locstor.updateAudioClipMetadata". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::updateAudioClipMetadata */ public function xr_updateAudioClipMetadata($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->updateAudioClipMetadata( $r['sessid'], $r['gunid'], $r['metadata'] ); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_updateAudioClip: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /** * Search in local metadata database * * The XML-RPC name of this method is "locstor.searchMetadata". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC array of structs with fields: * * (cnt value may be greater than size of result array - see limit param) * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::searchMetadata * @see BasicStor::localSearch */ public function xr_searchMetadata($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->searchMetadata($r['sessid'], $r['criteria']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_searchAudioClip: ".$res->getMessage(). " ".$res->getUserInfo() ); } # return new XML_RPC_Response(XML_RPC_encode($res)); $xv = new XML_RPC_Value; $xv->addStruct(array( 'cnt' => XML_RPC_encode($res['cnt']), 'results' => (count($res['results'])==0 ? new XML_RPC_Value(array(), 'array') : XML_RPC_encode($res['results']) ), )); return new XML_RPC_Response($xv); } /** * Return values of specified metadata category * * The XML-RPC name of this method is "locstor.browseCategory". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::browseCategory */ public function xr_browseCategory($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->browseCategory( $r['category'], $r['criteria'], $r['sessid'] ); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } $xv = new XML_RPC_Value; $xv->addStruct(array( 'cnt' => XML_RPC_encode($res['cnt']), 'results' => (count($res['results'])==0 ? new XML_RPC_Value(array(), 'array') : XML_RPC_encode($res['results']) ), )); return new XML_RPC_Response($xv); } /* ============================================== methods for preferences */ /** * Load user preference value * * The XML-RPC name of this method is "locstor.loadPref". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Pref::loadPref */ public function xr_loadPref($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); $res = $pr->loadPref($r['sessid'], $r['key']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res))); } /** * Save user preference value * * The XML-RPC name of this method is "locstor.savePref". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Pref::savePref */ public function xr_savePref($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); $res = $pr->savePref($r['sessid'], $r['key'], $r['value']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /** * Delete user preference record * * The XML-RPC name of this method is "locstor.delPref". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Pref::delPref */ public function xr_delPref($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); $res = $pr->delPref($r['sessid'], $r['key']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0 == GBERR_SESS || $ec0 == GBERR_PREF ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /** * Read group preference record * * The XML-RPC name of this method is "locstor.loadGroupPref". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Pref::loadGroupPref */ public function xr_loadGroupPref($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); $res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ( $ec0 == GBERR_SESS || $ec0 == GBERR_PREF || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('value'=>$res))); } /** * Save group preference record * * The XML-RPC name of this method is "locstor.saveGroupPref". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Pref::saveGroupPref */ public function xr_saveGroupPref($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); $res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ($ec0==GBERR_SESS || $ec0==ALIBERR_NOTGR ? 800+$ec0 : 805 ); return new XML_RPC_Response(0, $ec, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res))); } /* =============================== 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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::getTransportInfo */ public function xr_getTransportInfo($input) { list($ok, $r) = XR_LocStor::xr_getParams($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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::turnOnOffTransports */ public function xr_turnOnOffTransports($input) { list($ok, $r) = XR_LocStor::xr_getParams($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))); } /** * Pause, resume or cancel transport * * The XML-RPC name of this method is "locstor.doTransportAction". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::doTransportAction */ public function xr_doTransportAction($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once('../Transport.php'); $tr = new Transport($this); $res = $tr->doTransportAction($r['trtok'], $r['action']); 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_doTransportAction: ".$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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::uploadFile2Hub */ public function xr_uploadFile2Hub($input) { list($ok, $r) = XR_LocStor::xr_getParams($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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::getHubInitiatedTransfers */ public function xr_getHubInitiatedTransfers($input) { list($ok, $r) = XR_LocStor::xr_getParams($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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::startHubInitiatedTransfer */ public function xr_startHubInitiatedTransfer($input) { list($ok, $r) = XR_LocStor::xr_getParams($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 */ /** * Start upload of audioclip or playlist from local storageServer to hub * * The XML-RPC name of this method is "locstor.upload2Hub". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::upload2Hub */ public function xr_upload2Hub($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } require_once('../Transport.php'); $tr = new Transport($this); $res = $tr->upload2Hub($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_upload2Hub: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); } /** * Start download of audioclip or playlist from hub to local storageServer * * The XML-RPC name of this method is "locstor.downloadFromHub". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::downloadFromHub */ public function xr_downloadFromHub($input) { list($ok, $par) = XR_LocStor::xr_getParams($input); if (!$ok) { return $par; } require_once('../Transport.php'); $tr = new Transport($this); $uid = Alib::GetSessUserId($par['sessid']); $res = $tr->downloadFromHub($uid, $par['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_downloadFromHub: ".$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: * * * On success, returns a XML-RPC struct with the following fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::globalSearch */ // public function xr_globalSearch($input) // { // list($ok, $r) = XR_LocStor::xr_getParams($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. * (returns error if not finished) * * The XML-RPC name of this method is "locstor.getSearchResults". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC array of structs with fields: * * (cnt value may be greater than size of result array - see limit param) * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::getSearchResults */ // public function xr_getSearchResults($input) // { // list($ok, $r) = XR_LocStor::xr_getParams($input); // if (!$ok) { // return $r; // } // require_once('../Transport.php'); // $tr = new Transport($this); // $res = $tr->getSearchResults($r['trtok']); // if (PEAR::isError($res)) { // $ec0 = intval($res->getCode()); // $ec = ( // $ec0 == GBERR_SESS || $ec0 == TRERR_TOK || $ec0 == TRERR_NOTFIN // ? 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 * * The XML-RPC name of this method is "locstor.uploadToArchive". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::uploadToArchive */ // public function xr_uploadToArchive($input) // { // list($ok, $r) = XR_LocStor::xr_getParams($input); // if (!$ok) { // return $r; // } // require_once(dirname(__FILE__).'/../Transport.php'); // $tr = new Transport($this); // $res = $tr->uploadToArchive($r['gunid'], $r['sessid']); // if (PEAR::isError($res)) { // $ec0 = intval($res->getCode()); // $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); // return new XML_RPC_Response(0, $ec, // "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() // ); // } // return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); // } /** * OBSOLETE * Starts download audioclip from remote archive * * The XML-RPC name of this method is "locstor.downloadFromArchive". * * The input parameters are an XML-RPC struct with the following * fields: * * * On success, returns a XML-RPC struct with single field: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see Transport::downloadFromArchive */ // public function xr_downloadFromArchive($input) // { // list($ok, $r) = XR_LocStor::xr_getParams($input); // if (!$ok) { // return $r; // } // require_once(dirname(__FILE__).'/../Transport.php'); // $tr = new Transport($this); // $res = $tr->downloadFromArchive($r['gunid'], $r['sessid']); // if (PEAR::isError($res)) { // $ec0 = intval($res->getCode()); // $ec = ($ec0 == GBERR_SESS ? 800+$ec0 : 805 ); // return new XML_RPC_Response(0, $ec, // "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() // ); // } // return new XML_RPC_Response(XML_RPC_encode(array('trtok'=>$res))); // } /* ================================================ methods for debugging */ /** * Reset storageServer for debugging. * * The XML-RPC name of this method is "locstor.resetStorage". * * The input parameters are an empty XML-RPC struct, * or struct with the following optional fields: * * * On success, returns the same result as searchMetadata with filetype * 'all' and no conditions, ordered by filetype and dc:title * i.e. XML-RPC array of structs with fields: * * * On errors, returns an XML-RPC error response. * The possible error codes and error message are: * * * @param XML_RPC_Message $input * @return XML_RPC_Response * @see LocStor::getAudioClip */ public function xr_resetStorage($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->resetStorage( isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE, !(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE) ); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Test XMLRPC - strupper and return given string, * also return loginname of logged user * - debug method only * * @param XML_RPC_Message $input * @return XML_RPC_Response */ public function xr_test($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } return new XML_RPC_Response(XML_RPC_encode(array( 'str'=>strtoupper($r['teststring']), 'login' => Alib::GetSessLogin($r['sessid']), 'sessid'=>$r['sessid'] ))); } /** * Open writable URL for put method - debug method only * * @param XML_RPC_Message $input * @return XML_RPC_Response */ public function xr_openPut($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->bsOpenPut(); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Close writable URL - debug method only * * @param XML_RPC_Message $input * @return XML_RPC_Response */ public function xr_closePut($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->bsClosePut($r['token'], $r['chsum']); if (PEAR::isError($res)) { return new XML_RPC_Response(0, 805, "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode(array( 'fname'=>$res['fname'], 'owner'=>$res['owner'], ))); } /** * Simple ping method - return string * * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_ping($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = date("Ymd-H:i:s")." -- reply from remote node: {$r['par']}"; return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_uploadOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->uploadOpen($r['sessid'], $r['chsum']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_uploadOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * Check state of file upload * * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_uploadCheck($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->uploadCheck($r['token']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_uploadCheck: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_uploadClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->uploadClose($r['token'], $r['trtype'], $r['pars']); if (PEAR::isError($res)) { $code = 803; // Special case for duplicate file - give back // different error code so we can display nice user message. if ($res->getCode() == GBERR_GUNID) { $code = 888; } return new XML_RPC_Response(0, $code, "xr_uploadClose: ".$res->getMessage(). " ".$res->getUserInfo() ); } return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_downloadOpen($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->downloadOpen($r['sessid'], $r['trtype'], $r['pars']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_downloadOpen: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_downloadClose($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->downloadClose($r['token'], $r['trtype']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_downloadClose: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_prepareHubInitiatedTransfer($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } foreach (array('trtype'=>NULL, 'direction'=>'up', 'pars'=>array()) as $k => $dv) { if (!isset($r[$k])) { $r[$k] = $dv; } } $res = $this->prepareHubInitiatedTransfer( $r['target'], $r['trtype'], $r['direction'], $r['pars']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_prepareHubInitiatedTransfer: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_listHubInitiatedTransfers($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } foreach (array('target'=>NULL, 'direction'=>NULL, 'trtok'=>NULL) as $k=>$dv) { if (!isset($r[$k])) { $r[$k] = $dv; } } $res = $this->listHubInitiatedTransfers( $r['target'], $r['direction'], $r['trtok']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_listHubInitiatedTransfers: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /** * @param XML_RPC_Message $input * @return XML_RPC_Response */ function xr_setHubInitiatedTransfer($input) { list($ok, $r) = XR_LocStor::xr_getParams($input); if (!$ok) { return $r; } $res = $this->setHubInitiatedTransfer( $r['target'], $r['trtok'], $r['state']); if (PEAR::isError($res)) return new XML_RPC_Response(0, 803, "xr_setHubInitiatedTransfer: ".$res->getMessage(). " ".$res->getUserInfo() ); return new XML_RPC_Response(XML_RPC_encode($res)); } /* ==================================================== "private" methods */ /** * Check and convert struct of parameters * * @param XML_RPC_Message $input * @return array * Array of two items: first item is boolean, indicating * successful decode. * On success, the second param is an array of values. * On failure, the second param is an XML_RPC_Response object. */ protected static function xr_getParams($input) { $p = $input->getParam(0); if (isset($p) && ($p->scalartyp()=="struct")) { $r = XML_RPC_decode($p); return array(TRUE, $r); } else { return array(FALSE, new XML_RPC_Response(0, 801, "wrong 1st parameter, struct expected." )); } } } // class XR_LocStor ?>