summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
index a9c7346..de9c72b 100644
--- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -1,137 +1,137 @@
1/*************************************************************************** 1/***************************************************************************
2 ftpsitedlg.cpp - description 2 ftpsitedlg.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 ***************************************************************************/ 7 ***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15#include "optionsDialog.h" 15#include "optionsDialog.h"
16#include "gutenbrowser.h" 16#include "gutenbrowser.h"
17//#include "NetworkDialog.h" 17//#include "NetworkDialog.h"
18#include "output.h" 18#include "output.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/odebug.h> 21#include <opie2/odebug.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24/* QT */ 24/* QT */
25#include <qprogressbar.h> 25#include <qprogressbar.h>
26#include <qurloperator.h> 26#include <qurloperator.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28 28
29/* STD */ 29/* STD */
30#include <stdlib.h> 30#include <stdlib.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <stdio.h> 32#include <stdio.h>
33 33
34// :)~ 34// :)~
35void optionsDialog::ftpSiteDlg( ) 35void optionsDialog::ftpSiteDlg( )
36{ 36{
37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); 37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" );
38// initDialog(); 38// initDialog();
39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40// ListFile = local_library + "ftpList"; 40// ListFile = local_library + "ftpList";
41 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser"; 41 ListFile = QPEApplication::qpeDir() + "etc/gutenbrowser";
42 QDir dir(ListFile); 42 QDir dir(ListFile);
43 if( !dir.exists()) 43 if( !dir.exists())
44 dir.mkdir(ListFile,true); 44 dir.mkdir(ListFile,true);
45 ListFile+="/ftpList"; 45 ListFile+="/ftpList";
46 odebug << "opening "+ListFile << oendl; 46 odebug << "opening "+ListFile << oendl;
47 if ( QFile(ListFile).exists() ) { 47 if ( QFile(ListFile).exists() ) {
48 openSiteList(); 48 openSiteList();
49 } else { 49 } else {
50 switch( QMessageBox::warning( this, "Gutenbrowser", 50 switch( QMessageBox::warning( this, "Gutenbrowser",
51 "Do you want to download \nan ftp site list?", 51 "Do you want to download \nan ftp site list?",
52 QMessageBox::Yes, QMessageBox::No)) { 52 QMessageBox::Yes, QMessageBox::No)) {
53 case QMessageBox::Yes: // yes 53 case QMessageBox::Yes: // yes
54 getSite(); 54 getSite();
55 break; 55 break;
56 case QMessageBox::No: // No 56 case QMessageBox::No: // No
57 // exit 57 // exit
58 break; 58 break;
59 } 59 }
60 60
61 } 61 }
62} 62}
63 63
64 64
65/* 65/*
66// get ftp list from web- parse it. */ 66// get ftp list from web- parse it. */
67void optionsDialog::getSite() 67void optionsDialog::getSite()
68{ 68{
69 QString file_name; 69 QString file_name;
70 QString ftp_listFileURL; 70 QString ftp_listFileURL;
71 QString outputFile; 71 QString outputFile;
72// outputFile = local_library+ "list.html"; 72// outputFile = local_library+ "list.html";
73 outputFile = ListFile + "list.html"; 73 outputFile = ListFile + "list.html";
74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; 74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html";
75//http://www.gutenberg.org/index.html"; 75//http://www.gutenberg.org/index.html";
76// QString networkUrl= "http://llornkcor.com/index.shtml"; 76// QString networkUrl= "http://llornkcor.com/index.shtml";
77// // "http://www.gutenberg.org/index.html" 77// // "http://www.gutenberg.org/index.html"
78// 78//
79//Qhttp stops working at times.... :( 79//Qhttp stops working at times.... :(
80// NetworkDialog *NetworkDlg; 80// NetworkDialog *NetworkDlg;
81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); 81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
82// if( NetworkDlg->exec() != 0 ) 82// if( NetworkDlg->exec() != 0 )
83// { // use new, improved, *INSTANT* network-dialog-file-getterer 83// { // use new, improved, *INSTANT* network-dialog-file-getterer
84// odebug << "gitcha!" << oendl; 84// odebug << "gitcha!" << oendl;
85// } 85// }
86// delete NetworkDlg; 86// delete NetworkDlg;
87//#ifdef Q_WS_QWS 87//#ifdef Q_WS_QWS
88 88
89// TODO qprocess here 89// TODO qprocess here
90 90
91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; 91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
92 odebug << "Issuing the command "+cmd << oendl; 92 odebug << "Issuing the command "+cmd << oendl;
93 Output *outDlg; 93 Output *outDlg;
94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); 94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
95 outDlg->showMaximized(); 95 outDlg->showMaximized();
96 outDlg->show(); 96 outDlg->show();
97 qApp->processEvents(); 97 qApp->processEvents();
98 FILE *fp; 98 FILE *fp;
99 char line[130]; 99 char line[130];
100 outDlg->OutputEdit->append( tr("Running wget") ); 100 outDlg->OutputEdit->append( tr("Running wget") );
101 sleep(1); 101 sleep(1);
102 fp = popen( (const char *) cmd, "r"); 102 fp = popen( (const char *) cmd, "r");
103 while ( fgets( line, sizeof line, fp)) { 103 while ( fgets( line, sizeof line, fp)) {
104 outDlg->OutputEdit->append(line); 104 outDlg->OutputEdit->append(line);
105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
106 } 106 }
107 pclose(fp); 107 pclose(fp);
108 outDlg->close(); 108 outDlg->close();
109 if(outDlg) 109 if(outDlg)
110 delete outDlg; 110 delete outDlg;
111 111
112// outputFile=ListFile; 112// outputFile=ListFile;
113 ftp_QListBox_1->clear(); 113 ftp_QListBox_1->clear();
114 parseFtpList( outputFile); // got the html list, now parse it so we can use it 114 parseFtpList( outputFile); // got the html list, now parse it so we can use it
115} 115}
116 116
117bool optionsDialog::parseFtpList( QString outputFile) 117bool optionsDialog::parseFtpList( QString outputFile)
118{ 118{
119// parse ftplist html and extract just the machine names/directories 119// parse ftplist html and extract just the machine names/directories
120// TODO: add locations!! 120// TODO: add locations!!
121 odebug << "parse ftplist "+outputFile << oendl; 121 odebug << "parse ftplist "+outputFile << oendl;
122 QString ftpList, s_location; 122 QString ftpList, s_location;
123 QFile f( outputFile ); 123 QFile f( outputFile );
124 124
125 if( f.open( IO_ReadWrite )) { 125 if( f.open( IO_ReadWrite )) {
126 QTextStream t( &f); 126 QTextStream t( &f);
127 QString countryName; 127 QString countryName;
128 bool b_gotchTest=false; 128 bool b_gotchTest=false;
129 129
130 while ( !t.eof() ) { 130 while ( !t.eof() ) {
131 QString s = t.readLine(); 131 QString s = t.readLine();
132 int start; 132 int start;
133 int end; 133 int end;
134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file 134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file
135 b_gotchTest = true; 135 b_gotchTest = true;
136 } 136 }
137 if( b_gotchTest) { 137 if( b_gotchTest) {