fixed playlist event
now scheduler correclty plays scheduled events
This commit is contained in:
parent
bd36de8bd4
commit
9a185bb141
|
@ -1,8 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE scheduler [
|
||||
|
||||
<!ELEMENT scheduler (connectionManagerFactory,storageClientFactory,
|
||||
scheduleFactory,playLogFactory,audioPlayer,xmlRpcDaemon) >
|
||||
<!ELEMENT scheduler (user,
|
||||
connectionManagerFactory,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
scheduleFactory,
|
||||
playLogFactory,
|
||||
audioPlayer,
|
||||
xmlRpcDaemon) >
|
||||
|
||||
<!ELEMENT connectionManagerFactory (simpleConnectionManager) >
|
||||
|
||||
|
@ -11,6 +17,22 @@
|
|||
<!ATTLIST simpleConnectionManager userName CDATA #REQUIRED >
|
||||
<!ATTLIST simpleConnectionManager password CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||
webAuthentication)>
|
||||
|
||||
<!ELEMENT testAuthentication (user) >
|
||||
|
||||
<!ELEMENT user EMPTY >
|
||||
<!ATTLIST user login CDATA #REQUIRED >
|
||||
<!ATTLIST user password CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT webAuthentication (location) >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT storageClientFactory (testStorage|webStorage) >
|
||||
|
||||
<!ELEMENT testStorage (playlist*, audioClip*) >
|
||||
|
@ -19,11 +41,6 @@
|
|||
<!ELEMENT webStorage (location) >
|
||||
<!ATTLIST webStorage tempFiles CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
@ -62,6 +79,8 @@
|
|||
|
||||
]>
|
||||
<scheduler>
|
||||
<user login="root" password="q" />
|
||||
|
||||
<connectionManagerFactory>
|
||||
<simpleConnectionManager dsn = "LiveSupport-test"
|
||||
userName = "test"
|
||||
|
@ -69,6 +88,13 @@
|
|||
/>
|
||||
</connectionManagerFactory>
|
||||
|
||||
<authenticationClientFactory>
|
||||
<webAuthentication>
|
||||
<location server="localhost" port="80"
|
||||
path="/livesupportStorageServer/xmlrpc/xrLocStor.php" />
|
||||
</webAuthentication>
|
||||
</authenticationClientFactory>
|
||||
|
||||
<storageClientFactory>
|
||||
<webStorage tempFiles="file:///tmp/webStorageClient" >
|
||||
<location server="localhost" port="80"
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE scheduler [
|
||||
|
||||
<!ELEMENT scheduler (connectionManagerFactory,storageClientFactory,
|
||||
scheduleFactory,playLogFactory,audioPlayer,xmlRpcDaemon) >
|
||||
<!ELEMENT scheduler (user,
|
||||
connectionManagerFactory,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
scheduleFactory,
|
||||
playLogFactory,
|
||||
audioPlayer,
|
||||
xmlRpcDaemon) >
|
||||
|
||||
<!ELEMENT connectionManagerFactory (simpleConnectionManager) >
|
||||
|
||||
|
@ -11,6 +17,22 @@
|
|||
<!ATTLIST simpleConnectionManager userName CDATA #REQUIRED >
|
||||
<!ATTLIST simpleConnectionManager password CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||
webAuthentication)>
|
||||
|
||||
<!ELEMENT testAuthentication (user) >
|
||||
|
||||
<!ELEMENT user EMPTY >
|
||||
<!ATTLIST user login CDATA #REQUIRED >
|
||||
<!ATTLIST user password CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT webAuthentication (location) >
|
||||
|
||||
<!ELEMENT location EMPTY >
|
||||
<!ATTLIST location server CDATA #REQUIRED >
|
||||
<!ATTLIST location port NMTOKEN #REQUIRED >
|
||||
<!ATTLIST location path CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT storageClientFactory (testStorage) >
|
||||
|
||||
<!ELEMENT testStorage (playlist*, audioClip*) >
|
||||
|
@ -54,6 +76,8 @@
|
|||
|
||||
]>
|
||||
<scheduler>
|
||||
<user login="root" password="q" />
|
||||
|
||||
<connectionManagerFactory>
|
||||
<simpleConnectionManager dsn = "LiveSupport-test"
|
||||
userName = "test"
|
||||
|
@ -61,6 +85,12 @@
|
|||
/>
|
||||
</connectionManagerFactory>
|
||||
|
||||
<authenticationClientFactory>
|
||||
<testAuthentication>
|
||||
<user login="root" password="q" />
|
||||
</testAuthentication>
|
||||
</authenticationClientFactory>
|
||||
|
||||
<storageClientFactory>
|
||||
<testStorage tempFiles="file:///tmp/tempPlaylist">
|
||||
<playlist id="0000000000000001" playlength="01:30:00.000">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "PlaylistEvent.h"
|
||||
|
||||
using namespace boost;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
@ -65,15 +66,19 @@ using namespace LiveSupport::Scheduler;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
PlaylistEvent :: PlaylistEvent(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw ()
|
||||
{
|
||||
this->sessionId = sessionId;
|
||||
this->audioPlayer = audioPlayer;
|
||||
this->storage = storage;
|
||||
this->scheduleEntry = scheduleEntry;
|
||||
this->sessionId.reset(new SessionId("dummy session ID"));
|
||||
|
||||
// this init time is a wild guess, say 5 seconds should be enough
|
||||
initTime.reset(new posix_time::time_duration(0, 0, 5, 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Core/ScheduleEntry.h"
|
||||
#include "LiveSupport/Storage/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
|
@ -69,7 +70,7 @@ using namespace LiveSupport::Storage;
|
|||
* A scheduled event for playing a playlist.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.6 $
|
||||
*/
|
||||
class PlaylistEvent : public virtual ScheduledEventInterface
|
||||
{
|
||||
|
@ -109,13 +110,15 @@ class PlaylistEvent : public virtual ScheduledEventInterface
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param sessionId the session id used to access the storage.
|
||||
* @param audioPlayer the audio player to play the playlist with.
|
||||
* @param storage the storage containing the playlist to play,
|
||||
* and all the related audio clips.
|
||||
* @param scheduleEntry the schedule entry this event is
|
||||
* playing.
|
||||
*/
|
||||
PlaylistEvent(Ptr<AudioPlayerInterface>::Ref audioPlayer,
|
||||
PlaylistEvent(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleEntry>::Ref scheduleEntry)
|
||||
throw ();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainer.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -63,11 +63,13 @@ using namespace LiveSupport::Scheduler;
|
|||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
PlaylistEventContainer :: PlaylistEventContainer(
|
||||
Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleInterface>::Ref schedule,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer)
|
||||
throw ()
|
||||
{
|
||||
this->sessionId = sessionId;
|
||||
this->storage = storage;
|
||||
this->schedule = schedule;
|
||||
this->audioPlayer = audioPlayer;
|
||||
|
@ -84,7 +86,7 @@ PlaylistEventContainer :: getNextEvent(Ptr<ptime>::Ref when) throw ()
|
|||
Ptr<PlaylistEvent>::Ref event;
|
||||
|
||||
if (entry.get()) {
|
||||
event.reset(new PlaylistEvent(audioPlayer, storage, entry));
|
||||
event.reset(new PlaylistEvent(sessionId, audioPlayer, storage, entry));
|
||||
}
|
||||
|
||||
return event;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainer.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Storage/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/EventScheduler/EventContainerInterface.h"
|
||||
|
@ -70,12 +71,18 @@ using namespace LiveSupport::Storage;
|
|||
/**
|
||||
* An event container holding the scheduled playlists.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class PlaylistEventContainer : public virtual EventContainerInterface
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The session id, passed on to PlaylistEvents, to access
|
||||
* resources from the storage.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* The storage containing the playlists to play.
|
||||
*/
|
||||
|
@ -96,12 +103,15 @@ class PlaylistEventContainer : public virtual EventContainerInterface
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param sessionId the session id that will be accepted by
|
||||
* calls to storage
|
||||
* @param storage the storage containing the playlist and related
|
||||
* audio clips
|
||||
* @param schedule the schedule to get the events from.
|
||||
* @param audioPlayer the audio player to play the playlists with.
|
||||
*/
|
||||
PlaylistEventContainer(Ptr<StorageClientInterface>::Ref storage,
|
||||
PlaylistEventContainer(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<StorageClientInterface>::Ref storage,
|
||||
Ptr<ScheduleInterface>::Ref schedule,
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer)
|
||||
throw ();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -198,7 +198,10 @@ PlaylistEventContainerTest :: simpleTest(void)
|
|||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<PlaylistEventContainer>::Ref container;
|
||||
container.reset(new PlaylistEventContainer(storage, schedule, audioPlayer));
|
||||
container.reset(new PlaylistEventContainer(sessionId,
|
||||
storage,
|
||||
schedule,
|
||||
audioPlayer));
|
||||
|
||||
// see that there are no events scheduled
|
||||
Ptr<ScheduledEventInterface>::Ref scheduledEvent;
|
||||
|
@ -215,7 +218,10 @@ PlaylistEventContainerTest :: scheduleTest(void)
|
|||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<PlaylistEventContainer>::Ref container;
|
||||
container.reset(new PlaylistEventContainer(storage, schedule, audioPlayer));
|
||||
container.reset(new PlaylistEventContainer(sessionId,
|
||||
storage,
|
||||
schedule,
|
||||
audioPlayer));
|
||||
|
||||
// schedule playlist 1 at 10 seconds from now
|
||||
Ptr<UniqueId>::Ref playlistId(new UniqueId(1));
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -43,6 +43,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
|
||||
|
@ -53,6 +54,7 @@
|
|||
using namespace boost::posix_time;
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
@ -69,6 +71,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistEventTest);
|
|||
*/
|
||||
static const std::string audioPlayerConfigFileName = "etc/audioPlayer.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the authentication client factory.
|
||||
*/
|
||||
static const std::string authenticationClientConfigFileName =
|
||||
"etc/authenticationClient.xml";
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the storage client
|
||||
*/
|
||||
|
@ -104,6 +112,14 @@ PlaylistEventTest :: setUp(void) throw ()
|
|||
|
||||
storage = scf->getStorageClient();
|
||||
|
||||
// get an authentication client
|
||||
Ptr<AuthenticationClientFactory>::Ref acf;
|
||||
acf = AuthenticationClientFactory::getInstance();
|
||||
parser.reset(new xmlpp::DomParser(authenticationClientConfigFileName,
|
||||
true));
|
||||
acf->configure(*(parser->get_document()->get_root_node()));
|
||||
authentication = acf->getAuthenticationClient();
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
|
@ -115,6 +131,10 @@ PlaylistEventTest :: setUp(void) throw ()
|
|||
audioPlayer->initialize();
|
||||
|
||||
duration.reset(new time_duration(seconds(30)));
|
||||
|
||||
if (!(sessionId = authentication->login("root", "q"))) {
|
||||
CPPUNIT_FAIL("could not log in to authentication server");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,6 +149,10 @@ PlaylistEventTest :: tearDown(void) throw ()
|
|||
duration.reset();
|
||||
storage.reset();
|
||||
audioPlayer.reset();
|
||||
|
||||
authentication->logout(sessionId);
|
||||
sessionId.reset();
|
||||
authentication.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,7 +174,8 @@ PlaylistEventTest :: createTestEvent(void) throw ()
|
|||
startTime,
|
||||
endTime));
|
||||
|
||||
Ptr<PlaylistEvent>::Ref playlistEvent(new PlaylistEvent(audioPlayer,
|
||||
Ptr<PlaylistEvent>::Ref playlistEvent(new PlaylistEvent(sessionId,
|
||||
audioPlayer,
|
||||
storage,
|
||||
scheduleEntry));
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
|
||||
|
@ -53,6 +54,7 @@ using namespace boost::posix_time;
|
|||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
@ -66,8 +68,8 @@ using namespace LiveSupport::PlaylistExecutor;
|
|||
/**
|
||||
* Unit test for the PlaylistEvent class
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
* @see PlaylistEvent
|
||||
*/
|
||||
class PlaylistEventTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -94,6 +96,16 @@ class PlaylistEventTest : public CPPUNIT_NS::TestFixture
|
|||
*/
|
||||
Ptr<time_duration>::Ref duration;
|
||||
|
||||
/**
|
||||
* An authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Create a playlist event for testing purposes.
|
||||
*/
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.14 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.15 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -54,6 +54,7 @@
|
|||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include "LiveSupport/Db/ConnectionManagerFactory.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
#include "ScheduleFactory.h"
|
||||
|
@ -89,6 +90,20 @@ static const std::string confElement = "scheduler";
|
|||
*/
|
||||
static const std::string xmlRpcDaemonConfElement = "xmlRpcDaemon";
|
||||
|
||||
/**
|
||||
* The name of the config child element for the login and password
|
||||
*/
|
||||
static const std::string userConfigElementName = "user";
|
||||
|
||||
/**
|
||||
* The name of the config element attribute for the login
|
||||
*/
|
||||
static const std::string userLoginAttrName = "login";
|
||||
|
||||
/**
|
||||
* The name of the config element attribute for the password
|
||||
*/
|
||||
static const std::string userPasswordAttrName = "password";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -154,7 +169,27 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
xmlpp::Node::NodeList nodes;
|
||||
xmlpp::Node::NodeList nodes;
|
||||
const xmlpp::Element * elem;
|
||||
const xmlpp::Attribute * attribute;
|
||||
|
||||
// read in the user data
|
||||
std::string login;
|
||||
std::string password;
|
||||
|
||||
nodes = element.get_children(userConfigElementName);
|
||||
if (nodes.size() < 1) {
|
||||
throw std::invalid_argument("no user element");
|
||||
}
|
||||
elem = dynamic_cast<const xmlpp::Element*> (*nodes.begin());
|
||||
if (!(attribute = elem->get_attribute(userLoginAttrName))) {
|
||||
throw std::invalid_argument("missing login attribute");
|
||||
}
|
||||
login = attribute->get_value();
|
||||
if (!(attribute = elem->get_attribute(userPasswordAttrName))) {
|
||||
throw std::invalid_argument("missing password attribute");
|
||||
}
|
||||
password = attribute->get_value();
|
||||
|
||||
// configure the ConnectionManagerFactory
|
||||
nodes =
|
||||
|
@ -166,6 +201,16 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
= ConnectionManagerFactory::getInstance();
|
||||
cmf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
// configure the AuthenticationClientFactory
|
||||
nodes =
|
||||
element.get_children(AuthenticationClientFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
throw std::invalid_argument("no authenticationClientFactory element");
|
||||
}
|
||||
Ptr<AuthenticationClientFactory>::Ref acf
|
||||
= AuthenticationClientFactory::getInstance();
|
||||
acf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
// configure the StorageClientFactory
|
||||
nodes = element.get_children(StorageClientFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
|
@ -207,11 +252,20 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
|
||||
|
||||
// do some initialization, using the configured objects
|
||||
authentication = acf->getAuthenticationClient();
|
||||
try {
|
||||
sessionId = authentication->login(login, password);
|
||||
} catch (AuthenticationException &e) {
|
||||
// TODO: mark error
|
||||
std::cerr << "authentication problem: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
audioPlayer = apf->getAudioPlayer();
|
||||
|
||||
Ptr<PlaylistEventContainer>::Ref eventContainer;
|
||||
Ptr<time_duration>::Ref granularity;
|
||||
eventContainer.reset(new PlaylistEventContainer(scf->getStorageClient(),
|
||||
eventContainer.reset(new PlaylistEventContainer(sessionId,
|
||||
scf->getStorageClient(),
|
||||
sf->getSchedule(),
|
||||
audioPlayer));
|
||||
// TODO: read granularity from config file
|
||||
|
@ -223,6 +277,17 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
SchedulerDaemon :: ~SchedulerDaemon(void) throw ()
|
||||
{
|
||||
if (authentication.get() && sessionId.get()) {
|
||||
authentication->logout(sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Register our XML-RPC methods
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.12 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.13 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -60,6 +60,8 @@
|
|||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/Installable.h"
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/Core/SessionId.h"
|
||||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
#include "LiveSupport/EventScheduler/EventScheduler.h"
|
||||
#include "AddAudioClipToPlaylistMethod.h"
|
||||
|
@ -90,6 +92,7 @@ namespace Scheduler {
|
|||
|
||||
using namespace LiveSupport;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Authentication;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
@ -112,9 +115,13 @@ using namespace LiveSupport::PlaylistExecutor;
|
|||
*
|
||||
* <pre><code>
|
||||
* <scheduler>
|
||||
* <user login="userid" password="pwd" />
|
||||
* <connectionManagerFactory>
|
||||
* ...
|
||||
* </connectionManagerFactory>
|
||||
* <authenticationClientFactory>
|
||||
* ...
|
||||
* </authenticationClientFactory>
|
||||
* <storageClientFactory>
|
||||
* ...
|
||||
* </storageClientFactory>
|
||||
|
@ -130,20 +137,30 @@ using namespace LiveSupport::PlaylistExecutor;
|
|||
* </scheduler>
|
||||
* </code></pre>
|
||||
*
|
||||
* The user element holds creditentials for accessing the storage,
|
||||
* configured below.
|
||||
*
|
||||
* For details on the included elements, see the corresponding documentation
|
||||
* for XmlRpcDaemon, StorageClientFactory, ConnectionManagerFactory
|
||||
* and ScheduleFactory.
|
||||
* ScheduleFactory and AuthenticationClientFactory.
|
||||
*
|
||||
* The DTD for the above element is the following:
|
||||
*
|
||||
* <pre><code>
|
||||
* <!ELEMENT scheduler (connectionManagerFactory,storageClientFactory,
|
||||
* scheduleFactory,playLogFactory,xmlRpcDaemon) >
|
||||
* <!ELEMENT scheduler (user,
|
||||
* connectionManagerFactory,
|
||||
* authenticationClientFactory,
|
||||
* storageClientFactory,
|
||||
* scheduleFactory,
|
||||
* playLogFactory,
|
||||
* audioPlayer,
|
||||
* xmlRpcDaemon) >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.12 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.13 $
|
||||
* @see ConnectionManagerFactory
|
||||
* @see AuthenticationClientFactory
|
||||
* @see StorageClientFactory
|
||||
* @see ScheduleFactory
|
||||
* @see XmlRpcDaemon
|
||||
|
@ -159,6 +176,16 @@ class SchedulerDaemon : public Installable,
|
|||
*/
|
||||
static Ptr<SchedulerDaemon>::Ref schedulerDaemon;
|
||||
|
||||
/**
|
||||
* The authentication client.
|
||||
*/
|
||||
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* The session id for the scheduler user.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* The event scheduler.
|
||||
*/
|
||||
|
@ -301,9 +328,7 @@ class SchedulerDaemon : public Installable,
|
|||
* Virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~SchedulerDaemon(void) throw ()
|
||||
{
|
||||
}
|
||||
~SchedulerDaemon(void) throw ();
|
||||
|
||||
/**
|
||||
* Return a pointer to the singleton instance of SchedulerDaemon.
|
||||
|
|
Loading…
Reference in New Issue