2 ** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
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.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program in a file called COPYING; if not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 ** MA 02110-1301, USA.
24 ** Bug reports and questions can be sent to kde-devel@kde.org
28 #ifndef PKGINTERFACE_H
29 #define PKGINTERFACE_H
31 #include <QtCore/QList>
33 #include <QtCore/QStringList>
35 #include <QtGui/QPixmap>
38 #include <kstandarddirs.h>
40 #include "packageInfo.h"
42 #include "managementWidget.h"
49 class KActionCollection
;
50 //////////////////////////////////////////////////////////////////////////////
51 //////////////////////////////////////////////////////////////////////////////
53 // flags to install and uninstall
57 param(const QString
&nameP
, bool initP
, bool invertP
, const QString
&flagP
);
58 param(const QString
&nameP
, bool initP
, bool invertP
, const QString
&flagP
, const QString
&flagAP
);
61 QString name
; // Name of flag
62 bool init
; // Initial value
63 bool invert
; // Whether it needs to be inverted
64 QString flag
; // text flag on command
65 QString flagA
; // text flag on command
68 //////////////////////////////////////////////////////////////////////////////
69 //////////////////////////////////////////////////////////////////////////////
70 class pkgInterface
: public QObject
78 virtual void makeMenu(KActionCollection
* act
);
79 virtual void setMenu(KActionCollection
* act
, bool enable
);
81 bool ifExe(QString exe
);
82 // Check if this executable exists
84 virtual packageInfo
*getPackageInfo(const QString
&name
) ;
85 // get info on installed package
87 virtual void getFileList(packageInfo
*p
);
88 // get list of files in the package
90 virtual void getIFileList(packageInfo
*p
);
91 // get list of files in installed package
93 virtual void getFFileList(packageInfo
*p
);
94 // get list of files in package file
96 QStringList
depends(const QString
&name
, int src
);
97 // check dependencies for package
99 QStringList
verify(packageInfo
*p
, const QStringList
&files
);
100 // check the installed files in a package
102 virtual QStringList
FindFile(const QString
&name
, bool seachAll
=false);
103 // search for packages containing a file
105 virtual QStringList
getChangeLog(packageInfo
*p
);
108 virtual bool filesTab(packageInfo
*p
);
109 // If files tab is to be enabled
111 bool depTab(packageInfo
*p
) ;
112 // If dependency tab is to be enabled
114 virtual bool changeTab(packageInfo
*p
);
115 // If change log tab is to be enabled
117 bool parseName(const QString
&name
, QString
*n
, QString
*v
);
118 // breakup file name into package name and version
120 void listPackages(QList
<packageInfo
*> &pki
);
121 // scan various locations for list of packages
123 void listRemotePackages(QList
<packageInfo
*> &pki
);
125 void listPackagesFile(QList
<packageInfo
*> &pki
);
127 QStringList
getPackageState( const QStringList
&packages
);
128 // update installed/uninstalled state of packages
130 void getPackageDepends(packageInfo
*p
);
131 // Get package depends info
133 virtual packageInfo
*getFPackageInfo(const QString
&name
);
134 // Get package Info from file
136 void listInstalledPackages(QList
<packageInfo
*> &pki
);
137 // produce list of currently installed packages
139 QStringList
listInstalls(const QStringList
&packs
, bool install
, bool &cancel
);
140 // Convert list of packages requested to install to list of all packages to install
142 void smerge(packageInfo
*p
);
143 // merge in package info entry
145 packageInfo
*collectPath(const QString
&name
);
148 packageInfo
*collectDir(const QString
&name
, const QString
&size
, const QString
&dir
);
149 // build packageInfo object from directory entry
151 QString
provMap(const QString
&p
);
152 // convert from package depends to package
154 QString
setOptions(int flags
, QList
<param
*> ¶ms
);
155 // convert un/install flags to text
157 packageInfo
* collectInfo(QStringList
&ln
, pkgInterface
*pkgInt
= 0);
158 // Parse package info
160 QString
doUninstall(int uninstallFlags
, const QString
&packs
, bool &test
);
161 QString
doInstall(int installFlags
, const QString
&packs
, bool &test
);
163 void removeLastEmpty(QStringList
&list
);
165 QString
uninstall(int uninstallFlags
, QList
<packageInfo
*> p
,
167 QString
uninstall(int uninstallFlags
, packageInfo
*p
,
170 QString
install(int installFlags
, QList
<packageInfo
*> p
,
172 QString
install(int installFlags
, packageInfo
*p
,
175 QString
getDelimiter(short ptype
);
176 // return name version delimiter character
178 ///////////// DATA ///////////////////////
180 pkgOptions
*uninstallation
, *installation
;
182 QAction
*updateM
, *upgradeM
, *fixupM
, *fileM
;
186 QPixmap pict
, bad_pict
, new_pict
, updated_pict
;
187 // icons for package states
189 // icon for package group
192 // icon indicating mark for install/uninstall
194 Locations
*locatedialog
;
195 // dialog for setting the locations of uninstalled packages
196 LcacheObj
*packageLoc
;
197 // List of locations of uninstalled pacckages
200 // variables related to reading packages from directories
202 QString packagePattern
;
204 // Parameters for reading packages from directories
206 QList
<param
*> paramsInst
;
207 QList
<param
*> paramsUninst
;
209 QRegExp pFile
, deb
, rpm
, slack
, fin
;
210 // Regular expressions that match package names
213 // kpackage doesn't fetch this type of package itself
216 // This package type defaults to on
219 // The name of an executable that wasn't found
223 // for running processes
228 // can access on remote host
231 // can search uninstalled packages for files
234 // the program needed to handle this package type is available
237 // Count of packages read in
241 QStringList packList
;
242 // Buffer for splitting up package entries
245 // The type of the last package
248 void textIn(const QString
&s
);
249 // Process remote packace info
257 #endif // PKGINTERFACE_H