summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/packagelist.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/packagelist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp87
1 files changed, 19 insertions, 68 deletions
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 035ec81..b892b30 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,39 +1,25 @@
1#include "packagelist.h" 1#include "packagelist.h"
2 2
3#include <assert.h> 3#include <assert.h>
4#include <qfile.h> 4#include <qfile.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7#include <qpe/config.h>
8 7
9#include "debug.h" 8#include "debug.h"
10 9
11PackageList::PackageList() 10PackageList::PackageList()
12 : packageIter( packageList ) 11 : packageIter( packageList )
13{ 12{
14 empty=true; 13 empty=true;
15 {
16 Config cfg( "oipkg", Config::User );
17 cfg.setGroup( "Common" );
18 statusDir = cfg.readEntry( "statusDir", "" );
19 listsDir = cfg.readEntry( "listsDir", "" );
20 if ( statusDir=="" || ! QFileInfo(statusDir+"/status").isFile() )
21 {
22 statusDir="/usr/lib/ipkg/";
23 listsDir="/usr/lib/ipkg/lists/";
24 cfg.writeEntry( "statusDir", statusDir );
25 cfg.writeEntry( "listsDir", listsDir );
26 }
27 }
28 sections << "All"; 14 sections << "All";
29 subSections.insert("All", new QStringList() ); 15 subSections.insert("All", new QStringList() );
30 QStringList *ss = subSections["All"]; 16 QStringList *ss = subSections["All"];
31 *ss << "All"; 17 *ss << "All";
32 aktSection = "All"; 18 aktSection = "All";
33 aktSubSection = "All"; 19 aktSubSection = "All";
34} 20}
35 21
36PackageList::PackageList( PackageManagerSettings* s) 22PackageList::PackageList( PackageManagerSettings* s)
37 : packageIter( packageList ) 23 : packageIter( packageList )
38{ 24{
39 settings = s; 25 settings = s;
@@ -136,89 +122,54 @@ void PackageList::updateSections( Package* pack )
136 subSections.insert( s, new QStringList() ); 122 subSections.insert( s, new QStringList() );
137 QStringList *subsecs = subSections[s]; 123 QStringList *subsecs = subSections[s];
138 *subsecs += "All"; 124 *subsecs += "All";
139 } 125 }
140 QStringList *subsecs = subSections[s]; 126 QStringList *subsecs = subSections[s];
141 *subsecs += ss; 127 *subsecs += ss;
142 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); 128 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
143 subsecs = subSections["All"]; 129 subsecs = subSections["All"];
144 *subsecs += ss; 130 *subsecs += ss;
145} 131}
146 132
147 133
148
149/** No descriptions */
150void PackageList::parseStatus()
151{
152 QStringList dests = settings->getDestinationUrls();
153 QStringList destnames = settings->getDestinationNames();
154 QStringList::Iterator name = destnames.begin();
155 for ( QStringList::Iterator dir = dests.begin(); dir != dests.end(); ++dir )
156 {
157 pvDebug( 2,"Status: "+*dir+statusDir+"/status");
158 readFileEntries( *dir+statusDir+"/status", *name );
159 ++name;
160 };
161}
162
163void PackageList::parseList()
164{
165 QStringList srvs = settings->getActiveServers();
166
167 for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
168 {
169 pvDebug( 2, "List: "+listsDir+"/"+*it);
170 readFileEntries( listsDir+"/"+*it, "" );
171 }
172}
173
174void PackageList::readFileEntries( QString filename, QString dest ) 134void PackageList::readFileEntries( QString filename, QString dest )
175 { 135 {
136 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest);
176 QStringList packEntry; 137 QStringList packEntry;
177 QFile f( filename ); 138 QFile f( filename );
178 if ( !f.open(IO_ReadOnly) ) return; 139 if ( !f.open(IO_ReadOnly) ) return;
179 QTextStream *statusStream = new QTextStream( &f ); 140 QTextStream *statusStream = new QTextStream( &f );
180 while ( !statusStream ->eof() ) 141 while ( !statusStream ->eof() )
181 { 142 {
182 QString line = statusStream->readLine(); 143 QString line = statusStream->readLine();
183 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 144 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
184 { 145 {
185 //end of package 146 //end of package
186 if ( ! packEntry.isEmpty() ) 147 if ( ! packEntry.isEmpty() )
187 { 148 {
188 Package *p = new Package( packEntry, settings ); 149 Package *p = new Package( packEntry, settings );
189 p->setDest( dest ); 150 p->setDest( dest );
190 if ( p ) 151 if ( p )
191 { 152 {
192 insertPackage( p ); 153 insertPackage( p );
193 packEntry.clear(); 154 packEntry.clear();
194 } 155 }
195 } 156 }
196 }else{ 157 }else{
197 packEntry << line; 158 packEntry << line;
198 }; 159 };
199 } 160 }
200 return; 161 return;
201} 162}
202 163
203
204void PackageList::update()
205{
206 pvDebug( 2, "parseStatus");
207 parseStatus();
208 pvDebug( 2, "parseList");
209 parseList();
210 pvDebug( 2, "finished parsing");
211}
212
213void PackageList::setSettings( PackageManagerSettings *s ) 164void PackageList::setSettings( PackageManagerSettings *s )
214{ 165{
215 settings = s; 166 settings = s;
216} 167}
217 168
218Package* PackageList::getByName( QString n ) 169Package* PackageList::getByName( QString n )
219{ 170{
220 origPackageList[n]; 171 origPackageList[n];
221} 172}
222 173
223void PackageList::clear() 174void PackageList::clear()
224{ 175{