package install callback impl
authorStanislav Visnovsky <visnov@suse.cz>
Thu, 2 Feb 2006 11:22:04 +0000 (11:22 +0000)
committerStanislav Visnovsky <visnov@suse.cz>
Thu, 2 Feb 2006 11:22:04 +0000 (11:22 +0000)
zypp/Callback.h
zypp/Makefile.am
zypp/ZYppCallbacks.h
zypp/target/Makefile.am
zypp/target/TargetImpl.cc
zypp/target/rpm/RpmDb.cc
zypp/target/rpm/RpmDb.h

index 08abe76..ef23a17 100644 (file)
@@ -181,7 +181,7 @@ namespace zypp
          }
 
          Receiver * getReceiver() const
-         { return _receiver == &_noReceiver ? NULL : _receiver; }
+         { return _receiver == &_noReceiver ? 0 : _receiver; }
 
          void setReceiver( Receiver & rec_r )
          { _receiver = &rec_r; }
index a4d1089..285f28e 100644 (file)
@@ -73,7 +73,8 @@ pkginclude_HEADERS = NeedAType.h \
        UpgradeStatistics.h     \
        ZYpp.h          \
        TranslatedText.h \
-       ZYppFactory.h
+       ZYppFactory.h   \
+       ZYppCallbacks.h
 
 ## ##################################################
 
index f41bd59..1c3e6f6 100644 (file)
@@ -33,6 +33,7 @@ namespace zypp
       }; 
       
       enum Error {
+       NO_ERROR,
         NOT_FOUND,     // the requested Url was not found
        IO,             // IO error
        INVALID         // the downloaded file is invalid
@@ -70,6 +71,7 @@ namespace zypp
       }; 
       
       enum Error {
+       NO_ERROR,
         NOT_FOUND,     // the requested Url was not found
        IO,             // IO error
        INVALID         // the downloaded file is invalid
@@ -104,6 +106,7 @@ namespace zypp
       }; 
       
       enum Error {
+       NO_ERROR,
         NOT_FOUND,     // the requested Url was not found
        IO,             // IO error
        INVALID         // th source is invalid
@@ -138,6 +141,7 @@ namespace zypp
       }; 
       
       enum Error {
+       NO_ERROR,
         NOT_FOUND,     // the requested Url was not found
        IO,             // IO error
        INVALID         // th source is invalid
@@ -180,6 +184,7 @@ namespace zypp
       }; 
 
       enum Error { 
+       NO_ERROR,
         NOT_FOUND,  // the medie not found at all
         IO,    // error accessing the media
        INVALID, // media is broken
@@ -216,26 +221,27 @@ namespace zypp
         }; 
       
         enum Error {
+         NO_ERROR,
           NOT_FOUND,   // the requested Url was not found
          IO,           // IO error
          INVALID               // th resolvable is invalid
         };
       
         virtual void start(
-         Resolvable::Ptr resolvable
+         Resolvable::constPtr resolvable
         ) {}
 
-        virtual bool progress(int value, Resolvable::Ptr resolvable) 
+        virtual bool progress(int value, Resolvable::constPtr resolvable) 
         { return false; }
 
         virtual Action problem(
-          Resolvable::Ptr resolvable
+          Resolvable::constPtr resolvable
          , Error error
         , TranslatedText description
         ) { return ABORT; }
 
         virtual void finish(
-          Resolvable::Ptr resolvable
+          Resolvable::constPtr resolvable
           , Error error
          , TranslatedText reason
         ) {}
@@ -251,6 +257,7 @@ namespace zypp
         }; 
       
         enum Error {
+         NO_ERROR,
           NOT_FOUND,   // the requested Url was not found
          IO,           // IO error
          INVALID               // th resolvable is invalid
@@ -286,6 +293,7 @@ namespace zypp
         }; 
       
         enum Error {
+         NO_ERROR,
           NOT_FOUND,   // the requested Url was not found
          IO,           // IO error
          INVALID               // th resolvable is invalid
@@ -321,6 +329,7 @@ namespace zypp
         }; 
       
         enum Error {
+         NO_ERROR,
           NOT_FOUND,   // the requested Url was not found
          IO,           // IO error
          INVALID               // th resolvable is invalid
index c25bc7d..60f9428 100644 (file)
@@ -8,7 +8,8 @@ SUBDIRS = hal rpm store
 targetincludedir = $(pkgincludedir)/target
 
 targetinclude_HEADERS =                        \
-       TargetImpl.h
+       TargetImpl.h                    \
+       TargetCallbackReceiver.h
 
 ## ##################################################
 
@@ -17,7 +18,8 @@ noinst_LTLIBRARIES =  lib@PACKAGE@_target.la
 ## ##################################################
 
 lib@PACKAGE@_target_la_SOURCES =       \
-       TargetImpl.cc
+       TargetImpl.cc                   \
+       TargetCallbackReceiver.cc
 
 lib@PACKAGE@_target_la_LDFLAGS = @LIBZYPP_VERSION_INFO@
 
index daa9cee..b12f5b9 100644 (file)
@@ -13,6 +13,7 @@
 #include "zypp/base/Logger.h"
 
 #include "zypp/target/TargetImpl.h"
+#include "zypp/target/TargetCallbackReceiver.h"
 
 #include "zypp/solver/detail/Types.h"
 #include "zypp/solver/detail/InstallOrder.h"
@@ -119,8 +120,17 @@ namespace zypp
          Package::constPtr p = dynamic_pointer_cast<const Package>(it->resolvable());
          if (it->status().isToBeInstalled())
          {
+#warning Exception handling
+           // create a progress report proxy
+           RpmInstallPackageReceiver progress(it->resolvable());
+           
+           progress.connect();
+
            rpm().installPackage(p->getPlainRpm(),
              p->installOnly() ? rpm::RpmDb::RPMINST_NOUPGRADE : 0);
+             
+           progress.disconnect();
+
          }
          else
          {
index 3ff321e..9f045f2 100644 (file)
@@ -1668,25 +1668,29 @@ void RpmDb::processConfigFiles(const string& line, const string& name, const cha
 //
 void RpmDb::installPackage( const Pathname & filename, unsigned flags )
 {
-  RpmInstallReport report;
+  callback::SendReport<RpmInstallReport> report;
+
+  report->start(filename);
+
   try {
     doInstallPackage(filename, flags, report);
   }
   catch (RpmException & excpt_r)
   {
-    report.end(excpt_r);
+    report->end(/*excpt_r*/);
     ZYPP_RETHROW(excpt_r);
   }
-  report.end();
+  report->end();
 
 }
-void RpmDb::doInstallPackage( const Pathname & filename, unsigned flags, RpmInstallReport & report )
+void RpmDb::doInstallPackage( const Pathname & filename, unsigned flags, callback::SendReport<RpmInstallReport> & report )
 {
     FAILIFNOTINITIALIZED;
     Logfile progresslog;
 
     MIL << "RpmDb::installPackage(" << filename << "," << flags << ")" << endl;
 
+
     // backup
     if ( _packagebackups ) {
 // FIXME      report->progress( pd.init( -2, 100 ) ); // allow 1% for backup creation.
@@ -1694,9 +1698,9 @@ void RpmDb::doInstallPackage( const Pathname & filename, unsigned flags, RpmInst
        ERR << "backup of " << filename.asString() << " failed" << endl;
       }
 // FIXME status handling
-      report.progress( 0 ); // allow 1% for backup creation.
+      report->progress( 0 ); // allow 1% for backup creation.
     } else {
-      report.progress( 100 );
+      report->progress( 100 );
     }
 
     // run rpm
@@ -1741,7 +1745,7 @@ void RpmDb::doInstallPackage( const Pathname & filename, unsigned flags, RpmInst
        {
            int percent;
            sscanf (line.c_str () + 2, "%d", &percent);
-           report.progress( percent );
+           report->progress( percent );
        }
        else
            rpmmsg += line+'\n';
index 0bb1e0f..5c5ea8a 100644 (file)
@@ -539,7 +539,7 @@ namespace zypp {
 
        protected:
          void doRemovePackage( const std::string & name_r, unsigned flags, RpmRemoveReport & report );
-         void doInstallPackage( const Pathname & filename, unsigned flags, RpmInstallReport & report );
+         void doInstallPackage( const Pathname & filename, unsigned flags, callback::SendReport<RpmInstallReport> & report );
          const std::list<Package::Ptr> & doGetPackages(ScanDbReport & report);
          void doRebuildDatabase(RebuildDbReport & report);