libyui-ncurses-pkg
NCPackageSelector.h
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPackageSelector.h
37 
38  Author: Gabriele Strattner <gs@suse.de>
39 
40 /-*/
41 #ifndef NCPackageSelector_h
42 #define NCPackageSelector_h
43 
44 #include <iosfwd>
45 #include <map>
46 #include <string>
47 #include <utility> // for STL std::pair
48 
49 #include <zypp/ResObject.h>
50 #include <zypp/Patch.h>
51 #include <zypp/ui/Selectable.h>
52 
53 #define YUILogComponent "ncurses-pkg"
54 #include <yui/YUILog.h>
55 
56 #include <yui/YWidgetID.h>
57 #include <yui/ncurses/NCEmpty.h>
58 #include <yui/ncurses/YNCursesUI.h>
59 
60 #include "NCPkgFilterInstSummary.h"
61 #include "NCPkgFilterMain.h"
62 #include "NCPkgFilterSearch.h"
63 #include "NCPkgMenuFilter.h"
64 #include "NCPkgPackageDetails.h"
65 #include "NCPkgPopupDeps.h"
66 #include "NCPkgSearchSettings.h"
67 #include "NCPkgSelMapper.h"
68 #include "NCPkgStrings.h"
69 #include "NCPkgTable.h"
70 
71 class LangCode;
72 class NCMenuButton;
73 class NCPkgDiskspace;
76 class NCPkgFilterMain;
77 class NCPkgFilterPattern;
78 class NCPkgFilterSearch;
79 class NCPkgLocaleTable;
80 class NCPkgMenuAction;
81 class NCPkgMenuConfig;
82 class NCPkgMenuDeps;
83 class NCPkgMenuExtras;
84 class NCPkgMenuHelp;
85 class NCPkgMenuView;
87 class NCPkgPopupDeps;
88 class NCPkgPopupFile;
89 class NCPkgRepoTable;
91 class NCPkgServiceTable;
92 class NCPushButton;
93 class YNCursesUI;
94 class YReplacePoint;
95 
96 inline bool ic_compare ( char c1, char c2 )
97 {
98  return ( toupper( c1 ) == toupper( c2 ) );
99 }
100 
101 #define DOCTYPETAG "<!-- DT:Rich -->" // Special doctype for preformatted HTML
102 
104 //
105 // CLASS NAME : NCPackageSelector
106 //
107 // DESCRIPTION : Specialized high-level widget for package selection
108 //
110 {
111 
112  friend std::ostream & operator<<( std::ostream & STREAM, const NCPackageSelector & OBJ );
113 
114  NCPackageSelector & operator=( const NCPackageSelector & );
116 
117 private:
118 
119  // typedef for the pointer to handler member function
120  typedef bool (NCPackageSelector::* tHandlerFctPtr) ( const NCursesEvent& event );
121 
122  // typedef for the internal map: key=nameId, value=handler-fct-ptr
123  typedef std::map<std::string, tHandlerFctPtr> tHandlerMap;
124 
125  tHandlerMap eventHandlerMap; // event handler map
126 
127  NCPkgPopupDeps * depsPopup; // the package dependeny popup
128 
129  NCPkgFilterPattern * patternPopup; // the pattern popup
130  NCPkgLocaleTable * languagePopup; // language popup
131  NCPkgRepoTable * repoPopup;
132  NCPkgServiceTable * servicePopup;
133 
134  NCPkgDiskspace * diskspacePopup; // the popup showing the disk usage
135 
136  NCPkgFilterSearch * searchPopup; // the package search popup
137  NCPkgFilterInstSummary *inst_summary;
138 
139  NCPkgFilterClassification * pkgClass; // classification of packages
140 
141  bool youMode; // YOU
142  bool updateMode; // Update
143  bool testMode; // testing
144  bool repoMgrEnabled; // Manage repositories (add menu button "Configuration")
145  bool repoMode; // Start with "Repositories" filter view
146  bool summaryMode; // Start with "Summary" filter view
147  bool onlineSearchEnabled; // Add a "Search Online" option in the "Extras" menu
148 
149  std::map <std::string, std::string> sysconfig; // sysconfig values
150 
151  bool autoCheck; // dependency check on every 'click'
152  bool verifySystem; // system verification mode
153  bool installRecommended; // option install recommended packages
154 
155  std::string actionAtExit;
156 
157  // the package table
158  NCPkgTable * pkgList;
159 
160  NCPkgMenuDeps *depsMenu;
161  NCPkgMenuView *viewMenu;
162  NCPkgMenuConfig *configMenu;
163  NCPkgMenuExtras *extrasMenu;
164  NCPkgMenuHelp *helpMenu;
165  NCPkgFilterMain *filterMain;
166  NCPkgMenuAction *actionMenu;
167  NCPkgMenuFilter *filterMenu;
168  // FIXME - add update list to NCPkgFilterMain
169  YMenuItem * updatelistItem;
170 
171  // labels
172  YLabel * packageLabel;
173  YLabel * diskspaceLabel;
174  YLabel *patternLabel;
175 
176  // information about packages
177  NCPkgPackageDetails * infoText; // short/longdecsription, filelist
178  NCRichText * filter_desc;
179  NCInputField *searchField;
180  NCPkgSearchSettings *searchSet;
181  YReplacePoint * replacePoint; // replace point for info text
182  YReplacePoint * replPoint;
183  YReplacePoint * replPoint2;
184 
185  NCPkgTable * versionsList; // list of available package versions
186  // information about patches
187  NCPkgTable * patchPkgs; // pakages belonging to a patch
188  NCPkgTable * patchPkgsVersions; // versions of packages above
189 
190  NCPushButton * okButton;
191  NCPushButton * cancelButton;
192 
193  YMenuItem * visibleInfo; // current visible package info (description, file list, ...)
194 
195  // Mapping from ZyppPkg to the corresponding ZyppSel.
196  NCPkgSelMapper selMapper;
197 
198  std::set<std::string> verified_pkgs;
199 
200 
201 public:
202 
203  enum FilterMode
204  {
205  Patterns,
206  Languages,
207  Repositories,
208  Services,
209  Search,
210  Summary,
211  PkgClassification
212  };
213 
220  NCPackageSelector( long modeFlags );
221 
225  virtual ~NCPackageSelector();
226 
227  void setFlags( long modeFlags);
228 
229  void readSysconfig();
230  void writeSysconfig();
231 
238  void createPkgLayout( YWidget * parent, NCPkgTable::NCPkgTableType type );
239 
245  void createYouLayout( YWidget * parent );
246 
251 
252  // returns the package table widget
253  NCPkgTable * PackageList();
254  NCPkgPopupDeps *DepsPopup() { return depsPopup; }
255  NCPkgDiskspace *diskSpacePopup() { return diskspacePopup; }
256  YLabel *PackageLabel() { return packageLabel; }
257  YLabel *PatternLabel() { return patternLabel; }
258 
259  NCPkgPackageDetails *InfoText() { return infoText; }
260  void setInfoText ( NCPkgPackageDetails *itext ) { infoText = itext;}
261 
262  NCPkgTable *VersionsList() { return versionsList; }
263  void setVersionsList ( NCPkgTable *table ) { versionsList = table; }
264 
265  NCPkgTable * PatchPkgs() { return patchPkgs; }
266  NCPkgTable * PatchPkgsVersions() { return patchPkgsVersions; }
267 
268  YReplacePoint *ReplacePoint() { return replacePoint; }
269  NCRichText *FilterDescription() { return filter_desc; }
270  NCPkgSearchSettings *SearchSettings() { return searchSet; }
271 
272  bool checkNow( bool *ok );
273  bool systemVerification( bool *ok );
274  bool doInstallRecommended( bool *ok );
275 
276 
282  bool fillPatchList( NCPkgMenuFilter::PatchFilter filter );
283 
288  bool fillUpdateList();
289 
290 
297  bool fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj youPatch );
298 
309  bool fillPatchSearchList( const std::string & expr, bool checkName, bool checkSum );
310 
314  bool fillDefaultList();
315 
316  bool isYouMode() { return youMode; }
317 
318  bool isUpdateMode() { return updateMode; }
319 
320  bool isRepoMgrEnabled() { return repoMgrEnabled; }
321 
322  bool isTestMode() { return testMode; }
323 
324  bool isOnlineSearchEnabled() { return onlineSearchEnabled; }
325 
326  //
327  // Action at exit (means "summary", "restart" or "close") is written to
328  // /etc/sysconfig/yast2 and gets evaluated by the YaST packager workflow.
329  //
330  std::string ActionAtExit() { return actionAtExit; }
331  void setActionAtExit( std::string action ) { actionAtExit = action; }
332 
333  //
334  // The solver options 'cleanup dependencies on remove' and
335  // 'is allow vendor change' can only be set in /etc/zypp/zypp.conf.
336  //
337  bool isCleanDepsOnRemove();
338  void setCleanDepsOnRemove( bool on );
339 
340  bool isAllowVendorChange();
341  void setAllowVendorChange( bool on );
342 
343  //
344  // The solver options 'Install recommended packages' and
345  // 'verify system' can be changed in UI and are written to /etc/sysconfig/yast2.
346  //
347  bool isInstallRecommended();
348  void setInstallRecommended( bool on );
349  bool InstallRecommended() { return installRecommended; }
350 
351  bool isVerifySystem();
352  void setVerifySystem( bool on );
353  bool VerifySystem() { return verifySystem; }
354  //
355  // The 'automatic dependency check' setting is also saved in /etc/sysconfig/yast2
356  //
357  bool isAutoCheck();
358  void setAutoCheck( bool check) { autoCheck = check; }
359  bool AutoCheck() { return autoCheck; }
360 
367  bool handleEvent( const NCursesEvent& event );
368 
374  void showPatchPkgVersions();
375 
381  void showPatchPackages();
382 
388  void showVersionsList();
389 
395  void showInformation();
396 
397  void clearInfoArea();
398 
399  wrect deleteReplacePoint();
400 
401  void replaceFilter ( FilterMode mode);
402  void replaceFilterDescr ( bool b );
408  bool OkButtonHandler ( const NCursesEvent& event );
409 
415  bool CancelHandler ( const NCursesEvent& event );
416 
422  bool LinkHandler ( std::string link );
423 
428  bool showPackageDependencies ( bool doit );
429 
434 
438  void updatePackageList();
439 
445  bool checkPatch( ZyppPatch patch,
446  ZyppSel selectable,
447  NCPkgMenuFilter::PatchFilter filter );
448 
455  bool showLicensePopup( std::string pkgName, std::string license );
456 
460  void showDiskSpace();
461 
465  void showDownloadSize();
466 
470  void saveState();
471  void restoreState();
472  bool diffState();
473 
478  bool showPendingLicenseAgreements( ZyppPoolIterator begin, ZyppPoolIterator end );
479 
484  bool showLicenseAgreement( ZyppSel & slbPtr , std::string licenseText );
485 
491  std::set <std::string> getVerifiedPkgs()
492  {
493  return verified_pkgs;
494  }
495 
500  void insertVerifiedPkg( std::string pkgname )
501  {
502  verified_pkgs.insert( pkgname);
503  }
504 
510  {
511  if ( !verified_pkgs.empty() )
512  {
513  yuiMilestone() << "Discarding auto-dependency changes" << std::endl;
514  verified_pkgs.clear();
515  }
516  }
517 
518 };
519 
520 
521 #endif // NCPackageSelector_h
Definition: NCPkgMenuFilter.h:60
Definition: NCPkgPackageDetails.h:51
Definition: NCPkgSearchSettings.h:52
void showDiskSpace()
Definition: NCPackageSelector.cc:1542
Definition: NCPkgFilterService.h:78
void showSelectionDependencies()
Definition: NCPackageSelector.cc:1486
bool checkPatch(ZyppPatch patch, ZyppSel selectable, NCPkgMenuFilter::PatchFilter filter)
Definition: NCPackageSelector.cc:783
bool fillPatchList(NCPkgMenuFilter::PatchFilter filter)
Definition: NCPackageSelector.cc:593
bool showPendingLicenseAgreements()
Definition: NCPackageSelector.cc:1361
Definition: NCPkgSelMapper.h:58
void createPkgLayout(YWidget *parent, NCPkgTable::NCPkgTableType type)
Definition: NCPackageSelector.cc:1737
Definition: NCPkgTable.h:232
void insertVerifiedPkg(std::string pkgname)
Definition: NCPackageSelector.h:500
void showDownloadSize()
Definition: NCPackageSelector.cc:1566
bool handleEvent(const NCursesEvent &event)
Definition: NCPackageSelector.cc:472
void clearVerifiedPkgs()
Definition: NCPackageSelector.h:509
void updatePackageList()
Definition: NCPackageSelector.cc:1528
virtual ~NCPackageSelector()
Definition: NCPackageSelector.cc:158
Definition: NCPkgPopupDeps.h:77
std::set< std::string > getVerifiedPkgs()
Definition: NCPackageSelector.h:491
void showPatchPackages()
Definition: NCPackageSelector.cc:953
Definition: NCPkgFilterLocale.h:70
Definition: NCPkgMenuConfig.h:57
Definition: NCPkgMenuExtras.h:57
bool fillPatchPackages(NCPkgTable *pkgTable, ZyppObj youPatch)
Definition: NCPackageSelector.cc:713
bool anyRetractedPkgInstalled()
Definition: NCPackageSelector.cc:1928
bool CancelHandler(const NCursesEvent &event)
Definition: NCPackageSelector.cc:1221
bool showLicensePopup(std::string pkgName, std::string license)
Definition: NCPackageSelector.cc:1492
Definition: NCPkgFilterRepo.h:93
Definition: NCPkgMenuAction.h:55
Definition: NCPkgMenuHelp.h:56
void saveState()
Definition: NCPackageSelector.cc:414
Definition: NCPkgFilterClassification.h:61
Definition: NCPkgFilterMain.h:57
bool fillPatchSearchList(const std::string &expr, bool checkName, bool checkSum)
Definition: NCPackageSelector.cc:541
Definition: NCPkgMenuDeps.h:57
Definition: NCPkgMenuView.h:57
Definition: NCPkgFilterSearch.h:67
bool fillDefaultList()
Definition: NCPackageSelector.cc:1858
Definition: NCPackageSelector.h:109
Definition: NCPkgFilterPattern.h:60
bool LinkHandler(std::string link)
Definition: NCPackageSelector.cc:1179
void createYouLayout(YWidget *parent)
Definition: NCPackageSelector.cc:1654
bool OkButtonHandler(const NCursesEvent &event)
Definition: NCPackageSelector.cc:1263
void showPatchPkgVersions()
Definition: NCPackageSelector.cc:989
void showInformation()
Definition: NCPackageSelector.cc:895
bool showLicenseAgreement(ZyppSel &slbPtr, std::string licenseText)
Definition: NCPackageSelector.cc:1422
bool showPackageDependencies(bool doit)
Definition: NCPackageSelector.cc:1471
void showVersionsList()
Definition: NCPackageSelector.cc:918
bool fillUpdateList()
Definition: NCPackageSelector.cc:660
Definition: NCPkgPopupDiskspace.h:196
Definition: NCPkgFilterInstSummary.h:56