From 31b06e291119710acaf40e09003fee606b8b4513 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 2 Jun 2006 16:46:08 +0000 Subject: [PATCH] Reorganized the stuff which allows editing the config file when the authentication server is not found. closes #1658; related to #1627 --- .../LiveSupport/Core/OptionsContainer.h | 5 +- .../src/modules/core/src/OptionsContainer.cxx | 18 ++++++ .../gLiveSupport/src/GLiveSupport.cxx | 60 +++++++++++++++--- .../products/gLiveSupport/src/GLiveSupport.h | 21 +++---- .../gLiveSupport/src/MasterPanelWindow.cxx | 42 ++++++++----- .../gLiveSupport/src/OptionsWindow.cxx | 62 ++++++++++++++++++- .../products/gLiveSupport/src/OptionsWindow.h | 8 +++ .../src/products/gLiveSupport/var/root.txt | 12 ++-- 8 files changed, 183 insertions(+), 45 deletions(-) diff --git a/livesupport/src/modules/core/include/LiveSupport/Core/OptionsContainer.h b/livesupport/src/modules/core/include/LiveSupport/Core/OptionsContainer.h index bfd3268e6..1f2cd35ae 100644 --- a/livesupport/src/modules/core/include/LiveSupport/Core/OptionsContainer.h +++ b/livesupport/src/modules/core/include/LiveSupport/Core/OptionsContainer.h @@ -82,7 +82,10 @@ class OptionsContainer authenticationPath, storageServer, storagePort, - storagePath } OptionItemString; + storagePath, + schedulerServer, + schedulerPort, + schedulerPath } OptionItemString; private: diff --git a/livesupport/src/modules/core/src/OptionsContainer.cxx b/livesupport/src/modules/core/src/OptionsContainer.cxx index 470082b82..3d44e11f9 100644 --- a/livesupport/src/modules/core/src/OptionsContainer.cxx +++ b/livesupport/src/modules/core/src/OptionsContainer.cxx @@ -214,6 +214,24 @@ OptionsContainer :: selectNode(OptionItemString optionItem, "webStorage/location/@path"); isAttribute = true; break; + + case schedulerServer : + targetNode = getNode("schedulerClientFactory/" + "schedulerDaemonXmlRpcClient/@xmlRpcHost"); + isAttribute = true; + break; + + case schedulerPort : + targetNode = getNode("schedulerClientFactory/" + "schedulerDaemonXmlRpcClient/@xmlRpcPort"); + isAttribute = true; + break; + + case schedulerPath : + targetNode = getNode("schedulerClientFactory/" + "schedulerDaemonXmlRpcClient/@xmlRpcUri"); + isAttribute = true; + break; } return targetNode; diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx index defc46008..3e0b31f7e 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -445,17 +445,15 @@ GLiveSupport :: checkConfiguration(void) throw () return false; } - // === NON-FATAL ERRORS === - // check if the authentication server is available try { authentication->getVersion(); - authenticationAvailable = true; } catch (XmlRpcException &e) { - authenticationAvailable = false; - displayMessageWindow(getResourceUstring(authenticationNotReachableKey)); + displayAuthenticationServerMissingMessage(); + return false; } + // === NON-FATAL ERRORS === // check if the storage server is available try { @@ -488,10 +486,10 @@ LiveSupport :: GLiveSupport :: GLiveSupport :: displayMessageWindow(Ptr::Ref message) throw () { - DialogWindow * window = widgetFactory->createDialogWindow(message, - getBundle()); + Ptr::Ref window(widgetFactory->createDialogWindow( + message, + getBundle())); window->run(); - delete window; } @@ -1629,9 +1627,53 @@ GLiveSupport :: stopSchedulerClient(void) throw () void LiveSupport :: GLiveSupport :: GLiveSupport :: uploadToHub(Ptr::Ref playable) - throw () + throw () { masterPanel->uploadToHub(playable); } +/*------------------------------------------------------------------------------ + * Display a message that the authentication server is not available. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: displayAuthenticationServerMissingMessage(void) throw () +{ + Ptr::Ref message; + try { + message = getResourceUstring("authenticationNotReachableMsg"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + // "authentication not available -- would you like to edit the options?" + Ptr::Ref question(widgetFactory->createDialogWindow( + message, + getBundle(), + DialogWindow::noButton + | DialogWindow::yesButton )); + DialogWindow::ButtonType answer = question->run(); + + if (answer == DialogWindow::yesButton) { + Ptr::Ref bundle; + try { + bundle = getBundle("optionsWindow"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + return; + } + + Ptr::Ref optionsWindow(new OptionsWindow( + shared_from_this(), + bundle, + 0)); + optionsWindow->run(); + + if (optionsContainer->isTouched()) { + optionsContainer->writeToFile(); + } + } +} + diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h index efab910be..27722b9dd 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h @@ -327,11 +327,6 @@ class GLiveSupport : public LocalizedConfigurable, */ Ptr::Ref optionsContainer; - /** - * Whether the authentication component is available. - */ - bool authenticationAvailable; - /** * Whether the storage component is available. */ @@ -342,6 +337,13 @@ class GLiveSupport : public LocalizedConfigurable, */ bool schedulerAvailable; + /** + * 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 (); + protected: /** @@ -1174,15 +1176,6 @@ class GLiveSupport : public LocalizedConfigurable, void loadWindowContents(ContentsStorable * window) throw (); - /** - * Return whether the authentication component is available. - */ - bool - isAuthenticationAvailable(void) throw() - { - return authenticationAvailable; - } - /** * Return whether the storage component is available. */ diff --git a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx index 792e7a5d3..458c7beda 100644 --- a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -311,22 +311,33 @@ MasterPanelWindow :: changeLanguage(Ptr::Ref bundle) Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 5, 0); - // re-bind events to the buttons - liveModeButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onLiveModeButtonClicked)); - uploadFileButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onUploadFileButtonClicked)); - scratchpadButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onScratchpadButtonClicked)); - simplePlaylistMgmtButton->signal_clicked().connect( - sigc::mem_fun(*this, - &MasterPanelWindow::onSimplePlaylistMgmtButtonClicked)); - schedulerButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onSchedulerButtonClicked)); - searchButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onSearchButtonClicked)); + if (gLiveSupport->isStorageAvailable()) { + // re-bind events to the buttons + liveModeButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onLiveModeButtonClicked)); + uploadFileButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onUploadFileButtonClicked)); + scratchpadButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onScratchpadButtonClicked)); + simplePlaylistMgmtButton->signal_clicked().connect( + sigc::mem_fun(*this, + &MasterPanelWindow::onSimplePlaylistMgmtButtonClicked)); + schedulerButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onSchedulerButtonClicked)); + searchButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onSearchButtonClicked)); + } else { + // gray out all the buttons except Options + liveModeButton->set_sensitive(false); + uploadFileButton->set_sensitive(false); + scratchpadButton->set_sensitive(false); + simplePlaylistMgmtButton->set_sensitive(false); + schedulerButton->set_sensitive(false); + searchButton->set_sensitive(false); + } + optionsButton->signal_clicked().connect(sigc::mem_fun(*this, - &MasterPanelWindow::onOptionsButtonClicked)); + &MasterPanelWindow::onOptionsButtonClicked)); } @@ -645,6 +656,7 @@ MasterPanelWindow :: showAnonymousUI(void) throw () simplePlaylistMgmtButton->hide(); schedulerButton->hide(); searchButton->hide(); + optionsButton->hide(); if (liveModeWindow.get()) { if (liveModeWindow->is_visible()) { diff --git a/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx b/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx index af5ca4ae3..7d5450299 100644 --- a/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -163,9 +163,8 @@ OptionsWindow :: OptionsWindow (Ptr::Ref gLiveSupport, // show everything set_name(windowName); - set_default_size(700, 450); + set_default_size(700, 500); set_modal(false); - property_window_position().set_value(Gtk::WIN_POS_NONE); show_all_children(); } @@ -677,10 +676,56 @@ OptionsWindow :: constructServersSection(void) throw () storageTable->attach(*storagePortEntry, 2, 3, 1, 2); storageTable->attach(*storagePathEntry, 2, 3, 2, 3); + // the settings for the scheduler + Gtk::Table * schedulerTable = Gtk::manage(new Gtk::Table); + schedulerTable->set_row_spacings(5); + schedulerTable->set_col_spacings(5); + + Gtk::Label * schedulerLabel; + Gtk::Label * schedulerServerLabel; + Gtk::Label * schedulerPortLabel; + Gtk::Label * schedulerPathLabel; + try { + schedulerLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("schedulerLabel") )); + schedulerServerLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("serverLabel") )); + schedulerPortLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("portLabel") )); + schedulerPathLabel = Gtk::manage(new Gtk::Label( + *getResourceUstring("pathLabel") )); + + } catch (std::invalid_argument &e) { + // TODO: signal error + std::cerr << e.what() << std::endl; + std::exit(1); + } + + schedulerTable->attach(*schedulerLabel, + 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 5, 0); + schedulerTable->attach(*schedulerServerLabel, + 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); + schedulerTable->attach(*schedulerPortLabel, + 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK); + schedulerTable->attach(*schedulerPathLabel, + 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK); + + EntryBin * schedulerServerEntry = createEntry( + OptionsContainer::schedulerServer); + EntryBin * schedulerPortEntry = createEntry( + OptionsContainer::schedulerPort); + EntryBin * schedulerPathEntry = createEntry( + OptionsContainer::schedulerPath); + + schedulerTable->attach(*schedulerServerEntry, 2, 3, 0, 1); + schedulerTable->attach(*schedulerPortEntry, 2, 3, 1, 2); + schedulerTable->attach(*schedulerPathEntry, 2, 3, 2, 3); + // make a new box and pack the components into it Gtk::VBox * section = Gtk::manage(new Gtk::VBox); section->pack_start(*authenticationTable, Gtk::PACK_SHRINK, 10); section->pack_start(*storageTable, Gtk::PACK_SHRINK, 10); + section->pack_start(*schedulerTable, Gtk::PACK_SHRINK, 10); return section; } @@ -867,3 +912,16 @@ OptionsWindow :: resetEditedKeyBinding(void) throw () } } + +/*------------------------------------------------------------------------------ + * Show the window and return when the user hides it. + *----------------------------------------------------------------------------*/ +void +OptionsWindow :: run(void) throw () +{ + mainNotebook->activatePage(2); // "Servers" + property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS); + show_all(); + Gtk::Main::run(*this); +} + diff --git a/livesupport/src/products/gLiveSupport/src/OptionsWindow.h b/livesupport/src/products/gLiveSupport/src/OptionsWindow.h index 5235fe908..ced0cd75b 100644 --- a/livesupport/src/products/gLiveSupport/src/OptionsWindow.h +++ b/livesupport/src/products/gLiveSupport/src/OptionsWindow.h @@ -409,6 +409,14 @@ class OptionsWindow : public GuiWindow { return backupView ? backupView->getBackupList() : 0; } + + /** + * Show the window and return when the user hides it. + * This is used by GLiveSupport when the authentication server + * address is wrong. It opens the window to the "Servers" tab. + */ + void + run(void) throw (); }; /* ================================================= external data structures */ diff --git a/livesupport/src/products/gLiveSupport/var/root.txt b/livesupport/src/products/gLiveSupport/var/root.txt index 4be5e4d0d..67fa37904 100644 --- a/livesupport/src/products/gLiveSupport/var/root.txt +++ b/livesupport/src/products/gLiveSupport/var/root.txt @@ -21,11 +21,14 @@ root:table elapsedTimeLabel:string { "elapsed" } remainingTimeLabel:string { "remaining" } - localeNotAvailableMsg:string { "Locale {0} not available" } - schedulerNotReachableMsg:string { "Scheduler server not available" } - storageNotReachableMsg:string { "Storage server not available" } + localeNotAvailableMsg:string { "Locale {0} is not available." } + schedulerNotReachableMsg:string { "The scheduler server is not available." } + storageNotReachableMsg:string { "The storage server is not available." } authenticationNotReachableMsg:string - { "Authentication server not available" } + { "The authentication server is not " + "available.\n" + "Would you like to edit the server " + "settings?" } audioErrorMsg { "Audio player error: " } sureToExitMsg:string { "Are you sure you want to exit?" } @@ -283,6 +286,7 @@ root:table authenticationLabel:string { "Authentication server" } storageLabel:string { "Storage server" } + schedulerLabel:string { "Scheduler server" } serverLabel:string { "address:" } portLabel:string { "port:" } pathLabel:string { "path:" }