author | andyq <andyq> | 2002-11-21 18:11:40 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-21 18:11:40 (UTC) |
commit | 5e806f161bc0bde64d5058dab4850c45aeba2cdf (patch) (unidiff) | |
tree | e93f10fe052da154b1cfe42bdbf5f29ef8749bc4 | |
parent | 5b0e9483f45967da95dc05d770197c631b959070 (diff) | |
download | opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.zip opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.tar.gz opie-5e806f161bc0bde64d5058dab4850c45aeba2cdf.tar.bz2 |
Fixed bug where installed and local ipkg servers weren't shown (hopefully)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 0814121..cf94628 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,480 +1,481 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.cpp - description | 2 | networkpkgmgr.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 <fstream> | 18 | #include <fstream> |
19 | #include <iostream> | 19 | #include <iostream> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <linux/limits.h> | 24 | #include <linux/limits.h> |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | #include "datamgr.h" | 37 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 38 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | #include "categoryfilterimpl.h" | 43 | #include "categoryfilterimpl.h" |
44 | 44 | ||
45 | #include "global.h" | 45 | #include "global.h" |
46 | 46 | ||
47 | extern int compareVersions( const char *v1, const char *v2 ); | 47 | extern int compareVersions( const char *v1, const char *v2 ); |
48 | 48 | ||
49 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 49 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
50 | : QWidget(parent, name) | 50 | : QWidget(parent, name) |
51 | { | 51 | { |
52 | dataMgr = dataManager; | 52 | dataMgr = dataManager; |
53 | 53 | ||
54 | #ifdef QWS | 54 | #ifdef QWS |
55 | // read download directory from config file | 55 | // read download directory from config file |
56 | Config cfg( "aqpkg" ); | 56 | Config cfg( "aqpkg" ); |
57 | cfg.setGroup( "settings" ); | 57 | cfg.setGroup( "settings" ); |
58 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 58 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
59 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 59 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
60 | 60 | ||
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | showUninstalledPkgs = false; | 63 | showUninstalledPkgs = false; |
64 | showInstalledPkgs = false; | 64 | showInstalledPkgs = false; |
65 | showUpgradedPkgs = false; | 65 | showUpgradedPkgs = false; |
66 | categoryFilterEnabled = false; | 66 | categoryFilterEnabled = false; |
67 | 67 | ||
68 | initGui(); | 68 | initGui(); |
69 | setupConnections(); | 69 | setupConnections(); |
70 | 70 | ||
71 | updateData(); | 71 | updateData(); |
72 | } | 72 | } |
73 | 73 | ||
74 | NetworkPackageManager::~NetworkPackageManager() | 74 | NetworkPackageManager::~NetworkPackageManager() |
75 | { | 75 | { |
76 | } | 76 | } |
77 | 77 | ||
78 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 78 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
79 | { | 79 | { |
80 | killTimer( timerId ); | 80 | killTimer( timerId ); |
81 | 81 | ||
82 | // Add server names to listbox | 82 | // Add server names to listbox |
83 | updateData(); | 83 | updateData(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void NetworkPackageManager :: updateData() | 86 | void NetworkPackageManager :: updateData() |
87 | { | 87 | { |
88 | serversList->clear(); | 88 | serversList->clear(); |
89 | packagesList->clear(); | 89 | packagesList->clear(); |
90 | 90 | ||
91 | 91 | ||
92 | vector<Server>::iterator it; | 92 | vector<Server>::iterator it; |
93 | int activeItem = -1; | 93 | int activeItem = -1; |
94 | int i; | 94 | int i; |
95 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 95 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
96 | { | 96 | { |
97 | cout << "Adding " << it->getServerName() << " to combobox" << endl; | ||
97 | if ( !it->isServerActive() ) | 98 | if ( !it->isServerActive() ) |
98 | { | 99 | { |
99 | i--; | 100 | i--; |
100 | continue; | 101 | continue; |
101 | } | 102 | } |
102 | serversList->insertItem( it->getServerName() ); | 103 | serversList->insertItem( it->getServerName() ); |
103 | if ( it->getServerName() == currentlySelectedServer ) | 104 | if ( it->getServerName() == currentlySelectedServer ) |
104 | activeItem = i; | 105 | activeItem = i; |
105 | } | 106 | } |
106 | 107 | ||
107 | // set selected server to be active server | 108 | // set selected server to be active server |
108 | if ( activeItem != -1 ) | 109 | if ( activeItem != -1 ) |
109 | serversList->setCurrentItem( activeItem ); | 110 | serversList->setCurrentItem( activeItem ); |
110 | serverSelected( 0 ); | 111 | serverSelected( 0 ); |
111 | } | 112 | } |
112 | 113 | ||
113 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) | 114 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) |
114 | { | 115 | { |
115 | // First select local server | 116 | // First select local server |
116 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 117 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
117 | { | 118 | { |
118 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 119 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
119 | { | 120 | { |
120 | serversList->setCurrentItem( i ); | 121 | serversList->setCurrentItem( i ); |
121 | break; | 122 | break; |
122 | } | 123 | } |
123 | } | 124 | } |
124 | serverSelected( 0 ); | 125 | serverSelected( 0 ); |
125 | 126 | ||
126 | // Now set the check box of the selected package | 127 | // Now set the check box of the selected package |
127 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 128 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
128 | item != 0 ; | 129 | item != 0 ; |
129 | item = (QCheckListItem *)item->nextSibling() ) | 130 | item = (QCheckListItem *)item->nextSibling() ) |
130 | { | 131 | { |
131 | if ( item->text().startsWith( pkg ) ) | 132 | if ( item->text().startsWith( pkg ) ) |
132 | { | 133 | { |
133 | item->setOn( true ); | 134 | item->setOn( true ); |
134 | break; | 135 | break; |
135 | } | 136 | } |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | void NetworkPackageManager :: initGui() | 141 | void NetworkPackageManager :: initGui() |
141 | { | 142 | { |
142 | QLabel *l = new QLabel( "Servers", this ); | 143 | QLabel *l = new QLabel( "Servers", this ); |
143 | serversList = new QComboBox( this ); | 144 | serversList = new QComboBox( this ); |
144 | packagesList = new QListView( this ); | 145 | packagesList = new QListView( this ); |
145 | update = new QPushButton( "Refresh Lists", this ); | 146 | update = new QPushButton( "Refresh Lists", this ); |
146 | download = new QPushButton( "Download", this ); | 147 | download = new QPushButton( "Download", this ); |
147 | upgrade = new QPushButton( "Upgrade", this ); | 148 | upgrade = new QPushButton( "Upgrade", this ); |
148 | apply = new QPushButton( "Apply", this ); | 149 | apply = new QPushButton( "Apply", this ); |
149 | 150 | ||
150 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 151 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
151 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 152 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
152 | hbox1->addWidget( l ); | 153 | hbox1->addWidget( l ); |
153 | hbox1->addWidget( serversList ); | 154 | hbox1->addWidget( serversList ); |
154 | 155 | ||
155 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | 156 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); |
156 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | 157 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); |
157 | 158 | ||
158 | 159 | ||
159 | if ( showJumpTo ) | 160 | if ( showJumpTo ) |
160 | { | 161 | { |
161 | char text[2]; | 162 | char text[2]; |
162 | text[1] = '\0'; | 163 | text[1] = '\0'; |
163 | for ( int i = 0 ; i < 26 ; ++i ) | 164 | for ( int i = 0 ; i < 26 ; ++i ) |
164 | { | 165 | { |
165 | text[0] = 'A' + i; | 166 | text[0] = 'A' + i; |
166 | LetterPushButton *b = new LetterPushButton( text, this ); | 167 | LetterPushButton *b = new LetterPushButton( text, this ); |
167 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 168 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
168 | if ( i < 13 ) | 169 | if ( i < 13 ) |
169 | hbox3->addWidget( b ); | 170 | hbox3->addWidget( b ); |
170 | else | 171 | else |
171 | hbox4->addWidget( b ); | 172 | hbox4->addWidget( b ); |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
175 | vbox->addWidget( packagesList ); | 176 | vbox->addWidget( packagesList ); |
176 | packagesList->addColumn( "Packages" ); | 177 | packagesList->addColumn( "Packages" ); |
177 | 178 | ||
178 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 179 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
179 | hbox2->addWidget( update ); | 180 | hbox2->addWidget( update ); |
180 | hbox2->addWidget( download ); | 181 | hbox2->addWidget( download ); |
181 | hbox2->addWidget( upgrade ); | 182 | hbox2->addWidget( upgrade ); |
182 | hbox2->addWidget( apply ); | 183 | hbox2->addWidget( apply ); |
183 | } | 184 | } |
184 | 185 | ||
185 | void NetworkPackageManager :: setupConnections() | 186 | void NetworkPackageManager :: setupConnections() |
186 | { | 187 | { |
187 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 188 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
188 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 189 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
189 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 190 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
190 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | 191 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); |
191 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 192 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
192 | } | 193 | } |
193 | 194 | ||
194 | void NetworkPackageManager :: showProgressDialog( char *initialText ) | 195 | void NetworkPackageManager :: showProgressDialog( char *initialText ) |
195 | { | 196 | { |
196 | if ( !progressDlg ) | 197 | if ( !progressDlg ) |
197 | progressDlg = new ProgressDlg( this, "Progress", false ); | 198 | progressDlg = new ProgressDlg( this, "Progress", false ); |
198 | progressDlg->setText( initialText ); | 199 | progressDlg->setText( initialText ); |
199 | progressDlg->show(); | 200 | progressDlg->show(); |
200 | } | 201 | } |
201 | 202 | ||
202 | 203 | ||
203 | void NetworkPackageManager :: serverSelected( int ) | 204 | void NetworkPackageManager :: serverSelected( int ) |
204 | { | 205 | { |
205 | packagesList->clear(); | 206 | packagesList->clear(); |
206 | 207 | ||
207 | // display packages | 208 | // display packages |
208 | QString serverName = serversList->currentText(); | 209 | QString serverName = serversList->currentText(); |
209 | currentlySelectedServer = serverName; | 210 | currentlySelectedServer = serverName; |
210 | 211 | ||
211 | #ifdef QWS | 212 | #ifdef QWS |
212 | // read download directory from config file | 213 | // read download directory from config file |
213 | Config cfg( "aqpkg" ); | 214 | Config cfg( "aqpkg" ); |
214 | cfg.setGroup( "settings" ); | 215 | cfg.setGroup( "settings" ); |
215 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 216 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
216 | #endif | 217 | #endif |
217 | 218 | ||
218 | Server *s = dataMgr->getServer( serverName ); | 219 | Server *s = dataMgr->getServer( serverName ); |
219 | 220 | ||
220 | vector<Package> &list = s->getPackageList(); | 221 | vector<Package> &list = s->getPackageList(); |
221 | vector<Package>::iterator it; | 222 | vector<Package>::iterator it; |
222 | for ( it = list.begin() ; it != list.end() ; ++it ) | 223 | for ( it = list.begin() ; it != list.end() ; ++it ) |
223 | { | 224 | { |
224 | 225 | ||
225 | QString text = ""; | 226 | QString text = ""; |
226 | 227 | ||
227 | // Apply show only uninstalled packages filter | 228 | // Apply show only uninstalled packages filter |
228 | if ( showUninstalledPkgs && it->isInstalled() ) | 229 | if ( showUninstalledPkgs && it->isInstalled() ) |
229 | continue; | 230 | continue; |
230 | 231 | ||
231 | // Apply show only installed packages filter | 232 | // Apply show only installed packages filter |
232 | if ( showInstalledPkgs && !it->isInstalled() ) | 233 | if ( showInstalledPkgs && !it->isInstalled() ) |
233 | continue; | 234 | continue; |
234 | 235 | ||
235 | // Apply show only new installed packages filter | 236 | // Apply show only new installed packages filter |
236 | if ( showUpgradedPkgs ) | 237 | if ( showUpgradedPkgs ) |
237 | { | 238 | { |
238 | if ( !it->isInstalled() || | 239 | if ( !it->isInstalled() || |
239 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 240 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) |
240 | continue; | 241 | continue; |
241 | } | 242 | } |
242 | 243 | ||
243 | // Apply the section filter | 244 | // Apply the section filter |
244 | if ( categoryFilterEnabled && categoryFilter != "" ) | 245 | if ( categoryFilterEnabled && categoryFilter != "" ) |
245 | { | 246 | { |
246 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | 247 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) |
247 | continue; | 248 | continue; |
248 | } | 249 | } |
249 | 250 | ||
250 | // If the local server, only display installed packages | 251 | // If the local server, only display installed packages |
251 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 252 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
252 | continue; | 253 | continue; |
253 | 254 | ||
254 | 255 | ||
255 | text += it->getPackageName(); | 256 | text += it->getPackageName(); |
256 | if ( it->isInstalled() ) | 257 | if ( it->isInstalled() ) |
257 | { | 258 | { |
258 | text += " (installed)"; | 259 | text += " (installed)"; |
259 | 260 | ||
260 | // If a different version of package is available, postfix it with an * | 261 | // If a different version of package is available, postfix it with an * |
261 | if ( it->getVersion() != it->getInstalledVersion() ) | 262 | if ( it->getVersion() != it->getInstalledVersion() ) |
262 | { | 263 | { |
263 | 264 | ||
264 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | 265 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) |
265 | text += "*"; | 266 | text += "*"; |
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
269 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 270 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
270 | 271 | ||
271 | if ( it->isInstalled() ) | 272 | if ( it->isInstalled() ) |
272 | { | 273 | { |
273 | QString destName = ""; | 274 | QString destName = ""; |
274 | if ( it->getLocalPackage() ) | 275 | if ( it->getLocalPackage() ) |
275 | { | 276 | { |
276 | if ( it->getLocalPackage()->getInstalledTo() ) | 277 | if ( it->getLocalPackage()->getInstalledTo() ) |
277 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 278 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
278 | } | 279 | } |
279 | else | 280 | else |
280 | { | 281 | { |
281 | if ( it->getInstalledTo() ) | 282 | if ( it->getInstalledTo() ) |
282 | destName = it->getInstalledTo()->getDestinationName(); | 283 | destName = it->getInstalledTo()->getDestinationName(); |
283 | } | 284 | } |
284 | if ( destName != "" ) | 285 | if ( destName != "" ) |
285 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | 286 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); |
286 | } | 287 | } |
287 | 288 | ||
288 | if ( !it->isPackageStoredLocally() ) | 289 | if ( !it->isPackageStoredLocally() ) |
289 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 290 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
290 | else | 291 | else |
291 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 292 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
292 | 293 | ||
293 | if ( serverName == LOCAL_SERVER ) | 294 | if ( serverName == LOCAL_SERVER ) |
294 | { | 295 | { |
295 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); | 296 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); |
296 | } | 297 | } |
297 | else | 298 | else |
298 | { | 299 | { |
299 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 300 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
300 | if ( it->getLocalPackage() ) | 301 | if ( it->getLocalPackage() ) |
301 | { | 302 | { |
302 | if ( it->isInstalled() ) | 303 | if ( it->isInstalled() ) |
303 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 304 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | 307 | ||
307 | new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); | 308 | new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); |
308 | new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); | 309 | new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); |
309 | packagesList->insertItem( item ); | 310 | packagesList->insertItem( item ); |
310 | } | 311 | } |
311 | 312 | ||
312 | // If the local server or the local ipkgs server disable the download button | 313 | // If the local server or the local ipkgs server disable the download button |
313 | if ( serverName == LOCAL_SERVER ) | 314 | if ( serverName == LOCAL_SERVER ) |
314 | { | 315 | { |
315 | upgrade->setEnabled( false ); | 316 | upgrade->setEnabled( false ); |
316 | download->setText( "Download" ); | 317 | download->setText( "Download" ); |
317 | download->setEnabled( true ); | 318 | download->setEnabled( true ); |
318 | } | 319 | } |
319 | else if ( serverName == LOCAL_IPKGS ) | 320 | else if ( serverName == LOCAL_IPKGS ) |
320 | { | 321 | { |
321 | upgrade->setEnabled( false ); | 322 | upgrade->setEnabled( false ); |
322 | download->setEnabled( true ); | 323 | download->setEnabled( true ); |
323 | download->setText( "Remove" ); | 324 | download->setText( "Remove" ); |
324 | } | 325 | } |
325 | else | 326 | else |
326 | { | 327 | { |
327 | upgrade->setEnabled( true ); | 328 | upgrade->setEnabled( true ); |
328 | download->setEnabled( true ); | 329 | download->setEnabled( true ); |
329 | download->setText( "Download" ); | 330 | download->setText( "Download" ); |
330 | } | 331 | } |
331 | } | 332 | } |
332 | 333 | ||
333 | void NetworkPackageManager :: updateServer() | 334 | void NetworkPackageManager :: updateServer() |
334 | { | 335 | { |
335 | QString serverName = serversList->currentText(); | 336 | QString serverName = serversList->currentText(); |
336 | 337 | ||
337 | // Update the current server | 338 | // Update the current server |
338 | // Display dialog | 339 | // Display dialog |
339 | 340 | ||
340 | // Disable buttons to stop silly people clicking lots on them :) | 341 | // Disable buttons to stop silly people clicking lots on them :) |
341 | 342 | ||
342 | // First, write out ipkg_conf file so that ipkg can use it | 343 | // First, write out ipkg_conf file so that ipkg can use it |
343 | dataMgr->writeOutIpkgConf(); | 344 | dataMgr->writeOutIpkgConf(); |
344 | 345 | ||
345 | Ipkg ipkg; | 346 | Ipkg ipkg; |
346 | ipkg.setOption( "update" ); | 347 | ipkg.setOption( "update" ); |
347 | 348 | ||
348 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); | 349 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); |
349 | dlg.showDlg(); | 350 | dlg.showDlg(); |
350 | 351 | ||
351 | // Reload data | 352 | // Reload data |
352 | dataMgr->reloadServerData(); | 353 | dataMgr->reloadServerData(); |
353 | serverSelected(-1); | 354 | serverSelected(-1); |
354 | // delete progDlg; | 355 | // delete progDlg; |
355 | } | 356 | } |
356 | 357 | ||
357 | void NetworkPackageManager :: upgradePackages() | 358 | void NetworkPackageManager :: upgradePackages() |
358 | { | 359 | { |
359 | // We're gonna do an upgrade of all packages | 360 | // We're gonna do an upgrade of all packages |
360 | // First warn user that this isn't recommended | 361 | // First warn user that this isn't recommended |
361 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 362 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
362 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 363 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
363 | QMessageBox::Yes, | 364 | QMessageBox::Yes, |
364 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 365 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
365 | 0, this ); | 366 | 0, this ); |
366 | warn.adjustSize(); | 367 | warn.adjustSize(); |
367 | 368 | ||
368 | if ( warn.exec() == QMessageBox::Yes ) | 369 | if ( warn.exec() == QMessageBox::Yes ) |
369 | { | 370 | { |
370 | // First, write out ipkg_conf file so that ipkg can use it | 371 | // First, write out ipkg_conf file so that ipkg can use it |
371 | dataMgr->writeOutIpkgConf(); | 372 | dataMgr->writeOutIpkgConf(); |
372 | 373 | ||
373 | // Now run upgrade | 374 | // Now run upgrade |
374 | Ipkg ipkg; | 375 | Ipkg ipkg; |
375 | ipkg.setOption( "upgrade" ); | 376 | ipkg.setOption( "upgrade" ); |
376 | 377 | ||
377 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); | 378 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); |
378 | dlg.showDlg(); | 379 | dlg.showDlg(); |
379 | 380 | ||
380 | // Reload data | 381 | // Reload data |
381 | dataMgr->reloadServerData(); | 382 | dataMgr->reloadServerData(); |
382 | serverSelected(-1); | 383 | serverSelected(-1); |
383 | } | 384 | } |
384 | } | 385 | } |
385 | 386 | ||
386 | 387 | ||
387 | void NetworkPackageManager :: downloadPackage() | 388 | void NetworkPackageManager :: downloadPackage() |
388 | { | 389 | { |
389 | bool doUpdate = true; | 390 | bool doUpdate = true; |
390 | if ( download->text() == "Download" ) | 391 | if ( download->text() == "Download" ) |
391 | { | 392 | { |
392 | // See if any packages are selected | 393 | // See if any packages are selected |
393 | bool found = false; | 394 | bool found = false; |
394 | if ( serversList->currentText() != LOCAL_SERVER ) | 395 | if ( serversList->currentText() != LOCAL_SERVER ) |
395 | { | 396 | { |
396 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 397 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
397 | item != 0 && !found; | 398 | item != 0 && !found; |
398 | item = (QCheckListItem *)item->nextSibling() ) | 399 | item = (QCheckListItem *)item->nextSibling() ) |
399 | { | 400 | { |
400 | if ( item->isOn() ) | 401 | if ( item->isOn() ) |
401 | found = true; | 402 | found = true; |
402 | } | 403 | } |
403 | } | 404 | } |
404 | 405 | ||
405 | // If user selected some packages then download the and store the locally | 406 | // If user selected some packages then download the and store the locally |
406 | // otherwise, display dialog asking user what package to download from an http server | 407 | // otherwise, display dialog asking user what package to download from an http server |
407 | // and whether to install it | 408 | // and whether to install it |
408 | if ( found ) | 409 | if ( found ) |
409 | downloadSelectedPackages(); | 410 | downloadSelectedPackages(); |
410 | else | 411 | else |
411 | downloadRemotePackage(); | 412 | downloadRemotePackage(); |
412 | 413 | ||
413 | } | 414 | } |
414 | else if ( download->text() == "Remove" ) | 415 | else if ( download->text() == "Remove" ) |
415 | { | 416 | { |
416 | doUpdate = false; | 417 | doUpdate = false; |
417 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 418 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
418 | item != 0 ; | 419 | item != 0 ; |
419 | item = (QCheckListItem *)item->nextSibling() ) | 420 | item = (QCheckListItem *)item->nextSibling() ) |
420 | { | 421 | { |
421 | if ( item->isOn() ) | 422 | if ( item->isOn() ) |
422 | { | 423 | { |
423 | QString name = item->text(); | 424 | QString name = item->text(); |
424 | int pos = name.find( "*" ); | 425 | int pos = name.find( "*" ); |
425 | name.truncate( pos ); | 426 | name.truncate( pos ); |
426 | 427 | ||
427 | // if (there is a (installed), remove it | 428 | // if (there is a (installed), remove it |
428 | pos = name.find( "(installed)" ); | 429 | pos = name.find( "(installed)" ); |
429 | if ( pos > 0 ) | 430 | if ( pos > 0 ) |
430 | name.truncate( pos - 1 ); | 431 | name.truncate( pos - 1 ); |
431 | 432 | ||
432 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 433 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
433 | 434 | ||
434 | QString msgtext; | 435 | QString msgtext; |
435 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); | 436 | msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); |
436 | if ( QMessageBox::information( this, "Are you sure?", | 437 | if ( QMessageBox::information( this, "Are you sure?", |
437 | msgtext, "No", "Yes" ) == 1 ) | 438 | msgtext, "No", "Yes" ) == 1 ) |
438 | { | 439 | { |
439 | doUpdate = true; | 440 | doUpdate = true; |
440 | QFile f( p->getFilename() ); | 441 | QFile f( p->getFilename() ); |
441 | f.remove(); | 442 | f.remove(); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | } | 445 | } |
445 | } | 446 | } |
446 | 447 | ||
447 | if ( doUpdate ) | 448 | if ( doUpdate ) |
448 | { | 449 | { |
449 | dataMgr->reloadServerData(); | 450 | dataMgr->reloadServerData(); |
450 | serverSelected( -1 ); | 451 | serverSelected( -1 ); |
451 | } | 452 | } |
452 | } | 453 | } |
453 | 454 | ||
454 | void NetworkPackageManager :: downloadSelectedPackages() | 455 | void NetworkPackageManager :: downloadSelectedPackages() |
455 | { | 456 | { |
456 | // First, write out ipkg_conf file so that ipkg can use it | 457 | // First, write out ipkg_conf file so that ipkg can use it |
457 | dataMgr->writeOutIpkgConf(); | 458 | dataMgr->writeOutIpkgConf(); |
458 | 459 | ||
459 | // Display dialog to user asking where to download the files to | 460 | // Display dialog to user asking where to download the files to |
460 | bool ok = FALSE; | 461 | bool ok = FALSE; |
461 | QString dir = ""; | 462 | QString dir = ""; |
462 | #ifdef QWS | 463 | #ifdef QWS |
463 | // read download directory from config file | 464 | // read download directory from config file |
464 | Config cfg( "aqpkg" ); | 465 | Config cfg( "aqpkg" ); |
465 | cfg.setGroup( "settings" ); | 466 | cfg.setGroup( "settings" ); |
466 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 467 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
467 | #endif | 468 | #endif |
468 | 469 | ||
469 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 470 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
470 | if ( ok && !text.isEmpty() ) | 471 | if ( ok && !text.isEmpty() ) |
471 | dir = text; // user entered something and pressed ok | 472 | dir = text; // user entered something and pressed ok |
472 | else | 473 | else |
473 | return; // user entered nothing or pressed cancel | 474 | return; // user entered nothing or pressed cancel |
474 | 475 | ||
475 | #ifdef QWS | 476 | #ifdef QWS |
476 | // Store download directory in config file | 477 | // Store download directory in config file |
477 | cfg.writeEntry( "downloadDir", dir ); | 478 | cfg.writeEntry( "downloadDir", dir ); |
478 | #endif | 479 | #endif |
479 | 480 | ||
480 | // Get starting directory | 481 | // Get starting directory |
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 726cf00..58407d5 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -1,306 +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 <stdio.h> | 22 | #include <stdio.h> |
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #include <iostream> | 26 | #include <iostream> |
27 | #include <fstream> | 27 | #include <fstream> |
28 | using namespace std; | 28 | using namespace std; |
29 | 29 | ||
30 | #include "server.h" | 30 | #include "server.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | 32 | ||
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #include "utils.h" | 39 | #include "utils.h" |
40 | 40 | ||
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | Server :: Server( const char *name, const char *url ) | 43 | Server :: Server( const char *name, const char *url ) |
44 | { | 44 | { |
45 | serverName = name; | 45 | serverName = name; |
46 | serverUrl = url; | 46 | serverUrl = url; |
47 | packageFile = IPKG_DIR; | 47 | packageFile = IPKG_DIR; |
48 | active = true; | ||
48 | packageFile += "lists/" + serverName; | 49 | packageFile += "lists/" + serverName; |
49 | } | 50 | } |
50 | 51 | ||
51 | Server :: ~Server() | 52 | Server :: ~Server() |
52 | { | 53 | { |
53 | cleanUp(); | 54 | cleanUp(); |
54 | } | 55 | } |
55 | 56 | ||
56 | void Server :: cleanUp() | 57 | void Server :: cleanUp() |
57 | { | 58 | { |
58 | packageList.clear(); | 59 | packageList.clear(); |
59 | } | 60 | } |
60 | 61 | ||
61 | void Server :: readStatusFile( vector<Destination> &destList ) | 62 | void Server :: readStatusFile( vector<Destination> &destList ) |
62 | { | 63 | { |
63 | cleanUp(); | 64 | cleanUp(); |
64 | 65 | ||
65 | vector<Destination>::iterator dit; | 66 | vector<Destination>::iterator dit; |
66 | bool rootRead = false; | 67 | bool rootRead = false; |
67 | for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) | 68 | for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) |
68 | { | 69 | { |
69 | bool installingToRoot = false; | 70 | bool installingToRoot = false; |
70 | 71 | ||
71 | QString path = dit->getDestinationPath(); | 72 | QString path = dit->getDestinationPath(); |
72 | if ( path.right( 1 ) != "/" ) | 73 | if ( path.right( 1 ) != "/" ) |
73 | path += "/"; | 74 | path += "/"; |
74 | 75 | ||
75 | if ( path == "/" ) | 76 | if ( path == "/" ) |
76 | { | 77 | { |
77 | rootRead = true; | 78 | rootRead = true; |
78 | installingToRoot = true; | 79 | installingToRoot = true; |
79 | } | 80 | } |
80 | 81 | ||
81 | packageFile = path + "usr/lib/ipkg/status"; | 82 | packageFile = path + "usr/lib/ipkg/status"; |
82 | readPackageFile( 0, false, installingToRoot, dit ); | 83 | readPackageFile( 0, false, installingToRoot, dit ); |
83 | } | 84 | } |
84 | 85 | ||
85 | // Ensure that the root status file is read | 86 | // Ensure that the root status file is read |
86 | if ( !rootRead ) | 87 | if ( !rootRead ) |
87 | { | 88 | { |
88 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; | 89 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; |
89 | packageFile = "/usr/lib/ipkg/status"; | 90 | packageFile = "/usr/lib/ipkg/status"; |
90 | readPackageFile( 0, false, true ); | 91 | readPackageFile( 0, false, true ); |
91 | } | 92 | } |
92 | } | 93 | } |
93 | 94 | ||
94 | void Server :: readLocalIpks( Server *local ) | 95 | void Server :: readLocalIpks( Server *local ) |
95 | { | 96 | { |
96 | cleanUp(); | 97 | cleanUp(); |
97 | 98 | ||
98 | #ifdef QWS | 99 | #ifdef QWS |
99 | // First, get any local IPKGs in the documents area | 100 | // First, get any local IPKGs in the documents area |
100 | // Only applicable to Qtopie/Opie | 101 | // Only applicable to Qtopie/Opie |
101 | 102 | ||
102 | DocLnkSet files; | 103 | DocLnkSet files; |
103 | Global::findDocuments( &files, "application/ipkg" ); | 104 | Global::findDocuments( &files, "application/ipkg" ); |
104 | 105 | ||
105 | // Now add the items to the list | 106 | // Now add the items to the list |
106 | QListIterator<DocLnk> it( files.children() ); | 107 | QListIterator<DocLnk> it( files.children() ); |
107 | 108 | ||
108 | for ( ; it.current() ; ++it ) | 109 | for ( ; it.current() ; ++it ) |
109 | { | 110 | { |
110 | // OK, we have a local IPK file, I think the standard naming conventions | 111 | // OK, we have a local IPK file, I think the standard naming conventions |
111 | // for these are packagename_version_arm.ipk | 112 | // for these are packagename_version_arm.ipk |
112 | QString file = (*it)->file(); | 113 | QString file = (*it)->file(); |
113 | 114 | ||
114 | // Changed to display the filename (excluding the path) | 115 | // Changed to display the filename (excluding the path) |
115 | QString packageName = Utils::getFilenameFromIpkFilename( file ); | 116 | QString packageName = Utils::getFilenameFromIpkFilename( file ); |
116 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); | 117 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); |
117 | packageList.push_back( Package( packageName ) ); | 118 | packageList.push_back( Package( packageName ) ); |
118 | packageList.back().setVersion( ver ); | 119 | packageList.back().setVersion( ver ); |
119 | packageList.back().setFilename( file ); | 120 | packageList.back().setFilename( file ); |
120 | packageList.back().setPackageStoredLocally( true ); | 121 | packageList.back().setPackageStoredLocally( true ); |
121 | 122 | ||
122 | } | 123 | } |
123 | #else | 124 | #else |
124 | 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" }; | 125 | 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" }; |
125 | for ( int i = 0 ; i < 4 ; ++i ) | 126 | for ( int i = 0 ; i < 4 ; ++i ) |
126 | { | 127 | { |
127 | // OK, we have a local IPK file, I think the standard naming conventions | 128 | // OK, we have a local IPK file, I think the standard naming conventions |
128 | // for these are packagename_version_arm.ipk | 129 | // for these are packagename_version_arm.ipk |
129 | QString file = names[i]; | 130 | QString file = names[i]; |
130 | int p = file.find( "_" ); | 131 | int p = file.find( "_" ); |
131 | QString tmp = file.mid( 0, p ); | 132 | QString tmp = file.mid( 0, p ); |
132 | packageList.push_back( Package( tmp ) ); | 133 | packageList.push_back( Package( tmp ) ); |
133 | int p2 = file.find( "_", p+1 ); | 134 | int p2 = file.find( "_", p+1 ); |
134 | tmp = file.mid( p+1, p2-(p+1) ); | 135 | tmp = file.mid( p+1, p2-(p+1) ); |
135 | packageList.back().setVersion( tmp ); | 136 | packageList.back().setVersion( tmp ); |
136 | packageList.back().setPackageStoredLocally( true ); | 137 | packageList.back().setPackageStoredLocally( true ); |
137 | } | 138 | } |
138 | #endif | 139 | #endif |
139 | 140 | ||
140 | // build local packages | 141 | // build local packages |
141 | buildLocalPackages( local ); | 142 | buildLocalPackages( local ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) | 145 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) |
145 | { | 146 | { |
146 | ifstream in( packageFile ); | 147 | ifstream in( packageFile ); |
147 | if ( !in.is_open() ) | 148 | if ( !in.is_open() ) |
148 | return; | 149 | return; |
149 | 150 | ||
150 | char line[1001]; | 151 | char line[1001]; |
151 | char k[21]; | 152 | char k[21]; |
152 | char v[1001]; | 153 | char v[1001]; |
153 | QString key; | 154 | QString key; |
154 | QString value; | 155 | QString value; |
155 | 156 | ||
156 | if ( clearAll ) | 157 | if ( clearAll ) |
157 | cleanUp(); | 158 | cleanUp(); |
158 | Package *currPackage = 0; | 159 | Package *currPackage = 0; |
159 | 160 | ||
160 | bool newPackage = true; | 161 | bool newPackage = true; |
161 | do | 162 | do |
162 | { | 163 | { |
163 | in.getline( line, 1000 ); | 164 | in.getline( line, 1000 ); |
164 | if ( in.eof() ) | 165 | if ( in.eof() ) |
165 | continue; | 166 | continue; |
166 | 167 | ||
167 | k[0] = '\0'; | 168 | k[0] = '\0'; |
168 | v[0] = '\0'; | 169 | v[0] = '\0'; |
169 | 170 | ||
170 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 171 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
171 | key = k; | 172 | key = k; |
172 | value = v; | 173 | value = v; |
173 | key = key.stripWhiteSpace(); | 174 | key = key.stripWhiteSpace(); |
174 | value = value.stripWhiteSpace(); | 175 | value = value.stripWhiteSpace(); |
175 | if ( key == "Package" && newPackage ) | 176 | if ( key == "Package" && newPackage ) |
176 | { | 177 | { |
177 | newPackage = false; | 178 | newPackage = false; |
178 | 179 | ||
179 | currPackage = getPackage( value ); | 180 | currPackage = getPackage( value ); |
180 | if ( !currPackage ) | 181 | if ( !currPackage ) |
181 | { | 182 | { |
182 | packageList.push_back( Package( value ) ); | 183 | packageList.push_back( Package( value ) ); |
183 | currPackage = &(packageList.back()); | 184 | currPackage = &(packageList.back()); |
184 | currPackage->setInstalledTo( dest ); | 185 | currPackage->setInstalledTo( dest ); |
185 | 186 | ||
186 | if ( installingToRoot ) | 187 | if ( installingToRoot ) |
187 | currPackage->setInstalledToRoot( true ); | 188 | currPackage->setInstalledToRoot( true ); |
188 | } | 189 | } |
189 | else | 190 | else |
190 | { | 191 | { |
191 | if (currPackage->getStatus().find( "deinstall" ) != -1 ) | 192 | if (currPackage->getStatus().find( "deinstall" ) != -1 ) |
192 | currPackage->setInstalledTo( dest ); | 193 | currPackage->setInstalledTo( dest ); |
193 | } | 194 | } |
194 | } | 195 | } |
195 | else if ( key == "Version" ) | 196 | else if ( key == "Version" ) |
196 | { | 197 | { |
197 | if ( currPackage ) | 198 | if ( currPackage ) |
198 | currPackage->setVersion( value ); | 199 | currPackage->setVersion( value ); |
199 | } | 200 | } |
200 | else if ( key == "Status" ) | 201 | else if ( key == "Status" ) |
201 | { | 202 | { |
202 | if ( currPackage ) | 203 | if ( currPackage ) |
203 | currPackage->setStatus( value ); | 204 | currPackage->setStatus( value ); |
204 | } | 205 | } |
205 | else if ( key == "Description" ) | 206 | else if ( key == "Description" ) |
206 | { | 207 | { |
207 | if ( currPackage ) | 208 | if ( currPackage ) |
208 | currPackage->setDescription( value ); | 209 | currPackage->setDescription( value ); |
209 | } | 210 | } |
210 | else if ( key == "Filename" ) | 211 | else if ( key == "Filename" ) |
211 | { | 212 | { |
212 | if ( currPackage ) | 213 | if ( currPackage ) |
213 | currPackage->setFilename( value ); | 214 | currPackage->setFilename( value ); |
214 | } | 215 | } |
215 | else if ( key == "Size" ) | 216 | else if ( key == "Size" ) |
216 | { | 217 | { |
217 | if ( currPackage ) | 218 | if ( currPackage ) |
218 | currPackage->setPackageSize( value ); | 219 | currPackage->setPackageSize( value ); |
219 | } | 220 | } |
220 | else if ( key == "Section" ) | 221 | else if ( key == "Section" ) |
221 | { | 222 | { |
222 | if ( currPackage ) | 223 | if ( currPackage ) |
223 | currPackage->setSection( value ); | 224 | currPackage->setSection( value ); |
224 | 225 | ||
225 | DataManager::setAvailableCategories( value ); | 226 | DataManager::setAvailableCategories( value ); |
226 | } | 227 | } |
227 | else if ( key == "" ) | 228 | else if ( key == "" ) |
228 | { | 229 | { |
229 | newPackage = true; | 230 | newPackage = true; |
230 | } | 231 | } |
231 | } while ( !in.eof() ); | 232 | } while ( !in.eof() ); |
232 | 233 | ||
233 | in.close(); | 234 | in.close(); |
234 | 235 | ||
235 | // build local packages | 236 | // build local packages |
236 | buildLocalPackages( local ); | 237 | buildLocalPackages( local ); |
237 | } | 238 | } |
238 | 239 | ||
239 | void Server :: buildLocalPackages( Server *local ) | 240 | void Server :: buildLocalPackages( Server *local ) |
240 | { | 241 | { |
241 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 242 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) |
242 | { | 243 | { |
243 | QString name = packageList[i].getPackageName(); | 244 | QString name = packageList[i].getPackageName(); |
244 | 245 | ||
245 | // If the package name is an ipk name, then convert the filename to a package name | 246 | // If the package name is an ipk name, then convert the filename to a package name |
246 | if ( name.find( ".ipk" ) != -1 ) | 247 | if ( name.find( ".ipk" ) != -1 ) |
247 | name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); | 248 | name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); |
248 | 249 | ||
249 | if ( local ) | 250 | if ( local ) |
250 | { | 251 | { |
251 | Package *p = local->getPackage( name ); | 252 | Package *p = local->getPackage( name ); |
252 | packageList[i].setLocalPackage( p ); | 253 | packageList[i].setLocalPackage( p ); |
253 | if ( p ) | 254 | if ( p ) |
254 | { | 255 | { |
255 | // Set some default stuff like size and things | 256 | // Set some default stuff like size and things |
256 | if ( p->getInstalledVersion() == packageList[i].getVersion() ) | 257 | if ( p->getInstalledVersion() == packageList[i].getVersion() ) |
257 | { | 258 | { |
258 | p->setPackageSize( packageList[i].getPackageSize() ); | 259 | p->setPackageSize( packageList[i].getPackageSize() ); |
259 | p->setSection( packageList[i].getSection() ); | 260 | p->setSection( packageList[i].getSection() ); |
260 | p->setDescription( packageList[i].getDescription() ); | 261 | p->setDescription( packageList[i].getDescription() ); |
261 | } | 262 | } |
262 | } | 263 | } |
263 | 264 | ||
264 | } | 265 | } |
265 | else | 266 | else |
266 | packageList[i].setLocalPackage( 0 ); | 267 | packageList[i].setLocalPackage( 0 ); |
267 | } | 268 | } |
268 | 269 | ||
269 | } | 270 | } |
270 | 271 | ||
271 | Package *Server :: getPackage( QString &name ) | 272 | Package *Server :: getPackage( QString &name ) |
272 | { | 273 | { |
273 | return getPackage( (const char *)name ); | 274 | return getPackage( (const char *)name ); |
274 | } | 275 | } |
275 | 276 | ||
276 | Package *Server :: getPackage( const char *name ) | 277 | Package *Server :: getPackage( const char *name ) |
277 | { | 278 | { |
278 | Package *ret = 0; | 279 | Package *ret = 0; |
279 | 280 | ||
280 | for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) | 281 | for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) |
281 | { | 282 | { |
282 | if ( packageList[i].getPackageName() == name ) | 283 | if ( packageList[i].getPackageName() == name ) |
283 | ret = &packageList[i]; | 284 | ret = &packageList[i]; |
284 | } | 285 | } |
285 | 286 | ||
286 | return ret; | 287 | return ret; |
287 | } | 288 | } |
288 | 289 | ||
289 | QString Server :: toString() | 290 | QString Server :: toString() |
290 | { | 291 | { |
291 | QString ret = "Server\n name - " + serverName + | 292 | QString ret = "Server\n name - " + serverName + |
292 | "\n url - " + serverUrl + | 293 | "\n url - " + serverUrl + |
293 | "\n"; | 294 | "\n"; |
294 | 295 | ||
295 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 296 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) |
296 | ret += "\n " + packageList[i].toString(); | 297 | ret += "\n " + packageList[i].toString(); |
297 | 298 | ||
298 | 299 | ||
299 | return ret; | 300 | return ret; |
300 | } | 301 | } |
301 | 302 | ||
302 | vector<Package> &Server::getPackageList() | 303 | vector<Package> &Server::getPackageList() |
303 | { | 304 | { |
304 | return packageList; | 305 | return packageList; |
305 | } | 306 | } |
306 | 307 | ||