]> git.saurik.com Git - apt.git/blame - apt-pkg/cdrom.h
merged lp:~donkult/apt/experimental
[apt.git] / apt-pkg / cdrom.h
CommitLineData
a75c6a6e
MZ
1#ifndef PKGLIB_CDROM_H
2#define PKGLIB_CDROM_H
3
a75c6a6e
MZ
4#include<string>
5#include<vector>
6
472ff00e
DK
7class Configuration;
8class OpProgress;
a75c6a6e 9
92fcbfc1 10class pkgCdromStatus /*{{{*/
a75c6a6e
MZ
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"
8f3ba4e8 22 virtual void Update(std::string text="", int current=0) = 0;
a75c6a6e
MZ
23
24 // ask for cdrom insert
25 virtual bool ChangeCdrom() = 0;
26 // ask for cdrom name
8f3ba4e8 27 virtual bool AskCdromName(std::string &Name) = 0;
a75c6a6e
MZ
28 // Progress indicator for the Index rewriter
29 virtual OpProgress* GetOpProgress() {return NULL; };
30};
92fcbfc1
DK
31 /*}}}*/
32class pkgCdrom /*{{{*/
a75c6a6e
MZ
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
8f3ba4e8
DK
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,
a75c6a6e 55 unsigned int Depth = 0);
8f3ba4e8
DK
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);
a75c6a6e 59 bool WriteDatabase(Configuration &Cnf);
8f3ba4e8
DK
60 bool WriteSourceList(std::string Name,std::vector<std::string> &List,bool Source);
61 int Score(std::string Path);
a75c6a6e
MZ
62
63 public:
8f3ba4e8 64 bool Ident(std::string &ident, pkgCdromStatus *log);
a75c6a6e
MZ
65 bool Add(pkgCdromStatus *log);
66};
92fcbfc1 67 /*}}}*/
a75c6a6e 68
a75c6a6e 69
f4c4a24e 70// class that uses libudev to find cdrom/removable devices dynamically
3e2d7cce 71struct CdromDevice /*{{{*/
cbc9bed8 72{
8f3ba4e8 73 std::string DeviceName;
cbc9bed8 74 bool Mounted;
8f3ba4e8 75 std::string MountPath;
cbc9bed8 76};
3e2d7cce
MV
77 /*}}}*/
78class pkgUdevCdromDevices /*{{{*/
cbc9bed8
MV
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);
f7cbd1fb 94 int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
cbc9bed8
MV
95 // end libudev dlopen
96
97 public:
98 pkgUdevCdromDevices();
99 virtual ~pkgUdevCdromDevices();
100
101 // try to open
102 bool Dlopen();
f4c4a24e 103
f2e4a11d
MV
104 // convenience interface, this will just call ScanForRemovable
105 // with "APT::cdrom::CdromOnly"
8f3ba4e8 106 std::vector<CdromDevice> Scan();
f4c4a24e 107
8f3ba4e8 108 std::vector<CdromDevice> ScanForRemovable(bool CdromOnly);
cbc9bed8 109};
3e2d7cce 110 /*}}}*/
a75c6a6e
MZ
111
112#endif