1 ////////////////////////////////////////////////////////////////////////
2 // FILE: prtget.h
3 // AUTHOR: Johannes Winkelmann, jw@tks6.net
4 // COPYRIGHT: (c) 2002 by Johannes Winkelmann
5 // ---------------------------------------------------------------------
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 ////////////////////////////////////////////////////////////////////////
11
12 #ifndef _PRTGET_H_
13 #define _PRTGET_H_
14
15 class Repository;
16 class ArgParser;
17 class Configuration;
18
19 #include <list>
20 #include <utility>
21 #include <string>
22 using namespace std;
23
24 #include "pkgdb.h"
25 #include "signaldispatcher.h"
26 #include "locker.h"
27 #include "installtransaction.h"
28
29 /*!
30 \class PrtGet
31 \brief Main class
32
33 This is prt-get's main class, controlling all the commands
34 */
35 class PrtGet
36 : public SignalHandler
37 {
38 public:
39
40 enum PGReturnStates {
41 PG_GENERAL_ERROR = -1,
42 PG_OK = 0,
43 PG_ARG_ERROR,
44 PG_INSTALL_ERROR,
45 PG_PARTIAL_INSTALL_ERROR
46 };
47
48 PrtGet( const ArgParser* parser );
49 ~PrtGet();
50
51 void printVersion();
52 void printUsage();
53
54 void listPackages();
55 void listShadowed();
56 void listInstalled();
57
58 void searchPackages( bool searchDesc=false );
59 void printInfo();
60 void isInstalled();
61 void readme();
62
63 void install( bool update=false,
64 bool group=false,
65 bool dependencies=false );
66 void sysup();
67 void current();
68 void printDepends( bool simpleListing=false );
69 void printDependTree();
70 void printDependendent();
71 void printDiff();
72 void printQuickDiff();
73
74 void createCache();
75
76 void printPath();
77 void printf();
78
79 void cat();
80 void ls();
81 void edit();
82
83 void remove();
84
85 void setLock( bool lock );
86 void listLocked();
87
88 void fsearch();
89
90 void dumpConfig();
91
92 int returnValue() const;
93
94 SignalHandler::HandlerResult handleSignal( int signal );
95
96 protected:
97
98 void printDepsLevel(int indent, const Package* package);
99
100 void executeTransaction( InstallTransaction& transaction,
101 bool update, bool group );
102 void evaluateResult( InstallTransaction& transaction,
103 bool update,
104 bool interrupted=false );
105 void reportPrePost(const InstallTransaction::InstallInfo& info);
106
107 void readConfig();
108 void initRepo( bool listDuplicate=false );
109
110 void expandWildcardsPkgDB( const list<char*>& in,
111 map<string, string>& target );
112 void expandWildcardsRepo( const list<char*>& in,
113 list<string>& target );
114
115 void warnPackageNotFound(InstallTransaction& transaction);
116
117 Repository* m_repo;
118 PkgDB* m_pkgDB;
119 Configuration* m_config;
120 InstallTransaction* m_currentTransaction;
121
122 Locker m_locker;
123
124 const ArgParser* m_parser;
125 string m_appName;
126 string m_cacheFile;
127
128 int m_returnValue;
129
130 bool m_useRegex;
131
132 /*! Name of default configuration file */
133 static const string CONF_FILE;
134
135 /*! Name of default cache file */
136 static const string DEFAULT_CACHE_FILE;
137
138
139 void assertMinArgCount(int count);
140 void assertMaxArgCount(int count);
141 void assertExactArgCount(int count);
142 void argCountFailure(int count, const string& specifier);
143
144 bool greaterThan( const string& v1, const string& v2 );
145 static bool printFile(const string& file);
146 };
147
148 #endif /* _PRTGET_H_ */
|