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