Author: tgoettlicher Date: Thu Aug 2 17:15:49 2007 New Revision: 6402 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6402&view=rev Log: cleanup Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.cpp trunk/updater-kde/updater/zypp/ZYppUpdater.h Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.cpp URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpda... ============================================================================== --- trunk/updater-kde/updater/zypp/ZYppUpdater.cpp (original) +++ trunk/updater-kde/updater/zypp/ZYppUpdater.cpp Thu Aug 2 17:15:49 2007 @@ -53,7 +53,6 @@ ZYppUpdater::ZYppUpdater( QObject *parent, const char* name, const QStringList& ) : Updater( parent, name ) , _process(0L) - , _install_process(0L) , _state(Unknown) , _update_counter(0) , _patchList(0) @@ -70,8 +69,6 @@ kdDebug() << "Initializing zypp backend" << endl; _xml_reader.setContentHandler(this); - _xml_reader.parse( &_xml_source, - true /* incremental parsing*/); } @@ -88,8 +85,6 @@ kdDebug() << "install process exited." << endl; emit(showProgress(false)); - - if (p->exitStatus() == 0 && _install_stderr_buffer.isEmpty() && _install_stdout_buffer.isEmpty() ) { // Everything is fine @@ -98,23 +93,12 @@ doCheckForUpdates(); } - if (p->exitStatus() == 103 ) { - QMessageBox::information( NULL, PROGRAM_DISPLAY_NAME, i18n("One of installed patches affects the package manager itself, thus it requires to restart %1.").arg(PROGRAM_DISPLAY_NAME)); - system("( sleep 2; opensuseupdater-kde ) & "); - kapp->quit(); } - if (p->exitStatus() == 102) - { - QMessageBox::information( NULL, PROGRAM_DISPLAY_NAME, - i18n("One of installed patches requires reboot of your machine. Please, do it as soon as possible.")); - doCheckForUpdates(); - } - if ( !_install_stderr_buffer.isEmpty() || !_install_stdout_buffer.isEmpty() ) { // some errors/warnings occured @@ -139,7 +123,6 @@ _install_stderr_buffer.truncate(0); _install_stdout_buffer.truncate(0); delete p; - _install_process = 0L; } @@ -158,9 +141,8 @@ kdDebug() << _buffer << endl; delete _process; _process = 0L; - // parse the xml - + // parse the xml if ( ! _last_xml_parse_code ) { @@ -170,19 +152,9 @@ else updateAppletError(i18n("helper program returned:\n%1").arg(_buffer) ); - if ( _stderr_buffer.find("Forgot to chmod this program") != -1 ) - QMessageBox::critical( NULL, PROGRAM_DISPLAY_NAME, i18n("Unable to check for patches and updates because /usr/sbin/zypp-checkpatches-wrapper helper programm is not set SUID root.\nThis problem might be solved by setting "File Permissons" in YaST "Local Security" tab to "easy" or by modifying /etc/permissions.local.")); - - // clear the buffer _stderr_buffer.truncate(0); _buffer.truncate(0); - - // remove if 2 programs are run at the same time - _xml_source.setData(QString()); - _last_xml_parse_code = true; - _xml_reader.parse( &_xml_source, - true /* incremental parsing*/); emit(populateDone()); return; @@ -191,8 +163,6 @@ // clear the buffer _stderr_buffer.truncate(0); _buffer.truncate(0); - _xml_source.setData(QString()); - _last_xml_parse_code = true; if ( ! _patchList || !_packageList ) { @@ -203,7 +173,8 @@ _patchList->clear(); _packageList->clear(); - bool pkgmgr_avail=false; + bool pkgmgr_available=false; + bool critical_available=false; kdDebug() << "populating... " << _resolvables.count() << " resolvables" << endl; @@ -224,30 +195,39 @@ newItem->setText(COLUMN_RESTART, ((*it)->restart == true ) ? "Yes" : "No" ) ; newItem->setText(COLUMN_RESTART_HIDDEN, ((*it)->restart == true) ? "restart" : "norestart" ); + if ((*it)->category == "security") + critical_available=true; + if ((*it)->pkgmanager) { - pkgmgr_avail=true; + pkgmgr_available=true; newItem->setText(COLUMN_TYPE, "packagemanager" ); } - - } - if (pkgmgr_avail) + + if (pkgmgr_available) emit(updateApplet(APPLET_PKGMGR_UPDATES, _patchList->childCount(), _packageList->childCount())); + else if (critical_available) + emit(updateApplet(APPLET_CRITICAL_UPDATES, _patchList->childCount(), _packageList->childCount())); else if ( _patchList->childCount() > 0 ) emit(updateApplet(APPLET_UPDATES, _patchList->childCount(), _packageList->childCount())); else emit(updateApplet(APPLET_NO_UPDATES, 0, 0)); + // TODO + if ( _message ) + { + emit(updateAppletError(_error_buffer)); + _message_buffer.truncate(0); + } + if ( _error ) { - emit(updateAppletError(_error_message_buffer)); - _error_message_buffer.truncate(0); + emit(updateAppletError(_error_buffer)); + _error_buffer.truncate(0); } emit(populateDone()); - _xml_reader.parse( &_xml_source, - true /* incremental parsing*/); } void ZYppUpdater::slotReceivedStdout(KProcess *proc, char *buffer, int buflen) @@ -307,18 +287,15 @@ if ( _process ) { - kdDebug() << "Check process still running. Will not run this time." << endl; + kdDebug() << "Process still running. Will not run this time." << endl; emit(updateApplet(APPLET_CHECKING, 0, 0)); return; } - - if ( _install_process ) - { - kdDebug() << "Install process running. Will not run check this time." << endl; - emit(updateApplet(APPLET_INSTALLING, 0, 0)); - return; - } - + // remove if 2 programs are run at the same time + _xml_source.setData(QString()); + _last_xml_parse_code = true; + _xml_reader.parse( &_xml_source, + true /* incremental parsing*/); _process = new KProcess; *_process << "/usr/sbin/zypp-checkpatches-wrapper"; @@ -374,6 +351,13 @@ void ZYppUpdater::startInstall() { + if ( _process ) + { + // TODO update still running + kdDebug() << "Process still running. Will not run this time." << endl; + return; + } + if (!_patchList || !_packageList) { kdDebug() << "!_patchList || !_packageList!!! " << endl; @@ -383,9 +367,10 @@ QStringList installPatchList; QStringList installPackageList; - QStringList installPkgMgrList; QCheckListItem *item = (QCheckListItem*)_patchList->firstChild(); + kdDebug() << "patchlist elements: " << _patchList->childCount() << endl; + while (item != NULL) { if (item->isOn()) @@ -395,19 +380,14 @@ { ZYppResolvable *patch = zi->resolvable(); + kdDebug() << patch->name << endl; if ( patch->license.stripWhiteSpace().isEmpty()) - if (patch->pkgmanager) - installPkgMgrList += item->text(); - else - installPatchList += item->text(); + installPatchList += item->text(); else { licenseDialog->setText(i18n("License of %1").arg(patch->name), patch->license); if ( licenseDialog->exec() ) - if (patch->pkgmanager) - installPkgMgrList += item->text(); - else - installPatchList += item->text(); + installPatchList += item->text(); } } } @@ -423,12 +403,12 @@ ZYppListItem *zi = dynamic_cast<ZYppListItem *>(item); if ( zi ) { - ZYppResolvable *patch = zi->resolvable(); - if ( patch->license.stripWhiteSpace().isEmpty()) - installPackageList += item->text(); + ZYppResolvable *package = zi->resolvable(); + if ( package->license.stripWhiteSpace().isEmpty()) + installPackageList += item->text(); else { - licenseDialog->setText(i18n("License of %1").arg(patch->name), patch->license); + licenseDialog->setText(i18n("License of %1").arg(package->name), package->license); if ( licenseDialog->exec() ) installPackageList += item->text(); } @@ -438,44 +418,28 @@ } - - - - if ( _install_process ) - { - // TODO update still running - kdDebug() << "Update process still running. Will not run this time." << endl; - return; - } - - _install_process = new KProcess; + kdDebug() << "_process" << endl; + _process = new KProcess; QString command="/usr/sbin/zypper_install"; - *_install_process << command << "--patch" << installPatchList << "--package" << installPackageList << "--pkgmgr" << installPkgMgrList; - + *_process << command << "--patch" << installPatchList << "--package" << installPackageList; -// QObject::connect( _install_process, SIGNAL( processExited( KProcess * ) ), -// SLOT( slotInstallProcessExited( KProcess * ) ) ); -// QObject::connect( _install_process, SIGNAL( receivedStdout(KProcess *, char *, int ) ), -// SLOT( slotInstallReceivedStdout(KProcess *, char *, int ) ) ); -// QObject::connect( _install_process, SIGNAL( receivedStderr(KProcess *, char *, int ) ), -// SLOT( slotInstallReceivedStderr(KProcess *, char *, int ) ) ); - QObject::connect( _install_process, SIGNAL( processExited( KProcess * ) ), + QObject::connect( _process, SIGNAL( processExited( KProcess * ) ), SLOT( slotProcessExited( KProcess * ) ) ); - QObject::connect( _install_process, SIGNAL( receivedStdout(KProcess *, char *, int ) ), + QObject::connect( _process, SIGNAL( receivedStdout(KProcess *, char *, int ) ), SLOT( slotReceivedStdout(KProcess *, char *, int ) ) ); - QObject::connect( _install_process, SIGNAL( receivedStderr(KProcess *, char *, int ) ), + QObject::connect( _process, SIGNAL( receivedStderr(KProcess *, char *, int ) ), SLOT( slotReceivedStderr(KProcess *, char *, int ) ) ); - bool result = _install_process->start( KProcess::NotifyOnExit, KProcess::AllOutput ); + bool result = _process->start( KProcess::NotifyOnExit, KProcess::AllOutput ); if ( ! result ) { kdDebug() << "error launching install process..." << endl; emit(updateAppletError(i18n("Can't launch install helper program. Make sure zypper package is installed and working."))); - delete _install_process; - _install_process = 0L; + delete _process; + _process = 0L; emit(populateDone()); return; } @@ -501,6 +465,9 @@ inst_source->start( KProcess::NotifyOnExit ); } + + + // QXmlHandler stuff bool ZYppUpdater::startDocument() @@ -508,6 +475,7 @@ kdDebug() << "start document..." << endl; _found_update_status_tag = false; _error = false; + _message = false; _resolvables.setAutoDelete(true); _resolvables.clear(); return true; @@ -529,27 +497,32 @@ } if ( _state == Error ) { - _error_message_buffer += ch; + _error_buffer += ch; } return true; } bool ZYppUpdater::startElement( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ) { -// Unknown, -// UpdateSources, -// UpdateList, - // here we have to allocate a patch or source in the stack kdDebug() << "xml..." << qName << endl; // if ( qName == "update-status" ) // { // _found_update_status_tag = true; // } + if ( qName == "messages") + { + _state = Messages; + } if ( qName == "errors") { _state = Errors; } + if ( (qName == "message") && (_state == Messages ) ) + { + _state = Message; + _message = true; + } if ( (qName == "error") && (_state == Errors ) ) { _state = Error; @@ -571,12 +544,6 @@ _current_resolvable->resolvableType= ( atts.value("resolvabletype") == "patch" ? RESOLVABLE_PATCH : RESOLVABLE_PACKAGE ); -// _current_resolvable->restart=false; -// _current_resolvable->pkgmanager= false; -// _current_resolvable->interactive= false; - - - _state = Update; // ignore sources for now return true; @@ -630,9 +597,18 @@ } if ( (qName == "error") && (_state == Error) ) { - _error_message_buffer += "\n"; + _error_buffer += "\n"; _state = Errors; } + if ( (qName == "message") && (_state == Messages) ) + { + _message_buffer += "\n"; + _state = Messages; + } + if ( (qName == "messages") ) + { + _state = Unknown; + } if ( (qName == "errors") ) { _state = Unknown; Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpda... ============================================================================== --- trunk/updater-kde/updater/zypp/ZYppUpdater.h (original) +++ trunk/updater-kde/updater/zypp/ZYppUpdater.h Thu Aug 2 17:15:49 2007 @@ -67,6 +67,8 @@ UpdateLicense, Errors, Error, + Messages, + Message, } XmlState; class ZYppUpdater : public Updater, public QXmlDefaultHandler @@ -157,9 +159,9 @@ QString _buffer; QString _stderr_buffer; - QString _error_message_buffer; + QString _error_buffer; + QString _message_buffer; - KProcess *_install_process; QString _install_stderr_buffer; QString _install_stdout_buffer; @@ -188,6 +190,7 @@ bool _found_update_status_tag; bool _last_xml_parse_code; bool _error; + bool _message; // QProgressDialog *progressDialog; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org