summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/NetworkDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
index aed53c6..6e6b707 100644
--- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -10,15 +10,15 @@
10// ***************************************************************************/ 10// ***************************************************************************/
11// // half-assed attempt at providing a network dialog. 11// // half-assed attempt at providing a network dialog.
12// /* Created: Sun Aug 27 15:24:52 2000*/ 12// /* Created: Sun Aug 27 15:24:52 2000*/
13#include <unistd.h>
14 13
15extern "C" {
16#include <ftplib.h>
17}
18 14
19#include "NetworkDialog.h" 15#include "NetworkDialog.h"
20#include "gutenbrowser.h" 16#include "gutenbrowser.h"
21 17
18/* OPIE */
19#include <opie2/odebug.h>
20
21/* QT */
22#include <qprogressbar.h> 22#include <qprogressbar.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
@@ -30,6 +30,12 @@ extern "C" {
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32 32
33/* STD */
34#include <unistd.h>
35extern "C" {
36#include <ftplib.h>
37}
38
33QProgressBar* ProgressBar1; 39QProgressBar* ProgressBar1;
34QPushButton* buttonCancel; 40QPushButton* buttonCancel;
35static netbuf *conn = NULL; 41static netbuf *conn = NULL;
@@ -119,7 +125,7 @@ void NetworkDialog::initDialog() {
119// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot())); 125// connect( timer, SIGNAL(timeout()), this , SLOT(timeSlot()));
120// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot())); 126// connect( connectionTimer,SIGNAL( timeout()),this,SLOT( connectionTimeSlot()));
121 if(autoOk) { 127 if(autoOk) {
122 qWarning("XXXXXXXXXXXXXXXXXXXXXXXX"); 128 owarn << "XXXXXXXXXXXXXXXXXXXXXXXX" << oendl;
123 buttonOk->setDown(true); 129 buttonOk->setDown(true);
124 doOk(); 130 doOk();
125 } 131 }
@@ -143,13 +149,13 @@ void NetworkDialog::timeSlot() {
143// timerProgess--; 149// timerProgess--;
144// posTimer=TRUE; 150// posTimer=TRUE;
145// } 151// }
146// // qDebug("timer event"); 152// // odebug << "timer event" << oendl;
147// qApp->processEvents(); 153// qApp->processEvents();
148// repaint(); 154// repaint();
149} 155}
150 156
151void NetworkDialog::connectionTimeSlot() { 157void NetworkDialog::connectionTimeSlot() {
152// qDebug("Connections timed out"); 158// odebug << "Connections timed out" << oendl;
153// ftpQuit(); 159// ftpQuit();
154// qApp->processEvents(); 160// qApp->processEvents();
155// repaint(); 161// repaint();
@@ -167,21 +173,21 @@ bool NetworkDialog::downloadFile( QString networkUrl )
167// connectionTimer->start( 600 , FALSE); 173// connectionTimer->start( 600 , FALSE);
168 warnLabel ->setText( ""); 174 warnLabel ->setText( "");
169 qApp->processEvents(); 175 qApp->processEvents();
170 qDebug("Downloading: %s",networkUrl.latin1()); 176 odebug << "Downloading: " << networkUrl << "" << oendl;
171 qDebug("Into: %s",localFileName.latin1()); 177 odebug << "Into: " << localFileName << "" << oendl;
172 if( networkUrl.length() > 5) { 178 if( networkUrl.length() > 5) {
173 QString ftp_user = "anonymous"; 179 QString ftp_user = "anonymous";
174 QString ftp_pass = "zaurus@gutenbrowser.com"; 180 QString ftp_pass = "zaurus@gutenbrowser.com";
175// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), 181// ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE),
176 if(ftp_host.length() < 2) { 182 if(ftp_host.length() < 2) {
177 qDebug("Please select an ftp host" ); 183 odebug << "Please select an ftp host" << oendl;
178 successDownload=false; 184 successDownload=false;
179 QMessageBox::message("Note","You need to select an ftp host"); 185 QMessageBox::message("Note","You need to select an ftp host");
180 return false; 186 return false;
181 } 187 }
182 QString msg; 188 QString msg;
183 qDebug(ftp_host); 189 odebug << ftp_host << oendl;
184 qDebug("Opening ftp connection."); 190 odebug << "Opening ftp connection." << oendl;
185 warnLabel->setText("connecting to: "+ftp_host ); 191 warnLabel->setText("connecting to: "+ftp_host );
186 qApp->processEvents(); 192 qApp->processEvents();
187 /////////// Open FTP connection 193 /////////// Open FTP connection
@@ -200,7 +206,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
200 QMessageBox::message("Note",msg); 206 QMessageBox::message("Note",msg);
201 return false; 207 return false;
202 } 208 }
203 qDebug("Changing directories."); 209 odebug << "Changing directories." << oendl;
204 TextLabel3->setText("Changing directories."); 210 TextLabel3->setText("Changing directories.");
205 qApp->processEvents(); 211 qApp->processEvents();
206 if (!FtpChdir( dir.latin1(), conn )) { 212 if (!FtpChdir( dir.latin1(), conn )) {
@@ -217,7 +223,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
217// FtpQuit(conn); 223// FtpQuit(conn);
218// return false; 224// return false;
219// } 225// }
220 qDebug("Requesting directory list."); 226 odebug << "Requesting directory list." << oendl;
221 TextLabel3->setText("Getting directory list."); 227 TextLabel3->setText("Getting directory list.");
222 qApp->processEvents(); 228 qApp->processEvents();
223 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) { 229 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
@@ -232,7 +238,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
232 238
233 if (tmp.open(IO_ReadOnly)) { 239 if (tmp.open(IO_ReadOnly)) {
234 QTextStream t( &tmp ); // use a text stream 240 QTextStream t( &tmp ); // use a text stream
235 qDebug("Finding partial filename "+s_partialFileName); 241 odebug << "Finding partial filename "+s_partialFileName << oendl;
236 while ( !t.eof()) { 242 while ( !t.eof()) {
237 s = t.readLine(); 243 s = t.readLine();
238 244
@@ -241,12 +247,12 @@ bool NetworkDialog::downloadFile( QString networkUrl )
241 247
242 if (str.contains(".txt")) { 248 if (str.contains(".txt")) {
243 File_Name = str; 249 File_Name = str;
244 qDebug("Found file_name "+ File_Name); 250 odebug << "Found file_name "+ File_Name << oendl;
245 break; 251 break;
246 } 252 }
247// if (str.contains(".zip")) { 253// if (str.contains(".zip")) {
248// File_Name = str; 254// File_Name = str;
249// qDebug("Found file_name "+ File_Name); 255// odebug << "Found file_name "+ File_Name << oendl;
250// break; 256// break;
251// } 257// }
252 258
@@ -256,15 +262,15 @@ bool NetworkDialog::downloadFile( QString networkUrl )
256// tmp.remove(); ///TODO this is for release version Zaurus 262// tmp.remove(); ///TODO this is for release version Zaurus
257 } 263 }
258 else 264 else
259 qDebug("Error opening temp file."); 265 odebug << "Error opening temp file." << oendl;
260 266
261 Config cfg("Gutenbrowser"); 267 Config cfg("Gutenbrowser");
262 cfg.setGroup("General"); 268 cfg.setGroup("General");
263 QString temp=cfg.readEntry("DownloadDirectory",local_library); 269 QString temp=cfg.readEntry("DownloadDirectory",local_library);
264 270
265 localFileName = temp+File_Name; 271 localFileName = temp+File_Name;
266 qDebug("Requesting file "+ File_Name); 272 odebug << "Requesting file "+ File_Name << oendl;
267 qDebug( "Saving as "+localFileName); 273 odebug << "Saving as "+localFileName << oendl;
268 msg="Requesting file "+ File_Name; 274 msg="Requesting file "+ File_Name;
269 TextLabel3->setText(msg); 275 TextLabel3->setText(msg);
270 qApp->processEvents(); 276 qApp->processEvents();
@@ -293,7 +299,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
293 FtpQuit(conn); 299 FtpQuit(conn);
294 return false; 300 return false;
295 } 301 }
296 qDebug("Ftp session successful"); 302 odebug << "Ftp session successful" << oendl;
297 successDownload=TRUE; 303 successDownload=TRUE;
298 FtpQuit(conn); 304 FtpQuit(conn);
299 return true; 305 return true;
@@ -302,7 +308,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
302} 308}
303 309
304void NetworkDialog::doOk() { 310void NetworkDialog::doOk() {
305 qWarning("Do OK"); 311 owarn << "Do OK" << oendl;
306 QString loginStr; 312 QString loginStr;
307 loginStr = "gutenbrowser"; 313 loginStr = "gutenbrowser";
308 if ( !ftp_host.isEmpty() ) { 314 if ( !ftp_host.isEmpty() ) {