summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro4
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp893
-rw-r--r--noncore/settings/aqpkg/mainwin.h64
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp870
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h100
-rw-r--r--noncore/settings/aqpkg/progresswidget.cpp66
-rw-r--r--noncore/settings/aqpkg/progresswidget.h54
7 files changed, 909 insertions, 1142 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index b69bae4..fc1f53d 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -1,51 +1,47 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 HEADERS = global.h \ 3 HEADERS = global.h \
4 mainwin.h \ 4 mainwin.h \
5 datamgr.h \ 5 datamgr.h \
6 settingsimpl.h \ 6 settingsimpl.h \
7 ipkg.h \ 7 ipkg.h \
8 networkpkgmgr.h \
9 package.h \ 8 package.h \
10 progresswidget.h \
11 installdlgimpl.h \ 9 installdlgimpl.h \
12 instoptionsimpl.h \ 10 instoptionsimpl.h \
13 destination.h \ 11 destination.h \
14 utils.h \ 12 utils.h \
15 server.h \ 13 server.h \
16 helpwindow.h \ 14 helpwindow.h \
17 letterpushbutton.h \ 15 letterpushbutton.h \
18 inputdlg.h \ 16 inputdlg.h \
19 categoryfilterimpl.h 17 categoryfilterimpl.h
20 SOURCES = mainwin.cpp \ 18 SOURCES = mainwin.cpp \
21 datamgr.cpp \ 19 datamgr.cpp \
22 mem.cpp \ 20 mem.cpp \
23 settingsimpl.cpp \ 21 settingsimpl.cpp \
24 ipkg.cpp \ 22 ipkg.cpp \
25 networkpkgmgr.cpp \
26 main.cpp \ 23 main.cpp \
27 package.cpp \ 24 package.cpp \
28 progresswidget.cpp \
29 installdlgimpl.cpp \ 25 installdlgimpl.cpp \
30 instoptionsimpl.cpp \ 26 instoptionsimpl.cpp \
31 destination.cpp \ 27 destination.cpp \
32 utils.cpp \ 28 utils.cpp \
33 server.cpp \ 29 server.cpp \
34 helpwindow.cpp \ 30 helpwindow.cpp \
35 letterpushbutton.cpp \ 31 letterpushbutton.cpp \
36 inputdlg.cpp \ 32 inputdlg.cpp \
37 version.cpp \ 33 version.cpp \
38 categoryfilterimpl.cpp 34 categoryfilterimpl.cpp
39 INTERFACES= settings.ui \ 35 INTERFACES= settings.ui \
40 install.ui \ 36 install.ui \
41 instoptions.ui \ 37 instoptions.ui \
42 categoryfilter.ui 38 categoryfilter.ui
43 TARGET = aqpkg 39 TARGET = aqpkg
44INCLUDEPATH += $(OPIEDIR)/include 40INCLUDEPATH += $(OPIEDIR)/include
45DEPENDPATH += $(OPIEDIR)/include 41DEPENDPATH += $(OPIEDIR)/include
46LIBS += -lqpe -lopie -lstdc++ 42LIBS += -lqpe -lopie -lstdc++
47DESTDIR = $(OPIEDIR)/bin 43DESTDIR = $(OPIEDIR)/bin
48 44
49 45
50 46
51include ( ../../../include.pro ) 47include ( ../../../include.pro )
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index d79673f..c9963bc 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,338 +1,1155 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <unistd.h>
19
20#include <qpe/qcopenvelope_qws.h>
18#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpeapplication.h>
19#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/config.h>
20#include <qpe/resource.h> 25#include <qpe/resource.h>
21 26
22#include <qaction.h> 27#include <qaction.h>
28#include <qcombobox.h>
29#include <qfile.h>
30#include <qlabel.h>
31#include <qlayout.h>
23#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qlistview.h>
24#include <qmenubar.h> 34#include <qmenubar.h>
25#include <qmessagebox.h> 35#include <qmessagebox.h>
26#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qprogressbar.h>
27#include <qtimer.h> 38#include <qtimer.h>
28#include <qwhatsthis.h> 39#include <qwhatsthis.h>
29#include <qwidgetstack.h> 40#include <qwidgetstack.h>
30 41
31#include "mainwin.h" 42#include "categoryfilterimpl.h"
32#include "progresswidget.h"
33#include "datamgr.h" 43#include "datamgr.h"
34#include "networkpkgmgr.h" 44#include "global.h"
35#include "settingsimpl.h"
36#include "helpwindow.h" 45#include "helpwindow.h"
46#include "inputdlg.h"
47#include "installdlgimpl.h"
48#include "letterpushbutton.h"
49#include "mainwin.h"
50#include "settingsimpl.h"
37#include "utils.h" 51#include "utils.h"
38#include "global.h" 52
53extern int compareVersions( const char *v1, const char *v2 );
39 54
40MainWindow :: MainWindow() 55MainWindow :: MainWindow()
41 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 56 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
42{ 57{
43 setCaption( tr( "AQPkg - Package Manager" ) ); 58 setCaption( tr( "AQPkg - Package Manager" ) );
44 59
45 // Create UI widgets 60#ifdef QWS
46 progressWindow = new ProgressWidget( this ); 61 // read download directory from config file
47 networkPkgWindow = new NetworkPackageManager( this ); 62 Config cfg( "aqpkg" );
63 cfg.setGroup( "settings" );
64 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
65 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
66
67#endif
48 68
69 // Create UI widgets
70 initMainWidget();
71 initProgressWidget();
72
49 // Build menu and tool bars 73 // Build menu and tool bars
50 setToolBarsMovable( FALSE ); 74 setToolBarsMovable( FALSE );
51 75
52 QPEToolBar *bar = new QPEToolBar( this ); 76 QPEToolBar *bar = new QPEToolBar( this );
53 bar->setHorizontalStretchable( TRUE ); 77 bar->setHorizontalStretchable( TRUE );
54 QPEMenuBar *mb = new QPEMenuBar( bar ); 78 QPEMenuBar *mb = new QPEMenuBar( bar );
55 mb->setMargin( 0 ); 79 mb->setMargin( 0 );
56 bar = new QPEToolBar( this ); 80 bar = new QPEToolBar( this );
57 81
58 // Find toolbar 82 // Find toolbar
59 findBar = new QPEToolBar( this ); 83 findBar = new QPEToolBar( this );
60 addToolBar( findBar, QMainWindow::Top, true ); 84 addToolBar( findBar, QMainWindow::Top, true );
61 findBar->setHorizontalStretchable( true ); 85 findBar->setHorizontalStretchable( true );
62 findEdit = new QLineEdit( findBar ); 86 findEdit = new QLineEdit( findBar );
63 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 87 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
64 findBar->setStretchableWidget( findEdit ); 88 findBar->setStretchableWidget( findEdit );
65 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 89 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
66 90
67 // Packages menu 91 // Packages menu
68 QPopupMenu *popup = new QPopupMenu( this ); 92 QPopupMenu *popup = new QPopupMenu( this );
69 93
70 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 94 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
71 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 95 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
72 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( updateServer() ) ); 96 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
73 a->addTo( popup ); 97 a->addTo( popup );
74 a->addTo( bar ); 98 a->addTo( bar );
75 99
76 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 100 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
77 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 101 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
78 connect( actionUpgrade, SIGNAL( activated() ), networkPkgWindow, SLOT( upgradePackages() ) ); 102 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
79 actionUpgrade->addTo( popup ); 103 actionUpgrade->addTo( popup );
80 actionUpgrade->addTo( bar ); 104 actionUpgrade->addTo( bar );
81 105
82 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 106 iconDownload = Resource::loadPixmap( "aqpkg/download" );
83 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 107 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
84 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 108 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
85 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 109 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
86 connect( actionDownload, SIGNAL( activated() ), networkPkgWindow, SLOT( downloadPackage() ) ); 110 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
87 actionDownload->addTo( popup ); 111 actionDownload->addTo( popup );
88 actionDownload->addTo( bar ); 112 actionDownload->addTo( bar );
89 113
90 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 114 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
91 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 115 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
92 connect( a, SIGNAL( activated() ), networkPkgWindow, SLOT( applyChanges() ) ); 116 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
93 a->addTo( popup ); 117 a->addTo( popup );
94 a->addTo( bar ); 118 a->addTo( bar );
95 119
96 mb->insertItem( tr( "Actions" ), popup ); 120 mb->insertItem( tr( "Actions" ), popup );
97 121
98 // View menu 122 // View menu
99 popup = new QPopupMenu( this ); 123 popup = new QPopupMenu( this );
100 124
101 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 125 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
102 actionUninstalled->setToggleAction( TRUE ); 126 actionUninstalled->setToggleAction( TRUE );
103 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 127 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
104 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 128 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
105 actionUninstalled->addTo( popup ); 129 actionUninstalled->addTo( popup );
106 130
107 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 131 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
108 actionInstalled->setToggleAction( TRUE ); 132 actionInstalled->setToggleAction( TRUE );
109 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 133 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
110 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 134 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
111 actionInstalled->addTo( popup ); 135 actionInstalled->addTo( popup );
112 136
113 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 137 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
114 actionUpdated->setToggleAction( TRUE ); 138 actionUpdated->setToggleAction( TRUE );
115 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 139 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
116 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 140 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
117 actionUpdated->addTo( popup ); 141 actionUpdated->addTo( popup );
118 142
119 popup->insertSeparator(); 143 popup->insertSeparator();
120 144
121 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 145 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
122 actionFilter->setToggleAction( TRUE ); 146 actionFilter->setToggleAction( TRUE );
123 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 147 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
124 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 148 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
125 actionFilter->addTo( popup ); 149 actionFilter->addTo( popup );
126 150
127 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 151 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
128 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 152 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
129 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
130 a->addTo( popup ); 154 a->addTo( popup );
131 155
132 popup->insertSeparator(); 156 popup->insertSeparator();
133 157
134 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
135 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 159 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
136 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 160 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
137 a->addTo( popup ); 161 a->addTo( popup );
138 162
139 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 163 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
140 actionFindNext->setEnabled( FALSE ); 164 actionFindNext->setEnabled( FALSE );
141 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 165 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
142 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 166 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
143 actionFindNext->addTo( popup ); 167 actionFindNext->addTo( popup );
144 actionFindNext->addTo( findBar ); 168 actionFindNext->addTo( findBar );
145 169
146 mb->insertItem( tr( "View" ), popup ); 170 mb->insertItem( tr( "View" ), popup );
147 171
148 172
149 // Options menu 173 // Options menu
150 popup = new QPopupMenu( this ); 174 popup = new QPopupMenu( this );
151 175
152 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); 176 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 );
153 a->setWhatsThis( tr( "Click here to configure this application." ) ); 177 a->setWhatsThis( tr( "Click here to configure this application." ) );
154 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 178 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
155 a->addTo( popup ); 179 a->addTo( popup );
156 180
157 popup->insertSeparator(); 181 popup->insertSeparator();
158 182
159 a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); 183 a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 );
160 a->setWhatsThis( tr( "Click here for help." ) ); 184 a->setWhatsThis( tr( "Click here for help." ) );
161 connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); 185 connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) );
162 a->addTo( popup ); 186 a->addTo( popup );
163 187
164 a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); 188 a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 );
165 a->setWhatsThis( tr( "Click here for software version information." ) ); 189 a->setWhatsThis( tr( "Click here for software version information." ) );
166 connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) );
167 a->addTo( popup ); 191 a->addTo( popup );
168 192
169 mb->insertItem( tr( "Options" ), popup ); 193 mb->insertItem( tr( "Options" ), popup );
170 194
171 // Finish find toolbar creation 195 // Finish find toolbar creation
172 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 196 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
173 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 197 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
174 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
175 a->addTo( findBar ); 199 a->addTo( findBar );
176 findBar->hide(); 200 findBar->hide();
177 201
178
179 // Create widget stack and add UI widgets 202 // Create widget stack and add UI widgets
180 stack = new QWidgetStack( this ); 203 stack = new QWidgetStack( this );
181 stack->addWidget( progressWindow, 2 ); 204 stack->addWidget( progressWindow, 2 );
182 stack->addWidget( networkPkgWindow, 1 ); 205 stack->addWidget( networkPkgWindow, 1 );
183 setCentralWidget( stack ); 206 setCentralWidget( stack );
184 stack->raiseWidget( progressWindow ); 207 stack->raiseWidget( progressWindow );
185 208
186 // Delayed call to finish initialization 209 // Delayed call to finish initialization
187 QTimer::singleShot( 100, this, SLOT( init() ) ); 210 QTimer::singleShot( 100, this, SLOT( init() ) );
188} 211}
189 212
190MainWindow :: ~MainWindow() 213MainWindow :: ~MainWindow()
191{ 214{
192 delete mgr; 215 delete mgr;
193} 216}
194 217
218void MainWindow :: initMainWidget()
219{
220 networkPkgWindow = new QWidget( this );
221
222 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
223
224 serversList = new QComboBox( networkPkgWindow );
225 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) );
226 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
227
228 installedIcon = Resource::loadPixmap( "aqpkg/installed" );
229 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
230
231 packagesList = new QListView( networkPkgWindow );
232 packagesList->addColumn( tr( "Packages" ), 225 );
233 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
234
235 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
236 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
237 hbox1->addWidget( l );
238 hbox1->addWidget( serversList );
239
240
241 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 );
242 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 );
243
244 if ( showJumpTo )
245 {
246 char text[2];
247 text[1] = '\0';
248 for ( int i = 0 ; i < 26 ; ++i )
249 {
250 text[0] = 'A' + i;
251 LetterPushButton *b = new LetterPushButton( text, networkPkgWindow );
252 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
253 if ( i < 13 )
254 hbox3->addWidget( b );
255 else
256 hbox4->addWidget( b );
257 }
258 }
259
260 vbox->addWidget( packagesList );
261
262 downloadEnabled = TRUE;
263}
264
265void MainWindow :: initProgressWidget()
266{
267 progressWindow = new QWidget( this );
268
269 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
270
271 m_status = new QLabel( progressWindow );
272 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
273 layout->addWidget( m_status );
274
275 m_progress = new QProgressBar( progressWindow );
276 layout->addWidget( m_progress );
277}
278
195void MainWindow :: init() 279void MainWindow :: init()
196{ 280{
197 stack->raiseWidget( progressWindow ); 281 stack->raiseWidget( progressWindow );
198 282
199 mgr = new DataManager(); 283 mgr = new DataManager();
200 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) ); 284 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
201 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 285 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
202 progressWindow, SLOT( setMessage( const QString & ) ) ); 286 this, SLOT( setProgressMessage( const QString & ) ) );
203 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) ); 287 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
204 mgr->loadServers(); 288 mgr->loadServers();
205 289
206 networkPkgWindow->setDataManager( mgr ); 290 showUninstalledPkgs = false;
207 networkPkgWindow->updateData(); 291 showInstalledPkgs = false;
208 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) ); 292 showUpgradedPkgs = false;
209 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) ); 293 categoryFilterEnabled = false;
210 connect( networkPkgWindow, SIGNAL( appEnableUpgrade( bool ) ), this, SLOT( enableUpgrade( bool ) ) ); 294
211 connect( networkPkgWindow, SIGNAL( appEnableDownload( bool ) ), this, SLOT( enableDownload( bool ) ) ); 295 updateData();
212 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
213 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
214 progressWindow, SLOT( setMessage( const QString & ) ) );
215 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
216 296
217 stack->raiseWidget( networkPkgWindow ); 297 stack->raiseWidget( networkPkgWindow );
218} 298}
219 299
220void MainWindow :: setDocument( const QString &doc ) 300void MainWindow :: setDocument( const QString &doc )
221{ 301{
222 // Remove path from package 302 // Remove path from package
223 QString package = Utils::getPackageNameFromIpkFilename( doc ); 303 QString package = Utils::getPackageNameFromIpkFilename( doc );
224// std::cout << "Selecting package " << package << std::endl; 304// std::cout << "Selecting package " << package << std::endl;
225 networkPkgWindow->selectLocalPackage( package ); 305
306 // First select local server
307 for ( int i = 0 ; i < serversList->count() ; ++i )
308 {
309 if ( serversList->text( i ) == LOCAL_IPKGS )
310 {
311 serversList->setCurrentItem( i );
312 break;
313 }
314 }
315 serverSelected( 0 );
316
317 // Now set the check box of the selected package
318 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
319 item != 0 ;
320 item = (QCheckListItem *)item->nextSibling() )
321 {
322 if ( item->text().startsWith( package ) )
323 {
324 item->setOn( true );
325 break;
326 }
327 }
226} 328}
227 329
228void MainWindow :: displaySettings() 330void MainWindow :: displaySettings()
229{ 331{
230 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 332 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
231 if ( dlg->showDlg( 0 ) ) 333 if ( dlg->showDlg( 0 ) )
232 networkPkgWindow->updateData(); 334 updateData();
233 delete dlg; 335 delete dlg;
234} 336}
235 337
236void MainWindow :: displayHelp() 338void MainWindow :: displayHelp()
237{ 339{
238 HelpWindow *dlg = new HelpWindow( this ); 340 HelpWindow *dlg = new HelpWindow( this );
239 dlg->exec(); 341 dlg->exec();
240 delete dlg; 342 delete dlg;
241} 343}
242 344
243void MainWindow :: displayFindBar() 345void MainWindow :: displayFindBar()
244{ 346{
245 findBar->show(); 347 findBar->show();
246 findEdit->setFocus(); 348 findEdit->setFocus();
247} 349}
248 350
249void MainWindow :: repeatFind() 351void MainWindow :: repeatFind()
250{ 352{
251 networkPkgWindow->searchForPackage( findEdit->text() ); 353 searchForPackage( findEdit->text() );
252} 354}
253 355
254void MainWindow :: findPackage( const QString &text ) 356void MainWindow :: findPackage( const QString &text )
255{ 357{
256 actionFindNext->setEnabled( !text.isEmpty() ); 358 actionFindNext->setEnabled( !text.isEmpty() );
257 networkPkgWindow->searchForPackage( text ); 359 searchForPackage( text );
258} 360}
259 361
260void MainWindow :: hideFindBar() 362void MainWindow :: hideFindBar()
261{ 363{
262 findBar->hide(); 364 findBar->hide();
263} 365}
264 366
265void MainWindow :: displayAbout() 367void MainWindow :: displayAbout()
266{ 368{
267 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); 369 QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) );
268} 370}
269 371
270void MainWindow :: filterUninstalledPackages() 372void MainWindow :: filterUninstalledPackages()
271{ 373{
272 networkPkgWindow->showOnlyUninstalledPackages( actionUninstalled->isOn() ); 374 showUninstalledPkgs = actionUninstalled->isOn();
375 if ( showUninstalledPkgs )
376 {
377 showInstalledPkgs = FALSE;
378 showUpgradedPkgs = FALSE;
379 }
380 serverSelected( -1 );
381
273 actionInstalled->setOn( FALSE ); 382 actionInstalled->setOn( FALSE );
274 actionUpdated->setOn( FALSE ); 383 actionUpdated->setOn( FALSE );
275} 384}
276 385
277void MainWindow :: filterInstalledPackages() 386void MainWindow :: filterInstalledPackages()
278{ 387{
388 showInstalledPkgs = actionInstalled->isOn();
389 if ( showInstalledPkgs )
390 {
391 showUninstalledPkgs = FALSE;
392 showUpgradedPkgs = FALSE;
393 }
394 serverSelected( -1 );
395
279 actionUninstalled->setOn( FALSE ); 396 actionUninstalled->setOn( FALSE );
280 networkPkgWindow->showOnlyInstalledPackages( actionInstalled->isOn() );
281 actionUpdated->setOn( FALSE ); 397 actionUpdated->setOn( FALSE );
282} 398}
283 399
284void MainWindow :: filterUpgradedPackages() 400void MainWindow :: filterUpgradedPackages()
285{ 401{
402 showUpgradedPkgs = actionUpdated->isOn();
403 if ( showUpgradedPkgs )
404 {
405 showUninstalledPkgs = FALSE;
406 showInstalledPkgs = FALSE;
407 }
408 serverSelected( -1 );
409
286 actionUninstalled->setOn( FALSE ); 410 actionUninstalled->setOn( FALSE );
287 actionInstalled->setOn( FALSE ); 411 actionInstalled->setOn( FALSE );
288 networkPkgWindow->showUpgradedPackages( actionUpdated->isOn() );
289} 412}
290 413
291void MainWindow :: setFilterCategory() 414bool MainWindow :: setFilterCategory()
292{ 415{
293 if ( networkPkgWindow->setFilterCategory() ) 416 // Get categories;
417 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
418 if ( dlg.exec() == QDialog::Accepted )
419 {
420 categoryFilter = dlg.getSelectedFilter();
421
422 if ( categoryFilter == "" )
423 return false;
424
425 categoryFilterEnabled = true;
426 serverSelected( -1 );
294 actionFilter->setOn( TRUE ); 427 actionFilter->setOn( TRUE );
428 return true;
429 }
430
431 return false;
295} 432}
296 433
297void MainWindow :: filterCategory() 434void MainWindow :: filterCategory()
298{ 435{
299 if ( !actionFilter->isOn() ) 436 if ( !actionFilter->isOn() )
300 { 437 {
301 networkPkgWindow->filterByCategory( FALSE ); 438 filterByCategory( FALSE );
302 } 439 }
303 else 440 else
304 { 441 {
305 actionFilter->setOn( networkPkgWindow->filterByCategory( TRUE ) ); 442 actionFilter->setOn( filterByCategory( TRUE ) );
443 }
444}
445
446bool MainWindow :: filterByCategory( bool val )
447{
448 if ( val )
449 {
450 if ( categoryFilter == "" )
451 {
452 if ( !setFilterCategory() )
453 return false;
454 }
455
456 categoryFilterEnabled = true;
457 serverSelected( -1 );
458 return true;
459 }
460 else
461 {
462 // Turn off filter
463 categoryFilterEnabled = false;
464 serverSelected( -1 );
465 return false;
306 } 466 }
307} 467}
308 468
309void MainWindow :: raiseMainWidget() 469void MainWindow :: raiseMainWidget()
310{ 470{
311 stack->raiseWidget( networkPkgWindow ); 471 stack->raiseWidget( networkPkgWindow );
312} 472}
313 473
314void MainWindow :: raiseProgressWidget() 474void MainWindow :: raiseProgressWidget()
315{ 475{
316 stack->raiseWidget( progressWindow ); 476 stack->raiseWidget( progressWindow );
317} 477}
318 478
319void MainWindow :: enableUpgrade( bool enabled ) 479void MainWindow :: enableUpgrade( bool enabled )
320{ 480{
321 actionUpgrade->setEnabled( enabled ); 481 actionUpgrade->setEnabled( enabled );
322} 482}
323 483
324void MainWindow :: enableDownload( bool enabled ) 484void MainWindow :: enableDownload( bool enabled )
325{ 485{
326 if ( enabled ) 486 if ( enabled )
327 { 487 {
328 actionDownload->setIconSet( iconDownload ); 488 actionDownload->setIconSet( iconDownload );
329 actionDownload->setText( tr( "Download" ) ); 489 actionDownload->setText( tr( "Download" ) );
330 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 490 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
331 } 491 }
332 else 492 else
333 { 493 {
334 actionDownload->setIconSet( iconRemove ); 494 actionDownload->setIconSet( iconRemove );
335 actionDownload->setText( tr( "Remove" ) ); 495 actionDownload->setText( tr( "Remove" ) );
336 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 496 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
337 } 497 }
338} 498}
499
500void MainWindow :: setProgressSteps( int numsteps )
501{
502 m_progress->setTotalSteps( numsteps );
503}
504
505void MainWindow :: setProgressMessage( const QString &msg )
506{
507 m_status->setText( msg );
508}
509
510void MainWindow :: updateProgress( int progress )
511{
512 m_progress->setProgress( progress );
513}
514
515void MainWindow :: updateData()
516{
517 m_progress->setTotalSteps( mgr->getServerList().size() );
518
519 serversList->clear();
520 packagesList->clear();
521
522 vector<Server>::iterator it;
523 int activeItem = -1;
524 int i;
525 QString serverName;
526 for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i )
527 {
528 serverName = it->getServerName();
529 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
530 m_progress->setProgress( i );
531 qApp->processEvents();
532
533// cout << "Adding " << it->getServerName() << " to combobox" << endl;
534 if ( !it->isServerActive() )
535 {
536// cout << serverName << " is not active" << endl;
537 i--;
538 continue;
539 }
540
541 serversList->insertItem( serverName );
542 if ( serverName == currentlySelectedServer )
543 activeItem = i;
544 }
545
546 // set selected server to be active server
547 if ( activeItem != -1 )
548 serversList->setCurrentItem( activeItem );
549 serverSelected( 0, FALSE );
550}
551
552void MainWindow :: serverSelected( int index )
553{
554 serverSelected( index, TRUE );
555}
556
557void MainWindow :: serverSelected( int, bool raiseProgress )
558{
559 QPixmap nullIcon( installedIcon.size() );
560 nullIcon.fill( colorGroup().base() );
561
562 // display packages
563 QString serverName = serversList->currentText();
564 currentlySelectedServer = serverName;
565
566 vector<Server>::iterator s = mgr->getServer( serverName );
567
568 vector<Package> &list = s->getPackageList();
569 vector<Package>::iterator it;
570
571 // Display progress widget while loading list
572 bool doProgress = ( list.size() > 200 );
573 if ( doProgress )
574 {
575 if ( raiseProgress )
576 {
577 stack->raiseWidget( progressWindow );
578 }
579 m_progress->setTotalSteps( list.size() );
580 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
581 }
582
583 packagesList->clear();
584
585#ifdef QWS
586 // read download directory from config file
587 Config cfg( "aqpkg" );
588 cfg.setGroup( "settings" );
589 cfg.writeEntry( "selectedServer", currentlySelectedServer );
590#endif
591
592 int i = 0;
593 for ( it = list.begin() ; it != list.end() ; ++it )
594 {
595 // Update progress after every 100th package (arbitrary value, seems to give good balance)
596 i++;
597 if ( ( i % 100 ) == 0 )
598 {
599 if ( doProgress )
600 {
601 m_progress->setProgress( i );
602 }
603 qApp->processEvents();
604 }
605
606 QString text = "";
607
608 // Apply show only uninstalled packages filter
609 if ( showUninstalledPkgs && it->isInstalled() )
610 continue;
611
612 // Apply show only installed packages filter
613 if ( showInstalledPkgs && !it->isInstalled() )
614 continue;
615
616 // Apply show only new installed packages filter
617 if ( showUpgradedPkgs )
618 {
619 if ( !it->isInstalled() ||
620 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
621 continue;
622 }
623
624 // Apply the section filter
625 if ( categoryFilterEnabled && categoryFilter != "" )
626 {
627 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
628 continue;
629 }
630
631 // If the local server, only display installed packages
632 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
633 continue;
634
635
636 QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox );
637
638 if ( it->isInstalled() )
639 {
640 // If a different version of package is available, show update available icon
641 // Otherwise, show installed icon
642 if ( it->getVersion() != it->getInstalledVersion() &&
643 compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1)
644 {
645
646 item->setPixmap( 0, updatedIcon );
647 }
648 else
649 {
650 item->setPixmap( 0, installedIcon );
651 }
652
653 QString destName = "";
654 if ( it->getLocalPackage() )
655 {
656 if ( it->getLocalPackage()->getInstalledTo() )
657 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
658 }
659 else
660 {
661 if ( it->getInstalledTo() )
662 destName = it->getInstalledTo()->getDestinationName();
663 }
664 if ( destName != "" )
665 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
666 }
667 else
668 {
669 item->setPixmap( 0, nullIcon );
670 }
671
672 if ( !it->isPackageStoredLocally() )
673 {
674 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) );
675 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) );
676 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) );
677 }
678 else
679 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) );
680
681 if ( serverName == LOCAL_SERVER )
682 {
683 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
684 }
685 else
686 {
687 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
688 if ( it->getLocalPackage() )
689 {
690 if ( it->isInstalled() )
691 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
692 }
693 }
694
695 packagesList->insertItem( item );
696 }
697
698 // If the local server or the local ipkgs server disable the download button
699 if ( serverName == LOCAL_SERVER )
700 {
701 downloadEnabled = TRUE;
702 actionUpgrade->setEnabled( FALSE );
703 }
704 else if ( serverName == LOCAL_IPKGS )
705 {
706 downloadEnabled = FALSE;
707 actionUpgrade->setEnabled( FALSE );
708 }
709 else
710 {
711 downloadEnabled = TRUE;
712 actionUpgrade->setEnabled( TRUE );
713 }
714 enableDownload( downloadEnabled );
715
716 // Display this widget once everything is done
717 if ( doProgress && raiseProgress )
718 {
719 stack->raiseWidget( networkPkgWindow );
720 }
721}
722
723void MainWindow :: searchForPackage( const QString &text )
724{
725 if ( !text.isEmpty() )
726 {
727// cout << "searching for " << text << endl;
728 // look through package list for text startng at current position
729 vector<InstallData> workingPackages;
730 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
731 if ( start != 0 )
732 start = (QCheckListItem *)start->nextSibling();
733
734 if ( start == 0 )
735 start = (QCheckListItem *)packagesList->firstChild();
736
737 for ( QCheckListItem *item = start; item != 0 ;
738 item = (QCheckListItem *)item->nextSibling() )
739 {
740// cout << "checking " << item->text().lower() << endl;
741 if ( item->text().lower().find( text ) != -1 )
742 {
743// cout << "matched " << item->text() << endl;
744 packagesList->ensureItemVisible( item );
745 packagesList->setCurrentItem( item );
746 break;
747 }
748 }
749 }
750}
751
752void MainWindow :: updateServer()
753{
754 QString serverName = serversList->currentText();
755
756 // Update the current server
757 // Display dialog
758
759 // Disable buttons to stop silly people clicking lots on them :)
760
761 // First, write out ipkg_conf file so that ipkg can use it
762 mgr->writeOutIpkgConf();
763
764 Ipkg ipkg;
765 ipkg.setOption( "update" );
766
767 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
768 dlg.showDlg();
769
770 // Reload data
771 mgr->reloadServerData();
772 serverSelected(-1);
773// delete progDlg;
774}
775
776void MainWindow :: upgradePackages()
777{
778 // We're gonna do an upgrade of all packages
779 // First warn user that this isn't recommended
780 // TODO - ODevice????
781 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
782 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
783 QMessageBox::Yes,
784 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
785 0, this );
786 warn.adjustSize();
787
788 if ( warn.exec() == QMessageBox::Yes )
789 {
790 // First, write out ipkg_conf file so that ipkg can use it
791 mgr->writeOutIpkgConf();
792
793 // Now run upgrade
794 Ipkg ipkg;
795 ipkg.setOption( "upgrade" );
796
797 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
798 dlg.showDlg();
799
800 // Reload data
801 mgr->reloadServerData();
802 serverSelected(-1);
803 }
804}
805 void MainWindow :: downloadPackage()
806{
807 bool doUpdate = true;
808 if ( downloadEnabled )
809 {
810 // See if any packages are selected
811 bool found = false;
812 if ( serversList->currentText() != LOCAL_SERVER )
813 {
814 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
815 item != 0 && !found;
816 item = (QCheckListItem *)item->nextSibling() )
817 {
818 if ( item->isOn() )
819 found = true;
820 }
821 }
822
823 // If user selected some packages then download the and store the locally
824 // otherwise, display dialog asking user what package to download from an http server
825 // and whether to install it
826 if ( found )
827 downloadSelectedPackages();
828 else
829 downloadRemotePackage();
830
831 }
832 else
833 {
834 doUpdate = false;
835 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
836 item != 0 ;
837 item = (QCheckListItem *)item->nextSibling() )
838 {
839 if ( item->isOn() )
840 {
841 QString name = item->text();
842 int pos = name.find( "*" );
843 name.truncate( pos );
844
845 // if (there is a (installed), remove it
846 pos = name.find( "(installed)" );
847 if ( pos > 0 )
848 name.truncate( pos - 1 );
849
850 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
851
852 QString msgtext;
853 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
854 if ( QMessageBox::information( this, tr( "Are you sure?" ),
855 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
856 {
857 doUpdate = true;
858 QFile f( p->getFilename() );
859 f.remove();
860 }
861 }
862 }
863 }
864
865 if ( doUpdate )
866 {
867 mgr->reloadServerData();
868 serverSelected( -1 );
869 }
870}
871
872void MainWindow :: downloadSelectedPackages()
873{
874 // First, write out ipkg_conf file so that ipkg can use it
875 mgr->writeOutIpkgConf();
876
877 // Display dialog to user asking where to download the files to
878 bool ok = FALSE;
879 QString dir = "";
880#ifdef QWS
881 // read download directory from config file
882 Config cfg( "aqpkg" );
883 cfg.setGroup( "settings" );
884 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
885#endif
886
887 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
888 if ( ok && !text.isEmpty() )
889 dir = text; // user entered something and pressed ok
890 else
891 return; // user entered nothing or pressed cancel
892
893#ifdef QWS
894 // Store download directory in config file
895 cfg.writeEntry( "downloadDir", dir );
896#endif
897
898 // Get starting directory
899 char initDir[PATH_MAX];
900 getcwd( initDir, PATH_MAX );
901
902 // Download each package
903 Ipkg ipkg;
904 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
905
906 ipkg.setOption( "download" );
907 ipkg.setRuntimeDirectory( dir );
908 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
909 item != 0 ;
910 item = (QCheckListItem *)item->nextSibling() )
911 {
912 if ( item->isOn() )
913 {
914 ipkg.setPackage( item->text() );
915 ipkg.runIpkg( );
916 }
917 }
918}
919
920void MainWindow :: downloadRemotePackage()
921{
922 // Display dialog
923 bool ok;
924 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
925 if ( !ok || package.isEmpty() )
926 return;
927// DownloadRemoteDlgImpl dlg( this, "Install", true );
928// if ( dlg.exec() == QDialog::Rejected )
929// return;
930
931 // grab details from dialog
932// QString package = dlg.getPackageLocation();
933
934 InstallData item;
935 item.option = "I";
936 item.packageName = package;
937 vector<InstallData> workingPackages;
938 workingPackages.push_back( item );
939
940 InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true );
941 dlg2.showDlg();
942
943 // Reload data
944 mgr->reloadServerData();
945 serverSelected(-1);
946
947#ifdef QWS
948 // Finally let the main system update itself
949 QCopEnvelope e("QPE/System", "linkChanged(QString)");
950 QString lf = QString::null;
951 e << lf;
952#endif
953}
954
955
956void MainWindow :: applyChanges()
957{
958 stickyOption = "";
959
960 // First, write out ipkg_conf file so that ipkg can use it
961 mgr->writeOutIpkgConf();
962
963 // Now for each selected item
964 // deal with it
965
966 vector<InstallData> workingPackages;
967 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
968 item != 0 ;
969 item = (QCheckListItem *)item->nextSibling() )
970 {
971 if ( item->isOn() )
972 {
973 InstallData data = dealWithItem( item );
974 workingPackages.push_back( data );
975 }
976 }
977
978 if ( workingPackages.size() == 0 )
979 {
980 // Nothing to do
981 QMessageBox::information( this, tr( "Nothing to do" ),
982 tr( "No packages selected" ), tr( "OK" ) );
983
984 return;
985 }
986
987 // do the stuff
988 InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true );
989 dlg.showDlg();
990
991 // Reload data
992 mgr->reloadServerData();
993 serverSelected(-1);
994
995#ifdef QWS
996 // Finally let the main system update itself
997 QCopEnvelope e("QPE/System", "linkChanged(QString)");
998 QString lf = QString::null;
999 e << lf;
1000#endif
1001}
1002
1003// decide what to do - either remove, upgrade or install
1004// Current rules:
1005// If not installed - install
1006// If installed and different version available - upgrade
1007// If installed and version up to date - remove
1008InstallData MainWindow :: dealWithItem( QCheckListItem *item )
1009{
1010 QString name = item->text();
1011
1012 // Get package
1013 vector<Server>::iterator s = mgr->getServer( serversList->currentText() );
1014 Package *p = s->getPackage( name );
1015
1016 // If the package has a filename then it is a local file
1017 if ( p->isPackageStoredLocally() )
1018 name = p->getFilename();
1019
1020 QString option;
1021 QString dest = "root";
1022 if ( !p->isInstalled() )
1023 {
1024 InstallData item;
1025 item.option = "I";
1026 item.packageName = name;
1027 return item;
1028 }
1029 else
1030 {
1031 InstallData item;
1032 item.option = "D";
1033 if ( !p->isPackageStoredLocally() )
1034 item.packageName = p->getInstalledPackageName();
1035 else
1036 item.packageName = name;
1037
1038 if ( p->getInstalledTo() )
1039 {
1040 item.destination = p->getInstalledTo();
1041// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1042// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1043 }
1044 else
1045 {
1046 item.destination = p->getLocalPackage()->getInstalledTo();
1047 }
1048
1049 // Now see if version is newer or not
1050 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1051
1052 // If the version requested is older and user selected a local ipk file, then reinstall the file
1053 if ( p->isPackageStoredLocally() && val == -1 )
1054 val = 0;
1055
1056 if ( val == -2 )
1057 {
1058 // Error - should handle
1059 }
1060 else if ( val == -1 )
1061 {
1062 // Version available is older - remove only
1063 item.option = "D";
1064 }
1065 else
1066 {
1067 QString caption;
1068 QString text;
1069 QString secondButton;
1070 QString secondOption;
1071 if ( val == 0 )
1072 {
1073 // Version available is the same - option to remove or reinstall
1074 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1075 text = tr( "Remove or ReInstall" );
1076 secondButton = tr( "ReInstall" );
1077 secondOption = tr( "R" );
1078 }
1079 else if ( val == 1 )
1080 {
1081 // Version available is newer - option to remove or upgrade
1082 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1083 text = tr( "Remove or Upgrade" );
1084 secondButton = tr( "Upgrade" );
1085 secondOption = tr( "U" );
1086 }
1087
1088 // Sticky option not implemented yet, but will eventually allow
1089 // the user to say something like 'remove all'
1090 if ( stickyOption == "" )
1091 {
1092 QString msgtext;
1093 msgtext = caption.arg( ( const char * )name );
1094 switch( QMessageBox::information( this, text,
1095 msgtext, tr( "Remove" ), secondButton ) )
1096 {
1097 case 0: // Try again or Enter
1098 // option 0 = Remove
1099 item.option = "D";
1100 break;
1101 case 1: // Quit or Escape
1102 item.option = secondOption;
1103 break;
1104 }
1105 }
1106 else
1107 {
1108// item.option = stickyOption;
1109 }
1110 }
1111
1112
1113 // Check if we are reinstalling the same version
1114 if ( item.option != "R" )
1115 item.recreateLinks = true;
1116 else
1117 item.recreateLinks = false;
1118
1119 // User hit cancel (on dlg - assume remove)
1120 return item;
1121 }
1122}
1123
1124void MainWindow :: letterPushed( QString t )
1125{
1126 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1127 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1128 if ( packagesList->firstChild() == 0 )
1129 return;
1130
1131 QCheckListItem *item;
1132 if ( start == 0 )
1133 {
1134 item = (QCheckListItem *)packagesList->firstChild();
1135 start = top;
1136 }
1137 else
1138 item = (QCheckListItem *)start->nextSibling();
1139
1140 if ( item == 0 )
1141 item = (QCheckListItem *)packagesList->firstChild();
1142 do
1143 {
1144 if ( item->text().lower().startsWith( t.lower() ) )
1145 {
1146 packagesList->setSelected( item, true );
1147 packagesList->ensureItemVisible( item );
1148 break;
1149 }
1150
1151 item = (QCheckListItem *)item->nextSibling();
1152 if ( !item )
1153 item = (QCheckListItem *)packagesList->firstChild();
1154 } while ( item != start);
1155}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index ef67cc9..46b5fae 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,89 +1,133 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23 23
24class QWidgetStack;
25class QPEToolBar;
26class QLineEdit;
27class QAction;
28class ProgressWidget;
29class NetworkPackageManager;
30class DataManager; 24class DataManager;
25class InstallData;
26
27class QAction;
28class QCheckListItem;
29class QComboBox;
30class QLabel;
31class QLineEdit;
32class QListView;
33class QPEToolBar;
34class QProgressBar;
35class QWidgetStack;
31 36
32class MainWindow :public QMainWindow 37class MainWindow :public QMainWindow
33{ 38{
34 Q_OBJECT 39 Q_OBJECT
35public: 40public:
36 41
37 MainWindow(); 42 MainWindow();
38 ~MainWindow(); 43 ~MainWindow();
39 44
40private: 45private:
41 DataManager *mgr; 46 DataManager *mgr;
42 47
43 QWidgetStack *stack; 48 QWidgetStack *stack;
44 49
45 QPEToolBar *findBar; 50 QPEToolBar *findBar;
46 QLineEdit *findEdit; 51 QLineEdit *findEdit;
47 QAction *actionFindNext; 52 QAction *actionFindNext;
48 QAction *actionFilter; 53 QAction *actionFilter;
49 QAction *actionUpgrade; 54 QAction *actionUpgrade;
50 QAction *actionDownload; 55 QAction *actionDownload;
51 QAction *actionUninstalled; 56 QAction *actionUninstalled;
52 QAction *actionInstalled; 57 QAction *actionInstalled;
53 QAction *actionUpdated; 58 QAction *actionUpdated;
54 59
55 QPixmap iconDownload; 60 QPixmap iconDownload;
56 QPixmap iconRemove; 61 QPixmap iconRemove;
57 62
58 NetworkPackageManager *networkPkgWindow;
59 ProgressWidget *progressWindow;
60
61 int mnuShowUninstalledPkgsId; 63 int mnuShowUninstalledPkgsId;
62 int mnuShowInstalledPkgsId; 64 int mnuShowInstalledPkgsId;
63 int mnuShowUpgradedPkgsId; 65 int mnuShowUpgradedPkgsId;
64 int mnuFilterByCategory; 66 int mnuFilterByCategory;
65 int mnuSetFilterCategory; 67 int mnuSetFilterCategory;
66 68
69 // Main package list widget
70 QWidget *networkPkgWindow;
71 QComboBox *serversList;
72 QListView *packagesList;
73 QPixmap installedIcon;
74 QPixmap updatedIcon;
75 QString currentlySelectedServer;
76 QString categoryFilter;
77 QString stickyOption;
78
79 bool categoryFilterEnabled;
80 bool showJumpTo;
81 bool showUninstalledPkgs;
82 bool showInstalledPkgs;
83 bool showUpgradedPkgs;
84 bool downloadEnabled;
85
86 void initMainWidget();
87 void updateData();
88 void serverSelected( int index, bool showProgress );
89 void searchForPackage( const QString & );
90 bool filterByCategory( bool val );
91 void downloadSelectedPackages();
92 void downloadRemotePackage();
93 InstallData dealWithItem( QCheckListItem *item );
94
95 // Progress widget
96 QWidget *progressWindow;
97 QLabel *m_status;
98 QProgressBar *m_progress;
99
100 void initProgressWidget();
101
67public slots: 102public slots:
68 void setDocument( const QString &doc ); 103 void setDocument( const QString &doc );
69 void displayHelp(); 104 void displayHelp();
70 void displayFindBar(); 105 void displayFindBar();
71 void repeatFind(); 106 void repeatFind();
72 void findPackage( const QString & ); 107 void findPackage( const QString & );
73 void hideFindBar(); 108 void hideFindBar();
74 void displayAbout(); 109 void displayAbout();
75 void displaySettings(); 110 void displaySettings();
76 void filterUninstalledPackages(); 111 void filterUninstalledPackages();
77 void filterInstalledPackages(); 112 void filterInstalledPackages();
78 void filterUpgradedPackages(); 113 void filterUpgradedPackages();
79 void filterCategory(); 114 void filterCategory();
80 void setFilterCategory(); 115 bool setFilterCategory();
81 void raiseMainWidget(); 116 void raiseMainWidget();
82 void raiseProgressWidget(); 117 void raiseProgressWidget();
83 void enableUpgrade( bool ); 118 void enableUpgrade( bool );
84 void enableDownload( bool ); 119 void enableDownload( bool );
85 120
86private slots: 121private slots:
87 void init(); 122 void init();
123 void setProgressSteps( int );
124 void setProgressMessage( const QString & );
125 void updateProgress( int );
126 void serverSelected( int index );
127 void updateServer();
128 void upgradePackages();
129 void downloadPackage();
130 void applyChanges();
131 void letterPushed( QString t );
88}; 132};
89#endif 133#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
deleted file mode 100644
index b4b6475..0000000
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/dev/null
@@ -1,870 +0,0 @@
1/***************************************************************************
2 networkpkgmgr.cpp - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <unistd.h>
19
20#ifdef QWS
21#include <qpe/qpeapplication.h>
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h>
24#include <qpe/resource.h>
25#else
26#include <qapplication.h>
27#endif
28#include <qlabel.h>
29#include <qfile.h>
30#include <qmessagebox.h>
31#include <qwhatsthis.h>
32
33#include "datamgr.h"
34#include "networkpkgmgr.h"
35#include "installdlgimpl.h"
36#include "ipkg.h"
37#include "inputdlg.h"
38#include "letterpushbutton.h"
39#include "categoryfilterimpl.h"
40
41#include "global.h"
42
43extern int compareVersions( const char *v1, const char *v2 );
44
45NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
46 : QWidget(parent, name)
47{
48
49#ifdef QWS
50 // read download directory from config file
51 Config cfg( "aqpkg" );
52 cfg.setGroup( "settings" );
53 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
54 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
55
56#endif
57
58 showUninstalledPkgs = false;
59 showInstalledPkgs = false;
60 showUpgradedPkgs = false;
61 categoryFilterEnabled = false;
62
63 initGui();
64}
65
66NetworkPackageManager::~NetworkPackageManager()
67{
68}
69
70void NetworkPackageManager :: setDataManager( DataManager *dm )
71{
72 dataMgr = dm;
73}
74
75void NetworkPackageManager :: updateData()
76{
77 emit progressSetSteps( dataMgr->getServerList().size() );
78
79 serversList->clear();
80 packagesList->clear();
81
82 vector<Server>::iterator it;
83 int activeItem = -1;
84 int i;
85 QString serverName;
86 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
87 {
88 serverName = it->getServerName();
89 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
90 emit progressUpdate( i );
91 qApp->processEvents();
92
93// cout << "Adding " << it->getServerName() << " to combobox" << endl;
94 if ( !it->isServerActive() )
95 {
96// cout << serverName << " is not active" << endl;
97 i--;
98 continue;
99 }
100
101 serversList->insertItem( serverName );
102 if ( serverName == currentlySelectedServer )
103 activeItem = i;
104 }
105
106 // set selected server to be active server
107 if ( activeItem != -1 )
108 serversList->setCurrentItem( activeItem );
109 serverSelected( 0, FALSE );
110}
111
112void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
113{
114 // First select local server
115 for ( int i = 0 ; i < serversList->count() ; ++i )
116 {
117 if ( serversList->text( i ) == LOCAL_IPKGS )
118 {
119 serversList->setCurrentItem( i );
120 break;
121 }
122 }
123 serverSelected( 0 );
124
125 // Now set the check box of the selected package
126 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
127 item != 0 ;
128 item = (QCheckListItem *)item->nextSibling() )
129 {
130 if ( item->text().startsWith( pkg ) )
131 {
132 item->setOn( true );
133 break;
134 }
135 }
136}
137
138
139void NetworkPackageManager :: initGui()
140{
141 QLabel *l = new QLabel( tr( "Servers" ), this );
142 serversList = new QComboBox( this );
143 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
144 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
145
146 installedIcon = Resource::loadPixmap( "aqpkg/installed" );
147 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
148
149 packagesList = new QListView( this );
150 packagesList->addColumn( tr( "Packages" ), 225 );
151 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
152
153 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1 );
154 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
155 hbox1->addWidget( l );
156 hbox1->addWidget( serversList );
157
158 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 );
159 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 );
160
161
162 if ( showJumpTo )
163 {
164 char text[2];
165 text[1] = '\0';
166 for ( int i = 0 ; i < 26 ; ++i )
167 {
168 text[0] = 'A' + i;
169 LetterPushButton *b = new LetterPushButton( text, this );
170 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
171 if ( i < 13 )
172 hbox3->addWidget( b );
173 else
174 hbox4->addWidget( b );
175 }
176 }
177
178 vbox->addWidget( packagesList );
179
180 downloadEnabled = TRUE;
181}
182
183void NetworkPackageManager :: serverSelected( int index )
184{
185 serverSelected( index, TRUE );
186}
187
188void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
189{
190 QPixmap nullIcon( installedIcon.size() );
191 nullIcon.fill( colorGroup().base() );
192
193 // display packages
194 QString serverName = serversList->currentText();
195 currentlySelectedServer = serverName;
196
197 vector<Server>::iterator s = dataMgr->getServer( serverName );
198
199 vector<Package> &list = s->getPackageList();
200 vector<Package>::iterator it;
201
202 // Display progress widget while loading list
203 bool doProgress = ( list.size() > 200 );
204 if ( doProgress )
205 {
206 if ( raiseProgress )
207 {
208 emit appRaiseProgressWidget();
209 }
210 emit progressSetSteps( list.size() );
211 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
212 }
213
214 packagesList->clear();
215
216#ifdef QWS
217 // read download directory from config file
218 Config cfg( "aqpkg" );
219 cfg.setGroup( "settings" );
220 cfg.writeEntry( "selectedServer", currentlySelectedServer );
221#endif
222
223 int i = 0;
224 for ( it = list.begin() ; it != list.end() ; ++it )
225 {
226 // Update progress after every 100th package (arbitrary value, seems to give good balance)
227 i++;
228 if ( ( i % 100 ) == 0 )
229 {
230 if ( doProgress )
231 {
232 emit progressUpdate( i );
233 }
234 qApp->processEvents();
235 }
236
237 QString text = "";
238
239 // Apply show only uninstalled packages filter
240 if ( showUninstalledPkgs && it->isInstalled() )
241 continue;
242
243 // Apply show only installed packages filter
244 if ( showInstalledPkgs && !it->isInstalled() )
245 continue;
246
247 // Apply show only new installed packages filter
248 if ( showUpgradedPkgs )
249 {
250 if ( !it->isInstalled() ||
251 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
252 continue;
253 }
254
255 // Apply the section filter
256 if ( categoryFilterEnabled && categoryFilter != "" )
257 {
258 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
259 continue;
260 }
261
262 // If the local server, only display installed packages
263 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
264 continue;
265
266
267 QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox );
268
269 if ( it->isInstalled() )
270 {
271 // If a different version of package is available, show update available icon
272 // Otherwise, show installed icon
273 if ( it->getVersion() != it->getInstalledVersion() &&
274 compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1)
275 {
276
277 item->setPixmap( 0, updatedIcon );
278 }
279 else
280 {
281 item->setPixmap( 0, installedIcon );
282 }
283
284 QString destName = "";
285 if ( it->getLocalPackage() )
286 {
287 if ( it->getLocalPackage()->getInstalledTo() )
288 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
289 }
290 else
291 {
292 if ( it->getInstalledTo() )
293 destName = it->getInstalledTo()->getDestinationName();
294 }
295 if ( destName != "" )
296 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
297 }
298 else
299 {
300 item->setPixmap( 0, nullIcon );
301 }
302
303 if ( !it->isPackageStoredLocally() )
304 {
305 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) );
306 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) );
307 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) );
308 }
309 else
310 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) );
311
312 if ( serverName == LOCAL_SERVER )
313 {
314 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
315 }
316 else
317 {
318 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
319 if ( it->getLocalPackage() )
320 {
321 if ( it->isInstalled() )
322 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
323 }
324 }
325
326 packagesList->insertItem( item );
327 }
328
329 // If the local server or the local ipkgs server disable the download button
330 if ( serverName == LOCAL_SERVER )
331 {
332 downloadEnabled = TRUE;
333 emit appEnableUpgrade( FALSE );
334 }
335 else if ( serverName == LOCAL_IPKGS )
336 {
337 downloadEnabled = FALSE;
338 emit appEnableUpgrade( FALSE );
339 }
340 else
341 {
342 downloadEnabled = TRUE;
343 emit appEnableUpgrade( TRUE );
344 }
345 emit appEnableDownload( downloadEnabled );
346
347 // Display this widget once everything is done
348 if ( doProgress && raiseProgress )
349 {
350 emit appRaiseMainWidget();
351 }
352}
353
354void NetworkPackageManager :: updateServer()
355{
356 QString serverName = serversList->currentText();
357
358 // Update the current server
359 // Display dialog
360
361 // Disable buttons to stop silly people clicking lots on them :)
362
363 // First, write out ipkg_conf file so that ipkg can use it
364 dataMgr->writeOutIpkgConf();
365
366 Ipkg ipkg;
367 ipkg.setOption( "update" );
368
369 InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
370 dlg.showDlg();
371
372 // Reload data
373 dataMgr->reloadServerData();
374 serverSelected(-1);
375// delete progDlg;
376}
377
378void NetworkPackageManager :: upgradePackages()
379{
380 // We're gonna do an upgrade of all packages
381 // First warn user that this isn't recommended
382 // TODO - ODevice????
383 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
384 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
385 QMessageBox::Yes,
386 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
387 0, this );
388 warn.adjustSize();
389
390 if ( warn.exec() == QMessageBox::Yes )
391 {
392 // First, write out ipkg_conf file so that ipkg can use it
393 dataMgr->writeOutIpkgConf();
394
395 // Now run upgrade
396 Ipkg ipkg;
397 ipkg.setOption( "upgrade" );
398
399 InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
400 dlg.showDlg();
401
402 // Reload data
403 dataMgr->reloadServerData();
404 serverSelected(-1);
405 }
406}
407
408
409void NetworkPackageManager :: downloadPackage()
410{
411 bool doUpdate = true;
412 if ( downloadEnabled )
413 {
414 // See if any packages are selected
415 bool found = false;
416 if ( serversList->currentText() != LOCAL_SERVER )
417 {
418 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
419 item != 0 && !found;
420 item = (QCheckListItem *)item->nextSibling() )
421 {
422 if ( item->isOn() )
423 found = true;
424 }
425 }
426
427 // If user selected some packages then download the and store the locally
428 // otherwise, display dialog asking user what package to download from an http server
429 // and whether to install it
430 if ( found )
431 downloadSelectedPackages();
432 else
433 downloadRemotePackage();
434
435 }
436 else
437 {
438 doUpdate = false;
439 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
440 item != 0 ;
441 item = (QCheckListItem *)item->nextSibling() )
442 {
443 if ( item->isOn() )
444 {
445 QString name = item->text();
446 int pos = name.find( "*" );
447 name.truncate( pos );
448
449 // if (there is a (installed), remove it
450 pos = name.find( "(installed)" );
451 if ( pos > 0 )
452 name.truncate( pos - 1 );
453
454 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
455
456 QString msgtext;
457 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
458 if ( QMessageBox::information( this, tr( "Are you sure?" ),
459 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
460 {
461 doUpdate = true;
462 QFile f( p->getFilename() );
463 f.remove();
464 }
465 }
466 }
467 }
468
469 if ( doUpdate )
470 {
471 dataMgr->reloadServerData();
472 serverSelected( -1 );
473 }
474}
475
476void NetworkPackageManager :: downloadSelectedPackages()
477{
478 // First, write out ipkg_conf file so that ipkg can use it
479 dataMgr->writeOutIpkgConf();
480
481 // Display dialog to user asking where to download the files to
482 bool ok = FALSE;
483 QString dir = "";
484#ifdef QWS
485 // read download directory from config file
486 Config cfg( "aqpkg" );
487 cfg.setGroup( "settings" );
488 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
489#endif
490
491 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
492 if ( ok && !text.isEmpty() )
493 dir = text; // user entered something and pressed ok
494 else
495 return; // user entered nothing or pressed cancel
496
497#ifdef QWS
498 // Store download directory in config file
499 cfg.writeEntry( "downloadDir", dir );
500#endif
501
502 // Get starting directory
503 char initDir[PATH_MAX];
504 getcwd( initDir, PATH_MAX );
505
506 // Download each package
507 Ipkg ipkg;
508 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
509
510 ipkg.setOption( "download" );
511 ipkg.setRuntimeDirectory( dir );
512 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
513 item != 0 ;
514 item = (QCheckListItem *)item->nextSibling() )
515 {
516 if ( item->isOn() )
517 {
518 ipkg.setPackage( item->text() );
519 ipkg.runIpkg( );
520 }
521 }
522}
523
524void NetworkPackageManager :: downloadRemotePackage()
525{
526 // Display dialog
527 bool ok;
528 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
529 if ( !ok || package.isEmpty() )
530 return;
531// DownloadRemoteDlgImpl dlg( this, "Install", true );
532// if ( dlg.exec() == QDialog::Rejected )
533// return;
534
535 // grab details from dialog
536// QString package = dlg.getPackageLocation();
537
538 InstallData item;
539 item.option = "I";
540 item.packageName = package;
541 vector<InstallData> workingPackages;
542 workingPackages.push_back( item );
543
544 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
545 dlg2.showDlg();
546
547 // Reload data
548 dataMgr->reloadServerData();
549 serverSelected(-1);
550
551#ifdef QWS
552 // Finally let the main system update itself
553 QCopEnvelope e("QPE/System", "linkChanged(QString)");
554 QString lf = QString::null;
555 e << lf;
556#endif
557}
558
559
560void NetworkPackageManager :: applyChanges()
561{
562 stickyOption = "";
563
564 // First, write out ipkg_conf file so that ipkg can use it
565 dataMgr->writeOutIpkgConf();
566
567 // Now for each selected item
568 // deal with it
569
570 vector<InstallData> workingPackages;
571 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
572 item != 0 ;
573 item = (QCheckListItem *)item->nextSibling() )
574 {
575 if ( item->isOn() )
576 {
577 InstallData data = dealWithItem( item );
578 workingPackages.push_back( data );
579 }
580 }
581
582 if ( workingPackages.size() == 0 )
583 {
584 // Nothing to do
585 QMessageBox::information( this, tr( "Nothing to do" ),
586 tr( "No packages selected" ), tr( "OK" ) );
587
588 return;
589 }
590
591 // do the stuff
592 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
593 dlg.showDlg();
594
595 // Reload data
596 dataMgr->reloadServerData();
597 serverSelected(-1);
598
599#ifdef QWS
600 // Finally let the main system update itself
601 QCopEnvelope e("QPE/System", "linkChanged(QString)");
602 QString lf = QString::null;
603 e << lf;
604#endif
605}
606
607// decide what to do - either remove, upgrade or install
608// Current rules:
609// If not installed - install
610// If installed and different version available - upgrade
611// If installed and version up to date - remove
612InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
613{
614 QString name = item->text();
615
616 // Get package
617 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() );
618 Package *p = s->getPackage( name );
619
620 // If the package has a filename then it is a local file
621 if ( p->isPackageStoredLocally() )
622 name = p->getFilename();
623
624 QString option;
625 QString dest = "root";
626 if ( !p->isInstalled() )
627 {
628 InstallData item;
629 item.option = "I";
630 item.packageName = name;
631 return item;
632 }
633 else
634 {
635 InstallData item;
636 item.option = "D";
637 if ( !p->isPackageStoredLocally() )
638 item.packageName = p->getInstalledPackageName();
639 else
640 item.packageName = name;
641
642 if ( p->getInstalledTo() )
643 {
644 item.destination = p->getInstalledTo();
645// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
646// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
647 }
648 else
649 {
650 item.destination = p->getLocalPackage()->getInstalledTo();
651 }
652
653 // Now see if version is newer or not
654 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
655
656 // If the version requested is older and user selected a local ipk file, then reinstall the file
657 if ( p->isPackageStoredLocally() && val == -1 )
658 val = 0;
659
660 if ( val == -2 )
661 {
662 // Error - should handle
663 }
664 else if ( val == -1 )
665 {
666 // Version available is older - remove only
667 item.option = "D";
668 }
669 else
670 {
671 QString caption;
672 QString text;
673 QString secondButton;
674 QString secondOption;
675 if ( val == 0 )
676 {
677 // Version available is the same - option to remove or reinstall
678 caption = tr( "Do you wish to remove or reinstall\n%1?" );
679 text = tr( "Remove or ReInstall" );
680 secondButton = tr( "ReInstall" );
681 secondOption = tr( "R" );
682 }
683 else if ( val == 1 )
684 {
685 // Version available is newer - option to remove or upgrade
686 caption = tr( "Do you wish to remove or upgrade\n%1?" );
687 text = tr( "Remove or Upgrade" );
688 secondButton = tr( "Upgrade" );
689 secondOption = tr( "U" );
690 }
691
692 // Sticky option not implemented yet, but will eventually allow
693 // the user to say something like 'remove all'
694 if ( stickyOption == "" )
695 {
696 QString msgtext;
697 msgtext = caption.arg( ( const char * )name );
698 switch( QMessageBox::information( this, text,
699 msgtext, tr( "Remove" ), secondButton ) )
700 {
701 case 0: // Try again or Enter
702 // option 0 = Remove
703 item.option = "D";
704 break;
705 case 1: // Quit or Escape
706 item.option = secondOption;
707 break;
708 }
709 }
710 else
711 {
712// item.option = stickyOption;
713 }
714 }
715
716
717 // Check if we are reinstalling the same version
718 if ( item.option != "R" )
719 item.recreateLinks = true;
720 else
721 item.recreateLinks = false;
722
723 // User hit cancel (on dlg - assume remove)
724 return item;
725 }
726}
727
728void NetworkPackageManager :: displayText( const QString &/*t*/ )
729{
730// cout << t << endl;
731}
732
733
734void NetworkPackageManager :: letterPushed( QString t )
735{
736 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
737 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
738 if ( packagesList->firstChild() == 0 )
739 return;
740
741 QCheckListItem *item;
742 if ( start == 0 )
743 {
744 item = (QCheckListItem *)packagesList->firstChild();
745 start = top;
746 }
747 else
748 item = (QCheckListItem *)start->nextSibling();
749
750 if ( item == 0 )
751 item = (QCheckListItem *)packagesList->firstChild();
752 do
753 {
754 if ( item->text().lower().startsWith( t.lower() ) )
755 {
756 packagesList->setSelected( item, true );
757 packagesList->ensureItemVisible( item );
758 break;
759 }
760
761 item = (QCheckListItem *)item->nextSibling();
762 if ( !item )
763 item = (QCheckListItem *)packagesList->firstChild();
764 } while ( item != start);
765}
766
767
768void NetworkPackageManager :: searchForPackage( const QString &text )
769{
770 if ( !text.isEmpty() )
771 {
772// cout << "searching for " << text << endl;
773 // look through package list for text startng at current position
774 vector<InstallData> workingPackages;
775 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
776 if ( start != 0 )
777 start = (QCheckListItem *)start->nextSibling();
778
779 if ( start == 0 )
780 start = (QCheckListItem *)packagesList->firstChild();
781
782 for ( QCheckListItem *item = start; item != 0 ;
783 item = (QCheckListItem *)item->nextSibling() )
784 {
785// cout << "checking " << item->text().lower() << endl;
786 if ( item->text().lower().find( text ) != -1 )
787 {
788// cout << "matched " << item->text() << endl;
789 packagesList->ensureItemVisible( item );
790 packagesList->setCurrentItem( item );
791 break;
792 }
793 }
794 }
795}
796
797void NetworkPackageManager :: showOnlyUninstalledPackages( bool val )
798{
799 showUninstalledPkgs = val;
800 if ( val )
801 {
802 showInstalledPkgs = FALSE;
803 showUpgradedPkgs = FALSE;
804 }
805 serverSelected( -1 );
806}
807
808void NetworkPackageManager :: showOnlyInstalledPackages( bool val )
809{
810 showInstalledPkgs = val;
811 if ( val )
812 {
813 showUninstalledPkgs = FALSE;
814 showUpgradedPkgs = FALSE;
815 }
816 serverSelected( -1 );
817}
818
819void NetworkPackageManager :: showUpgradedPackages( bool val )
820{
821 showUpgradedPkgs = val;
822 if ( val )
823 {
824 showUninstalledPkgs = FALSE;
825 showInstalledPkgs = FALSE;
826 }
827 serverSelected( -1 );
828}
829
830bool NetworkPackageManager :: filterByCategory( bool val )
831{
832 if ( val )
833 {
834 if ( categoryFilter == "" )
835 {
836 if ( !setFilterCategory() )
837 return false;
838 }
839
840 categoryFilterEnabled = true;
841 serverSelected( -1 );
842 return true;
843 }
844 else
845 {
846 // Turn off filter
847 categoryFilterEnabled = false;
848 serverSelected( -1 );
849 return false;
850 }
851}
852
853bool NetworkPackageManager :: setFilterCategory( )
854{
855 // Get categories;
856 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
857 if ( dlg.exec() == QDialog::Accepted )
858 {
859 categoryFilter = dlg.getSelectedFilter();
860
861 if ( categoryFilter == "" )
862 return false;
863
864 categoryFilterEnabled = true;
865 serverSelected( -1 );
866 return true;
867 }
868
869 return false;
870}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
deleted file mode 100644
index 99eff2e..0000000
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/dev/null
@@ -1,100 +0,0 @@
1/***************************************************************************
2 networkpkgmgr.h - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H
20
21#include <qlayout.h>
22#include <qpixmap.h>
23#include <qpushbutton.h>
24#include <qwidget.h>
25#include <qcombobox.h>
26#include <qlistview.h>
27
28#include "datamgr.h"
29
30class InstallData;
31
32/** NetworkPackageManager is the base class of the project */
33class NetworkPackageManager : public QWidget
34{
35 Q_OBJECT
36public:
37 /** construtor */
38 NetworkPackageManager( QWidget* parent=0, const char *name=0 );
39 /** destructor */
40 ~NetworkPackageManager();
41
42 void setDataManager( DataManager *dm );
43 void selectLocalPackage( const QString &pkg );
44 void updateData();
45 void searchForPackage( const QString & );
46 void showOnlyUninstalledPackages( bool val );
47 void showOnlyInstalledPackages( bool val );
48 void showUpgradedPackages( bool val );
49 bool filterByCategory( bool val );
50 bool setFilterCategory();
51
52private:
53 DataManager *dataMgr;
54
55 QComboBox *serversList;
56 QListView *packagesList;
57
58 QPixmap installedIcon;
59 QPixmap updatedIcon;
60
61 QString currentlySelectedServer;
62 QString categoryFilter;
63
64 bool categoryFilterEnabled;
65 bool showJumpTo;
66 bool showUninstalledPkgs;
67 bool showInstalledPkgs;
68 bool showUpgradedPkgs;
69
70 bool downloadEnabled;
71
72 void initGui();
73 void showProgressDialog( char *initialText );
74 void downloadSelectedPackages();
75 void downloadRemotePackage();
76 void serverSelected( int index, bool showProgress );
77
78 InstallData dealWithItem( QCheckListItem *item );
79 QString stickyOption;
80
81signals:
82 void appRaiseMainWidget();
83 void appRaiseProgressWidget();
84 void appEnableUpgrade( bool );
85 void appEnableDownload( bool );
86 void progressSetSteps( int );
87 void progressSetMessage( const QString & );
88 void progressUpdate( int );
89
90public slots:
91 void applyChanges();
92 void upgradePackages();
93 void downloadPackage();
94 void updateServer();
95 void displayText( const QString &t );
96 void letterPushed( QString t );
97 void serverSelected( int index );
98};
99
100#endif
diff --git a/noncore/settings/aqpkg/progresswidget.cpp b/noncore/settings/aqpkg/progresswidget.cpp
deleted file mode 100644
index bbafcac..0000000
--- a/noncore/settings/aqpkg/progresswidget.cpp
+++ b/dev/null
@@ -1,66 +0,0 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "progresswidget.h"
30
31#include <qlabel.h>
32#include <qlayout.h>
33#include <qprogressbar.h>
34
35ProgressWidget::ProgressWidget( QWidget *parent, const char *name, WFlags f )
36 : QWidget( parent, name, f )
37{
38 QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 );
39
40 m_status = new QLabel( this );
41 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
42 layout->addWidget( m_status );
43
44 m_progress = new QProgressBar( this );
45 layout->addWidget( m_progress );
46}
47
48ProgressWidget::~ProgressWidget()
49{
50}
51
52void ProgressWidget::setSteps( int numsteps )
53{
54 m_progress->setTotalSteps( numsteps );
55}
56
57void ProgressWidget::setMessage( const QString &msg )
58{
59 m_status->setText( msg );
60}
61
62void ProgressWidget::update( int progress )
63{
64 m_progress->setProgress( progress );
65}
66
diff --git a/noncore/settings/aqpkg/progresswidget.h b/noncore/settings/aqpkg/progresswidget.h
deleted file mode 100644
index 7d99978..0000000
--- a/noncore/settings/aqpkg/progresswidget.h
+++ b/dev/null
@@ -1,54 +0,0 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef PROGRESSWIDGET_H
30#define PROGRESSWIDGET_H
31
32#include <qwidget.h>
33
34class QLabel;
35class QProgressBar;
36
37class ProgressWidget : public QWidget
38{
39 Q_OBJECT
40public:
41 ProgressWidget( QWidget * = 0, const char * = 0, WFlags = 0 );
42 ~ProgressWidget();
43
44private:
45 QLabel *m_status;
46 QProgressBar *m_progress;
47
48public slots:
49 void setSteps( int );
50 void setMessage( const QString & );
51 void update( int );
52};
53
54#endif