You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
2.9 KiB

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