diff --git a/livesupport/products/scheduler/doc/model/SchedulerModel.zuml b/livesupport/products/scheduler/doc/model/SchedulerModel.zuml index a14396569..24be20da0 100644 Binary files a/livesupport/products/scheduler/doc/model/SchedulerModel.zuml and b/livesupport/products/scheduler/doc/model/SchedulerModel.zuml differ diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx index ba58b3e47..e0568fe4b 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -39,6 +39,7 @@ #include "LiveSupport/Storage/StorageClientFactory.h" #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" #include "DeletePlaylistMethod.h" @@ -81,23 +82,6 @@ DeletePlaylistMethod :: DeletePlaylistMethod ( } -/*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName])); - return id; -} - - /*------------------------------------------------------------------------------ * Execute the XML-RPC function call. * (Overrides 'execute' in XmlRpcServerMethod.) @@ -114,7 +98,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref id = extractPlaylistId(parameters[0]); + Ptr::Ref id = XmlRpcTools::extractPlaylistId(parameters[0]); Ptr::Ref scf; Ptr::Ref storage; diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.h b/livesupport/products/scheduler/src/DeletePlaylistMethod.h index 8f5b0f5b5..1549dc0ea 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.h +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -81,7 +81,7 @@ using namespace LiveSupport::Core; * * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -98,17 +98,6 @@ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod */ 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::Ref - extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); public: /** diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx index 6e0a6f18c..41ce2c1ff 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Storage/StorageClientFactory.h" #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" + #include "DisplayPlaylistMethod.h" @@ -90,37 +92,6 @@ DisplayPlaylistMethod :: DisplayPlaylistMethod ( } -/*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName])); - return id; -} - - -/*------------------------------------------------------------------------------ - * Convert a Playlist to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -DisplayPlaylistMethod :: playlistToXmlRpcValue( - Ptr::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. *----------------------------------------------------------------------------*/ @@ -136,7 +107,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref id = extractPlaylistId(parameters[0]); + Ptr::Ref id = XmlRpcTools::extractPlaylistId(parameters[0]); Ptr::Ref scf; Ptr::Ref storage; @@ -152,7 +123,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters, Ptr::Ref playlist = storage->getPlaylist(id); - playlistToXmlRpcValue(playlist, returnValue); + XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue); } catch (std::invalid_argument &e) { // TODO: mark error diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h index 03aa65779..fbacbc2b9 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -83,8 +83,8 @@ using namespace LiveSupport::Core; * * In case of an error, a simple false value is returned. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ */ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -101,29 +101,6 @@ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ 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::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::Ref playlist, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); public: /** diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx index 52d570353..8164ab6f3 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -38,6 +38,8 @@ #include "LiveSupport/Core/StorageClientInterface.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "XmlRpcTools.h" + #include "DisplayPlaylistsMethod.h" 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::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::Ref>::const_iterator it = - playlistVector->begin(); - int arraySize = 0; - while (it != playlistVector->end()) { - Ptr::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. *----------------------------------------------------------------------------*/ @@ -120,6 +94,6 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters, Ptr::Ref> >::Ref playlistVector = storage->getAllPlaylists(); - playlistVectorToXmlRpcValue(playlistVector, returnValue); + XmlRpcTools::playlistVectorToXmlRpcValue(playlistVector, returnValue); } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h index e2b3f4641..100c3ec9b 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -83,7 +83,7 @@ using namespace LiveSupport::Core; * * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod { @@ -94,18 +94,6 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod */ 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::Ref> >::Ref playlistVector, - XmlRpc::XmlRpcValue & returnValue) - throw (); public: /** diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx index 270743730..38fa67046 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,8 @@ #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" + #include "DisplayScheduleMethod.h" @@ -65,18 +67,6 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ 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 */ @@ -93,109 +83,6 @@ DisplayScheduleMethod :: DisplayScheduleMethod ( } -/*------------------------------------------------------------------------------ - * Extract the from time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref ptime(new ptime(date, hours)); - - return ptime; -} - - -/*------------------------------------------------------------------------------ - * Extract the to time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref ptime(new ptime(date, hours)); - - return ptime; -} - - -/*------------------------------------------------------------------------------ - * Convert a boost::posix_time::ptime to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -DisplayScheduleMethod :: ptimeToXmlRpcValue( - Ptr::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::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::Ref>::iterator it - = scheduleEntries->begin(); - int arraySize = 0; - while (it != scheduleEntries->end()) { - Ptr::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. *----------------------------------------------------------------------------*/ @@ -211,8 +98,10 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref fromTime = extractFrom(parameters[0]); - Ptr::Ref toTime = extractTo(parameters[0]); + Ptr::Ref fromTime + = XmlRpcTools::extractFromTime(parameters[0]); + Ptr::Ref toTime + = XmlRpcTools::extractToTime(parameters[0]); Ptr::Ref sf = ScheduleFactory::getInstance(); Ptr::Ref schedule = sf->getSchedule(); @@ -220,7 +109,8 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, Ptr::Ref> >::Ref scheduleEntries = schedule->getScheduleEntries(fromTime, toTime); - scheduleEntriesToXmlRpcValue(scheduleEntries, returnValue); + XmlRpcTools::scheduleEntriesToXmlRpcValue(scheduleEntries, + returnValue); } catch (std::invalid_argument &e) { // TODO: mark error diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.h b/livesupport/products/scheduler/src/DisplayScheduleMethod.h index e749532d2..e24769cf9 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.h +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -92,8 +92,8 @@ using namespace LiveSupport::Core; *
  • end - datetime - the end of the scheduled item
  • * * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ */ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -104,66 +104,6 @@ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod */ 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::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::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::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::Ref> >::Ref scheduleEntries, - XmlRpc::XmlRpcValue & returnValue) - throw (); public: /** diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx index e87e6a7c6..a18a4e392 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,8 @@ #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" + #include "RemoveFromScheduleMethod.h" @@ -62,13 +64,6 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ 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 */ @@ -85,23 +80,6 @@ RemoveFromScheduleMethod :: RemoveFromScheduleMethod ( } -/*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName])); - return id; -} - - /*------------------------------------------------------------------------------ * Execute the remove from schedule XML-RPC function call. *----------------------------------------------------------------------------*/ @@ -117,7 +95,8 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref entryId = extractScheduleEntryId(parameters[0]); + Ptr::Ref entryId + = XmlRpcTools::extractScheduleEntryId(parameters[0]); Ptr::Ref sf = ScheduleFactory::getInstance(); Ptr::Ref schedule = sf->getSchedule(); diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h index 81b80ed41..77765e49c 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -74,8 +74,8 @@ using namespace LiveSupport::Core; *
  • scheduleEntryId - int - the id of the scheduled entry to remove
  • * * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ */ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -86,24 +86,6 @@ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod */ 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::Ref - extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - public: /** diff --git a/livesupport/products/scheduler/src/RescheduleMethod.cxx b/livesupport/products/scheduler/src/RescheduleMethod.cxx index 784f37759..1c066f6b9 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RescheduleMethod.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -44,6 +44,8 @@ #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" + #include "RescheduleMethod.h" @@ -65,19 +67,6 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ 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 */ @@ -94,44 +83,6 @@ RescheduleMethod :: RescheduleMethod ( } -/*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName])); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the playtime from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref ptime(new ptime(date, hours)); - - return ptime; -} - - /*------------------------------------------------------------------------------ * Execute the upload playlist method XML-RPC function call. *----------------------------------------------------------------------------*/ @@ -147,8 +98,10 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref entryId = extractScheduleEntryId(parameters[0]); - Ptr::Ref playschedule = extractPlayschedule(parameters[0]); + Ptr::Ref entryId + = XmlRpcTools::extractScheduleEntryId(parameters[0]); + Ptr::Ref playschedule + = XmlRpcTools::extractPlayschedule(parameters[0]); Ptr::Ref scheduleEntryId; Ptr::Ref sf = ScheduleFactory::getInstance(); @@ -168,7 +121,6 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - returnValue = XmlRpc::XmlRpcValue(true); } diff --git a/livesupport/products/scheduler/src/RescheduleMethod.h b/livesupport/products/scheduler/src/RescheduleMethod.h index adf6f4f85..bb6e96de3 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.h +++ b/livesupport/products/scheduler/src/RescheduleMethod.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ 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, * or a boolean false, if there were errors. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ */ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod { @@ -90,42 +90,6 @@ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod */ 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::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::Ref - extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - public: /** diff --git a/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx index 46ea5b08d..b74f8a28a 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ 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_sec = 0; parameters["to"] = &time; - xmlRpcClient.execute("displaySchedule", parameters, result); CPPUNIT_ASSERT(result.valid()); CPPUNIT_ASSERT(result.size() == 0); diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx index 5f50bfa13..d8899c60c 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Storage/StorageClientFactory.h" #include "ScheduleInterface.h" #include "ScheduleFactory.h" +#include "XmlRpcTools.h" + #include "UploadPlaylistMethod.h" @@ -68,18 +70,6 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ 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 */ @@ -96,44 +86,6 @@ UploadPlaylistMethod :: UploadPlaylistMethod ( } -/*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref id(new UniqueId((int) xmlRpcValue[playlistIdName])); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the playtime from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::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::Ref ptime(new ptime(date, hours)); - - return ptime; -} - - /*------------------------------------------------------------------------------ * Execute the upload playlist method XML-RPC function call. *----------------------------------------------------------------------------*/ @@ -149,8 +101,10 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters, return; } - Ptr::Ref id = extractPlaylistId(parameters[0]); - Ptr::Ref playschedule = extractPlayschedule(parameters[0]); + Ptr::Ref id + = XmlRpcTools::extractPlaylistId(parameters[0]); + Ptr::Ref playschedule + = XmlRpcTools::extractPlayschedule(parameters[0]); Ptr::Ref scheduleEntryId; Ptr::Ref scf; diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.h b/livesupport/products/scheduler/src/UploadPlaylistMethod.h index e831277b9..ef79d2921 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.h +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.5 $ 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 * by uploading, or a boolean false, if there were errors. * - * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.5 $ */ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod { @@ -91,42 +91,6 @@ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod */ 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::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::Ref - extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - public: /** diff --git a/livesupport/products/scheduler/src/XmlRpcTools.cxx b/livesupport/products/scheduler/src/XmlRpcTools.cxx index 45873ea78..1dad6ef45 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.cxx +++ b/livesupport/products/scheduler/src/XmlRpcTools.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -70,6 +70,31 @@ const std::string XmlRpcTools::audioClipIdName = "audioClipId"; *----------------------------------------------------------------------------*/ 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 */ @@ -79,6 +104,23 @@ const std::string XmlRpcTools::relativeOffsetName = "relativeOffset"; /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Extract the schedule entry ID from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +XmlRpcTools :: extractScheduleEntryId( + XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(scheduleEntryIdName)) { + throw std::invalid_argument("missing schedule entry ID argument"); + } + + Ptr::Ref id(new UniqueId((int) xmlRpcValue[scheduleEntryIdName])); + return id; +} + + /*------------------------------------------------------------------------------ * 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::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::Ref>::const_iterator it = + playlistVector->begin(); + int arraySize = 0; + while (it != playlistVector->end()) { + Ptr::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 *----------------------------------------------------------------------------*/ @@ -167,3 +237,127 @@ XmlRpcTools :: validStatusToXmlRpcValue( xmlRpcValue["valid"] = XmlRpc::XmlRpcValue(validStatus); } + +/*------------------------------------------------------------------------------ + * Extract the from time from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::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::Ref ptime(new ptime(date, hours)); + + return ptime; +} + + +/*------------------------------------------------------------------------------ + * Extract the to time from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::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::Ref ptime(new ptime(date, hours)); + + return ptime; +} + + +/*------------------------------------------------------------------------------ + * Convert a boost::posix_time::ptime to an XmlRpcValue + *----------------------------------------------------------------------------*/ +void +XmlRpcTools :: ptimeToXmlRpcValue( + Ptr::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::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::Ref>::iterator it + = scheduleEntries->begin(); + int arraySize = 0; + while (it != scheduleEntries->end()) { + Ptr::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::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::Ref ptime(new ptime(date, hours)); + + return ptime; +} + diff --git a/livesupport/products/scheduler/src/XmlRpcTools.h b/livesupport/products/scheduler/src/XmlRpcTools.h index 282965cef..99ba46739 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.h +++ b/livesupport/products/scheduler/src/XmlRpcTools.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -42,10 +42,13 @@ #include #include +#include #include +#include #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Playlist.h" +#include "ScheduleEntry.h" namespace LiveSupport { @@ -68,11 +71,11 @@ using namespace LiveSupport::Core; * in the Scheduler. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class XmlRpcTools { - public: + private: /** * The name of the playlistId member in the XML-RPC parameter * structure given as the input to an XmlRpcServerMethod. @@ -91,6 +94,56 @@ class XmlRpcTools */ 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::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::Ref + extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + /** * Extract the playlist id from the XML-RPC parameters. * @@ -162,6 +215,69 @@ class XmlRpcTools validStatusToXmlRpcValue(bool validStatus, 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::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::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::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::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::Ref> >::Ref scheduleEntries, + XmlRpc::XmlRpcValue & returnValue) + throw (); + }; /* ================================================= external data structures */