41 #define YUILogComponent "ncurses-pkg" 44 #include "NCPkgStatusStrategy.h" 47 #include "NCPopupInfo.h" 48 #include "NCPkgStrings.h" 50 #include <zypp/ui/Selectable.h> 51 #include <zypp/base/LogTools.h> 52 #include <zypp/ResObject.h> 64 NCPkgStatusStrategy::NCPkgStatusStrategy()
71 NCPkgStatusStrategy::~NCPkgStatusStrategy()
87 return slbPtr->status();
91 yuiError() <<
"Selectable pointer not valid" << endl;
109 yuiError() <<
"Invalid package object" << endl;
113 ok = slbPtr->setStatus( newstatus );
115 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: " 116 << newstatus <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
131 ZyppStatus & newStat )
137 ZyppStatus retStat = S_NoInst;
139 bool installed = !slbPtr->installedEmpty();
157 if ( oldStatus == S_NoInst
158 || oldStatus == S_AutoInstall )
163 else if ( oldStatus == S_Del
164 || oldStatus == S_AutoDel)
166 retStat = S_KeepInstalled;
168 else if ( oldStatus == S_AutoUpdate )
179 if ( oldStatus == S_KeepInstalled
180 || oldStatus == S_Del
181 || oldStatus == S_AutoDel )
183 if ( slbPtr->hasCandidateObj() )
197 if ( oldStatus == S_Install
198 || oldStatus == S_AutoInstall )
202 else if ( oldStatus == S_Update
203 || oldStatus == S_AutoUpdate )
205 retStat = S_KeepInstalled;
219 retStat = S_Protected;
224 yuiDebug() <<
"Key not valid" << endl;
244 ZyppStatus & newStat_ret )
252 ZyppStatus newStatus = oldStatus;
253 ZyppPattern patPtr = tryCastToZyppPattern (objPtr);
258 newStatus = S_KeepInstalled;
269 case S_KeepInstalled:
271 newStatus = S_Install;
273 else if ( slbPtr->hasCandidateObj() )
275 newStatus = S_Update;
284 if ( slbPtr->hasCandidateObj() || patPtr )
286 newStatus = S_Install;
290 yuiWarning() <<
"No candidate object for " << slbPtr->theObj()->name().c_str() << endl;
291 newStatus = S_NoInst;
298 newStatus = S_NoInst;
302 newStatus = S_KeepInstalled;
306 newStatus = S_KeepInstalled;
310 newStatus = S_NoInst;
314 newStatus = S_KeepInstalled;
318 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
319 newStat_ret = newStatus;
333 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
334 resolver->resolvePool();
346 PackageStatStrategy::PackageStatStrategy()
361 PatchStatStrategy::PatchStatStrategy()
376 ZyppStatus & newStat )
378 if ( !slbPtr || !slbPtr->hasCandidateObj() )
382 ZyppStatus retStat = S_NoInst;
384 bool toBeInst = slbPtr->candidateObj().status().isToBeInstalled();
385 bool isRelevant = slbPtr->candidateObj().isRelevant();
386 bool isBroken = slbPtr->candidateObj().isBroken();
388 yuiMilestone() << slbPtr->name() <<
": " << (toBeInst?
"to be installed" :
"not to be installed,")
389 <<
" old status: " << oldStatus << endl;
400 else if ( oldStatus == S_Taboo )
419 ( oldStatus == S_NoInst ||
420 oldStatus == S_AutoInstall ||
421 oldStatus == S_KeepInstalled ) )
439 yuiDebug() <<
"Key not valid" << endl;
447 yuiMilestone() <<
"New status: " << newStat << endl;
461 ZyppStatus & newStat_ret )
463 if ( !slbPtr || !slbPtr->hasCandidateObj() )
469 bool isBroken = slbPtr->candidateObj().isBroken();
470 ZyppStatus newStatus = oldStatus;
476 newStatus = S_NoInst;
479 case S_KeepInstalled:
480 newStatus = S_Install;
484 newStatus = S_Install;
490 newStatus = S_Install;
494 newStatus = S_NoInst;
499 newStatus = oldStatus;
503 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
504 newStat_ret = newStatus;
523 yuiError() <<
"Invalid patch object" << endl;
527 ok = slbPtr->setStatus( newstatus );
528 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: " 529 << newstatus <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
545 SelectionStatStrategy::SelectionStatStrategy()
562 if ( !slbPtr || !objPtr )
564 yuiError() <<
"Invalid selection" << endl;
568 ok = slbPtr->setStatus( newstatus );
569 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: " 570 << newstatus <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
586 DependencyStatStrategy::DependencyStatStrategy()
599 AvailableStatStrategy::AvailableStatStrategy()
617 if ( !slbPtr || !objPtr )
622 ZyppObj newCandidate = objPtr;
624 if ( newCandidate != slbPtr->candidateObj() )
626 yuiMilestone() <<
"CANDIDATE changed" << endl;
629 ZyppStatus status = slbPtr->status();
631 if ( slbPtr->installedObj() &&
632 slbPtr->installedObj()->edition() == newCandidate->edition() &&
633 slbPtr->installedObj()->vendor() == newCandidate->vendor() )
635 yuiMilestone() <<
"Identical package installed" << endl;
638 status = S_KeepInstalled;
644 case S_KeepInstalled:
664 ok = bool( slbPtr->setCandidate( newCandidate ) );
665 yuiMilestone() <<
"Set user candidate returns: " << ( ok ?
"true" :
"false" ) << endl;
669 ok = slbPtr->setStatus( status );
670 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: " 671 << status <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
686 MultiVersionStatStrategy::MultiVersionStatStrategy()
701 if ( !slbPtr || !objPtr )
703 yuiError() <<
"Selectable pointer not valid" << endl;
707 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
708 return slbPtr->pickStatus( itemPtr );
725 if ( !slbPtr || !objPtr )
729 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
731 bool multiVersion = itemPtr->multiversionInstall();
732 yuiMilestone() <<
"Selected: " 733 << ( multiVersion ?
"Multiversion " :
"Non-Multiversion " )
738 yuiMilestone() <<
"Multiversion and non-multiversion conflict!" << endl;
742 ok = slbPtr->setPickStatus( itemPtr, newstatus );
743 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
744 <<
" to: " << newstatus <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
748 yuiMilestone() <<
"Selection canceled by the user.";
753 ok = slbPtr->setPickStatus( itemPtr, newstatus );
754 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
755 <<
" to: " << newstatus <<
" returns: " << ( ok ?
"true" :
"false" ) << endl;
771 zypp::ui::Selectable::available_iterator it = slbPtr->availableBegin();
773 while ( it != slbPtr->availableEnd() )
775 if ( it->multiversionInstall() == multiversion )
777 switch ( slbPtr->pickStatus( *it ) )
781 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
782 <<
" to install" << endl;
784 case S_KeepInstalled:
785 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
786 <<
" wich is already installed" << endl;
796 yuiMilestone() <<
"No " << ( multiversion ?
"multiversion" :
"non-multiversion" )
797 <<
" to install" << endl;
811 std::string msg = NCPkgStrings::MultiversionIntro();
815 msg += NCPkgStrings::MultiversionText();
819 msg += NCPkgStrings::NotMultiversionText();
822 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-22)/2, (NCurses::cols()-45)/2 ),
828 cancelMsg->setPreferredSize( 60, 15 );
829 cancelMsg->focusCancelButton();
830 NCursesEvent input = cancelMsg->showInfoPopup();
832 YDialog::deleteTopmostDialog();
834 return !(input == NCursesEvent::cancel);
845 UpdateStatStrategy::UpdateStatStrategy()
858 PatchPkgStatStrategy::PatchPkgStatStrategy()
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of th eobject).
virtual bool anyMultiVersionToInstall(ZyppSel slbPtr, bool multiversion) const
Check if any package version is marked for installation where its 'multiversion' flag is set to 'mult...
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of the patch). ...
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
It is not possible to std::set the package status for packages belonging to a patch, i.e.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
virtual bool cycleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat_ret)
Cyle the package status (e.g.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the patch AND the status of the patch packages.
static const std::string MultiversionHead()
Info about multiversion packages.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the selection.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
static const std::string ContinueLabel()
The label of the Continue button.
virtual bool cycleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat_ret)
Cycle the patch status (e.g.
static const std::string CancelLabel()
The label of the Cancel button.
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.