source: projects/synaptic/trunk/common/rcdscanner.h @ 280

Revision 280, 2.4 KB checked in by yasumichi, 13 years ago (diff)

first import

Line 
1/* rcdscanner.h
2 *
3 * Copyright (c) 2000, 2001 Conectiva S/A
4 *
5 * Author: Alfredo K. Kojima <kojima@conectiva.com.br>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23
24#ifndef _RCDSCANNER_H_
25#define _RCDSCANNER_H_
26
27#include<config.h>
28#ifndef HAVE_APTPKG_CDROM
29
30#include <vector>
31#include <string>
32
33#include "rpackagelister.h"
34
35using namespace std;
36
37class Configuration;
38
39
40class RCDScanProgress {
41
42 protected:
43   int _total;
44
45 public:
46   void setTotal(int total) {
47      _total = total;
48   };
49
50   virtual void update(string text, int current) = 0;
51   virtual ~RCDScanProgress() {};
52};
53
54class RCDScanner {
55
56   Configuration *_database;
57
58   RUserDialog *_userDialog;
59
60 protected:
61
62   enum {
63      STEP_PREPARE = 1,
64      STEP_UNMOUNT,
65      STEP_WAIT,
66      STEP_MOUNT,
67      STEP_IDENT,
68      STEP_SCAN,
69      STEP_CLEAN,
70      STEP_UNMOUNT2,
71      STEP_REGISTER,
72      STEP_COPY,
73      STEP_WRITE,
74      STEP_UNMOUNT3,
75      STEP_LAST
76   };
77
78   vector<string> _pkgList;
79   vector<string> _srcList;
80   string _infoDir;
81
82   string _cdId;
83   string _cdName;
84   string _cdOldName;
85
86   bool _cdromMounted;
87   bool _scannedOk;
88
89   string pkgSourceType() const;
90   string srcSourceType() const;
91   bool scanDirectory(string path, RCDScanProgress *progress, int depth = 0);
92
93   void cleanPkgList(vector<string> &list);
94   void cleanSrcList(vector<string> &list);
95
96   bool writeDatabase();
97   bool writeSourceList(vector<string> &list, bool pkg);
98
99 public:
100   bool start(RCDScanProgress *progress);
101   bool finish(RCDScanProgress *progress);
102   void unmount();
103
104   string getDiscName();
105   bool setDiscName(string name);
106
107   void countLists(int &pkgLists, int &srcLists);
108
109   RCDScanner(RUserDialog *userDialog)
110 :   _database(0), _userDialog(userDialog), _cdromMounted(0), _scannedOk(0) {
111   };
112};
113
114#endif
115#endif
Note: See TracBrowser for help on using the repository browser.