41 #define YUILogComponent "ncurses-pkg"
44 #include "NCPkgStatusStrategy.h"
50 #include <zypp/ui/Selectable.h>
51 #include <zypp/ResObject.h>
62 NCPkgStatusStrategy::NCPkgStatusStrategy()
69 NCPkgStatusStrategy::~NCPkgStatusStrategy()
84 return slbPtr->status();
88 yuiError() <<
"Selectable pointer not valid" << endl;
105 yuiError() <<
"Invalid package object" << endl;
109 ok = slbPtr->setStatus( newstatus );
111 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
112 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
126 ZyppStatus & newStat )
132 ZyppStatus retStat = S_NoInst;
134 bool installed = !slbPtr->installedEmpty();
151 if ( oldStatus == S_NoInst
152 || oldStatus == S_AutoInstall )
157 else if ( oldStatus == S_Del
158 || oldStatus == S_AutoDel)
160 retStat = S_KeepInstalled;
162 else if ( oldStatus == S_AutoUpdate )
172 if ( oldStatus == S_KeepInstalled
173 || oldStatus == S_Del
174 || oldStatus == S_AutoDel )
176 if ( slbPtr->hasCandidateObj() )
189 if ( oldStatus == S_Install
190 || oldStatus == S_AutoInstall )
194 else if ( oldStatus == S_Update
195 || oldStatus == S_AutoUpdate )
197 retStat = S_KeepInstalled;
209 retStat = S_Protected;
213 yuiDebug() <<
"Key not valid" << endl;
232 ZyppStatus & newStat )
240 ZyppStatus newStatus = oldStatus;
241 ZyppPattern patPtr = tryCastToZyppPattern (objPtr);
246 newStatus = S_KeepInstalled;
249 newStatus =S_NoInst ;
254 case S_KeepInstalled:
256 newStatus = S_Install;
258 else if ( slbPtr->hasCandidateObj() )
260 newStatus = S_Update;
268 if ( slbPtr->hasCandidateObj() || patPtr )
270 newStatus = S_Install;
274 yuiWarning() <<
"No candidate object for " << slbPtr->theObj()->name().c_str() << endl;
275 newStatus = S_NoInst;
283 newStatus = S_KeepInstalled;
286 newStatus = S_KeepInstalled;
289 newStatus = S_NoInst;
292 newStatus = S_KeepInstalled;
296 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
310 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
311 resolver->resolvePool();
323 PackageStatStrategy::PackageStatStrategy()
338 PatchStatStrategy::PatchStatStrategy()
353 ZyppStatus & newStat )
359 ZyppStatus retStat = S_NoInst;
361 bool installed = !slbPtr->installedEmpty();
377 if ( oldStatus == S_NoInst
378 || oldStatus == S_AutoInstall )
382 else if ( oldStatus == S_Del
383 || oldStatus == S_AutoDel)
385 retStat = S_KeepInstalled;
394 if ( oldStatus == S_KeepInstalled
395 || oldStatus == S_Del
396 || oldStatus == S_AutoDel )
398 if ( slbPtr->hasCandidateObj() )
409 yuiDebug() <<
"Key not valid" << endl;
419 #if EXTRA_PATCH_STRATEGY
429 ZyppStatus & newStat )
437 ZyppStatus newStatus = oldStatus;
443 newStatus =S_NoInst ;
448 newStatus = S_KeepInstalled;
450 case S_KeepInstalled:
451 if ( slbPtr->hasCandidateObj() )
453 newStatus = S_Update;
457 newStatus = S_Install ;
460 newStatus = S_NoInst;
463 newStatus = S_KeepInstalled;
466 newStatus = oldStatus;
488 yuiError() <<
"Invalid patch object" << endl;
492 ok = slbPtr->setStatus( newstatus );
493 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
494 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
509 SelectionStatStrategy::SelectionStatStrategy()
525 if ( !slbPtr || !objPtr )
527 yuiError() <<
"Invalid selection" << endl;
531 ok = slbPtr->setStatus( newstatus );
532 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
533 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
548 DependencyStatStrategy::DependencyStatStrategy()
560 AvailableStatStrategy::AvailableStatStrategy()
572 ZyppSel slbPtr, ZyppObj objPtr )
576 if ( !slbPtr || !objPtr )
581 ZyppObj newCandidate = objPtr;
583 if ( newCandidate != slbPtr->candidateObj() )
585 yuiMilestone() <<
"CANDIDATE changed" << endl;
588 ZyppStatus status = slbPtr->status();
590 if ( slbPtr->installedObj() &&
591 slbPtr->installedObj()->edition() == newCandidate->edition() &&
592 slbPtr->installedObj()->vendor() == newCandidate->vendor()
595 yuiMilestone() <<
"Identical package installed" << endl;
598 status = S_KeepInstalled;
604 case S_KeepInstalled:
624 ok = slbPtr->setCandidate( newCandidate );
625 yuiMilestone() <<
"Set user candidate returns: " << (ok?
"true":
"false") << endl;
629 ok = slbPtr->setStatus( status );
630 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
631 << status <<
" returns: " << (ok?
"true":
"false") << endl;
646 MultiVersionStatStrategy::MultiVersionStatStrategy()
660 if ( !slbPtr || !objPtr )
662 yuiError() <<
"Selectable pointer not valid" << endl;
666 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
667 return slbPtr->pickStatus( itemPtr );
677 ZyppSel slbPtr, ZyppObj objPtr )
681 if ( !slbPtr || !objPtr )
686 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
687 ok = slbPtr->setPickStatus( itemPtr, newstatus );
688 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
689 <<
" to: " << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
701 UpdateStatStrategy::UpdateStatStrategy()
714 PatchPkgStatStrategy::PatchPkgStatStrategy()
720 ZyppSel slbPtr, ZyppObj objPtr )