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>
63 NCPkgStatusStrategy::NCPkgStatusStrategy()
70 NCPkgStatusStrategy::~NCPkgStatusStrategy()
85 return slbPtr->status();
89 yuiError() <<
"Selectable pointer not valid" << endl;
106 yuiError() <<
"Invalid package object" << endl;
110 ok = slbPtr->setStatus( newstatus );
112 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
113 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
127 ZyppStatus & newStat )
133 ZyppStatus retStat = S_NoInst;
135 bool installed = !slbPtr->installedEmpty();
152 if ( oldStatus == S_NoInst
153 || oldStatus == S_AutoInstall )
158 else if ( oldStatus == S_Del
159 || oldStatus == S_AutoDel)
161 retStat = S_KeepInstalled;
163 else if ( oldStatus == S_AutoUpdate )
173 if ( oldStatus == S_KeepInstalled
174 || oldStatus == S_Del
175 || oldStatus == S_AutoDel )
177 if ( slbPtr->hasCandidateObj() )
190 if ( oldStatus == S_Install
191 || oldStatus == S_AutoInstall )
195 else if ( oldStatus == S_Update
196 || oldStatus == S_AutoUpdate )
198 retStat = S_KeepInstalled;
210 retStat = S_Protected;
214 yuiDebug() <<
"Key not valid" << endl;
233 ZyppStatus & newStat )
241 ZyppStatus newStatus = oldStatus;
242 ZyppPattern patPtr = tryCastToZyppPattern (objPtr);
247 newStatus = S_KeepInstalled;
250 newStatus =S_NoInst ;
255 case S_KeepInstalled:
257 newStatus = S_Install;
259 else if ( slbPtr->hasCandidateObj() )
261 newStatus = S_Update;
269 if ( slbPtr->hasCandidateObj() || patPtr )
271 newStatus = S_Install;
275 yuiWarning() <<
"No candidate object for " << slbPtr->theObj()->name().c_str() << endl;
276 newStatus = S_NoInst;
282 newStatus = S_NoInst;
285 newStatus = S_KeepInstalled;
288 newStatus = S_KeepInstalled;
291 newStatus = S_NoInst;
294 newStatus = S_KeepInstalled;
298 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
312 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
313 resolver->resolvePool();
325 PackageStatStrategy::PackageStatStrategy()
340 PatchStatStrategy::PatchStatStrategy()
355 ZyppStatus & newStat )
357 if ( !slbPtr || !slbPtr->hasCandidateObj() )
361 ZyppStatus retStat = S_NoInst;
363 bool toBeInst = slbPtr->candidateObj().status().isToBeInstalled();
364 bool isRelevant = slbPtr->candidateObj().isRelevant();
365 bool isBroken = slbPtr->candidateObj().isBroken();
367 yuiMilestone() << slbPtr->name() <<
": " << (toBeInst?
"to be installed":
"not to be installed,")
368 <<
" old status: " << oldStatus << endl;
379 else if ( oldStatus == S_Taboo )
398 ( oldStatus == S_NoInst ||
399 oldStatus == S_AutoInstall ||
400 oldStatus == S_KeepInstalled ) )
418 yuiDebug() <<
"Key not valid" << endl;
426 yuiMilestone() <<
"New status: " << newStat << endl;
439 ZyppStatus & newStat )
441 if ( !slbPtr || !slbPtr->hasCandidateObj() )
447 bool isBroken = slbPtr->candidateObj().isBroken();
448 ZyppStatus newStatus = oldStatus;
454 newStatus = S_NoInst ;
456 case S_KeepInstalled:
457 newStatus = S_Install;
460 newStatus = S_Install ;
465 newStatus = S_Install;
469 newStatus = S_NoInst;
473 newStatus = oldStatus;
475 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
496 yuiError() <<
"Invalid patch object" << endl;
500 ok = slbPtr->setStatus( newstatus );
501 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
502 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
517 SelectionStatStrategy::SelectionStatStrategy()
533 if ( !slbPtr || !objPtr )
535 yuiError() <<
"Invalid selection" << endl;
539 ok = slbPtr->setStatus( newstatus );
540 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
541 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
556 DependencyStatStrategy::DependencyStatStrategy()
568 AvailableStatStrategy::AvailableStatStrategy()
580 ZyppSel slbPtr, ZyppObj objPtr )
584 if ( !slbPtr || !objPtr )
589 ZyppObj newCandidate = objPtr;
591 if ( newCandidate != slbPtr->candidateObj() )
593 yuiMilestone() <<
"CANDIDATE changed" << endl;
596 ZyppStatus status = slbPtr->status();
598 if ( slbPtr->installedObj() &&
599 slbPtr->installedObj()->edition() == newCandidate->edition() &&
600 slbPtr->installedObj()->vendor() == newCandidate->vendor()
603 yuiMilestone() <<
"Identical package installed" << endl;
606 status = S_KeepInstalled;
612 case S_KeepInstalled:
632 ok = bool( slbPtr->setCandidate( newCandidate ) );
633 yuiMilestone() <<
"Set user candidate returns: " << (ok?
"true":
"false") << endl;
637 ok = slbPtr->setStatus( status );
638 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
639 << status <<
" returns: " << (ok?
"true":
"false") << endl;
654 MultiVersionStatStrategy::MultiVersionStatStrategy()
668 if ( !slbPtr || !objPtr )
670 yuiError() <<
"Selectable pointer not valid" << endl;
674 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
675 return slbPtr->pickStatus( itemPtr );
686 ZyppSel slbPtr, ZyppObj objPtr )
690 if ( !slbPtr || !objPtr )
694 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
696 bool multiVersion = itemPtr->multiversionInstall();
697 yuiMilestone() <<
"Selected: "
698 << ( multiVersion ?
"Multiversion " :
"Non-Multiversion " )
703 yuiMilestone() <<
"Multiversion and non-multiversion conflict!" << endl;
707 ok = slbPtr->setPickStatus( itemPtr, newstatus );
708 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
709 <<
" to: " << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
713 yuiMilestone() <<
"Selection canceled by the user.";
718 ok = slbPtr->setPickStatus( itemPtr, newstatus );
719 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
720 <<
" to: " << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
738 zypp::ui::Selectable::available_iterator it = slbPtr->availableBegin();
740 while ( it != slbPtr->availableEnd() )
742 if ( it->multiversionInstall() == multiversion )
744 switch ( slbPtr->pickStatus( *it ) )
748 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
749 <<
" to install" << endl;
751 case S_KeepInstalled:
752 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
753 <<
" wich is already installed" << endl;
763 yuiMilestone() <<
"No " << ( multiversion ?
"multiversion" :
"non-multiversion" )
764 <<
" to install" << endl;
777 std::string msg = NCPkgStrings::MultiversionIntro();
781 msg += NCPkgStrings::MultiversionText();
785 msg += NCPkgStrings::NotMultiversionText();
788 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-22)/2, (NCurses::cols()-45)/2 ),
794 cancelMsg->setPreferredSize( 60, 15 );
795 cancelMsg->focusCancelButton();
796 NCursesEvent input = cancelMsg->showInfoPopup( );
798 YDialog::deleteTopmostDialog();
800 return !(input == NCursesEvent::cancel);
813 UpdateStatStrategy::UpdateStatStrategy()
826 PatchPkgStatStrategy::PatchPkgStatStrategy()
832 ZyppSel slbPtr, ZyppObj objPtr )
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 toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the package status (e.g.
virtual bool toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the patch status (e.g.
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 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 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 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.
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.