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 bool greaterThan( const string& v1, const string& v2 );
93
94 int returnValue() const;
95
96 SignalHandler::HandlerResult handleSignal( int signal );
97
98 protected:
99
100 void printDepsLevel(int indent, const Package* package);
101
102 void executeTransaction( InstallTransaction& transaction,
103 bool update, bool group );
104 void evaluateResult( InstallTransaction& transaction,
105 bool update,
106 bool interrupted=false );
107 void reportPrePost(const InstallTransaction::InstallInfo& info);
108
109 void readConfig();
110 void initRepo( bool listDuplicate=false );
111
112 void expandWildcardsPkgDB( const list<char*>& in,
113 map<string, string>& target );
114 void expandWildcardsRepo( const list<char*>& in,
115 list<string>& target );
116
117 void warnPackageNotFound(InstallTransaction& transaction);
118
119 Repository* m_repo;
120 PkgDB* m_pkgDB;
121 Configuration* m_config;
122 InstallTransaction* m_currentTransaction;
123
124 Locker m_locker;
125
126 const ArgParser* m_parser;
127 string m_appName;
128 string m_cacheFile;
129
130 int m_returnValue;
131
132 bool m_useRegex;
133
134 /*! Name of default configuration file */
135 static const string CONF_FILE;
136
137 /*! Name of default cache file */
138 static const string DEFAULT_CACHE_FILE;
139
140
141 void assertMinArgCount(int count);
142 void assertMaxArgCount(int count);
143 void assertExactArgCount(int count);
144 void argCountFailure(int count, const string& specifier);
145
146 };
147
148 #endif /* _PRTGET_H_ */
|