[yast-commit] r52217 - in /trunk/pkg-bindings: package/yast2-pkg-bindings.changes src/Callbacks.cc src/Callbacks.h src/Package.cc src/PkgFunctions.cc src/PkgFunctions.h
Author: lslezak Date: Wed Oct 15 11:01:05 2008 New Revision: 52217 URL: http://svn.opensuse.org/viewcvs/yast?rev=52217&view=rev Log: - report SourceChanged callback also during package installation (bnc#362003) Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes trunk/pkg-bindings/src/Callbacks.cc trunk/pkg-bindings/src/Callbacks.h trunk/pkg-bindings/src/Package.cc trunk/pkg-bindings/src/PkgFunctions.cc trunk/pkg-bindings/src/PkgFunctions.h Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Oct 15 11:01:05 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Oct 15 10:56:06 CEST 2008 - lslezak@suse.cz + +- report SourceChanged callback also during package installation + (bnc#362003) + +------------------------------------------------------------------- Thu Oct 9 15:25:52 CEST 2008 - lslezak@suse.cz - do not print anything on the stdout when detecting network Modified: trunk/pkg-bindings/src/Callbacks.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Callbacks.cc?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/src/Callbacks.cc (original) +++ trunk/pkg-bindings/src/Callbacks.cc Wed Oct 15 11:01:05 2008 @@ -256,10 +256,11 @@ struct InstallPkgReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::target::rpm::InstallResolvableReport> { zypp::Resolvable::constPtr _last; + PkgFunctions &_pkg_ref; int last_reported; time_t last_reported_time; - InstallPkgReceive(RecipientCtl & construct_r) : Recipient(construct_r) + InstallPkgReceive(RecipientCtl & construct_r, PkgFunctions &pk) : Recipient(construct_r), _last(NULL), _pkg_ref(pk) { } @@ -285,6 +286,22 @@ if( _last == resolvable ) return; + // convert the repo ID + PkgFunctions::RepoId source_id = _pkg_ref.logFindAlias(res->repoInfo().alias()); + int media_nr = res->mediaNr(); + + if( source_id != _pkg_ref.LastReportedRepo() || media_nr != _pkg_ref.LastReportedMedium()) + { + CB callback( ycpcb( YCPCallbacks::CB_SourceChange ) ); + if (callback._set) { + callback.addInt( source_id ); + callback.addInt( media_nr ); + callback.evaluate(); + } + + _pkg_ref.SetReportedSource(source_id, media_nr); + } + CB callback( ycpcb( YCPCallbacks::CB_StartPackage ) ); if (callback._set) { callback.addStr(res->location().filename()); @@ -495,11 +512,9 @@ /////////////////////////////////////////////////////////////////// struct DownloadResolvableReceive : public Recipient, public zypp::callback::ReceiveReport<zypp::repo::DownloadResolvableReport> { - static int last_source_id; - static int last_source_media; - const PkgFunctions &_pkg_ref; + PkgFunctions &_pkg_ref; - DownloadResolvableReceive( RecipientCtl & construct_r, const PkgFunctions &pk ) : Recipient( construct_r ), _pkg_ref(pk) {} + DownloadResolvableReceive( RecipientCtl & construct_r, PkgFunctions &pk ) : Recipient( construct_r ), _pkg_ref(pk) {} int last_reported; time_t last_reported_time; @@ -534,10 +549,10 @@ size = pkg->downloadSize(); // convert the repo ID - long long source_id = _pkg_ref.logFindAlias(pkg->repoInfo().alias()); + PkgFunctions::RepoId source_id = _pkg_ref.logFindAlias(pkg->repoInfo().alias()); int media_nr = pkg->mediaNr(); - if( source_id != last_source_id || media_nr != last_source_media ) + if( source_id != _pkg_ref.LastReportedRepo() || media_nr != _pkg_ref.LastReportedMedium()) { CB callback( ycpcb( YCPCallbacks::CB_SourceChange ) ); if (callback._set) { @@ -545,8 +560,7 @@ callback.addInt( media_nr ); callback.evaluate(); } - last_source_id = source_id; - last_source_media = media_nr; + _pkg_ref.SetReportedSource(source_id, media_nr); } } @@ -783,10 +797,6 @@ }; - int DownloadResolvableReceive::last_source_id = -1; - int DownloadResolvableReceive::last_source_media = -1; - - /////////////////////////////////////////////////////////////////// // DownloadProgressReceive /////////////////////////////////////////////////////////////////// @@ -1833,12 +1843,12 @@ public: - ZyppReceive( const YCPCallbacks & ycpcb_r, const PkgFunctions &pkg) + ZyppReceive( const YCPCallbacks & ycpcb_r, PkgFunctions &pkg) : RecipientCtl( ycpcb_r ) , _convertDbReceive( *this ) , _rebuildDbReceive( *this ) , _scanDbReceive( *this ) - , _installPkgReceive( *this ) + , _installPkgReceive( *this, pkg ) , _removePkgReceive( *this ) , _providePkgReceive( *this, pkg ) , _mediaChangeReceive( *this ) @@ -1913,7 +1923,7 @@ // METHOD NAME : PkgFunctions::CallbackHandler::CallbackHandler // METHOD TYPE : Constructor // -PkgFunctions::CallbackHandler::CallbackHandler(const PkgFunctions &pk) +PkgFunctions::CallbackHandler::CallbackHandler(PkgFunctions &pk) : _ycpCallbacks( *new YCPCallbacks() ) , _zyppReceive( *new ZyppReceive(_ycpCallbacks, pk) ) { Modified: trunk/pkg-bindings/src/Callbacks.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Callbacks.h?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/src/Callbacks.h (original) +++ trunk/pkg-bindings/src/Callbacks.h Wed Oct 15 11:01:05 2008 @@ -87,7 +87,7 @@ * Constructor. Setup handler and redirect Y2PMCallbacks * to the ZyppReceiver. **/ - CallbackHandler(const PkgFunctions &); + CallbackHandler(PkgFunctions &); /** * Destructor. Reset Y2PMCallbacks to it's defaults. Modified: trunk/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Package.cc?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/src/Package.cc (original) +++ trunk/pkg-bindings/src/Package.cc Wed Oct 15 11:01:05 2008 @@ -2071,6 +2071,10 @@ try { + // reset the values for SourceChanged callback + last_reported_repo = -1; + last_reported_mediumnr = 1; + zypp::ZYppCommitPolicy policy; policy.restrictToMedia( medianr ); result = zypp_ptr()->commit(policy); Modified: trunk/pkg-bindings/src/PkgFunctions.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgFunctions.cc?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/src/PkgFunctions.cc (original) +++ trunk/pkg-bindings/src/PkgFunctions.cc Wed Oct 15 11:01:05 2008 @@ -259,3 +259,18 @@ return ret; } +PkgFunctions::RepoId PkgFunctions::LastReportedRepo() const +{ + return last_reported_repo; +} + +int PkgFunctions::LastReportedMedium() const +{ + return last_reported_mediumnr; +} + +void PkgFunctions::SetReportedSource(RepoId repo, int medium) +{ + last_reported_repo = repo; + last_reported_mediumnr = medium; +} Modified: trunk/pkg-bindings/src/PkgFunctions.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgFunctions.h?rev=52217&r1=52216&r2=52217&view=diff ============================================================================== --- trunk/pkg-bindings/src/PkgFunctions.h (original) +++ trunk/pkg-bindings/src/PkgFunctions.h Wed Oct 15 11:01:05 2008 @@ -95,10 +95,12 @@ // container for the internal structure typedef std::vector<YRepo_Ptr> RepoCont; + + public: + // ID type typedef RepoCont::size_type RepoId; - private: // source related // all known installation sources @@ -110,6 +112,9 @@ // flag for skipping autorefresh volatile bool autorefresh_skipped; + RepoId last_reported_repo; + int last_reported_mediumnr; + YCPValue SourceRefreshHelper(const YCPInteger &id, bool forced = false); // helper - is the network running? @@ -811,5 +816,8 @@ // must be public, used in callbacks RepoId logFindAlias(const std::string &alias) const; + RepoId LastReportedRepo() const; + int LastReportedMedium() const; + void SetReportedSource(RepoId repo, int medium); }; #endif // PkgFunctions_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org