42 #include "NCWidgetFactory.h" 43 #include "NCPushButton.h" 44 #include "NCMenuButton.h" 46 #include "NCSpacing.h" 47 #include "NCRichText.h" 49 #include "NCPkgFilterRPMGroups.h" 50 #include "NCPopupInfo.h" 51 #include "NCSelectionBox.h" 52 #include "NCMenuButton.h" 53 #include "NCPkgFilterPattern.h" 54 #include "NCPkgFilterLocale.h" 55 #include "NCPkgFilterRepo.h" 56 #include "NCPkgFilterService.h" 57 #include "NCPkgFilterClassification.h" 58 #include "NCPkgPopupDeps.h" 59 #include "NCPkgPopupDiskspace.h" 60 #include "NCPkgMenuDeps.h" 61 #include "NCPkgMenuView.h" 62 #include "NCPkgMenuExtras.h" 63 #include "NCPkgMenuConfig.h" 64 #include "NCPkgMenuHelp.h" 65 #include "NCPkgMenuAction.h" 66 #include "NCPkgPopupDescr.h" 67 #include "NCPackageSelector.h" 68 #include "NCLayoutBox.h" 69 #include "YSelectionBox.h" 70 #include "YAlignment.h" 71 #include "YNCursesUI.h" 72 #include "YApplication.h" 82 #include <zypp/ui/Selectable.h> 83 #include <zypp/base/Sysconfig.h> 85 #include "YWidgetID.h" 86 #include "YPackageSelector.h" 88 #define PATH_TO_YAST_SYSCONFIG "/etc/sysconfig/yast2" 90 #define OPTION_RECOMMENDED "PKGMGR_RECOMMENDED" 91 #define OPTION_REEVALUATE "PKGMGR_REEVALUATE_RECOMMENDED" 92 #define OPTION_VERIFY "PKGMGR_VERIFY_SYSTEM" 93 #define OPTION_AUTO_CHECK "PKGMGR_AUTO_CHECK" 94 #define OPTION_EXIT "PKGMGR_ACTION_AT_EXIT" 96 typedef zypp::Patch::Contents ZyppPatchContents;
97 typedef zypp::Patch::Contents::Selectable_iterator ZyppPatchContentsIterator;
111 NCPackageSelector::NCPackageSelector(
long modeFlags )
117 , diskspacePopup( 0 )
120 , verifySystem( false )
121 , installRecommended( false )
131 , updatelistItem( 0 )
133 , diskspaceLabel( 0 )
138 , patchPkgsVersions( 0 )
144 setFlags( modeFlags );
149 setInstallRecommended( isInstallRecommended() );
150 setAutoCheck( isAutoCheck() );
151 setVerifySystem( isVerifySystem() );
166 void NCPackageSelector::setFlags(
long modeFlags )
168 youMode = ( modeFlags & YPkg_OnlineUpdateMode ) ?
true :
false ;
170 updateMode = ( modeFlags & YPkg_UpdateMode ) ?
true :
false ;
172 repoMgrEnabled = (modeFlags & YPkg_RepoMgr) ?
true :
false;
174 testMode = (modeFlags & YPkg_TestMode ) ?
true :
false ;
176 repoMode = ( modeFlags & YPkg_RepoMode ) ?
true :
false;
178 summaryMode = ( modeFlags & YPkg_SummaryMode ) ?
true :
false;
181 void NCPackageSelector::readSysconfig()
183 sysconfig = zypp::base::sysconfig::read( PATH_TO_YAST_SYSCONFIG );
184 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_EXIT );
186 if (it != sysconfig.end())
188 actionAtExit = it->second;
189 yuiMilestone() <<
"Read sysconfig's action at pkg mgr exit value: " << actionAtExit << endl;
194 yuiMilestone() <<
"Could not read " << OPTION_EXIT <<
"variable from sysconfig, disabling the menu" << endl;
198 void NCPackageSelector::writeSysconfig( )
201 if( !actionAtExit.empty() )
205 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
208 "Set behaviour when package installation has finished.");
210 catch(
const std::exception &e )
212 yuiError() <<
"Writing " << OPTION_EXIT <<
" failed" << endl;
218 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
220 (autoCheck?
"yes":
"no"),
221 "Automatic dependency checking" );
223 catch(
const std::exception &e )
225 yuiError() <<
"Writing " << OPTION_AUTO_CHECK <<
" failed" << endl;
230 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
232 (verifySystem?
"yes":
"no"),
233 "System verification mode" );
235 catch(
const std::exception &e )
237 yuiError() <<
"Writing " << OPTION_VERIFY <<
" failed" << endl;
242 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
244 (installRecommended?
"yes":
"no"),
245 "Install recommended packages" );
247 catch(
const std::exception &e )
249 yuiError() <<
"Writing " << OPTION_RECOMMENDED <<
" failed" << endl;
253 bool NCPackageSelector::checkNow(
bool *ok )
258 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok );
259 YDialog::deleteTopmostDialog();
263 bool NCPackageSelector::systemVerification(
bool *ok )
268 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Verify, ok );
269 YDialog::deleteTopmostDialog();
273 bool NCPackageSelector::doInstallRecommended(
bool *ok )
275 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended(
false );
276 zypp::getZYpp()->resolver()->resolvePool();
286 bool NCPackageSelector::isCleanDepsOnRemove()
288 return zypp::getZYpp()->resolver()->cleandepsOnRemove();
291 void NCPackageSelector::setCleanDepsOnRemove(
bool on )
293 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
294 zypp::getZYpp()->resolver()->resolvePool();
302 bool NCPackageSelector::isInstallRecommended()
304 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_RECOMMENDED );
306 if ( it != sysconfig.end() )
308 yuiMilestone() << OPTION_RECOMMENDED <<
": " << it->second << endl;
309 if ( it->second ==
"yes" )
310 installRecommended =
true;
311 else if ( it->second ==
"no")
312 installRecommended =
false;
314 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
318 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
320 yuiMilestone() <<
"installRecommended: " << (installRecommended?
"yes":
"no") << endl;
322 return installRecommended;
325 void NCPackageSelector::setInstallRecommended(
bool on )
327 installRecommended = on;
328 zypp::getZYpp()->resolver()->setOnlyRequires( !on );
330 zypp::getZYpp()->resolver()->resolvePool();
335 bool NCPackageSelector::isAutoCheck()
339 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_AUTO_CHECK);
341 if ( it != sysconfig.end() )
343 yuiMilestone() << OPTION_AUTO_CHECK <<
": " << it->second << endl;
344 if ( it->second ==
"no" )
347 yuiMilestone() <<
"autoCheck " << (autoCheck?
"yes":
"no") << endl;
352 bool NCPackageSelector::isVerifySystem( )
354 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_VERIFY );
356 if ( it != sysconfig.end() )
358 yuiMilestone() << OPTION_VERIFY <<
": " << it->second << endl;
359 if ( it->second ==
"yes" )
361 else if ( it->second ==
"no")
362 verifySystem =
false;
364 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
368 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
370 yuiMilestone() <<
"verifySystem: " << (verifySystem?
"yes":
"no") << endl;
375 void NCPackageSelector::setVerifySystem(
bool on )
378 zypp::getZYpp()->resolver()->setSystemVerification( on );
380 zypp::getZYpp()->resolver()->resolvePool();
388 bool NCPackageSelector::isAllowVendorChange()
390 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
391 bool change = resolver->allowVendorChange();
392 yuiMilestone() <<
"Vendor change allowed: " << (change?
"true":
"false") << endl;
396 void NCPackageSelector::setAllowVendorChange(
bool on )
398 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
399 zypp::getZYpp()->resolver()->resolvePool();
410 ZyppPool p = zyppPool ();
412 p.saveState<zypp::Package> ();
413 p.saveState<zypp::SrcPackage> ();
415 p.saveState<zypp::Patch> ();
417 p.saveState<zypp::Pattern> ();
421 void NCPackageSelector::restoreState ()
423 ZyppPool p = zyppPool ();
425 p.restoreState<zypp::Package> ();
426 p.restoreState<zypp::SrcPackage> ();
428 p.restoreState<zypp::Patch> ();
430 p.restoreState<zypp::Pattern> ();
434 bool NCPackageSelector::diffState ()
436 ZyppPool p = zyppPool ();
440 std::ostream & log = yuiMilestone();
441 log <<
"diffState" << endl;
442 diff = diff || p.diffState<zypp::Package> ();
444 diff = diff || p.diffState<zypp::SrcPackage> ();
447 diff = diff || p.diffState<zypp::Patch> ();
450 diff = diff || p.diffState<zypp::Pattern> ();
467 if ( event == NCursesEvent::handled )
470 yuiMilestone() <<
"widget event: " <<
event << endl;
472 if ( event == NCursesEvent::button )
474 if ( event.widget == okButton )
478 else if ( event.widget == cancelButton )
482 else if ( event.widget == filterPopup )
484 retVal = filterPopup->handleEvent();
486 else if ( event.widget == filterMain )
488 retVal = filterMain->handleEvent();
490 else if ( event.widget == searchField )
492 if ( event.reason == YEvent::Activated )
494 retVal = searchPopup->showSearchResultPackages();
502 else if ( event == NCursesEvent::menu )
504 if ( event.widget == actionMenu )
506 retVal = actionMenu->handleEvent( event );
507 else if ( event.widget == viewMenu )
509 retVal = viewMenu->handleEvent( event );
510 else if ( event.widget == depsMenu )
511 retVal = depsMenu->handleEvent( event );
512 else if ( event.widget == extrasMenu )
513 retVal = extrasMenu->handleEvent( event );
514 else if ( event.widget == configMenu )
515 retVal = configMenu->handleEvent( event );
516 else if ( event.widget == helpMenu )
517 retVal = helpMenu->handleEvent( event );
518 else if ( event.widget == filterMenu )
519 retVal = filterMenu->handleEvent( event );
520 else if ( event.selection->label().substr(0,4) ==
"pkg:" )
549 q.addKind( zypp::ResKind::patch );
550 q.addAttribute( zypp::sat::SolvAttr::keywords );
553 q.addAttribute( zypp::sat::SolvAttr::name );
557 q.addAttribute( zypp::sat::SolvAttr::summary );
560 for( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
561 it != q.selectableEnd(); it++)
563 yuiMilestone() << (*it)->name() << endl;
564 ZyppPatch patchPtr = tryCastToZyppPatch( (*it)->theObj() );
593 yuiError() <<
"No valid NCPkgTable widget" << endl;
601 std::list<ZyppSel> patchList( zyppPatchesBegin (), zyppPatchesEnd () );
602 patchList.sort( sortByName );
603 std::list<ZyppSel>::iterator listIt = patchList.begin();
605 while ( listIt != patchList.end() )
607 ZyppPatch patchPtr = tryCastToZyppPatch( ( *listIt)->theObj() );
616 if ( filter == NCPkgMenuFilter::F_All
630 case NCPkgMenuFilter::F_Needed:
636 case NCPkgMenuFilter::F_Unneeded:
638 packageLabel->setLabel( NCPkgStrings::InstPatches() );
643 packageLabel->setLabel( NCPkgStrings::Patches() );
663 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
670 std::list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
672 for ( std::list<zypp::PoolItem>::const_iterator it = problemList.begin();
673 it != problemList.end();
676 ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
684 yuiMilestone() <<
"Problematic package: " << pkg->name().c_str() <<
" " <<
685 pkg->edition().asString().c_str() << endl;
711 if ( !pkgTable || !objPtr )
716 std::set<ZyppSel> patchSelectables;
717 ZyppPatch patchPtr = tryCastToZyppPatch( objPtr );
722 ZyppPatchContents patchContents( patchPtr->contents() );
724 yuiMilestone() <<
"Filtering for patch: " << patchPtr->name().c_str() <<
" number of atoms: " 725 << patchContents.size() << endl ;
727 for ( ZyppPatchContentsIterator it = patchContents.selectableBegin();
728 it != patchContents.selectableEnd();
731 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
735 yuiMilestone() <<
"Patch package found: " << (*it)->name().c_str() << endl;
740 if ( inContainer( patchSelectables, sel ) )
742 yuiMilestone() <<
"Suppressing duplicate selectable: " << (*it)->name().c_str() <<
"-" <<
743 pkg->edition().asString().c_str() <<
" " <<
744 pkg->arch().asString().c_str() << endl;
748 patchSelectables.insert( sel );
749 yuiDebug() << (*it)->name().c_str() <<
": Version: " << pkg->edition().asString() << endl;
757 yuiDebug() <<
"Found unknown atom of kind %s: %s" <<
758 (*it)->kind().asString().c_str() <<
759 (*it)->name().c_str() << endl;
779 NCPkgMenuFilter::PatchFilter filter )
783 bool displayPatch =
false;
787 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
790 if ( !patchPtr || !selectable || !selectable->hasCandidateObj() )
792 yuiError() <<
"Patch data not valid" << endl;
795 yuiDebug() <<
"Filter: " << filter << endl;
797 if ( filter == NCPkgMenuFilter::F_All )
802 else if ( selectable->candidateObj().isRelevant() )
806 case NCPkgMenuFilter::F_Unneeded:
808 if ( selectable->candidateObj().isSatisfied() &&
809 !selectable->candidateObj().status().isToBeInstalled() )
815 case NCPkgMenuFilter::F_Needed:
817 if ( !selectable->candidateObj().isSatisfied() ||
819 selectable->candidateObj().status().isToBeInstalled() )
823 case NCPkgMenuFilter::F_Security:
825 if ( patchPtr->category() ==
"security" )
829 case NCPkgMenuFilter::F_Recommended:
831 if ( patchPtr->category() ==
"recommended" )
835 case NCPkgMenuFilter::F_Optional:
837 if ( patchPtr->category() ==
"optional" )
842 yuiWarning() <<
"Unknown patch filter" << endl;
858 wrect NCPackageSelector::deleteReplacePoint()
861 YWidget * replaceChild = replacePoint->firstChild();
866 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
873 patchPkgsVersions = 0;
889 wrect oldSize = deleteReplacePoint();
896 infoText->setSize( oldSize.Sze.W, oldSize.Sze.H );
911 wrect oldSize = deleteReplacePoint();
915 YTableHeader * tableHeader =
new YTableHeader();
916 versionsList =
new NCPkgTable( replacePoint, tableHeader );
920 if ( versionsList && packageList )
926 versionsList->setSize( oldSize.Sze.W, oldSize.Sze.H );
928 versionsList->fillAvailableList( packageList->
getSelPointer( packageList->getCurrentItem() ) );
929 versionsList->Redraw();
931 packageList->setKeyboardFocus();
946 wrect oldSize = deleteReplacePoint();
950 YTableHeader * tableHeader =
new YTableHeader();
951 patchPkgs =
new NCPkgTable( replacePoint, tableHeader );
953 if ( patchPkgs && packageList )
959 patchPkgs->
setTableType( NCPkgTable::T_PatchPkgs, strategy );
961 patchPkgs->setSize( oldSize.Sze.W, oldSize.Sze.H );
966 packageList->setKeyboardFocus();
985 ZyppSel sel = patchPkgs->
getSelPointer( patchPkgs->getCurrentItem() );
991 _(
"Package Versions"),
993 _(
"List of all available package versions:"),
996 NCursesEvent input = availablePopup->showAvailablesPopup( sel );
998 YDialog::deleteTopmostDialog();
1000 patchPkgs->setKeyboardFocus();
1004 void NCPackageSelector::clearInfoArea()
1007 infoText->setText(
"");
1011 packageLabel->setText(
".....................................");
1014 void NCPackageSelector::replaceFilter( FilterMode mode)
1016 patternLabel->setLabel(
" " );
1017 YWidget * replaceChild = replPoint->firstChild();
1022 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1024 delete replaceChild;
1036 replaceFilterDescr( mode == Search );
1042 YTableHeader *hhh =
new YTableHeader ();
1044 patternPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1045 patternPopup->Redraw();
1047 patternPopup->setKeyboardFocus();
1052 YTableHeader *hhh =
new YTableHeader ();
1054 languagePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1055 languagePopup->Redraw();
1056 languagePopup->showLocalePackages();
1057 languagePopup->setKeyboardFocus();
1062 YTableHeader *hhh =
new YTableHeader ();
1064 repoPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1065 repoPopup->Redraw();
1066 repoPopup->showRepoPackages();
1067 repoPopup->setKeyboardFocus();
1072 YTableHeader *hhh =
new YTableHeader ();
1074 servicePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1075 servicePopup->Redraw();
1077 servicePopup->setKeyboardFocus();
1083 filterPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1084 filterPopup->Redraw();
1086 YStringTreeItem * defaultGroup = filterPopup->getDefaultRpmGroup();
1090 yuiMilestone() <<
"default RPM group: " << defaultGroup->value().translation() << endl;
1091 filterPopup->showRPMGroupPackages ( defaultGroup->value().translation(), defaultGroup );
1095 yuiError() <<
"No default RPM group available" << endl;
1097 filterPopup->setKeyboardFocus();
1103 searchPopup->createLayout( replPoint );
1104 searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1105 searchPopup->Redraw();
1107 searchField = searchPopup->getSearchField();
1110 searchField->setKeyboardFocus();
1111 searchField->setNotify(
true);
1118 inst_summary->setSize( oldSize.Sze.W, oldSize.Sze.H );
1119 inst_summary->Redraw();
1120 inst_summary->setKeyboardFocus();
1121 pkgList->fillSummaryList(NCPkgTable::L_Changes);
1124 case PkgClassification:
1127 pkgClass->setSize( oldSize.Sze.W, oldSize.Sze.H );
1129 pkgClass->setKeyboardFocus();
1134 yuiError() <<
"zatim nic" << endl;
1144 pkgList->setCurrentItem(0);
1150 void NCPackageSelector::replaceFilterDescr(
bool b )
1152 YWidget * replaceChild = replPoint2->firstChild();
1157 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1159 delete replaceChild;
1167 searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
1168 searchSet->Redraw();
1172 filter_desc =
new NCRichText( replPoint2,
"");
1173 filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
1174 filter_desc->Redraw();
1189 std::string pkgName = link.substr(6);
1195 for (i = b; i != e; ++i)
1197 ZyppPkg pkgPtr = tryCastToZyppPkg ((*i)->theObj());
1198 if ( pkgPtr && pkgPtr->name() == pkgName )
1200 yuiMilestone() <<
"Package " << pkgName <<
" found" << endl;
1203 popupDescr->showInfoPopup( pkgPtr, *i );
1205 YDialog::deleteTopmostDialog();
1213 yuiError() <<
"Package " << pkgName <<
" NOT found" << endl;
1229 bool changes = diffState ();
1233 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-45)/2 ),
1234 NCPkgStrings::NotifyLabel(),
1235 NCPkgStrings::CancelText(),
1239 cancelMsg->setPreferredSize( 45, 8 );
1240 cancelMsg->focusCancelButton();
1241 NCursesEvent input = cancelMsg->showInfoPopup( );
1243 YDialog::deleteTopmostDialog();
1245 if ( input == NCursesEvent::cancel ) {
1253 yuiMilestone() <<
"Cancel button pressed - leaving package selection" << endl;
1254 const_cast<NCursesEvent &
>(event).result =
"cancel";
1268 bool closeDialog =
true;
1269 bool confirmedAllLicenses =
false;
1279 closeDialog =
false;
1284 }
while ( !confirmedAllLicenses && closeDialog );
1292 _(
"Automatic Changes"),
1294 _(
"In addition to your manual selections, the following" ),
1296 _(
"packages have been changed to resolve dependencies:" )
1298 NCursesEvent input = autoChangePopup->showInfoPopup();
1300 YDialog::deleteTopmostDialog();
1302 if ( input == NCursesEvent::cancel )
1305 closeDialog =
false;
1309 if ( diskspacePopup )
1311 std::string message =
"";
1312 message = diskspacePopup->checkDiskSpace();
1313 if ( message !=
"" )
1316 NCPopupInfo * spaceMsg =
new NCPopupInfo( wpos( (NCurses::lines()-10)/2, (NCurses::cols()-50)/2 ),
1317 NCPkgStrings::ErrorLabel(),
1319 _(
"You can choose to install anyway, but you risk getting a corrupted system." ),
1320 _(
"&Continue anyway" ),
1323 spaceMsg->setPreferredSize( 50, 10 );
1324 spaceMsg->focusOkButton();
1325 NCursesEvent input = spaceMsg->showInfoPopup( );
1327 YDialog::deleteTopmostDialog();
1329 if ( input == NCursesEvent::cancel )
1332 closeDialog =
false;
1344 const_cast<NCursesEvent &
>(event).result =
"accept";
1345 yuiMilestone() <<
"OK button pressed - leaving package selection, starting installation" << endl;
1356 packageList->setKeyboardFocus();
1365 bool allConfirmed =
true;
1372 return allConfirmed;
1377 yuiMilestone() <<
"Showing all pending license agreements" << endl;
1379 bool allConfirmed =
true;
1381 for ( ZyppPoolIterator it = begin; it != end; ++it )
1383 ZyppSel sel = (*it);
1385 switch ( sel->status() )
1392 if ( sel->candidateObj() )
1394 std::string licenseText = sel->candidateObj()->licenseToConfirm();
1396 if ( ! licenseText.empty() )
1398 yuiMilestone() <<
"Package/Patch " << sel->name().c_str() <<
1399 "has a license" << endl;
1401 if( ! sel->hasLicenceConfirmed() )
1407 yuiMilestone() <<
"License for " << sel->name().c_str() <<
1408 " is already confirmed" << endl;
1419 return allConfirmed;
1427 bool license_confirmed =
true;
1429 std::string pkgName = slbPtr->name();
1433 if ( !license_confirmed )
1436 switch ( slbPtr->status() )
1440 slbPtr->setStatus( S_Taboo );
1445 slbPtr->setStatus( S_Protected );
1454 yuiMilestone() <<
"User confirmed license agreement for " << pkgName << endl;
1455 slbPtr->setLicenceConfirmed (
true);
1471 bool cancel =
false;
1473 if ( doit || autoCheck )
1475 yuiMilestone() <<
"Checking dependencies" << endl;
1476 cancel = checkNow( & ok );
1499 std::string html_text =
"";
1500 const std::string htmlIdent(DOCTYPETAG);
1501 bool confirmed =
false;
1503 if ( license.find( htmlIdent ) != std::string::npos )
1505 html_text = license;
1509 html_text =
"<pre>" + license +
"</pre>";
1512 NCPopupInfo * info =
new NCPopupInfo ( wpos( NCurses::lines()/10, NCurses::cols()/10),
1514 _(
"End User License Agreement" ),
1515 "<i>" + pkgName +
"</i><br><br>" 1520 info->setPreferredSize( (NCurses::cols() * 80)/100, (NCurses::lines()*80)/100);
1521 info->focusOkButton();
1522 confirmed = info->showInfoPopup( ) != NCursesEvent::cancel;
1524 YDialog::deleteTopmostDialog();
1552 if ( diskspacePopup )
1554 diskspacePopup->checkDiskSpaceRange( );
1557 if ( diskspaceLabel )
1559 diskspaceLabel->setText( diskspacePopup->calculateDiff().asString() );
1573 std::set<ZyppSel> selectablesToInstall;
1575 for ( ZyppPoolIterator patches_it = zyppPatchesBegin();
1576 patches_it != zyppPatchesEnd();
1579 ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
1583 ZyppPatchContents patchContents( patch->contents() );
1585 for ( ZyppPatchContentsIterator contents_it = patchContents.selectableBegin();
1586 contents_it != patchContents.selectableEnd();
1589 ZyppPkg pkg = tryCastToZyppPkg( (*contents_it)->theObj() );
1598 switch ( sel->status() )
1609 selectablesToInstall.insert( sel );
1615 case S_KeepInstalled:
1629 FSize totalSize = 0;
1631 for ( std::set<ZyppSel>::iterator it = selectablesToInstall.begin();
1632 it != selectablesToInstall.end();
1635 if ( (*it)->candidateObj() )
1636 totalSize += (*it)->candidateObj()->installSize();
1640 if ( diskspaceLabel )
1642 diskspaceLabel->setText( totalSize.asString() );
1651 NCPkgTable * NCPackageSelector::PackageList()
1662 YLayoutBox * split = YUI::widgetFactory()->createVBox( selector );
1664 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( split );
1666 YAlignment * left1 = YUI::widgetFactory()->createLeft( hSplit );
1667 filterMenu =
new NCPkgMenuFilter( left1, NCPkgStrings::Filter(),
this );
1669 YAlignment * left2 = YUI::widgetFactory()->createLeft( hSplit );
1670 actionMenu =
new NCPkgMenuAction( left2, NCPkgStrings::Actions(),
this );
1672 YAlignment * left3 = YUI::widgetFactory()->createLeft( hSplit );
1673 viewMenu =
new NCPkgMenuView( left3, NCPkgStrings::View(),
this);
1675 YAlignment * left4 = YUI::widgetFactory()->createLeft( hSplit );
1676 depsMenu =
new NCPkgMenuDeps( left4, NCPkgStrings::Deps(),
this);
1679 YTableHeader * tableHeader =
new YTableHeader();
1681 pkgList =
new NCPkgTable( split, tableHeader );
1682 YUI_CHECK_NEW( pkgList );
1687 pkgList->
setTableType( NCPkgTable::T_Patches, strategy );
1694 std::vector<std::string> pkgHeader;
1695 pkgList->getHeader( pkgHeader );
1699 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( split );
1701 YLayoutBox * hSplit3 = YUI::widgetFactory()->createHBox( hSplit2 );
1703 new NCLabel( hSplit3, _(
"Filter: " ) );
1704 packageLabel = YUI::widgetFactory()->createLabel ( hSplit3,
"....................................." );
1706 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1708 YLayoutBox * hSplit4 = YUI::widgetFactory()->createHBox( hSplit2 );
1710 new NCLabel( hSplit4, _(
"Total Download Size: " ) );
1712 diskspaceLabel = YUI::widgetFactory()->createLabel ( hSplit4,
" " );
1714 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( split );
1715 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1718 YUI_CHECK_NEW( infoText );
1720 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vSplit );
1721 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1725 YAlignment *r = YUI::widgetFactory()->createRight( bottom_bar );
1726 YLayoutBox * hSplit5 = YUI::widgetFactory()->createHBox( r );
1729 cancelButton =
new NCPushButton( hSplit5, _(
"&Cancel" ) );
1730 YUI_CHECK_NEW( cancelButton );
1731 cancelButton->setFunctionKey( 9 );
1734 okButton =
new NCPushButton( hSplit5, _(
"&Accept" ) );
1735 YUI_CHECK_NEW( okButton );
1736 okButton->setFunctionKey( 10 );
1746 YLayoutBox * vsplit = YUI::widgetFactory()->createVBox( selector );
1747 YLayoutBox * menu_bar = YUI::widgetFactory()->createHBox( vsplit );
1748 YLayoutBox * panels = YUI::widgetFactory()->createVBox( vsplit );
1749 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vsplit );
1751 YAlignment * left1 = YUI::widgetFactory()->createLeft( menu_bar );
1753 YLayoutBox * menu_buttons = YUI::widgetFactory()->createHBox( left1);
1754 depsMenu =
new NCPkgMenuDeps( menu_buttons, NCPkgStrings::Deps(),
this);
1755 viewMenu =
new NCPkgMenuView( menu_buttons, NCPkgStrings::View(),
this);
1758 if (isRepoMgrEnabled())
1759 configMenu =
new NCPkgMenuConfig( menu_buttons, _(
"C&onfiguration" ),
this);
1761 extrasMenu =
new NCPkgMenuExtras( menu_buttons, NCPkgStrings::Extras(),
this);
1763 YLayoutBox * hbox_top = YUI::widgetFactory()->createHBox( panels );
1764 YLayoutBox * hbox_bottom = YUI::widgetFactory()->createHBox( panels );
1766 YLayoutBox * vbox_left = YUI::widgetFactory()->createVBox( hbox_top );
1767 vbox_left->setWeight(YD_HORIZ,1);
1768 YFrame * fr = YUI::widgetFactory()->createFrame (vbox_left,
"");
1769 YLayoutBox * vv = YUI::widgetFactory()->createVBox( fr );
1770 YAlignment *l = YUI::widgetFactory()->createLeft( vv );
1773 replPoint = YUI::widgetFactory()->createReplacePoint( vv );
1776 searchPopup->createLayout( replPoint );
1778 searchField = searchPopup->getSearchField();
1781 searchField->setKeyboardFocus();
1782 searchField->setNotify(
true );
1785 YAlignment *l1 = YUI::widgetFactory()->createLeft( vbox_left );
1786 patternLabel =
new NCLabel( l1,
" " );
1789 YTableHeader * tableHeader =
new YTableHeader();
1791 YLayoutBox * v = YUI::widgetFactory()->createVBox( hbox_top );
1792 v->setWeight(YD_HORIZ,2);
1794 YUI_CHECK_NEW( pkgList );
1800 case NCPkgTable::T_Packages:
1802 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1803 case NCPkgTable::T_Update:
1805 pkgList->
setTableType( NCPkgTable::T_Update, strategy );
1808 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1815 std::vector<std::string> pkgHeader;
1816 pkgList->getHeader( pkgHeader );
1820 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( v );
1821 new NCLabel( hSplit2, NCPkgStrings::PackageName() );
1822 packageLabel = YUI::widgetFactory()->createLabel ( hSplit2,
"......................" );
1823 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1824 actionMenu =
new NCPkgMenuAction ( hSplit2, NCPkgStrings::Actions(),
this );
1827 replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
1828 replPoint2->setWeight(YD_HORIZ, 1);
1832 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
1833 vSplit->setWeight(YD_HORIZ, 2);
1834 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1836 YUI_CHECK_NEW( infoText );
1839 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1841 YUI_CHECK_NEW( helpMenu );
1844 YAlignment *right = YUI::widgetFactory()->createRight( bottom_bar );
1845 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( right );
1848 cancelButton =
new NCPushButton( hSplit, _(
"&Cancel" ) );
1849 YUI_CHECK_NEW( cancelButton );
1850 cancelButton->setFunctionKey( 9 );
1853 okButton =
new NCPushButton( hSplit, _(
"&Accept" ) );
1854 YUI_CHECK_NEW( okButton );
1855 okButton->setFunctionKey( 10 );
1867 yuiMilestone() <<
"Filling package list: " << (NCWidget *) pkgList << endl;
1869 switch ( pkgList->getTableType() )
1871 case NCPkgTable::T_Patches: {
1875 pkgList->setVisibleInfo(NCPkgTable::I_PatchDescr);
1878 pkgList->setKeyboardFocus();
1881 case NCPkgTable::T_Update: {
1882 if ( ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty() )
1886 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1892 case NCPkgTable::T_Packages: {
1894 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1895 searchField->setKeyboardFocus();
1905 replaceFilter ( NCPackageSelector::Repositories );
1907 filterMain->setReposSelected();
1909 else if ( summaryMode )
1911 replaceFilter ( NCPackageSelector::Summary );
1913 filterMain->setSummarySelected();
bool showInformation()
Show the corresponding information (e.g.
bool createPatchEntry(ZyppPatch pkgPtr, ZyppSel slbPtr)
Creates a line in the YOU patch table.
void showDiskSpace()
Calls the package mananager (updateDu()) and shows the required disk space.
static const std::string YOUPatches()
The label Filter: YOU Patches.
void showSelectionDependencies()
Checks and shows the selectiondependencies.
bool checkPatch(ZyppPatch patch, ZyppSel selectable, NCPkgMenuFilter::PatchFilter filter)
Check if 'patch' matches the selected filter.
static const std::string UpdateProblem()
The label for Filter: Update problem.
bool fillPatchList(NCPkgMenuFilter::PatchFilter filter)
Fills the package table with YOU patches matching the filter.
bool showPendingLicenseAgreements()
Check for license.
void createPkgLayout(YWidget *parent, NCPkgTable::NCPkgTableType type)
Create layout for the PackageSelector.
ZyppObj getDataPointer(int index)
Gets the data pointer of a certain package.
void showDownloadSize()
Shows the total download size.
bool handleEvent(const NCursesEvent &event)
Handle the given event.
void updatePackageList()
Updates the status in list of packages.
virtual ~NCPackageSelector()
Destructor.
void showPatchPackages()
Creates an NCPkgTable widget and shows all packages belonging to a patch.
void fillHeader()
Fills the header of the table.
bool fillPatchPackages(NCPkgTable *pkgTable, ZyppObj youPatch)
Fills the list of packages belonging to the youPatch.
bool CancelHandler(const NCursesEvent &event)
Handler function for "Cancel button pressed".
bool showLicensePopup(std::string pkgName, std::string license)
Shows 'End User License Agreement' popup with license text.
void showPatternPackages()
Shows the popup with the add ons (package categories).
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
static const std::string AcceptLabel()
The label of the Accept button.
static const std::string SearchResults()
The label for Filter: Search results.
bool createInfoEntry(std::string text)
Creates a line in the table shwing an info text.
void saveState()
Check for changes.
bool fillPatchSearchList(const std::string &expr, bool checkName, bool checkSum)
Fills the package table with packages matching the search expression.
ZyppSel getSelPointer(int index)
Gets the selectable pointer of a certain package.
bool updateTable()
Set the status information if status has changed.
bool setTableType(NCPkgTableType type, NCPkgStatusStrategy *strategy)
Sets the type of the table and the status strategy (which means call particular methods to set/get th...
unsigned int getNumLines()
Returns the number of lines in the table (the table size)
static const std::string NoPatches()
Info line in empty patch list.
static const std::string YesLabel()
The label of the Yes button.
bool fillDefaultList()
Fills the default package table.
virtual void itemsCleared()
Clears the package list.
static const std::string NoLabel()
The label of the No button.
bool LinkHandler(std::string link)
Handles hyperlinks in package description.
void showServicePackages()
Make the Package List show the packages for the currently selected service.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)
void createYouLayout(YWidget *parent)
Create layout for the Online Update.
bool OkButtonHandler(const NCursesEvent &event)
Handler function for "OK button pressed".
void setPackager(NCPackageSelector *pkg)
Sets the member variable PackageSelector *packager.
void showPatchPkgVersions()
Creates an NCPkgTable widget and shows all versions of all packages belonging to a patch...
static const std::string DiskSpaceError()
The headline of the disk space popup.
void showInformation()
Creates an NCRichText widget for package (patch) information.
bool showLicenseAgreement(ZyppSel &slbPtr, std::string licenseText)
Show popup with license.
bool showPackageDependencies(bool doit)
Checks and shows the dependencies.
static const std::string CancelLabel()
The label of the Cancel button.
void showVersionsList()
Creates an NCPkgTable widget and shows all verions a the selected package.
bool fillUpdateList()
Fills the package table with packages with update problems.
ZyppSel findZyppSel(ZyppPkg pkg)
Find the corresponding ZyppSel to a ZyppPkg.