-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 14 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkgconfigdlg.cpp | 7 |
2 files changed, 18 insertions, 3 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 3d2c621..417ee95 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,794 +1,806 @@ | |||
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 | ||
41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location | 45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location |
46 | 46 | ||
47 | OIpkg *oipkg; | 47 | OIpkg *oipkg; |
48 | 48 | ||
49 | // Ipkg callback functions | 49 | // Ipkg callback functions |
50 | 50 | ||
51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 51 | int 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 | ||
62 | char *fIpkgResponse( char */*question*/ ) | 62 | char *fIpkgResponse( char */*question*/ ) |
63 | { | 63 | { |
64 | return 0l; | 64 | return 0l; |
65 | } | 65 | } |
66 | 66 | ||
67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 67 | int 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 | ||
73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 73 | int 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 | ||
80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 80 | OIpkg::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 | ||
98 | OIpkg::~OIpkg() | 98 | OIpkg::~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 | ||
108 | OConfItemList *OIpkg::configItems() | 108 | OConfItemList *OIpkg::configItems() |
109 | { | 109 | { |
110 | // Retrieve all configuration items | 110 | // Retrieve all configuration items |
111 | return filterConfItems(); | 111 | return filterConfItems(); |
112 | } | 112 | } |
113 | 113 | ||
114 | OConfItemList *OIpkg::servers() | 114 | OConfItemList *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 | ||
120 | OConfItemList *OIpkg::destinations() | 120 | OConfItemList *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 | ||
126 | OConfItemList *OIpkg::options() | 126 | OConfItemList *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 | ||
132 | void OIpkg::setConfigItems( OConfItemList *configList ) | 132 | void 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 | ||
226 | void OIpkg::saveSettings() | 226 | void 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 | ||
237 | OPackageList *OIpkg::availablePackages( const QString &server ) | 237 | OPackageList *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 | ||
247 | QString listsDir; | ||
248 | OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); | ||
249 | if ( confItem ) | ||
250 | listsDir = confItem->value(); | ||
251 | else | ||
252 | listsDir = IPKG_PKG_PATH; | ||
253 | |||
246 | // Open package list file | 254 | // Open package list file |
247 | QFile f( IPKG_PKG_PATH + "/" + server ); | 255 | QFile f( listsDir + "/" + server ); |
248 | if ( !f.open( IO_ReadOnly ) ) | 256 | if ( !f.open( IO_ReadOnly ) ) |
249 | return NULL; | 257 | return NULL; |
250 | QTextStream t( &f ); | 258 | QTextStream t( &f ); |
251 | 259 | ||
252 | // Process all information in package list file | 260 | // Process all information in package list file |
253 | OPackage *package = NULL; | 261 | OPackage *package = NULL; |
254 | QString line = t.readLine(); | 262 | QString line = t.readLine(); |
255 | while ( !t.eof() ) | 263 | while ( !t.eof() ) |
256 | { | 264 | { |
257 | // Determine key/value pair | 265 | // Determine key/value pair |
258 | int pos = line.find( ':', 0 ); | 266 | int pos = line.find( ':', 0 ); |
259 | QString key; | 267 | QString key; |
260 | if ( pos > -1 ) | 268 | if ( pos > -1 ) |
261 | key = line.mid( 0, pos ); | 269 | key = line.mid( 0, pos ); |
262 | else | 270 | else |
263 | key = QString::null; | 271 | key = QString::null; |
264 | QString value = line.mid( pos+2, line.length()-pos ); | 272 | QString value = line.mid( pos+2, line.length()-pos ); |
265 | 273 | ||
266 | // Allocate new package and insert into list | 274 | // Allocate new package and insert into list |
267 | if ( package == NULL && !key.isEmpty() ) | 275 | if ( package == NULL && !key.isEmpty() ) |
268 | { | 276 | { |
269 | package = new OPackage( value ); | 277 | package = new OPackage( value ); |
270 | package->setSource( server ); | 278 | package->setSource( server ); |
271 | pl->append( package ); | 279 | pl->append( package ); |
272 | } | 280 | } |
273 | 281 | ||
274 | // Update package data | 282 | // Update package data |
275 | if ( key == "Package" ) | 283 | if ( key == "Package" ) |
276 | package->setName( value ); | 284 | package->setName( value ); |
277 | else if ( key == "Version" ) | 285 | else if ( key == "Version" ) |
278 | package->setVersion( value ); | 286 | package->setVersion( value ); |
279 | else if ( key == "Section" ) | 287 | else if ( key == "Section" ) |
280 | package->setCategory( value ); | 288 | package->setCategory( value ); |
281 | //DataManager::setAvailableCategories( value ); | 289 | //DataManager::setAvailableCategories( value ); |
282 | else if ( key.isEmpty() && value.isEmpty() ) | 290 | else if ( key.isEmpty() && value.isEmpty() ) |
283 | package = NULL; | 291 | package = NULL; |
284 | 292 | ||
285 | // Skip past all description lines | 293 | // Skip past all description lines |
286 | if ( key == "Description" ) | 294 | if ( key == "Description" ) |
287 | { | 295 | { |
288 | line = t.readLine(); | 296 | line = t.readLine(); |
289 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 297 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
290 | line = t.readLine(); | 298 | line = t.readLine(); |
291 | } | 299 | } |
292 | else | 300 | else |
293 | line = t.readLine(); | 301 | line = t.readLine(); |
294 | } | 302 | } |
295 | 303 | ||
296 | f.close(); | 304 | f.close(); |
297 | 305 | ||
298 | return pl; | 306 | return pl; |
299 | } | 307 | } |
300 | 308 | ||
301 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 309 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
302 | { | 310 | { |
303 | // Load Ipkg configuration info if not already cached | 311 | // Load Ipkg configuration info if not already cached |
304 | if ( !m_confInfo ) | 312 | if ( !m_confInfo ) |
305 | loadConfiguration(); | 313 | loadConfiguration(); |
306 | 314 | ||
307 | // Build new server list (caller is responsible for deleting) | 315 | // Build new server list (caller is responsible for deleting) |
308 | OPackageList *pl = new OPackageList; | 316 | OPackageList *pl = new OPackageList; |
309 | 317 | ||
310 | // Open status file | 318 | // Open status file |
311 | QString path = destPath; | 319 | QString path = destPath; |
312 | if ( path.right( 1 ) != "/" ) | 320 | if ( path.right( 1 ) != "/" ) |
313 | path.append( "/" ); | 321 | path.append( "/" ); |
314 | path.append( IPKG_STATUS_PATH ); | 322 | path.append( IPKG_STATUS_PATH ); |
315 | 323 | ||
316 | QFile f( path ); | 324 | QFile f( path ); |
317 | if ( !f.open( IO_ReadOnly ) ) | 325 | if ( !f.open( IO_ReadOnly ) ) |
318 | return NULL; | 326 | return NULL; |
319 | QTextStream t( &f ); | 327 | QTextStream t( &f ); |
320 | 328 | ||
321 | // Process all information in status file | 329 | // Process all information in status file |
322 | bool newPackage = false; | 330 | bool newPackage = false; |
323 | QString line = t.readLine(); | 331 | QString line = t.readLine(); |
324 | QString name; | 332 | QString name; |
325 | QString version; | 333 | QString version; |
326 | QString status; | 334 | QString status; |
327 | 335 | ||
328 | while ( !t.eof() ) | 336 | while ( !t.eof() ) |
329 | { | 337 | { |
330 | // Determine key/value pair | 338 | // Determine key/value pair |
331 | int pos = line.find( ':', 0 ); | 339 | int pos = line.find( ':', 0 ); |
332 | QString key; | 340 | QString key; |
333 | if ( pos > -1 ) | 341 | if ( pos > -1 ) |
334 | key = line.mid( 0, pos ); | 342 | key = line.mid( 0, pos ); |
335 | else | 343 | else |
336 | key = QString::null; | 344 | key = QString::null; |
337 | QString value = line.mid( pos+2, line.length()-pos ); | 345 | QString value = line.mid( pos+2, line.length()-pos ); |
338 | 346 | ||
339 | // Allocate new package and insert into list | 347 | // Allocate new package and insert into list |
340 | if ( newPackage && !key.isEmpty() ) | 348 | if ( newPackage && !key.isEmpty() ) |
341 | { | 349 | { |
342 | // 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 |
343 | if ( !name.isNull() && status.contains( " installed" ) ) | 351 | if ( !name.isNull() && status.contains( " installed" ) ) |
344 | { | 352 | { |
345 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 353 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
346 | name = QString::null; | 354 | name = QString::null; |
347 | version = QString::null; | 355 | version = QString::null; |
348 | status = QString::null; | 356 | status = QString::null; |
349 | 357 | ||
350 | newPackage = false; | 358 | newPackage = false; |
351 | } | 359 | } |
352 | } | 360 | } |
353 | 361 | ||
354 | // Update package data | 362 | // Update package data |
355 | if ( key == "Package" ) | 363 | if ( key == "Package" ) |
356 | name = value; | 364 | name = value; |
357 | else if ( key == "Version" ) | 365 | else if ( key == "Version" ) |
358 | version = value; | 366 | version = value; |
359 | else if ( key == "Status" ) | 367 | else if ( key == "Status" ) |
360 | status = value; | 368 | status = value; |
361 | else if ( key.isEmpty() && value.isEmpty() ) | 369 | else if ( key.isEmpty() && value.isEmpty() ) |
362 | newPackage = true; | 370 | newPackage = true; |
363 | 371 | ||
364 | // Skip past all description lines | 372 | // Skip past all description lines |
365 | if ( key == "Description" ) | 373 | if ( key == "Description" ) |
366 | { | 374 | { |
367 | line = t.readLine(); | 375 | line = t.readLine(); |
368 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 376 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
369 | line = t.readLine(); | 377 | line = t.readLine(); |
370 | } | 378 | } |
371 | else | 379 | else |
372 | line = t.readLine(); | 380 | line = t.readLine(); |
373 | } | 381 | } |
374 | 382 | ||
375 | f.close(); | 383 | f.close(); |
376 | 384 | ||
377 | // Make sure to add to list last entry | 385 | // Make sure to add to list last entry |
378 | if ( !name.isNull() && status.contains( " installed" ) ) | 386 | if ( !name.isNull() && status.contains( " installed" ) ) |
379 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 387 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
380 | 388 | ||
381 | return pl; | 389 | return pl; |
382 | } | 390 | } |
383 | 391 | ||
384 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) | 392 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) |
385 | { | 393 | { |
386 | // Find configuration item in list | 394 | // Find configuration item in list |
387 | OConfItemListIterator configIt( *m_confInfo ); | 395 | OConfItemListIterator configIt( *m_confInfo ); |
388 | OConfItem *config = 0l; | 396 | OConfItem *config = 0l; |
389 | for ( ; configIt.current(); ++configIt ) | 397 | for ( ; configIt.current(); ++configIt ) |
390 | { | 398 | { |
391 | config = configIt.current(); | 399 | config = configIt.current(); |
392 | if ( config->type() == type && config->name() == name ) | 400 | if ( config->type() == type && config->name() == name ) |
393 | break; | 401 | break; |
394 | } | 402 | } |
395 | 403 | ||
396 | if ( config && config->type() == type && config->name() == name ) | 404 | if ( config && config->type() == type && config->name() == name ) |
397 | return config; | 405 | return config; |
398 | 406 | ||
399 | return 0l; | 407 | return 0l; |
400 | } | 408 | } |
401 | 409 | ||
402 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, | 410 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
403 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 411 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
404 | { | 412 | { |
405 | if ( command == OPackage::NotDefined ) | 413 | if ( command == OPackage::NotDefined ) |
406 | return false; | 414 | return false; |
407 | 415 | ||
408 | // Set ipkg run-time options/arguments | 416 | // Set ipkg run-time options/arguments |
409 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 417 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
410 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 418 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
411 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 419 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
412 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 420 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
413 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 421 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
414 | if ( m_ipkgArgs.dest ) | 422 | if ( m_ipkgArgs.dest ) |
415 | free( m_ipkgArgs.dest ); | 423 | free( m_ipkgArgs.dest ); |
416 | if ( !destination.isNull() ) | 424 | if ( !destination.isNull() ) |
417 | { | 425 | { |
418 | int len = destination.length() + 1; | 426 | int len = destination.length() + 1; |
419 | m_ipkgArgs.dest = (char *)malloc( len ); | 427 | m_ipkgArgs.dest = (char *)malloc( len ); |
420 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 428 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
421 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 429 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
422 | } | 430 | } |
423 | else | 431 | else |
424 | m_ipkgArgs.dest = 0l; | 432 | m_ipkgArgs.dest = 0l; |
425 | 433 | ||
426 | // Connect output signal to widget | 434 | // Connect output signal to widget |
427 | 435 | ||
428 | if ( !rawOutput ) | 436 | if ( !rawOutput ) |
429 | { | 437 | { |
430 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 438 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
431 | } | 439 | } |
432 | 440 | ||
433 | switch( command ) | 441 | switch( command ) |
434 | { | 442 | { |
435 | case OPackage::Update : { | 443 | case OPackage::Update : { |
436 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 444 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
437 | ipkg_lists_update( &m_ipkgArgs ); | 445 | ipkg_lists_update( &m_ipkgArgs ); |
438 | }; | 446 | }; |
439 | break; | 447 | break; |
440 | case OPackage::Upgrade : { | 448 | case OPackage::Upgrade : { |
441 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 449 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
442 | ipkg_packages_upgrade( &m_ipkgArgs ); | 450 | ipkg_packages_upgrade( &m_ipkgArgs ); |
443 | 451 | ||
444 | // Re-link non-root destinations to make sure everything is in sync | 452 | // Re-link non-root destinations to make sure everything is in sync |
445 | OConfItemList *destList = destinations(); | 453 | OConfItemList *destList = destinations(); |
446 | OConfItemListIterator it( *destList ); | 454 | OConfItemListIterator it( *destList ); |
447 | for ( ; it.current(); ++it ) | 455 | for ( ; it.current(); ++it ) |
448 | { | 456 | { |
449 | OConfItem *dest = it.current(); | 457 | OConfItem *dest = it.current(); |
450 | if ( dest->name() != "root" ) | 458 | if ( dest->name() != "root" ) |
451 | linkPackageDir( dest->name() ); | 459 | linkPackageDir( dest->name() ); |
452 | } | 460 | } |
453 | delete destList; | 461 | delete destList; |
454 | }; | 462 | }; |
455 | break; | 463 | break; |
456 | case OPackage::Install : { | 464 | case OPackage::Install : { |
457 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 465 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
458 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 466 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
459 | { | 467 | { |
460 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 468 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
461 | } | 469 | } |
462 | if ( destination != "root" ) | 470 | if ( destination != "root" ) |
463 | linkPackageDir( destination ); | 471 | linkPackageDir( destination ); |
464 | }; | 472 | }; |
465 | break; | 473 | break; |
466 | case OPackage::Remove : { | 474 | case OPackage::Remove : { |
467 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 475 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
468 | 476 | ||
469 | // Get list of destinations for unlinking of packages not installed to root | 477 | // Get list of destinations for unlinking of packages not installed to root |
470 | OConfItemList *destList = destinations(); | 478 | OConfItemList *destList = destinations(); |
471 | 479 | ||
472 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 480 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
473 | { | 481 | { |
474 | unlinkPackage( (*it), destList ); | 482 | unlinkPackage( (*it), destList ); |
475 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 483 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
476 | } | 484 | } |
477 | 485 | ||
478 | delete destList; | 486 | delete destList; |
479 | }; | 487 | }; |
480 | break; | 488 | break; |
481 | case OPackage::Download : { | 489 | case OPackage::Download : { |
482 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 490 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
483 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 491 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
484 | { | 492 | { |
485 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 493 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
486 | } | 494 | } |
487 | }; | 495 | }; |
488 | break; | 496 | break; |
489 | case OPackage::Info : { | 497 | case OPackage::Info : { |
490 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); | 498 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); |
491 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); | 499 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); |
492 | }; | 500 | }; |
493 | break; | 501 | break; |
494 | case OPackage::Files : { | 502 | case OPackage::Files : { |
495 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); | 503 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); |
496 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); | 504 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); |
497 | }; | 505 | }; |
498 | break; | 506 | break; |
499 | default : break; | 507 | default : break; |
500 | }; | 508 | }; |
501 | 509 | ||
502 | return true; | 510 | return true; |
503 | } | 511 | } |
504 | 512 | ||
505 | void OIpkg::ipkgMessage( char *msg ) | 513 | void OIpkg::ipkgMessage( char *msg ) |
506 | { | 514 | { |
507 | emit signalIpkgMessage( msg ); | 515 | emit signalIpkgMessage( msg ); |
508 | } | 516 | } |
509 | 517 | ||
510 | void OIpkg::ipkgStatus( char *status ) | 518 | void OIpkg::ipkgStatus( char *status ) |
511 | { | 519 | { |
512 | emit signalIpkgStatus( status ); | 520 | emit signalIpkgStatus( status ); |
513 | } | 521 | } |
514 | 522 | ||
515 | void OIpkg::ipkgList( char *filelist ) | 523 | void OIpkg::ipkgList( char *filelist ) |
516 | { | 524 | { |
517 | emit signalIpkgList( filelist ); | 525 | emit signalIpkgList( filelist ); |
518 | } | 526 | } |
519 | 527 | ||
520 | void OIpkg::loadConfiguration() | 528 | void OIpkg::loadConfiguration() |
521 | { | 529 | { |
522 | if ( m_confInfo ) | 530 | if ( m_confInfo ) |
523 | delete m_confInfo; | 531 | delete m_confInfo; |
524 | 532 | ||
525 | // Load configuration item list | 533 | // Load configuration item list |
526 | m_confInfo = new OConfItemList(); | 534 | m_confInfo = new OConfItemList(); |
527 | 535 | ||
528 | QStringList confFiles; | 536 | QStringList confFiles; |
529 | QDir confDir( IPKG_CONF_DIR ); | 537 | QDir confDir( IPKG_CONF_DIR ); |
530 | if ( confDir.exists() ) | 538 | if ( confDir.exists() ) |
531 | { | 539 | { |
532 | confDir.setNameFilter( "*.conf" ); | 540 | confDir.setNameFilter( "*.conf" ); |
533 | confDir.setFilter( QDir::Files ); | 541 | confDir.setFilter( QDir::Files ); |
534 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 542 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
535 | } | 543 | } |
536 | confFiles << IPKG_CONF; | 544 | confFiles << IPKG_CONF; |
537 | 545 | ||
538 | QStringList::Iterator lastFile = confFiles.end(); | 546 | QStringList::Iterator lastFile = confFiles.end(); |
539 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 547 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
540 | { | 548 | { |
541 | // Create absolute file path if necessary | 549 | // Create absolute file path if necessary |
542 | QString absFile = (*it); | 550 | QString absFile = (*it); |
543 | if ( !absFile.startsWith( "/" ) ) | 551 | if ( !absFile.startsWith( "/" ) ) |
544 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 552 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
545 | 553 | ||
546 | // Read in file | 554 | // Read in file |
547 | QFile f( absFile ); | 555 | QFile f( absFile ); |
548 | if ( f.open( IO_ReadOnly ) ) | 556 | if ( f.open( IO_ReadOnly ) ) |
549 | { | 557 | { |
550 | QTextStream s( &f ); | 558 | QTextStream s( &f ); |
551 | while ( !s.eof() ) | 559 | while ( !s.eof() ) |
552 | { | 560 | { |
553 | 561 | ||
554 | QString line = s.readLine().simplifyWhiteSpace(); | 562 | QString line = s.readLine().simplifyWhiteSpace(); |
555 | 563 | ||
556 | // Parse line and save info to the conf options list | 564 | // Parse line and save info to the conf options list |
557 | if ( !line.isEmpty() ) | 565 | if ( !line.isEmpty() ) |
558 | { | 566 | { |
559 | // Strip leading comment marker if exists | 567 | // Strip leading comment marker if exists |
560 | bool comment = false; | 568 | bool comment = false; |
561 | if ( line.startsWith( "#" ) ) | 569 | if ( line.startsWith( "#" ) ) |
562 | { | 570 | { |
563 | line.remove( 0, 1 ); | 571 | line.remove( 0, 1 ); |
564 | line = line.simplifyWhiteSpace(); | 572 | line = line.simplifyWhiteSpace(); |
565 | comment = true; | 573 | comment = true; |
566 | } | 574 | } |
567 | 575 | ||
568 | bool recognizedOption = true; | 576 | bool recognizedOption = true; |
569 | int pos = line.find( ' ', 1 ) + 1; | 577 | int pos = line.find( ' ', 1 ) + 1; |
570 | int endpos = line.find( ' ', pos ); | 578 | int endpos = line.find( ' ', pos ); |
571 | 579 | ||
572 | // Name | 580 | // Name |
573 | QString name = line.mid( pos, endpos - pos ); | 581 | QString name = line.mid( pos, endpos - pos ); |
574 | 582 | ||
575 | // Value | 583 | // Value |
576 | QString value = ""; | 584 | QString value = ""; |
577 | if ( endpos > -1 ) | 585 | if ( endpos > -1 ) |
578 | value = line.right( line.length() - endpos - 1 ); | 586 | value = line.right( line.length() - endpos - 1 ); |
579 | 587 | ||
580 | // Active | 588 | // Active |
581 | bool active = !comment; | 589 | bool active = !comment; |
582 | 590 | ||
583 | // Type | 591 | // Type |
584 | // For options w/type = Other, the mapping is as follows: | 592 | // For options w/type = Other, the mapping is as follows: |
585 | // name = typeStr (e.g. "lists_dir") | 593 | // name = typeStr (e.g. "lists_dir") |
586 | // value = value | 594 | // value = value |
587 | // features = name (from configuration file) | 595 | // features = name (from configuration file) |
588 | 596 | ||
589 | QString typeStr = line.left( pos - 1 ); | 597 | QString typeStr = line.left( pos - 1 ); |
590 | OConfItem::Type type; | 598 | OConfItem::Type type; |
591 | QString features; | 599 | QString features; |
592 | if ( typeStr == "src" ) | 600 | if ( typeStr == "src" ) |
593 | type = OConfItem::Source; | 601 | type = OConfItem::Source; |
594 | else if ( typeStr == "src/gz" ) | 602 | else if ( typeStr == "src/gz" ) |
595 | { | 603 | { |
596 | type = OConfItem::Source; | 604 | type = OConfItem::Source; |
597 | features = "Compressed"; | 605 | features = "Compressed"; |
598 | } | 606 | } |
599 | else if ( typeStr == "dest" ) | 607 | else if ( typeStr == "dest" ) |
600 | type = OConfItem::Destination; | 608 | type = OConfItem::Destination; |
601 | else if ( typeStr == "option" ) | 609 | else if ( typeStr == "option" ) |
602 | type = OConfItem::Option; | 610 | type = OConfItem::Option; |
603 | else if ( typeStr == "arch" ) | 611 | else if ( typeStr == "arch" ) |
604 | type = OConfItem::Arch; | 612 | type = OConfItem::Arch; |
605 | else if ( typeStr == "lists_dir" ) | 613 | else if ( typeStr == "lists_dir" ) |
606 | { | 614 | { |
607 | type = OConfItem::Other; | 615 | type = OConfItem::Other; |
608 | features = name; | 616 | features = name; |
609 | name = typeStr; | 617 | name = typeStr; |
618 | |||
619 | // Default value when not defined | ||
620 | if ( value == QString::null || value == "" ) | ||
621 | value = IPKG_PKG_PATH; | ||
610 | } | 622 | } |
611 | else | 623 | else |
612 | recognizedOption = false; | 624 | recognizedOption = false; |
613 | 625 | ||
614 | // Add to list | 626 | // Add to list |
615 | if ( recognizedOption ) | 627 | if ( recognizedOption ) |
616 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 628 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
617 | } | 629 | } |
618 | } | 630 | } |
619 | 631 | ||
620 | f.close(); | 632 | f.close(); |
621 | } | 633 | } |
622 | } | 634 | } |
623 | 635 | ||
624 | // Load Ipkg execution options from application configuration file | 636 | // Load Ipkg execution options from application configuration file |
625 | if ( m_config ) | 637 | if ( m_config ) |
626 | { | 638 | { |
627 | m_config->setGroup( "Ipkg" ); | 639 | m_config->setGroup( "Ipkg" ); |
628 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 640 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
629 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 641 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
630 | } | 642 | } |
631 | } | 643 | } |
632 | 644 | ||
633 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 645 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
634 | { | 646 | { |
635 | // Load Ipkg configuration info if not already cached | 647 | // Load Ipkg configuration info if not already cached |
636 | if ( !m_confInfo ) | 648 | if ( !m_confInfo ) |
637 | loadConfiguration(); | 649 | loadConfiguration(); |
638 | 650 | ||
639 | // Build new server list (caller is responsible for deleting) | 651 | // Build new server list (caller is responsible for deleting) |
640 | OConfItemList *sl = new OConfItemList; | 652 | OConfItemList *sl = new OConfItemList; |
641 | 653 | ||
642 | // If typefilter is empty, retrieve all items | 654 | // If typefilter is empty, retrieve all items |
643 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 655 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
644 | 656 | ||
645 | // Parse configuration info for servers | 657 | // Parse configuration info for servers |
646 | OConfItemListIterator it( *m_confInfo ); | 658 | OConfItemListIterator it( *m_confInfo ); |
647 | for ( ; it.current(); ++it ) | 659 | for ( ; it.current(); ++it ) |
648 | { | 660 | { |
649 | OConfItem *item = it.current(); | 661 | OConfItem *item = it.current(); |
650 | if ( retrieveAll || item->type() == typefilter ) | 662 | if ( retrieveAll || item->type() == typefilter ) |
651 | { | 663 | { |
652 | sl->append( item ); | 664 | sl->append( item ); |
653 | } | 665 | } |
654 | } | 666 | } |
655 | 667 | ||
656 | return sl; | 668 | return sl; |
657 | } | 669 | } |
658 | 670 | ||
659 | const QString &OIpkg::rootPath() | 671 | const QString &OIpkg::rootPath() |
660 | { | 672 | { |
661 | if ( m_rootPath.isEmpty() ) | 673 | if ( m_rootPath.isEmpty() ) |
662 | { | 674 | { |
663 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 675 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
664 | rootDest ? m_rootPath = rootDest->value() | 676 | rootDest ? m_rootPath = rootDest->value() |
665 | : m_rootPath = '/'; | 677 | : m_rootPath = '/'; |
666 | if ( m_rootPath.right( 1 ) == '/' ) | 678 | if ( m_rootPath.right( 1 ) == '/' ) |
667 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 679 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
668 | } | 680 | } |
669 | return m_rootPath; | 681 | return m_rootPath; |
670 | } | 682 | } |
671 | 683 | ||
672 | void OIpkg::linkPackageDir( const QString &dest ) | 684 | void OIpkg::linkPackageDir( const QString &dest ) |
673 | { | 685 | { |
674 | if ( !dest.isNull() ) | 686 | if ( !dest.isNull() ) |
675 | { | 687 | { |
676 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); | 688 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); |
677 | 689 | ||
678 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); | 690 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); |
679 | 691 | ||
680 | // Set package destination directory | 692 | // Set package destination directory |
681 | QString destDir = destConfItem->value(); | 693 | QString destDir = destConfItem->value(); |
682 | QString destInfoDir = destDir; | 694 | QString destInfoDir = destDir; |
683 | if ( destInfoDir.right( 1 ) != '/' ) | 695 | if ( destInfoDir.right( 1 ) != '/' ) |
684 | destInfoDir.append( '/' ); | 696 | destInfoDir.append( '/' ); |
685 | destInfoDir.append( IPKG_INFO_PATH ); | 697 | destInfoDir.append( IPKG_INFO_PATH ); |
686 | 698 | ||
687 | // Get list of installed packages in destination | 699 | // Get list of installed packages in destination |
688 | QDir packageDir( destInfoDir ); | 700 | QDir packageDir( destInfoDir ); |
689 | QStringList packageFiles; | 701 | QStringList packageFiles; |
690 | if ( packageDir.exists() ) | 702 | if ( packageDir.exists() ) |
691 | { | 703 | { |
692 | packageDir.setNameFilter( "*.list" ); | 704 | packageDir.setNameFilter( "*.list" ); |
693 | packageDir.setFilter( QDir::Files ); | 705 | packageDir.setFilter( QDir::Files ); |
694 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); | 706 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); |
695 | } | 707 | } |
696 | 708 | ||
697 | // Link all files for every package installed in desination | 709 | // Link all files for every package installed in desination |
698 | QStringList::Iterator lastFile = packageFiles.end(); | 710 | QStringList::Iterator lastFile = packageFiles.end(); |
699 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) | 711 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) |
700 | { | 712 | { |
701 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); | 713 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); |
702 | QString packageFileName = destInfoDir; | 714 | QString packageFileName = destInfoDir; |
703 | packageFileName.append( '/' ); | 715 | packageFileName.append( '/' ); |
704 | packageFileName.append( (*it) ); | 716 | packageFileName.append( (*it) ); |
705 | QFile packageFile( packageFileName ); | 717 | QFile packageFile( packageFileName ); |
706 | if ( packageFile.open( IO_ReadOnly ) ) | 718 | if ( packageFile.open( IO_ReadOnly ) ) |
707 | { | 719 | { |
708 | QTextStream t( &packageFile ); | 720 | QTextStream t( &packageFile ); |
709 | QString linkFile; | 721 | QString linkFile; |
710 | while ( !t.eof() ) | 722 | while ( !t.eof() ) |
711 | { | 723 | { |
712 | // Get the name of the file to link and build the sym link filename | 724 | // Get the name of the file to link and build the sym link filename |
713 | linkFile = t.readLine(); | 725 | linkFile = t.readLine(); |
714 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); | 726 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); |
715 | linkDest.prepend( rootPath() ); | 727 | linkDest.prepend( rootPath() ); |
716 | 728 | ||
717 | // If file installed file is actually symbolic link, use actual file for linking | 729 | // If file installed file is actually symbolic link, use actual file for linking |
718 | QFileInfo fileInfo( linkFile ); | 730 | QFileInfo fileInfo( linkFile ); |
719 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) | 731 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) |
720 | linkFile = fileInfo.readLink(); | 732 | linkFile = fileInfo.readLink(); |
721 | 733 | ||
722 | // See if directory exists in 'root', if not, create | 734 | // See if directory exists in 'root', if not, create |
723 | fileInfo.setFile( linkDest ); | 735 | fileInfo.setFile( linkDest ); |
724 | QString linkDestDirName = fileInfo.dirPath( true ); | 736 | QString linkDestDirName = fileInfo.dirPath( true ); |
725 | QDir linkDestDir( linkDestDirName ); | 737 | QDir linkDestDir( linkDestDirName ); |
726 | if ( !linkDestDir.exists() ) | 738 | if ( !linkDestDir.exists() ) |
727 | { | 739 | { |
728 | linkDestDir.mkdir( linkDestDirName ); | 740 | linkDestDir.mkdir( linkDestDirName ); |
729 | } | 741 | } |
730 | else | 742 | else |
731 | { | 743 | { |
732 | // Remove any previous link to make sure we will be pointing to the current version | 744 | // Remove any previous link to make sure we will be pointing to the current version |
733 | if ( QFile::exists( linkDest ) ) | 745 | if ( QFile::exists( linkDest ) ) |
734 | QFile::remove( linkDest ); | 746 | QFile::remove( linkDest ); |
735 | } | 747 | } |
736 | 748 | ||
737 | // Link the file | 749 | // Link the file |
738 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); | 750 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); |
739 | if ( symlink( linkFile, linkDest ) == -1 ) | 751 | if ( symlink( linkFile, linkDest ) == -1 ) |
740 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) | 752 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) |
741 | .arg( linkFile ) | 753 | .arg( linkFile ) |
742 | .arg( linkDest ) ); | 754 | .arg( linkDest ) ); |
743 | } | 755 | } |
744 | packageFile.close(); | 756 | packageFile.close(); |
745 | } | 757 | } |
746 | } | 758 | } |
747 | } | 759 | } |
748 | } | 760 | } |
749 | 761 | ||
750 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) | 762 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) |
751 | { | 763 | { |
752 | if ( !package.isNull() ) | 764 | if ( !package.isNull() ) |
753 | { | 765 | { |
754 | // Find destination package is installed in | 766 | // Find destination package is installed in |
755 | if ( destList ) | 767 | if ( destList ) |
756 | { | 768 | { |
757 | OConfItemListIterator it( *destList ); | 769 | OConfItemListIterator it( *destList ); |
758 | for ( ; it.current(); ++it ) | 770 | for ( ; it.current(); ++it ) |
759 | { | 771 | { |
760 | OConfItem *dest = it.current(); | 772 | OConfItem *dest = it.current(); |
761 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) | 773 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) |
762 | .arg( IPKG_INFO_PATH ) | 774 | .arg( IPKG_INFO_PATH ) |
763 | .arg( package ); | 775 | .arg( package ); |
764 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); | 776 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); |
765 | 777 | ||
766 | // If found and destination is not 'root', remove symbolic links | 778 | // If found and destination is not 'root', remove symbolic links |
767 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) | 779 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) |
768 | { | 780 | { |
769 | QFile destInfoFile( destInfoFileName ); | 781 | QFile destInfoFile( destInfoFileName ); |
770 | if ( destInfoFile.open( IO_ReadOnly ) ) | 782 | if ( destInfoFile.open( IO_ReadOnly ) ) |
771 | { | 783 | { |
772 | QTextStream t( &destInfoFile ); | 784 | QTextStream t( &destInfoFile ); |
773 | QString linkFile; | 785 | QString linkFile; |
774 | while ( !t.eof() ) | 786 | while ( !t.eof() ) |
775 | { | 787 | { |
776 | // Get the name of the file to link and build the sym link filename | 788 | // Get the name of the file to link and build the sym link filename |
777 | linkFile = t.readLine(); | 789 | linkFile = t.readLine(); |
778 | QString linkDest( linkFile.right( linkFile.length() - | 790 | QString linkDest( linkFile.right( linkFile.length() - |
779 | dest->value().length() ) ); | 791 | dest->value().length() ) ); |
780 | linkDest.prepend( rootPath() ); | 792 | linkDest.prepend( rootPath() ); |
781 | 793 | ||
782 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); | 794 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); |
783 | QFile::remove( linkDest ); | 795 | QFile::remove( linkDest ); |
784 | } | 796 | } |
785 | destInfoFile.close(); | 797 | destInfoFile.close(); |
786 | } | 798 | } |
787 | 799 | ||
788 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); | 800 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); |
789 | return; | 801 | return; |
790 | } | 802 | } |
791 | } | 803 | } |
792 | } | 804 | } |
793 | } | 805 | } |
794 | } | 806 | } |
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index d234251..0ad1c82 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp | |||
@@ -1,520 +1,523 @@ | |||
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 "oipkgconfigdlg.h" | 32 | #include "oipkgconfigdlg.h" |
33 | 33 | ||
34 | #include <opie2/ofiledialog.h> | 34 | #include <opie2/ofiledialog.h> |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
41 | #include <qgroupbox.h> | 41 | #include <qgroupbox.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qscrollview.h> | 46 | #include <qscrollview.h> |
47 | #include <qwhatsthis.h> | 47 | #include <qwhatsthis.h> |
48 | 48 | ||
49 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) | 49 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) |
50 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 50 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
51 | , m_ipkg( ipkg ) | 51 | , m_ipkg( ipkg ) |
52 | , m_configs( 0l ) | 52 | , m_configs( 0l ) |
53 | , m_installOptions( installOptions ) | 53 | , m_installOptions( installOptions ) |
54 | , m_serverCurrent( -1 ) | 54 | , m_serverCurrent( -1 ) |
55 | , m_destCurrent( -1 ) | 55 | , m_destCurrent( -1 ) |
56 | , m_layout( this, 2, 4 ) | 56 | , m_layout( this, 2, 4 ) |
57 | , m_tabWidget( this ) | 57 | , m_tabWidget( this ) |
58 | { | 58 | { |
59 | setCaption( tr( "Configuration" ) ); | 59 | setCaption( tr( "Configuration" ) ); |
60 | 60 | ||
61 | // Initialize configuration widgets | 61 | // Initialize configuration widgets |
62 | if ( !installOptions ) | 62 | if ( !installOptions ) |
63 | { | 63 | { |
64 | initServerWidget(); | 64 | initServerWidget(); |
65 | initDestinationWidget(); | 65 | initDestinationWidget(); |
66 | initProxyWidget(); | 66 | initProxyWidget(); |
67 | } | 67 | } |
68 | initOptionsWidget(); | 68 | initOptionsWidget(); |
69 | 69 | ||
70 | // Load configuration information | 70 | // Load configuration information |
71 | initData(); | 71 | initData(); |
72 | 72 | ||
73 | // Setup tabs for all info | 73 | // Setup tabs for all info |
74 | m_layout.addWidget( &m_tabWidget ); | 74 | m_layout.addWidget( &m_tabWidget ); |
75 | if ( !m_installOptions ) | 75 | if ( !m_installOptions ) |
76 | { | 76 | { |
77 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); | 77 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); |
78 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); | 78 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); |
79 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); | 79 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); |
80 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 80 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
81 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); | 81 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); |
82 | } | 82 | } |
83 | else | 83 | else |
84 | { | 84 | { |
85 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 85 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | void OIpkgConfigDlg::accept() | 89 | void OIpkgConfigDlg::accept() |
90 | { | 90 | { |
91 | // Save server, destination and proxy configuration | 91 | // Save server, destination and proxy configuration |
92 | if ( !m_installOptions ) | 92 | if ( !m_installOptions ) |
93 | { | 93 | { |
94 | // Update proxy information before saving settings | 94 | // Update proxy information before saving settings |
95 | OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); | 95 | OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); |
96 | if ( confItem ) | 96 | if ( confItem ) |
97 | { | 97 | { |
98 | confItem->setValue( m_proxyHttpServer->text() ); | 98 | confItem->setValue( m_proxyHttpServer->text() ); |
99 | confItem->setActive( m_proxyHttpActive->isChecked() ); | 99 | confItem->setActive( m_proxyHttpActive->isChecked() ); |
100 | } | 100 | } |
101 | else | 101 | else |
102 | m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", | 102 | m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", |
103 | m_proxyHttpServer->text(), QString::null, | 103 | m_proxyHttpServer->text(), QString::null, |
104 | m_proxyHttpActive->isChecked() ) ); | 104 | m_proxyHttpActive->isChecked() ) ); |
105 | 105 | ||
106 | confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); | 106 | confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); |
107 | if ( confItem ) | 107 | if ( confItem ) |
108 | { | 108 | { |
109 | confItem->setValue( m_proxyFtpServer->text() ); | 109 | confItem->setValue( m_proxyFtpServer->text() ); |
110 | confItem->setActive( m_proxyFtpActive->isChecked() ); | 110 | confItem->setActive( m_proxyFtpActive->isChecked() ); |
111 | } | 111 | } |
112 | else | 112 | else |
113 | m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", | 113 | m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", |
114 | m_proxyFtpServer->text(), QString::null, | 114 | m_proxyFtpServer->text(), QString::null, |
115 | m_proxyFtpActive->isChecked() ) ); | 115 | m_proxyFtpActive->isChecked() ) ); |
116 | 116 | ||
117 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); | 117 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); |
118 | if ( confItem ) | 118 | if ( confItem ) |
119 | confItem->setValue( m_proxyUsername->text() ); | 119 | confItem->setValue( m_proxyUsername->text() ); |
120 | else | 120 | else |
121 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", | 121 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", |
122 | m_proxyUsername->text() ) ); | 122 | m_proxyUsername->text() ) ); |
123 | 123 | ||
124 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); | 124 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); |
125 | if ( confItem ) | 125 | if ( confItem ) |
126 | confItem->setValue( m_proxyPassword->text() ); | 126 | confItem->setValue( m_proxyPassword->text() ); |
127 | else | 127 | else |
128 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", | 128 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", |
129 | m_proxyPassword->text() ) ); | 129 | m_proxyPassword->text() ) ); |
130 | 130 | ||
131 | QString listsDir = m_optSourceLists->text(); | ||
132 | if ( listsDir == QString::null || listsDir == "" ) | ||
133 | listsDir = "/usr/lib/ipkg/lists"; // TODO - use proper libipkg define | ||
131 | confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); | 134 | confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); |
132 | if ( confItem ) | 135 | if ( confItem ) |
133 | confItem->setValue( m_optSourceLists->text() ); | 136 | confItem->setValue( listsDir ); |
134 | else | 137 | else |
135 | m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", | 138 | m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", |
136 | m_optSourceLists->text(), "name" ) ); | 139 | listsDir, "name" ) ); |
137 | 140 | ||
138 | m_ipkg->setConfigItems( m_configs ); | 141 | m_ipkg->setConfigItems( m_configs ); |
139 | } | 142 | } |
140 | 143 | ||
141 | // Save options configuration | 144 | // Save options configuration |
142 | int options = 0; | 145 | int options = 0; |
143 | if ( m_optForceDepends->isChecked() ) | 146 | if ( m_optForceDepends->isChecked() ) |
144 | options |= FORCE_DEPENDS; | 147 | options |= FORCE_DEPENDS; |
145 | if ( m_optForceReinstall->isChecked() ) | 148 | if ( m_optForceReinstall->isChecked() ) |
146 | options |= FORCE_REINSTALL; | 149 | options |= FORCE_REINSTALL; |
147 | if ( m_optForceRemove->isChecked() ) | 150 | if ( m_optForceRemove->isChecked() ) |
148 | options |= FORCE_REMOVE; | 151 | options |= FORCE_REMOVE; |
149 | if ( m_optForceOverwrite->isChecked() ) | 152 | if ( m_optForceOverwrite->isChecked() ) |
150 | options |= FORCE_OVERWRITE; | 153 | options |= FORCE_OVERWRITE; |
151 | m_ipkg->setIpkgExecOptions( options ); | 154 | m_ipkg->setIpkgExecOptions( options ); |
152 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); | 155 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); |
153 | 156 | ||
154 | QDialog::accept(); | 157 | QDialog::accept(); |
155 | } | 158 | } |
156 | 159 | ||
157 | void OIpkgConfigDlg::reject() | 160 | void OIpkgConfigDlg::reject() |
158 | { | 161 | { |
159 | if ( m_configs ) | 162 | if ( m_configs ) |
160 | delete m_configs; | 163 | delete m_configs; |
161 | } | 164 | } |
162 | 165 | ||
163 | void OIpkgConfigDlg::initServerWidget() | 166 | void OIpkgConfigDlg::initServerWidget() |
164 | { | 167 | { |
165 | m_serverWidget = new QWidget( this ); | 168 | m_serverWidget = new QWidget( this ); |
166 | 169 | ||
167 | // Initialize UI | 170 | // Initialize UI |
168 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); | 171 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); |
169 | QScrollView *sv = new QScrollView( m_serverWidget ); | 172 | QScrollView *sv = new QScrollView( m_serverWidget ); |
170 | vb->addWidget( sv, 0, 0 ); | 173 | vb->addWidget( sv, 0, 0 ); |
171 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 174 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
172 | sv->setFrameStyle( QFrame::NoFrame ); | 175 | sv->setFrameStyle( QFrame::NoFrame ); |
173 | QWidget *container = new QWidget( sv->viewport() ); | 176 | QWidget *container = new QWidget( sv->viewport() ); |
174 | sv->addChild( container ); | 177 | sv->addChild( container ); |
175 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); | 178 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); |
176 | 179 | ||
177 | m_serverList = new QListBox( container ); | 180 | m_serverList = new QListBox( container ); |
178 | QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); | 181 | QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); |
179 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 182 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
180 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); | 183 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); |
181 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); | 184 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); |
182 | 185 | ||
183 | QPixmap pic; | 186 | QPixmap pic; |
184 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 187 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
185 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); | 188 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); |
186 | btn->setMinimumHeight( AppLnk::smallIconSize() ); | 189 | btn->setMinimumHeight( AppLnk::smallIconSize() ); |
187 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); | 190 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); |
188 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); | 191 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); |
189 | layout->addWidget( btn, 1, 0 ); | 192 | layout->addWidget( btn, 1, 0 ); |
190 | 193 | ||
191 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 194 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
192 | m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); | 195 | m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); |
193 | m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 196 | m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
194 | m_serverEditBtn->setEnabled( false ); | 197 | m_serverEditBtn->setEnabled( false ); |
195 | QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); | 198 | QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); |
196 | connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); | 199 | connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); |
197 | layout->addWidget( m_serverEditBtn, 1, 1 ); | 200 | layout->addWidget( m_serverEditBtn, 1, 1 ); |
198 | 201 | ||
199 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 202 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
200 | m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); | 203 | m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); |
201 | m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 204 | m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
202 | m_serverDeleteBtn->setEnabled( false ); | 205 | m_serverDeleteBtn->setEnabled( false ); |
203 | QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); | 206 | QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); |
204 | connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); | 207 | connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); |
205 | layout->addWidget( m_serverDeleteBtn, 1, 2 ); | 208 | layout->addWidget( m_serverDeleteBtn, 1, 2 ); |
206 | } | 209 | } |
207 | 210 | ||
208 | void OIpkgConfigDlg::initDestinationWidget() | 211 | void OIpkgConfigDlg::initDestinationWidget() |
209 | { | 212 | { |
210 | m_destWidget = new QWidget( this ); | 213 | m_destWidget = new QWidget( this ); |
211 | 214 | ||
212 | // Initialize UI | 215 | // Initialize UI |
213 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); | 216 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); |
214 | QScrollView *sv = new QScrollView( m_destWidget ); | 217 | QScrollView *sv = new QScrollView( m_destWidget ); |
215 | vb->addWidget( sv, 0, 0 ); | 218 | vb->addWidget( sv, 0, 0 ); |
216 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 219 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
217 | sv->setFrameStyle( QFrame::NoFrame ); | 220 | sv->setFrameStyle( QFrame::NoFrame ); |
218 | QWidget *container = new QWidget( sv->viewport() ); | 221 | QWidget *container = new QWidget( sv->viewport() ); |
219 | sv->addChild( container ); | 222 | sv->addChild( container ); |
220 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); | 223 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); |
221 | 224 | ||
222 | m_destList = new QListBox( container ); | 225 | m_destList = new QListBox( container ); |
223 | QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); | 226 | QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); |
224 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 227 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
225 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); | 228 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); |
226 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); | 229 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); |
227 | 230 | ||
228 | QPixmap pic; | 231 | QPixmap pic; |
229 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 232 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
230 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); | 233 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); |
231 | btn->setMinimumHeight( AppLnk::smallIconSize() ); | 234 | btn->setMinimumHeight( AppLnk::smallIconSize() ); |
232 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); | 235 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); |
233 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); | 236 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); |
234 | layout->addWidget( btn, 1, 0 ); | 237 | layout->addWidget( btn, 1, 0 ); |
235 | 238 | ||
236 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 239 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
237 | m_destEditBtn = new QPushButton( pic, tr( "Edit" ), container ); | 240 | m_destEditBtn = new QPushButton( pic, tr( "Edit" ), container ); |
238 | m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 241 | m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
239 | m_destEditBtn->setEnabled( false ); | 242 | m_destEditBtn->setEnabled( false ); |
240 | QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); | 243 | QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); |
241 | connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); | 244 | connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); |
242 | layout->addWidget( m_destEditBtn, 1, 1 ); | 245 | layout->addWidget( m_destEditBtn, 1, 1 ); |
243 | 246 | ||
244 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 247 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
245 | m_destDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); | 248 | m_destDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); |
246 | m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 249 | m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
247 | m_destDeleteBtn->setEnabled( false ); | 250 | m_destDeleteBtn->setEnabled( false ); |
248 | QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); | 251 | QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); |
249 | connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); | 252 | connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); |
250 | layout->addWidget( m_destDeleteBtn, 1, 2 ); | 253 | layout->addWidget( m_destDeleteBtn, 1, 2 ); |
251 | } | 254 | } |
252 | 255 | ||
253 | void OIpkgConfigDlg::initProxyWidget() | 256 | void OIpkgConfigDlg::initProxyWidget() |
254 | { | 257 | { |
255 | m_proxyWidget = new QWidget( this ); | 258 | m_proxyWidget = new QWidget( this ); |
256 | 259 | ||
257 | // Initialize UI | 260 | // Initialize UI |
258 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); | 261 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); |
259 | QScrollView *sv = new QScrollView( m_proxyWidget ); | 262 | QScrollView *sv = new QScrollView( m_proxyWidget ); |
260 | vb->addWidget( sv, 0, 0 ); | 263 | vb->addWidget( sv, 0, 0 ); |
261 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 264 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
262 | sv->setFrameStyle( QFrame::NoFrame ); | 265 | sv->setFrameStyle( QFrame::NoFrame ); |
263 | QWidget *container = new QWidget( sv->viewport() ); | 266 | QWidget *container = new QWidget( sv->viewport() ); |
264 | sv->addChild( container ); | 267 | sv->addChild( container ); |
265 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); | 268 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); |
266 | 269 | ||
267 | // HTTP proxy server configuration | 270 | // HTTP proxy server configuration |
268 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 271 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
269 | grpbox->layout()->setSpacing( 2 ); | 272 | grpbox->layout()->setSpacing( 2 ); |
270 | grpbox->layout()->setMargin( 4 ); | 273 | grpbox->layout()->setMargin( 4 ); |
271 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 274 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
272 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 275 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
273 | m_proxyHttpServer = new QLineEdit( grpbox ); | 276 | m_proxyHttpServer = new QLineEdit( grpbox ); |
274 | QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); | 277 | QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); |
275 | grplayout->addWidget( m_proxyHttpServer ); | 278 | grplayout->addWidget( m_proxyHttpServer ); |
276 | m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); | 279 | m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); |
277 | QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); | 280 | QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); |
278 | grplayout->addWidget( m_proxyHttpActive ); | 281 | grplayout->addWidget( m_proxyHttpActive ); |
279 | 282 | ||
280 | // FTP proxy server configuration | 283 | // FTP proxy server configuration |
281 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 284 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
282 | grpbox->layout()->setSpacing( 2 ); | 285 | grpbox->layout()->setSpacing( 2 ); |
283 | grpbox->layout()->setMargin( 4 ); | 286 | grpbox->layout()->setMargin( 4 ); |
284 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 287 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
285 | grplayout = new QVBoxLayout( grpbox->layout() ); | 288 | grplayout = new QVBoxLayout( grpbox->layout() ); |
286 | m_proxyFtpServer = new QLineEdit( grpbox ); | 289 | m_proxyFtpServer = new QLineEdit( grpbox ); |
287 | QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); | 290 | QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); |
288 | grplayout->addWidget( m_proxyFtpServer ); | 291 | grplayout->addWidget( m_proxyFtpServer ); |
289 | m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); | 292 | m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); |
290 | QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); | 293 | QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); |
291 | grplayout->addWidget( m_proxyFtpActive ); | 294 | grplayout->addWidget( m_proxyFtpActive ); |
292 | 295 | ||
293 | // Proxy server username and password configuration | 296 | // Proxy server username and password configuration |
294 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 297 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
295 | QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); | 298 | QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); |
296 | layout->addWidget( label, 2, 0 ); | 299 | layout->addWidget( label, 2, 0 ); |
297 | m_proxyUsername = new QLineEdit( container ); | 300 | m_proxyUsername = new QLineEdit( container ); |
298 | QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); | 301 | QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); |
299 | layout->addWidget( m_proxyUsername, 2, 1 ); | 302 | layout->addWidget( m_proxyUsername, 2, 1 ); |
300 | 303 | ||
301 | label = new QLabel( tr( "Password:" ), container ); | 304 | label = new QLabel( tr( "Password:" ), container ); |
302 | QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); | 305 | QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); |
303 | layout->addWidget( label, 3, 0 ); | 306 | layout->addWidget( label, 3, 0 ); |
304 | m_proxyPassword = new QLineEdit( container ); | 307 | m_proxyPassword = new QLineEdit( container ); |
305 | QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); | 308 | QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); |
306 | layout->addWidget( m_proxyPassword, 3, 1 ); | 309 | layout->addWidget( m_proxyPassword, 3, 1 ); |
307 | } | 310 | } |
308 | 311 | ||
309 | void OIpkgConfigDlg::initOptionsWidget() | 312 | void OIpkgConfigDlg::initOptionsWidget() |
310 | { | 313 | { |
311 | m_optionsWidget = new QWidget( this ); | 314 | m_optionsWidget = new QWidget( this ); |
312 | 315 | ||
313 | // Initialize UI | 316 | // Initialize UI |
314 | QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); | 317 | QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); |
315 | QScrollView *sv = new QScrollView( m_optionsWidget ); | 318 | QScrollView *sv = new QScrollView( m_optionsWidget ); |
316 | vb->addWidget( sv, 0, 0 ); | 319 | vb->addWidget( sv, 0, 0 ); |
317 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 320 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
318 | sv->setFrameStyle( QFrame::NoFrame ); | 321 | sv->setFrameStyle( QFrame::NoFrame ); |
319 | QWidget *container = new QWidget( sv->viewport() ); | 322 | QWidget *container = new QWidget( sv->viewport() ); |
320 | sv->addChild( container ); | 323 | sv->addChild( container ); |
321 | QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 ); | 324 | QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 ); |
322 | 325 | ||
323 | m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); | 326 | m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); |
324 | QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); | 327 | QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); |
325 | layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 ); | 328 | layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 ); |
326 | 329 | ||
327 | m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); | 330 | m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); |
328 | QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); | 331 | QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); |
329 | layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 ); | 332 | layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 ); |
330 | 333 | ||
331 | m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); | 334 | m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); |
332 | QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); | 335 | QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); |
333 | layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 ); | 336 | layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 ); |
334 | 337 | ||
335 | m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); | 338 | m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); |
336 | QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); | 339 | QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); |
337 | layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 ); | 340 | layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 ); |
338 | 341 | ||
339 | QLabel *l = new QLabel( tr( "Information level:" ), container ); | 342 | QLabel *l = new QLabel( tr( "Information level:" ), container ); |
340 | QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); | 343 | QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); |
341 | layout->addMultiCellWidget( l, 4, 4, 0, 1 ); | 344 | layout->addMultiCellWidget( l, 4, 4, 0, 1 ); |
342 | 345 | ||
343 | m_optVerboseIpkg = new QComboBox( container ); | 346 | m_optVerboseIpkg = new QComboBox( container ); |
344 | QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); | 347 | QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); |
345 | m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); | 348 | m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); |
346 | m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); | 349 | m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); |
347 | m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); | 350 | m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); |
348 | m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); | 351 | m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); |
349 | layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 ); | 352 | layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 ); |
350 | 353 | ||
351 | l = new QLabel( tr( "Package source lists directory:" ), container ); | 354 | l = new QLabel( tr( "Package source lists directory:" ), container ); |
352 | QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) ); | 355 | QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) ); |
353 | layout->addMultiCellWidget( l, 6, 6, 0, 1 ); | 356 | layout->addMultiCellWidget( l, 6, 6, 0, 1 ); |
354 | 357 | ||
355 | m_optSourceLists = new QLineEdit( container ); | 358 | m_optSourceLists = new QLineEdit( container ); |
356 | QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) ); | 359 | QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) ); |
357 | layout->addWidget( m_optSourceLists, 7, 0 ); | 360 | layout->addWidget( m_optSourceLists, 7, 0 ); |
358 | QPixmap pic; | 361 | QPixmap pic; |
359 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 362 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
360 | QPushButton *btn = new QPushButton( pic, QString::null, container ); | 363 | QPushButton *btn = new QPushButton( pic, QString::null, container ); |
361 | btn->setMaximumWidth( btn->height() ); | 364 | btn->setMaximumWidth( btn->height() ); |
362 | QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) ); | 365 | QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) ); |
363 | connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) ); | 366 | connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) ); |
364 | layout->addWidget( btn, 7, 1 ); | 367 | layout->addWidget( btn, 7, 1 ); |
365 | 368 | ||
366 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 369 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
367 | } | 370 | } |
368 | 371 | ||
369 | void OIpkgConfigDlg::initData() | 372 | void OIpkgConfigDlg::initData() |
370 | { | 373 | { |
371 | // Read ipkg configuration (server/destination/proxy) information | 374 | // Read ipkg configuration (server/destination/proxy) information |
372 | if ( m_ipkg && !m_installOptions ) | 375 | if ( m_ipkg && !m_installOptions ) |
373 | { | 376 | { |
374 | m_configs = m_ipkg->configItems(); | 377 | m_configs = m_ipkg->configItems(); |
375 | if ( m_configs ) | 378 | if ( m_configs ) |
376 | { | 379 | { |
377 | for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) | 380 | for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) |
378 | { | 381 | { |
379 | OConfItem *config = configIt.current(); | 382 | OConfItem *config = configIt.current(); |
380 | 383 | ||
381 | // Add configuration item to the appropriate dialog controls | 384 | // Add configuration item to the appropriate dialog controls |
382 | if ( config ) | 385 | if ( config ) |
383 | { | 386 | { |
384 | switch ( config->type() ) | 387 | switch ( config->type() ) |
385 | { | 388 | { |
386 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; | 389 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; |
387 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; | 390 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; |
388 | case OConfItem::Option : | 391 | case OConfItem::Option : |
389 | { | 392 | { |
390 | if ( config->name() == "http_proxy" ) | 393 | if ( config->name() == "http_proxy" ) |
391 | { | 394 | { |
392 | m_proxyHttpServer->setText( config->value() ); | 395 | m_proxyHttpServer->setText( config->value() ); |
393 | m_proxyHttpActive->setChecked( config->active() ); | 396 | m_proxyHttpActive->setChecked( config->active() ); |
394 | } | 397 | } |
395 | else if ( config->name() == "ftp_proxy" ) | 398 | else if ( config->name() == "ftp_proxy" ) |
396 | { | 399 | { |
397 | m_proxyFtpServer->setText( config->value() ); | 400 | m_proxyFtpServer->setText( config->value() ); |
398 | m_proxyFtpActive->setChecked( config->active() ); | 401 | m_proxyFtpActive->setChecked( config->active() ); |
399 | } | 402 | } |
400 | else if ( config->name() == "proxy_username" ) | 403 | else if ( config->name() == "proxy_username" ) |
401 | { | 404 | { |
402 | m_proxyUsername->setText( config->value() ); | 405 | m_proxyUsername->setText( config->value() ); |
403 | } | 406 | } |
404 | else if ( config->name() == "proxy_password" ) | 407 | else if ( config->name() == "proxy_password" ) |
405 | { | 408 | { |
406 | m_proxyPassword->setText( config->value() ); | 409 | m_proxyPassword->setText( config->value() ); |
407 | } | 410 | } |
408 | } | 411 | } |
409 | break; | 412 | break; |
410 | case OConfItem::Other : | 413 | case OConfItem::Other : |
411 | { | 414 | { |
412 | if ( config->name() == "lists_dir" ) | 415 | if ( config->name() == "lists_dir" ) |
413 | m_optSourceLists->setText( config->value() ); | 416 | m_optSourceLists->setText( config->value() ); |
414 | else // TODO - use proper libipkg define | 417 | else // TODO - use proper libipkg define |
415 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); | 418 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); |
416 | } | 419 | } |
417 | break; | 420 | break; |
418 | default : break; | 421 | default : break; |
419 | }; | 422 | }; |
420 | } | 423 | } |
421 | } | 424 | } |
422 | } | 425 | } |
423 | } | 426 | } |
424 | 427 | ||
425 | // Get Ipkg execution options | 428 | // Get Ipkg execution options |
426 | int options = m_ipkg->ipkgExecOptions(); | 429 | int options = m_ipkg->ipkgExecOptions(); |
427 | if ( options & FORCE_DEPENDS ) | 430 | if ( options & FORCE_DEPENDS ) |
428 | m_optForceDepends->setChecked( true ); | 431 | m_optForceDepends->setChecked( true ); |
429 | if ( options & FORCE_REINSTALL ) | 432 | if ( options & FORCE_REINSTALL ) |
430 | m_optForceReinstall->setChecked( true ); | 433 | m_optForceReinstall->setChecked( true ); |
431 | if ( options & FORCE_REMOVE ) | 434 | if ( options & FORCE_REMOVE ) |
432 | m_optForceRemove->setChecked( true ); | 435 | m_optForceRemove->setChecked( true ); |
433 | if ( options & FORCE_OVERWRITE ) | 436 | if ( options & FORCE_OVERWRITE ) |
434 | m_optForceOverwrite->setChecked( true ); | 437 | m_optForceOverwrite->setChecked( true ); |
435 | 438 | ||
436 | m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); | 439 | m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); |
437 | } | 440 | } |
438 | 441 | ||
439 | void OIpkgConfigDlg::slotServerSelected( int index ) | 442 | void OIpkgConfigDlg::slotServerSelected( int index ) |
440 | { | 443 | { |
441 | m_serverCurrent = index; | 444 | m_serverCurrent = index; |
442 | 445 | ||
443 | // Enable Edit and Delete buttons | 446 | // Enable Edit and Delete buttons |
444 | m_serverEditBtn->setEnabled( true ); | 447 | m_serverEditBtn->setEnabled( true ); |
445 | m_serverDeleteBtn->setEnabled( true ); | 448 | m_serverDeleteBtn->setEnabled( true ); |
446 | } | 449 | } |
447 | 450 | ||
448 | void OIpkgConfigDlg::slotServerNew() | 451 | void OIpkgConfigDlg::slotServerNew() |
449 | { | 452 | { |
450 | OConfItem *server = new OConfItem( OConfItem::Source ); | 453 | OConfItem *server = new OConfItem( OConfItem::Source ); |
451 | 454 | ||
452 | OIpkgServerDlg dlg( server, this ); | 455 | OIpkgServerDlg dlg( server, this ); |
453 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 456 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
454 | { | 457 | { |
455 | // Add to configuration option list | 458 | // Add to configuration option list |
456 | m_configs->append( server ); | 459 | m_configs->append( server ); |
457 | m_configs->sort(); | 460 | m_configs->sort(); |
458 | 461 | ||
459 | // Add to server list | 462 | // Add to server list |
460 | m_serverList->insertItem( server->name() ); | 463 | m_serverList->insertItem( server->name() ); |
461 | m_serverList->setCurrentItem( m_serverList->count() ); | 464 | m_serverList->setCurrentItem( m_serverList->count() ); |
462 | } | 465 | } |
463 | else | 466 | else |
464 | delete server; | 467 | delete server; |
465 | } | 468 | } |
466 | 469 | ||
467 | void OIpkgConfigDlg::slotServerEdit() | 470 | void OIpkgConfigDlg::slotServerEdit() |
468 | { | 471 | { |
469 | // Find selected server in list | 472 | // Find selected server in list |
470 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); | 473 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); |
471 | 474 | ||
472 | // Edit server | 475 | // Edit server |
473 | if ( server ) | 476 | if ( server ) |
474 | { | 477 | { |
475 | QString origName = server->name(); | 478 | QString origName = server->name(); |
476 | OIpkgServerDlg dlg( server, this ); | 479 | OIpkgServerDlg dlg( server, this ); |
477 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 480 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
478 | { | 481 | { |
479 | // Check to see if name has changed, if so update the server list | 482 | // Check to see if name has changed, if so update the server list |
480 | if ( server->name() != origName ) | 483 | if ( server->name() != origName ) |
481 | m_serverList->changeItem( server->name(), m_serverCurrent ); | 484 | m_serverList->changeItem( server->name(), m_serverCurrent ); |
482 | } | 485 | } |
483 | } | 486 | } |
484 | } | 487 | } |
485 | 488 | ||
486 | void OIpkgConfigDlg::slotServerDelete() | 489 | void OIpkgConfigDlg::slotServerDelete() |
487 | { | 490 | { |
488 | // Find selected server in list | 491 | // Find selected server in list |
489 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); | 492 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); |
490 | 493 | ||
491 | // Delete server | 494 | // Delete server |
492 | if ( server ) | 495 | if ( server ) |
493 | { | 496 | { |
494 | m_configs->removeRef( server ); | 497 | m_configs->removeRef( server ); |
495 | m_serverList->removeItem( m_serverCurrent ); | 498 | m_serverList->removeItem( m_serverCurrent ); |
496 | } | 499 | } |
497 | } | 500 | } |
498 | 501 | ||
499 | void OIpkgConfigDlg::slotDestSelected( int index ) | 502 | void OIpkgConfigDlg::slotDestSelected( int index ) |
500 | { | 503 | { |
501 | m_destCurrent = index; | 504 | m_destCurrent = index; |
502 | 505 | ||
503 | // Enable Edit and Delete buttons | 506 | // Enable Edit and Delete buttons |
504 | m_destEditBtn->setEnabled( true ); | 507 | m_destEditBtn->setEnabled( true ); |
505 | m_destDeleteBtn->setEnabled( true ); | 508 | m_destDeleteBtn->setEnabled( true ); |
506 | } | 509 | } |
507 | 510 | ||
508 | void OIpkgConfigDlg::slotDestNew() | 511 | void OIpkgConfigDlg::slotDestNew() |
509 | { | 512 | { |
510 | OConfItem *dest = new OConfItem( OConfItem::Destination ); | 513 | OConfItem *dest = new OConfItem( OConfItem::Destination ); |
511 | 514 | ||
512 | OIpkgDestDlg dlg( dest, this ); | 515 | OIpkgDestDlg dlg( dest, this ); |
513 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 516 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
514 | { | 517 | { |
515 | // Add to configuration option list | 518 | // Add to configuration option list |
516 | m_configs->append( dest ); | 519 | m_configs->append( dest ); |
517 | m_configs->sort(); | 520 | m_configs->sort(); |
518 | 521 | ||
519 | // Add to destination list | 522 | // Add to destination list |
520 | m_destList->insertItem( dest->name() ); | 523 | m_destList->insertItem( dest->name() ); |