summaryrefslogtreecommitdiff
authordrw <drw>2004-04-07 23:23:04 (UTC)
committer drw <drw>2004-04-07 23:23:04 (UTC)
commit0a21abab4eed64d17c4b1475569194117dab709c (patch) (unidiff)
treeb4f7cdf929202dd18db86916906e957658b8e1e9
parent52ccc71e2859ae9d738629249baeef3e3df992a2 (diff)
downloadopie-0a21abab4eed64d17c4b1475569194117dab709c.zip
opie-0a21abab4eed64d17c4b1475569194117dab709c.tar.gz
opie-0a21abab4eed64d17c4b1475569194117dab709c.tar.bz2
Added TODO doc and a couple minor updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/README2
-rw-r--r--noncore/settings/packagemanager/TODO28
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp7
3 files changed, 31 insertions, 6 deletions
diff --git a/noncore/settings/packagemanager/README b/noncore/settings/packagemanager/README
index 7b6305a..9324f9c 100644
--- a/noncore/settings/packagemanager/README
+++ b/noncore/settings/packagemanager/README
@@ -1,55 +1,55 @@
1/************************************************************************ 1/************************************************************************
2/* 2/*
3/* Opie - Package Manager 3/* Opie - Package Manager
4/* ======================== 4/* ========================
5/* Version 0.2.0 5/* Version 0.3.0
6/* 6/*
7/* A package management client for Opie 7/* A package management client for Opie
8/* 8/*
9/************************************************************************ 9/************************************************************************
10 10
11------------------------------------------------------- 11-------------------------------------------------------
12 Release Notes for Opie-PackageManager - January, 2004 12 Release Notes for Opie-PackageManager - January, 2004
13------------------------------------------------------- 13-------------------------------------------------------
14 14
15====================== 15======================
16= To-do = 16= To-do =
17====================== 17======================
18 18
19- See $OPIEDIR/noncore/settings/packagemanager/TODO for more info. 19- See $OPIEDIR/noncore/settings/packagemanager/TODO for more info.
20 20
21====================== 21======================
22= Build = 22= Build =
23====================== 23======================
24 24
25In order to build opie-packagemanager, libipkg needs to be present on 25In order to build opie-packagemanager, libipkg needs to be present on
26the build system along with the appropriate headers. 26the build system along with the appropriate headers.
27 27
28- libipkg source (best to use version 109 or greater): 28- libipkg source (best to use version 109 or greater):
29 - Familiar CVS directory: familiar/dist/ipkg/C (e.g. 'cvs co familiar/dist/ipkg/C') 29 - Familiar CVS directory: familiar/dist/ipkg/C (e.g. 'cvs co familiar/dist/ipkg/C')
30 - FTP: ftp://handhelds.org/linux/packages/ipkg 30 - FTP: ftp://handhelds.org/linux/packages/ipkg
31 31
32- before building opie-packagemanager, define the environmental variable 32- before building opie-packagemanager, define the environmental variable
33 IPKGDIR to point to the directory containing the ipkg source code 33 IPKGDIR to point to the directory containing the ipkg source code
34 - e.g. 'export IPKGDIR=$HOME/familiar/dist/ipkg/C' 34 - e.g. 'export IPKGDIR=$HOME/familiar/dist/ipkg/C'
35 35
36====================== 36======================
37= Run = 37= Run =
38====================== 38======================
39 39
40- In order to use opie-packagemanager, libipkg must be installed 40- In order to use opie-packagemanager, libipkg must be installed
41 on the system. 41 on the system.
42 42
43====================== 43======================
44= Credits = 44= Credits =
45====================== 45======================
46 46
47- Opie-PackageManager is (C) 2003-2004 Dan Williams 47- Opie-PackageManager is (C) 2003-2004 Dan Williams
48 48
49====================== 49======================
50= Links = 50= Links =
51====================== 51======================
52 52
53- Opie Project: http://opie.handhelds.org 53- Opie Project: http://opie.handhelds.org
54- OpenZaurus Project: http://openzaurus.org 54- OpenZaurus Project: http://openzaurus.org
55- Familiar Project: http://familiar.handhelds.org 55- Familiar Project: http://familiar.handhelds.org
diff --git a/noncore/settings/packagemanager/TODO b/noncore/settings/packagemanager/TODO
new file mode 100644
index 0000000..448ade3
--- a/dev/null
+++ b/noncore/settings/packagemanager/TODO
@@ -0,0 +1,28 @@
1/************************************************************************
2/*
3/* Opie - Package Manager
4/* ========================
5/* Version 0.3.0
6/*
7/* A package management client for Opie
8/*
9/************************************************************************
10
11---------------------------------------------
12 To-do for Opie-PackageManager - April, 2004
13---------------------------------------------
14
15======================
16= Current release =
17======================
18
191. Save configuration information (i.e. /etc/ipkg.conf)
202. Link non-root destination apps
213. Implement QCOP interface for installing, removing, etc.
224. Redesign configuration dialog
23
24======================
25= Future releases =
26======================
27
281. ??? \ No newline at end of file
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 1dc23a4..5c79ba9 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,509 +1,506 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkg.h" 32#include "oipkg.h"
33 33
34#include <stdlib.h> 34#include <stdlib.h>
35#include <string.h> 35#include <string.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qmessagebox.h>
40#include <qtextstream.h> 39#include <qtextstream.h>
41 40
42const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 41const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
43const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 42const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
44const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 43const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
45const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 44const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
46 45
47OIpkg *oipkg; 46OIpkg *oipkg;
48 47
49// Ipkg callback functions 48// Ipkg callback functions
50 49
51int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) 50int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
52{ 51{
53 oipkg->ipkgMessage( msg ); 52 oipkg->ipkgMessage( msg );
54 return 0; 53 return 0;
55} 54}
56 55
57char *fIpkgResponse( char */*question*/ ) 56char *fIpkgResponse( char */*question*/ )
58{ 57{
59 return 0x0; 58 return 0x0;
60} 59}
61 60
62int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 61int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
63{ 62{
64 oipkg->ipkgStatus( desc ); 63 oipkg->ipkgStatus( desc );
65 return 0; 64 return 0;
66} 65}
67 66
68int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 67int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
69 void */*userdata*/ ) 68 void */*userdata*/ )
70{ 69{
71 oipkg->ipkgList( desc ); 70 oipkg->ipkgList( desc );
72 return 0; 71 return 0;
73} 72}
74 73
75OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 74OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
76 : QObject( parent, name ) 75 : QObject( parent, name )
77 , m_config( config ) 76 , m_config( config )
78 , m_confInfo( NULL ) 77 , m_confInfo( NULL )
79 , m_ipkgExecOptions( 0 ) 78 , m_ipkgExecOptions( 0 )
80 , m_ipkgExecVerbosity( 1 ) 79 , m_ipkgExecVerbosity( 1 )
81{ 80{
82 oipkg = this; 81 oipkg = this;
83 82
84 // Initialize libipkg 83 // Initialize libipkg
85 if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) 84 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
86 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
87 85
88 // Default ipkg run-time arguments 86 // Default ipkg run-time arguments
89 m_ipkgArgs.noaction = false; 87 m_ipkgArgs.noaction = false;
90 m_ipkgArgs.force_defaults = true; 88 m_ipkgArgs.force_defaults = true;
91} 89}
92 90
93OIpkg::~OIpkg() 91OIpkg::~OIpkg()
94{ 92{
95 // Upon destruction, ensure that items in config list are deleted with list 93 // Upon destruction, ensure that items in config list are deleted with list
96 if ( m_confInfo ) 94 if ( m_confInfo )
97 m_confInfo->setAutoDelete( true ); 95 m_confInfo->setAutoDelete( true );
98 96
99 // Free up libipkg resources 97 // Free up libipkg resources
100 if ( ipkg_deinit( &m_ipkgArgs ) ) 98 ipkg_deinit( &m_ipkgArgs );
101 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) );
102} 99}
103 100
104OConfItemList *OIpkg::configItems() 101OConfItemList *OIpkg::configItems()
105{ 102{
106 // Retrieve all configuration items 103 // Retrieve all configuration items
107 return filterConfItems(); 104 return filterConfItems();
108} 105}
109 106
110OConfItemList *OIpkg::servers() 107OConfItemList *OIpkg::servers()
111{ 108{
112 // Retrieve only servers 109 // Retrieve only servers
113 return filterConfItems( OConfItem::Source ); 110 return filterConfItems( OConfItem::Source );
114} 111}
115 112
116OConfItemList *OIpkg::destinations() 113OConfItemList *OIpkg::destinations()
117{ 114{
118 // Retrieve only destinations 115 // Retrieve only destinations
119 return filterConfItems( OConfItem::Destination ); 116 return filterConfItems( OConfItem::Destination );
120} 117}
121 118
122OConfItemList *OIpkg::options() 119OConfItemList *OIpkg::options()
123{ 120{
124 // Retrieve only destinations 121 // Retrieve only destinations
125 return filterConfItems( OConfItem::Option ); 122 return filterConfItems( OConfItem::Option );
126} 123}
127 124
128void OIpkg::setConfigItems( OConfItemList *configList ) 125void OIpkg::setConfigItems( OConfItemList *configList )
129{ 126{
130 if ( m_confInfo ) 127 if ( m_confInfo )
131 delete m_confInfo; 128 delete m_confInfo;
132 129
133 m_confInfo = configList; 130 m_confInfo = configList;
134} 131}
135 132
136void OIpkg::saveSettings() 133void OIpkg::saveSettings()
137{ 134{
138 // Save Ipkg execution options to application configuration file 135 // Save Ipkg execution options to application configuration file
139 if ( m_config ) 136 if ( m_config )
140 { 137 {
141 m_config->setGroup( "Ipkg" ); 138 m_config->setGroup( "Ipkg" );
142 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 139 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
143 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 140 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
144 } 141 }
145} 142}
146 143
147OPackageList *OIpkg::availablePackages( const QString &server ) 144OPackageList *OIpkg::availablePackages( const QString &server )
148{ 145{
149 // Load Ipkg configuration info if not already cached 146 // Load Ipkg configuration info if not already cached
150 if ( !m_confInfo ) 147 if ( !m_confInfo )
151 loadConfiguration(); 148 loadConfiguration();
152 149
153 // Build new server list (caller is responsible for deleting) 150 // Build new server list (caller is responsible for deleting)
154 OPackageList *pl = new OPackageList; 151 OPackageList *pl = new OPackageList;
155 152
156 // Open package list file 153 // Open package list file
157 QFile f( IPKG_PKG_PATH + "/" + server ); 154 QFile f( IPKG_PKG_PATH + "/" + server );
158 if ( !f.open( IO_ReadOnly ) ) 155 if ( !f.open( IO_ReadOnly ) )
159 return NULL; 156 return NULL;
160 QTextStream t( &f ); 157 QTextStream t( &f );
161 158
162 // Process all information in package list file 159 // Process all information in package list file
163 OPackage *package = NULL; 160 OPackage *package = NULL;
164 QString line = t.readLine(); 161 QString line = t.readLine();
165 while ( !t.eof() ) 162 while ( !t.eof() )
166 { 163 {
167 // Determine key/value pair 164 // Determine key/value pair
168 int pos = line.find( ':', 0 ); 165 int pos = line.find( ':', 0 );
169 QString key; 166 QString key;
170 if ( pos > -1 ) 167 if ( pos > -1 )
171 key = line.mid( 0, pos ); 168 key = line.mid( 0, pos );
172 else 169 else
173 key = QString::null; 170 key = QString::null;
174 QString value = line.mid( pos+2, line.length()-pos ); 171 QString value = line.mid( pos+2, line.length()-pos );
175 172
176 // Allocate new package and insert into list 173 // Allocate new package and insert into list
177 if ( package == NULL && !key.isEmpty() ) 174 if ( package == NULL && !key.isEmpty() )
178 { 175 {
179 package = new OPackage( value ); 176 package = new OPackage( value );
180 package->setSource( server ); 177 package->setSource( server );
181 pl->append( package ); 178 pl->append( package );
182 } 179 }
183 180
184 // Update package data 181 // Update package data
185 if ( key == "Package" ) 182 if ( key == "Package" )
186 package->setName( value ); 183 package->setName( value );
187 else if ( key == "Version" ) 184 else if ( key == "Version" )
188 package->setVersion( value ); 185 package->setVersion( value );
189 else if ( key == "Section" ) 186 else if ( key == "Section" )
190 package->setCategory( value ); 187 package->setCategory( value );
191 //DataManager::setAvailableCategories( value ); 188 //DataManager::setAvailableCategories( value );
192 else if ( key.isEmpty() && value.isEmpty() ) 189 else if ( key.isEmpty() && value.isEmpty() )
193 package = NULL; 190 package = NULL;
194 191
195 // Skip past all description lines 192 // Skip past all description lines
196 if ( key == "Description" ) 193 if ( key == "Description" )
197 { 194 {
198 line = t.readLine(); 195 line = t.readLine();
199 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 196 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
200 line = t.readLine(); 197 line = t.readLine();
201 } 198 }
202 else 199 else
203 line = t.readLine(); 200 line = t.readLine();
204 } 201 }
205 202
206 f.close(); 203 f.close();
207 204
208 return pl; 205 return pl;
209} 206}
210 207
211OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 208OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
212{ 209{
213 // Load Ipkg configuration info if not already cached 210 // Load Ipkg configuration info if not already cached
214 if ( !m_confInfo ) 211 if ( !m_confInfo )
215 loadConfiguration(); 212 loadConfiguration();
216 213
217 // Build new server list (caller is responsible for deleting) 214 // Build new server list (caller is responsible for deleting)
218 OPackageList *pl = new OPackageList; 215 OPackageList *pl = new OPackageList;
219 216
220 // Open status file 217 // Open status file
221 QString path = destPath; 218 QString path = destPath;
222 if ( path.right( 1 ) != "/" ) 219 if ( path.right( 1 ) != "/" )
223 path.append( "/" ); 220 path.append( "/" );
224 path.append( IPKG_STATUS_PATH ); 221 path.append( IPKG_STATUS_PATH );
225 222
226 QFile f( path ); 223 QFile f( path );
227 if ( !f.open( IO_ReadOnly ) ) 224 if ( !f.open( IO_ReadOnly ) )
228 return NULL; 225 return NULL;
229 QTextStream t( &f ); 226 QTextStream t( &f );
230 227
231 // Process all information in status file 228 // Process all information in status file
232 bool newPackage = false; 229 bool newPackage = false;
233 QString line = t.readLine(); 230 QString line = t.readLine();
234 QString name; 231 QString name;
235 QString version; 232 QString version;
236 QString status; 233 QString status;
237 234
238 while ( !t.eof() ) 235 while ( !t.eof() )
239 { 236 {
240 // Determine key/value pair 237 // Determine key/value pair
241 int pos = line.find( ':', 0 ); 238 int pos = line.find( ':', 0 );
242 QString key; 239 QString key;
243 if ( pos > -1 ) 240 if ( pos > -1 )
244 key = line.mid( 0, pos ); 241 key = line.mid( 0, pos );
245 else 242 else
246 key = QString::null; 243 key = QString::null;
247 QString value = line.mid( pos+2, line.length()-pos ); 244 QString value = line.mid( pos+2, line.length()-pos );
248 245
249 // Allocate new package and insert into list 246 // Allocate new package and insert into list
250 if ( newPackage && !key.isEmpty() ) 247 if ( newPackage && !key.isEmpty() )
251 { 248 {
252 // Add to list only if it has a valid name and is installed 249 // Add to list only if it has a valid name and is installed
253 if ( !name.isNull() && status.contains( " installed" ) ) 250 if ( !name.isNull() && status.contains( " installed" ) )
254 { 251 {
255 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 252 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
256 name = QString::null; 253 name = QString::null;
257 version = QString::null; 254 version = QString::null;
258 status = QString::null; 255 status = QString::null;
259 256
260 newPackage = false; 257 newPackage = false;
261 } 258 }
262 } 259 }
263 260
264 // Update package data 261 // Update package data
265 if ( key == "Package" ) 262 if ( key == "Package" )
266 name = value; 263 name = value;
267 else if ( key == "Version" ) 264 else if ( key == "Version" )
268 version = value; 265 version = value;
269 else if ( key == "Status" ) 266 else if ( key == "Status" )
270 status = value; 267 status = value;
271 else if ( key.isEmpty() && value.isEmpty() ) 268 else if ( key.isEmpty() && value.isEmpty() )
272 newPackage = true; 269 newPackage = true;
273 270
274 // Skip past all description lines 271 // Skip past all description lines
275 if ( key == "Description" ) 272 if ( key == "Description" )
276 { 273 {
277 line = t.readLine(); 274 line = t.readLine();
278 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 275 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
279 line = t.readLine(); 276 line = t.readLine();
280 } 277 }
281 else 278 else
282 line = t.readLine(); 279 line = t.readLine();
283 } 280 }
284 281
285 f.close(); 282 f.close();
286 283
287 return pl; 284 return pl;
288} 285}
289 286
290bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 287bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
291 const QObject *receiver, const char *slotOutput, bool rawOutput ) 288 const QObject *receiver, const char *slotOutput, bool rawOutput )
292{ 289{
293 if ( command == OPackage::NotDefined ) 290 if ( command == OPackage::NotDefined )
294 return false; 291 return false;
295 292
296 // Set ipkg run-time options/arguments 293 // Set ipkg run-time options/arguments
297 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 294 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
298 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 295 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
299 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 296 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
300 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 297 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
301 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 298 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
302 if ( m_ipkgArgs.dest ) 299 if ( m_ipkgArgs.dest )
303 free( m_ipkgArgs.dest ); 300 free( m_ipkgArgs.dest );
304 if ( !destination.isNull() ) 301 if ( !destination.isNull() )
305 { 302 {
306 int len = destination.length() + 1; 303 int len = destination.length() + 1;
307 m_ipkgArgs.dest = (char *)malloc( len ); 304 m_ipkgArgs.dest = (char *)malloc( len );
308 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 305 strncpy( m_ipkgArgs.dest, destination, destination.length() );
309 m_ipkgArgs.dest[ len - 1 ] = '\0'; 306 m_ipkgArgs.dest[ len - 1 ] = '\0';
310 } 307 }
311 else 308 else
312 m_ipkgArgs.dest = 0x0; 309 m_ipkgArgs.dest = 0x0;
313 310
314 // Connect output signal to widget 311 // Connect output signal to widget
315 312
316 if ( rawOutput ) 313 if ( rawOutput )
317 { 314 {
318// if ( slotOutput ) 315// if ( slotOutput )
319// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 316// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
320 } 317 }
321 else 318 else
322 { 319 {
323 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 320 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
324 } 321 }
325 322
326 switch( command ) 323 switch( command )
327 { 324 {
328 case OPackage::Update : { 325 case OPackage::Update : {
329 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 326 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
330 ipkg_lists_update( &m_ipkgArgs ); 327 ipkg_lists_update( &m_ipkgArgs );
331 }; 328 };
332 break; 329 break;
333 case OPackage::Upgrade : { 330 case OPackage::Upgrade : {
334 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 331 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
335 ipkg_packages_upgrade( &m_ipkgArgs ); 332 ipkg_packages_upgrade( &m_ipkgArgs );
336 }; 333 };
337 break; 334 break;
338 case OPackage::Install : { 335 case OPackage::Install : {
339 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 336 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
340 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 337 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
341 { 338 {
342 ipkg_packages_install( &m_ipkgArgs, (*it) ); 339 ipkg_packages_install( &m_ipkgArgs, (*it) );
343 } 340 }
344 }; 341 };
345 break; 342 break;
346 case OPackage::Remove : { 343 case OPackage::Remove : {
347 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 344 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
348 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 345 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
349 { 346 {
350 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 347 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
351 } 348 }
352 }; 349 };
353 break; 350 break;
354 case OPackage::Download : { 351 case OPackage::Download : {
355 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 352 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
356 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 353 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
357 { 354 {
358 ipkg_packages_download( &m_ipkgArgs, (*it) ); 355 ipkg_packages_download( &m_ipkgArgs, (*it) );
359 } 356 }
360 }; 357 };
361 break; 358 break;
362 case OPackage::Info : { 359 case OPackage::Info : {
363 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); 360 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
364 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); 361 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
365 }; 362 };
366 break; 363 break;
367 case OPackage::Files : { 364 case OPackage::Files : {
368 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); 365 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
369 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); 366 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
370 }; 367 };
371 break; 368 break;
372 default : break; 369 default : break;
373 }; 370 };
374 371
375 return true; 372 return true;
376} 373}
377 374
378void OIpkg::ipkgMessage( char *msg ) 375void OIpkg::ipkgMessage( char *msg )
379{ 376{
380 emit signalIpkgMessage( msg ); 377 emit signalIpkgMessage( msg );
381} 378}
382 379
383void OIpkg::ipkgStatus( char *status ) 380void OIpkg::ipkgStatus( char *status )
384{ 381{
385 emit signalIpkgStatus( status ); 382 emit signalIpkgStatus( status );
386} 383}
387 384
388void OIpkg::ipkgList( char *filelist ) 385void OIpkg::ipkgList( char *filelist )
389{ 386{
390 emit signalIpkgList( filelist ); 387 emit signalIpkgList( filelist );
391} 388}
392 389
393void OIpkg::loadConfiguration() 390void OIpkg::loadConfiguration()
394{ 391{
395 if ( m_confInfo ) 392 if ( m_confInfo )
396 delete m_confInfo; 393 delete m_confInfo;
397 394
398 // Load configuration item list 395 // Load configuration item list
399 m_confInfo = new OConfItemList(); 396 m_confInfo = new OConfItemList();
400 397
401 QStringList confFiles; 398 QStringList confFiles;
402 QDir confDir( IPKG_CONF_DIR ); 399 QDir confDir( IPKG_CONF_DIR );
403 if ( confDir.exists() ) 400 if ( confDir.exists() )
404 { 401 {
405 confDir.setNameFilter( "*.conf" ); 402 confDir.setNameFilter( "*.conf" );
406 confDir.setFilter( QDir::Files ); 403 confDir.setFilter( QDir::Files );
407 confFiles = confDir.entryList( "*.conf", QDir::Files ); 404 confFiles = confDir.entryList( "*.conf", QDir::Files );
408 confFiles << IPKG_CONF; 405 confFiles << IPKG_CONF;
409 406
410 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) 407 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
411 { 408 {
412 // Create absolute file path if necessary 409 // Create absolute file path if necessary
413 QString absFile = (*it); 410 QString absFile = (*it);
414 if ( !absFile.startsWith( "/" ) ) 411 if ( !absFile.startsWith( "/" ) )
415 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 412 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
416 413
417 // Read in file 414 // Read in file
418 QFile f( absFile ); 415 QFile f( absFile );
419 if ( f.open( IO_ReadOnly ) ) 416 if ( f.open( IO_ReadOnly ) )
420 { 417 {
421 QTextStream s( &f ); 418 QTextStream s( &f );
422 while ( !s.eof() ) 419 while ( !s.eof() )
423 { 420 {
424 421
425 QString line = s.readLine().simplifyWhiteSpace(); 422 QString line = s.readLine().simplifyWhiteSpace();
426 423
427 // Parse line and save info to the conf options list 424 // Parse line and save info to the conf options list
428 if ( !line.isEmpty() ) 425 if ( !line.isEmpty() )
429 { 426 {
430 if ( !line.startsWith( "#" ) || 427 if ( !line.startsWith( "#" ) ||
431 line.startsWith( "#src" ) || 428 line.startsWith( "#src" ) ||
432 line.startsWith( "#dest" ) || 429 line.startsWith( "#dest" ) ||
433 line.startsWith( "#arch" ) || 430 line.startsWith( "#arch" ) ||
434 line.startsWith( "#option" ) ) 431 line.startsWith( "#option" ) )
435 { 432 {
436 int pos = line.find( ' ', 1 ); 433 int pos = line.find( ' ', 1 );
437 434
438 // Type 435 // Type
439 QString typeStr = line.left( pos ); 436 QString typeStr = line.left( pos );
440 OConfItem::Type type; 437 OConfItem::Type type;
441 if ( typeStr == "src" || typeStr == "#src" ) 438 if ( typeStr == "src" || typeStr == "#src" )
442 type = OConfItem::Source; 439 type = OConfItem::Source;
443 else if ( typeStr == "dest" || typeStr == "#dest" ) 440 else if ( typeStr == "dest" || typeStr == "#dest" )
444 type = OConfItem::Destination; 441 type = OConfItem::Destination;
445 else if ( typeStr == "option" || typeStr == "#option" ) 442 else if ( typeStr == "option" || typeStr == "#option" )
446 type = OConfItem::Option; 443 type = OConfItem::Option;
447 else if ( typeStr == "arch" || typeStr == "#arch" ) 444 else if ( typeStr == "arch" || typeStr == "#arch" )
448 type = OConfItem::Arch; 445 type = OConfItem::Arch;
449 else 446 else
450 type = OConfItem::NotDefined; 447 type = OConfItem::NotDefined;
451 ++pos; 448 ++pos;
452 int endpos = line.find( ' ', pos ); 449 int endpos = line.find( ' ', pos );
453 450
454 // Name 451 // Name
455 QString name = line.mid( pos, endpos - pos ); 452 QString name = line.mid( pos, endpos - pos );
456 453
457 // Value 454 // Value
458 QString value = ""; 455 QString value = "";
459 if ( endpos > -1 ) 456 if ( endpos > -1 )
460 value = line.right( line.length() - endpos - 1 ); 457 value = line.right( line.length() - endpos - 1 );
461 458
462 // Active 459 // Active
463 bool active = !line.startsWith( "#" ); 460 bool active = !line.startsWith( "#" );
464 461
465 // Add to list 462 // Add to list
466 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); 463 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) );
467 } 464 }
468 } 465 }
469 } 466 }
470 467
471 f.close(); 468 f.close();
472 } 469 }
473 } 470 }
474 } 471 }
475 472
476 // Load Ipkg execution options from application configuration file 473 // Load Ipkg execution options from application configuration file
477 if ( m_config ) 474 if ( m_config )
478 { 475 {
479 m_config->setGroup( "Ipkg" ); 476 m_config->setGroup( "Ipkg" );
480 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 477 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
481 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 478 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
482 } 479 }
483} 480}
484 481
485OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 482OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
486{ 483{
487 // Load Ipkg configuration info if not already cached 484 // Load Ipkg configuration info if not already cached
488 if ( !m_confInfo ) 485 if ( !m_confInfo )
489 loadConfiguration(); 486 loadConfiguration();
490 487
491 // Build new server list (caller is responsible for deleting) 488 // Build new server list (caller is responsible for deleting)
492 OConfItemList *sl = new OConfItemList; 489 OConfItemList *sl = new OConfItemList;
493 490
494 // If typefilter is empty, retrieve all items 491 // If typefilter is empty, retrieve all items
495 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 492 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
496 493
497 // Parse configuration info for servers 494 // Parse configuration info for servers
498 OConfItemListIterator it( *m_confInfo ); 495 OConfItemListIterator it( *m_confInfo );
499 for ( ; it.current(); ++it ) 496 for ( ; it.current(); ++it )
500 { 497 {
501 OConfItem *item = it.current(); 498 OConfItem *item = it.current();
502 if ( retrieveAll || item->type() == typefilter ) 499 if ( retrieveAll || item->type() == typefilter )
503 { 500 {
504 sl->append( item ); 501 sl->append( item );
505 } 502 }
506 } 503 }
507 504
508 return sl; 505 return sl;
509} 506}