author | drw <drw> | 2004-04-21 15:59:57 (UTC) |
---|---|---|
committer | drw <drw> | 2004-04-21 15:59:57 (UTC) |
commit | 7dc2ed4e55acf69b0edf01ded81f00b61c472312 (patch) (unidiff) | |
tree | 3d90c6ca4484f8558a530aa9169a27213ce01586 | |
parent | 5ac20617216e4592685940ede23f135d86e8d2cd (diff) | |
download | opie-7dc2ed4e55acf69b0edf01ded81f00b61c472312.zip opie-7dc2ed4e55acf69b0edf01ded81f00b61c472312.tar.gz opie-7dc2ed4e55acf69b0edf01ded81f00b61c472312.tar.bz2 |
Should have deleted a line before checking in...
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index b9c82df..696a64a 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -94,193 +94,192 @@ OIpkg::~OIpkg() | |||
94 | if ( m_confInfo ) | 94 | if ( m_confInfo ) |
95 | m_confInfo->setAutoDelete( true ); | 95 | m_confInfo->setAutoDelete( true ); |
96 | 96 | ||
97 | // Free up libipkg resources | 97 | // Free up libipkg resources |
98 | ipkg_deinit( &m_ipkgArgs ); | 98 | ipkg_deinit( &m_ipkgArgs ); |
99 | } | 99 | } |
100 | 100 | ||
101 | OConfItemList *OIpkg::configItems() | 101 | OConfItemList *OIpkg::configItems() |
102 | { | 102 | { |
103 | // Retrieve all configuration items | 103 | // Retrieve all configuration items |
104 | return filterConfItems(); | 104 | return filterConfItems(); |
105 | } | 105 | } |
106 | 106 | ||
107 | OConfItemList *OIpkg::servers() | 107 | OConfItemList *OIpkg::servers() |
108 | { | 108 | { |
109 | // Retrieve only servers | 109 | // Retrieve only servers |
110 | return filterConfItems( OConfItem::Source ); | 110 | return filterConfItems( OConfItem::Source ); |
111 | } | 111 | } |
112 | 112 | ||
113 | OConfItemList *OIpkg::destinations() | 113 | OConfItemList *OIpkg::destinations() |
114 | { | 114 | { |
115 | // Retrieve only destinations | 115 | // Retrieve only destinations |
116 | return filterConfItems( OConfItem::Destination ); | 116 | return filterConfItems( OConfItem::Destination ); |
117 | } | 117 | } |
118 | 118 | ||
119 | OConfItemList *OIpkg::options() | 119 | OConfItemList *OIpkg::options() |
120 | { | 120 | { |
121 | // Retrieve only destinations | 121 | // Retrieve only destinations |
122 | return filterConfItems( OConfItem::Option ); | 122 | return filterConfItems( OConfItem::Option ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void OIpkg::setConfigItems( OConfItemList *configList ) | 125 | void OIpkg::setConfigItems( OConfItemList *configList ) |
126 | { | 126 | { |
127 | if ( m_confInfo ) | 127 | if ( m_confInfo ) |
128 | delete m_confInfo; | 128 | delete m_confInfo; |
129 | 129 | ||
130 | m_confInfo = configList; | 130 | m_confInfo = configList; |
131 | 131 | ||
132 | // Write out new /etc/ipkg.conf | 132 | // Write out new /etc/ipkg.conf |
133 | QFile confFile( IPKG_CONF ); | 133 | QFile confFile( IPKG_CONF ); |
134 | if ( confFile.open( IO_WriteOnly ) ) | 134 | if ( confFile.open( IO_WriteOnly ) ) |
135 | { | 135 | { |
136 | QTextStream confStream( &confFile ); | 136 | QTextStream confStream( &confFile ); |
137 | confStream << "# Generated by Opie Package Manager\n\n"; | 137 | confStream << "# Generated by Opie Package Manager\n\n"; |
138 | 138 | ||
139 | OConfItemListIterator it( *m_confInfo ); | 139 | OConfItemListIterator it( *m_confInfo ); |
140 | for ( ; it.current(); ++it ) | 140 | for ( ; it.current(); ++it ) |
141 | { | 141 | { |
142 | OConfItem *item = it.current(); | 142 | OConfItem *item = it.current(); |
143 | 143 | ||
144 | // Only write out valid conf items | 144 | // Only write out valid conf items |
145 | if ( item->type() != OConfItem::NotDefined ) | 145 | if ( item->type() != OConfItem::NotDefined ) |
146 | { | 146 | { |
147 | QString confLine; | 147 | QString confLine; |
148 | if ( !item->active() ) | 148 | if ( !item->active() ) |
149 | confLine = "#"; | 149 | confLine = "#"; |
150 | 150 | ||
151 | switch ( item->type() ) | 151 | switch ( item->type() ) |
152 | { | 152 | { |
153 | case OConfItem::Source : confLine.append( "src " ); break; | 153 | case OConfItem::Source : confLine.append( "src " ); break; |
154 | case OConfItem::Destination : confLine.append( "dest " ); break; | 154 | case OConfItem::Destination : confLine.append( "dest " ); break; |
155 | case OConfItem::Option : confLine.append( "option " ); break; | 155 | case OConfItem::Option : confLine.append( "option " ); break; |
156 | case OConfItem::Arch : confLine.append( "arch " ); break; | 156 | case OConfItem::Arch : confLine.append( "arch " ); break; |
157 | default : break; | 157 | default : break; |
158 | }; | 158 | }; |
159 | 159 | ||
160 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 160 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | confFile.close(); | 164 | confFile.close(); |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 168 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | 171 | ||
172 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 172 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
173 | QStringList confFiles; | 173 | QStringList confFiles; |
174 | QDir confDir( IPKG_CONF_DIR ); | 174 | QDir confDir( IPKG_CONF_DIR ); |
175 | if ( confDir.exists() ) | 175 | if ( confDir.exists() ) |
176 | { | 176 | { |
177 | confDir.setNameFilter( "*.conf" ); | 177 | confDir.setNameFilter( "*.conf" ); |
178 | confDir.setFilter( QDir::Files ); | 178 | confDir.setFilter( QDir::Files ); |
179 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 179 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
180 | 180 | ||
181 | QStringList::Iterator lastFile = confFiles.end(); | 181 | QStringList::Iterator lastFile = confFiles.end(); |
182 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 182 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
183 | { | 183 | { |
184 | // Create absolute file path if necessary | 184 | // Create absolute file path if necessary |
185 | QString absFile = (*it); | 185 | QString absFile = (*it); |
186 | if ( !absFile.startsWith( "/" ) ) | 186 | if ( !absFile.startsWith( "/" ) ) |
187 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 187 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
188 | 188 | ||
189 | // Delete file | 189 | // Delete file |
190 | printf( "Deleting: \'%s\'\n", absFile.latin1() ); | ||
191 | QFile::remove( absFile ); | 190 | QFile::remove( absFile ); |
192 | } | 191 | } |
193 | } | 192 | } |
194 | 193 | ||
195 | // Reinitialize libipkg to pick up new configuration | 194 | // Reinitialize libipkg to pick up new configuration |
196 | ipkg_deinit( &m_ipkgArgs ); | 195 | ipkg_deinit( &m_ipkgArgs ); |
197 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 196 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
198 | m_ipkgArgs.noaction = false; | 197 | m_ipkgArgs.noaction = false; |
199 | m_ipkgArgs.force_defaults = true; | 198 | m_ipkgArgs.force_defaults = true; |
200 | } | 199 | } |
201 | 200 | ||
202 | void OIpkg::saveSettings() | 201 | void OIpkg::saveSettings() |
203 | { | 202 | { |
204 | // Save Ipkg execution options to application configuration file | 203 | // Save Ipkg execution options to application configuration file |
205 | if ( m_config ) | 204 | if ( m_config ) |
206 | { | 205 | { |
207 | m_config->setGroup( "Ipkg" ); | 206 | m_config->setGroup( "Ipkg" ); |
208 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 207 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
209 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 208 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
210 | } | 209 | } |
211 | } | 210 | } |
212 | 211 | ||
213 | OPackageList *OIpkg::availablePackages( const QString &server ) | 212 | OPackageList *OIpkg::availablePackages( const QString &server ) |
214 | { | 213 | { |
215 | // Load Ipkg configuration info if not already cached | 214 | // Load Ipkg configuration info if not already cached |
216 | if ( !m_confInfo ) | 215 | if ( !m_confInfo ) |
217 | loadConfiguration(); | 216 | loadConfiguration(); |
218 | 217 | ||
219 | // Build new server list (caller is responsible for deleting) | 218 | // Build new server list (caller is responsible for deleting) |
220 | OPackageList *pl = new OPackageList; | 219 | OPackageList *pl = new OPackageList; |
221 | 220 | ||
222 | // Open package list file | 221 | // Open package list file |
223 | QFile f( IPKG_PKG_PATH + "/" + server ); | 222 | QFile f( IPKG_PKG_PATH + "/" + server ); |
224 | if ( !f.open( IO_ReadOnly ) ) | 223 | if ( !f.open( IO_ReadOnly ) ) |
225 | return NULL; | 224 | return NULL; |
226 | QTextStream t( &f ); | 225 | QTextStream t( &f ); |
227 | 226 | ||
228 | // Process all information in package list file | 227 | // Process all information in package list file |
229 | OPackage *package = NULL; | 228 | OPackage *package = NULL; |
230 | QString line = t.readLine(); | 229 | QString line = t.readLine(); |
231 | while ( !t.eof() ) | 230 | while ( !t.eof() ) |
232 | { | 231 | { |
233 | // Determine key/value pair | 232 | // Determine key/value pair |
234 | int pos = line.find( ':', 0 ); | 233 | int pos = line.find( ':', 0 ); |
235 | QString key; | 234 | QString key; |
236 | if ( pos > -1 ) | 235 | if ( pos > -1 ) |
237 | key = line.mid( 0, pos ); | 236 | key = line.mid( 0, pos ); |
238 | else | 237 | else |
239 | key = QString::null; | 238 | key = QString::null; |
240 | QString value = line.mid( pos+2, line.length()-pos ); | 239 | QString value = line.mid( pos+2, line.length()-pos ); |
241 | 240 | ||
242 | // Allocate new package and insert into list | 241 | // Allocate new package and insert into list |
243 | if ( package == NULL && !key.isEmpty() ) | 242 | if ( package == NULL && !key.isEmpty() ) |
244 | { | 243 | { |
245 | package = new OPackage( value ); | 244 | package = new OPackage( value ); |
246 | package->setSource( server ); | 245 | package->setSource( server ); |
247 | pl->append( package ); | 246 | pl->append( package ); |
248 | } | 247 | } |
249 | 248 | ||
250 | // Update package data | 249 | // Update package data |
251 | if ( key == "Package" ) | 250 | if ( key == "Package" ) |
252 | package->setName( value ); | 251 | package->setName( value ); |
253 | else if ( key == "Version" ) | 252 | else if ( key == "Version" ) |
254 | package->setVersion( value ); | 253 | package->setVersion( value ); |
255 | else if ( key == "Section" ) | 254 | else if ( key == "Section" ) |
256 | package->setCategory( value ); | 255 | package->setCategory( value ); |
257 | //DataManager::setAvailableCategories( value ); | 256 | //DataManager::setAvailableCategories( value ); |
258 | else if ( key.isEmpty() && value.isEmpty() ) | 257 | else if ( key.isEmpty() && value.isEmpty() ) |
259 | package = NULL; | 258 | package = NULL; |
260 | 259 | ||
261 | // Skip past all description lines | 260 | // Skip past all description lines |
262 | if ( key == "Description" ) | 261 | if ( key == "Description" ) |
263 | { | 262 | { |
264 | line = t.readLine(); | 263 | line = t.readLine(); |
265 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 264 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
266 | line = t.readLine(); | 265 | line = t.readLine(); |
267 | } | 266 | } |
268 | else | 267 | else |
269 | line = t.readLine(); | 268 | line = t.readLine(); |
270 | } | 269 | } |
271 | 270 | ||
272 | f.close(); | 271 | f.close(); |
273 | 272 | ||
274 | return pl; | 273 | return pl; |
275 | } | 274 | } |
276 | 275 | ||
277 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 276 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
278 | { | 277 | { |
279 | // Load Ipkg configuration info if not already cached | 278 | // Load Ipkg configuration info if not already cached |
280 | if ( !m_confInfo ) | 279 | if ( !m_confInfo ) |
281 | loadConfiguration(); | 280 | loadConfiguration(); |
282 | 281 | ||
283 | // Build new server list (caller is responsible for deleting) | 282 | // Build new server list (caller is responsible for deleting) |
284 | OPackageList *pl = new OPackageList; | 283 | OPackageList *pl = new OPackageList; |
285 | 284 | ||
286 | // Open status file | 285 | // Open status file |