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 printDependent();
71 void printDiff();
72 void printQuickDiff();
73 void listOrphans();
74
75 void createCache();
76
77 void printPath();
78 void printf();
79
80 void cat();
81 void ls();
82 void edit();
83
84 void remove();
85
86 void setLock( bool lock );
87 void listLocked();
88
89 void fsearch();
90
91 void dumpConfig();
92
93 int returnValue() const;
94
95 SignalHandler::HandlerResult handleSignal( int signal );
96
97 protected:
98
99 void printDepsLevel(int indent, const Package* package);
100
101 void printDependent(const std::string& dep, int level);
102
103 void executeTransaction( InstallTransaction& transaction,
104 bool update, bool group );
105 void evaluateResult( InstallTransaction& transaction,
106 bool update,
107 bool interrupted=false );
108 void reportPrePost(const InstallTransaction::InstallInfo& info);
109
110 void readConfig();
111 void initRepo( bool listDuplicate=false );
112
113 void expandWildcardsPkgDB( const list<char*>& in,
114 map<string, string>& target );
115 void expandWildcardsRepo( const list<char*>& in,
116 list<string>& target );
117
118 void warnPackageNotFound(InstallTransaction& transaction);
119
120 Repository* m_repo;
121 PkgDB* m_pkgDB;
122 Configuration* m_config;
123 InstallTransaction* m_currentTransaction;
124
125 Locker m_locker;
126
127 const ArgParser* m_parser;
128 string m_appName;
129 string m_cacheFile;
130
131 int m_returnValue;
132
133 bool m_useRegex;
134
135 /*! Name of default configuration file */
136 static const string CONF_FILE;
137
138 /*! Name of default cache file */
139 static const string DEFAULT_CACHE_FILE;
140
141
142 void assertMinArgCount(int count);
143 void assertMaxArgCount(int count);
144 void assertExactArgCount(int count);
145 void argCountFailure(int count, const string& specifier);
146
147 bool greaterThan( const string& v1, const string& v2 );
148 static bool printFile(const string& file);
149 };
150
151 #endif /* _PRTGET_H_ */
|