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