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