summaryrefslogtreecommitdiff
authordrw <drw>2005-03-22 22:57:07 (UTC)
committer drw <drw>2005-03-22 22:57:07 (UTC)
commit3011e3f1741057b9163c3658a8847c528da5da05 (patch) (unidiff)
treed4ddecfd5073465973cbeb92a3301a3247df5594
parent63d19f6ef6eeeb362323e3301daab03df1588faa (diff)
downloadopie-3011e3f1741057b9163c3658a8847c528da5da05.zip
opie-3011e3f1741057b9163c3658a8847c528da5da05.tar.gz
opie-3011e3f1741057b9163c3658a8847c528da5da05.tar.bz2
Disconnect signals after command executes to prevent bug where messages show up multiple times in install dialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 417ee95..127204d 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,806 +1,813 @@
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 <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39#include <unistd.h> 39#include <unistd.h>
40 40
41const 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
42const 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
43const 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
44const 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
45const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location 45const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location
46 46
47OIpkg *oipkg; 47OIpkg *oipkg;
48 48
49// Ipkg callback functions 49// Ipkg callback functions
50 50
51int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) 51int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg )
52{ 52{
53 // Display message only if it is below the message level threshold 53 // Display message only if it is below the message level threshold
54 if ( conf && ( conf->verbosity < level ) ) 54 if ( conf && ( conf->verbosity < level ) )
55 return 0; 55 return 0;
56 else 56 else
57 oipkg->ipkgMessage( msg ); 57 oipkg->ipkgMessage( msg );
58 58
59 return 0; 59 return 0;
60} 60}
61 61
62char *fIpkgResponse( char */*question*/ ) 62char *fIpkgResponse( char */*question*/ )
63{ 63{
64 return 0l; 64 return 0l;
65} 65}
66 66
67int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 67int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
68{ 68{
69 oipkg->ipkgStatus( desc ); 69 oipkg->ipkgStatus( desc );
70 return 0; 70 return 0;
71} 71}
72 72
73int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 73int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
74 void */*userdata*/ ) 74 void */*userdata*/ )
75{ 75{
76 oipkg->ipkgList( desc ); 76 oipkg->ipkgList( desc );
77 return 0; 77 return 0;
78} 78}
79 79
80OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 80OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
81 : QObject( parent, name ) 81 : QObject( parent, name )
82 , m_config( config ) 82 , m_config( config )
83 , m_confInfo( NULL ) 83 , m_confInfo( NULL )
84 , m_ipkgExecOptions( 0 ) 84 , m_ipkgExecOptions( 0 )
85 , m_ipkgExecVerbosity( 1 ) 85 , m_ipkgExecVerbosity( 1 )
86{ 86{
87 // Keep pointer to self for the Ipkg callback functions 87 // Keep pointer to self for the Ipkg callback functions
88 oipkg = this; 88 oipkg = this;
89 89
90 // Initialize libipkg 90 // Initialize libipkg
91 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 91 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
92 92
93 // Default ipkg run-time arguments 93 // Default ipkg run-time arguments
94 m_ipkgArgs.noaction = false; 94 m_ipkgArgs.noaction = false;
95 m_ipkgArgs.force_defaults = true; 95 m_ipkgArgs.force_defaults = true;
96} 96}
97 97
98OIpkg::~OIpkg() 98OIpkg::~OIpkg()
99{ 99{
100 // Upon destruction, ensure that items in config list are deleted with list 100 // Upon destruction, ensure that items in config list are deleted with list
101 if ( m_confInfo ) 101 if ( m_confInfo )
102 m_confInfo->setAutoDelete( true ); 102 m_confInfo->setAutoDelete( true );
103 103
104 // Free up libipkg resources 104 // Free up libipkg resources
105 ipkg_deinit( &m_ipkgArgs ); 105 ipkg_deinit( &m_ipkgArgs );
106} 106}
107 107
108OConfItemList *OIpkg::configItems() 108OConfItemList *OIpkg::configItems()
109{ 109{
110 // Retrieve all configuration items 110 // Retrieve all configuration items
111 return filterConfItems(); 111 return filterConfItems();
112} 112}
113 113
114OConfItemList *OIpkg::servers() 114OConfItemList *OIpkg::servers()
115{ 115{
116 // Retrieve only servers 116 // Retrieve only servers
117 return filterConfItems( OConfItem::Source ); 117 return filterConfItems( OConfItem::Source );
118} 118}
119 119
120OConfItemList *OIpkg::destinations() 120OConfItemList *OIpkg::destinations()
121{ 121{
122 // Retrieve only destinations 122 // Retrieve only destinations
123 return filterConfItems( OConfItem::Destination ); 123 return filterConfItems( OConfItem::Destination );
124} 124}
125 125
126OConfItemList *OIpkg::options() 126OConfItemList *OIpkg::options()
127{ 127{
128 // Retrieve only destinations 128 // Retrieve only destinations
129 return filterConfItems( OConfItem::Option ); 129 return filterConfItems( OConfItem::Option );
130} 130}
131 131
132void OIpkg::setConfigItems( OConfItemList *configList ) 132void OIpkg::setConfigItems( OConfItemList *configList )
133{ 133{
134 if ( m_confInfo ) 134 if ( m_confInfo )
135 delete m_confInfo; 135 delete m_confInfo;
136 136
137 m_confInfo = configList; 137 m_confInfo = configList;
138 138
139 // Write out new /etc/ipkg.conf 139 // Write out new /etc/ipkg.conf
140 QFile confFile( IPKG_CONF ); 140 QFile confFile( IPKG_CONF );
141 if ( confFile.open( IO_WriteOnly ) ) 141 if ( confFile.open( IO_WriteOnly ) )
142 { 142 {
143 QTextStream confStream( &confFile ); 143 QTextStream confStream( &confFile );
144 confStream << "# Generated by Opie Package Manager\n\n"; 144 confStream << "# Generated by Opie Package Manager\n\n";
145 145
146 OConfItemListIterator it( *m_confInfo ); 146 OConfItemListIterator it( *m_confInfo );
147 for ( ; it.current(); ++it ) 147 for ( ; it.current(); ++it )
148 { 148 {
149 OConfItem *item = it.current(); 149 OConfItem *item = it.current();
150 150
151 // Only write out valid conf items 151 // Only write out valid conf items
152 if ( item->type() != OConfItem::NotDefined ) 152 if ( item->type() != OConfItem::NotDefined )
153 { 153 {
154 QString confLine; 154 QString confLine;
155 QString name = item->name(); 155 QString name = item->name();
156 if ( !item->active() ) 156 if ( !item->active() )
157 confLine = "#"; 157 confLine = "#";
158 158
159 switch ( item->type() ) 159 switch ( item->type() )
160 { 160 {
161 case OConfItem::Source : 161 case OConfItem::Source :
162 { 162 {
163 if ( item->features().contains( "Compressed" ) ) 163 if ( item->features().contains( "Compressed" ) )
164 confLine.append( "src/gz" ); 164 confLine.append( "src/gz" );
165 else 165 else
166 confLine.append( "src" ); 166 confLine.append( "src" );
167 } 167 }
168 break; 168 break;
169 case OConfItem::Destination : confLine.append( "dest" ); break; 169 case OConfItem::Destination : confLine.append( "dest" ); break;
170 case OConfItem::Option : confLine.append( "option" ); break; 170 case OConfItem::Option : confLine.append( "option" ); break;
171 case OConfItem::Arch : confLine.append( "arch" ); break; 171 case OConfItem::Arch : confLine.append( "arch" ); break;
172 case OConfItem::Other : 172 case OConfItem::Other :
173 { 173 {
174 // For options w/type = Other, the mapping is as follows: 174 // For options w/type = Other, the mapping is as follows:
175 // name = typeStr (e.g. "lists_dir") 175 // name = typeStr (e.g. "lists_dir")
176 // value = value 176 // value = value
177 // features = name (from configuration file) 177 // features = name (from configuration file)
178 confLine.append( item->name() ); 178 confLine.append( item->name() );
179 name = item->features(); 179 name = item->features();
180 } 180 }
181 break; 181 break;
182 default : break; 182 default : break;
183 }; 183 };
184 184
185 confStream << confLine << " " << name << " " << item->value() << "\n"; 185 confStream << confLine << " " << name << " " << item->value() << "\n";
186 } 186 }
187 } 187 }
188 188
189 confFile.close(); 189 confFile.close();
190 } 190 }
191 else 191 else
192 { 192 {
193 // Problem writing to /etc/ipkg.conf, exit before removing other conf files 193 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
194 return; 194 return;
195 } 195 }
196 196
197 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings 197 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
198 QStringList confFiles; 198 QStringList confFiles;
199 QDir confDir( IPKG_CONF_DIR ); 199 QDir confDir( IPKG_CONF_DIR );
200 if ( confDir.exists() ) 200 if ( confDir.exists() )
201 { 201 {
202 confDir.setNameFilter( "*.conf" ); 202 confDir.setNameFilter( "*.conf" );
203 confDir.setFilter( QDir::Files ); 203 confDir.setFilter( QDir::Files );
204 confFiles = confDir.entryList( "*.conf", QDir::Files ); 204 confFiles = confDir.entryList( "*.conf", QDir::Files );
205 205
206 QStringList::Iterator lastFile = confFiles.end(); 206 QStringList::Iterator lastFile = confFiles.end();
207 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 207 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
208 { 208 {
209 // Create absolute file path if necessary 209 // Create absolute file path if necessary
210 QString absFile = (*it); 210 QString absFile = (*it);
211 if ( !absFile.startsWith( "/" ) ) 211 if ( !absFile.startsWith( "/" ) )
212 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 212 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
213 213
214 // Delete file 214 // Delete file
215 QFile::remove( absFile ); 215 QFile::remove( absFile );
216 } 216 }
217 } 217 }
218 218
219 // Reinitialize libipkg to pick up new configuration 219 // Reinitialize libipkg to pick up new configuration
220 ipkg_deinit( &m_ipkgArgs ); 220 ipkg_deinit( &m_ipkgArgs );
221 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 221 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
222 m_ipkgArgs.noaction = false; 222 m_ipkgArgs.noaction = false;
223 m_ipkgArgs.force_defaults = true; 223 m_ipkgArgs.force_defaults = true;
224} 224}
225 225
226void OIpkg::saveSettings() 226void OIpkg::saveSettings()
227{ 227{
228 // Save Ipkg execution options to application configuration file 228 // Save Ipkg execution options to application configuration file
229 if ( m_config ) 229 if ( m_config )
230 { 230 {
231 m_config->setGroup( "Ipkg" ); 231 m_config->setGroup( "Ipkg" );
232 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 232 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
233 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 233 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
234 } 234 }
235} 235}
236 236
237OPackageList *OIpkg::availablePackages( const QString &server ) 237OPackageList *OIpkg::availablePackages( const QString &server )
238{ 238{
239 // Load Ipkg configuration info if not already cached 239 // Load Ipkg configuration info if not already cached
240 if ( !m_confInfo ) 240 if ( !m_confInfo )
241 loadConfiguration(); 241 loadConfiguration();
242 242
243 // Build new server list (caller is responsible for deleting) 243 // Build new server list (caller is responsible for deleting)
244 OPackageList *pl = new OPackageList; 244 OPackageList *pl = new OPackageList;
245 245
246 // Get directory where server lists are located 246 // Get directory where server lists are located
247 QString listsDir; 247 QString listsDir;
248 OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); 248 OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" );
249 if ( confItem ) 249 if ( confItem )
250 listsDir = confItem->value(); 250 listsDir = confItem->value();
251 else 251 else
252 listsDir = IPKG_PKG_PATH; 252 listsDir = IPKG_PKG_PATH;
253 253
254 // Open package list file 254 // Open package list file
255 QFile f( listsDir + "/" + server ); 255 QFile f( listsDir + "/" + server );
256 if ( !f.open( IO_ReadOnly ) ) 256 if ( !f.open( IO_ReadOnly ) )
257 return NULL; 257 return NULL;
258 QTextStream t( &f ); 258 QTextStream t( &f );
259 259
260 // Process all information in package list file 260 // Process all information in package list file
261 OPackage *package = NULL; 261 OPackage *package = NULL;
262 QString line = t.readLine(); 262 QString line = t.readLine();
263 while ( !t.eof() ) 263 while ( !t.eof() )
264 { 264 {
265 // Determine key/value pair 265 // Determine key/value pair
266 int pos = line.find( ':', 0 ); 266 int pos = line.find( ':', 0 );
267 QString key; 267 QString key;
268 if ( pos > -1 ) 268 if ( pos > -1 )
269 key = line.mid( 0, pos ); 269 key = line.mid( 0, pos );
270 else 270 else
271 key = QString::null; 271 key = QString::null;
272 QString value = line.mid( pos+2, line.length()-pos ); 272 QString value = line.mid( pos+2, line.length()-pos );
273 273
274 // Allocate new package and insert into list 274 // Allocate new package and insert into list
275 if ( package == NULL && !key.isEmpty() ) 275 if ( package == NULL && !key.isEmpty() )
276 { 276 {
277 package = new OPackage( value ); 277 package = new OPackage( value );
278 package->setSource( server ); 278 package->setSource( server );
279 pl->append( package ); 279 pl->append( package );
280 } 280 }
281 281
282 // Update package data 282 // Update package data
283 if ( key == "Package" ) 283 if ( key == "Package" )
284 package->setName( value ); 284 package->setName( value );
285 else if ( key == "Version" ) 285 else if ( key == "Version" )
286 package->setVersion( value ); 286 package->setVersion( value );
287 else if ( key == "Section" ) 287 else if ( key == "Section" )
288 package->setCategory( value ); 288 package->setCategory( value );
289 //DataManager::setAvailableCategories( value ); 289 //DataManager::setAvailableCategories( value );
290 else if ( key.isEmpty() && value.isEmpty() ) 290 else if ( key.isEmpty() && value.isEmpty() )
291 package = NULL; 291 package = NULL;
292 292
293 // Skip past all description lines 293 // Skip past all description lines
294 if ( key == "Description" ) 294 if ( key == "Description" )
295 { 295 {
296 line = t.readLine(); 296 line = t.readLine();
297 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 297 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
298 line = t.readLine(); 298 line = t.readLine();
299 } 299 }
300 else 300 else
301 line = t.readLine(); 301 line = t.readLine();
302 } 302 }
303 303
304 f.close(); 304 f.close();
305 305
306 return pl; 306 return pl;
307} 307}
308 308
309OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 309OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
310{ 310{
311 // Load Ipkg configuration info if not already cached 311 // Load Ipkg configuration info if not already cached
312 if ( !m_confInfo ) 312 if ( !m_confInfo )
313 loadConfiguration(); 313 loadConfiguration();
314 314
315 // Build new server list (caller is responsible for deleting) 315 // Build new server list (caller is responsible for deleting)
316 OPackageList *pl = new OPackageList; 316 OPackageList *pl = new OPackageList;
317 317
318 // Open status file 318 // Open status file
319 QString path = destPath; 319 QString path = destPath;
320 if ( path.right( 1 ) != "/" ) 320 if ( path.right( 1 ) != "/" )
321 path.append( "/" ); 321 path.append( "/" );
322 path.append( IPKG_STATUS_PATH ); 322 path.append( IPKG_STATUS_PATH );
323 323
324 QFile f( path ); 324 QFile f( path );
325 if ( !f.open( IO_ReadOnly ) ) 325 if ( !f.open( IO_ReadOnly ) )
326 return NULL; 326 return NULL;
327 QTextStream t( &f ); 327 QTextStream t( &f );
328 328
329 // Process all information in status file 329 // Process all information in status file
330 bool newPackage = false; 330 bool newPackage = false;
331 QString line = t.readLine(); 331 QString line = t.readLine();
332 QString name; 332 QString name;
333 QString version; 333 QString version;
334 QString status; 334 QString status;
335 335
336 while ( !t.eof() ) 336 while ( !t.eof() )
337 { 337 {
338 // Determine key/value pair 338 // Determine key/value pair
339 int pos = line.find( ':', 0 ); 339 int pos = line.find( ':', 0 );
340 QString key; 340 QString key;
341 if ( pos > -1 ) 341 if ( pos > -1 )
342 key = line.mid( 0, pos ); 342 key = line.mid( 0, pos );
343 else 343 else
344 key = QString::null; 344 key = QString::null;
345 QString value = line.mid( pos+2, line.length()-pos ); 345 QString value = line.mid( pos+2, line.length()-pos );
346 346
347 // Allocate new package and insert into list 347 // Allocate new package and insert into list
348 if ( newPackage && !key.isEmpty() ) 348 if ( newPackage && !key.isEmpty() )
349 { 349 {
350 // Add to list only if it has a valid name and is installed 350 // Add to list only if it has a valid name and is installed
351 if ( !name.isNull() && status.contains( " installed" ) ) 351 if ( !name.isNull() && status.contains( " installed" ) )
352 { 352 {
353 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 353 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
354 name = QString::null; 354 name = QString::null;
355 version = QString::null; 355 version = QString::null;
356 status = QString::null; 356 status = QString::null;
357 357
358 newPackage = false; 358 newPackage = false;
359 } 359 }
360 } 360 }
361 361
362 // Update package data 362 // Update package data
363 if ( key == "Package" ) 363 if ( key == "Package" )
364 name = value; 364 name = value;
365 else if ( key == "Version" ) 365 else if ( key == "Version" )
366 version = value; 366 version = value;
367 else if ( key == "Status" ) 367 else if ( key == "Status" )
368 status = value; 368 status = value;
369 else if ( key.isEmpty() && value.isEmpty() ) 369 else if ( key.isEmpty() && value.isEmpty() )
370 newPackage = true; 370 newPackage = true;
371 371
372 // Skip past all description lines 372 // Skip past all description lines
373 if ( key == "Description" ) 373 if ( key == "Description" )
374 { 374 {
375 line = t.readLine(); 375 line = t.readLine();
376 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 376 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
377 line = t.readLine(); 377 line = t.readLine();
378 } 378 }
379 else 379 else
380 line = t.readLine(); 380 line = t.readLine();
381 } 381 }
382 382
383 f.close(); 383 f.close();
384 384
385 // Make sure to add to list last entry 385 // Make sure to add to list last entry
386 if ( !name.isNull() && status.contains( " installed" ) ) 386 if ( !name.isNull() && status.contains( " installed" ) )
387 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 387 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
388 388
389 return pl; 389 return pl;
390} 390}
391 391
392OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) 392OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name )
393{ 393{
394 // Find configuration item in list 394 // Find configuration item in list
395 OConfItemListIterator configIt( *m_confInfo ); 395 OConfItemListIterator configIt( *m_confInfo );
396 OConfItem *config = 0l; 396 OConfItem *config = 0l;
397 for ( ; configIt.current(); ++configIt ) 397 for ( ; configIt.current(); ++configIt )
398 { 398 {
399 config = configIt.current(); 399 config = configIt.current();
400 if ( config->type() == type && config->name() == name ) 400 if ( config->type() == type && config->name() == name )
401 break; 401 break;
402 } 402 }
403 403
404 if ( config && config->type() == type && config->name() == name ) 404 if ( config && config->type() == type && config->name() == name )
405 return config; 405 return config;
406 406
407 return 0l; 407 return 0l;
408} 408}
409 409
410bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination, 410bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination,
411 const QObject *receiver, const char *slotOutput, bool rawOutput ) 411 const QObject *receiver, const char *slotOutput, bool rawOutput )
412{ 412{
413 if ( command == OPackage::NotDefined ) 413 if ( command == OPackage::NotDefined )
414 return false; 414 return false;
415 415
416 // Set ipkg run-time options/arguments 416 // Set ipkg run-time options/arguments
417 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 417 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
418 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 418 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
419 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 419 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
420 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 420 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
421 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 421 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
422 if ( m_ipkgArgs.dest ) 422 if ( m_ipkgArgs.dest )
423 free( m_ipkgArgs.dest ); 423 free( m_ipkgArgs.dest );
424 if ( !destination.isNull() ) 424 if ( !destination.isNull() )
425 { 425 {
426 int len = destination.length() + 1; 426 int len = destination.length() + 1;
427 m_ipkgArgs.dest = (char *)malloc( len ); 427 m_ipkgArgs.dest = (char *)malloc( len );
428 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 428 strncpy( m_ipkgArgs.dest, destination, destination.length() );
429 m_ipkgArgs.dest[ len - 1 ] = '\0'; 429 m_ipkgArgs.dest[ len - 1 ] = '\0';
430 } 430 }
431 else 431 else
432 m_ipkgArgs.dest = 0l; 432 m_ipkgArgs.dest = 0l;
433 433
434 // Connect output signal to widget 434 // Connect output signal to widget
435 435
436 if ( !rawOutput ) 436 if ( !rawOutput )
437 { 437 {
438 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 438 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
439 } 439 }
440 440
441 switch( command ) 441 switch( command )
442 { 442 {
443 case OPackage::Update : { 443 case OPackage::Update : {
444 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 444 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
445 ipkg_lists_update( &m_ipkgArgs ); 445 ipkg_lists_update( &m_ipkgArgs );
446 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
446 }; 447 };
447 break; 448 break;
448 case OPackage::Upgrade : { 449 case OPackage::Upgrade : {
449 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 450 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
450 ipkg_packages_upgrade( &m_ipkgArgs ); 451 ipkg_packages_upgrade( &m_ipkgArgs );
451 452
452 // Re-link non-root destinations to make sure everything is in sync 453 // Re-link non-root destinations to make sure everything is in sync
453 OConfItemList *destList = destinations(); 454 OConfItemList *destList = destinations();
454 OConfItemListIterator it( *destList ); 455 OConfItemListIterator it( *destList );
455 for ( ; it.current(); ++it ) 456 for ( ; it.current(); ++it )
456 { 457 {
457 OConfItem *dest = it.current(); 458 OConfItem *dest = it.current();
458 if ( dest->name() != "root" ) 459 if ( dest->name() != "root" )
459 linkPackageDir( dest->name() ); 460 linkPackageDir( dest->name() );
460 } 461 }
461 delete destList; 462 delete destList;
463 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
462 }; 464 };
463 break; 465 break;
464 case OPackage::Install : { 466 case OPackage::Install : {
465 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 467 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
466 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 468 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
467 { 469 {
468 ipkg_packages_install( &m_ipkgArgs, (*it) ); 470 ipkg_packages_install( &m_ipkgArgs, (*it) );
469 } 471 }
470 if ( destination != "root" ) 472 if ( destination != "root" )
471 linkPackageDir( destination ); 473 linkPackageDir( destination );
474 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
472 }; 475 };
473 break; 476 break;
474 case OPackage::Remove : { 477 case OPackage::Remove : {
475 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 478 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
476 479
477 // Get list of destinations for unlinking of packages not installed to root 480 // Get list of destinations for unlinking of packages not installed to root
478 OConfItemList *destList = destinations(); 481 OConfItemList *destList = destinations();
479 482
480 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 483 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
481 { 484 {
482 unlinkPackage( (*it), destList ); 485 unlinkPackage( (*it), destList );
483 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 486 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
484 } 487 }
485 488
486 delete destList; 489 delete destList;
490 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
487 }; 491 };
488 break; 492 break;
489 case OPackage::Download : { 493 case OPackage::Download : {
490 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 494 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
491 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 495 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
492 { 496 {
493 ipkg_packages_download( &m_ipkgArgs, (*it) ); 497 ipkg_packages_download( &m_ipkgArgs, (*it) );
494 } 498 }
499 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
495 }; 500 };
496 break; 501 break;
497 case OPackage::Info : { 502 case OPackage::Info : {
498 connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); 503 connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput );
499 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); 504 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l );
505 disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 );
500 }; 506 };
501 break; 507 break;
502 case OPackage::Files : { 508 case OPackage::Files : {
503 connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); 509 connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput );
504 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); 510 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l );
511 disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 );
505 }; 512 };
506 break; 513 break;
507 default : break; 514 default : break;
508 }; 515 };
509 516
510 return true; 517 return true;
511} 518}
512 519
513void OIpkg::ipkgMessage( char *msg ) 520void OIpkg::ipkgMessage( char *msg )
514{ 521{
515 emit signalIpkgMessage( msg ); 522 emit signalIpkgMessage( msg );
516} 523}
517 524
518void OIpkg::ipkgStatus( char *status ) 525void OIpkg::ipkgStatus( char *status )
519{ 526{
520 emit signalIpkgStatus( status ); 527 emit signalIpkgStatus( status );
521} 528}
522 529
523void OIpkg::ipkgList( char *filelist ) 530void OIpkg::ipkgList( char *filelist )
524{ 531{
525 emit signalIpkgList( filelist ); 532 emit signalIpkgList( filelist );
526} 533}
527 534
528void OIpkg::loadConfiguration() 535void OIpkg::loadConfiguration()
529{ 536{
530 if ( m_confInfo ) 537 if ( m_confInfo )
531 delete m_confInfo; 538 delete m_confInfo;
532 539
533 // Load configuration item list 540 // Load configuration item list
534 m_confInfo = new OConfItemList(); 541 m_confInfo = new OConfItemList();
535 542
536 QStringList confFiles; 543 QStringList confFiles;
537 QDir confDir( IPKG_CONF_DIR ); 544 QDir confDir( IPKG_CONF_DIR );
538 if ( confDir.exists() ) 545 if ( confDir.exists() )
539 { 546 {
540 confDir.setNameFilter( "*.conf" ); 547 confDir.setNameFilter( "*.conf" );
541 confDir.setFilter( QDir::Files ); 548 confDir.setFilter( QDir::Files );
542 confFiles = confDir.entryList( "*.conf", QDir::Files ); 549 confFiles = confDir.entryList( "*.conf", QDir::Files );
543 } 550 }
544 confFiles << IPKG_CONF; 551 confFiles << IPKG_CONF;
545 552
546 QStringList::Iterator lastFile = confFiles.end(); 553 QStringList::Iterator lastFile = confFiles.end();
547 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 554 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
548 { 555 {
549 // Create absolute file path if necessary 556 // Create absolute file path if necessary
550 QString absFile = (*it); 557 QString absFile = (*it);
551 if ( !absFile.startsWith( "/" ) ) 558 if ( !absFile.startsWith( "/" ) )
552 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 559 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
553 560
554 // Read in file 561 // Read in file
555 QFile f( absFile ); 562 QFile f( absFile );
556 if ( f.open( IO_ReadOnly ) ) 563 if ( f.open( IO_ReadOnly ) )
557 { 564 {
558 QTextStream s( &f ); 565 QTextStream s( &f );
559 while ( !s.eof() ) 566 while ( !s.eof() )
560 { 567 {
561 568
562 QString line = s.readLine().simplifyWhiteSpace(); 569 QString line = s.readLine().simplifyWhiteSpace();
563 570
564 // Parse line and save info to the conf options list 571 // Parse line and save info to the conf options list
565 if ( !line.isEmpty() ) 572 if ( !line.isEmpty() )
566 { 573 {
567 // Strip leading comment marker if exists 574 // Strip leading comment marker if exists
568 bool comment = false; 575 bool comment = false;
569 if ( line.startsWith( "#" ) ) 576 if ( line.startsWith( "#" ) )
570 { 577 {
571 line.remove( 0, 1 ); 578 line.remove( 0, 1 );
572 line = line.simplifyWhiteSpace(); 579 line = line.simplifyWhiteSpace();
573 comment = true; 580 comment = true;
574 } 581 }
575 582
576 bool recognizedOption = true; 583 bool recognizedOption = true;
577 int pos = line.find( ' ', 1 ) + 1; 584 int pos = line.find( ' ', 1 ) + 1;
578 int endpos = line.find( ' ', pos ); 585 int endpos = line.find( ' ', pos );
579 586
580 // Name 587 // Name
581 QString name = line.mid( pos, endpos - pos ); 588 QString name = line.mid( pos, endpos - pos );
582 589
583 // Value 590 // Value
584 QString value = ""; 591 QString value = "";
585 if ( endpos > -1 ) 592 if ( endpos > -1 )
586 value = line.right( line.length() - endpos - 1 ); 593 value = line.right( line.length() - endpos - 1 );
587 594
588 // Active 595 // Active
589 bool active = !comment; 596 bool active = !comment;
590 597
591 // Type 598 // Type
592 // For options w/type = Other, the mapping is as follows: 599 // For options w/type = Other, the mapping is as follows:
593 // name = typeStr (e.g. "lists_dir") 600 // name = typeStr (e.g. "lists_dir")
594 // value = value 601 // value = value
595 // features = name (from configuration file) 602 // features = name (from configuration file)
596 603
597 QString typeStr = line.left( pos - 1 ); 604 QString typeStr = line.left( pos - 1 );
598 OConfItem::Type type; 605 OConfItem::Type type;
599 QString features; 606 QString features;
600 if ( typeStr == "src" ) 607 if ( typeStr == "src" )
601 type = OConfItem::Source; 608 type = OConfItem::Source;
602 else if ( typeStr == "src/gz" ) 609 else if ( typeStr == "src/gz" )
603 { 610 {
604 type = OConfItem::Source; 611 type = OConfItem::Source;
605 features = "Compressed"; 612 features = "Compressed";
606 } 613 }
607 else if ( typeStr == "dest" ) 614 else if ( typeStr == "dest" )
608 type = OConfItem::Destination; 615 type = OConfItem::Destination;
609 else if ( typeStr == "option" ) 616 else if ( typeStr == "option" )
610 type = OConfItem::Option; 617 type = OConfItem::Option;
611 else if ( typeStr == "arch" ) 618 else if ( typeStr == "arch" )
612 type = OConfItem::Arch; 619 type = OConfItem::Arch;
613 else if ( typeStr == "lists_dir" ) 620 else if ( typeStr == "lists_dir" )
614 { 621 {
615 type = OConfItem::Other; 622 type = OConfItem::Other;
616 features = name; 623 features = name;
617 name = typeStr; 624 name = typeStr;
618 625
619 // Default value when not defined 626 // Default value when not defined
620 if ( value == QString::null || value == "" ) 627 if ( value == QString::null || value == "" )
621 value = IPKG_PKG_PATH; 628 value = IPKG_PKG_PATH;
622 } 629 }
623 else 630 else
624 recognizedOption = false; 631 recognizedOption = false;
625 632
626 // Add to list 633 // Add to list
627 if ( recognizedOption ) 634 if ( recognizedOption )
628 m_confInfo->append( new OConfItem( type, name, value, features, active ) ); 635 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
629 } 636 }
630 } 637 }
631 638
632 f.close(); 639 f.close();
633 } 640 }
634 } 641 }
635 642
636 // Load Ipkg execution options from application configuration file 643 // Load Ipkg execution options from application configuration file
637 if ( m_config ) 644 if ( m_config )
638 { 645 {
639 m_config->setGroup( "Ipkg" ); 646 m_config->setGroup( "Ipkg" );
640 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 647 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
641 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 648 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
642 } 649 }
643} 650}
644 651
645OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 652OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
646{ 653{
647 // Load Ipkg configuration info if not already cached 654 // Load Ipkg configuration info if not already cached
648 if ( !m_confInfo ) 655 if ( !m_confInfo )
649 loadConfiguration(); 656 loadConfiguration();
650 657
651 // Build new server list (caller is responsible for deleting) 658 // Build new server list (caller is responsible for deleting)
652 OConfItemList *sl = new OConfItemList; 659 OConfItemList *sl = new OConfItemList;
653 660
654 // If typefilter is empty, retrieve all items 661 // If typefilter is empty, retrieve all items
655 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 662 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
656 663
657 // Parse configuration info for servers 664 // Parse configuration info for servers
658 OConfItemListIterator it( *m_confInfo ); 665 OConfItemListIterator it( *m_confInfo );
659 for ( ; it.current(); ++it ) 666 for ( ; it.current(); ++it )
660 { 667 {
661 OConfItem *item = it.current(); 668 OConfItem *item = it.current();
662 if ( retrieveAll || item->type() == typefilter ) 669 if ( retrieveAll || item->type() == typefilter )
663 { 670 {
664 sl->append( item ); 671 sl->append( item );
665 } 672 }
666 } 673 }
667 674
668 return sl; 675 return sl;
669} 676}
670 677
671const QString &OIpkg::rootPath() 678const QString &OIpkg::rootPath()
672{ 679{
673 if ( m_rootPath.isEmpty() ) 680 if ( m_rootPath.isEmpty() )
674 { 681 {
675 OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); 682 OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" );
676 rootDest ? m_rootPath = rootDest->value() 683 rootDest ? m_rootPath = rootDest->value()
677 : m_rootPath = '/'; 684 : m_rootPath = '/';
678 if ( m_rootPath.right( 1 ) == '/' ) 685 if ( m_rootPath.right( 1 ) == '/' )
679 m_rootPath.truncate( m_rootPath.length() - 1 ); 686 m_rootPath.truncate( m_rootPath.length() - 1 );
680 } 687 }
681 return m_rootPath; 688 return m_rootPath;
682} 689}
683 690
684void OIpkg::linkPackageDir( const QString &dest ) 691void OIpkg::linkPackageDir( const QString &dest )
685{ 692{
686 if ( !dest.isNull() ) 693 if ( !dest.isNull() )
687 { 694 {
688 OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); 695 OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest );
689 696
690 emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); 697 emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) );
691 698
692 // Set package destination directory 699 // Set package destination directory
693 QString destDir = destConfItem->value(); 700 QString destDir = destConfItem->value();
694 QString destInfoDir = destDir; 701 QString destInfoDir = destDir;
695 if ( destInfoDir.right( 1 ) != '/' ) 702 if ( destInfoDir.right( 1 ) != '/' )
696 destInfoDir.append( '/' ); 703 destInfoDir.append( '/' );
697 destInfoDir.append( IPKG_INFO_PATH ); 704 destInfoDir.append( IPKG_INFO_PATH );
698 705
699 // Get list of installed packages in destination 706 // Get list of installed packages in destination
700 QDir packageDir( destInfoDir ); 707 QDir packageDir( destInfoDir );
701 QStringList packageFiles; 708 QStringList packageFiles;
702 if ( packageDir.exists() ) 709 if ( packageDir.exists() )
703 { 710 {
704 packageDir.setNameFilter( "*.list" ); 711 packageDir.setNameFilter( "*.list" );
705 packageDir.setFilter( QDir::Files ); 712 packageDir.setFilter( QDir::Files );
706 packageFiles = packageDir.entryList( "*.list", QDir::Files ); 713 packageFiles = packageDir.entryList( "*.list", QDir::Files );
707 } 714 }
708 715
709 // Link all files for every package installed in desination 716 // Link all files for every package installed in desination
710 QStringList::Iterator lastFile = packageFiles.end(); 717 QStringList::Iterator lastFile = packageFiles.end();
711 for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) 718 for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it )
712 { 719 {
713 //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); 720 //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) );
714 QString packageFileName = destInfoDir; 721 QString packageFileName = destInfoDir;
715 packageFileName.append( '/' ); 722 packageFileName.append( '/' );
716 packageFileName.append( (*it) ); 723 packageFileName.append( (*it) );
717 QFile packageFile( packageFileName ); 724 QFile packageFile( packageFileName );
718 if ( packageFile.open( IO_ReadOnly ) ) 725 if ( packageFile.open( IO_ReadOnly ) )
719 { 726 {
720 QTextStream t( &packageFile ); 727 QTextStream t( &packageFile );
721 QString linkFile; 728 QString linkFile;
722 while ( !t.eof() ) 729 while ( !t.eof() )
723 { 730 {
724 // Get the name of the file to link and build the sym link filename 731 // Get the name of the file to link and build the sym link filename
725 linkFile = t.readLine(); 732 linkFile = t.readLine();
726 QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); 733 QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) );
727 linkDest.prepend( rootPath() ); 734 linkDest.prepend( rootPath() );
728 735
729 // If file installed file is actually symbolic link, use actual file for linking 736 // If file installed file is actually symbolic link, use actual file for linking
730 QFileInfo fileInfo( linkFile ); 737 QFileInfo fileInfo( linkFile );
731 if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) 738 if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() )
732 linkFile = fileInfo.readLink(); 739 linkFile = fileInfo.readLink();
733 740
734 // See if directory exists in 'root', if not, create 741 // See if directory exists in 'root', if not, create
735 fileInfo.setFile( linkDest ); 742 fileInfo.setFile( linkDest );
736 QString linkDestDirName = fileInfo.dirPath( true ); 743 QString linkDestDirName = fileInfo.dirPath( true );
737 QDir linkDestDir( linkDestDirName ); 744 QDir linkDestDir( linkDestDirName );
738 if ( !linkDestDir.exists() ) 745 if ( !linkDestDir.exists() )
739 { 746 {
740 linkDestDir.mkdir( linkDestDirName ); 747 linkDestDir.mkdir( linkDestDirName );
741 } 748 }
742 else 749 else
743 { 750 {
744 // Remove any previous link to make sure we will be pointing to the current version 751 // Remove any previous link to make sure we will be pointing to the current version
745 if ( QFile::exists( linkDest ) ) 752 if ( QFile::exists( linkDest ) )
746 QFile::remove( linkDest ); 753 QFile::remove( linkDest );
747 } 754 }
748 755
749 // Link the file 756 // Link the file
750 //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); 757 //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) );
751 if ( symlink( linkFile, linkDest ) == -1 ) 758 if ( symlink( linkFile, linkDest ) == -1 )
752 emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) 759 emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" )
753 .arg( linkFile ) 760 .arg( linkFile )
754 .arg( linkDest ) ); 761 .arg( linkDest ) );
755 } 762 }
756 packageFile.close(); 763 packageFile.close();
757 } 764 }
758 } 765 }
759 } 766 }
760} 767}
761 768
762void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) 769void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList )
763{ 770{
764 if ( !package.isNull() ) 771 if ( !package.isNull() )
765 { 772 {
766 // Find destination package is installed in 773 // Find destination package is installed in
767 if ( destList ) 774 if ( destList )
768 { 775 {
769 OConfItemListIterator it( *destList ); 776 OConfItemListIterator it( *destList );
770 for ( ; it.current(); ++it ) 777 for ( ; it.current(); ++it )
771 { 778 {
772 OConfItem *dest = it.current(); 779 OConfItem *dest = it.current();
773 QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) 780 QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() )
774 .arg( IPKG_INFO_PATH ) 781 .arg( IPKG_INFO_PATH )
775 .arg( package ); 782 .arg( package );
776 //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); 783 //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) );
777 784
778 // If found and destination is not 'root', remove symbolic links 785 // If found and destination is not 'root', remove symbolic links
779 if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) 786 if ( QFile::exists( destInfoFileName ) && dest->name() != "root" )
780 { 787 {
781 QFile destInfoFile( destInfoFileName ); 788 QFile destInfoFile( destInfoFileName );
782 if ( destInfoFile.open( IO_ReadOnly ) ) 789 if ( destInfoFile.open( IO_ReadOnly ) )
783 { 790 {
784 QTextStream t( &destInfoFile ); 791 QTextStream t( &destInfoFile );
785 QString linkFile; 792 QString linkFile;
786 while ( !t.eof() ) 793 while ( !t.eof() )
787 { 794 {
788 // Get the name of the file to link and build the sym link filename 795 // Get the name of the file to link and build the sym link filename
789 linkFile = t.readLine(); 796 linkFile = t.readLine();
790 QString linkDest( linkFile.right( linkFile.length() - 797 QString linkDest( linkFile.right( linkFile.length() -
791 dest->value().length() ) ); 798 dest->value().length() ) );
792 linkDest.prepend( rootPath() ); 799 linkDest.prepend( rootPath() );
793 800
794 //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); 801 //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) );
795 QFile::remove( linkDest ); 802 QFile::remove( linkDest );
796 } 803 }
797 destInfoFile.close(); 804 destInfoFile.close();
798 } 805 }
799 806
800 emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); 807 emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) );
801 return; 808 return;
802 } 809 }
803 } 810 }
804 } 811 }
805 } 812 }
806} 813}