Author: tgoettlicher Date: Thu Nov 15 14:52:10 2007 New Revision: 7825 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7825&view=rev Log: fixed update check starts again with new kde session (#331651) Modified: trunk/updater-kde/updater/MainWindow.cpp trunk/updater-kde/updater/UpdaterApplication.cpp trunk/updater-kde/updater/opensuseupdater_settings.kcfg Modified: trunk/updater-kde/updater/MainWindow.cpp URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.cpp?rev=7825&r1=7824&r2=7825&view=diff ============================================================================== --- trunk/updater-kde/updater/MainWindow.cpp (original) +++ trunk/updater-kde/updater/MainWindow.cpp Thu Nov 15 14:52:10 2007 @@ -354,14 +354,10 @@ _check_updates_action->setEnabled(false); _edit_sources_action->setEnabled(false); - } -// todo + void MainWindow::slotAppletState(int state, int patches, int packages) { - - - if (state == APPLET_UPDATES || state == APPLET_CRITICAL_UPDATES ) { _simple->setRecommendedCount(patchCountRecommended()); @@ -494,6 +490,11 @@ { kdDebug() << "populateDone()" << endl; updateButtons(); + + // set last check time + UpdaterSettings::self()->setLastCheckTime(QDateTime::currentDateTime() ); + UpdaterSettings::self()->writeConfig(); + } void MainWindow::gotDescription(QString description, int resolvableType) @@ -793,6 +794,10 @@ updateButtons(); + // clear last check time + UpdaterSettings::self()->setLastCheckTime(QDateTime()); + UpdaterSettings::self()->writeConfig(); + emit(populateLists(patchList, packageList, !displayProgress)); //3arg = silent } Modified: trunk/updater-kde/updater/UpdaterApplication.cpp URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/UpdaterApplication.cpp?rev=7825&r1=7824&r2=7825&view=diff ============================================================================== --- trunk/updater-kde/updater/UpdaterApplication.cpp (original) +++ trunk/updater-kde/updater/UpdaterApplication.cpp Thu Nov 15 14:52:10 2007 @@ -40,23 +40,23 @@ { _simple = new SimpleView(); - _main = new MainWindow(0, _simple); + _main = new MainWindow(0, _simple); _simple->setDetailWindow(_main); setMainWidget(_main); setTopWidget(_main); - connect(this, SIGNAL(pluginError(const QString &)), _main, SLOT(slotPluginError(const QString &))); - connect(this, SIGNAL(showConfig()), _main, SLOT(configButtonClicked())); + connect(this, SIGNAL(pluginError(const QString &)), _main, SLOT(slotPluginError(const QString &))); + connect(this, SIGNAL(showConfig()), _main, SLOT(configButtonClicked())); - connect(_main, SIGNAL(signalConfigChanged()), this, SLOT(slotConfigChanged())); - - connect(_simple, SIGNAL(showDetailView()), _main, SLOT(showMainWindow())); - connect(_simple, SIGNAL(startInstall()), _main, SLOT(installButtonClicked())); - connect(_simple, SIGNAL(patchSelectRecommended()), _main, SLOT(patchSelectRecommended())); - connect(_simple, SIGNAL(patchStandardSelection()), _main, SLOT(patchStandardSelection())); - connect(_simple, SIGNAL(patchUnselectRestart()), _main, SLOT(patchUnselectRestart())); + connect(_main, SIGNAL(signalConfigChanged()), this, SLOT(slotConfigChanged())); + connect(_simple, SIGNAL(showDetailView()), _main, SLOT(showMainWindow())); + connect(_simple, SIGNAL(startInstall()), _main, SLOT(installButtonClicked())); + connect(_simple, SIGNAL(patchSelectRecommended()), _main, SLOT(patchSelectRecommended())); + connect(_simple, SIGNAL(patchStandardSelection()), _main, SLOT(patchStandardSelection())); + connect(_simple, SIGNAL(patchUnselectRestart()), _main, SLOT(patchUnselectRestart())); + connectToPlugin(); } @@ -64,12 +64,12 @@ { // disconnect old plugin and delete it - if ( _updater ) + if ( _updater ) { disconnect(_updater,0, _main,0); disconnect(_main,0, _updater,0); - _updater->shutdown(); + _updater->shutdown(); delete _updater; _updater = NULL; } @@ -80,15 +80,34 @@ if ( service ) loadPlugin(service); else - emit(pluginError(i18n("Backend plugin is not properly configured.\nPlease use the configuration dialog to choose the correct one."))); + emit(pluginError(i18n( + "Backend plugin is not properly configured.\nPlease use the configuration dialog to choose the correct one."))); - if ( _updater ) + if ( _updater ) { setupUpdater(_updater); - kdDebug() << "Will check for updates soon." << endl; - QTimer::singleShot( 30*1000, _main , SLOT(checkUpdatesWithoutProgress() )); - _main->slotAppletState(APPLET_CHECKING, 0, 0); - _main->setUpdaterCapabilities(_updater->capabilities()); + _main->setUpdaterCapabilities(_updater->capabilities()); + + // calculate time for first check + QDateTime lastCheckTime = UpdaterSettings::self()->lastCheckTime(); + QDateTime now = QDateTime::currentDateTime(); + int interval = UpdaterSettings::self()->interval(); + int nextCheck = (interval * 60 * 60 ) - lastCheckTime.secsTo(now); + if (nextCheck < 30) + nextCheck = 30; + + kdDebug() << "LastCheck: " << lastCheckTime << endl; + kdDebug() << "now: " << now << endl; + kdDebug() << "interval: " << interval << endl; + kdDebug() << "interval s:" << interval * 60 * 60 << endl; + kdDebug() << "sec diff : " << lastCheckTime.secsTo(now) << endl; + kdDebug() << "nextCheck: " << nextCheck << endl; + + // clear last check time + UpdaterSettings::self()->setLastCheckTime(QDateTime()); + UpdaterSettings::self()->writeConfig(); + + QTimer::singleShot( nextCheck * 1000, _main , SLOT(checkUpdatesWithoutProgress() )); } } @@ -147,23 +166,23 @@ KService::Ptr UpdaterApplication::selectPlugin(QString backendName) { int pluginCount=0; - KService::Ptr service; + KService::Ptr service; - kdDebug() << "Searching for desired backend plugin \"" << backendName << "\" ..." << endl; + kdDebug() << "Searching for desired backend plugin \"" << backendName << "\" ..." << endl; - KTrader::OfferList offers = KTrader::self()->query("openSUSEUpdater/Backend"); - KTrader::OfferList::ConstIterator iter; + KTrader::OfferList offers = KTrader::self()->query("openSUSEUpdater/Backend"); + KTrader::OfferList::ConstIterator iter; // ---------------------------------------------------------- // Try to load selected plugin - for(iter = offers.begin(); iter != offers.end(); ++iter ) - { - service = *iter; + for(iter = offers.begin(); iter != offers.end(); ++iter ) + { + service = *iter; pluginCount++; - kdDebug() << "Found backend plugin \"" << service->name() << "\"" << endl; - if (service->name() == backendName) + kdDebug() << "Found backend plugin \"" << service->name() << "\"" << endl; + if (service->name() == backendName) return service; } @@ -175,7 +194,7 @@ if (pluginCount == 0) { QMessageBox::critical( NULL, PROGRAM_DISPLAY_NAME, - QString("Unable to find any backend plugin. Please install one and restart %1").arg(PROGRAM_DISPLAY_NAME)); + QString("Unable to find any backend plugin. Please install one and restart %1").arg(PROGRAM_DISPLAY_NAME)); return NULL; } @@ -220,46 +239,46 @@ void UpdaterApplication::setupUpdater( Updater *updater ) { - //Connects the signals + //Connects the signals - //Signal that controls applet state - connect(updater, SIGNAL(updateApplet(int, int, int)), _main, SLOT(slotAppletState(int, int, int))); + //Signal that controls applet state + connect(updater, SIGNAL(updateApplet(int, int, int)), _main, SLOT(slotAppletState(int, int, int))); - connect(updater, SIGNAL(setProgress(int, int, QString)), _main, SLOT(slotSetProgress(int, int, QString))); - connect(updater, SIGNAL(setProgressNextStep(QString)), _main, SLOT(slotSetProgressNextStep(QString))); - connect(updater, SIGNAL(showProgress(bool)), _main, SLOT(showProgress(bool))); + connect(updater, SIGNAL(setProgress(int, int, QString)), _main, SLOT(slotSetProgress(int, int, QString))); + connect(updater, SIGNAL(setProgressNextStep(QString)), _main, SLOT(slotSetProgressNextStep(QString))); + connect(updater, SIGNAL(showProgress(bool)), _main, SLOT(showProgress(bool))); - connect(updater, SIGNAL(updateAppletError(const QString &)), _main, SLOT(slotAppletError(const QString &))); + connect(updater, SIGNAL(updateAppletError(const QString &)), _main, SLOT(slotAppletError(const QString &))); - //Signal which allows updater "plugins" to force an update refresh - connect(updater, SIGNAL(refreshList()), _main, SLOT(checkUpdatesWithoutProgress())); + //Signal which allows updater "plugins" to force an update refresh + connect(updater, SIGNAL(refreshList()), _main, SLOT(checkUpdatesWithoutProgress())); - //Starts installation - connect(_main, SIGNAL(startInstall()), updater, SLOT(startInstall())); + //Starts installation + connect(_main, SIGNAL(startInstall()), updater, SLOT(startInstall())); - //Starts updater backend configuration - connect(_main, SIGNAL(configureUpdater()), updater, SLOT(configureUpdater())); + //Starts updater backend configuration + connect(_main, SIGNAL(configureUpdater()), updater, SLOT(configureUpdater())); - //Start update list populate, makes backend check for updates - connect(_main, SIGNAL(populateLists(QListView*, QListView*, bool)), updater, SLOT(populateLists(QListView*, QListView*, bool))); + //Start update list populate, makes backend check for updates + connect(_main, SIGNAL(populateLists(QListView*, QListView*, bool)), updater, SLOT(populateLists(QListView*, QListView*, bool))); - //Signal to inform the mainwindow of new updates in the list - connect(updater, SIGNAL(populateDone()), _main, SLOT(populateDone())); + //Signal to inform the mainwindow of new updates in the list + connect(updater, SIGNAL(populateDone()), _main, SLOT(populateDone())); - //Signals to get backend to put together a description for selected update and to return that description - connect(_main, SIGNAL(resolvableSelected(QListViewItem*, int)), updater, SLOT(resolvableSelected(QListViewItem*, int))); - connect(updater, SIGNAL(returnDescription(QString,int)), _main, SLOT(gotDescription(QString,int))); + //Signals to get backend to put together a description for selected update and to return that description + connect(_main, SIGNAL(resolvableSelected(QListViewItem*, int)), updater, SLOT(resolvableSelected(QListViewItem*, int))); + connect(updater, SIGNAL(returnDescription(QString,int)), _main, SLOT(gotDescription(QString,int))); - //Signal to tell the backend to show a menu at the specified position -// connect(_main, SIGNAL(updateMenu(QListViewItem*, const QPoint&)), updater, SLOT(updateMenu(QListViewItem*, const QPoint&))); + //Signal to tell the backend to show a menu at the specified position + //connect(_main, SIGNAL(updateMenu(QListViewItem*, const QPoint&)), updater, SLOT(updateMenu(QListViewItem*, const QPoint&))); } UpdaterApplication::~UpdaterApplication() { - if ( _updater ) - _updater->shutdown(); + if ( _updater ) + _updater->shutdown(); delete _main; delete _updater; Modified: trunk/updater-kde/updater/opensuseupdater_settings.kcfg URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/opensuseupdater_settings.kcfg?rev=7825&r1=7824&r2=7825&view=diff ============================================================================== --- trunk/updater-kde/updater/opensuseupdater_settings.kcfg (original) +++ trunk/updater-kde/updater/opensuseupdater_settings.kcfg Thu Nov 15 14:52:10 2007 @@ -30,5 +30,8 @@ <label>Always show detailed view.</label> <default>false</default> </entry> + <entry name="LastCheckTime" type="DateTime"> + <label>Last check for updates.</label> + </entry> </group> </kcfg> -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org