summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-16 23:08:56 (UTC)
committer andyq <andyq>2002-10-16 23:08:56 (UTC)
commitb1d16660979fa8bb767fa0a6fe2d966e5633abdc (patch) (unidiff)
tree42390cc528f61bd44c0de7084d0fed8000bc10c4
parent593fe744126a398e2714070137b6f19e398d2c9d (diff)
downloadopie-b1d16660979fa8bb767fa0a6fe2d966e5633abdc.zip
opie-b1d16660979fa8bb767fa0a6fe2d966e5633abdc.tar.gz
opie-b1d16660979fa8bb767fa0a6fe2d966e5633abdc.tar.bz2
Handles commented servers nicely
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 318b26d..3ce7960 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,218 +1,224 @@
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>
20using namespace std; 20using 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 43
44#include "global.h" 44#include "global.h"
45 45
46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
47 : QWidget(parent, name) 47 : QWidget(parent, name)
48{ 48{
49 dataMgr = dataManager; 49 dataMgr = dataManager;
50 50
51#ifdef QWS 51#ifdef QWS
52 // read download directory from config file 52 // read download directory from config file
53 Config cfg( "aqpkg" ); 53 Config cfg( "aqpkg" );
54 cfg.setGroup( "settings" ); 54 cfg.setGroup( "settings" );
55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
56#endif 56#endif
57 57
58 58
59 initGui(); 59 initGui();
60 setupConnections(); 60 setupConnections();
61 61
62 progressDlg = 0; 62 progressDlg = 0;
63 timerId = startTimer( 100 ); 63 timerId = startTimer( 100 );
64} 64}
65 65
66NetworkPackageManager::~NetworkPackageManager() 66NetworkPackageManager::~NetworkPackageManager()
67{ 67{
68} 68}
69 69
70void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 70void NetworkPackageManager :: timerEvent ( QTimerEvent * )
71{ 71{
72 killTimer( timerId ); 72 killTimer( timerId );
73 73
74// showProgressDialog(); 74// showProgressDialog();
75 // Add server names to listbox 75 // Add server names to listbox
76 updateData(); 76 updateData();
77 77
78// progressDlg->hide(); 78// progressDlg->hide();
79} 79}
80 80
81void NetworkPackageManager :: updateData() 81void NetworkPackageManager :: updateData()
82{ 82{
83 serversList->clear(); 83 serversList->clear();
84 packagesList->clear(); 84 packagesList->clear();
85 85
86
86 vector<Server>::iterator it; 87 vector<Server>::iterator it;
87 int activeItem = -1; 88 int activeItem = -1;
88 int i; 89 int i;
89 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 90 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
90 { 91 {
92 if ( !it->isServerActive() )
93 {
94 i--;
95 continue;
96 }
91 serversList->insertItem( it->getServerName() ); 97 serversList->insertItem( it->getServerName() );
92 if ( it->getServerName() == currentlySelectedServer ) 98 if ( it->getServerName() == currentlySelectedServer )
93 activeItem = i; 99 activeItem = i;
94 } 100 }
95 101
96 // set selected server to be active server 102 // set selected server to be active server
97 if ( activeItem != -1 ) 103 if ( activeItem != -1 )
98 serversList->setCurrentItem( activeItem ); 104 serversList->setCurrentItem( activeItem );
99 serverSelected( 0 ); 105 serverSelected( 0 );
100} 106}
101 107
102 108
103void NetworkPackageManager :: initGui() 109void NetworkPackageManager :: initGui()
104{ 110{
105 QLabel *l = new QLabel( "Servers", this ); 111 QLabel *l = new QLabel( "Servers", this );
106 serversList = new QComboBox( this ); 112 serversList = new QComboBox( this );
107 packagesList = new QListView( this ); 113 packagesList = new QListView( this );
108 update = new QPushButton( "Refresh List", this ); 114 update = new QPushButton( "Refresh List", this );
109 download = new QPushButton( "Download", this ); 115 download = new QPushButton( "Download", this );
110 upgrade = new QPushButton( "Upgrade", this ); 116 upgrade = new QPushButton( "Upgrade", this );
111 apply = new QPushButton( "Apply", this ); 117 apply = new QPushButton( "Apply", this );
112 118
113 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 119 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
114 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 120 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
115 hbox1->addWidget( l ); 121 hbox1->addWidget( l );
116 hbox1->addWidget( serversList ); 122 hbox1->addWidget( serversList );
117 123
118 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 124 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
119 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 125 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
120 126
121 char text[2]; 127 char text[2];
122 text[1] = '\0'; 128 text[1] = '\0';
123 for ( int i = 0 ; i < 26 ; ++i ) 129 for ( int i = 0 ; i < 26 ; ++i )
124 { 130 {
125 text[0] = 'A' + i; 131 text[0] = 'A' + i;
126 LetterPushButton *b = new LetterPushButton( text, this ); 132 LetterPushButton *b = new LetterPushButton( text, this );
127 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 133 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
128 if ( i < 16 ) 134 if ( i < 16 )
129 hbox3->addWidget( b ); 135 hbox3->addWidget( b );
130 else 136 else
131 hbox4->addWidget( b ); 137 hbox4->addWidget( b );
132 } 138 }
133 139
134 vbox->addWidget( packagesList ); 140 vbox->addWidget( packagesList );
135 packagesList->addColumn( "Packages" ); 141 packagesList->addColumn( "Packages" );
136 142
137 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 143 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
138 hbox2->addWidget( update ); 144 hbox2->addWidget( update );
139 hbox2->addWidget( download ); 145 hbox2->addWidget( download );
140 hbox2->addWidget( upgrade ); 146 hbox2->addWidget( upgrade );
141 hbox2->addWidget( apply ); 147 hbox2->addWidget( apply );
142} 148}
143 149
144void NetworkPackageManager :: setupConnections() 150void NetworkPackageManager :: setupConnections()
145{ 151{
146 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 152 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
147 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 153 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
148 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 154 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
149 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 155 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
150 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 156 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
151} 157}
152 158
153void NetworkPackageManager :: showProgressDialog( char *initialText ) 159void NetworkPackageManager :: showProgressDialog( char *initialText )
154{ 160{
155 if ( !progressDlg ) 161 if ( !progressDlg )
156 progressDlg = new ProgressDlg( this, "Progress", false ); 162 progressDlg = new ProgressDlg( this, "Progress", false );
157 progressDlg->setText( initialText ); 163 progressDlg->setText( initialText );
158 progressDlg->show(); 164 progressDlg->show();
159} 165}
160 166
161 167
162void NetworkPackageManager :: serverSelected( int ) 168void NetworkPackageManager :: serverSelected( int )
163{ 169{
164 packagesList->clear(); 170 packagesList->clear();
165 171
166 // display packages 172 // display packages
167 QString serverName = serversList->currentText(); 173 QString serverName = serversList->currentText();
168 currentlySelectedServer = serverName; 174 currentlySelectedServer = serverName;
169 175
170#ifdef QWS 176#ifdef QWS
171 // read download directory from config file 177 // read download directory from config file
172 Config cfg( "aqpkg" ); 178 Config cfg( "aqpkg" );
173 cfg.setGroup( "settings" ); 179 cfg.setGroup( "settings" );
174 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 180 cfg.writeEntry( "selectedServer", currentlySelectedServer );
175#endif 181#endif
176 182
177 Server *s = dataMgr->getServer( serverName ); 183 Server *s = dataMgr->getServer( serverName );
178// dataMgr->setActiveServer( serverName ); 184// dataMgr->setActiveServer( serverName );
179 185
180 vector<Package> &list = s->getPackageList(); 186 vector<Package> &list = s->getPackageList();
181 vector<Package>::iterator it; 187 vector<Package>::iterator it;
182 for ( it = list.begin() ; it != list.end() ; ++it ) 188 for ( it = list.begin() ; it != list.end() ; ++it )
183 { 189 {
184 QString text = ""; 190 QString text = "";
185 191
186 // If the local server, only display installed packages 192 // If the local server, only display installed packages
187 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 193 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
188 continue; 194 continue;
189 195
190 text += it->getPackageName(); 196 text += it->getPackageName();
191 if ( it->isInstalled() ) 197 if ( it->isInstalled() )
192 { 198 {
193 text += " (installed)"; 199 text += " (installed)";
194 200
195 // If a different version of package is available, postfix it with an * 201 // If a different version of package is available, postfix it with an *
196 if ( it->getVersion() != it->getInstalledVersion() ) 202 if ( it->getVersion() != it->getInstalledVersion() )
197 text += "*"; 203 text += "*";
198 } 204 }
199 205
200 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 206 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
201 if ( !it->isPackageStoredLocally() ) 207 if ( !it->isPackageStoredLocally() )
202 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 208 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
203 else 209 else
204 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 210 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
205 211
206 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 212 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
207 if ( it->getLocalPackage() ) 213 if ( it->getLocalPackage() )
208 { 214 {
209 if ( it->isInstalled() ) 215 if ( it->isInstalled() )
210 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 216 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
211 } 217 }
212 packagesList->insertItem( item ); 218 packagesList->insertItem( item );
213 } 219 }
214 220
215 // If the local server or the local ipkgs server disable the download button 221 // If the local server or the local ipkgs server disable the download button
216 if ( serverName == LOCAL_SERVER ) 222 if ( serverName == LOCAL_SERVER )
217 { 223 {
218 upgrade->setEnabled( false ); 224 upgrade->setEnabled( false );