moved XML-RPC packing/unpacking functions to XmlRpcTools.cxx
This commit is contained in:
parent
a5b4dd625e
commit
acd6329cac
Binary file not shown.
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "DeletePlaylistMethod.h"
|
#include "DeletePlaylistMethod.h"
|
||||||
|
|
||||||
|
@ -81,23 +82,6 @@ DeletePlaylistMethod :: DeletePlaylistMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the UniqueId from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
DeletePlaylistMethod :: extractPlaylistId(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(playlistIdName)) {
|
|
||||||
throw std::invalid_argument("no playlist id in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the XML-RPC function call.
|
* Execute the XML-RPC function call.
|
||||||
* (Overrides 'execute' in XmlRpcServerMethod.)
|
* (Overrides 'execute' in XmlRpcServerMethod.)
|
||||||
|
@ -114,7 +98,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id = extractPlaylistId(parameters[0]);
|
Ptr<UniqueId>::Ref id = XmlRpcTools::extractPlaylistId(parameters[0]);
|
||||||
|
|
||||||
Ptr<StorageClientFactory>::Ref scf;
|
Ptr<StorageClientFactory>::Ref scf;
|
||||||
Ptr<StorageClientInterface>::Ref storage;
|
Ptr<StorageClientInterface>::Ref storage;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -81,7 +81,7 @@ using namespace LiveSupport::Core;
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -98,17 +98,6 @@ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string playlistIdName;
|
static const std::string playlistIdName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 UniqueId
|
|
||||||
* in xmlRpcValue
|
|
||||||
*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -46,6 +46,8 @@
|
||||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "DisplayPlaylistMethod.h"
|
#include "DisplayPlaylistMethod.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,37 +92,6 @@ DisplayPlaylistMethod :: DisplayPlaylistMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the UniqueId from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
DisplayPlaylistMethod :: extractPlaylistId(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(playlistIdName)) {
|
|
||||||
throw std::invalid_argument("no playlist id in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Convert a Playlist to an XmlRpcValue
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
DisplayPlaylistMethod :: playlistToXmlRpcValue(
|
|
||||||
Ptr<const Playlist>::Ref playlist,
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw ()
|
|
||||||
{
|
|
||||||
xmlRpcValue["id"] = (int) (playlist->getId()->getId());
|
|
||||||
xmlRpcValue["playlength"] = playlist->getPlaylength()->total_seconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the stop XML-RPC function call.
|
* Execute the stop XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -136,7 +107,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id = extractPlaylistId(parameters[0]);
|
Ptr<UniqueId>::Ref id = XmlRpcTools::extractPlaylistId(parameters[0]);
|
||||||
|
|
||||||
Ptr<StorageClientFactory>::Ref scf;
|
Ptr<StorageClientFactory>::Ref scf;
|
||||||
Ptr<StorageClientInterface>::Ref storage;
|
Ptr<StorageClientInterface>::Ref storage;
|
||||||
|
@ -152,7 +123,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
|
|
||||||
Ptr<Playlist>::Ref playlist = storage->getPlaylist(id);
|
Ptr<Playlist>::Ref playlist = storage->getPlaylist(id);
|
||||||
|
|
||||||
playlistToXmlRpcValue(playlist, returnValue);
|
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
|
||||||
|
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
// TODO: mark error
|
// TODO: mark error
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -83,8 +83,8 @@ using namespace LiveSupport::Core;
|
||||||
* </ul>
|
* </ul>
|
||||||
* In case of an error, a simple false value is returned.
|
* In case of an error, a simple false value is returned.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -101,29 +101,6 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string playlistIdName;
|
static const std::string playlistIdName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 UniqueId
|
|
||||||
* in xmlRpcValue
|
|
||||||
*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
extractPlaylistId(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 value of
|
|
||||||
* the conversion.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
playlistToXmlRpcValue(Ptr<const Playlist>::Ref playlist,
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw ();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
#include "LiveSupport/Core/StorageClientInterface.h"
|
#include "LiveSupport/Core/StorageClientInterface.h"
|
||||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "DisplayPlaylistsMethod.h"
|
#include "DisplayPlaylistsMethod.h"
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
@ -75,34 +77,6 @@ DisplayPlaylistsMethod :: DisplayPlaylistsMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Convert a vector of Playlists into an XML-RPC value.
|
|
||||||
* This function returns an XML-RPC array of XML-RPC structures.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
DisplayPlaylistsMethod :: 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;
|
|
||||||
returnStruct["id"] = (int) (playlist->getId()->getId());
|
|
||||||
returnStruct["playlength"] = playlist->getPlaylength()->total_seconds();
|
|
||||||
returnValue[arraySize++] = returnStruct;
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the stop XML-RPC function call.
|
* Execute the stop XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -120,6 +94,6 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
|
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector =
|
||||||
storage->getAllPlaylists();
|
storage->getAllPlaylists();
|
||||||
|
|
||||||
playlistVectorToXmlRpcValue(playlistVector, returnValue);
|
XmlRpcTools::playlistVectorToXmlRpcValue(playlistVector, returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -83,7 +83,7 @@ using namespace LiveSupport::Core;
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -94,18 +94,6 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string methodName;
|
static const std::string methodName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
playlistVectorToXmlRpcValue(
|
|
||||||
const Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlistVector,
|
|
||||||
XmlRpc::XmlRpcValue & returnValue)
|
|
||||||
throw ();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "DisplayScheduleMethod.h"
|
#include "DisplayScheduleMethod.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,18 +67,6 @@ using namespace LiveSupport::Scheduler;
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string DisplayScheduleMethod::methodName = "displaySchedule";
|
const std::string DisplayScheduleMethod::methodName = "displaySchedule";
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the from member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string DisplayScheduleMethod::fromName = "from";
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the to member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string DisplayScheduleMethod::toName = "to";
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
@ -93,109 +83,6 @@ DisplayScheduleMethod :: DisplayScheduleMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the from time from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<ptime>::Ref
|
|
||||||
DisplayScheduleMethod :: extractFrom(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(fromName)) {
|
|
||||||
throw std::invalid_argument("no from part in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm tm = (struct tm) xmlRpcValue[fromName];
|
|
||||||
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
|
||||||
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
||||||
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
|
||||||
|
|
||||||
return ptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the to time from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<ptime>::Ref
|
|
||||||
DisplayScheduleMethod :: extractTo(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(toName)) {
|
|
||||||
throw std::invalid_argument("no to part in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm tm = (struct tm) xmlRpcValue[toName];
|
|
||||||
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
|
||||||
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
||||||
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
|
||||||
|
|
||||||
return ptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Convert a boost::posix_time::ptime to an XmlRpcValue
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
DisplayScheduleMethod :: ptimeToXmlRpcValue(
|
|
||||||
Ptr<const ptime>::Ref ptime,
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw ()
|
|
||||||
{
|
|
||||||
gregorian::date date = ptime->date();
|
|
||||||
posix_time::time_duration hours = ptime->time_of_day();
|
|
||||||
struct tm time;
|
|
||||||
|
|
||||||
time.tm_year = date.year();
|
|
||||||
time.tm_mon = date.month();
|
|
||||||
time.tm_mday = date.day();
|
|
||||||
time.tm_hour = hours.hours();
|
|
||||||
time.tm_min = hours.minutes();
|
|
||||||
time.tm_sec = hours.seconds();
|
|
||||||
// TODO: set tm_wday, tm_yday and tm_isdst fields as well
|
|
||||||
|
|
||||||
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
|
|
||||||
DisplayScheduleMethod :: 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"] = (int) (entry->getId()->getId());
|
|
||||||
returnStruct["playlistId"] = (int) (entry->getPlaylistId()->getId());
|
|
||||||
|
|
||||||
XmlRpc::XmlRpcValue time;
|
|
||||||
ptimeToXmlRpcValue(entry->getStartTime(), time);
|
|
||||||
returnStruct["start"] = time;
|
|
||||||
|
|
||||||
ptimeToXmlRpcValue(entry->getEndTime(), time);
|
|
||||||
returnStruct["end"] = time;
|
|
||||||
|
|
||||||
returnValue[arraySize++] = returnStruct;
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the stop XML-RPC function call.
|
* Execute the stop XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -211,8 +98,10 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<ptime>::Ref fromTime = extractFrom(parameters[0]);
|
Ptr<ptime>::Ref fromTime
|
||||||
Ptr<ptime>::Ref toTime = extractTo(parameters[0]);
|
= XmlRpcTools::extractFromTime(parameters[0]);
|
||||||
|
Ptr<ptime>::Ref toTime
|
||||||
|
= XmlRpcTools::extractToTime(parameters[0]);
|
||||||
|
|
||||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||||
Ptr<ScheduleInterface>::Ref schedule = sf->getSchedule();
|
Ptr<ScheduleInterface>::Ref schedule = sf->getSchedule();
|
||||||
|
@ -220,7 +109,8 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref scheduleEntries
|
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref scheduleEntries
|
||||||
= schedule->getScheduleEntries(fromTime, toTime);
|
= schedule->getScheduleEntries(fromTime, toTime);
|
||||||
|
|
||||||
scheduleEntriesToXmlRpcValue(scheduleEntries, returnValue);
|
XmlRpcTools::scheduleEntriesToXmlRpcValue(scheduleEntries,
|
||||||
|
returnValue);
|
||||||
|
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
// TODO: mark error
|
// TODO: mark error
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -92,8 +92,8 @@ using namespace LiveSupport::Core;
|
||||||
* <li>end - datetime - the end of the scheduled item</li>
|
* <li>end - datetime - the end of the scheduled item</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -104,66 +104,6 @@ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string methodName;
|
static const std::string methodName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the from member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string fromName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the to member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string toName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
Ptr<boost::posix_time::ptime>::Ref
|
|
||||||
extractFrom(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
|
|
||||||
*/
|
|
||||||
Ptr<boost::posix_time::ptime>::Ref
|
|
||||||
extractTo(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 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.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
scheduleEntriesToXmlRpcValue(
|
|
||||||
Ptr<std::vector<Ptr<ScheduleEntry>::Ref> >::Ref scheduleEntries,
|
|
||||||
XmlRpc::XmlRpcValue & returnValue)
|
|
||||||
throw ();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "RemoveFromScheduleMethod.h"
|
#include "RemoveFromScheduleMethod.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,13 +64,6 @@ using namespace LiveSupport::Scheduler;
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string RemoveFromScheduleMethod::methodName = "removeFromSchedule";
|
const std::string RemoveFromScheduleMethod::methodName = "removeFromSchedule";
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the playlist id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string RemoveFromScheduleMethod::scheduleEntryIdName =
|
|
||||||
"scheduleEntryId";
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
@ -85,23 +80,6 @@ RemoveFromScheduleMethod :: RemoveFromScheduleMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the UniqueId from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
RemoveFromScheduleMethod :: extractScheduleEntryId(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(scheduleEntryIdName)) {
|
|
||||||
throw std::invalid_argument("no playlist id in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the remove from schedule XML-RPC function call.
|
* Execute the remove from schedule XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -117,7 +95,8 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref entryId = extractScheduleEntryId(parameters[0]);
|
Ptr<UniqueId>::Ref entryId
|
||||||
|
= XmlRpcTools::extractScheduleEntryId(parameters[0]);
|
||||||
|
|
||||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||||
Ptr<ScheduleInterface>::Ref schedule = sf->getSchedule();
|
Ptr<ScheduleInterface>::Ref schedule = sf->getSchedule();
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -74,8 +74,8 @@ using namespace LiveSupport::Core;
|
||||||
* <li>scheduleEntryId - int - the id of the scheduled entry to remove</li>
|
* <li>scheduleEntryId - int - the id of the scheduled entry to remove</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -86,24 +86,6 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string methodName;
|
static const std::string methodName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the entry id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string scheduleEntryIdName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "RescheduleMethod.h"
|
#include "RescheduleMethod.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,19 +67,6 @@ using namespace LiveSupport::Scheduler;
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string RescheduleMethod::methodName = "reschedule";
|
const std::string RescheduleMethod::methodName = "reschedule";
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the playlist id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string RescheduleMethod::scheduleEntryIdName =
|
|
||||||
"scheduleEntryId";
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the playtime member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string RescheduleMethod::playtimeName = "playtime";
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
@ -94,44 +83,6 @@ RescheduleMethod :: RescheduleMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the UniqueId from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
RescheduleMethod :: extractScheduleEntryId(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(scheduleEntryIdName)) {
|
|
||||||
throw std::invalid_argument("no playlist id in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the playtime from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<ptime>::Ref
|
|
||||||
RescheduleMethod :: extractPlayschedule(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(playtimeName)) {
|
|
||||||
throw std::invalid_argument("no playtime in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm tm = (struct tm) xmlRpcValue[playtimeName];
|
|
||||||
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
|
||||||
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
||||||
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
|
||||||
|
|
||||||
return ptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the upload playlist method XML-RPC function call.
|
* Execute the upload playlist method XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -147,8 +98,10 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref entryId = extractScheduleEntryId(parameters[0]);
|
Ptr<UniqueId>::Ref entryId
|
||||||
Ptr<ptime>::Ref playschedule = extractPlayschedule(parameters[0]);
|
= XmlRpcTools::extractScheduleEntryId(parameters[0]);
|
||||||
|
Ptr<ptime>::Ref playschedule
|
||||||
|
= XmlRpcTools::extractPlayschedule(parameters[0]);
|
||||||
Ptr<UniqueId>::Ref scheduleEntryId;
|
Ptr<UniqueId>::Ref scheduleEntryId;
|
||||||
|
|
||||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||||
|
@ -168,7 +121,6 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
returnValue = XmlRpc::XmlRpcValue(true);
|
returnValue = XmlRpc::XmlRpcValue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -78,8 +78,8 @@ using namespace LiveSupport::Core;
|
||||||
* The return value is true if all went well,
|
* The return value is true if all went well,
|
||||||
* or a boolean false, if there were errors.
|
* or a boolean false, if there were errors.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
|
class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -90,42 +90,6 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string methodName;
|
static const std::string methodName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the scheduled entry id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string scheduleEntryIdName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the playtime member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string playtimeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
extractScheduleEntryId(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
|
|
||||||
*/
|
|
||||||
Ptr<boost::posix_time::ptime>::Ref
|
|
||||||
extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayScheduleTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayScheduleTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -140,7 +140,6 @@ SchedulerDaemonDisplayScheduleTest :: simpleTest(void)
|
||||||
time.tm_min = 0;
|
time.tm_min = 0;
|
||||||
time.tm_sec = 0;
|
time.tm_sec = 0;
|
||||||
parameters["to"] = &time;
|
parameters["to"] = &time;
|
||||||
|
|
||||||
xmlRpcClient.execute("displaySchedule", parameters, result);
|
xmlRpcClient.execute("displaySchedule", parameters, result);
|
||||||
CPPUNIT_ASSERT(result.valid());
|
CPPUNIT_ASSERT(result.valid());
|
||||||
CPPUNIT_ASSERT(result.size() == 0);
|
CPPUNIT_ASSERT(result.size() == 0);
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.4 $
|
Version : $Revision: 1.5 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -46,6 +46,8 @@
|
||||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||||
#include "ScheduleInterface.h"
|
#include "ScheduleInterface.h"
|
||||||
#include "ScheduleFactory.h"
|
#include "ScheduleFactory.h"
|
||||||
|
#include "XmlRpcTools.h"
|
||||||
|
|
||||||
#include "UploadPlaylistMethod.h"
|
#include "UploadPlaylistMethod.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,18 +70,6 @@ using namespace LiveSupport::Scheduler;
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string UploadPlaylistMethod::methodName = "uploadPlaylist";
|
const std::string UploadPlaylistMethod::methodName = "uploadPlaylist";
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the playlist id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string UploadPlaylistMethod::playlistIdName = "playlistId";
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* The name of the playtime member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
const std::string UploadPlaylistMethod::playtimeName = "playtime";
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
@ -96,44 +86,6 @@ UploadPlaylistMethod :: UploadPlaylistMethod (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the UniqueId from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
UploadPlaylistMethod :: extractPlaylistId(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(playlistIdName)) {
|
|
||||||
throw std::invalid_argument("no playlist id in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Extract the playtime from an XML-RPC function call parameter
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
Ptr<ptime>::Ref
|
|
||||||
UploadPlaylistMethod :: extractPlayschedule(
|
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument)
|
|
||||||
{
|
|
||||||
if (!xmlRpcValue.hasMember(playtimeName)) {
|
|
||||||
throw std::invalid_argument("no playtime in parameter structure");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm tm = (struct tm) xmlRpcValue[playtimeName];
|
|
||||||
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
|
||||||
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
||||||
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
|
||||||
|
|
||||||
return ptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Execute the upload playlist method XML-RPC function call.
|
* Execute the upload playlist method XML-RPC function call.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -149,8 +101,10 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UniqueId>::Ref id = extractPlaylistId(parameters[0]);
|
Ptr<UniqueId>::Ref id
|
||||||
Ptr<ptime>::Ref playschedule = extractPlayschedule(parameters[0]);
|
= XmlRpcTools::extractPlaylistId(parameters[0]);
|
||||||
|
Ptr<ptime>::Ref playschedule
|
||||||
|
= XmlRpcTools::extractPlayschedule(parameters[0]);
|
||||||
Ptr<UniqueId>::Ref scheduleEntryId;
|
Ptr<UniqueId>::Ref scheduleEntryId;
|
||||||
|
|
||||||
Ptr<StorageClientFactory>::Ref scf;
|
Ptr<StorageClientFactory>::Ref scf;
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.4 $
|
Version : $Revision: 1.5 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -79,8 +79,8 @@ using namespace LiveSupport::Core;
|
||||||
* The return value is an int, the id of the schedule entry created
|
* The return value is an int, the id of the schedule entry created
|
||||||
* by uploading, or a boolean false, if there were errors.
|
* by uploading, or a boolean false, if there were errors.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
{
|
{
|
||||||
|
@ -91,42 +91,6 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod
|
||||||
*/
|
*/
|
||||||
static const std::string methodName;
|
static const std::string methodName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the playlist id member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string playlistIdName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the playtime member in the XML-RPC parameter
|
|
||||||
* structure.
|
|
||||||
*/
|
|
||||||
static const std::string playtimeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 UniqueId
|
|
||||||
* in xmlRpcValue
|
|
||||||
*/
|
|
||||||
Ptr<UniqueId>::Ref
|
|
||||||
extractPlaylistId(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
|
|
||||||
*/
|
|
||||||
Ptr<boost::posix_time::ptime>::Ref
|
|
||||||
extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|
||||||
throw (std::invalid_argument);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -70,6 +70,31 @@ const std::string XmlRpcTools::audioClipIdName = "audioClipId";
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string XmlRpcTools::relativeOffsetName = "relativeOffset";
|
const std::string XmlRpcTools::relativeOffsetName = "relativeOffset";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the from member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const std::string XmlRpcTools::fromTimeName = "from";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the to member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const std::string XmlRpcTools::toTimeName = "to";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playlist id member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const std::string XmlRpcTools::scheduleEntryIdName =
|
||||||
|
"scheduleEntryId";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the playtime member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const std::string XmlRpcTools::playtimeName = "playtime";
|
||||||
|
|
||||||
|
|
||||||
/* ================================================ local constants & macros */
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
@ -79,6 +104,23 @@ const std::string XmlRpcTools::relativeOffsetName = "relativeOffset";
|
||||||
|
|
||||||
/* ============================================================= module code */
|
/* ============================================================= 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)) {
|
||||||
|
throw std::invalid_argument("missing schedule entry ID argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName]));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Extract the playlist ID from an XML-RPC function call parameter
|
* Extract the playlist ID from an XML-RPC function call parameter
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -142,6 +184,34 @@ XmlRpcTools :: playlistToXmlRpcValue(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* 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;
|
||||||
|
returnStruct["id"] = (int) (playlist->getId()->getId());
|
||||||
|
returnStruct["playlength"] = playlist->getPlaylength()->total_seconds();
|
||||||
|
returnValue[arraySize++] = returnStruct;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Convert an error code, error message pair to an XmlRpcValue
|
* Convert an error code, error message pair to an XmlRpcValue
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -167,3 +237,127 @@ XmlRpcTools :: validStatusToXmlRpcValue(
|
||||||
xmlRpcValue["valid"] = XmlRpc::XmlRpcValue(validStatus);
|
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)) {
|
||||||
|
throw std::invalid_argument("no from part in parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm = (struct tm) xmlRpcValue[fromTimeName];
|
||||||
|
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
||||||
|
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
|
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
||||||
|
|
||||||
|
return ptime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* 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)) {
|
||||||
|
throw std::invalid_argument("no to part in parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm = (struct tm) xmlRpcValue[toTimeName];
|
||||||
|
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
||||||
|
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
|
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
||||||
|
|
||||||
|
return ptime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Convert a boost::posix_time::ptime to an XmlRpcValue
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
XmlRpcTools :: ptimeToXmlRpcValue(
|
||||||
|
Ptr<const ptime>::Ref ptime,
|
||||||
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
gregorian::date date = ptime->date();
|
||||||
|
posix_time::time_duration hours = ptime->time_of_day();
|
||||||
|
struct tm time;
|
||||||
|
|
||||||
|
time.tm_year = date.year();
|
||||||
|
time.tm_mon = date.month();
|
||||||
|
time.tm_mday = date.day();
|
||||||
|
time.tm_hour = hours.hours();
|
||||||
|
time.tm_min = hours.minutes();
|
||||||
|
time.tm_sec = hours.seconds();
|
||||||
|
// TODO: set tm_wday, tm_yday and tm_isdst fields as well
|
||||||
|
|
||||||
|
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"] = (int) (entry->getId()->getId());
|
||||||
|
returnStruct["playlistId"] = (int) (entry->getPlaylistId()->getId());
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
throw std::invalid_argument("no playtime in parameter structure");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm = (struct tm) xmlRpcValue[playtimeName];
|
||||||
|
gregorian::date date(tm.tm_year, tm.tm_mon, tm.tm_mday);
|
||||||
|
time_duration hours(tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
|
Ptr<ptime>::Ref ptime(new ptime(date, hours));
|
||||||
|
|
||||||
|
return ptime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -42,10 +42,13 @@
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <XmlRpcValue.h>
|
#include <XmlRpcValue.h>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
#include "LiveSupport/Core/Ptr.h"
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
#include "LiveSupport/Core/Playlist.h"
|
#include "LiveSupport/Core/Playlist.h"
|
||||||
|
#include "ScheduleEntry.h"
|
||||||
|
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
|
@ -68,11 +71,11 @@ using namespace LiveSupport::Core;
|
||||||
* in the Scheduler.
|
* in the Scheduler.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
class XmlRpcTools
|
class XmlRpcTools
|
||||||
{
|
{
|
||||||
public:
|
private:
|
||||||
/**
|
/**
|
||||||
* The name of the playlistId member in the XML-RPC parameter
|
* The name of the playlistId member in the XML-RPC parameter
|
||||||
* structure given as the input to an XmlRpcServerMethod.
|
* structure given as the input to an XmlRpcServerMethod.
|
||||||
|
@ -91,6 +94,56 @@ class XmlRpcTools
|
||||||
*/
|
*/
|
||||||
static const std::string relativeOffsetName;
|
static const std::string relativeOffsetName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the from member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
static const std::string fromTimeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the to member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
static const std::string toTimeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the entry id member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
static const std::string scheduleEntryIdName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the playtime member in the XML-RPC parameter
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
static const std::string playtimeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ();
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
* Extract the playlist id from the XML-RPC parameters.
|
||||||
*
|
*
|
||||||
|
@ -162,6 +215,69 @@ class XmlRpcTools
|
||||||
validStatusToXmlRpcValue(bool validStatus,
|
validStatusToXmlRpcValue(bool validStatus,
|
||||||
XmlRpc::XmlRpcValue & xmlRpcValue)
|
XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||||
throw ();
|
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 ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================= external data structures */
|
/* ================================================= external data structures */
|
||||||
|
|
Loading…
Reference in New Issue