moved XmlRpcTools (and PlayLogEntry) over to the Core module
This commit is contained in:
parent
21485a6d01
commit
cf1054852c
7 changed files with 1400 additions and 8 deletions
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: fgerlits $
|
# Author : $Author: fgerlits $
|
||||||
# Version : $Revision: 1.20 $
|
# Version : $Revision: 1.21 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/Makefile.in,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/Makefile.in,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -117,7 +117,8 @@ CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \
|
||||||
${TMP_DIR}/Thread.o \
|
${TMP_DIR}/Thread.o \
|
||||||
${TMP_DIR}/LocalizedObject.o \
|
${TMP_DIR}/LocalizedObject.o \
|
||||||
${TMP_DIR}/LocalizedConfigurable.o \
|
${TMP_DIR}/LocalizedConfigurable.o \
|
||||||
${TMP_DIR}/Md5.o
|
${TMP_DIR}/Md5.o \
|
||||||
|
${TMP_DIR}/XmlRpcTools.o
|
||||||
|
|
||||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||||
${TMP_DIR}/UniqueIdTest.o \
|
${TMP_DIR}/UniqueIdTest.o \
|
||||||
|
@ -130,7 +131,8 @@ TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||||
${TMP_DIR}/ThreadTest.o \
|
${TMP_DIR}/ThreadTest.o \
|
||||||
${TMP_DIR}/LocalizedObjectTest.o \
|
${TMP_DIR}/LocalizedObjectTest.o \
|
||||||
${TMP_DIR}/LocalizedConfigurableTest.o \
|
${TMP_DIR}/LocalizedConfigurableTest.o \
|
||||||
${TMP_DIR}/Md5Test.o
|
${TMP_DIR}/Md5Test.o \
|
||||||
|
${TMP_DIR}/XmlRpcToolsTest.o
|
||||||
|
|
||||||
TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
||||||
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
||||||
|
@ -138,7 +140,7 @@ TEST_RUNNER_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
||||||
${TMP_DIR}/${PACKAGE_NAME}_jp.res
|
${TMP_DIR}/${PACKAGE_NAME}_jp.res
|
||||||
|
|
||||||
TEST_RUNNER_LIBS = -l${CORE_LIB} ${ICU_LIBS} -lboost_date_time-gcc \
|
TEST_RUNNER_LIBS = -l${CORE_LIB} ${ICU_LIBS} -lboost_date_time-gcc \
|
||||||
-lcppunit -ldl
|
-lcppunit -ldl -lxmlrpc++
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -20,8 +20,8 @@ dnl along with LiveSupport; if not, write to the Free Software
|
||||||
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
dnl
|
dnl
|
||||||
dnl
|
dnl
|
||||||
dnl Author : $Author: maroy $
|
dnl Author : $Author: fgerlits $
|
||||||
dnl Version : $Revision: 1.7 $
|
dnl Version : $Revision: 1.8 $
|
||||||
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/configure.ac,v $
|
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/etc/configure.ac,v $
|
||||||
dnl-----------------------------------------------------------------------------
|
dnl-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ dnl-----------------------------------------------------------------------------
|
||||||
AC_INIT(Core, 1.0, bugs@campware.org)
|
AC_INIT(Core, 1.0, bugs@campware.org)
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ(2.59)
|
||||||
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
|
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
|
||||||
AC_REVISION($Revision: 1.7 $)
|
AC_REVISION($Revision: 1.8 $)
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR(../src/UniqueId.cxx)
|
AC_CONFIG_SRCDIR(../src/UniqueId.cxx)
|
||||||
|
|
||||||
AC_CONFIG_HEADERS(configure.h)
|
AC_CONFIG_HEADERS(configure.h)
|
||||||
AC_PROG_CXX()
|
AC_PROG_CXX()
|
||||||
|
|
||||||
AC_CHECK_HEADERS(getopt.h sys/time.h)
|
AC_CHECK_HEADERS(getopt.h sys/time.h time.h)
|
||||||
|
|
||||||
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.6.0])
|
PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.6.0])
|
||||||
AC_SUBST(LIBXMLPP_CFLAGS)
|
AC_SUBST(LIBXMLPP_CFLAGS)
|
||||||
|
|
170
livesupport/modules/core/include/LiveSupport/Core/PlayLogEntry.h
Normal file
170
livesupport/modules/core/include/LiveSupport/Core/PlayLogEntry.h
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
LiveSupport is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: fgerlits $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/PlayLogEntry.h,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
#ifndef LiveSupport_Core_PlayLogEntry_h
|
||||||
|
#define LiveSupport_Core_PlayLogEntry_h
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#error This is a C++ include file
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <libxml++/libxml++.h>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
#include "LiveSupport/Core/UniqueId.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace LiveSupport {
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
using namespace boost::posix_time;
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
|
||||||
|
/* =================================================================== macros */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================================== data types */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class representing a play log entry.
|
||||||
|
* PlayLogEntries contain information about the audio clips played.
|
||||||
|
*
|
||||||
|
* @author $Author: fgerlits $
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
*/
|
||||||
|
class PlayLogEntry
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The unique id of the play log entry.
|
||||||
|
*/
|
||||||
|
Ptr<UniqueId>::Ref id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the audio clip referenced by this play log entry.
|
||||||
|
*/
|
||||||
|
Ptr<UniqueId>::Ref audioClipId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time this audio clip was played.
|
||||||
|
*/
|
||||||
|
Ptr<ptime>::Ref timestamp;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
PlayLogEntry(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a play log entry by specifying all details.
|
||||||
|
*
|
||||||
|
* @param id the ID of the play log entry.
|
||||||
|
* @param audioClipId the ID of the audio clip logged
|
||||||
|
* @param timestamp the time this audio clip was played.
|
||||||
|
*/
|
||||||
|
PlayLogEntry(Ptr<UniqueId>::Ref id,
|
||||||
|
Ptr<UniqueId>::Ref audioClipId,
|
||||||
|
Ptr<ptime>::Ref timestamp) throw()
|
||||||
|
{
|
||||||
|
this->id = id;
|
||||||
|
this->audioClipId = audioClipId;
|
||||||
|
this->timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A virtual destructor, as this class has virtual functions.
|
||||||
|
*/
|
||||||
|
virtual
|
||||||
|
~PlayLogEntry(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ID of the play log entry.
|
||||||
|
*
|
||||||
|
* @return the unique ID of the play log entry.
|
||||||
|
*/
|
||||||
|
Ptr<const UniqueId>::Ref
|
||||||
|
getId(void) const throw ()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ID of the audio clip referenced by this entry.
|
||||||
|
*
|
||||||
|
* @return the unique ID of the audio clip.
|
||||||
|
*/
|
||||||
|
Ptr<const UniqueId>::Ref
|
||||||
|
getAudioClipId(void) const throw ()
|
||||||
|
{
|
||||||
|
return audioClipId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the time this audio clip was played.
|
||||||
|
*
|
||||||
|
* @return the the time the audio clip was played.
|
||||||
|
*/
|
||||||
|
Ptr<const ptime>::Ref
|
||||||
|
getTimestamp(void) const throw ()
|
||||||
|
{
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================= external data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================== function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
} // namespace LiveSupport
|
||||||
|
|
||||||
|
#endif // LiveSupport_Core_PlayLogEntry_h
|
||||||
|
|
358
livesupport/modules/core/include/LiveSupport/Core/XmlRpcTools.h
Normal file
358
livesupport/modules/core/include/LiveSupport/Core/XmlRpcTools.h
Normal file
|
@ -0,0 +1,358 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
LiveSupport is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: fgerlits $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/XmlRpcTools.h,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
#ifndef LiveSupport_Core_XmlRpcTools_h
|
||||||
|
#define LiveSupport_Core_XmlRpcTools_h
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#error This is a C++ include file
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <XmlRpcValue.h>
|
||||||
|
#include <XmlRpcException.h>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
#include "LiveSupport/Core/SessionId.h"
|
||||||
|
#include "LiveSupport/Core/Playlist.h"
|
||||||
|
#include "LiveSupport/Core/ScheduleEntry.h"
|
||||||
|
#include "LiveSupport/Core/PlayLogEntry.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace LiveSupport {
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
using namespace LiveSupport;
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
|
||||||
|
/* =================================================================== macros */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================================== data types */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A toolbox for converting between inner representations of classes
|
||||||
|
* and XmlRpcValues. Used by almost all XmlRpcServerMethod subclasses
|
||||||
|
* in the Scheduler.
|
||||||
|
*
|
||||||
|
* @author $Author: fgerlits $
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
*/
|
||||||
|
class XmlRpcTools
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a boost::posix_time::ptime to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param ptime the ptime to convert
|
||||||
|
* @param xmlRpcValue the output parameter holding the value of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
ptimeToXmlRpcValue(Ptr<const ptime>::Ref ptime,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a PlayLogEntry to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param playLogEntry the PlayLogEntry to convert.
|
||||||
|
* @param xmlRpcValue the output parameter holding the result of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
playLogEntryToXmlRpcValue(Ptr<const PlayLogEntry>::Ref playLogEntry,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Extract the schedule entry id from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no UniqueId
|
||||||
|
* in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<UniqueId>::Ref
|
||||||
|
extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the playlist id from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no playlistId
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<UniqueId>::Ref
|
||||||
|
extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the audio clip id from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no audioClipId
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<UniqueId>::Ref
|
||||||
|
extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the relative offset from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a time_duration that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no relativeOffset
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<time_duration>::Ref
|
||||||
|
extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a Playlist to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param playlist the Playlist to convert.
|
||||||
|
* @param xmlRpcValue the output parameter holding the result of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
playlistToXmlRpcValue(Ptr<const Playlist>::Ref playlist,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a vector of Playlists to an XML-RPC return value.
|
||||||
|
*
|
||||||
|
* @param playlistVector a list of Playlists.
|
||||||
|
* @param returnValue the output parameter holding an XML-RPC
|
||||||
|
* representation of the list of Playlists.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
playlistVectorToXmlRpcValue(
|
||||||
|
const Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an AudioClip to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param audioClip the AudioClip to convert.
|
||||||
|
* @param xmlRpcValue the output parameter holding the result of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
audioClipToXmlRpcValue(Ptr<const AudioClip>::Ref audioClip,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a vector of AudioClips to an XML-RPC return value.
|
||||||
|
*
|
||||||
|
* @param audioClipVector a list of AudioClips.
|
||||||
|
* @param returnValue the output parameter holding an XML-RPC
|
||||||
|
* representation of the list of AudioClips.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
audioClipVectorToXmlRpcValue(
|
||||||
|
const Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an error code, message pair to an XML-RPC fault response.
|
||||||
|
* This is done by throwing an XmlRpc::XmlRpcException. The client
|
||||||
|
* receives a fault response, and the return value is set to a
|
||||||
|
* { faultCode, faultString } structure holding the error code and
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @param errorCode the numerical code of the error.
|
||||||
|
* @param errorMessage a short English description of the error.
|
||||||
|
* @param xmlRpcValue remains here from an earlier version
|
||||||
|
* TODO: remove this later.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
markError(int errorCode, const std::string errorMessage,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (XmlRpc::XmlRpcException);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the valid status of a playlist to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param validStatus true if the playlist is valid, false otherwise.
|
||||||
|
* @param xmlRpcValue the output parameter holding the result of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
validStatusToXmlRpcValue(bool validStatus,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the from time parameter from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return the time value for the from parameter
|
||||||
|
* @exception std::invalid_argument if there was no from parameter
|
||||||
|
* in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<boost::posix_time::ptime>::Ref
|
||||||
|
extractFromTime(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the to parameter from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return the time value for the to parameter
|
||||||
|
* @exception std::invalid_argument if there was no to parameter
|
||||||
|
* in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<boost::posix_time::ptime>::Ref
|
||||||
|
extractToTime(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the playtime from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return the playing time, as stored in the XML-RPC parameter
|
||||||
|
* @exception std::invalid_argument if there was no playtime
|
||||||
|
* in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<boost::posix_time::ptime>::Ref
|
||||||
|
extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the fade in time from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a time_duration that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no fadeIn
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<time_duration>::Ref
|
||||||
|
extractFadeIn(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the fade out time from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a time_duration that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no fadeOut
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<time_duration>::Ref
|
||||||
|
extractFadeOut(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a vector of ScheduleEntries to an XML-RPC return value.
|
||||||
|
*
|
||||||
|
* @param scheduleEntries a list of ScheduleEntries.
|
||||||
|
* @param returnValue the output parameter holding an XML-RPC
|
||||||
|
* representation of the suppied schedule entires.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
scheduleEntriesToXmlRpcValue(
|
||||||
|
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref scheduleEntries,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a schedule entry ID (a UniqueId) to an XmlRpcValue
|
||||||
|
*
|
||||||
|
* @param scheduleEntryId the UniqueId to convert.
|
||||||
|
* @param returnValue the output parameter holding the result of
|
||||||
|
* the conversion.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
scheduleEntryIdToXmlRpcValue(
|
||||||
|
Ptr<const UniqueId>::Ref scheduleEntryId,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a vector of PlayLogEntries to an XML-RPC return value.
|
||||||
|
*
|
||||||
|
* @param playLogVector a list of PlayLogEntries.
|
||||||
|
* @param returnValue the output parameter holding an XML-RPC
|
||||||
|
* representation of the list of PlayLogEntries.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
playLogVectorToXmlRpcValue(
|
||||||
|
Ptr<const std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
|
||||||
|
playLogVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the session ID from the XML-RPC parameters.
|
||||||
|
*
|
||||||
|
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||||
|
* @return a SessionId that was found in the XML-RPC parameter.
|
||||||
|
* @exception std::invalid_argument if there was no sessionId
|
||||||
|
* member in xmlRpcValue
|
||||||
|
*/
|
||||||
|
static Ptr<SessionId>::Ref
|
||||||
|
extractSessionId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================= external data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================== function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
} // namespace LiveSupport
|
||||||
|
|
||||||
|
#endif // LiveSupport_Core_XmlRpcTools_h
|
||||||
|
|
529
livesupport/modules/core/src/XmlRpcTools.cxx
Normal file
529
livesupport/modules/core/src/XmlRpcTools.cxx
Normal file
|
@ -0,0 +1,529 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
LiveSupport is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: fgerlits $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/XmlRpcTools.cxx,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#else
|
||||||
|
#error need time.h
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "LiveSupport/Core/TimeConversion.h"
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace boost;
|
||||||
|
using namespace boost::posix_time;
|
||||||
|
|
||||||
|
using namespace LiveSupport;
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playlist ID member in the XML-RPC parameter structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string playlistIdName = "playlistId";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the audio clip ID member in the XML-RPC parameter structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string audioClipIdName = "audioClipId";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the relative offset member in the XML-RPC parameter structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string relativeOffsetName = "relativeOffset";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the from member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string fromTimeName = "from";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the to member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string toTimeName = "to";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playlist id member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string scheduleEntryIdName = "scheduleEntryId";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playtime member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string playtimeName = "playtime";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the fade in member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string fadeInName = "fadeIn";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the fade out member in the XML-RPC parameter structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string fadeOutName = "fadeOut";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the session ID member in the XML-RPC parameter structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string sessionIdName = "sessionId";
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================= module code */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the schedule entry ID from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<UniqueId>::Ref
|
||||||
|
XmlRpcTools :: extractScheduleEntryId(
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(scheduleEntryIdName)
|
||||||
|
|| xmlRpcValue[scheduleEntryIdName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||||
|
throw std::invalid_argument("missing or bad schedule entry ID "
|
||||||
|
"argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<UniqueId>::Ref id(new UniqueId(std::string(
|
||||||
|
xmlRpcValue[scheduleEntryIdName] )));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the playlist ID from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<UniqueId>::Ref
|
||||||
|
XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(playlistIdName)
|
||||||
|
|| xmlRpcValue[playlistIdName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||||
|
throw std::invalid_argument("missing or bad playlist ID argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<UniqueId>::Ref id(new UniqueId(std::string(
|
||||||
|
xmlRpcValue[playlistIdName] )));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the audio clip ID from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<UniqueId>::Ref
|
||||||
|
XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(audioClipIdName)
|
||||||
|
|| xmlRpcValue[audioClipIdName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||||
|
throw std::invalid_argument("missing or bad audio clip ID argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<UniqueId>::Ref id(new UniqueId(std::string(
|
||||||
|
xmlRpcValue[audioClipIdName] )));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the relative offset from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<time_duration>::Ref
|
||||||
|
XmlRpcTools :: extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(relativeOffsetName)
|
||||||
|
|| xmlRpcValue[relativeOffsetName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeInt) {
|
||||||
|
throw std::invalid_argument("missing relative offset argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,0,
|
||||||
|
int(xmlRpcValue[relativeOffsetName]), 0));
|
||||||
|
return relativeOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a Playlist to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: playlistToXmlRpcValue(
|
||||||
|
Ptr<const Playlist>::Ref playlist,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
xmlRpcValue["id"] = std::string(*playlist->getId());
|
||||||
|
xmlRpcValue["playlength"] = int(playlist->getPlaylength()->total_seconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a vector of Playlists into an XML-RPC value.
|
||||||
|
* This function returns an XML-RPC array of XML-RPC structures.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: playlistVectorToXmlRpcValue(
|
||||||
|
const Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue.setSize(playlistVector->size());
|
||||||
|
// a call to setSize() makes sure it's an XML-RPC
|
||||||
|
// array
|
||||||
|
|
||||||
|
std::vector<Ptr<Playlist>::Ref>::const_iterator it =
|
||||||
|
playlistVector->begin();
|
||||||
|
int arraySize = 0;
|
||||||
|
while (it != playlistVector->end()) {
|
||||||
|
Ptr<Playlist>::Ref playlist = *it;
|
||||||
|
XmlRpc::XmlRpcValue returnStruct;
|
||||||
|
playlistToXmlRpcValue(playlist, returnStruct);
|
||||||
|
returnValue[arraySize++] = returnStruct;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert an AudioClip to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: audioClipToXmlRpcValue(
|
||||||
|
Ptr<const AudioClip>::Ref audioClip,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
xmlRpcValue["id"] = std::string(*audioClip->getId());
|
||||||
|
xmlRpcValue["playlength"] = int(audioClip->getPlaylength()
|
||||||
|
->total_seconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a vector of AudioClips into an XML-RPC value.
|
||||||
|
* This function returns an XML-RPC array of XML-RPC structures.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: audioClipVectorToXmlRpcValue(
|
||||||
|
const Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClipVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue.setSize(audioClipVector->size());
|
||||||
|
// a call to setSize() makes sure it's an XML-RPC
|
||||||
|
// array
|
||||||
|
|
||||||
|
std::vector<Ptr<AudioClip>::Ref>::const_iterator it =
|
||||||
|
audioClipVector->begin();
|
||||||
|
int arraySize = 0;
|
||||||
|
while (it != audioClipVector->end()) {
|
||||||
|
Ptr<AudioClip>::Ref audioClip = *it;
|
||||||
|
XmlRpc::XmlRpcValue returnStruct;
|
||||||
|
audioClipToXmlRpcValue(audioClip, returnStruct);
|
||||||
|
returnValue[arraySize++] = returnStruct;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert an error code, error message pair to an XML-RPC fault response
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: markError(int errorCode, const std::string errorMessage,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (XmlRpc::XmlRpcException)
|
||||||
|
{
|
||||||
|
throw XmlRpc::XmlRpcException(errorMessage, errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert the valid status of a playlist to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: validStatusToXmlRpcValue(
|
||||||
|
bool validStatus,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
xmlRpcValue["valid"] = XmlRpc::XmlRpcValue(validStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the from time from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<ptime>::Ref
|
||||||
|
XmlRpcTools :: extractFromTime(
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(fromTimeName)
|
||||||
|
|| xmlRpcValue[fromTimeName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeDateTime) {
|
||||||
|
throw std::invalid_argument("missing or bad 'from' time in "
|
||||||
|
"parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm time = (struct tm) xmlRpcValue[fromTimeName];
|
||||||
|
return TimeConversion::tmToPtime(&time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the to time from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<ptime>::Ref
|
||||||
|
XmlRpcTools :: extractToTime(
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(toTimeName)
|
||||||
|
|| xmlRpcValue[toTimeName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeDateTime) {
|
||||||
|
throw std::invalid_argument("missing or bad 'to' time in "
|
||||||
|
"parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm time = (struct tm) xmlRpcValue[toTimeName];
|
||||||
|
return TimeConversion::tmToPtime(&time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a boost::posix_time::ptime to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: ptimeToXmlRpcValue(
|
||||||
|
Ptr<const ptime>::Ref ptimeParam,
|
||||||
|
XmlRpc::XmlRpcValue& xmlRpcValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
struct tm time;
|
||||||
|
Ptr<ptime>::Ref myPtime(new ptime(*ptimeParam)); // get rid of const
|
||||||
|
|
||||||
|
TimeConversion::ptimeToTm(myPtime, time);
|
||||||
|
xmlRpcValue = XmlRpc::XmlRpcValue(&time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a vector of ScheduleEntries into an XML-RPC value.
|
||||||
|
* This function returns an XML-RPC array of XML-RPC structures.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: scheduleEntriesToXmlRpcValue(
|
||||||
|
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref scheduleEntries,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue.setSize(scheduleEntries->size());
|
||||||
|
// a call to setSize() makes sure it's an XML-RPC
|
||||||
|
// array
|
||||||
|
|
||||||
|
std::vector<Ptr<ScheduleEntry>::Ref>::iterator it
|
||||||
|
= scheduleEntries->begin();
|
||||||
|
int arraySize = 0;
|
||||||
|
while (it != scheduleEntries->end()) {
|
||||||
|
Ptr<ScheduleEntry>::Ref entry = *it;
|
||||||
|
XmlRpc::XmlRpcValue returnStruct;
|
||||||
|
returnStruct["id"] = std::string(*entry->getId());
|
||||||
|
returnStruct["playlistId"] = std::string(*entry->getPlaylistId());
|
||||||
|
|
||||||
|
XmlRpc::XmlRpcValue time;
|
||||||
|
ptimeToXmlRpcValue(entry->getStartTime(), time);
|
||||||
|
returnStruct["start"] = time;
|
||||||
|
|
||||||
|
ptimeToXmlRpcValue(entry->getEndTime(), time);
|
||||||
|
returnStruct["end"] = time;
|
||||||
|
|
||||||
|
returnValue[arraySize++] = returnStruct;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the playtime from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<ptime>::Ref
|
||||||
|
XmlRpcTools :: extractPlayschedule(
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(playtimeName)
|
||||||
|
|| xmlRpcValue[playtimeName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeDateTime) {
|
||||||
|
throw std::invalid_argument("missing or bad playtime in "
|
||||||
|
"parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm time = (struct tm) xmlRpcValue[playtimeName];
|
||||||
|
return TimeConversion::tmToPtime(&time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the fade in time from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<time_duration>::Ref
|
||||||
|
XmlRpcTools :: extractFadeIn(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(fadeInName)
|
||||||
|
|| xmlRpcValue[fadeInName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeInt) {
|
||||||
|
throw std::invalid_argument("missing or bad 'fade in' argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<time_duration>::Ref fadeIn(new time_duration(0,0,
|
||||||
|
int(xmlRpcValue[fadeInName]), 0));
|
||||||
|
return fadeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the fade out time from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<time_duration>::Ref
|
||||||
|
XmlRpcTools :: extractFadeOut(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(fadeOutName)
|
||||||
|
|| xmlRpcValue[fadeOutName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeInt) {
|
||||||
|
throw std::invalid_argument("missing or bad 'fade out' argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<time_duration>::Ref fadeOut(new time_duration(0,0,
|
||||||
|
int(xmlRpcValue[fadeOutName]), 0));
|
||||||
|
return fadeOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a schedule entry ID (a UniqueId) to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: scheduleEntryIdToXmlRpcValue(
|
||||||
|
Ptr<const UniqueId>::Ref scheduleEntryId,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue[scheduleEntryIdName] = std::string(*scheduleEntryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a PlayLogEntry to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: playLogEntryToXmlRpcValue(
|
||||||
|
Ptr<const PlayLogEntry>::Ref playLogEntry,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue["audioClipId"] = std::string(*playLogEntry->getAudioClipId());
|
||||||
|
|
||||||
|
XmlRpc::XmlRpcValue timestamp;
|
||||||
|
ptimeToXmlRpcValue(playLogEntry->getTimestamp(), timestamp);
|
||||||
|
returnValue["timestamp"] = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a vector of PlayLogEntries into an XML-RPC value.
|
||||||
|
* This function returns an XML-RPC array of XML-RPC structures.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: playLogVectorToXmlRpcValue(
|
||||||
|
Ptr<const std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
|
||||||
|
playLogVector,
|
||||||
|
XmlRpc::XmlRpcValue & returnValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
returnValue.setSize(playLogVector->size());
|
||||||
|
// a call to setSize() makes sure it's an XML-RPC
|
||||||
|
// array
|
||||||
|
|
||||||
|
std::vector<Ptr<PlayLogEntry>::Ref>::const_iterator it =
|
||||||
|
playLogVector->begin();
|
||||||
|
int arraySize = 0;
|
||||||
|
while (it != playLogVector->end()) {
|
||||||
|
Ptr<PlayLogEntry>::Ref playLog = *it;
|
||||||
|
XmlRpc::XmlRpcValue returnStruct;
|
||||||
|
playLogEntryToXmlRpcValue(playLog, returnStruct);
|
||||||
|
returnValue[arraySize++] = returnStruct;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Extract the session ID from an XML-RPC function call parameter
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<SessionId>::Ref
|
||||||
|
XmlRpcTools :: extractSessionId(
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
if (!xmlRpcValue.hasMember(sessionIdName)
|
||||||
|
|| xmlRpcValue[sessionIdName].getType()
|
||||||
|
!= XmlRpc::XmlRpcValue::TypeString) {
|
||||||
|
throw std::invalid_argument("missing or bad session ID argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<SessionId>::Ref id(new SessionId(std::string(
|
||||||
|
xmlRpcValue[sessionIdName] )));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
200
livesupport/modules/core/src/XmlRpcToolsTest.cxx
Normal file
200
livesupport/modules/core/src/XmlRpcToolsTest.cxx
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
LiveSupport is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: fgerlits $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/XmlRpcToolsTest.cxx,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#error "Need unistd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <XmlRpcValue.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/XmlRpcTools.h"
|
||||||
|
#include "XmlRpcToolsTest.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace XmlRpc;
|
||||||
|
|
||||||
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcToolsTest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the configuration file for the playlist.
|
||||||
|
*/
|
||||||
|
const std::string configFileName = "etc/playlist.xml";
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================= module code */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Configure a Configurable with an XML file.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcToolsTest :: configure(
|
||||||
|
Ptr<Configurable>::Ref configurable,
|
||||||
|
const std::string fileName)
|
||||||
|
throw (CPPUNIT_NS::Exception)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Ptr<xmlpp::DomParser>::Ref parser(
|
||||||
|
new xmlpp::DomParser(configFileName, true));
|
||||||
|
const xmlpp::Document * document = parser->get_document();
|
||||||
|
const xmlpp::Element * root = document->get_root_node();
|
||||||
|
|
||||||
|
configurable->configure(*root);
|
||||||
|
} catch (std::invalid_argument &e) {
|
||||||
|
CPPUNIT_FAIL("semantic error in configuration file");
|
||||||
|
} catch (xmlpp::exception &e) {
|
||||||
|
CPPUNIT_FAIL("error parsing configuration file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Set up the test environment
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcToolsTest :: setUp(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Clean up the test environment
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcToolsTest :: tearDown(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Just a very simple smoke test
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcToolsTest :: firstTest(void)
|
||||||
|
throw (CPPUNIT_NS::Exception)
|
||||||
|
{
|
||||||
|
XmlRpcValue xmlRpcPlaylist;
|
||||||
|
XmlRpcValue xmlRpcAudioClip;
|
||||||
|
Ptr<Playlist>::Ref playlist = Ptr<Playlist>::Ref(new Playlist);
|
||||||
|
Ptr<const AudioClip>::Ref audioClip;
|
||||||
|
|
||||||
|
// set up a playlist instance
|
||||||
|
configure(playlist, configFileName);
|
||||||
|
audioClip = playlist->begin()->second->getAudioClip();
|
||||||
|
|
||||||
|
// run the packing methods
|
||||||
|
XmlRpcTools :: playlistToXmlRpcValue(playlist, xmlRpcPlaylist);
|
||||||
|
XmlRpcTools :: audioClipToXmlRpcValue(audioClip, xmlRpcAudioClip);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("id"));
|
||||||
|
CPPUNIT_ASSERT(xmlRpcPlaylist["id"].getType() == XmlRpcValue::TypeString);
|
||||||
|
CPPUNIT_ASSERT(std::string(xmlRpcPlaylist["id"]) == "0000000000000001");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("playlength"));
|
||||||
|
CPPUNIT_ASSERT(xmlRpcPlaylist["playlength"].getType()
|
||||||
|
== XmlRpcValue::TypeInt);
|
||||||
|
CPPUNIT_ASSERT(int(xmlRpcPlaylist["playlength"]) == 34);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("id"));
|
||||||
|
CPPUNIT_ASSERT(xmlRpcAudioClip["id"].getType() == XmlRpcValue::TypeString);
|
||||||
|
CPPUNIT_ASSERT(std::string(xmlRpcAudioClip["id"]) == "0000000000010001");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("playlength"));
|
||||||
|
CPPUNIT_ASSERT(xmlRpcAudioClip["playlength"].getType()
|
||||||
|
== XmlRpcValue::TypeInt);
|
||||||
|
CPPUNIT_ASSERT(int(xmlRpcAudioClip["playlength"]) == 11);
|
||||||
|
|
||||||
|
XmlRpcValue xmlRpcPlaylistId;
|
||||||
|
Ptr<UniqueId>::Ref playlistId(new UniqueId(rand()));
|
||||||
|
Ptr<UniqueId>::Ref audioClipId(new UniqueId(rand()));
|
||||||
|
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,0,rand(),0));
|
||||||
|
|
||||||
|
xmlRpcPlaylistId["playlistId"] = std::string(*playlistId);
|
||||||
|
xmlRpcPlaylistId["audioClipId"] = std::string(*audioClipId);
|
||||||
|
xmlRpcPlaylistId["relativeOffset"] = relativeOffset->total_seconds();
|
||||||
|
|
||||||
|
// run the unpacking methods
|
||||||
|
Ptr<UniqueId>::Ref newPlaylistId;
|
||||||
|
Ptr<UniqueId>::Ref newAudioClipId;
|
||||||
|
Ptr<time_duration>::Ref newRelativeOffset;
|
||||||
|
try {
|
||||||
|
newPlaylistId = XmlRpcTools::extractPlaylistId(xmlRpcPlaylistId);
|
||||||
|
newAudioClipId = XmlRpcTools::extractAudioClipId(xmlRpcPlaylistId);
|
||||||
|
newRelativeOffset = XmlRpcTools::extractRelativeOffset(xmlRpcPlaylistId);
|
||||||
|
}
|
||||||
|
catch (std::invalid_argument &e) {
|
||||||
|
CPPUNIT_FAIL(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(*playlistId == *newPlaylistId);
|
||||||
|
CPPUNIT_ASSERT(*audioClipId == *newAudioClipId);
|
||||||
|
CPPUNIT_ASSERT(*relativeOffset == *newRelativeOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Testing markError()
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcToolsTest :: errorTest(void)
|
||||||
|
throw (CPPUNIT_NS::Exception)
|
||||||
|
{
|
||||||
|
XmlRpcValue xmlRpcValue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
XmlRpcTools :: markError(42, "this is an error", xmlRpcValue);
|
||||||
|
CPPUNIT_FAIL("did not throw exception in markError()");
|
||||||
|
}
|
||||||
|
catch (XmlRpc::XmlRpcException &e) {
|
||||||
|
CPPUNIT_ASSERT(e.getCode() == 42);
|
||||||
|
CPPUNIT_ASSERT(e.getMessage() == "this is an error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
133
livesupport/modules/core/src/XmlRpcToolsTest.h
Normal file
133
livesupport/modules/core/src/XmlRpcToolsTest.h
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
LiveSupport is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: fgerlits $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/XmlRpcToolsTest.h,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
#ifndef XmlRpcToolsTest_h
|
||||||
|
#define XmlRpcToolsTest_h
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#error This is a C++ include file
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace LiveSupport {
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
using namespace LiveSupport;
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
|
||||||
|
/* =================================================================== macros */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================================== data types */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for the XmlRpcTools class.
|
||||||
|
*
|
||||||
|
* @author $Author: fgerlits $
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
* @see XmlRpcTools
|
||||||
|
*/
|
||||||
|
class XmlRpcToolsTest : public CPPUNIT_NS::TestFixture
|
||||||
|
{
|
||||||
|
CPPUNIT_TEST_SUITE(XmlRpcToolsTest);
|
||||||
|
CPPUNIT_TEST(firstTest);
|
||||||
|
CPPUNIT_TEST(errorTest);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure a configurable with an XML file.
|
||||||
|
*
|
||||||
|
* @param configurable configure this
|
||||||
|
* @param fileName the name of the XML file to configure with.
|
||||||
|
* @exception CPPUNIT_NS::Exception on XML parsing errors.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
configure(Ptr<Configurable>::Ref configurable,
|
||||||
|
std::string fileName)
|
||||||
|
throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple test.
|
||||||
|
*
|
||||||
|
* @exception CPPUNIT_NS::Exception on test failures.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testing the method for error message packaging.
|
||||||
|
*
|
||||||
|
* @exception CPPUNIT_NS::Exception on test failures.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
errorTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the environment for the test case.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setUp(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up the environment after the test case.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
tearDown(void) throw ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================= external data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================== function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Scheduler
|
||||||
|
} // namespace LiveSupport
|
||||||
|
|
||||||
|
#endif // XmlRpcToolsTest_h
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue