[zypp-commit] r5530 - in /branches/work/updater-kde-refactoring/updater-kde/updater: MainWindow.cpp MainWindow.h UpdaterApplication.cpp UpdaterApplication.h
Author: tgoettlicher Date: Thu May 10 15:09:31 2007 New Revision: 5530 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5530&view=rev Log: backend plugin can be changed without restart Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.h Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp?rev=5530&r1=5529&r2=5530&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp Thu May 10 15:09:31 2007 @@ -43,7 +43,6 @@ #include "HeaderWidget.h" #include "MainWindow.h" #include "kconfigdialog.h" -//#include "updatersettingswidget_base.h" #include "opensuseupdater_settings.h" #include "Updater.h" #include "UpdateListItem.h" @@ -52,7 +51,6 @@ - MainWindow::MainWindow( const UpdaterCapabilities &caps, QWidget *parent) : KMainWindow(parent) , _caps(caps) @@ -333,7 +331,11 @@ KConfigDialog* dialog = new KConfigDialog( this, "updater-settings", UpdaterSettings::self() ); connect( configDialog, SIGNAL(settingsChanged()), this, SLOT(slotConfigChanged()) ); - connect( configDialog, SIGNAL(settingsChanged()), this, SLOT(slotConfigChanged()) ); + + // dirty hack + connect( this, SIGNAL(settingsChanged()), configDialog, SLOT(settingsChangedSlot()) ); + emit (settingsChanged()); + configDialog->show(); } @@ -431,7 +433,6 @@ kapp->quit(); } -// void MainWindow::showMainWindow() { show(); Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h?rev=5530&r1=5529&r2=5530&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h Thu May 10 15:09:31 2007 @@ -81,6 +81,8 @@ signals: + void settingsChanged(); + /** Signal we send to our current backend requesting updates for the list. Modified: branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp?rev=5530&r1=5529&r2=5530&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp Thu May 10 15:09:31 2007 @@ -38,17 +38,47 @@ { _main = new MainWindow(UpdaterCapabilities()); + setMainWidget(_main); + connect(this, SIGNAL(pluginError(const QString &)), _main, SLOT(slotAppletError(const QString &))); connect(this, SIGNAL(pluginError(const QString &)), _main, SLOT(configButtonClicked())); connect(_main, SIGNAL(signalConfigChanged()), this, SLOT(slotConfigChanged())); - selectPlugin(); - setMainWidget(_main); + connectToPlugin(); + +} + +void UpdaterApplication::connectToPlugin() +{ + + // disconnect old plugin and delete it + if ( _updater ) + { + disconnect(_updater,0, _main,0); + disconnect(_main,0, _updater,0); + + _updater->shutdown(); + delete _updater; + } + + // read new plugin form config and connect to it + KService::Ptr service = selectPlugin(UpdaterSettings::self()->backendPlugin()); + + + if ( service != NULL) + loadPlugin(service); + else + { + emit(pluginError(i18n("Backend plugin is not properly configured.\nPlease use the configuration dialog to choose the correct one."))); + } + if (_updater != NULL ) setupUpdater(_updater); + + _main->checkUpdates(); +} -} bool UpdaterApplication::loadPlugin(KService::Ptr service) { @@ -96,61 +126,29 @@ void UpdaterApplication::slotConfigChanged() { - - - - kdDebug() << "CONFIG CHANGED" << endl; - kdDebug() << "Unable to connect new plugin. " << endl; - kdDebug() << "Restart Application to use new plugin " << endl; - - return; - - if ( _updater ) - { - _updater->shutdown(); - delete _updater; - } - - disconnect(_updater,0, _main,0); - disconnect(_main,0, _updater,0); - - selectPlugin(); - - if (_updater != NULL ) - setupUpdater(_updater); - - + kdDebug() << "Config has changed. Reloading backend plugin..." << endl; + connectToPlugin(); } -void UpdaterApplication::selectPlugin() +KService::Ptr UpdaterApplication::selectPlugin(QString backendName) { - - QString backend = UpdaterSettings::self()->backendPlugin(); - - kdDebug() << "Searching for desired backend plugin \"" << backend << "\" ..." << endl; + kdDebug() << "Searching for desired backend plugin \"" << backendName << "\" ..." << endl; KTrader::OfferList offers = KTrader::self()->query("openSUSEUpdater/Backend"); KTrader::OfferList::ConstIterator iter; - bool pluginFound = false; - for(iter = offers.begin(); iter != offers.end(); ++iter ) { KService::Ptr service = *iter; kdDebug() << "Found backend plugin \"" << service->name() << "\"" << endl; - if (service->name() == backend) - { - kdDebug() << "Trying to load backend plugin \"" << service->name() << "\"." << endl; - loadPlugin(service); - pluginFound = true; - } - } - if (!pluginFound) - { - emit(pluginError(i18n("Backend plugin is not properly configured.\nPlease use the configuration dialog to choose the correct one."))); + if (service->name() == backendName) + return service; } + + // No Plugin found + return NULL; } void UpdaterApplication::setupUpdater( Updater *updater ) Modified: branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.h?rev=5530&r1=5529&r2=5530&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.h (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.h Thu May 10 15:09:31 2007 @@ -56,7 +56,9 @@ MainWindow *_main; Updater *_updater; bool loadPlugin(KService::Ptr service); - void selectPlugin(); + KService::Ptr selectPlugin(QString backendName); + void connectToPlugin(); + signals: void shutdown(); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
tgoettlicher@svn.opensuse.org