summaryrefslogtreecommitdiff
authordrw <drw>2004-01-24 01:30:42 (UTC)
committer drw <drw>2004-01-24 01:30:42 (UTC)
commitd542ba6a426f9868d521dbd9eb502184086535fc (patch) (side-by-side diff)
tree6c975a8d20949d10dc48f2f372b836032988dcbd
parent77ad4fd70864e36745dbee587ca959a2e56998a6 (diff)
downloadopie-d542ba6a426f9868d521dbd9eb502184086535fc.zip
opie-d542ba6a426f9868d521dbd9eb502184086535fc.tar.gz
opie-d542ba6a426f9868d521dbd9eb502184086535fc.tar.bz2
Added download packages (requires current version of libipkg) and code to have Opie update links so apps will display properly in Launcher after adding/removing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog6
-rw-r--r--noncore/settings/packagemanager/entrydlg.cpp82
-rw-r--r--noncore/settings/packagemanager/entrydlg.h57
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp2
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp50
-rw-r--r--noncore/settings/packagemanager/mainwindow.h2
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp9
-rw-r--r--noncore/settings/packagemanager/packagemanager.pro4
-rw-r--r--noncore/settings/packagemanager/promptdlg.cpp2
9 files changed, 185 insertions, 29 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index 1ba12af..efa75b1 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,8 +1,14 @@
+2004-01-23 Dan Williams <drw@handhelds.org>
+
+ * Added package download functionality
+ * Have Opie update links after install/removal so that apps
+ will display properly in Launcher
+
2004-01-20 Dan Williams <drw@handhelds.org>
* Released version 0.2.0
* Converted to use libipkg in place of spawning ipkg process
2004-01-13 Dan Williams <drw@handhelds.org>
* Released version 0.1.0
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp
new file mode 100644
index 0000000..8deaa37
--- a/dev/null
+++ b/noncore/settings/packagemanager/entrydlg.cpp
@@ -0,0 +1,82 @@
+/*
+                This file is part of the OPIE Project
+
+ =. Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+             .=l.
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include "entrydlg.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+
+EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal )
+ : QDialog( parent, name, modal )
+{
+ QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
+
+ QLabel *l = new QLabel( label, this );
+ l->setAlignment( AlignLeft | AlignTop | WordBreak );
+ vbox->addWidget( l );
+
+ m_entry = new QLineEdit( this );
+ vbox->addWidget( m_entry );
+
+ connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) );
+}
+
+void EntryDlg::setText( const QString &text )
+{
+ m_entry->setText( text );
+ m_entry->selectAll();
+}
+
+QString EntryDlg::getText()
+{
+ return m_entry->text();
+}
+
+QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok,
+ QWidget *parent, const char *name )
+{
+ EntryDlg *dlg = new EntryDlg( label, parent, name, true );
+ dlg->setCaption( caption );
+ dlg->setText( text );
+
+ QString result;
+ *ok = ( dlg->exec() == QDialog::Accepted );
+ if ( *ok )
+ result = dlg->getText();
+
+ delete dlg;
+ return result;
+}
+void EntryDlg::tryAccept()
+{
+ if ( !m_entry->text().isEmpty() )
+ accept();
+}
diff --git a/noncore/settings/packagemanager/entrydlg.h b/noncore/settings/packagemanager/entrydlg.h
new file mode 100644
index 0000000..33a7920
--- a/dev/null
+++ b/noncore/settings/packagemanager/entrydlg.h
@@ -0,0 +1,57 @@
+/*
+                This file is part of the OPIE Project
+
+ =. Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+             .=l.
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef ENTRYDLG_H
+#define ENTRYDLG_H
+
+#include <qdialog.h>
+
+class QLineEdit;
+
+class EntryDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ static QString getText( const QString &caption, const QString &label, const QString &text = QString::null,
+ bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
+
+ EntryDlg( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = true );
+
+ void setText( const QString &text );
+ QString getText();
+
+private slots:
+ void tryAccept();
+
+private:
+ QLineEdit *m_entry;
+};
+
+#endif // EntryDlg_H
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 6a9ccbd..0c2ea78 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -136,16 +136,18 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
switch( m_command[ i ] )
{
case OPackage::Install : lineStr.append( tr( "install" ) );
break;
case OPackage::Remove : lineStr.append( tr( "remove" ) );
break;
case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
break;
+ case OPackage::Download : lineStr.append( tr( "download" ) );
+ break;
default :
break;
};
lineStr.append( ":\n" );
for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it )
{
lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 4611404..486561d 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -23,32 +23,35 @@
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qaction.h>
+#include <qdir.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qtoolbar.h>
#include <qwhatsthis.h>
+#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include "mainwindow.h"
#include "installdlg.h"
#include "filterdlg.h"
#include "promptdlg.h"
+#include "entrydlg.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
: QMainWindow( parent, name, fl || WStyle_ContextHelp )
, m_config( "packman" )
, m_packman( &m_config, this )
, m_menuBar( this )
, m_toolBar( this )
, m_findBar( this )
@@ -157,25 +160,23 @@ void MainWindow::initUI()
a->addTo( &m_toolBar );
QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( &m_toolBar );
-/*
QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
actionDownload->addTo( popup );
actionDownload->addTo( &m_toolBar );
-*/
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
a->addTo( popup );
a->addTo( &m_toolBar );
popup->insertSeparator();
@@ -365,67 +366,63 @@ void MainWindow::slotUpgrade()
OPackage::Upgrade );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
-/*
void MainWindow::slotDownload()
{
// Retrieve list of packages selected for download (if any)
QStringList *workingPackages = new QStringList();
for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
item != 0 ;
item = static_cast<QCheckListItem *>(item->nextSibling()) )
{
if ( item->isOn() )
workingPackages->append( item->text() );
}
if ( workingPackages->isEmpty() )
{
- // No packages were selected, prompt for URL of package to download
+ QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
+ return;
}
else
{
// Download selected packages
m_config.setGroup( "settings" );
QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
-// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
-// if ( ok && !text.isEmpty() )
-// workingDir = text; // user entered something and pressed ok
-// else
-// return; // user entered nothing or pressed cancel
+ bool ok = false;
+ QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
+ if ( ok && !text.isEmpty() )
+ workingDir = text; // user entered something and pressed ok
+ else
+ return; // user entered nothing or pressed cancel
-// // Store download directory in config file
-// m_config.writeEntry( "DownloadDir", workingDir );
+ // Store download directory in config file
+ m_config.writeEntry( "DownloadDir", workingDir );
// Get starting directory
-// char initDir[PATH_MAX];
-// getcwd( initDir, PATH_MAX );
+ QDir::setCurrent( workingDir );
- // Download packages
+ // Create package manager output widget
+ InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
+ OPackage::Download, workingPackages );
+ connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
+ // Display widget
+ m_widgetStack.addWidget( dlg, 3 );
+ m_widgetStack.raiseWidget( dlg );
}
-
- // Create package manager output widget
- InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
- OPackage::Download, workingPackages );
- connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
-
- // Display widget
- m_widgetStack.addWidget( dlg, 3 );
- m_widgetStack.raiseWidget( dlg );
}
-*/
void MainWindow::slotApply()
{
QStringList *removeList = 0x0;
QStringList *installList = 0x0;
QStringList *upgradeList = 0x0;
for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
@@ -521,16 +518,21 @@ void MainWindow::slotApply()
void MainWindow::slotCloseInstallDlg()
{
// Close install dialog
delete m_widgetStack.visibleWidget();
// Reload package list
initPackageInfo();
+
+ // Update Opie launcher links
+ QCopEnvelope e("QPE/System", "linkChanged(QString)");
+ QString lf = QString::null;
+ e << lf;
}
void MainWindow::slotConfigure()
{
if ( m_packman.configureDlg( false ) )
{
if ( PromptDlg::ask( tr( "Config updated" ),
tr( "The configuration has been updated. Do you want to update server and package information now?" ),
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h
index 49bb66c..285cddf 100644
--- a/noncore/settings/packagemanager/mainwindow.h
+++ b/noncore/settings/packagemanager/mainwindow.h
@@ -109,17 +109,17 @@ private slots:
// Status widget slots
void slotInitStatusBar( int numSteps );
void slotStatusText( const QString &status );
void slotStatusBar( int currStep );
// Actions menu action slots
void slotUpdate();
void slotUpgrade();
-// void slotDownload();
+ void slotDownload();
void slotApply();
void slotCloseInstallDlg();
void slotConfigure();
// View menu action slots
void slotShowNotInstalled();
void slotShowInstalled();
void slotShowUpdated();
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index eeb0131..ed9ea10 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -322,18 +322,23 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters,
break;
case OPackage::Remove : {
for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
ipkg_packages_remove( &m_ipkgArgs, (*it), true );
}
};
break;
- //case OPackage::Download : ;
- // break;
+ case OPackage::Download : {
+ for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ {
+ ipkg_packages_download( &m_ipkgArgs, (*it) );
+ }
+ };
+ break;
default : break;
};
return true;
}
void OIpkg::ipkgOutput( char *msg )
{
diff --git a/noncore/settings/packagemanager/packagemanager.pro b/noncore/settings/packagemanager/packagemanager.pro
index 55af13e..9a64322 100644
--- a/noncore/settings/packagemanager/packagemanager.pro
+++ b/noncore/settings/packagemanager/packagemanager.pro
@@ -8,27 +8,29 @@ SOURCES = opackage.cpp \
oipkg.cpp \
oipkgconfigdlg.cpp \
opackagemanager.cpp \
mainwindow.cpp \
installdlg.cpp \
packageinfodlg.cpp \
filterdlg.cpp \
promptdlg.cpp \
+ entrydlg.cpp \
main.cpp
HEADERS = opackage.h \
oconfitem.h \
oipkg.h \
oipkgconfigdlg.h \
opackagemanager.h \
mainwindow.h \
installdlg.h \
packageinfodlg.h \
filterdlg.h \
- promptdlg.h
+ promptdlg.h \
+ entrydlg.h
DEFINES += IPKG_LIB
DEFINES += HAVE_MKDTEMP
TARGET = packagemanager
INCLUDEPATH += $(OPIEDIR)/include $(IPKGDIR)
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie -lipkg
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp
index 3122699..bb27190 100644
--- a/noncore/settings/packagemanager/promptdlg.cpp
+++ b/noncore/settings/packagemanager/promptdlg.cpp
@@ -40,17 +40,17 @@ PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString
QWidget *parent )
: QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog )
, m_btnClicked( -1 )
{
setCaption( caption );
QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
QLabel *label = new QLabel( text, this );
- label->setAlignment( AlignCenter | WordBreak );
+ label->setAlignment( AlignCenter | AlignTop | WordBreak );
layout->addMultiCellWidget( label, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( btn1, this );
layout->addWidget( btn, 1, 0 );
connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) );
btn = new QPushButton( btn2, this );
layout->addWidget( btn, 1, 1 );