Author: jkupec Date: Tue Jul 10 11:33:55 2007 New Revision: 39269 URL: http://svn.opensuse.org/viewcvs/yast?rev=39269&view=rev Log: - SourceChangeUrl reimplemented - adapted callbacks to namespace change (source->repo) Modified: branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc branches/REFACTORING-10_3/pkg-bindings/src/Source.cc Modified: branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/... ============================================================================== --- branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc (original) +++ branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc Tue Jul 10 11:33:55 2007 @@ -422,7 +422,7 @@ /////////////////////////////////////////////////////////////////// // DownloadResolvableCallback /////////////////////////////////////////////////////////////////// - struct DownloadResolvableReceive : public Recipient, public zypp::callback::ReceiveReportzypp::source::DownloadResolvableReport + struct DownloadResolvableReceive : public Recipient, public zypp::callback::ReceiveReportzypp::repo::DownloadResolvableReport { static int last_source_id; static int last_source_media; @@ -451,7 +451,7 @@ zypp::Package::constPtr pkg = zypp::asKindzypp::Package(resolvable_ptr); - size = pkg->archivesize(); + size = pkg->downloadSize(); // FIXME NID int source_id = 0;//pkg->source().numericId(); @@ -482,7 +482,7 @@ } } - virtual void finish(zypp::Resolvable::constPtr resolvable, zypp::source::DownloadResolvableReport::Error error, const std::string &reason) + virtual void finish(zypp::Resolvable::constPtr resolvable, zypp::repo::DownloadResolvableReport::Error error, const std::string &reason) { CB callback( ycpcb( YCPCallbacks::CB_DoneProvide) ); if (callback._set) { @@ -503,10 +503,10 @@ return callback.evaluateBool(); // return value ignored by RpmDb } - return zypp::source::DownloadResolvableReport::progress(value, resolvable_ptr); + return zypp::repo::DownloadResolvableReport::progress(value, resolvable_ptr); } - virtual Action problem(zypp::Resolvable::constPtr resolvable_ptr, zypp::source::DownloadResolvableReport::Error error, const std::string &description) + virtual Action problem(zypp::Resolvable::constPtr resolvable_ptr, zypp::repo::DownloadResolvableReport::Error error, const std::string &description) { CB callback( ycpcb( YCPCallbacks::CB_DoneProvide) ); if (callback._set) { @@ -516,19 +516,19 @@ std::string ret = callback.evaluateStr(); // "R" = retry - if (ret == "R") return zypp::source::DownloadResolvableReport::RETRY; + if (ret == "R") return zypp::repo::DownloadResolvableReport::RETRY; // "C" = cancel - if (ret == "C") return zypp::source::DownloadResolvableReport::ABORT; + if (ret == "C") return zypp::repo::DownloadResolvableReport::ABORT; // "I" = ignore - if (ret == "I") return zypp::source::DownloadResolvableReport::IGNORE; + if (ret == "I") return zypp::repo::DownloadResolvableReport::IGNORE; // otherwise return the default value from the parent class } // return the default value from the parent class - return zypp::source::DownloadResolvableReport::problem(resolvable_ptr, error, description); + return zypp::repo::DownloadResolvableReport::problem(resolvable_ptr, error, description); } // Download delta rpm: @@ -561,7 +561,7 @@ return callback.evaluateBool(); } - return zypp::source::DownloadResolvableReport::progressDeltaDownload(value); + return zypp::repo::DownloadResolvableReport::progressDeltaDownload(value); } virtual void problemDeltaDownload( const std::string &description ) @@ -665,7 +665,7 @@ return callback.evaluateBool(); } - return zypp::source::DownloadResolvableReport::progressPatchDownload(value); + return zypp::repo::DownloadResolvableReport::progressPatchDownload(value); } virtual void problemPatchDownload( const std::string &description ) Modified: branches/REFACTORING-10_3/pkg-bindings/src/Source.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/... ============================================================================== --- branches/REFACTORING-10_3/pkg-bindings/src/Source.cc (original) +++ branches/REFACTORING-10_3/pkg-bindings/src/Source.cc Tue Jul 10 11:33:55 2007 @@ -854,7 +854,7 @@ try { - src = logFindRepository(id->value()).info(); + src = logFindRepository(id->value()); } catch (const zypp::Exception& excpt) { @@ -910,14 +910,40 @@ return YCPBoolean(false); } - try { -#warning FIXME: SourceChangeUrl is NOT implemented -// we cannot simply change the base URL we have to create a new RepoInfo... -// src.setBaseUrl(); + try + { + if (src.baseUrlsSize() > 1) + { + // store current urls + std::setzypp::Url baseUrls; + for (std::setzypp::Url::const_iterator i = src.baseUrlsBegin(); + i != src.baseUrlsEnd(); ++i) + baseUrls.insert(*i); + + // reset url list and store the new one there + src.setBaseUrl(zypp::Url(u->value())); + + // add the rest of base urls + for (std::setzypp::Url::const_iterator i = baseUrls.begin(); + i != baseUrls.end(); ++i) + src.addBaseUrl(*i); + } + else + src.setBaseUrl(zypp::Url(u->value())); + } + catch (const zypp::Exception & excpt) + { + _last_error.setLastError(excpt.asUserString()); + y2error ("Cannot set the new URL for source %s (%lld): %s", + src.alias().c_str(), id->asInteger()->value(), excpt.msg().c_str()); + return YCPBoolean(false); + } -// zypp::RepoManager repomanager; -// repomanager.modifyRepository(src.alias(), src); + try { + zypp::RepoManager repomanager; + repomanager.modifyRepository(src.alias(), src); +#warning FIXME is MediaManager::open() needed here? /* zypp::Pathname pth = src.path(); zypp::Url url = zypp::Url(u->value ()); zypp::media::MediaManager media_mgr; @@ -928,7 +954,8 @@ catch (const zypp::Exception & excpt) { _last_error.setLastError(excpt.asUserString()); - y2error ("Cannot change media for source %lld: %s", id->asInteger()->value(), excpt.msg().c_str()); + y2error ("Cannot change media for source %s (%lld): %s", + src.alias().c_str(), id->asInteger()->value(), excpt.msg().c_str()); return YCPBoolean(false); } return YCPBoolean(true); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org