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
|
// pkg_info_screen.cc
//
// Copyright 2000-2002, 2004-2005 Daniel Burrows
//
// 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; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// Gathers information about a package into one
// spot (pkg_grouppolicy_info*) and provides dedicated code to display
// it (pkg_info_screen)
#include "aptitude.h"
#include "pkg_info_screen.h"
#include "vscreen/fragment.h"
#include "vscreen/vs_layout_item.h"
#include "dep_item.h"
#include "desc_parse.h"
#include "pkg_item_with_subtree.h"
#include "pkg_subtree.h"
#include "pkg_ver_item.h"
#include "trust.h"
#include <generic/apt/apt.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/strutl.h>
class pkg_grouppolicy_info:public pkg_grouppolicy
{
public:
pkg_grouppolicy_info(pkg_signal *_sig,
desc_signal *_desc_sig)
:pkg_grouppolicy(_sig, _desc_sig) {}
void add_package(const pkgCache::PkgIterator &pkg, pkg_subtree *root);
static void setup_package_info(const pkgCache::PkgIterator &pkg,
const pkgCache::VerIterator &ver,
pkg_item_with_generic_subtree *tree,
pkg_signal *sig);
};
void pkg_grouppolicy_info::add_package(const pkgCache::PkgIterator &pkg,
pkg_subtree *root)
{
pkg_item_with_generic_subtree *newtree=new pkg_item_with_generic_subtree(pkg,
get_sig(),
true);
setup_package_info(pkg, pkg_item::visible_version(pkg), newtree, get_sig());
root->add_child(newtree);
}
void pkg_grouppolicy_info::setup_package_info(const pkgCache::PkgIterator &pkg,
const pkgCache::VerIterator &ver,
pkg_item_with_generic_subtree *tree,
pkg_signal *sig)
{
char buf[256];
if(!ver.end())
{
pkgRecords::Parser &rec=apt_package_records->Lookup(ver.FileList());
string desc=apt_package_records->Lookup(ver.FileList()).LongDesc();
string shortdesc=string(desc, 0, desc.find('\n'));
vector<fragment*> frags;
fragment *untrusted_warning=make_untrusted_warning(ver);
if(untrusted_warning != NULL)
{
frags.push_back(untrusted_warning);
frags.push_back(newline_fragment());
}
// Avoid creating new strings to translate.
frags.push_back(clipbox(fragf("%B%s%b%s%n",
_("Description: "), shortdesc.c_str())));
frags.push_back(indentbox(2, 2, make_desc_fragment(transcode(desc))));
fragment *tags = make_tags_fragment(pkg);
if(tags != NULL)
frags.push_back(fragf("%n%F", tags));
// Can I use something other than a clipbox below?
if((pkg->Flags&pkgCache::Flag::Essential)==pkgCache::Flag::Essential ||
(pkg->Flags&pkgCache::Flag::Important)==pkgCache::Flag::Important)
frags.push_back(clipbox(fragf("%B%s%b%s",
_("Essential: "), _("yes"))));
frags.push_back(clipbox(fragf("%B%s%b%s%n"
"%B%s%b%s%n"
"%B%s%b%s%n"
"%B%s%b%s%n"
"%B%s%b%s%n"
"%B%s%b%s%n",
_("Priority: "),pkgCache::VerIterator(ver).PriorityType()?pkgCache::VerIterator(ver).PriorityType():_("Unknown"),
_("Section: "),pkg.Section()?pkg.Section():_("Unknown"),
_("Maintainer: "),rec.Maintainer().c_str(),
_("Compressed size: "), SizeToStr(ver->Size).c_str(),
_("Uncompressed size: "), SizeToStr(ver->InstalledSize).c_str(),
_("Source Package: "),
rec.SourcePkg().empty()?pkg.Name():rec.SourcePkg().c_str())));
tree->add_child(new vs_layout_item(sequence_fragment(frags)));
setup_package_deps<pkg_item_with_generic_subtree>(pkg, ver, tree, sig);
// Note: reverse provides show up in the version list
if(!ver.ProvidesList().end())
{
snprintf(buf, 256, _("Package names provided by %s"), pkg.Name());
pkg_subtree *prvtree=new pkg_subtree(transcode(buf));
for(pkgCache::PrvIterator prv=ver.ProvidesList(); !prv.end(); ++prv)
prvtree->add_child(new pkg_item(prv.ParentPkg(), sig));
tree->add_child(prvtree);
}
}
snprintf(buf, 256, _("Packages which depend on %s"), pkg.Name());
pkg_subtree *revtree=new pkg_subtree(transcode(buf));
setup_package_deps<pkg_subtree>(pkg, ver, revtree, sig, true);
tree->add_child(revtree);
pkg_vertree_generic *newtree=new pkg_vertree_generic(transcode(_("Versions")), true);
setup_package_versions(pkg, newtree, sig);
tree->add_child(newtree);
}
pkg_info_screen::pkg_info_screen(const pkgCache::PkgIterator &pkg,
const pkgCache::VerIterator &ver)
:apt_info_tree(pkg.Name(), ver.end()?"":ver.VerStr())
{
set_root(setup_new_root(pkg, ver), true);
}
vs_treeitem *pkg_info_screen::setup_new_root(const pkgCache::PkgIterator &pkg,
const pkgCache::VerIterator &ver)
{
pkg_item_with_generic_subtree *tree=new pkg_item_with_generic_subtree(pkg,
get_sig(),
true);
pkg_grouppolicy_info::setup_package_info(pkg, ver, tree, get_sig());
return tree;
}
|