summaryrefslogtreecommitdiff
authordrw <drw>2004-04-21 15:57:19 (UTC)
committer drw <drw>2004-04-21 15:57:19 (UTC)
commit5ac20617216e4592685940ede23f135d86e8d2cd (patch) (unidiff)
tree17a2ba8adc06eed219b3b77e42d46e5e0c714630
parent4e6c1ec2758d337d772af3af49a1b74f737cd57f (diff)
downloadopie-5ac20617216e4592685940ede23f135d86e8d2cd.zip
opie-5ac20617216e4592685940ede23f135d86e8d2cd.tar.gz
opie-5ac20617216e4592685940ede23f135d86e8d2cd.tar.bz2
Implement saving of ipkg config information and re-initialization of libipkg after config info changed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 5c79ba9..b9c82df 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -128,6 +128,75 @@ void OIpkg::setConfigItems( OConfItemList *configList )
128 delete m_confInfo; 128 delete m_confInfo;
129 129
130 m_confInfo = configList; 130 m_confInfo = configList;
131
132 // Write out new /etc/ipkg.conf
133 QFile confFile( IPKG_CONF );
134 if ( confFile.open( IO_WriteOnly ) )
135 {
136 QTextStream confStream( &confFile );
137 confStream << "# Generated by Opie Package Manager\n\n";
138
139 OConfItemListIterator it( *m_confInfo );
140 for ( ; it.current(); ++it )
141 {
142 OConfItem *item = it.current();
143
144 // Only write out valid conf items
145 if ( item->type() != OConfItem::NotDefined )
146 {
147 QString confLine;
148 if ( !item->active() )
149 confLine = "#";
150
151 switch ( item->type() )
152 {
153 case OConfItem::Source : confLine.append( "src " ); break;
154 case OConfItem::Destination : confLine.append( "dest " ); break;
155 case OConfItem::Option : confLine.append( "option " ); break;
156 case OConfItem::Arch : confLine.append( "arch " ); break;
157 default : break;
158 };
159
160 confStream << confLine << " " << item->name() << " " << item->value() << "\n";
161 }
162 }
163
164 confFile.close();
165 }
166 else
167 {
168 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
169 return;
170 }
171
172 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
173 QStringList confFiles;
174 QDir confDir( IPKG_CONF_DIR );
175 if ( confDir.exists() )
176 {
177 confDir.setNameFilter( "*.conf" );
178 confDir.setFilter( QDir::Files );
179 confFiles = confDir.entryList( "*.conf", QDir::Files );
180
181 QStringList::Iterator lastFile = confFiles.end();
182 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
183 {
184 // Create absolute file path if necessary
185 QString absFile = (*it);
186 if ( !absFile.startsWith( "/" ) )
187 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
188
189 // Delete file
190printf( "Deleting: \'%s\'\n", absFile.latin1() );
191 QFile::remove( absFile );
192 }
193 }
194
195 // Reinitialize libipkg to pick up new configuration
196 ipkg_deinit( &m_ipkgArgs );
197 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
198 m_ipkgArgs.noaction = false;
199 m_ipkgArgs.force_defaults = true;
131} 200}
132 201
133void OIpkg::saveSettings() 202void OIpkg::saveSettings()
@@ -404,7 +473,8 @@ void OIpkg::loadConfiguration()
404 confFiles = confDir.entryList( "*.conf", QDir::Files ); 473 confFiles = confDir.entryList( "*.conf", QDir::Files );
405 confFiles << IPKG_CONF; 474 confFiles << IPKG_CONF;
406 475
407 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) 476 QStringList::Iterator lastFile = confFiles.end();
477 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
408 { 478 {
409 // Create absolute file path if necessary 479 // Create absolute file path if necessary
410 QString absFile = (*it); 480 QString absFile = (*it);