Author: tgoettlicher
Date: Tue Jul 17 16:25:26 2007
New Revision: 6050
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6050&view=rev
Log:
Added Zypp Backend with traditional logic (calling yast for
installation)
Added:
trunk/updater-kde/updater/zypp_traditional/
trunk/updater-kde/updater/zypp_traditional/CMakeLists.txt
trunk/updater-kde/updater/zypp_traditional/ZYppListItem.cpp
trunk/updater-kde/updater/zypp_traditional/ZYppListItem.h
trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.cpp
trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.h
trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.cpp
trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.h
trunk/updater-kde/updater/zypp_traditional/opensuseupdater_zypp_traditional.desktop
trunk/updater-kde/updater/zypp_traditional/zyppupdaterpreferences_base.ui
Modified:
trunk/updater-kde/updater/CMakeLists.txt
trunk/updater-kde/updater/MainWindow.cpp
trunk/updater-kde/updater/MainWindow.h
trunk/updater-kde/updater/simpleview.cpp
trunk/updater-kde/updater/simpleview.h
trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
Modified: trunk/updater-kde/updater/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/CMakeLists.txt?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/CMakeLists.txt (original)
+++ trunk/updater-kde/updater/CMakeLists.txt Tue Jul 17 16:25:26 2007
@@ -1,5 +1,6 @@
#ADD_SUBDIRECTORY( zmd )
ADD_SUBDIRECTORY( zypp )
+ADD_SUBDIRECTORY( zypp_traditional )
ADD_SUBDIRECTORY( dummy )
ADD_SUBDIRECTORY( dummy_with_packages )
Modified: trunk/updater-kde/updater/MainWindow.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.cpp?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/MainWindow.cpp (original)
+++ trunk/updater-kde/updater/MainWindow.cpp Tue Jul 17 16:25:26 2007
@@ -340,6 +340,7 @@
_simple->setRecommendedCount(patchCountRecommended());
_simple->setSecurityCount(patchCountSecurity());
+ _simple->setRestartCount(patchCountRestart());
_simple->setState(state);
}
@@ -486,6 +487,8 @@
void MainWindow::patchSelectButtonClicked()
{
+
+
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
@@ -532,10 +535,15 @@
void MainWindow::patchStandardSelection()
{
+
+ if ( _caps.canSelectIndividualUpdates == false )
+ return;
+
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
- if (item->text(COLUMN_TYPE) == "security" ) {
+ if (item->text(COLUMN_TYPE).lower() == "security" )
+ {
item->setState(QCheckListItem::On);
item->setSelected(true);
}
@@ -554,7 +562,8 @@
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
- if (item->text(COLUMN_TYPE) == "recommended" ) {
+ if (item->text(COLUMN_TYPE).lower() == "recommended" )
+ {
item->setState(QCheckListItem::On);
item->setSelected(true);
}
@@ -570,7 +579,7 @@
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
- if (item->text(COLUMN_TYPE) == "recommended" ) {
+ if (item->text(COLUMN_TYPE).lower() == "recommended" ) {
count++;
}
item = (QCheckListItem*)item->nextSibling();
@@ -585,7 +594,7 @@
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
- if (item->text(COLUMN_TYPE) == "security" ) {
+ if (item->text(COLUMN_TYPE).lower() == "security" ) {
count++;
}
item = (QCheckListItem*)item->nextSibling();
@@ -593,13 +602,27 @@
return count;
}
+int MainWindow::patchCountRestart()
+{
+ int count=0;
+
+ QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
+
+ while (item != NULL) {
+ if (item->text(COLUMN_RESTART_HIDDEN).lower() == "restart" ) {
+ count++;
+ }
+ item = (QCheckListItem*)item->nextSibling();
+ }
+ return count;
+}
void MainWindow::patchUnselectRestart()
{
QCheckListItem *item = (QCheckListItem*)patchList->firstChild();
while (item != NULL) {
- if (item->text(COLUMN_RESTART_HIDDEN) == "restart" ) {
+ if (item->text(COLUMN_RESTART_HIDDEN).lower() == "restart" ) {
item->setState(QCheckListItem::Off);
item->setSelected(false);
}
Modified: trunk/updater-kde/updater/MainWindow.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/MainWindow.h?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/MainWindow.h (original)
+++ trunk/updater-kde/updater/MainWindow.h Tue Jul 17 16:25:26 2007
@@ -316,6 +316,7 @@
int getNetworkStatus() const;
int patchCountRecommended();
+ int patchCountRestart();
int patchCountSecurity();
};
Modified: trunk/updater-kde/updater/simpleview.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/simpleview.cpp?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/simpleview.cpp (original)
+++ trunk/updater-kde/updater/simpleview.cpp Tue Jul 17 16:25:26 2007
@@ -45,7 +45,7 @@
title = new QLabel(centralWidget);
title->setText(i18n("Choose the updates to be installed:"));
- recommended = new QCheckBox(i18n("install %1 recommeded updates additionally").arg(42), centralWidget);
+ recommended = new QCheckBox(i18n("Install %1 recommeded updates additionally").arg(0), centralWidget);
norestart = new QCheckBox(i18n("Don't install updates that require a restart"), centralWidget);
bar = new QProgressBar(centralWidget);
@@ -185,15 +185,17 @@
if (recommendedCount > 0)
{
- recommended->setText(i18n("install %1 recommeded updates additionally").arg(recommendedCount));
+ recommended->setText(i18n("Install %1 recommeded updates additionally").arg(recommendedCount));
recommended->show();
}
else
- {
- recommended->show();
- }
+ recommended->hide();
+
+ if (restartCount > 0)
+ norestart->show();
+ else
+ norestart->hide();
- norestart->show();
install->show();
ok->hide();
details->show();
@@ -228,6 +230,12 @@
securityCount=count;
}
+void SimpleView::setRestartCount(int count)
+{
+ restartCount=count;
+}
+
+
void SimpleView::setProgress(int progress)
{
Modified: trunk/updater-kde/updater/simpleview.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/simpleview.h?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/simpleview.h (original)
+++ trunk/updater-kde/updater/simpleview.h Tue Jul 17 16:25:26 2007
@@ -29,13 +29,14 @@
int recommendedCount;
int securityCount;
-
+ int restartCount;
public slots:
void setState(int state, const QString &description = QString() );
void setRecommendedCount(int count);
void setSecurityCount(int count);
+ void setRestartCount(int count);
void setProgress(int step);
void nextStep();
void setTotalSteps(int steps);
Modified: trunk/updater-kde/updater/zypp/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp/ZYppUpdater.cpp?rev=6050&r1=6049&r2=6050&view=diff
==============================================================================
--- trunk/updater-kde/updater/zypp/ZYppUpdater.cpp (original)
+++ trunk/updater-kde/updater/zypp/ZYppUpdater.cpp Tue Jul 17 16:25:26 2007
@@ -212,7 +212,8 @@
_process = new KProcess;
- *_process << "/tmp/zypp-checkpatches-wrapper";
+// *_process << "/tmp/zypp-checkpatches-wrapper";
+ *_process << "/usr/sbin/zypp-checkpatches-wrapper";
QObject::connect( _process, SIGNAL( processExited( KProcess * ) ),
SLOT( slotProcessExited( KProcess * ) ) );
@@ -415,6 +416,12 @@
_current_resolvable->name = atts.value("name");
_current_resolvable->category = atts.value("category");
_current_resolvable->edition = atts.value("edition");
+// _current_resolvable->downloadSize= atoi (atts.value("downloadsize"));
+// _current_resolvable->resolvableType=
+// ( atts.value("resolvabletype") == "patch" ? RESOLVABLE_PATCH : RESOLVABLE_PACKAGE );
+// _current_resolvable->restart= ( atts.value("restart") == "true") ? true : false ;
+// _current_resolvable->pkgmanager= ( atts.value("pkgmanager") == "true") ? true : false ;
+// _current_resolvable->interactive= ( atts.value("interactive") == "true") ? true : false ;
_current_resolvable->downloadSize= atoi (atts.value("downloadsize"));
_current_resolvable->resolvableType=
( atts.value("resolvabletype") == "patch" ? RESOLVABLE_PATCH : RESOLVABLE_PACKAGE );
@@ -422,6 +429,13 @@
_current_resolvable->pkgmanager= ( atts.value("pkgmanager") == "true") ? true : false ;
_current_resolvable->interactive= ( atts.value("interactive") == "true") ? true : false ;
+ _current_resolvable->downloadSize= 42;
+ _current_resolvable->resolvableType= RESOLVABLE_PATCH ;
+ _current_resolvable->restart=false;
+ _current_resolvable->pkgmanager= false;
+ _current_resolvable->interactive= false;
+
+
_state = Update;
// ignore sources for now
Added: trunk/updater-kde/updater/zypp_traditional/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/CMakeLists.txt?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/CMakeLists.txt (added)
+++ trunk/updater-kde/updater/zypp_traditional/CMakeLists.txt Tue Jul 17 16:25:26 2007
@@ -0,0 +1,19 @@
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/updater ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} )
+
+
+########### next target ###############
+
+SET(opensuseupdater_zypp_traditional_PART_SRCS
+ZYppUpdater.cpp
+ZYppListItem.cpp
+)
+
+KDE3_AUTOMOC(${opensuseupdater_zypp_traditional_PART_SRCS})
+KDE3_ADD_KPART(opensuseupdater_zypp_traditional ${opensuseupdater_zypp_traditional_PART_SRCS})
+TARGET_LINK_LIBRARIES(opensuseupdater_zypp_traditional ${QT_AND_KDECORE_LIBS} opensuseupdater )
+INSTALL_TARGETS(/lib/kde3 opensuseupdater_zypp_traditional )
+
+########### install files ###############
+
+INSTALL_FILES( /share/services FILES opensuseupdater_zypp_traditional.desktop )
+
Added: trunk/updater-kde/updater/zypp_traditional/ZYppListItem.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppListItem.cpp?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppListItem.cpp (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppListItem.cpp Tue Jul 17 16:25:26 2007
@@ -0,0 +1,31 @@
+/*
+ Copyright (C) 2006 Narayan Newton
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "ZYppListItem.h"
+
+ZYppListItem::ZYppListItem( ZYppResolvable *patch, QListView *parent, const QString &text )
+ : QListViewItem(parent, text )
+ , _patch(patch)
+{
+}
+
+ZYppResolvable * ZYppListItem::patch() const
+{
+ return _patch;
+}
Added: trunk/updater-kde/updater/zypp_traditional/ZYppListItem.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppListItem.h?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppListItem.h (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppListItem.h Tue Jul 17 16:25:26 2007
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2006 Narayan Newton
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _ZYPP_LIST_ITEM_H_
+#define _ZYPP_LIST_ITEM_H_
+
+#include
+#include
+
+/**
+ @file
+
+ Defines ZYppListItem.
+**/
+
+/**
+ ZYppListItem basically just allows for special "refcounting."
+ It keeps track of user clicks and increments/decrements a counter
+
+ @author Narayan Newton
+**/
+class ZYppListItem : public QListViewItem
+{
+
+ public:
+
+ ZYppListItem( ZYppResolvable *, QListView *, const QString& );
+ ZYppResolvable * patch() const;
+
+ private:
+ ZYppResolvable *_patch;
+};
+
+#endif
+
Added: trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.cpp?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.cpp (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.cpp Tue Jul 17 16:25:26 2007
@@ -0,0 +1,457 @@
+/*
+ Copyright (C) 2006 Novell Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ZYppUpdater.h"
+#include "ZYppListItem.h"
+#include "MainWindow.h"
+#include "UpdateListItem.h"
+
+// <?xml version='1.0'?>
+// <update-status op="success">
+// <update-sources>
+// <source url="http://ftp.gwdg.de/pub/suse/update/10.1" alias="http://ftp.gwdg.de/pub/suse/update/10.1"/>
+// </update-sources>
+// <update-list>
+// <update category="security">
+// <name>java-1_5_0-sun</name>
+// <edition>1438-0</edition>
+// </update>
+// <update category="recommended">
+// <name>ghostscript-library</name>
+// <edition>1686-0</edition>
+// </update>
+// </update-list>
+// <update-summary total="2" security="1"/>
+// </update-status>
+
+K_EXPORT_COMPONENT_FACTORY( opensuseupdater_zypp_traditional, KGenericFactory<ZYppUpdater>( "opensuseupdater_zypp_traditional" ) )
+
+ZYppUpdater::ZYppUpdater( QObject *parent, const char* name, const QStringList& ) : Updater( parent, name )
+ , _process(0L)
+ , _you_process(0L)
+ , _state(Unknown)
+ , _update_counter(0)
+ , _patchList(0)
+ , _packageList(0)
+ , _found_update_status_tag(false)
+ , _end_document_reached(false)
+ , _error(false)
+{
+ //setInstance(KGenericFactory<ZYppUpdater>::instance());
+ //setXMLFile("plugindemo_capitalizeui.rc");
+
+ // For ease announce that we have been loaded.
+ kdDebug() << "ZyppUpdater plugin loaded" << endl;
+
+ kdDebug() << "Initializing zypp backend" << endl;
+}
+
+UpdaterCapabilities ZYppUpdater::capabilities()
+{
+ UpdaterCapabilities caps;
+ caps.canSelectIndividualUpdates = false;
+ caps.canProvidePackages = false;
+ return caps;
+}
+
+void ZYppUpdater::slotYOUProcessExited( KProcess *p )
+{
+ delete p;
+ _you_process = 0L;
+ doCheckForUpdates();
+}
+
+void ZYppUpdater::slotInstSourceProcessExited( KProcess *p )
+{
+ delete p;
+}
+
+void ZYppUpdater::showLog()
+{
+}
+
+void ZYppUpdater::slotProcessExited( KProcess *proc )
+{
+ kdDebug() << "check process finished..." << endl;
+ kdDebug() << _buffer << endl;
+ delete _process;
+ _process = 0L;
+ // parse the xml
+
+ QXmlInputSource xml_source;
+ xml_source.setData(_buffer);
+
+ QXmlSimpleReader reader;
+ reader.setContentHandler(this);
+ reader.parse(xml_source);
+
+ if ( !_end_document_reached )
+ {
+ kdDebug() << "Houston, we have a problem." << endl;
+ if ( _buffer.isEmpty() && !_stderr_buffer.isEmpty() )
+ updateAppletError( i18n("helper program returned:\n%1").arg(_stderr_buffer) );
+ else
+ updateAppletError(i18n("helper program returned:\n%1").arg(_buffer) );
+
+ // clear the buffer
+ _stderr_buffer.truncate(0);
+ _buffer.truncate(0);
+ emit(populateDone());
+ return;
+ }
+
+ // clear the buffer
+ _stderr_buffer.truncate(0);
+ _buffer.truncate(0);
+
+ if ( ! _patchList || !_packageList )
+ {
+ kdDebug() << " ! _patchList || ! _packageList " << endl;
+ return;
+ }
+
+ _patchList->clear();
+ _packageList->clear();
+
+
+// TODO
+ kdDebug() << "populating... " << _patches.count() << " patches" << endl;
+ for ( QPtrList<ZYppResolvable>::const_iterator it = _patches.begin(); it != _patches.end(); ++it )
+ {
+ if ( (*it)->category != "optional" )
+ {
+ QListViewItem *newItem;
+ newItem = new ZYppListItem( (*it), _patchList, (*it)->summary );
+
+ newItem->setText(COLUMN_TYPE, ((*it)->category == "security") ? i18n("Security") : i18n("Patch") );
+ newItem->setText(COLUMN_NEW_VERSION,(*it)->edition);
+ //newItem->setText(COLUMN_ID, (*iter).id);
+ newItem->setText(COLUMN_CATALOG, (*it)->source );
+ }
+ }
+
+ // TODO
+ if ( _patches.count() > 0 )
+ emit(updateApplet(APPLET_UPDATES, _patches.count(), _patches.count()));
+ else
+ emit(updateApplet(APPLET_NO_UPDATES, 0, 0));
+
+ if ( _error )
+ {
+ emit(updateAppletError(_error_message_buffer));
+ _error_message_buffer.truncate(0);
+ }
+
+ emit(populateDone());
+}
+
+void ZYppUpdater::slotReceivedStdout(KProcess *proc, char *buffer, int buflen)
+{
+ kdDebug() << "got..." << endl;
+ // add stdout to a buffer
+ // we can parse it when process finishes
+ _buffer += QString::fromUtf8( buffer, buflen );
+}
+
+
+
+void ZYppUpdater::slotReceivedStderr(KProcess *proc, char *buffer, int buflen)
+{
+ _stderr_buffer += QString::fromUtf8( buffer, buflen );
+}
+
+void ZYppUpdater::shutdown()
+{
+
+}
+
+void ZYppUpdater::doCheckForUpdates()
+{
+ kdDebug() << "Checking for updates..." << endl;
+
+ if ( _process ) {
+ kdDebug() << "Check process still running. Will not run this time." << endl;
+ emit(updateApplet(APPLET_CHECKING, 0, 0));
+ return;
+ }
+
+ _process = new KProcess;
+
+ *_process << "/usr/sbin/zypp-checkpatches-wrapper";
+
+ QObject::connect( _process, SIGNAL( processExited( KProcess * ) ),
+ SLOT( slotProcessExited( KProcess * ) ) );
+ QObject::connect( _process, SIGNAL( receivedStdout(KProcess *, char *, int ) ),
+ SLOT( slotReceivedStdout(KProcess *, char *, int ) ) );
+ QObject::connect( _process, SIGNAL( receivedStderr(KProcess *, char *, int ) ),
+ SLOT( slotReceivedStderr(KProcess *, char *, int ) ) );
+
+
+ bool result = _process->start( KProcess::NotifyOnExit, KProcess::AllOutput );
+ if ( ! result )
+ {
+ kdDebug() << "error launching zypp-checkpatches-wrapper..." << endl;
+ emit(updateAppletError(i18n("Can't launch zypp-checkpatches-wrapper helper program. Make sure zypper package is installed and working.")));
+// _list_view = 0L;
+ delete _process;
+ _process = 0L;
+ emit(populateDone());
+ return;
+ }
+
+ kdDebug() << "check process started.." << endl;
+ emit(updateApplet(APPLET_CHECKING, 0, 0));
+ //mStatusLabel->setText( i18n("Checking...") );
+}
+
+void ZYppUpdater::populateLists(QListView *patchList, QListView *packageList )
+{
+ kdDebug() << "got populate UI request..." << endl;
+ _patchList = patchList;
+ _packageList = packageList;
+ emit(updateApplet(APPLET_NO_UPDATES, 0, 0));
+ doCheckForUpdates();
+}
+
+
+
+void ZYppUpdater::resolvableSelected(QListViewItem *item, int resolvableType)
+{
+ // retrieve description
+ kdDebug() << "updating item" << endl;
+ if (resolvableType == RESOLVABLE_PATCH)
+ {
+ //TODO
+ ZYppListItem *zi = dynamic_cast(item);
+ if ( zi )
+ {
+ ZYppResolvable *patch = zi->patch();
+ emit(returnDescription(patch->description, RESOLVABLE_PATCH));
+ }
+ }
+ else
+ //TODO
+ emit(returnDescription("This package does nothing.", RESOLVABLE_PACKAGE));
+}
+
+
+void ZYppUpdater::startInstall()
+{
+ if ( _you_process != 0L )
+ {
+ kdDebug() << "yast already running" << endl;
+ return;
+ }
+
+ _you_process = new KProcess;
+ *_you_process << "opensuseupdater-su" << "-c" << "/sbin/yast2 online_update";
+
+ connect( _you_process, SIGNAL( processExited( KProcess * ) ),
+ SLOT( slotYOUProcessExited( KProcess * ) ) );
+ _you_process->start( KProcess::NotifyOnExit );
+}
+
+
+void ZYppUpdater::configureUpdater()
+{
+ kdDebug() << "configure updater" << endl;
+
+ KProcess *inst_source = new KProcess;
+ *inst_source << "opensuseupdater-su" << "-c" << "/sbin/yast2 inst_source";
+
+ connect( inst_source, SIGNAL( processExited( KProcess * ) ),
+ SLOT( slotInstSourceProcessExited( KProcess * ) ) );
+ inst_source->start( KProcess::NotifyOnExit );
+}
+
+// QXmlHandler stuff
+
+bool ZYppUpdater::startDocument()
+{
+ kdDebug() << "start document..." << endl;
+ _found_update_status_tag = false;
+ _end_document_reached = false;
+ _error = false;
+ _patches.setAutoDelete(true);
+ _patches.clear();
+ return true;
+}
+
+bool ZYppUpdater::characters ( const QString & ch )
+{
+ if ( _state == UpdateDescription )
+ {
+ _current_resolvable->description += ch;
+ }
+ if ( _state == UpdateSummary )
+ {
+ _current_resolvable->summary += ch;
+ }
+ if ( _state == Error )
+ {
+ _error_message_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 == "errors")
+ {
+ _state = Errors;
+ }
+ if ( (qName == "error") && (_state == Errors ) )
+ {
+ _state = Error;
+ _error = true;
+ }
+ if ( qName == "update" )
+ {
+ //TODO
+ kdDebug() << "found patch..." << qName << endl;
+ _current_resolvable = new ZYppResolvable();
+ _current_resolvable->name = atts.value("name");
+ _current_resolvable->category = atts.value("category");
+ _current_resolvable->edition = atts.value("edition");
+
+ _state = Update;
+ // ignore sources for now
+ return true;
+ }
+ if ( qName == "description" )
+ {
+ _state = UpdateDescription;
+ return true;
+ }
+ if ( qName == "summary" )
+ {
+ _state = UpdateSummary;
+ // ignore sources for now
+ return true;
+ }
+ if ( qName == "source" )
+ {
+ if ( _state == Update )
+ {
+ _current_resolvable->source = atts.value("alias");
+ }
+ else
+ {
+
+ }
+ // ignore sources for now
+ return true;
+ }
+ return true;
+}
+
+bool ZYppUpdater::endDocument()
+{
+ _end_document_reached = true;
+ kdDebug() << "end document" << endl;
+ if ( ! _found_update_status_tag )
+ {
+ kdDebug() << "Wrong xml output" << endl;
+ emit(updateAppletError(_buffer));
+ return false;
+ }
+ return true;
+}
+
+bool ZYppUpdater::endElement( const QString &uri , const QString &localname, const QString &qName )
+{
+ if ( qName == "source" )
+ {
+ //_state = Update;
+ }
+ if ( qName == "update-status" )
+ {
+ _state = Unknown;
+ }
+ if ( (qName == "error") && (_state == Error) )
+ {
+ _error_message_buffer += "\n";
+ _state = Errors;
+ }
+ if ( (qName == "errors") )
+ {
+ _state = Unknown;
+ }
+ if ( qName == "description" )
+ {
+ _state = Update;
+ return true;
+ }
+ if ( qName == "summary" )
+ {
+ _state = Update;
+ // ignore sources for now
+ return true;
+ }
+ if ( qName == "update" )
+ {
+ _state = Unknown;
+ kdDebug() << _current_resolvable->name << " appended" << endl;
+ _patches.append(_current_resolvable);
+ // ignore sources for now
+
+ kdDebug() << _current_resolvable->name << endl;
+ kdDebug() << _current_resolvable->summary << endl;
+
+ return true;
+ }
+
+ return true;
+}
+
+#include "ZYppUpdater.moc"
+
Added: trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.h?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.h (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppUpdater.h Tue Jul 17 16:25:26 2007
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2006 Novell Inc
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _ZYPP_UPDATER_H_
+#define _ZYPP_UPDATER_H_
+
+#include "Updater.h"
+#include
+
+/**
+ @file
+
+ This file defines ZYpp Backend
+
+ @author Martin Vidner
+ @author Duncan Mac-Vicar
+ @author Thomas Goettlicher
+*/
+
+class KProcess;
+
+struct ZYppResolvable
+{
+ QString category;
+ QString name;
+ QString edition;
+ QString source;
+ QString summary;
+ QString description;
+};
+
+struct ZYppSource
+{
+ QString url;
+ QString alias;
+};
+
+typedef enum
+{
+ Unknown,
+ Update,
+ UpdateDescription,
+ UpdateSummary,
+ Errors,
+ Error,
+} XmlState;
+
+class ZYppUpdater : public Updater, public QXmlDefaultHandler
+{
+Q_OBJECT
+ public:
+
+ ZYppUpdater( QObject *parent, const char* name, const QStringList&);
+ virtual ~ZYppUpdater() {};
+
+ virtual UpdaterCapabilities capabilities();
+ virtual void shutdown();
+
+ // QXmlDefaultHandler implementation
+ virtual bool startDocument();
+ virtual bool endDocument();
+ virtual bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& );
+ virtual bool endElement( const QString&, const QString&, const QString& );
+ virtual bool characters ( const QString & ch );
+ private slots:
+
+ /**
+ Slot which gets called when we need to throw up the add/remove server dialog.
+ */
+ void configureUpdater();
+
+ /**
+ Slot which gets called when we need to start an update.
+ Collect our update info from the list we got passed
+ in populateList and go.
+ */
+ void startInstall();
+
+ /**
+ Slot which gets called when we need to check for updates
+ and load up the list.
+
+ @param updateList the list on the main window
+ */
+ void populateLists(QListView* patchList, QListView* packageList);
+
+ /**
+ Slot which gets called when the user selects an update.
+ We are expected to write a description of the update and pass it back.
+
+ @param item the update itself
+
+ */
+ void resolvableSelected(QListViewItem* item, int);
+
+ /**
+ Slot which gets called when the user right clicks an update.
+
+ @param updateItem the update itself.
+ @param point where to show the menu
+ */
+ void updateMenu(QListViewItem* item, const QPoint& point);
+
+ /**
+ Slot which gets called 1 minute after CheckForUpdates
+ has detected "network connection being established"
+ */
+ void slotCheckAgainForUpdates();
+
+
+ protected slots:
+
+ void slotYOUProcessExited( KProcess * );
+ void slotInstSourceProcessExited( KProcess * );
+
+ void showLog();
+ void slotProcessExited( KProcess *proc );
+ void slotReceivedStdout(KProcess *proc, char *buffer, int buflen);
+ void slotReceivedStderr(KProcess *proc, char *buffer, int buflen);
+
+ private:
+
+ int getNetworkStatus() const;
+
+ void doCheckForUpdates();
+
+ KProcess *_process;
+ QString _buffer;
+
+ QString _stderr_buffer;
+ QString _error_message_buffer;
+
+ KProcess *_you_process;
+
+ // parsed data, cleared between calls
+ // to checkpatches
+ QPtrList<ZYppResolvable> _patches;
+ QValueList<ZYppSource> _sources;
+
+ ZYppSource _current_source;
+
+ XmlState _state;
+
+ //We hold the QListView passed in "populateUpdateList" here
+ QListView *tempList;
+ //This holds the currently selected update in the list
+ QListViewItem *currentUpdate;
+ //Holds the descript for the currently selected update
+
+ ZYppResolvable *_current_resolvable;
+
+ int _update_counter;
+
+ QListView *_patchList;
+ QListView *_packageList;
+ bool _found_update_status_tag;
+ bool _end_document_reached;
+ bool _error;
+};
+
+#endif
+
Added: trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.cpp?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.cpp (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.cpp Tue Jul 17 16:25:26 2007
@@ -0,0 +1,61 @@
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include "zyppupdaterpreferences_base.h"
+
+typedef KGenericFactory<ZYppUpdaterPreferencesModule> ZYppUpdaterPreferencesModuleFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kopete_latex, ZYppUpdaterPreferencesModuleFactory( "kcm_opensuseupdater_zypp" ) )
+
+ZYppUpdaterPreferencesModule::ZYppUpdaterPreferencesModule(QWidget *parent, const QStringList &args)
+ : KCModule(ZYppUpdaterPreferencesModuleFactory::componentData(), parent, args)
+{
+ QVBoxLayout* l = new QVBoxLayout( this );
+ QWidget* w = new QWidget;
+ m_preferencesWidget = new ZYppUpdaterPreferences_Base;
+ m_preferencesWidget->setupUi( w );
+ l->addWidget( w );
+
+ // connect widget signals here
+ m_preferencesWidget->horizontalDPI->setMinimum(1);
+ m_preferencesWidget->verticalDPI->setMinimum(1);
+
+ connect(m_preferencesWidget->horizontalDPI, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
+ connect(m_preferencesWidget->verticalDPI, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
+
+ load();
+}
+
+ZYppUpdaterPreferencesModule::~ZYppUpdaterPreferencesModule()
+{
+ delete m_preferencesWidget;
+}
+
+void ZYppUpdaterPreferencesModule::load()
+{
+ //LatexConfig::self()->readConfig();
+ // load widgets here
+ //m_preferencesWidget->horizontalDPI->setValue(LatexConfig::self()->horizontalDPI());
+ //m_preferencesWidget->verticalDPI->setValue(LatexConfig::self()->verticalDPI());
+ emit KCModule::changed(false);
+}
+
+void ZYppUpdaterPreferencesModule::slotModified()
+{
+ emit KCModule::changed(true);
+}
+
+void ZYppUpdaterPreferencesModule::save()
+{
+ //LatexConfig::self()->setHorizontalDPI(m_preferencesWidget->horizontalDPI->value());
+ //LatexConfig::self()->setVerticalDPI(m_preferencesWidget->verticalDPI->value());
+ //LatexConfig::self()->writeConfig();
+ emit KCModule::changed(false);
+}
+
+#include "ZYppUpdaterPreferencesModule.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
Added: trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.h?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.h (added)
+++ trunk/updater-kde/updater/zypp_traditional/ZYppUpdaterPreferencesModule.h Tue Jul 17 16:25:26 2007
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2007 by Duncan Mac-Vicar Prett
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef ZYppUpdaterPreferencesModule_H
+#define ZYppUpdaterPreferencesModule_H
+
+#include
+#include
+
+class ZYppUpdaterPreferences_Base;
+
+/**
+ *@author Duncan Mac-Vicar Prett
+ */
+
+class ZYppUpdaterPreferencesModule : public KCModule
+{
+ Q_OBJECT
+public:
+
+ ZYppUpdaterPreferencesModule(QWidget *parent = 0, const QStringList &args = QStringList());
+ ~ZYppUpdaterPreferencesModule();
+
+ virtual void save();
+ virtual void load();
+
+private:
+ ZYppUpdaterPreferences_Base *m_preferencesWidget;
+private slots:
+ void slotModified();
+};
+
+#endif
\ No newline at end of file
Added: trunk/updater-kde/updater/zypp_traditional/opensuseupdater_zypp_traditional.desktop
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/opensuseupdater_zypp_traditional.desktop?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/opensuseupdater_zypp_traditional.desktop (added)
+++ trunk/updater-kde/updater/zypp_traditional/opensuseupdater_zypp_traditional.desktop Tue Jul 17 16:25:26 2007
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=zypp_backend_traditional
+Comment=traditional ZYpp Backend
+ServiceTypes=openSUSEUpdater/Backend
+Type=Service
+X-KDE-Library=opensuseupdater_zypp_traditional
Added: trunk/updater-kde/updater/zypp_traditional/zyppupdaterpreferences_base.ui
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/updater-kde/updater/zypp_traditional/zyppupdaterpreferences_base.ui?rev=6050&view=auto
==============================================================================
--- trunk/updater-kde/updater/zypp_traditional/zyppupdaterpreferences_base.ui (added)
+++ trunk/updater-kde/updater/zypp_traditional/zyppupdaterpreferences_base.ui Tue Jul 17 16:25:26 2007
@@ -0,0 +1,71 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ZYppUpdaterPreferences_Base</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ZYppUpdaterPreferences_Base</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>109</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QDial">
+ <property name="name">
+ <cstring>kcfg_Priority</cstring>
+ </property>
+ <property name="minValue">
+ <number>-20</number>
+ </property>
+ <property name="maxValue">
+ <number>19</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Update checking process priority</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org