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