summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp1
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
@@ -126,129 +126,128 @@ 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
190printf( "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
202void OIpkg::saveSettings() 201void 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
213OPackageList *OIpkg::availablePackages( const QString &server ) 212OPackageList *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 );