diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php
index f4ad54c14..9fd46cde0 100644
--- a/livesupport/modules/storageServer/var/BasicStor.php
+++ b/livesupport/modules/storageServer/var/BasicStor.php
@@ -23,7 +23,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -36,6 +36,7 @@ define('GBERR_NONE', 45);
define('GBERR_AOBJNEX', 46);
define('GBERR_NOTF', 47);
define('GBERR_SESS', 48);
+define('GBERR_PREF', 49);
define('GBERR_NOTIMPL', 50);
@@ -49,7 +50,7 @@ require_once "StoredFile.php";
* Core of LiveSupport file storage module
*
* @author $Author: tomas $
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
* @see Alib
*/
class BasicStor extends Alib{
diff --git a/livesupport/modules/storageServer/var/Prefs.php b/livesupport/modules/storageServer/var/Prefs.php
index 3843a9e89..f97af3b3b 100644
--- a/livesupport/modules/storageServer/var/Prefs.php
+++ b/livesupport/modules/storageServer/var/Prefs.php
@@ -23,7 +23,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -69,6 +69,10 @@ class Prefs{
}
$val = $this->readVal($subjid, $key);
if(PEAR::isError($val)) return $val;
+ if($val === FALSE){
+ return PEAR::raiseError("Prefs::loadPref: invalid preference key",
+ GBERR_PREF);
+ }
return $val;
}
@@ -88,15 +92,39 @@ class Prefs{
return PEAR::raiseError("Prefs::loadPref: invalid session id",
GBERR_SESS);
}
- $r = $this->delete($subjid, $key);
+ $r = $this->update($subjid, $key, $value);
if(PEAR::isError($r)) return $r;
- if($value != ''){
+ if($r === FALSE){
$r = $this->insert($subjid, $key, $value);
if(PEAR::isError($r)) return $r;
}
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 */
/**
* Insert of new preference record
@@ -134,7 +162,7 @@ class Prefs{
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($val)) return $val;
- if(is_null($val)) return '';
+ if(is_null($val)) return FALSE;
return $val;
}
@@ -154,6 +182,7 @@ class Prefs{
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($r)) return $r;
+ if($this->dbc->affectedRows()<1) return FALSE;
return TRUE;
}
@@ -171,6 +200,7 @@ class Prefs{
WHERE subjid=$subjid AND keystr='$keystr'
");
if(PEAR::isError($r)) return $r;
+ if($this->dbc->affectedRows()<1) return FALSE;
return TRUE;
}
diff --git a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php
index 0fc6bdb1a..88ec1bc84 100644
--- a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php
+++ b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php
@@ -23,7 +23,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -1244,11 +1244,12 @@ class XR_LocStor extends LocStor{
*
805 - xr_loadPref:
* <message from lower layer>
* 848 - invalid session id.
+ * 849 - invalid preference key.
*
*
* @param input XMLRPC struct
* @return XMLRPC struct
- * @see LocStor::getAudioClip
+ * @see Pref::loadPref
*/
function xr_loadPref($input)
{
@@ -1259,7 +1260,7 @@ class XR_LocStor extends LocStor{
$res = $pr->loadPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){
$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()
);
@@ -1298,7 +1299,7 @@ class XR_LocStor extends LocStor{
*
* @param input XMLRPC struct
* @return XMLRPC struct
- * @see LocStor::getAudioClip
+ * @see Pref::savePref
*/
function xr_savePref($input)
{
@@ -1310,13 +1311,62 @@ class XR_LocStor extends LocStor{
if(PEAR::isError($res)){
#return new XML_RPC_Response(0, 805,
$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()
);
}
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:
+ *
+ * - sessid : string - session id
+ * - key : string - preference key
+ *
+ *
+ * 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:
+ *
+ * - 3 - Incorrect parameters passed to method:
+ * Wanted ... , got ... at param
+ * - 801 - wrong 1st parameter, struct expected.
+ * - 805 - xr_delPref:
+ * <message from lower layer>
+ * - 848 - invalid session id.
+ * - 849 - invalid preference key.
+ *
+ *
+ * @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 */
/**
diff --git a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
index 75bb7b79c..6c8edac6b 100755
--- a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
+++ b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh
@@ -23,7 +23,7 @@
#
#
# 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 $
#-------------------------------------------------------------------------------
@@ -231,7 +231,7 @@ prefTest() {
$XR_CLI savePref $SESSID "$PREFKEY" "$PREFVAL"|| exit $?
echo -n "# loadPref: "
VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
- { ERN=$?; echo $RES; exit $ERN; }
+ { ERN=$?; echo $VAL; exit $ERN; }
echo "$VAL "
if [ "x$VAL" != "x$PREFVAL" ] ; then
echo " NOT MATCH"
@@ -241,12 +241,14 @@ prefTest() {
else
echo "# pref value check: OK"
fi
- echo -n "# savePref: "
- $XR_CLI savePref $SESSID "$PREFKEY" ""|| exit $?
- echo -n "# loadPref: "
- VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || \
- { ERN=$?; echo $RES; exit $ERN; }
- echo $VAL
+ echo -n "# delPref: "
+ $XR_CLI delPref $SESSID "$PREFKEY"|| exit $?
+ if [ $DEBUG ]; then
+ echo -n "# loadPref: "
+ VAL=`$XR_CLI loadPref $SESSID "$PREFKEY"` || echo $?
+ else
+ echo $VAL
+ fi
}
logout() {
diff --git a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php
index 7c962f4b6..2c9300450 100644
--- a/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php
+++ b/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php
@@ -23,7 +23,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -116,6 +116,7 @@ $methods = array(
'loadPref' => 'Load user preference value.',
'savePref' => 'Save user preference value.',
+ 'delPref' => 'Delete user preference record.',
);
$defs = array();
diff --git a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
index aa7a0f030..99ca608a4 100755
--- a/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
+++ b/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.py
@@ -24,7 +24,7 @@
#
#
# 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 $
#
#------------------------------------------------------------------------------
@@ -188,6 +188,8 @@ try:
print server.locstor.loadPref({'sessid':pars[0], 'key':pars[1]})['value']
elif method=="savePref":
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":
print server.locstor.resetStorage({})
elif method=="openPut":