libyui-ncurses-pkg
Loading...
Searching...
No Matches
NCPackageSelector.h
1/*
2 Copyright (c) [2002-2011] Novell, Inc.
3 Copyright (c) 2021 SUSE LLC
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) version 3.0 of the License. This library
9 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 License for more details. You should have received a copy of the GNU
13 Lesser General Public License along with this library; if not, write
14 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
15 Floor, Boston, MA 02110-1301 USA
16
17
18 File: NCPackageSelector.h
19 Author: Gabriele Strattner <gs@suse.de>
20
21*/
22
23
24#ifndef NCPackageSelector_h
25#define NCPackageSelector_h
26
27#include <iosfwd>
28#include <map>
29#include <string>
30#include <utility> // for STL std::pair
31
32#include <zypp/ResObject.h>
33#include <zypp/Patch.h>
34#include <zypp/ui/Selectable.h>
35
36#define YUILogComponent "ncurses-pkg"
37#include <yui/YUILog.h>
38
39#include <yui/YWidgetID.h>
40#include <yui/ncurses/NCEmpty.h>
41#include <yui/ncurses/YNCursesUI.h>
42
43#include "NCPkgFilterInstSummary.h"
44#include "NCPkgFilterMain.h"
45#include "NCPkgFilterSearch.h"
46#include "NCPkgMenuFilter.h"
47#include "NCPkgPackageDetails.h"
48#include "NCPkgPopupDeps.h"
49#include "NCPkgSearchSettings.h"
50#include "NCPkgSelMapper.h"
51#include "NCPkgStrings.h"
52#include "NCPkgTable.h"
53
54class LangCode;
55class NCMenuButton;
56class NCPkgDiskspace;
59class NCPkgFilterMain;
63class NCPkgMenuAction;
64class NCPkgMenuConfig;
65class NCPkgMenuDeps;
66class NCPkgMenuExtras;
67class NCPkgMenuHelp;
68class NCPkgMenuView;
70class NCPkgPopupDeps;
71class NCPkgPopupFile;
72class NCPkgRepoTable;
75class NCPushButton;
76class YNCursesUI;
77class YReplacePoint;
78
79inline bool ic_compare ( char c1, char c2 )
80{
81 return ( toupper( c1 ) == toupper( c2 ) );
82}
83
84#define DOCTYPETAG "<!-- DT:Rich -->" // Special doctype for preformatted HTML
85
87//
88// CLASS NAME : NCPackageSelector
89//
90// DESCRIPTION : Specialized high-level widget for package selection
91//
92//------------------------------------------------------------------------------
93//
94// FIXME: This should be split up into a base class and two subclasses, one for
95// pkgMode and one for youMode. They should not share any member variables or
96// methods that can't be used in both modes. In particular, they should not
97// share any widget pointers where the corresponding widgets are not created in
98// both modes.
99//
100// NCPackageSelectorBase (containing only common members and methods)
101// NCPackageSelector (for pkgMode)
102// NCPatchSelector (for youMode)
103//
105{
106
107 friend std::ostream & operator<<( std::ostream & STREAM, const NCPackageSelector & OBJ );
108
109 NCPackageSelector & operator=( const NCPackageSelector & );
111
112private:
113
114 // typedef for the pointer to handler member function
115 typedef bool (NCPackageSelector::* tHandlerFctPtr) ( const NCursesEvent& event );
116
117 // typedef for the internal map: key=nameId, value=handler-fct-ptr
118 typedef std::map<std::string, tHandlerFctPtr> tHandlerMap;
119
120 tHandlerMap eventHandlerMap; // event handler map
121
122 NCPkgPopupDeps * depsPopup; // the package dependeny popup
123
124 NCPkgFilterPattern * patternPopup; // the pattern popup
125 NCPkgLocaleTable * languagePopup; // language popup
126 NCPkgRepoTable * repoPopup;
127 NCPkgServiceTable * servicePopup;
128
129 NCPkgDiskspace * diskspacePopup; // the popup showing the disk usage
130
131 NCPkgFilterSearch * searchPopup; // the package search popup
132 NCPkgFilterInstSummary *inst_summary;
133
134 NCPkgFilterClassification * pkgClass; // classification of packages
135
136 bool youMode; // YOU
137 bool updateMode; // Update
138 bool testMode; // testing
139 bool repoMgrEnabled; // Manage repositories (add menu button "Configuration")
140 bool repoMode; // Start with "Repositories" filter view
141 bool summaryMode; // Start with "Summary" filter view
142 bool onlineSearchEnabled; // Add a "Search Online" option in the "Extras" menu
143
144 std::map <std::string, std::string> sysconfig; // sysconfig values
145
146 bool autoCheck; // dependency check on every 'click'
147 bool verifySystem; // system verification mode
148 bool installRecommended; // option install recommended packages
149
150 std::string actionAtExit;
151
152 // the package table
153 NCPkgTable * pkgList;
154
155 NCPkgMenuDeps *depsMenu;
156 NCPkgMenuView *viewMenu;
157 NCPkgMenuConfig *configMenu;
158 NCPkgMenuExtras *extrasMenu;
159 NCPkgMenuHelp *helpMenu;
160 NCPkgFilterMain *filterMain;
161 NCPkgMenuAction *actionMenu;
162 NCPkgMenuFilter *filterMenu;
163 // FIXME - add update list to NCPkgFilterMain
164 YMenuItem * updatelistItem;
165
166 // labels
167 YLabel * packageLabel;
168 YLabel * diskspaceLabel;
169 YLabel *patternLabel;
170
171 // information about packages
172 NCPkgPackageDetails * infoText; // short/longdecsription, filelist
173 NCRichText * filter_desc;
174 NCInputField *searchField;
175 NCPkgSearchSettings *searchSet;
176 YReplacePoint * replacePoint; // replace point for info text
177 YReplacePoint * replPoint;
178 YReplacePoint * replPoint2;
179
180 NCPkgTable * versionsList; // list of available package versions
181 // information about patches
182 NCPkgTable * patchPkgs; // pakages belonging to a patch
183 NCPkgTable * patchPkgsVersions; // versions of packages above
184
185 NCPushButton * okButton;
186 NCPushButton * cancelButton;
187
188 YMenuItem * visibleInfo; // current visible package info (description, file list, ...)
189
190 // Mapping from ZyppPkg to the corresponding ZyppSel.
191 NCPkgSelMapper selMapper;
192
193 std::set<std::string> verified_pkgs;
194
195
196public:
197
198 enum FilterMode
199 {
200 Patterns,
201 Languages,
202 Repositories,
203 Services,
204 Search,
205 Summary,
206 PkgClassification
207 };
208
215 NCPackageSelector( long modeFlags );
216
220 virtual ~NCPackageSelector();
221
222 void setFlags( long modeFlags);
223
224 void readSysconfig();
225 void writeSysconfig();
226
233 void createPkgLayout( YWidget * parent, NCPkgTable::NCPkgTableType type );
234
240 void createYouLayout( YWidget * parent );
241
246
247 // returns the package table widget
248 NCPkgTable * PackageList();
249 NCPkgPopupDeps *DepsPopup() { return depsPopup; }
250 NCPkgDiskspace *diskSpacePopup() { return diskspacePopup; }
251 YLabel *PackageLabel() { return packageLabel; }
252 YLabel *PatternLabel() { return patternLabel; }
253
254 NCPkgPackageDetails *InfoText() { return infoText; }
255 void setInfoText ( NCPkgPackageDetails *itext ) { infoText = itext;}
256
257 NCPkgTable *VersionsList() { return versionsList; }
258 void setVersionsList ( NCPkgTable *table ) { versionsList = table; }
259
260 NCPkgTable * PatchPkgs() { return patchPkgs; }
261 NCPkgTable * PatchPkgsVersions() { return patchPkgsVersions; }
262
263 YReplacePoint *ReplacePoint() { return replacePoint; }
264 NCRichText *FilterDescription() { return filter_desc; }
265 NCPkgSearchSettings *SearchSettings() { return searchSet; }
266
267 bool checkNow( bool *ok );
268 bool systemVerification( bool *ok );
269 bool doInstallRecommended( bool *ok );
270
271
277 bool fillPatchList( NCPkgMenuFilter::PatchFilter filter );
278
283 bool fillUpdateList();
284
285
292 bool fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj youPatch );
293
304 bool fillPatchSearchList( const std::string & expr, bool checkName, bool checkSum );
305
309 bool fillDefaultList();
310
311 bool isYouMode() { return youMode; }
312
313 bool isUpdateMode() { return updateMode; }
314
315 bool isRepoMgrEnabled() { return repoMgrEnabled; }
316
317 bool isTestMode() { return testMode; }
318
319 bool isOnlineSearchEnabled() { return onlineSearchEnabled; }
320
321 //
322 // Action at exit (means "summary", "restart" or "close") is written to
323 // /etc/sysconfig/yast2 and gets evaluated by the YaST packager workflow.
324 //
325 std::string ActionAtExit() { return actionAtExit; }
326 void setActionAtExit( std::string action ) { actionAtExit = action; }
327
328 //
329 // The solver options 'cleanup dependencies on remove' and
330 // 'is allow vendor change' can only be set in /etc/zypp/zypp.conf.
331 //
332 bool isCleanDepsOnRemove();
333 void setCleanDepsOnRemove( bool on );
334
335 bool isAllowVendorChange();
336 void setAllowVendorChange( bool on );
337
338 //
339 // The solver options 'Install recommended packages' and
340 // 'verify system' can be changed in UI and are written to /etc/sysconfig/yast2.
341 //
342 bool isInstallRecommended();
343 void setInstallRecommended( bool on );
344 bool InstallRecommended() { return installRecommended; }
345
346 bool isVerifySystem();
347 void setVerifySystem( bool on );
348 bool VerifySystem() { return verifySystem; }
349 //
350 // The 'automatic dependency check' setting is also saved in /etc/sysconfig/yast2
351 //
352 bool isAutoCheck();
353 void setAutoCheck( bool check) { autoCheck = check; }
354 bool AutoCheck() { return autoCheck; }
355
362 bool handleEvent( const NCursesEvent& event );
363
370
376 void showPatchPackages();
377
383 void showVersionsList();
384
390 void showInformation();
391
392 void clearInfoArea();
393
394 wrect deleteReplacePoint();
395
396 void replaceFilter ( FilterMode mode);
397 void replaceFilterDescr ( bool b );
403 bool OkButtonHandler ( const NCursesEvent& event );
404
410 bool CancelHandler ( const NCursesEvent& event );
411
417 bool LinkHandler ( std::string link );
418
423 bool showPackageDependencies ( bool doit );
424
429
433 void updatePackageList();
434
440 bool checkPatch( ZyppPatch patch,
441 ZyppSel selectable,
442 NCPkgMenuFilter::PatchFilter filter );
443
450 bool showLicensePopup( std::string pkgName, std::string license );
451
455 void showDiskSpace();
456
460 void showDownloadSize();
461
465 void saveState();
466 void restoreState();
467 bool diffState();
468
473 bool showPendingLicenseAgreements( ZyppPoolIterator begin, ZyppPoolIterator end );
474
479 bool showLicenseAgreement( ZyppSel & slbPtr , std::string licenseText );
480
486 std::set <std::string> getVerifiedPkgs()
487 {
488 return verified_pkgs;
489 }
490
495 void insertVerifiedPkg( std::string pkgname )
496 {
497 verified_pkgs.insert( pkgname);
498 }
499
505 {
506 if ( !verified_pkgs.empty() )
507 {
508 yuiMilestone() << "Discarding auto-dependency changes" << std::endl;
509 verified_pkgs.clear();
510 }
511 }
512
513};
514
515
516#endif // NCPackageSelector_h
Definition NCPackageSelector.h:105
void showSelectionDependencies()
Definition NCPackageSelector.cc:1487
void showInformation()
Definition NCPackageSelector.cc:885
bool fillUpdateList()
Definition NCPackageSelector.cc:650
bool fillDefaultList()
Definition NCPackageSelector.cc:1871
void showPatchPkgVersions()
Definition NCPackageSelector.cc:979
bool showPendingLicenseAgreements()
Definition NCPackageSelector.cc:1362
void createYouLayout(YWidget *parent)
Definition NCPackageSelector.cc:1667
bool fillPatchPackages(NCPkgTable *pkgTable, ZyppObj youPatch)
Definition NCPackageSelector.cc:703
bool LinkHandler(std::string link)
Definition NCPackageSelector.cc:1180
bool fillPatchList(NCPkgMenuFilter::PatchFilter filter)
Definition NCPackageSelector.cc:583
bool showPackageDependencies(bool doit)
Definition NCPackageSelector.cc:1472
void showDownloadSize()
Definition NCPackageSelector.cc:1567
void showDiskSpace()
Definition NCPackageSelector.cc:1543
void updatePackageList()
Definition NCPackageSelector.cc:1529
bool anyRetractedPkgInstalled()
Definition NCPackageSelector.cc:1941
bool CancelHandler(const NCursesEvent &event)
Definition NCPackageSelector.cc:1222
void saveState()
Definition NCPackageSelector.cc:404
void insertVerifiedPkg(std::string pkgname)
Definition NCPackageSelector.h:495
void clearVerifiedPkgs()
Definition NCPackageSelector.h:504
bool showLicensePopup(std::string pkgName, std::string license)
Definition NCPackageSelector.cc:1493
void showPatchPackages()
Definition NCPackageSelector.cc:943
bool handleEvent(const NCursesEvent &event)
Definition NCPackageSelector.cc:462
std::set< std::string > getVerifiedPkgs()
Definition NCPackageSelector.h:486
bool showLicenseAgreement(ZyppSel &slbPtr, std::string licenseText)
Definition NCPackageSelector.cc:1423
void showVersionsList()
Definition NCPackageSelector.cc:908
virtual ~NCPackageSelector()
Definition NCPackageSelector.cc:148
void createPkgLayout(YWidget *parent, NCPkgTable::NCPkgTableType type)
Definition NCPackageSelector.cc:1750
bool OkButtonHandler(const NCursesEvent &event)
Definition NCPackageSelector.cc:1264
bool checkPatch(ZyppPatch patch, ZyppSel selectable, NCPkgMenuFilter::PatchFilter filter)
Definition NCPackageSelector.cc:773
bool fillPatchSearchList(const std::string &expr, bool checkName, bool checkSum)
Definition NCPackageSelector.cc:531
Definition NCPkgPopupDiskspace.h:180
Definition NCPkgFilterClassification.h:44
Definition NCPkgFilterInstSummary.h:39
Definition NCPkgFilterMain.h:40
Definition NCPkgFilterPattern.h:44
Definition NCPkgFilterSearch.h:51
Definition NCPkgFilterLocale.h:53
Definition NCPkgMenuAction.h:39
Definition NCPkgMenuConfig.h:41
Definition NCPkgMenuDeps.h:41
Definition NCPkgMenuExtras.h:41
Definition NCPkgMenuFilter.h:44
Definition NCPkgMenuHelp.h:40
Definition NCPkgMenuView.h:41
Definition NCPkgPackageDetails.h:35
Definition NCPkgPopupDeps.h:57
Definition NCPkgFilterRepo.h:76
Definition NCPkgSearchSettings.h:35
Definition NCPkgSelMapper.h:39
Definition NCPkgFilterService.h:74
Definition NCPkgTable.h:215