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