summaryrefslogtreecommitdiffstats
path: root/kpackage/pkgInterface.h
blob: 5b39aa06da5ed3c2f6ef9b398bb70854563d634c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
**
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to kde-devel@kde.org
*/


#ifndef PKG_IFACE_H
#define PKG_IFACE_H

#include "../config.h"
#include <tqptrlist.h>
#include <tqstring.h>
#include <tqstringlist.h>

#include <kglobal.h>
#include <kstandarddirs.h>

#include "packageInfo.h"
#include "managementWidget.h"

class packageInfo;
class pkgOptions;
class Locations;
class LcacheObj;
class cacheObj;
class KAccel;
class KActionCollection;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//  flags to install and uninstall
class param
{
public:
  param(const TQString &nameP, bool initP,  bool invertP, const TQString &flagP);
  param(const TQString &nameP, bool initP,  bool invertP, const TQString &flagP, const TQString &flagAP);
  ~param();

  TQString name;  // Name of flag
  bool init;         // Initial value
  bool invert;       // Whether it needs to be inverted
  TQString flag; // text flag on command
  TQString flagA; // text flag on command
};

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
class pkgInterface: public TQObject
{
  Q_OBJECT
  

public:
  pkgInterface();
  virtual ~pkgInterface();

  virtual bool isType(char *buf, const TQString &fname) =  0;
  // looks at start of file to check that package is correct type

  virtual void makeMenu(KActionCollection* act);
  virtual void setMenu(KActionCollection* act, bool enable);

  bool ifExe(TQString exe);
  // Check if this executable exists
  
  virtual packageInfo *getPackageInfo(char mode, const TQString &name,
				      const TQString &version) =  0;
  // get info on installed or uninstalled package. version is only set if
  // mode is 'i' (ie, if the package is already installed).

  virtual TQStringList getFileList(packageInfo *p) =  0;
  // get list of files in the package

  virtual TQStringList depends(const TQString &name, int src);
  // check dependencies for package

  virtual TQStringList verify(packageInfo *p, const TQStringList &files);
  // check the installed files in a package

  virtual TQStringList FindFile(const TQString &name, bool seachAll=false) = 0;
  // search for packages containg a file

  virtual TQStringList getChangeLog(packageInfo *p) = 0;
  // Get change log

  virtual bool filesTab(packageInfo *p) = 0;
  // If files tab is to be enabled

  virtual bool changeTab(packageInfo *p) = 0;
  // If change log tab is to be enabled

  virtual bool parseName(const TQString &name, TQString *n, TQString *v) = 0;
  // breakup file name into package name and version

  virtual void listPackages(TQPtrList<packageInfo> *pki);
  // scan various locations for list of packages

  virtual void listInstalledPackages(TQPtrList<packageInfo> *pki) = 0;
  // produce list of currently installed packages

  virtual TQStringList  listInstalls(const TQStringList &packs, bool install, bool &cancel);
  // Convert list of packages requested to install to list of all packages to install

  virtual void smerge(packageInfo *p);
  // merge in package info entry

  TQString getDir(cacheObj *cp);
  // list directory local or remote

  void listDir(TQPtrList<packageInfo> *pki, const TQString &fname, const TQString &dir, bool subdirs = FALSE);
  // list the packages in a directory

  packageInfo *collectDir(const TQString &name, const TQString &size, const TQString &dir);
  // build packageInfo object from directory entry

  TQString getPackList(cacheObj *cp);
  // get packages information file

  virtual TQString  provMap(const TQString &p);
  // convert from package depends to package

  TQString setOptions(int flags, TQPtrList<param> &params);
  // convert un/install flags to text

  virtual TQString doUninstall(int uninstallFlags, const TQString &packs, bool &test);
  virtual TQString doInstall(int installFlags, const TQString &packs, bool &test);
  virtual TQString uninstall(int uninstallFlags, TQPtrList<packageInfo> *p,
				  bool &test);
  virtual TQString uninstall(int uninstallFlags, packageInfo *p,
				  bool &test);
  virtual TQString install(int installFlags, TQPtrList<packageInfo> *p,
				  bool &test);
  virtual TQString install(int installFlags, packageInfo *p,
				  bool &test);

  virtual TQStringList readApt();
  virtual void writeApt(const TQStringList &list);

  ///////////// DATA ///////////////////////
  pkgOptions *uninstallation, *installation;

  TQString icon;
  // name icon file
  TQString head;
  // capitalized name of package type
  TQString name;
  // More descriptive name
  TQPixmap pict, bad_pict, new_pict, updated_pict;
  // icons for package states
  TQPixmap folder;
  // icon for package group
  TQPixmap markInst;
  TQPixmap markUnInst;
  // icon indicating mark for install/uninstall

  Locations *locatedialog;
  // dialog for setting the locations of  uninstalled packages
  LcacheObj *packageLoc;
  // List of locations of uninstalled pacckages

  bool dirOK;
  // variables related to reading packages from directories

  TQString packagePattern;
  TQString queryMsg;
  TQString typeID;
  // Parameters for reading packages from directories

  TQPtrList<param> paramsInst;
  TQPtrList<param> paramsUninst;

  bool noFetch;
  // kpackage doesn't fetch this type of package itself

  bool defaultHandle;
  // This package type defaults to on

  TQString errExe;
  // The name of an executable that wasn't found

  TQString procMsg;
  // for running processes

  TQString DELMSG;

  bool hasRemote;
  // can access on remote host

  bool hasSearchAll;
  // can search uninstalled packages for files

  bool hasProgram;
  // the program needed to handle this package type is available

public slots:
  virtual void setLocation() = 0;
  virtual void setAvail(LcacheObj *) = 0;
};

#endif