-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalpminterface.h
78 lines (62 loc) · 2.38 KB
/
alpminterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef ALPMINTERFACE_H
#define ALPMINTERFACE_H
#include "pkgInterface.h"
#include <vector>
#include <string>
#include <set>
typedef struct __alpm_handle_t alpm_handle_t;
typedef struct __alpm_db_t alpm_db_t;
typedef struct __alpm_pkg_t alpm_pkg_t;
struct alpmPackageInfo : public packageInfo
{
alpmPackageInfo(QDict<QString> *_info, pkgInterface *type, alpm_pkg_t *me) :
packageInfo(_info, type), alpm_pkg(me) {}
alpmPackageInfo(QDict<QString> *_info, QString _filename, alpm_pkg_t *me) :
packageInfo(_info, _filename),
alpm_pkg(me) { }
~alpmPackageInfo();
alpm_pkg_t *alpm_pkg;
};
class alpmInterface : public pkgInterface
{
public:
alpmInterface();
~alpmInterface();
// pkgInterface interface
public:
bool isType(char *buf, const char *fname) override;
param *initinstallOptions() override;
param *inituninstallOptions() override;
packageInfo *getPackageInfo(char mode, const char *name, const char *version) override;
QListT<char> *getFileList(packageInfo *p) override;
QListT<char> *depends(const char *name, int src) override;
int doUninstall(int installFlags, QString packs) override;
int doInstall(int installFlags, QString packs) override;
QString FindFile(const char *name) override;
bool parseName(QString name, QString *n, QString *v) override;
void listPackages(QList<packageInfo> *pki) override;
void listInstalledPackages(QListT<packageInfo> *pki) override;
void smerge(packageInfo *p) override;
bool initialize();
void removeAlpmPackage(alpmPackageInfo *pkg) {
m_instantiated.erase(pkg);
}
virtual int uninstall(int uninstallFlags, QList<packageInfo> *p);
virtual int uninstall(int uninstallFlags, packageInfo *p);
// uninstall package or packages
virtual int install(int installFlags, QList<packageInfo> *p);
virtual int install(int installFlags, packageInfo *p);
public slots:
void setLocation() override;
void setAvail(LcacheObj *) override;
private:
void parseDatabase(alpm_db_t *db, QList<packageInfo> *pki);
bool loadConfig();
packageInfo *createInfo(alpm_pkg_t *pkg);
alpm_pkg_t *findPackage(const char *name, const char *version);
alpm_handle_t *m_handle;
std::vector<std::string> m_repos;
// I don't understand QListT, so just do it manually
std::set<alpmPackageInfo*> m_instantiated;
};
#endif // ALPMINTERFACE_H