-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 24 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 1 |
5 files changed, 33 insertions, 14 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 6bf9a7a..c95f482 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -1,357 +1,371 @@ // adadpted form qpe/qipkg #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/qpetoolbar.h> #include <qpe/qcopenvelope_qws.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qlistview.h> #include <qtextview.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> +#include <qmessagebox.h> #include <qlayout.h> #include "pksettingsbase.h" #include "packagelistitem.h" + MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ) { settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); ipkg = new PmIpkg( settings, this ); setCentralWidget( listViewPackages ); setCaption( tr("Package Manager") ); +// wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); + wait = new QMessageBox(this); + wait->setText(tr("Please wait")); + channel = new QCopChannel( "QPE/Application/oipkg", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); makeMenu(); connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); ipkg = new PmIpkg( settings, this ); packageList.setSettings( settings ); getList(); setSections(); setSubSections(); displayList(); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *srvMenu = new QPopupMenu( menuBar ); QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Package" ), srvMenu ); menuBar->insertItem( tr( "View" ), viewMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); // menuBar->insertItem( tr( "Sections" ), sectMenu ); QLabel *spacer = new QLabel( "", toolBar ); spacer->setBackgroundColor( toolBar->backgroundColor() ); toolBar->setStretchableWidget( spacer ); runAction = new QAction( tr( "Apply" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); connect( runAction, SIGNAL( activated() ), this, SLOT( runIpkg() ) ); runAction->addTo( toolBar ); runAction->addTo( srvMenu ); srvMenu->insertSeparator (); updateAction = new QAction( tr( "Update" ), Resource::loadIconSet( "oipkg/update" ), QString::null, 0, this, 0 ); connect( updateAction, SIGNAL( activated() ), this , SLOT( updateList() ) ); updateAction->addTo( toolBar ); updateAction->addTo( srvMenu ); // would we use for find // detailsAction = new QAction( tr( "Details" ), // Resource::loadIconSet( "find" ), // QString::null, 0, this, 0 ); // connect( detailsAction, SIGNAL( activated() ), // this , SLOT( showDetails() ) ); // detailsAction->addTo( toolBar ); // detailsAction->addTo( srvMenu ); QAction *cfgact; cfgact = new QAction( tr( "Setups" ), // Resource::loadIconSet( "" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettings() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Servers" ), // Resource::loadIconSet( "" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsSrv() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Destinations" ), // Resource::loadIconSet( "" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsDst() ) ); cfgact->addTo( cfgMenu ); QAction *a; sectionBar = new QPEToolBar( this ); addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); sectionBar->setHorizontalStretchable( true ); QLabel *label = new QLabel( tr("Section: "), sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); sectionBar->setStretchableWidget( label ); section = new QComboBox( false, sectionBar ); // section->setBackgroundMode( PaletteBackground ); label = new QLabel( " / ", sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); subsection = new QComboBox( false, sectionBar ); a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); a->addTo( sectionBar ); sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); sectionAction->setToggleAction( true ); sectionAction->setOn( true ); sectionAction->addTo( viewMenu ); findBar = new QPEToolBar(this); addToolBar( findBar, "Search", QMainWindow::Top, TRUE ); label = new QLabel( tr("Filter: "), findBar ); label->setBackgroundColor( findBar->backgroundColor() ); findBar->setHorizontalStretchable( TRUE ); findEdit = new QLineEdit( findBar, "findEdit" ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( displayList() ) ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); a->addTo( findBar ); findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 ); connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); findAction->setToggleAction( true ); findAction->setOn( true ); findAction->addTo( viewMenu ); #ifdef NEW Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( setting ) ); CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); findShow(bool b) sectionShow(bool b) #endif } MainWindow::~MainWindow() { } void MainWindow::runIpkg() { ipkg->commit( packageList ); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::updateList() { + wait->show(); QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); t->start( 0, false ); packageList.clear(); ipkg->update(); getList(); - t->stop(); + t->stop(); + wait->hide(); + } void MainWindow::getList() { + wait->show(); packageList.update(); displayList(); + wait->hide(); } void MainWindow::filterList() { + wait->show(); QString f = ""; if ( findAction->isOn() ) f = findEdit->text(); packageList.filterPackages( f ); + wait->hide(); } void MainWindow::displayList() { + wait->hide(); filterList(); listViewPackages->clear(); Package *pack = packageList.first(); while( pack ) { if ( pack && (pack->name() != "") ) listViewPackages->insertItem( new PackageListItem( listViewPackages, pack, settings ) ); pack = packageList.next(); } } void MainWindow::sectionChanged() { disconnect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); disconnect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); subsection->clear(); packageList.setSection( section->currentText() ); setSubSections(); connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); displayList(); } void MainWindow::subSectionChanged() { disconnect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); disconnect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); packageList.setSubSection( subsection->currentText() ); connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); displayList(); } void MainWindow::setSections() { section->clear(); section->insertStringList( packageList.getSections() ); } void MainWindow::setSubSections() { subsection->clear(); subsection->insertStringList( packageList.getSubSections() ); } void MainWindow::showSettings() { if ( settings->showDialog( 0 ) ) updateList(); } void MainWindow::showSettingsSrv() { if ( settings->showDialog( 1 ) ) updateList(); } void MainWindow::showSettingsDst() { if ( settings->showDialog( 2 ) ) updateList(); } void MainWindow::sectionShow(bool b) { if (b) sectionBar->show(); else sectionBar->hide(); sectionAction->setOn( b ); } void MainWindow::sectionClose() { sectionAction->setOn( false ); } void MainWindow::findShow(bool b) { if (b) findBar->show(); else findBar->hide(); findAction->setOn( b ); } void MainWindow::findClose() { findAction->setOn( false ); } void MainWindow::rotateUpdateIcon() { pvDebug(2, "MainWindow::rotateUpdateIcon"); if ( updateIcon ) updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); else updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); updateIcon = !updateIcon; } void MainWindow::setDocument(const QString &fileName) { installFile(fileName); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::installFile(const QString &fileName) { pvDebug(3, "MainWindow::installFile "+fileName); if ( !QFile::exists( fileName ) ) return; ipkg->installFile( fileName ); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::receive(const QCString &msg, const QByteArray &arg) { pvDebug(3, "QCop "+msg); if ( msg == "installFile(QString)" ) { installFile( QString(arg) ); } }
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h index bcb0cc9..a713d00 100644 --- a/noncore/unsupported/oipkg/mainwindow.h +++ b/noncore/unsupported/oipkg/mainwindow.h @@ -1,76 +1,78 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qaction.h> #include <qtimer.h> #include <qpopupmenu.h> #include "packagelist.h" #include "pmipkg.h" #include "pksettings.h" #include "packagelistview.h" class QComboBox; class QPEToolBar; class QLineEdit; class PackageListItem; class QCopChannel; +class QMessageBox; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~MainWindow(); QCopChannel *channel; protected slots: void runIpkg(); void getList(); void updateList(); void displayList(); void subSectionChanged(); void sectionChanged(); void showSettings(); void showSettingsSrv(); void showSettingsDst(); public slots: void sectionClose(); void sectionShow(bool); void findClose(); void findShow(bool); void filterList(); void receive (const QCString &, const QByteArray &); void setDocument (const QString &); private: void makeMenu(); void setSections(); void setSubSections(); void installFile(const QString &); bool updateIcon; PmIpkg* ipkg; PackageManagerSettings *settings; PackageList packageList; QAction *runAction; QAction *detailsAction; QAction *updateAction; QAction *findAction; QAction *sectionAction; PackageListView *listViewPackages; QPEToolBar *findBar; QLineEdit *findEdit; QPEToolBar *sectionBar; QComboBox *section; QComboBox *subsection; + QMessageBox *wait; private slots: void rotateUpdateIcon(); }; #endif diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index f84a9c4..be01837 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp @@ -105,387 +105,387 @@ void PackageManagerSettings::editServer(int i) if ( servername->isEnabled() ) { disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); } else { servername->setEnabled(TRUE); serverurl->setEnabled(TRUE); } servername->setText( servers->text(i) ); serverurl->setText( *serverurlDic[i] ); editedserver = i; connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); } void PackageManagerSettings::editDestination(int i) { if ( destinationname->isEnabled() ) { disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); } else { destinationname->setEnabled(TRUE); destinationurl->setEnabled(TRUE); } destinationname->setText( destinations->text(i) ); destinationurl->setText( *destinationurlDic[i] ); editeddestination = i; connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); } void PackageManagerSettings::removeServer() { disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); servername->setText(servers->text(editedserver)); serverurl->setText(*serverurlDic[editedserver]); disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->removeItem(editedserver); activeServers->removeItem(editedserver); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servername->setEnabled(FALSE); serverurl->setEnabled(FALSE); } void PackageManagerSettings::removeDestination() { disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); destinationname->setText(destinations->text(editedserver)); destinationurl->setText(*destinationurlDic[editedserver]); disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinations->removeItem(editeddestination); activeDestination->removeItem(editeddestination); activeLinkDestination->removeItem(editeddestination); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinationname->setEnabled(FALSE); destinationurl->setEnabled(FALSE); } void PackageManagerSettings::serverNameChanged(const QString& t) { disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->changeItem( t, editedserver ); activeServers->changeItem( t, editedserver ); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); } void PackageManagerSettings::destNameChanged(const QString& t) { disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinations->changeItem( t, editeddestination ); activeDestination->changeItem( t, editeddestination ); activeLinkDestination->changeItem( t, editeddestination ); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); } void PackageManagerSettings::serverUrlChanged(const QString& t) { serverurlDic.replace(editedserver, new QString(t)); } void PackageManagerSettings::destUrlChanged(const QString& t) { destinationurlDic.replace(editeddestination, new QString(t)); } void PackageManagerSettings::writeIpkgConfig(const QString& conffile) { QFile conf(conffile); if ( ! conf.open(IO_WriteOnly) ) return; QTextStream s(&conf); s << "# Written by qpie Package Manager\n"; for (int i=0; i<(int)activeServers->count(); i++) { QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); if ( !activeServers->isSelected(i) ) s << "#"; s << "src " << activeServers->text(i) << " " << url << "\n"; } for (int i=0; i<(int)destinations->count(); i++) { QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); s << "dest " << destinations->text(i) << " " << url << "\n"; } conf.close(); } void PackageManagerSettings::readInstallationSettings() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); installationSettingsCount = cfg.readNumEntry( "count", -1 ); currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1 for (int i = 0; i < installationSettingsCount; i++) { cfg.setGroup( "Setting_" + QString::number(i) ); settingName->insertItem( cfg.readEntry( "name", "???" ), i ); }; readInstallationSetting( currentSetting ); } /** * remove from conf file */ void PackageManagerSettings::removeInstallationSetting() { settingName->removeItem( settingName->currentItem() ); Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); cfg.clearGroup(); installationSettingsCount--; changed = true; settingName->setEditable( false ); } /** * write to confgile */ void PackageManagerSettings::newInstallationSetting() { installationSettingsCount++; settingName->insertItem( "New", installationSettingsCount ); settingName->setCurrentItem( installationSettingsCount ); settingName->setEditable( true ); changed = true; } void PackageManagerSettings::installationSettingChange(int cs) { writeCurrentInstallationSetting(); currentSetting = cs; readInstallationSetting( cs ); } void PackageManagerSettings::writeInstallationSettings() { if ( ! changed ) return ; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); cfg.writeEntry( "count", installationSettingsCount ); cfg.writeEntry( "current", currentSetting ); } writeCurrentInstallationSetting(); } void PackageManagerSettings::readInstallationSetting(int setting) { if ( setting < 0 ) return; Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( setting ) ); CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); QString dest = cfg.readEntry( "dest" ); QString linkdest = cfg.readEntry( "linkdest" ); pvDebug(3, "dest="+dest); pvDebug(3, "linkdest="+linkdest); for ( int i = 0; i < activeDestination->count(); i++) { if ( activeDestination->text( i ) == dest ) - activeDestination->setCurrentItem( i ); + activeDestination->setCurrentItem( i ); if ( activeLinkDestination->text( i ) == linkdest ) - activeLinkDestination->setCurrentItem( i ); + activeLinkDestination->setCurrentItem( i ); } } void PackageManagerSettings::writeCurrentInstallationSetting() { Config cfg( "oipkg", Config::User ); changed = false; cfg.setGroup( "Setting_" + QString::number(currentSetting) ); cfg.writeEntry( "link", CheckBoxLink->isChecked() ); cfg.writeEntry( "dest", getDestinationName() ); cfg.writeEntry( "linkdest" , getLinkDestinationName() ); QStringList sers = getActiveServers(); int srvc = 0; for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { cfg.writeEntry( "server_" + QString::number(srvc++), *it ); } cfg.writeEntry( "server_count", srvc ); } void PackageManagerSettings::renameInstallationSetting() { settingName->setEditable( true ); changed = true; } void PackageManagerSettings::installationSettingSetName(const QString &name) { settingName->changeItem( name, settingName->currentItem() ); changed = true; } bool PackageManagerSettings::readIpkgConfig(const QString& conffile) { QFile conf(conffile); if ( conf.open(IO_ReadOnly) ) { QTextStream s(&conf); servers->clear(); activeServers->clear(); activeDestination->clear(); activeLinkDestination->clear(); serverurlDic.clear(); destinationurlDic.clear(); ipkg_old=0; int currentserver=0; while ( !s.atEnd() ) { QString l = s.readLine(); QStringList token = QStringList::split(' ', l); if ( token[0] == "src" || token[0] == "#src" ) { currentserver=servers->count(); serverurlDic.insert(servers->count(),new QString(token[2])); int a = token[0] == "src" ? 1 : 0; int i = servers->count(); servers->insertItem(token[1]); activeServers->insertItem( token[1] ); activeServers->setSelected(i,a); } else if ( token[0] == "dest" ) { currentserver=destinations->count(); destinationurlDic.insert(destinations->count(),new QString(token[2])); destinations->insertItem(token[1]); activeDestination->insertItem( token[1] ); activeLinkDestination->insertItem( token[1] ); } else if ( token[0] == "option" ) { // ### somehow need to use the settings from netsetup // if ( token[1] == "http_proxy" ) // http->setText(token[2]); // else if ( token[1] == "ftp_proxy" ) // ftp->setText(token[2]); // else if ( token[1] == "proxy_username" ) // username->setText(token[2]); // else if ( token[1] == "proxy_password" ) // password->setText(token[2]); } else { // Old style? int eq = l.find('='); if ( eq >= 0 ) { QString v = l.mid(eq+1).stripWhiteSpace(); if ( v[0] == '"' || v[0] == '\'' ) { int cl=v.find(v[0],1); if ( cl >= 0 ) v = v.mid(1,cl-1); } if ( l.left(12) == "IPKG_SOURCE=" ) { ipkg_old=1; currentserver=servers->count(); serverurlDic.insert(servers->count(),new QString(v)); servers->insertItem(v); } else if ( l.left(13) == "#IPKG_SOURCE=" ) { serverurlDic.insert(servers->count(),new QString(v)); servers->insertItem(v); } else if ( l.left(10) == "IPKG_ROOT=" ) { // ### no UI // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) { // username->setText(v); // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) { // password->setText(v); // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) { // http->setText(v); // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) { // ftp->setText(v); } } } } if ( ipkg_old ) { servers->setSelectionMode(QListBox::Single); servers->setSelected(currentserver,TRUE); } return TRUE; } else { return FALSE; } } /** * read from config file(s) */ void PackageManagerSettings::readSettings() { readIpkgConfig("/etc/ipkg.conf"); readInstallationSettings(); } void PackageManagerSettings::writeSettings() { writeIpkgConfig("/etc/ipkg.conf"); writeInstallationSettings(); } /** shows the setting dialog */ bool PackageManagerSettings::showDialog( int i ) { TabWidget->setCurrentPage( i ); showMaximized(); bool ret = exec(); if ( ret ) writeSettings(); else readSettings(); return ret; } /** Returns the installation destination */ QString PackageManagerSettings::getDestinationName() { return activeDestination->currentText(); } /** Returns the link destination */ QString PackageManagerSettings::getLinkDestinationName() { return activeLinkDestination->currentText(); } /** Returns the URL of the active destination */ QString PackageManagerSettings::getDestinationUrl() { int dnr = activeDestination->currentItem(); return *destinationurlDic.find(dnr); } /** Should oipkg create links form install destination to link destination */ bool PackageManagerSettings::createLinks() { return CheckBoxLink->isChecked(); } /** get the servers that are active */ QStringList PackageManagerSettings::getActiveServers() { QStringList sl; for (int i=0; i<(int)activeServers->count(); i++) { if ( activeServers->isSelected(i) ) sl += activeServers->text(i); } return sl; } /** returns the destination listed in ipkg.conf */ QStringList PackageManagerSettings::getDestinationUrls() { QStringList sl; for (int i=0; i<(int)destinations->count(); i++) { sl += *destinationurlDic[i]; } return sl; } /** returns the destination listed in ipkg.conf */ QString PackageManagerSettings::getDestinationUrlByName(QString n) { QStringList sl; for (int i=0; i<(int)destinations->count(); i++) { if ( n == destinations->text(i)) return*destinationurlDic[i]; } diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index f0992f5..ecc97b2 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -13,374 +13,376 @@ #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindowopen = false; runwindow = new RunWindow( p, name, true, f ); } PmIpkg::~PmIpkg() { } //#define PROC #define SYSTEM int PmIpkg::runIpkg(const QString& args, const QString& dest ) { pvDebug(2,"PmIpkg::runIpkg "+args); #ifdef PROC QStringList cmd = "/usr/bin/ipkg "; #endif #ifdef SYSTEM QString cmd = "/usr/bin/ipkg "; #endif pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; // if (runwindow->forcedepends->isChecked()) // cmd += " -force-depends "; out( "<hr><br>Starting to "+ args+"<br>\n"); cmd += args; int r = 0; #ifdef PROC QString o = "start"; Process *ipkg = new Process( "ls");//cmd ); out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); QString description; ipkg->exec("",o); // out( o ); #endif #ifdef SYSTEM out( "running:<br>\n"+cmd+"<br>\n" ); QString redirect = "/tmp/oipkg.pipe"; cmd += " 2>&1 | tee "+redirect+" 2>&1"; pvDebug(2, "running >"+cmd+"<"); r = system(cmd.latin1()); QFile f( redirect ); QString line; QString oldLine; while ( ! f.open(IO_ReadOnly) ) {}; // { QTextStream t( &f ); // QString fp; while ( !t.eof() ) { line = t.readLine(); if ( line != oldLine ) { out( line +"<br>" ); oldLine = line; } } // } f.close(); out( "Finished!<br>"); #endif return r; } void PmIpkg::makeLinks(Package *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); QString dest = settings->getDestinationUrlByName( pack->dest() ); if (dest == "/" ) return; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list"; linkPackage( fn, dest ); } void PmIpkg::linkPackage( QString packFileName, QString dest ) { QFile f( packFileName ); if ( ! f.open(IO_ReadOnly) ) { out( "<b>Panik!</b> Could not open:<br>"+packFileName ); return; }; out( "<br>creating links<br>" ); out("for package "+packFileName+" in "+dest+"<br>"); QTextStream t( &f ); QString fp; while ( !t.eof() ) { fp = t.readLine(); processLinkDir( fp, dest ); } f.close(); } void PmIpkg::processLinkDir( QString file, QString dest ) { pvDebug( 7,"PmIpkg::processLinkDir "+file+" to "+ dest); if ( dest == "???" ) return; QString destFile = file; file = dest+"/"+file; if (file == dest) return; QFileInfo fileInfo( file ); if ( fileInfo.isDir() ) { QDir destDir( destFile ); destDir.mkdir( destFile, true ); QDir d( file ); d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { // out( "<b>"+fi->absFilePath()+"</b>" ); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).ascii() ); const char *linkFile = strdup( (destFile).ascii()); // out( "linking: "+file+" -> "+destFile ); qDebug( "linking: %s -> %s", instFile, linkFile ); symlink( instFile, linkFile ); } } void PmIpkg::commit( PackageList pl ) { int sizecount = 0; to_install.clear(); to_remove.clear(); QString rem="<b>"+tr("To remove:")+"</b><br>\n"; QString inst="<b>"+tr("To install:")+"</b><br>\n"; pl.allPackages(); for( Package *pack = pl.first();pack ; (pack = pl.next()) ) { if ( pack && (pack->name() != "") && pack) { if ( pack->toInstall() ) { to_install.append( pack ); sizecount += pack->size().toInt(); inst += pack->name()+"\t("+tr("on ")+pack->dest()+")<br>"; } if ( pack->toRemove() ) { to_remove.append( pack ); sizecount += 1; rem += pack->name()+"<br>"; } } } startDialog(); } void PmIpkg::startDialog() { - QDialog *d = new QDialog(); - QGridLayout *RunWindowLayout = new QGridLayout( d ); + installDialog = new QDialog(0,0,true); + QGridLayout *RunWindowLayout = new QGridLayout( installDialog ); RunWindowLayout->setSpacing( 2 ); RunWindowLayout->setMargin( 2 ); QHBoxLayout *buttons = new QHBoxLayout; buttons->setSpacing( 6 ); buttons->setMargin( 0 ); - PackageListView *plv = new PackageListView(d, "install",settings); + PackageListView *plv = new PackageListView(installDialog, "install",settings); RunWindowLayout->addWidget( plv, 1, 0 ); for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) { plv->insertItem( new PackageListItem(plv, it,settings) ); } for (Package *it=to_install.first(); it != 0; it=to_install.next() ) { plv->insertItem( new PackageListItem(plv, it,settings) ); } - QPushButton *doItButton = new QPushButton( d, "doItButton" ); + QPushButton *doItButton = new QPushButton( installDialog, "doItButton" ); doItButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, doItButton->sizePolicy().hasHeightForWidth() ) ); QFont doItButton_font( doItButton->font() ); doItButton_font.setPointSize( 8 ); doItButton->setFont( doItButton_font ); doItButton->setText( tr( "Do all " ) ); doItButton->setAutoResize( FALSE ); buttons->addWidget( doItButton ); - QPushButton *installButton = new QPushButton( d, "installButton" ); + QPushButton *installButton = new QPushButton( installDialog, "installButton" ); QFont installButton_font( installButton->font() ); installButton_font.setPointSize( 8 ); installButton->setFont( installButton_font ); installButton->setText( tr( "Install" ) ); installButton->setAutoResize( TRUE ); buttons->addWidget( installButton ); - QPushButton *removeButton = new QPushButton( d, "removeButton" ); + QPushButton *removeButton = new QPushButton( installDialog, "removeButton" ); QFont removeButton_font( removeButton->font() ); removeButton_font.setPointSize( 7 ); removeButton->setFont( removeButton_font ); removeButton->setText( tr( "Remove" ) ); removeButton->setAutoResize( TRUE ); buttons->addWidget( removeButton ); - QPushButton *cancelButton = new QPushButton( d, "cancelButton" ); + QPushButton *cancelButton = new QPushButton( installDialog, "cancelButton" ); QFont cancelButton_font( cancelButton->font() ); cancelButton_font.setPointSize( 8 ); cancelButton->setFont( cancelButton_font ); cancelButton->setText( tr( "Cancel" ) ); cancelButton->setAutoResize( TRUE ); buttons->addWidget( cancelButton ); RunWindowLayout->addLayout( buttons, 3, 0 ); connect( doItButton, SIGNAL( clicked() ), this, SLOT( doIt() ) ); connect( installButton, SIGNAL( clicked() ), this, SLOT( install() ) ); connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); connect( cancelButton, SIGNAL( clicked() ), - d, SLOT( close() ) ); - d->showMaximized(); - d->exec(); - // d->close(); + installDialog, SLOT( close() ) ); + installDialog->showMaximized(); + if ( installDialog->exec() ) doIt(); + installDialog->close(); } void PmIpkg::doIt() { remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; + installDialog->close(); show( true ); out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) { if ( runIpkg("remove " + it->name()) == 0) { runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); it->processed(); runwindow->progress->setProgress( 1 ); }else{ out("<b>"+tr("Error while removing")+"</b>"+it->name()); } } } void PmIpkg::install() { if ( to_install.count() == 0 ) return; + installDialog->close(); show( true ); out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); for (Package *it=to_install.first(); it != 0; it=to_install.next() ) { if ( runIpkg("install " + it->getPackageName(), it->dest() ) == 0 ) { runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); if ( it->link() ) makeLinks( it ); it->processed(); }else{ out("<b>"+tr("Error while installing")+"</b>"+it->name()); } } } void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) { qDebug("msg="+msg+" -- "+QString(dest) ); // QDir d( src ); // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); //// if (! d.exists() ) return; // const QFileInfoList *list = d.entryInfoList(); // QFileInfoListIterator it( *list ); // QFileInfo *fi; // while ( (fi=it.current()) ) { // processLinkDir( fi->absFilePath(), dest ); // ++it; // } } void PmIpkg::update() { show( false ); runIpkg( "update" ); runwindow->close(); } void PmIpkg::out( QString o ) { runwindow->outPut->setText( runwindow->outPut->text()+o ); runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight()); } void PmIpkg::showButtons(bool b) { if ( b ) { runwindow->cancelButton->hide(); runwindow->doItButton->hide(); runwindow->removeButton->hide(); runwindow->installButton->hide(); }else{ runwindow->cancelButton->show(); runwindow->doItButton->show(); runwindow->removeButton->show(); runwindow->installButton->show(); } } void PmIpkg::show(bool b) { if (!runwindow->isVisible()) runwindow->showMaximized(); showButtons(b); if ( !b ) runwindow->progress->hide(); else runwindow->progress->show(); } void PmIpkg::installFile(const QString &fileName) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::installFile "+ fileName); to_install.append( new Package(fileName,settings) ); startDialog(); } diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index f70283e..c5e6255 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,51 +1,52 @@ #ifndef PMIPKG_H #define PMIPKG_H #include <qobject.h> #include <qlist.h> #include <qstring.h> #include <qwidget.h> #include "pksettings.h" #include "runwindow.h" #include "packagelist.h" #include "debug.h" class Package; class PmIpkg : public QObject { Q_OBJECT public: PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); ~PmIpkg(); void commit( PackageList ); void update(); PackageList* getPackageList(); void showButtons(bool b=true); void show( bool buttons=true ); private: PackageManagerSettings* settings; RunWindow *runwindow; + QDialog *installDialog; QList<Package> to_remove; QList<Package> to_install; bool runwindowopen; QString fileNameToInstall; void startDialog(); void makeLinks(Package*); void linkPackage( QString, QString ); void processLinkDir( QString, QString ); int runIpkg(const QString& args, const QString& dest="" ); void out( QString ); public slots: void doIt(); void install(); void remove(); void installFile(const QString &fileName); void linkDestination( const QString, const QByteArray ); }; #endif |