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
|
/*
** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
**
// Author: Damyan Pepper
//
// This file contains the definition of the class packageInfo
//
// packageInfo is used to store information regarding an package.
// This information is normally gained by querying the database or
// by querying an package.
//
// The package information consists of a set of properties. These
// properties are stored in a dictionary that is passed to the
// constructor. The properties can be accessed using the function
// `getProperty'.
//
// In addition, packageInfo objects can place themselves inside
// a tree list with the function `place'. Doing this creates
// a tree list item object that can be accessed with the function
// `item'.
*/
/*
** 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 PACKAGEINFO_H
#define PACKAGEINFO_H
#include "../config.h"
#include <qmap.h>
#include <qdict.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qptrlist.h>
#include <qlistview.h>
class pkgInterface;
class KpTreeListItem;
class KpTreeList;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
class packageInfo
{
public:
packageInfo(QMap<QString, QString> _info, pkgInterface *type);
// Constructor: create a packageInfo object using the property
// dictionary from _info
packageInfo(QMap<QString, QString> _info, const QString &_filename);
// Constructor: same as above, but also sets filename to _filename.
// This is used in the case that the package info was obtained from
// an uninstalled package.
~packageInfo();
// Distructor
/**
* Look ups the property `property' from the dictionary
*/
QString getProperty(const QString &property);
/**
* Checks whether the property `property' is defined in the dictionary
*/
bool hasProperty(const QString &property);
void fixup();
// Initialize fields if missing
KpTreeListItem *place(KpTreeList *tree, bool InsertI=FALSE);
// places the object in the treelist `tree' and initialises
// `item'. If necessary, new groups will be added to `tree'.
KpTreeListItem *getItem();
// returns the treelist item object for this package or
// NULL if the object hasn't been placed
void setFilename(const QString &f);
QString getUrl();
// return URL of package file
bool isFileLocal();
// True if package file is local or cached file
bool isInstallable();
// True if package can be installed
bool isFetchable();
// True if package needs to be fetched
QString getFilename();
QString fetchFilename();
// gets the filename, fetching package if necessary
int newer(packageInfo *p);
// if package p is newer
void pkgFileIns(const QString &fileName);
// Insert a package from a file into package tree
bool pkgInsert(QPtrList<packageInfo> *pki, const QString &exp, bool installed,
bool infoPackage = FALSE);
// insert packgeInfo either installed or not installed
QMap<QString, QString> info;
// This stores the property dictionary of the package
KpTreeListItem *item;
// This stores the tree list item for this package (or NULL if
// the package hasn't been placed in a tree list)
pkgInterface *interface;
// interface points to the class of the package (deb, rpm etc)
bool smerge( const QString &exp);
// merge with already existing NOLIST package info
bool display(int treeType);
// if this package is to be should in the tree list
enum {UNSET, AVAILABLE, INSTALLED, BAD_INSTALL, UPDATED,
NEW, NOLIST, HIDDEN};
int packageState;
bool updated;
private:
int getDigElement(const QString &s, int *pos);
QString getNdigElement(const QString &s, int *pos);
// break up version string
int pnewer(const QString &s, const QString &sp);
// compare parts of a version string
QString url;
// This stores the filename of the package the info was obtained from.
// If it is empty then the info was obtained from an installed package.
};
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#endif
|