changed try-catch formatting

added deletePreferencesItem() to authentication module
This commit is contained in:
fgerlits 2005-01-13 14:43:42 +00:00
parent 5c5e8c7de9
commit db0fcb87fb
14 changed files with 261 additions and 77 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/include/LiveSupport/Authentication/AuthenticationClientInterface.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -69,7 +69,7 @@ using namespace LiveSupport::Core;
* An interface for authentication clients. * An interface for authentication clients.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class AuthenticationClientInterface class AuthenticationClientInterface
{ {
@ -162,6 +162,29 @@ class AuthenticationClientInterface
Ptr<const Glib::ustring>::Ref value) Ptr<const Glib::ustring>::Ref value)
throw (XmlRpcException) throw (XmlRpcException)
= 0; = 0;
/**
* Delete a `user preferences' item from the server.
*
* @param sessionId the ID of the current session (from login())
* @param key the name of the item
*
* @exception XmlRpcInvalidArgumentException
* bad sessionId argument
* @exception XmlRpcCommunicationException
* problem with performing XML-RPC call
* @exception XmlRpcMethodFaultException
* XML-RPC method returned fault response
* @exception XmlRpcMethodResponseException
* response from XML-RPC method is incorrect
* @exception XmlRpcException other error
* (TestAuthenticationClient only)
*/
virtual void
deletePreferencesItem(Ptr<SessionId>::Ref sessionId,
const Glib::ustring & key)
throw (XmlRpcException)
= 0;
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/AuthenticationClientFactoryTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -199,7 +199,7 @@ AuthenticationClientFactoryTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == "страстные"); CPPUNIT_ASSERT(*newPrefValue == "страстные");
// check another normal save and load // check another normal save and load...
prefValue.reset(new const Glib::ustring("ne dobryj")); prefValue.reset(new const Glib::ustring("ne dobryj"));
try { try {
authentication->savePreferencesItem(sessionId, "hour", prefValue); authentication->savePreferencesItem(sessionId, "hour", prefValue);
@ -207,6 +207,14 @@ AuthenticationClientFactoryTest :: preferencesTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
// ... but now change session ID in the middle
try {
authentication->logout(sessionId);
sessionId = authentication->login("root", "q");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try { try {
newPrefValue = authentication->loadPreferencesItem(sessionId, "hour"); newPrefValue = authentication->loadPreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -214,6 +222,19 @@ AuthenticationClientFactoryTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == *prefValue); CPPUNIT_ASSERT(*newPrefValue == *prefValue);
// check the delete method
try {
authentication->deletePreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try {
newPrefValue = authentication->loadPreferencesItem(sessionId, "hour");
CPPUNIT_FAIL("Allowed to load preference after it was deleted");
} catch (XmlRpcException &e) {
}
// and log out // and log out
try { try {
authentication->logout(sessionId); authentication->logout(sessionId);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.5 $ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -168,8 +168,7 @@ TestAuthenticationClient :: login(const std::string & login,
sessionIdList.insert(sessionIdStream.str()); sessionIdList.insert(sessionIdStream.str());
sessionId.reset(new SessionId(sessionIdStream.str())); sessionId.reset(new SessionId(sessionIdStream.str()));
return sessionId; return sessionId;
} } else {
else {
throw XmlRpcException("incorrect login or password"); throw XmlRpcException("incorrect login or password");
} }
} }
@ -185,8 +184,7 @@ TestAuthenticationClient :: logout(Ptr<SessionId>::Ref sessionId)
// this returns the number of entries found and erased // this returns the number of entries found and erased
if (!sessionId || sessionIdList.erase(sessionId->getId())) { if (!sessionId || sessionIdList.erase(sessionId->getId())) {
return; return;
} } else {
else {
throw XmlRpcException("logout() called without previous login()"); throw XmlRpcException("logout() called without previous login()");
} }
} }
@ -203,10 +201,10 @@ TestAuthenticationClient :: loadPreferencesItem(
{ {
if (!sessionId if (!sessionId
|| sessionIdList.find(sessionId->getId()) == sessionIdList.end()) { || sessionIdList.find(sessionId->getId()) == sessionIdList.end()) {
throw XmlRpcException("loadPreferences() called before login()"); throw XmlRpcException("bad session ID");
} }
preferencesType::iterator it; PreferencesType::iterator it;
if ((it = preferences.find(key)) == preferences.end()) { if ((it = preferences.find(key)) == preferences.end()) {
throw XmlRpcException("no such user preferences item"); throw XmlRpcException("no such user preferences item");
@ -227,6 +225,11 @@ TestAuthenticationClient :: savePreferencesItem(
Ptr<const Glib::ustring>::Ref value) Ptr<const Glib::ustring>::Ref value)
throw (XmlRpcException) throw (XmlRpcException)
{ {
if (!sessionId
|| sessionIdList.find(sessionId->getId()) == sessionIdList.end()) {
throw XmlRpcException("bad session ID");
}
if (sessionIdList.find(sessionId->getId()) == sessionIdList.end()) { if (sessionIdList.find(sessionId->getId()) == sessionIdList.end()) {
throw XmlRpcException("loadPreferences() called before login()"); throw XmlRpcException("loadPreferences() called before login()");
} }
@ -234,3 +237,27 @@ TestAuthenticationClient :: savePreferencesItem(
preferences[key] = value; preferences[key] = value;
} }
/*------------------------------------------------------------------------------
* Delete a `user preferences' item from the server.
*----------------------------------------------------------------------------*/
void
TestAuthenticationClient :: deletePreferencesItem(
Ptr<SessionId>::Ref sessionId,
const Glib::ustring & key)
throw (XmlRpcException)
{
if (!sessionId
|| sessionIdList.find(sessionId->getId()) == sessionIdList.end()) {
throw XmlRpcException("bad session ID");
}
PreferencesType::iterator it;
if ((it = preferences.find(key)) == preferences.end()) {
throw XmlRpcException("no such user preferences item");
}
preferences.erase(it);
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClient.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -65,7 +65,10 @@ using namespace LiveSupport::Core;
/* =============================================================== data types */ /* =============================================================== data types */
/** /**
* A dummy authentication client. * A dummy authentication client. It only supports one user, whose name and
* password are read from a configuration file. It issues session IDs when
* login() is called, and deletes these session IDs when logout() is called.
* It also stores (key, value) pairs of user preferences for this one user.
* *
* This object has to be configured with an XML configuration element * This object has to be configured with an XML configuration element
* called testAuthentication. This element contains a child element * called testAuthentication. This element contains a child element
@ -92,7 +95,7 @@ using namespace LiveSupport::Core;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class TestAuthenticationClient : class TestAuthenticationClient :
virtual public Configurable, virtual public Configurable,
@ -119,12 +122,12 @@ class TestAuthenticationClient :
* A type for the list of sessionId's. * A type for the list of sessionId's.
*/ */
typedef std::set<std::string> typedef std::set<std::string>
sessionIdListType; SessionIdListType;
/** /**
* A list of the sessionId's we have issued. * A list of the sessionId's we have issued.
*/ */
sessionIdListType sessionIdList; SessionIdListType sessionIdList;
/** /**
* The number of the sessionId's we have issued. * The number of the sessionId's we have issued.
@ -135,12 +138,12 @@ class TestAuthenticationClient :
* A type for the list of user preferences. * A type for the list of user preferences.
*/ */
typedef std::map<const Glib::ustring, Ptr<const Glib::ustring>::Ref> typedef std::map<const Glib::ustring, Ptr<const Glib::ustring>::Ref>
preferencesType; PreferencesType;
/** /**
* A list of the user preferences items stored. * A list of the user preferences items stored.
*/ */
preferencesType preferences; PreferencesType preferences;
public: public:
@ -228,6 +231,18 @@ class TestAuthenticationClient :
const Glib::ustring & key, const Glib::ustring & key,
Ptr<const Glib::ustring>::Ref value) Ptr<const Glib::ustring>::Ref value)
throw (XmlRpcException); throw (XmlRpcException);
/**
* Delete a `user preferences' item from the server.
*
* @param sessionId the ID of the current session (from login())
* @param key the name of the item
* @exception XmlRpcException invalid session ID, or no such key
*/
virtual void
deletePreferencesItem(Ptr<SessionId>::Ref sessionId,
const Glib::ustring & key)
throw (XmlRpcException);
}; };

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.5 $ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/TestAuthenticationClientTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -207,7 +207,7 @@ TestAuthenticationClientTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == "страстные"); CPPUNIT_ASSERT(*newPrefValue == "страстные");
// check another normal save and load // check another normal save and load...
prefValue.reset(new const Glib::ustring("ne dobryj")); prefValue.reset(new const Glib::ustring("ne dobryj"));
try { try {
tac->savePreferencesItem(sessionId, "hour", prefValue); tac->savePreferencesItem(sessionId, "hour", prefValue);
@ -215,6 +215,14 @@ TestAuthenticationClientTest :: preferencesTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
// ... but now change session ID in the middle
try {
tac->logout(sessionId);
sessionId = tac->login("root", "q");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try { try {
newPrefValue = tac->loadPreferencesItem(sessionId, "hour"); newPrefValue = tac->loadPreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -222,6 +230,19 @@ TestAuthenticationClientTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == *prefValue); CPPUNIT_ASSERT(*newPrefValue == *prefValue);
// check the delete method
try {
tac->deletePreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try {
newPrefValue = tac->loadPreferencesItem(sessionId, "hour");
CPPUNIT_FAIL("Allowed to load preference after it was deleted");
} catch (XmlRpcException &e) {
}
// and log out // and log out
try { try {
tac->logout(sessionId); tac->logout(sessionId);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -139,6 +139,11 @@ static const std::string loadPreferencesMethodName = "locstor.loadPref";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string savePreferencesMethodName = "locstor.savePref"; static const std::string savePreferencesMethodName = "locstor.savePref";
/*------------------------------------------------------------------------------
* The name of the delete preferences method on the server
*----------------------------------------------------------------------------*/
static const std::string deletePreferencesMethodName = "locstor.delPref";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the session ID parameter in the input structure * The name of the session ID parameter in the input structure
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -450,6 +455,59 @@ WebAuthenticationClient :: savePreferencesItem(
} }
/*------------------------------------------------------------------------------
* Delete a `user preferences' item from the server.
*----------------------------------------------------------------------------*/
void
WebAuthenticationClient :: deletePreferencesItem(
Ptr<SessionId>::Ref sessionId,
const Glib::ustring & key)
throw (XmlRpcException)
{
if (!sessionId) {
throw Core::XmlRpcInvalidArgumentException("Missing session ID.");
}
XmlRpcValue parameters;
XmlRpcValue result;
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
storageServerPath.c_str(), false);
parameters.clear();
parameters[preferencesSessionIdParamName] = sessionId->getId();
parameters[preferencesKeyParamName] = std::string(key);
result.clear();
if (!xmlRpcClient.execute(deletePreferencesMethodName.c_str(),
parameters, result)) {
throw Core::XmlRpcCommunicationException(
"Could not execute XML-RPC method.");
}
if (xmlRpcClient.isFault()) {
std::stringstream eMsg;
eMsg << "XML-RPC method "
<< deletePreferencesMethodName
<< " returned fault response:\n"
<< result;
throw Core::XmlRpcMethodFaultException(eMsg.str());
}
if (! result.hasMember(preferencesStatusParamName)
|| result[preferencesStatusParamName].getType()
!= XmlRpcValue::TypeBoolean
|| ! bool(result[preferencesStatusParamName])) {
std::stringstream eMsg;
eMsg << "XML-RPC method "
<< deletePreferencesMethodName
<< " returned unexpected response:\n"
<< result;
throw Core::XmlRpcMethodResponseException(eMsg.str());
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Reset the list of preferences to its initial (empty) state. * Reset the list of preferences to its initial (empty) state.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClient.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -93,7 +93,7 @@ using namespace LiveSupport::Core;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.4 $ * @version $Revision: 1.5 $
*/ */
class WebAuthenticationClient : class WebAuthenticationClient :
virtual public Configurable, virtual public Configurable,
@ -236,6 +236,26 @@ class WebAuthenticationClient :
Ptr<const Glib::ustring>::Ref value) Ptr<const Glib::ustring>::Ref value)
throw (XmlRpcException); throw (XmlRpcException);
/**
* Delete a `user preferences' item from the server.
*
* @param sessionId the ID of the current session (from login())
* @param key the name of the item
*
* @exception XmlRpcInvalidArgumentException
* bad sessionId argument
* @exception XmlRpcCommunicationException
* problem with performing XML-RPC call
* @exception XmlRpcMethodFaultException
* XML-RPC method returned fault response
* @exception XmlRpcMethodResponseException
* response from XML-RPC method is incorrect
*/
virtual void
deletePreferencesItem(Ptr<SessionId>::Ref sessionId,
const Glib::ustring & key)
throw (XmlRpcException);
/** /**
* Reset the list of preferences to its initial (empty) state. * Reset the list of preferences to its initial (empty) state.
* *

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/authentication/src/WebAuthenticationClientTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -212,7 +212,7 @@ WebAuthenticationClientTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == "страстные"); CPPUNIT_ASSERT(*newPrefValue == "страстные");
// check another normal save and load // check another normal save and load ...
prefValue.reset(new const Glib::ustring("ne dobryj")); prefValue.reset(new const Glib::ustring("ne dobryj"));
try { try {
wac->savePreferencesItem(sessionId, "hour", prefValue); wac->savePreferencesItem(sessionId, "hour", prefValue);
@ -220,6 +220,14 @@ WebAuthenticationClientTest :: preferencesTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
// ... but now change session ID in the middle
try {
wac->logout(sessionId);
sessionId = wac->login("root", "q");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try { try {
newPrefValue = wac->loadPreferencesItem(sessionId, "hour"); newPrefValue = wac->loadPreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -227,6 +235,19 @@ WebAuthenticationClientTest :: preferencesTest(void)
} }
CPPUNIT_ASSERT(*newPrefValue == *prefValue); CPPUNIT_ASSERT(*newPrefValue == *prefValue);
// check the delete method
try {
wac->deletePreferencesItem(sessionId, "hour");
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
try {
newPrefValue = wac->loadPreferencesItem(sessionId, "hour");
CPPUNIT_FAIL("Allowed to load preference after it was deleted");
} catch (XmlRpcException &e) {
}
// and log out // and log out
try { try {
wac->logout(sessionId); wac->logout(sessionId);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.16 $ Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -288,8 +288,7 @@ AudioClip :: configure(const xmlpp::Element & element)
if (dataElement->has_child_text()) { if (dataElement->has_child_text()) {
playlength.reset(new time_duration(duration_from_string( playlength.reset(new time_duration(duration_from_string(
dataElement->get_child_text()->get_content() ))); dataElement->get_child_text()->get_content() )));
} } else { // or just leave blank? bad either way
else { // or just leave blank? bad either way
playlength.reset(new time_duration(0,0,0,0)); playlength.reset(new time_duration(0,0,0,0));
} }
} }
@ -299,8 +298,7 @@ AudioClip :: configure(const xmlpp::Element & element)
Glib::ustring value; Glib::ustring value;
if (dataElement->has_child_text()) { if (dataElement->has_child_text()) {
value = dataElement->get_child_text()->get_content(); value = dataElement->get_child_text()->get_content();
} } else {
else {
value = ""; value = "";
} }
Ptr<const Glib::ustring>::Ref ptrToValue( Ptr<const Glib::ustring>::Ref ptrToValue(
@ -413,8 +411,7 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
xmlpp::Element* metadata; xmlpp::Element* metadata;
if (rootList.size() > 0) { if (rootList.size() > 0) {
metadata = dynamic_cast<xmlpp::Element*> (rootList.front()); metadata = dynamic_cast<xmlpp::Element*> (rootList.front());
} } else {
else {
metadata = rootNode->add_child("metadata"); metadata = rootNode->add_child("metadata");
metadata->set_namespace_declaration(defaultPrefixUri); metadata->set_namespace_declaration(defaultPrefixUri);
metadata->set_namespace_declaration(titleElementUri, metadata->set_namespace_declaration(titleElementUri,

View File

@ -73,7 +73,7 @@ documentation and/or software.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Md5.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Md5.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -198,8 +198,7 @@ void Md5::update (uint1 *input, uint4 input_length)
transform (input+input_index); transform (input+input_index);
} }
buffer_index = 0; // so we can buffer remaining buffer_index = 0; // so we can buffer remaining
} } else {
else {
input_index=0; // so we can buffer the whole input input_index=0; // so we can buffer the whole input
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.25 $ Version : $Revision: 1.26 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -109,8 +109,7 @@ Playlist :: configure(const xmlpp::Element & element)
if ((attribute = element.get_attribute(titleAttrName))) { if ((attribute = element.get_attribute(titleAttrName))) {
title.reset(new const Glib::ustring(attribute->get_value())); title.reset(new const Glib::ustring(attribute->get_value()));
} } else {
else {
title.reset(new const Glib::ustring("")); title.reset(new const Glib::ustring(""));
} }
@ -276,17 +275,14 @@ Playlist::setLockedForEditing(const bool lockStatus)
if (lockStatus == true) { if (lockStatus == true) {
if (isLockedForPlaying || isLockedForEditing) { if (isLockedForPlaying || isLockedForEditing) {
return false; return false;
} } else {
else {
isLockedForEditing = true; isLockedForEditing = true;
return true; return true;
} }
} } else {
else {
if (isLockedForPlaying) { if (isLockedForPlaying) {
return false; return false;
} } else {
else {
isLockedForEditing = false; isLockedForEditing = false;
return true; // returns true also if playlist return true; // returns true also if playlist
} // was already unlocked! } // was already unlocked!
@ -304,13 +300,11 @@ Playlist::setLockedForPlaying(const bool lockStatus)
if (lockStatus == true) { if (lockStatus == true) {
if (isLockedForPlaying) { if (isLockedForPlaying) {
return false; return false;
} } else {
else {
isLockedForPlaying = true; // preserve LockedForEditing state isLockedForPlaying = true; // preserve LockedForEditing state
return true; return true;
} }
} } else {
else {
isLockedForPlaying = false; // restore LockedForEditing state; isLockedForPlaying = false; // restore LockedForEditing state;
return true; // returns true also if playlist return true; // returns true also if playlist
} // was already unlocked! } // was already unlocked!
@ -337,15 +331,14 @@ Playlist::valid(void) throw ()
if (playlistElement->getType() == PlaylistElement::AudioClipType) { if (playlistElement->getType() == PlaylistElement::AudioClipType) {
audioClip = playlistElement->getAudioClip(); audioClip = playlistElement->getAudioClip();
*runningTime += *(audioClip->getPlaylength()); *runningTime += *(audioClip->getPlaylength());
} } else if (playlistElement->getType()
else if (playlistElement->getType() == PlaylistElement::PlaylistType) { == PlaylistElement::PlaylistType) {
playlist = playlistElement->getPlaylist(); playlist = playlistElement->getPlaylist();
if (!playlist->valid()) { if (!playlist->valid()) {
return false; return false;
} }
*runningTime += *(playlist->getPlaylength()); *runningTime += *(playlist->getPlaylength());
} } else { // this should never happen
else { // this should never happen
return false; return false;
} }
++it; ++it;
@ -409,8 +402,7 @@ Playlist :: getMetadata(const string &key, const string &ns) const
if (it != metadata.end()) { if (it != metadata.end()) {
Ptr<Glib::ustring>::Ref data(new Glib::ustring(*it->second)); Ptr<Glib::ustring>::Ref data(new Glib::ustring(*it->second));
return data; return data;
} } else {
else {
Ptr<Glib::ustring>::Ref nullPointer; Ptr<Glib::ustring>::Ref nullPointer;
return nullPointer; return nullPointer;
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.9 $ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElement.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElement.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -135,8 +135,7 @@ PlaylistElement :: configure(const xmlpp::Element & element)
eMsg += " XML element"; eMsg += " XML element";
throw std::invalid_argument(eMsg); throw std::invalid_argument(eMsg);
} }
} } else {
else {
childNodes = element.get_children(playlistElementName); childNodes = element.get_children(playlistElementName);
it = childNodes.begin(); it = childNodes.begin();
if (it != childNodes.end()) { if (it != childNodes.end()) {
@ -153,8 +152,7 @@ PlaylistElement :: configure(const xmlpp::Element & element)
eMsg += " XML element"; eMsg += " XML element";
throw std::invalid_argument(eMsg); throw std::invalid_argument(eMsg);
} }
} } else {
else {
std::string eMsg = "missing "; std::string eMsg = "missing ";
eMsg += audioClipElementName; eMsg += audioClipElementName;
eMsg += " or "; eMsg += " or ";

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.28 $ Version : $Revision: 1.29 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -371,8 +371,7 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
smilAudioClipUriAttrName, smilAudioClipUriAttrName,
*(audioClip->getUri()) ); *(audioClip->getUri()) );
++it; ++it;
} } else if (plElement->getType() == PlaylistElement::PlaylistType) {
else if (plElement->getType() == PlaylistElement::PlaylistType) {
Ptr<Playlist>::Ref playlist Ptr<Playlist>::Ref playlist
= acquirePlaylist(sessionId, plElement = acquirePlaylist(sessionId, plElement
->getPlaylist() ->getPlaylist()
@ -387,8 +386,7 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
smilPlaylistUriAttrName, smilPlaylistUriAttrName,
*(playlist->getUri()) ); *(playlist->getUri()) );
++it; ++it;
} } else { // this should never happen
else { // this should never happen
throw XmlRpcInvalidArgumentException( throw XmlRpcInvalidArgumentException(
"unexpected playlist element type " "unexpected playlist element type "
"(neither audio clip nor playlist)"); "(neither audio clip nor playlist)");
@ -442,8 +440,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
eMsg += "\n"; eMsg += "\n";
} }
++it; ++it;
} } else if (plElement->getType() == PlaylistElement::PlaylistType) {
else if (plElement->getType() == PlaylistElement::PlaylistType) {
try { try {
releasePlaylist(sessionId, it->second->getPlaylist()); releasePlaylist(sessionId, it->second->getPlaylist());
} }
@ -452,8 +449,7 @@ TestStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
eMsg += "\n"; eMsg += "\n";
} }
++it; ++it;
} } else { // this should never happen
else { // this should never happen
eMsg += "unexpected playlist element type\n"; eMsg += "unexpected playlist element type\n";
} }
} }

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.23 $ Version : $Revision: 1.24 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -1016,8 +1016,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
smilAudioClipUriAttrName, smilAudioClipUriAttrName,
*(audioClip->getUri()) ); *(audioClip->getUri()) );
++it; ++it;
} } else if (plElement->getType() == PlaylistElement::PlaylistType) {
else if (plElement->getType() == PlaylistElement::PlaylistType) {
Ptr<Playlist>::Ref playlist Ptr<Playlist>::Ref playlist
= acquirePlaylist(sessionId, plElement = acquirePlaylist(sessionId, plElement
->getPlaylist() ->getPlaylist()
@ -1032,8 +1031,7 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
smilPlaylistUriAttrName, smilPlaylistUriAttrName,
*(playlist->getUri()) ); *(playlist->getUri()) );
++it; ++it;
} } else { // this should never happen
else { // this should never happen
throw XmlRpcInvalidArgumentException( throw XmlRpcInvalidArgumentException(
"unexpected playlist element type " "unexpected playlist element type "
"(neither audio clip nor playlist)"); "(neither audio clip nor playlist)");
@ -1086,8 +1084,7 @@ WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
eMsg += "\n"; eMsg += "\n";
} }
++it; ++it;
} } else if (plElement->getType() == PlaylistElement::PlaylistType) {
else if (plElement->getType() == PlaylistElement::PlaylistType) {
try { try {
releasePlaylist(sessionId, it->second->getPlaylist()); releasePlaylist(sessionId, it->second->getPlaylist());
} }
@ -1096,8 +1093,7 @@ WebStorageClient :: releasePlaylist(Ptr<SessionId>::Ref sessionId,
eMsg += "\n"; eMsg += "\n";
} }
++it; ++it;
} } else { // this should never happen
else { // this should never happen
eMsg += "unexpected playlist element type\n"; eMsg += "unexpected playlist element type\n";
} }
} }