summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/pmipkg.cpp
authortille <tille>2002-04-27 21:02:53 (UTC)
committer tille <tille>2002-04-27 21:02:53 (UTC)
commit69e271e44d23befc74a96a98708ddb6ec754a4b6 (patch) (unidiff)
tree6f8300d8858d2c7659eb90066b58b302a2863e43 /noncore/unsupported/oipkg/pmipkg.cpp
parentacdc33336307e48ac7089b146006fe7b36e321a5 (diff)
downloadopie-69e271e44d23befc74a96a98708ddb6ec754a4b6.zip
opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.gz
opie-69e271e44d23befc74a96a98708ddb6ec754a4b6.tar.bz2
setDocument working and some changes in install gui
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp134
1 files changed, 86 insertions, 48 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 45c89c5..f0992f5 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,20 +1,20 @@
1#include "pmipkg.h" 1#include "pmipkg.h"
2#include "pkdesc.h"
3#include "pksettings.h" 2#include "pksettings.h"
4#include "package.h" 3#include "package.h"
5#include "packagelistitem.h" 4#include "packagelistitem.h"
6 5
7#include <qpe/process.h> 6#include <qpe/process.h>
8#include <qpe/resource.h> 7#include <qpe/resource.h>
9#include <qpe/config.h> 8#include <qpe/config.h>
10#include <qpe/stringutil.h> 9#include <qpe/stringutil.h>
11#include <qdir.h> 10#include <qdir.h>
12#include <qfile.h> 11#include <qfile.h>
13#include <qmultilineedit.h> 12#include <qmultilineedit.h>
14#include <qstring.h> 13#include <qstring.h>
14#include <qcheckbox.h>
15#include <qtextstream.h> 15#include <qtextstream.h>
16#include <qtextview.h> 16#include <qtextview.h>
17 17
18#include <qprogressbar.h> 18#include <qprogressbar.h>
19#include <qpushbutton.h> 19#include <qpushbutton.h>
20#include <qlayout.h> 20#include <qlayout.h>
@@ -54,12 +54,15 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
54 cmd += " -dest "+settings->getDestinationName(); 54 cmd += " -dest "+settings->getDestinationName();
55 else 55 else
56 cmd += " -dest "+ dest; 56 cmd += " -dest "+ dest;
57 57
58 cmd += " -force-defaults "; 58 cmd += " -force-defaults ";
59 59
60// if (runwindow->forcedepends->isChecked())
61 // cmd += " -force-depends ";
62
60 out( "<hr><br>Starting to "+ args+"<br>\n"); 63 out( "<hr><br>Starting to "+ args+"<br>\n");
61 cmd += args; 64 cmd += args;
62 int r = 0; 65 int r = 0;
63#ifdef PROC 66#ifdef PROC
64 QString o = "start"; 67 QString o = "start";
65 Process *ipkg = new Process( "ls");//cmd ); 68 Process *ipkg = new Process( "ls");//cmd );
@@ -68,13 +71,13 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
68 ipkg->exec("",o); 71 ipkg->exec("",o);
69// out( o ); 72// out( o );
70#endif 73#endif
71#ifdef SYSTEM 74#ifdef SYSTEM
72 out( "running:<br>\n"+cmd+"<br>\n" ); 75 out( "running:<br>\n"+cmd+"<br>\n" );
73 QString redirect = "/tmp/oipkg.pipe"; 76 QString redirect = "/tmp/oipkg.pipe";
74 cmd += " | tee "+redirect+" 2>&1"; 77 cmd += " 2>&1 | tee "+redirect+" 2>&1";
75 pvDebug(2, "running >"+cmd+"<"); 78 pvDebug(2, "running >"+cmd+"<");
76 r = system(cmd.latin1()); 79 r = system(cmd.latin1());
77 QFile f( redirect ); 80 QFile f( redirect );
78 QString line; 81 QString line;
79 QString oldLine; 82 QString oldLine;
80 while ( ! f.open(IO_ReadOnly) ) {}; 83 while ( ! f.open(IO_ReadOnly) ) {};
@@ -100,14 +103,12 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
100 103
101void PmIpkg::makeLinks(Package *pack) 104void PmIpkg::makeLinks(Package *pack)
102{ 105{
103 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 106 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
104 QString dest = settings->getDestinationUrlByName( pack->dest() ); 107 QString dest = settings->getDestinationUrlByName( pack->dest() );
105 if (dest == "/" ) return; 108 if (dest == "/" ) return;
106 out( "<br>creating links<br>" );
107 out("for package "+pack->name()+" in "+dest+"<br>");
108 { 109 {
109 Config cfg( "oipkg", Config::User ); 110 Config cfg( "oipkg", Config::User );
110 cfg.setGroup( "Common" ); 111 cfg.setGroup( "Common" );
111 QString statusDir = cfg.readEntry( "statusDir", "" ); 112 QString statusDir = cfg.readEntry( "statusDir", "" );
112 } 113 }
113 QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list"; 114 QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list";
@@ -119,24 +120,27 @@ void PmIpkg::linkPackage( QString packFileName, QString dest )
119 QFile f( packFileName ); 120 QFile f( packFileName );
120 if ( ! f.open(IO_ReadOnly) ) 121 if ( ! f.open(IO_ReadOnly) )
121 { 122 {
122 out( "<b>Panik!</b> Could not open:<br>"+packFileName ); 123 out( "<b>Panik!</b> Could not open:<br>"+packFileName );
123 return; 124 return;
124 }; 125 };
126 out( "<br>creating links<br>" );
127 out("for package "+packFileName+" in "+dest+"<br>");
125 QTextStream t( &f ); 128 QTextStream t( &f );
126 QString fp; 129 QString fp;
127 while ( !t.eof() ) 130 while ( !t.eof() )
128 { 131 {
129 fp = t.readLine(); 132 fp = t.readLine();
130 processLinkDir( fp, dest ); 133 processLinkDir( fp, dest );
131 } 134 }
132 f.close(); 135 f.close();
133} 136}
134 137
135void PmIpkg::processLinkDir( QString file, QString dest ) 138void PmIpkg::processLinkDir( QString file, QString dest )
136{ 139{
140 pvDebug( 7,"PmIpkg::processLinkDir "+file+" to "+ dest);
137 if ( dest == "???" ) return; 141 if ( dest == "???" ) return;
138 QString destFile = file; 142 QString destFile = file;
139 file = dest+"/"+file; 143 file = dest+"/"+file;
140 if (file == dest) return; 144 if (file == dest) return;
141 QFileInfo fileInfo( file ); 145 QFileInfo fileInfo( file );
142 if ( fileInfo.isDir() ) 146 if ( fileInfo.isDir() )
@@ -164,58 +168,108 @@ void PmIpkg::processLinkDir( QString file, QString dest )
164 symlink( instFile, linkFile ); 168 symlink( instFile, linkFile );
165 } 169 }
166} 170}
167 171
168void PmIpkg::commit( PackageList pl ) 172void PmIpkg::commit( PackageList pl )
169 { 173 {
170 show( false ); 174 int sizecount = 0;
171 runwindow->outPut->setText("");
172 out( "<h1>"+tr("Todo")+"</h1>\n");
173
174 to_install.clear(); 175 to_install.clear();
175 to_remove.clear(); 176 to_remove.clear();
176 int sizecount = 0; 177 QString rem="<b>"+tr("To remove:")+"</b><br>\n";
177 QString rem="<b>To remove:</b><br>\n"; 178 QString inst="<b>"+tr("To install:")+"</b><br>\n";
178 QString inst="<b>To install:</b><br>\n";;
179 pl.allPackages(); 179 pl.allPackages();
180 for( Package *pack = pl.first();pack ; (pack = pl.next()) ) 180 for( Package *pack = pl.first();pack ; (pack = pl.next()) )
181 { 181 {
182 if ( pack && (pack->name() != "") && pack) 182 if ( pack && (pack->name() != "") && pack)
183 { 183 {
184 if ( pack->toInstall() ) 184 if ( pack->toInstall() )
185 { 185 {
186 to_install.append( pack ); 186 to_install.append( pack );
187 sizecount += pack->size().toInt(); 187 sizecount += pack->size().toInt();
188 inst += pack->name()+"\t(on "+pack->dest()+")<br>"; 188 inst += pack->name()+"\t("+tr("on ")+pack->dest()+")<br>";
189 } 189 }
190 if ( pack->toRemove() ) 190 if ( pack->toRemove() )
191 { 191 {
192 to_remove.append( pack ); 192 to_remove.append( pack );
193 sizecount += 1; 193 sizecount += 1;
194 rem += pack->name()+"<br>"; 194 rem += pack->name()+"<br>";
195 } 195 }
196 } 196 }
197 } 197 }
198 198
199 out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); 199 startDialog();
200
201 qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
202 200
203 runwindow->progress->setTotalSteps( sizecount ); 201}
204 202
205 connect( runwindow->doItButton, SIGNAL( clicked() ), 203void PmIpkg::startDialog()
206 SLOT( doIt() ) ); 204{
207 connect( runwindow->installButton, SIGNAL( clicked() ), 205 QDialog *d = new QDialog();
206 QGridLayout *RunWindowLayout = new QGridLayout( d );
207 RunWindowLayout->setSpacing( 2 );
208 RunWindowLayout->setMargin( 2 );
209
210 QHBoxLayout *buttons = new QHBoxLayout;
211 buttons->setSpacing( 6 );
212 buttons->setMargin( 0 );
213
214 PackageListView *plv = new PackageListView(d, "install",settings);
215 RunWindowLayout->addWidget( plv, 1, 0 );
216 for (Package *it=to_remove.first(); it != 0; it=to_remove.next() )
217 {
218 plv->insertItem( new PackageListItem(plv, it,settings) );
219 }
220 for (Package *it=to_install.first(); it != 0; it=to_install.next() )
221 {
222 plv->insertItem( new PackageListItem(plv, it,settings) );
223 }
224 QPushButton *doItButton = new QPushButton( d, "doItButton" );
225 doItButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, doItButton->sizePolicy().hasHeightForWidth() ) );
226 QFont doItButton_font( doItButton->font() );
227 doItButton_font.setPointSize( 8 );
228 doItButton->setFont( doItButton_font );
229 doItButton->setText( tr( "Do all " ) );
230 doItButton->setAutoResize( FALSE );
231 buttons->addWidget( doItButton );
232
233 QPushButton *installButton = new QPushButton( d, "installButton" );
234 QFont installButton_font( installButton->font() );
235 installButton_font.setPointSize( 8 );
236 installButton->setFont( installButton_font );
237 installButton->setText( tr( "Install" ) );
238 installButton->setAutoResize( TRUE );
239 buttons->addWidget( installButton );
240
241 QPushButton *removeButton = new QPushButton( d, "removeButton" );
242 QFont removeButton_font( removeButton->font() );
243 removeButton_font.setPointSize( 7 );
244 removeButton->setFont( removeButton_font );
245 removeButton->setText( tr( "Remove" ) );
246 removeButton->setAutoResize( TRUE );
247 buttons->addWidget( removeButton );
248
249 QPushButton *cancelButton = new QPushButton( d, "cancelButton" );
250 QFont cancelButton_font( cancelButton->font() );
251 cancelButton_font.setPointSize( 8 );
252 cancelButton->setFont( cancelButton_font );
253 cancelButton->setText( tr( "Cancel" ) );
254 cancelButton->setAutoResize( TRUE );
255 buttons->addWidget( cancelButton );
256
257 RunWindowLayout->addLayout( buttons, 3, 0 );
258
259 connect( doItButton, SIGNAL( clicked() ),
260 this, SLOT( doIt() ) );
261 connect( installButton, SIGNAL( clicked() ),
208 this, SLOT( install() ) ); 262 this, SLOT( install() ) );
209 connect( runwindow->removeButton, SIGNAL( clicked() ), 263 connect( removeButton, SIGNAL( clicked() ),
210 this, SLOT( remove() ) ); 264 this, SLOT( remove() ) );
211 connect( runwindow->cancelButton, SIGNAL( clicked() ), 265 connect( cancelButton, SIGNAL( clicked() ),
212 runwindow, SLOT( close() ) ); 266 d, SLOT( close() ) );
213 267 d->showMaximized();
214 runwindow->exec(); 268 d->exec();
215 out("<h1>"+tr("Its now save to close this window")+"<h1>"); 269 // d->close();
216} 270}
217 271
218void PmIpkg::doIt() 272void PmIpkg::doIt()
219{ 273{
220 remove(); 274 remove();
221 install(); 275 install();
@@ -248,13 +302,13 @@ void PmIpkg::install()
248 if ( to_install.count() == 0 ) return; 302 if ( to_install.count() == 0 ) return;
249 show( true ); 303 show( true );
250 out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); 304 out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>");
251 for (Package *it=to_install.first(); it != 0; it=to_install.next() ) 305 for (Package *it=to_install.first(); it != 0; it=to_install.next() )
252 { 306 {
253 307
254 if ( runIpkg("install " + it->name(), it->dest() ) == 0 ) 308 if ( runIpkg("install " + it->getPackageName(), it->dest() ) == 0 )
255 { 309 {
256 runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); 310 runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress());
257 if ( it->link() ) 311 if ( it->link() )
258 makeLinks( it ); 312 makeLinks( it );
259 it->processed(); 313 it->processed();
260 }else{ 314 }else{
@@ -311,38 +365,22 @@ void PmIpkg::showButtons(bool b)
311 365
312void PmIpkg::show(bool b) 366void PmIpkg::show(bool b)
313{ 367{
314 if (!runwindow->isVisible()) 368 if (!runwindow->isVisible())
315 runwindow->showMaximized(); 369 runwindow->showMaximized();
316 showButtons(b); 370 showButtons(b);
317 if ( b ) 371 if ( !b )
318 runwindow->progress->hide(); 372 runwindow->progress->hide();
319 else 373 else
320 runwindow->progress->show(); 374 runwindow->progress->show();
321} 375}
322 376
323void PmIpkg::installFile(const QString &fileName) 377void PmIpkg::installFile(const QString &fileName)
324{ 378{
379
380 to_install.clear();
381 to_remove.clear();
325 pvDebug( 2,"PmIpkg::installFile "+ fileName); 382 pvDebug( 2,"PmIpkg::installFile "+ fileName);
326 show( false ); 383 to_install.append( new Package(fileName,settings) );
327 runwindow->outPut->setText(""); 384 startDialog();
328 fileNameToInstall = fileName;
329 runwindow->doItButton->hide();
330 runwindow->removeButton->hide();
331 out("<b>"+tr("Install: ")+fileName);
332 connect( runwindow->installButton, SIGNAL( clicked() ),
333 this, SLOT( installFileName() ) );
334 connect( runwindow->cancelButton, SIGNAL( clicked() ),
335 runwindow, SLOT( close() ) );
336
337 runwindow->exec();
338} 385}
339 386
340void PmIpkg::installFileName()
341{
342 if ( !QFile::exists( fileNameToInstall ) ) return;
343 out(tr("Installing pacakge ")+fileNameToInstall+"<br>"+tr("please wait")+"</b><br>");
344 runIpkg("install " + fileNameToInstall );
345 if ( settings->createLinks() )
346 linkPackage( fileNameToInstall, settings->getDestinationUrl() );
347 out("<h1>"+tr("Its now save to close this window")+"<h1>");
348} \ No newline at end of file