]>
Commit | Line | Data |
---|---|---|
1 | #ifndef PKGLIB_CDROM_H | |
2 | #define PKGLIB_CDROM_H | |
3 | ||
4 | #include<string> | |
5 | #include<vector> | |
6 | ||
7 | #ifndef APT_8_CLEANER_HEADERS | |
8 | #include <apt-pkg/init.h> | |
9 | using namespace std; | |
10 | #endif | |
11 | ||
12 | class Configuration; | |
13 | class OpProgress; | |
14 | ||
15 | class pkgCdromStatus /*{{{*/ | |
16 | { | |
17 | protected: | |
18 | int totalSteps; | |
19 | ||
20 | public: | |
21 | pkgCdromStatus() : totalSteps(0) {}; | |
22 | virtual ~pkgCdromStatus() {}; | |
23 | ||
24 | // total steps | |
25 | virtual void SetTotal(int total) { totalSteps = total; }; | |
26 | // update steps, will be called regularly as a "pulse" | |
27 | virtual void Update(std::string text="", int current=0) = 0; | |
28 | ||
29 | // ask for cdrom insert | |
30 | virtual bool ChangeCdrom() = 0; | |
31 | // ask for cdrom name | |
32 | virtual bool AskCdromName(std::string &Name) = 0; | |
33 | // Progress indicator for the Index rewriter | |
34 | virtual OpProgress* GetOpProgress() {return NULL; }; | |
35 | }; | |
36 | /*}}}*/ | |
37 | class pkgCdrom /*{{{*/ | |
38 | { | |
39 | protected: | |
40 | enum { | |
41 | STEP_PREPARE = 1, | |
42 | STEP_UNMOUNT, | |
43 | STEP_WAIT, | |
44 | STEP_MOUNT, | |
45 | STEP_IDENT, | |
46 | STEP_SCAN, | |
47 | STEP_COPY, | |
48 | STEP_WRITE, | |
49 | STEP_UNMOUNT3, | |
50 | STEP_LAST | |
51 | }; | |
52 | ||
53 | ||
54 | bool FindPackages(std::string CD, | |
55 | std::vector<std::string> &List, | |
56 | std::vector<std::string> &SList, | |
57 | std::vector<std::string> &SigList, | |
58 | std::vector<std::string> &TransList, | |
59 | std::string &InfoDir, pkgCdromStatus *log, | |
60 | unsigned int Depth = 0); | |
61 | bool DropBinaryArch(std::vector<std::string> &List); | |
62 | bool DropRepeats(std::vector<std::string> &List,const char *Name); | |
63 | bool DropTranslation(std::vector<std::string> &List); | |
64 | void ReduceSourcelist(std::string CD,std::vector<std::string> &List); | |
65 | bool WriteDatabase(Configuration &Cnf); | |
66 | bool WriteSourceList(std::string Name,std::vector<std::string> &List,bool Source); | |
67 | int Score(std::string Path); | |
68 | ||
69 | public: | |
70 | bool Ident(std::string &ident, pkgCdromStatus *log); | |
71 | bool Add(pkgCdromStatus *log); | |
72 | }; | |
73 | /*}}}*/ | |
74 | ||
75 | ||
76 | // class that uses libudev to find cdrom/removable devices dynamically | |
77 | struct CdromDevice /*{{{*/ | |
78 | { | |
79 | std::string DeviceName; | |
80 | bool Mounted; | |
81 | std::string MountPath; | |
82 | }; | |
83 | /*}}}*/ | |
84 | class pkgUdevCdromDevices /*{{{*/ | |
85 | { | |
86 | protected: | |
87 | // libudev dlopen stucture | |
88 | void *libudev_handle; | |
89 | struct udev* (*udev_new)(void); | |
90 | int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); | |
91 | int (*udev_enumerate_scan_devices)(struct udev_enumerate *udev_enumerate); | |
92 | struct udev_list_entry* (*udev_enumerate_get_list_entry)(struct udev_enumerate *udev_enumerate); | |
93 | struct udev_device* (*udev_device_new_from_syspath)(struct udev *udev, const char *syspath); | |
94 | struct udev* (*udev_enumerate_get_udev)(struct udev_enumerate *udev_enumerate); | |
95 | const char* (*udev_list_entry_get_name)(struct udev_list_entry *list_entry); | |
96 | const char* (*udev_device_get_devnode)(struct udev_device *udev_device); | |
97 | struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev); | |
98 | struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry); | |
99 | const char* (*udev_device_get_property_value)(struct udev_device *udev_device, const char *key); | |
100 | int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); | |
101 | // end libudev dlopen | |
102 | ||
103 | public: | |
104 | pkgUdevCdromDevices(); | |
105 | virtual ~pkgUdevCdromDevices(); | |
106 | ||
107 | // try to open | |
108 | bool Dlopen(); | |
109 | ||
110 | // convenience interface, this will just call ScanForRemovable | |
111 | // with "APT::cdrom::CdromOnly" | |
112 | std::vector<CdromDevice> Scan(); | |
113 | ||
114 | std::vector<CdromDevice> ScanForRemovable(bool CdromOnly); | |
115 | }; | |
116 | /*}}}*/ | |
117 | ||
118 | #endif |