Changes according to note 595 in:
http://bugs.campware.org/view.php?id=494
This commit is contained in:
parent
dff985ecb2
commit
70c4802b25
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.13 $
|
Version : $Revision: 1.14 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -36,6 +36,7 @@ define('GBERR_NONE', 45);
|
||||||
define('GBERR_AOBJNEX', 46);
|
define('GBERR_AOBJNEX', 46);
|
||||||
define('GBERR_NOTF', 47);
|
define('GBERR_NOTF', 47);
|
||||||
define('GBERR_SESS', 48);
|
define('GBERR_SESS', 48);
|
||||||
|
define('GBERR_PREF', 49);
|
||||||
|
|
||||||
define('GBERR_NOTIMPL', 50);
|
define('GBERR_NOTIMPL', 50);
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ require_once "StoredFile.php";
|
||||||
* Core of LiveSupport file storage module
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.13 $
|
* @version $Revision: 1.14 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Prefs.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Prefs.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -69,6 +69,10 @@ class Prefs{
|
||||||
}
|
}
|
||||||
$val = $this->readVal($subjid, $key);
|
$val = $this->readVal($subjid, $key);
|
||||||
if(PEAR::isError($val)) return $val;
|
if(PEAR::isError($val)) return $val;
|
||||||
|
if($val === FALSE){
|
||||||
|
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
|
||||||
|
GBERR_PREF);
|
||||||
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,15 +92,39 @@ class Prefs{
|
||||||
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
||||||
GBERR_SESS);
|
GBERR_SESS);
|
||||||
}
|
}
|
||||||
$r = $this->delete($subjid, $key);
|
$r = $this->update($subjid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
if($value != ''){
|
if($r === FALSE){
|
||||||
$r = $this->insert($subjid, $key, $value);
|
$r = $this->insert($subjid, $key, $value);
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete preference record by session id
|
||||||
|
*
|
||||||
|
* @param sessid string, session id
|
||||||
|
* @param key string, preference key
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function delPref($sessid, $key)
|
||||||
|
{
|
||||||
|
$subjid = $this->gb->getSessUserId($sessid);
|
||||||
|
if(PEAR::isError($subjid)) return $subjid;
|
||||||
|
if(is_null($subjid)){
|
||||||
|
return PEAR::raiseError("Prefs::loadPref: invalid session id",
|
||||||
|
GBERR_SESS);
|
||||||
|
}
|
||||||
|
$r = $this->delete($subjid, $key);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
|
if($r === FALSE){
|
||||||
|
return PEAR::raiseError("Prefs::delPref: invalid preference key",
|
||||||
|
GBERR_PREF);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===================================================== gb level methods */
|
/* ===================================================== gb level methods */
|
||||||
/**
|
/**
|
||||||
* Insert of new preference record
|
* Insert of new preference record
|
||||||
|
@ -134,7 +162,7 @@ class Prefs{
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($val)) return $val;
|
if(PEAR::isError($val)) return $val;
|
||||||
if(is_null($val)) return '';
|
if(is_null($val)) return FALSE;
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +182,7 @@ class Prefs{
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
|
if($this->dbc->affectedRows()<1) return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +200,7 @@ class Prefs{
|
||||||
WHERE subjid=$subjid AND keystr='$keystr'
|
WHERE subjid=$subjid AND keystr='$keystr'
|
||||||
");
|
");
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
|
if($this->dbc->affectedRows()<1) return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -1244,11 +1244,12 @@ class XR_LocStor extends LocStor{
|
||||||
* <li> 805 - xr_loadPref:
|
* <li> 805 - xr_loadPref:
|
||||||
* <message from lower layer> </li>
|
* <message from lower layer> </li>
|
||||||
* <li> 848 - invalid session id.</li>
|
* <li> 848 - invalid session id.</li>
|
||||||
|
* <li> 849 - invalid preference key.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param input XMLRPC struct
|
* @param input XMLRPC struct
|
||||||
* @return XMLRPC struct
|
* @return XMLRPC struct
|
||||||
* @see LocStor::getAudioClip
|
* @see Pref::loadPref
|
||||||
*/
|
*/
|
||||||
function xr_loadPref($input)
|
function xr_loadPref($input)
|
||||||
{
|
{
|
||||||
|
@ -1259,7 +1260,7 @@ class XR_LocStor extends LocStor{
|
||||||
$res = $pr->loadPref($r['sessid'], $r['key']);
|
$res = $pr->loadPref($r['sessid'], $r['key']);
|
||||||
if(PEAR::isError($res)){
|
if(PEAR::isError($res)){
|
||||||
$ec = intval($res->getCode());
|
$ec = intval($res->getCode());
|
||||||
return new XML_RPC_Response(0, 800+($ec == 48 ? 48 : 5 ),
|
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ),
|
||||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -1298,7 +1299,7 @@ class XR_LocStor extends LocStor{
|
||||||
*
|
*
|
||||||
* @param input XMLRPC struct
|
* @param input XMLRPC struct
|
||||||
* @return XMLRPC struct
|
* @return XMLRPC struct
|
||||||
* @see LocStor::getAudioClip
|
* @see Pref::savePref
|
||||||
*/
|
*/
|
||||||
function xr_savePref($input)
|
function xr_savePref($input)
|
||||||
{
|
{
|
||||||
|
@ -1310,13 +1311,62 @@ class XR_LocStor extends LocStor{
|
||||||
if(PEAR::isError($res)){
|
if(PEAR::isError($res)){
|
||||||
#return new XML_RPC_Response(0, 805,
|
#return new XML_RPC_Response(0, 805,
|
||||||
$ec = intval($res->getCode());
|
$ec = intval($res->getCode());
|
||||||
return new XML_RPC_Response(0, 800+($ec == 48 ? 48 : 5 ),
|
return new XML_RPC_Response(0, 800+($ec == 48 ? $ec : 5 ),
|
||||||
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
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:
|
||||||
|
* <ul>
|
||||||
|
* <li> sessid : string - session id </li>
|
||||||
|
* <li> key : string - preference key </li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* On success, returns a XML-RPC struct with single field:
|
||||||
|
* <ul>
|
||||||
|
* <li> status : boolean</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_delPref:
|
||||||
|
* <message from lower layer> </li>
|
||||||
|
* <li> 848 - invalid session id.</li>
|
||||||
|
* <li> 849 - invalid preference key.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param input XMLRPC struct
|
||||||
|
* @return XMLRPC struct
|
||||||
|
* @see Pref::delPref
|
||||||
|
*/
|
||||||
|
function xr_delPref($input)
|
||||||
|
{
|
||||||
|
list($ok, $r) = $this->_xr_getPars($input);
|
||||||
|
if(!$ok) return $r;
|
||||||
|
require_once '../../../storageServer/var/Prefs.php';
|
||||||
|
$pr =& new Prefs(&$this);
|
||||||
|
$res = $pr->delPref($r['sessid'], $r['key']);
|
||||||
|
if(PEAR::isError($res)){
|
||||||
|
#return new XML_RPC_Response(0, 805,
|
||||||
|
$ec = intval($res->getCode());
|
||||||
|
return new XML_RPC_Response(0, 800+($ec == 48 || $ec == 49 ? $ec : 5 ),
|
||||||
|
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return new XML_RPC_Response(XML_RPC_encode(array('status'=>$res)));
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------- test methods for debugging */
|
/* ------------------------------------------- test methods for debugging */
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: tomas $
|
# Author : $Author: tomas $
|
||||||
# Version : $Revision: 1.13 $
|
# Version : $Revision: 1.14 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ prefTest() {
|
||||||
$XR_CLI savePref $SESSID "$PREFKEY" "$PREFVAL"|| exit $?
|
$XR_CLI savePref $SESSID "$PREFKEY" "$PREFVAL"|| exit $?
|
||||||
echo -n "# loadPref: "
|
echo -n "# loadPref: "
|
||||||
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
|
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
|
||||||
{ ERN=$?; echo $RES; exit $ERN; }
|
{ ERN=$?; echo $VAL; exit $ERN; }
|
||||||
echo "$VAL "
|
echo "$VAL "
|
||||||
if [ "x$VAL" != "x$PREFVAL" ] ; then
|
if [ "x$VAL" != "x$PREFVAL" ] ; then
|
||||||
echo " NOT MATCH"
|
echo " NOT MATCH"
|
||||||
|
@ -241,12 +241,14 @@ prefTest() {
|
||||||
else
|
else
|
||||||
echo "# pref value check: OK"
|
echo "# pref value check: OK"
|
||||||
fi
|
fi
|
||||||
echo -n "# savePref: "
|
echo -n "# delPref: "
|
||||||
$XR_CLI savePref $SESSID "$PREFKEY" ""|| exit $?
|
$XR_CLI delPref $SESSID "$PREFKEY"|| exit $?
|
||||||
echo -n "# loadPref: "
|
if [ $DEBUG ]; then
|
||||||
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
|
echo -n "# loadPref: "
|
||||||
{ ERN=$?; echo $RES; exit $ERN; }
|
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || echo $?
|
||||||
echo $VAL
|
else
|
||||||
|
echo $VAL
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.16 $
|
Version : $Revision: 1.17 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -116,6 +116,7 @@ $methods = array(
|
||||||
|
|
||||||
'loadPref' => 'Load user preference value.',
|
'loadPref' => 'Load user preference value.',
|
||||||
'savePref' => 'Save user preference value.',
|
'savePref' => 'Save user preference value.',
|
||||||
|
'delPref' => 'Delete user preference record.',
|
||||||
);
|
);
|
||||||
|
|
||||||
$defs = array();
|
$defs = array();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: tomas $
|
# Author : $Author: tomas $
|
||||||
# Version : $Revision: 1.12 $
|
# Version : $Revision: 1.13 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -188,6 +188,8 @@ try:
|
||||||
print server.locstor.loadPref({'sessid':pars[0], 'key':pars[1]})['value']
|
print server.locstor.loadPref({'sessid':pars[0], 'key':pars[1]})['value']
|
||||||
elif method=="savePref":
|
elif method=="savePref":
|
||||||
print server.locstor.savePref({'sessid':pars[0], 'key':pars[1], 'value':pars[2]})
|
print server.locstor.savePref({'sessid':pars[0], 'key':pars[1], 'value':pars[2]})
|
||||||
|
elif method=="delPref":
|
||||||
|
print server.locstor.delPref({'sessid':pars[0], 'key':pars[1]})
|
||||||
elif method=="resetStorage":
|
elif method=="resetStorage":
|
||||||
print server.locstor.resetStorage({})
|
print server.locstor.resetStorage({})
|
||||||
elif method=="openPut":
|
elif method=="openPut":
|
||||||
|
|
Loading…
Reference in New Issue