diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx index 31ae59611..88382aa35 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -85,8 +85,15 @@ using namespace LiveSupport::GLiveSupport; /*------------------------------------------------------------------------------ * The name of the config element for this class *----------------------------------------------------------------------------*/ -const std::string LiveSupport :: GLiveSupport :: - GLiveSupport :: configElementNameStr = "gLiveSupport"; +const std::string + LiveSupport :: GLiveSupport :: GLiveSupport :: configElementNameStr + = "gLiveSupport"; + +/*------------------------------------------------------------------------------ + * The singleton instance of GLiveSupport + *----------------------------------------------------------------------------*/ +Ptr::Ref + LiveSupport :: GLiveSupport :: GLiveSupport :: singleton; namespace { @@ -209,6 +216,21 @@ const std::string serialPortDefaultDevice = "/dev/ttyS0"; /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Return the singleton instance to WidgetFactory + *----------------------------------------------------------------------------*/ +Ptr::Ref +LiveSupport :: GLiveSupport :: +GLiveSupport :: getInstance(void) throw () +{ + if (!singleton.get()) { + singleton.reset(new LiveSupport::GLiveSupport::GLiveSupport()); + } + + return singleton; +} + + /*------------------------------------------------------------------------------ * Configure the gLiveSupport object *----------------------------------------------------------------------------*/ @@ -478,7 +500,7 @@ GLiveSupport :: configSupportedLanguages(const xmlpp::Element & element) *----------------------------------------------------------------------------*/ bool LiveSupport :: GLiveSupport :: -GLiveSupport :: checkConfiguration(void) throw () +GLiveSupport :: checkConfiguration(void) throw () { // === FATAL ERRORS === @@ -602,7 +624,7 @@ GLiveSupport :: runDialog(const Glib::ustring & dialogName, *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: show(void) throw () +GLiveSupport :: show(void) throw () { masterPanel.reset(new MasterPanelWindow(shared_from_this(), getBundle(), @@ -699,7 +721,7 @@ GLiveSupport :: login(const std::string & login, *----------------------------------------------------------------------------*/ bool LiveSupport :: GLiveSupport :: -GLiveSupport :: logout(void) throw () +GLiveSupport :: logout(void) throw () { if (!sessionId) { return false; @@ -733,7 +755,7 @@ GLiveSupport :: logout(void) throw () void LiveSupport :: GLiveSupport :: GLiveSupport :: storeWindowContents(ContentsStorable * window) - throw () + throw () { Ptr::Ref userPreferencesKey = window->getUserPreferencesKey(); @@ -759,7 +781,7 @@ GLiveSupport :: storeWindowContents(ContentsStorable * window) void LiveSupport :: GLiveSupport :: GLiveSupport :: loadWindowContents(ContentsStorable * window) - throw () + throw () { Ptr::Ref userPreferencesKey = window->getUserPreferencesKey(); @@ -1058,7 +1080,7 @@ GLiveSupport :: addToScratchpad(Ptr::Ref playable) void LiveSupport :: GLiveSupport :: GLiveSupport :: addToLiveMode(Ptr::Ref playable) - throw () + throw () { masterPanel->updateLiveModeWindow(playable); } @@ -1070,7 +1092,7 @@ GLiveSupport :: addToLiveMode(Ptr::Ref playable) void LiveSupport :: GLiveSupport :: GLiveSupport :: setNowPlaying(Ptr::Ref playable) - throw () + throw () { // test needed: this gets called indirectly from ~MasterPanelWindow if (masterPanel) { @@ -1242,7 +1264,7 @@ GLiveSupport :: removeFromSchedule(Ptr::Ref scheduleEntryId) void LiveSupport :: GLiveSupport :: GLiveSupport :: preload(Ptr::Ref playable) - throw () + throw () { Ptr::Ref uri = playable->getUri(); if (uri) { @@ -1366,7 +1388,7 @@ GLiveSupport :: stopOutputAudio(void) void LiveSupport :: GLiveSupport :: GLiveSupport :: onStop(Ptr::Ref errorMessage) - throw () + throw () { outputItemPlayingNow.reset(); try { @@ -1497,7 +1519,7 @@ GLiveSupport :: stopCueAudio(void) void LiveSupport :: GLiveSupport :: GLiveSupport :: attachCueAudioListener(AudioPlayerEventListener * listener) - throw () + throw () { cuePlayer->attachListener(listener); } @@ -1520,7 +1542,7 @@ GLiveSupport :: detachCueAudioListener(AudioPlayerEventListener * listener) *----------------------------------------------------------------------------*/ Glib::RefPtr LiveSupport :: GLiveSupport :: -GLiveSupport :: getStationLogoPixbuf(void) throw() +GLiveSupport :: getStationLogoPixbuf(void) throw() { return stationLogoPixbuf; } diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupport.h b/campcaster/src/products/gLiveSupport/src/GLiveSupport.h index 8fe448296..c745a0da7 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupport.h +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupport.h @@ -155,6 +155,11 @@ class GLiveSupport : public LocalizedConfigurable, */ static const std::string configElementNameStr; + /** + * The singleton instance of this object. + */ + static Ptr::Ref singleton; + /** * The authentication client used by the application. */ @@ -301,7 +306,7 @@ class GLiveSupport : public LocalizedConfigurable, * Emit the "edited playlist has been modified" signal. */ void - emitSignalEditedPlaylistModified(void) throw () + emitSignalEditedPlaylistModified(void) throw () { signalEditedPlaylistModified().emit(); } @@ -357,12 +362,24 @@ class GLiveSupport : public LocalizedConfigurable, */ bool schedulerAvailable; + /** + * Private constructor. + */ + GLiveSupport(void) throw () + : outputPlayerIsPaused(false), + cuePlayerIsPaused(false) + { + openedAudioClips.reset(new AudioClipMap()); + openedPlaylists.reset(new PlaylistMap()); + serialStream.reset(new LibSerial::SerialStream()); + } + /** * Display a message that the authentication server is not available. * And offer a chance to edit the options to fix it. */ void - displayAuthenticationServerMissingMessage(void) throw (); + displayAuthenticationServerMissingMessage(void) throw (); /** * Refresh the playlist in the Live Mode window. @@ -375,7 +392,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void refreshPlaylistInLiveMode(Ptr::Ref playlist) - throw (); + throw (); /** * Replace the placeholders in the RDS settings with the @@ -386,7 +403,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void substituteRdsData(Ptr::Ref rdsString) - throw (); + throw (); /** * Replace a single placeholders in the RDS settings. @@ -444,23 +461,11 @@ class GLiveSupport : public LocalizedConfigurable, public: - /** - * Constructor. - */ - GLiveSupport(void) throw () - : outputPlayerIsPaused(false), - cuePlayerIsPaused(false) - { - openedAudioClips.reset(new AudioClipMap()); - openedPlaylists.reset(new PlaylistMap()); - serialStream.reset(new LibSerial::SerialStream()); - } - /** * Virtual destructor. */ virtual - ~GLiveSupport(void) throw () + ~GLiveSupport(void) throw () { if (outputPlayer.get()) { outputPlayer->deInitialize(); @@ -485,11 +490,19 @@ class GLiveSupport : public LocalizedConfigurable, * @return the name of the expected XML configuration element. */ static const std::string - getConfigElementName(void) throw () + getConfigElementName(void) throw () { return configElementNameStr; } + /** + * Returns the singleton instance of this object. + * + * @return the singleton instance of this object. + */ + static Ptr::Ref + getInstance() throw (); + /** * Configure the scheduler daemon based on the XML element * supplied. @@ -514,7 +527,7 @@ class GLiveSupport : public LocalizedConfigurable, * false otherwise */ bool - checkConfiguration(void) throw (); + checkConfiguration(void) throw (); /** * Display a message window. @@ -524,7 +537,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void displayMessageWindow(const Glib::ustring & message) - throw (); + throw (); /** * Run a dialog window with No and Yes buttons. @@ -549,7 +562,7 @@ class GLiveSupport : public LocalizedConfigurable, * This call will only return after the main window has been closed. */ void - show(void) throw (); + show(void) throw (); /** * Change the language of the application. @@ -576,7 +589,7 @@ class GLiveSupport : public LocalizedConfigurable, */ bool login(const std::string & login, - const std::string & password) throw (); + const std::string & password) throw (); /** * Return the session id for the user. @@ -588,7 +601,7 @@ class GLiveSupport : public LocalizedConfigurable, * @see #login */ Ptr::Ref - getSessionId(void) const throw () + getSessionId(void) const throw () { return sessionId; } @@ -603,7 +616,7 @@ class GLiveSupport : public LocalizedConfigurable, * @see #logout */ bool - logout(void) throw (); + logout(void) throw (); /** * Accessor function to the scheduler client held by this object. @@ -611,7 +624,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return the scheduler client held by this object. */ Ptr::Ref - getScheduler(void) throw () + getScheduler(void) throw () { return scheduler; } @@ -622,7 +635,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return the map of supported languages. */ Ptr::Ref - getSupportedLanguages(void) const throw () + getSupportedLanguages(void) const throw () { return supportedLanguages; } @@ -633,7 +646,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return the metadata type container */ Ptr::Ref - getMetadataTypeContainer(void) const throw () + getMetadataTypeContainer(void) const throw () { return metadataTypeContainer; } @@ -675,7 +688,7 @@ class GLiveSupport : public LocalizedConfigurable, * @exception XmlRpcException on communication problems. */ void - resetStorage(void) throw (XmlRpcException) + resetStorage(void) throw (XmlRpcException) { storage->reset(); } @@ -833,7 +846,7 @@ class GLiveSupport : public LocalizedConfigurable, * @param playable the audio clip or playlist to be added */ void - addToLiveMode(Ptr::Ref playable) throw (); + addToLiveMode(Ptr::Ref playable) throw (); /** * Return the currently edited playlist. @@ -842,7 +855,7 @@ class GLiveSupport : public LocalizedConfigurable, * if no playlist is edited */ Ptr::Ref - getEditedPlaylist(void) throw () + getEditedPlaylist(void) throw () { return editedPlaylist; } @@ -963,7 +976,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void preload(Ptr::Ref playable) - throw (); + throw (); /** * Play a Playable object using the output audio player. @@ -1080,7 +1093,7 @@ class GLiveSupport : public LocalizedConfigurable, void playTestSoundOnCue(Ptr::Ref oldDevice, Ptr::Ref newDevice) - throw (); + throw (); /** * Search in the local storage. @@ -1105,14 +1118,14 @@ class GLiveSupport : public LocalizedConfigurable, virtual void onStop(Ptr::Ref errorMessage = Ptr::Ref()) - throw (); + throw (); /** * Display the playable item on the master panel as "now playing". */ void setNowPlaying(Ptr::Ref playable) - throw (); + throw (); /** * Return a pixbuf containing the radio station logo. @@ -1120,7 +1133,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return a pixbuf containing the station logo image. */ Glib::RefPtr - getStationLogoPixbuf() throw (); + getStationLogoPixbuf() throw (); /** * The signal raised when the edited playlist is modified. @@ -1128,7 +1141,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return the signal object (a protected member of this class) */ sigc::signal - signalEditedPlaylistModified(void) throw () + signalEditedPlaylistModified(void) throw () { return signalEditedPlaylistModifiedObject; } @@ -1285,7 +1298,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void storeWindowContents(Ptr::Ref window) - throw () + throw () { storeWindowContents(window.get()); } @@ -1297,7 +1310,7 @@ class GLiveSupport : public LocalizedConfigurable, */ void loadWindowContents(Ptr::Ref window) - throw () + throw () { loadWindowContents(window.get()); } @@ -1308,7 +1321,7 @@ class GLiveSupport : public LocalizedConfigurable, * @param window the window to get the contents of. */ void - storeWindowContents(ContentsStorable * window) throw (); + storeWindowContents(ContentsStorable * window) throw (); /** * Load the contents of a window as a user preference. @@ -1316,13 +1329,13 @@ class GLiveSupport : public LocalizedConfigurable, * @param window the window to restore the contents of. */ void - loadWindowContents(ContentsStorable * window) throw (); + loadWindowContents(ContentsStorable * window) throw (); /** * Return whether the storage component is available. */ bool - isStorageAvailable(void) throw() + isStorageAvailable(void) throw() { return storageAvailable; } @@ -1331,7 +1344,7 @@ class GLiveSupport : public LocalizedConfigurable, * Return whether the scheduler component is available. */ bool - isSchedulerAvailable(void) throw() + isSchedulerAvailable(void) throw() { return schedulerAvailable; } @@ -1340,7 +1353,7 @@ class GLiveSupport : public LocalizedConfigurable, * Access the StorageClientInterface object. */ Ptr::Ref - getStorageClient(void) throw() + getStorageClient(void) throw() { return storage; } @@ -1350,19 +1363,19 @@ class GLiveSupport : public LocalizedConfigurable, * This updates the schedulerAvailable variable accordingly. */ void - checkSchedulerClient(void) throw(); + checkSchedulerClient(void) throw(); /** * Start the scheduler client. */ void - startSchedulerClient(void) throw(); + startSchedulerClient(void) throw(); /** * Stop the scheduler client. */ void - stopSchedulerClient(void) throw(); + stopSchedulerClient(void) throw(); /** * Upload a Playable object to the network hub. @@ -1373,7 +1386,7 @@ class GLiveSupport : public LocalizedConfigurable, * @param playable the audio clip or playlist to be uploaded. */ void - uploadToHub(Ptr::Ref playable) throw (); + uploadToHub(Ptr::Ref playable) throw (); /** * Take a break. @@ -1383,7 +1396,7 @@ class GLiveSupport : public LocalizedConfigurable, * make sure your window gets redrawn. */ void - runMainLoop(void) throw () + runMainLoop(void) throw () { while (Gtk::Main::events_pending()) { Gtk::Main::iteration(); @@ -1394,7 +1407,7 @@ class GLiveSupport : public LocalizedConfigurable, * Preload the Scratchpad window during login. */ void - createScratchpadWindow(void) throw (); + createScratchpadWindow(void) throw (); /** * Read the RDS settings, and send them to the serial port. @@ -1412,7 +1425,7 @@ class GLiveSupport : public LocalizedConfigurable, * @see substituteRdsData() */ void - updateRds(void) throw (); + updateRds(void) throw (); /** * Return the directory where the Glade files are. @@ -1420,7 +1433,7 @@ class GLiveSupport : public LocalizedConfigurable, * @return the directory where the Glade files are. */ Glib::ustring - getGladeDir(void) throw () + getGladeDir(void) throw () { return gladeDir; } diff --git a/campcaster/src/products/gLiveSupport/src/GLiveSupportTest.cxx b/campcaster/src/products/gLiveSupport/src/GLiveSupportTest.cxx index 097f51a8c..2c3715dfb 100644 --- a/campcaster/src/products/gLiveSupport/src/GLiveSupportTest.cxx +++ b/campcaster/src/products/gLiveSupport/src/GLiveSupportTest.cxx @@ -113,7 +113,7 @@ GLiveSupportTest :: setUp(void) throw (CPPUNIT_NS::Exception) { Gtk::Main kit(0, 0); - gLiveSupport.reset(new GLiveSupport()); + gLiveSupport = GLiveSupport::getInstance(); uid_t uid = getuid(); struct passwd * pwd = getpwuid(uid); diff --git a/campcaster/src/products/gLiveSupport/src/main.cxx b/campcaster/src/products/gLiveSupport/src/main.cxx index a7688d506..a3afb2cb0 100644 --- a/campcaster/src/products/gLiveSupport/src/main.cxx +++ b/campcaster/src/products/gLiveSupport/src/main.cxx @@ -28,7 +28,7 @@ ------------------------------------------------------------------------------*/ /** @file - * This file contains the main entry point to the Scheduler daemon. + * This file contains the main entry point to the Studio client. */ /* ============================================================ include files */ @@ -155,7 +155,7 @@ int main ( int argc, } Ptr::Ref - gLiveSupport(new LiveSupport::GLiveSupport::GLiveSupport()); + gLiveSupport = LiveSupport::GLiveSupport::GLiveSupport::getInstance(); try { std::auto_ptr