Author: lslezak Date: Mon Aug 18 15:17:41 2008 New Revision: 50180 URL: http://svn.opensuse.org/viewcvs/yast?rev=50180&view=rev Log: - ui:Selectable in Pkg::FilterPackages() and Pkg::GetPackages() Modified: branches/tmp/lslezak/pkg-bindings/src/Package.cc Modified: branches/tmp/lslezak/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/pkg-bindings/src/Package.cc?rev=50180&r1=50179&r2=50180&view=diff ============================================================================== --- branches/tmp/lslezak/pkg-bindings/src/Package.cc (original) +++ branches/tmp/lslezak/pkg-bindings/src/Package.cc Mon Aug 18 15:17:41 2008 @@ -1417,21 +1417,27 @@ /* helper function */ static void -pkg2list (YCPList &list, const zypp::ResPool::byKind_iterator& it, bool names_only) +pkg2list (YCPList &list, const zypp::PoolItem &item, bool names_only) { + zypp::Package::constPtr pkg = zypp::dynamic_pointer_cast<const zypp::Package>(item.resolvable()); + + if (!pkg) + { + return; + } + if (names_only) { - list->add(YCPString((*it)->name())); + list->add(YCPString(pkg->name())); } else { - string fullname = (*it)->name(); - fullname += (" " + (*it)->edition().version()); - fullname += (" " + (*it)->edition().release()); - fullname += (" " + (*it)->arch().asString()); + string fullname = pkg->name(); + fullname += (" " + pkg->edition().version()); + fullname += (" " + pkg->edition().release()); + fullname += (" " + pkg->arch().asString()); list->add (YCPString (fullname)); } - return; } @@ -1463,20 +1469,26 @@ try { - for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(zypp::ResKind::package); - it != zypp_ptr()->pool().byKindEnd(zypp::ResKind::package); - ++it) - { - // check status and causer - if (it->status().isToBeInstalled() && - ((byAuto && it->status().isBySolver()) || -#warning FilterPackages: APPL_LOW and APPL_HIGH are treated as one level for now - (byApp && (it->status().isByApplHigh() || it->status().isByApplLow())) || - (byUser && it->status().isByUser()) - )) + // access to the Pool of Selectables + zypp::ResPoolProxy selectablePool(zypp::ResPool::instance().proxy()); + + for_(it, selectablePool.byKindBeginzypp::Package(), + selectablePool.byKindEndzypp::Package()) + { + zypp::ui::Selectable::Ptr s = (*it); + + if (s && s->fate() == zypp::ui::Selectable::TO_INSTALL) + { + zypp::ResStatus::TransactByValue by = s->modifiedBy(); + + if ((byAuto && by == zypp::ResStatus::SOLVER) || + (byApp && (by == zypp::ResStatus::APPL_HIGH || by == zypp::ResStatus::APPL_LOW)) || + (byUser && by == zypp::ResStatus::USER) + ) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->candidateObj(), names_only); } + } } } catch (...) @@ -1514,50 +1526,56 @@ try { - for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(zypp::ResKind::package); - it != zypp_ptr()->pool().byKindEnd(zypp::ResKind::package); - ++it) + // access to the Pool of Selectables + zypp::ResPoolProxy selectablePool(zypp::ResPool::instance().proxy()); + + for_(it, selectablePool.byKindBeginzypp::Package(), + selectablePool.byKindEndzypp::Package()) { + zypp::ui::Selectable::Ptr s = (*it); + + if (!s) continue; + if (which == "installed") { - if (it->status().isInstalled()) + if (s->hasInstalledObj()) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->installedObj(), names_only); } } else if (which == "selected") { - if (it->status().isToBeInstalled()) + if (s->fate() == zypp::ui::Selectable::TO_INSTALL && s->hasCandidateObj()) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->candidateObj(), names_only); } } else if (which == "removed") { - if (it->status().isToBeUninstalled()) + if (s->fate() == zypp::ui::Selectable::TO_DELETE && s->hasInstalledObj()) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->installedObj(), names_only); } } else if (which == "available") { - if (!it->status().isInstalled()) + if (s->hasCandidateObj()) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->candidateObj(), names_only); } } else if (which == "locked") { - if (it->status().isLocked() && it->status().isInstalled()) + if (s->status() == zypp::ui::S_Protected) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->installedObj(), names_only); } } else if (which == "taboo") { - if (it->status().isLocked() && !it->status().isInstalled()) + if (s->status() == zypp::ui::S_Taboo) { - pkg2list(packages, it, names_only); + pkg2list(packages, s->candidateObj(), names_only); } } else -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org