1 | #ifndef _UNINSTALL_H_
|
---|
2 | #define _UNINSTALL_H_
|
---|
3 | #include <string>
|
---|
4 | #include <vector>
|
---|
5 | #include <map>
|
---|
6 | using namespace std;
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <fstream.h>
|
---|
10 |
|
---|
11 | #include "stringArray.h"
|
---|
12 |
|
---|
13 | static string uninstall_ALL = "all";
|
---|
14 |
|
---|
15 | typedef class unInstallCommand
|
---|
16 | { public:
|
---|
17 | string command;
|
---|
18 | stringArray parameters;
|
---|
19 |
|
---|
20 | unInstallCommand() { };
|
---|
21 | unInstallCommand(string commandname) { this->command = commandname; };
|
---|
22 | unInstallCommand(string commandname, stringArray params)
|
---|
23 | { this->command = commandname;
|
---|
24 | this->parameters = params;
|
---|
25 | };
|
---|
26 | void addParameter(string parameter) { this->parameters.add(parameter); };
|
---|
27 | string commandName() { return this->command; };
|
---|
28 | stringArray ¶meterList() { return this->parameters; };
|
---|
29 | } unInstallCommand;
|
---|
30 |
|
---|
31 | typedef vector<unInstallCommand> unInstallCommandList;
|
---|
32 |
|
---|
33 | typedef map<string, unInstallCommandList, less<string> > unInstallCommandMap;
|
---|
34 |
|
---|
35 | class installManager
|
---|
36 | { private:
|
---|
37 | fstream logfile;
|
---|
38 | string logfileName;
|
---|
39 | string currentModule;
|
---|
40 | unInstallCommandMap modules;
|
---|
41 |
|
---|
42 | bool writeString(string str);
|
---|
43 | bool writeString(char *string);
|
---|
44 | bool writeSeparator();
|
---|
45 | string readString();
|
---|
46 | bool writeCommand(unInstallCommand &command);
|
---|
47 | string readCommand(stringArray ¶ms);
|
---|
48 | public:
|
---|
49 | installManager() { };
|
---|
50 | bool openLog(string filename, bool write);
|
---|
51 | bool closeLog();
|
---|
52 | bool reopenLog();
|
---|
53 | void setModule(string moduleName);
|
---|
54 | bool storeCommand(unInstallCommand &command);
|
---|
55 | string popCommand(stringArray ¶ms);
|
---|
56 | bool isEmpty();
|
---|
57 | ~installManager();
|
---|
58 | };
|
---|
59 |
|
---|
60 | class installAgent
|
---|
61 | { protected:
|
---|
62 | installManager *manager;
|
---|
63 | public:
|
---|
64 | installAgent(installManager &useManager) { this->manager = &useManager; };
|
---|
65 | virtual bool undoAction(string actionName, stringArray ¶ms) { return false; };
|
---|
66 | // bool undo(string actionName);
|
---|
67 | };
|
---|
68 |
|
---|
69 | class unInstaller
|
---|
70 | { private:
|
---|
71 | unInstallCommandMap _map;
|
---|
72 | void unInstallGroup(unInstallCommandList &list);
|
---|
73 | bool readFile(string &fileName);
|
---|
74 | bool getLine(char *line, string &groupname);
|
---|
75 | public:
|
---|
76 | unInstaller(string &fileName);
|
---|
77 | unInstaller(const char *fileName);
|
---|
78 | void unInstall(string &listName);
|
---|
79 | bool record(string group, string cmd, string param);
|
---|
80 | bool record(string group, string cmd, int count, ...);
|
---|
81 | bool saveToFile(string filename);
|
---|
82 | bool execCommand(string &command, stringArray ¶ms);
|
---|
83 | };
|
---|
84 |
|
---|
85 | #endif
|
---|