Author: tgoettlicher
Date: Thu Apr 26 15:20:44 2007
New Revision: 5454
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5454&view=rev
Log:
Dummy plugin added for testing different backends.
Added:
branches/work/updater-kde-refactoring/updater-kde/updater/dummy/
branches/work/updater-kde-refactoring/updater-kde/updater/dummy/CMakeLists.txt
branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp
branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.h
branches/work/updater-kde-refactoring/updater-kde/updater/dummy/opensuseupdater_dummy.desktop
Modified:
branches/work/updater-kde-refactoring/updater-kde/updater/CMakeLists.txt
branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp
branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp
Modified: branches/work/updater-kde-refactoring/updater-kde/updater/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/CMakeLists.txt?rev=5454&r1=5453&r2=5454&view=diff
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/CMakeLists.txt (original)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/CMakeLists.txt Thu Apr 26 15:20:44 2007
@@ -1,5 +1,6 @@
#ADD_SUBDIRECTORY( zmd )
ADD_SUBDIRECTORY( zypp )
+ADD_SUBDIRECTORY( dummy )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/kxmlrpcclient ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} )
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=5454&r1=5453&r2=5454&view=diff
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp (original)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp Thu Apr 26 15:20:44 2007
@@ -76,41 +76,45 @@
KService::Ptr service = *iter;
kdDebug() << "Found plugin: " << service->name() << endl;
- int errCode = 0;
- Updater* plugin = KParts::ComponentFactory::createInstanceFromService<Updater> ( service, 0, 0, QStringList(), &errCode);
-
- // only ZYpp backend supported till now
- if (plugin && errCode == 0 && service->name() == "ZYpp backend") {
- _updater = plugin;
- kdDebug() << "Loaded plugin " << service->name() << endl;
- }
- else
+ if (service->name() == "ZYpp backend")
+// if (service->name() == "Dummy backend")
{
- switch (errCode)
+ int errCode = 0;
+ Updater* plugin = KParts::ComponentFactory::createInstanceFromService<Updater> ( service, 0, 0, QStringList(), &errCode);
+
+ if (plugin && errCode == 0 )
+ {
+ _updater = plugin;
+ kdDebug() << "Loaded plugin " << service->name() << endl;
+ }
+ else
{
- case KParts::ComponentFactory::ErrNoServiceFound :
- kdDebug() << "Unable to load plugin. ErrNoServiceFound" << endl;
- break;
-
- case KParts::ComponentFactory::ErrServiceProvidesNoLibrary :
- kdDebug() << "Unable to load plugin. ErrServiceProvidesNoLibrary" << endl;
- break;
-
- case KParts::ComponentFactory::ErrNoLibrary :
- kdDebug() << "Unable to load plugin. ErrNoLibrary: " << KLibLoader::self()->lastErrorMessage() << endl;
- break;
-
- case KParts::ComponentFactory::ErrNoFactory :
- kdDebug() << "Unable to load plugin. ErrNoFactory" << endl;
- break;
-
- case KParts::ComponentFactory::ErrNoComponent :
- kdDebug() << "Unable to load plugin. ErrNoComponent" << endl;
- break;
-
- default:
- kdDebug() << "Unable to load plugin. Unknown Error" << errCode << endl;
- break;
+ switch (errCode)
+ {
+ case KParts::ComponentFactory::ErrNoServiceFound :
+ kdDebug() << "Unable to load plugin. ErrNoServiceFound" << endl;
+ break;
+
+ case KParts::ComponentFactory::ErrServiceProvidesNoLibrary :
+ kdDebug() << "Unable to load plugin. ErrServiceProvidesNoLibrary" << endl;
+ break;
+
+ case KParts::ComponentFactory::ErrNoLibrary :
+ kdDebug() << "Unable to load plugin. ErrNoLibrary: " << KLibLoader::self()->lastErrorMessage() << endl;
+ break;
+
+ case KParts::ComponentFactory::ErrNoFactory :
+ kdDebug() << "Unable to load plugin. ErrNoFactory" << endl;
+ break;
+
+ case KParts::ComponentFactory::ErrNoComponent :
+ kdDebug() << "Unable to load plugin. ErrNoComponent" << endl;
+ break;
+
+ default:
+ kdDebug() << "Unable to load plugin. Unknown Error" << errCode << endl;
+ break;
+ }
}
}
}
Added: branches/work/updater-kde-refactoring/updater-kde/updater/dummy/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/dummy/CMakeLists.txt?rev=5454&view=auto
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/dummy/CMakeLists.txt (added)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/dummy/CMakeLists.txt Thu Apr 26 15:20:44 2007
@@ -0,0 +1,18 @@
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/updater ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} )
+
+
+########### next target ###############
+
+SET(opensuseupdater_dummy_PART_SRCS
+DummyUpdater.cpp
+)
+
+KDE3_AUTOMOC(${opensuseupdater_dummy_PART_SRCS})
+KDE3_ADD_KPART(opensuseupdater_dummy ${opensuseupdater_dummy_PART_SRCS})
+TARGET_LINK_LIBRARIES(opensuseupdater_dummy ${QT_AND_KDECORE_LIBS} opensuseupdater )
+INSTALL_TARGETS(/lib/kde3 opensuseupdater_dummy )
+
+########### install files ###############
+
+INSTALL_FILES( /share/services FILES opensuseupdater_dummy.desktop )
+
Added: branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp?rev=5454&view=auto
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp (added)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp Thu Apr 26 15:20:44 2007
@@ -0,0 +1,194 @@
+/*
+ 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
+#include
+
+#include "DummyUpdater.h"
+#include "MainWindow.h"
+
+
+K_EXPORT_COMPONENT_FACTORY( opensuseupdater_dummy, KGenericFactory<DummyUpdater>( "opensuseupdater_dummy" ) )
+
+DummyUpdater::DummyUpdater( QObject *parent, const char* name, const QStringList& ) : Updater( parent, name )
+ , _process(0L)
+ , _you_process(0L)
+ , _update_counter(0)
+ , _list_view(0)
+ , _found_update_status_tag(false)
+ , _end_document_reached(false)
+ , _error(false)
+{
+
+ // For ease announce that we have been loaded.
+ kdDebug() << "DummyUpdater plugin loaded" << endl;
+
+ kdDebug() << "Initializing dummy backend" << endl;
+ doCheckForUpdates();
+}
+
+UpdaterCapabilities DummyUpdater::capabilities()
+{
+ UpdaterCapabilities caps;
+ caps.canSelectIndividualUpdates = false;
+ return caps;
+}
+
+void DummyUpdater::slotYOUProcessExited( KProcess *p )
+{
+ delete p;
+ _you_process = 0L;
+ doCheckForUpdates();
+}
+
+
+void DummyUpdater::slotInstSourceProcessExited( KProcess *p )
+{
+ delete p;
+}
+
+
+
+void DummyUpdater::showLog()
+{
+}
+
+void DummyUpdater::slotCheckDone()
+{
+
+
+ if (!_list_view)
+ return;
+
+ // Since this is a dummy backend we have no real updates
+ // We will construct an example patch
+
+ int patchcount=1;
+
+ QListViewItem *newItem;
+ newItem = new QListViewItem(_list_view);
+
+ newItem->setText(COLUMN_NAME, "Dummy-Program: Fixes nothing since this is an example");
+ newItem->setText(COLUMN_TYPE, "Dummy-Patch");
+ newItem->setText(COLUMN_NEW_VERSION, "42" );
+ newItem->setText(COLUMN_CATALOG, "Dummy-Source" );
+
+ if ( patchcount > 0 )
+ {
+ emit(updateApplet(APPLET_UPDATES, patchcount));
+ emit(installAllowed(true));
+ }
+ else
+ {
+ emit(updateApplet(APPLET_NO_UPDATES, 0));
+ emit(installAllowed(false));
+ }
+
+ if ( _error )
+ {
+ emit(updateAppletError(_error_message_buffer));
+ _error_message_buffer.truncate(0);
+ }
+
+ _list_view = 0L;
+ emit(populateDone());
+}
+
+void DummyUpdater::shutdown()
+{
+}
+
+void DummyUpdater::doCheckForUpdates(bool lastattempt)
+{
+ kdDebug() << "Starting check for updates ..." << endl;
+
+ emit(updateApplet(APPLET_CHECKING, 0));
+
+ // We don't realy check for updates since this is a
+ // dummy backend. We only wait 10 seconds.
+ QTimer::singleShot( 10*1000, this, SLOT(slotCheckDone()));
+
+}
+
+void DummyUpdater::populateUpdateList(QListView *updateList)
+{
+ kdDebug() << "got populate UI request..." << endl;
+ _list_view = updateList;
+ emit(updateApplet(APPLET_NO_UPDATES, 0));
+ doCheckForUpdates();
+}
+
+void DummyUpdater::updateSelected(QListViewItem *item)
+{
+}
+
+void DummyUpdater::updateMenu(QListViewItem *item, const QPoint& point)
+{
+}
+
+void DummyUpdater::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 DummyUpdater::configureUpdater()
+{
+ 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 );
+}
+
+#include "DummyUpdater.moc"
+
Added: branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.h?rev=5454&view=auto
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.h (added)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.h Thu Apr 26 15:20:44 2007
@@ -0,0 +1,136 @@
+/*
+ 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 _DUMMY_UPDATER_H_
+#define _DUMMY_UPDATER_H_
+
+#include "Updater.h"
+#include
+#include
+
+/**
+ @file
+
+ This file defines a dummy backend
+
+ @author Martin Vidner
+ @author Duncan Mac-Vicar
+ @author Thomas Goettlicher
+*/
+
+class KDE_EXPORT DummyUpdater : public Updater, public QXmlDefaultHandler
+{
+Q_OBJECT
+ public:
+
+ DummyUpdater( QObject *parent, const char* name, const QStringList&);
+ virtual ~DummyUpdater() {};
+
+ virtual UpdaterCapabilities capabilities();
+ virtual void shutdown();
+
+ 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 populateUpdateList(QListView* updateList);
+
+ /**
+ 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 updateSelected(QListViewItem* item);
+
+ /**
+ 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();
+
+
+ void slotCheckDone();
+
+
+ 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(bool lastattempt=false);
+
+ KProcess *_process;
+ QString _buffer;
+
+ QString _stderr_buffer;
+ QString _error_message_buffer;
+
+ KProcess *_you_process;
+
+ //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
+
+ int _update_counter;
+
+ QListView *_list_view;
+ bool _found_update_status_tag;
+ bool _end_document_reached;
+ bool _error;
+};
+
+#endif
+
Added: branches/work/updater-kde-refactoring/updater-kde/updater/dummy/opensuseupdater_dummy.desktop
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/dummy/opensuseupdater_dummy.desktop?rev=5454&view=auto
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/dummy/opensuseupdater_dummy.desktop (added)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/dummy/opensuseupdater_dummy.desktop Thu Apr 26 15:20:44 2007
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=Dummy backend
+Comment=Dummy backend for openSUSE updater
+ServiceTypes=openSUSEUpdater/Backend
+Type=Service
+X-KDE-Library=opensuseupdater_dummy
Modified: branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp?rev=5454&r1=5453&r2=5454&view=diff
==============================================================================
--- branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp (original)
+++ branches/work/updater-kde-refactoring/updater-kde/updater/zypp/ZYppUpdater.cpp Thu Apr 26 15:20:44 2007
@@ -191,6 +191,8 @@
_buffer += QString::fromUtf8( buffer, buflen );
}
+
+
void ZYppUpdater::slotReceivedStderr(KProcess *proc, char *buffer, int buflen)
{
_stderr_buffer += QString::fromUtf8( buffer, buflen );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org