summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
index ad770b5..a9c7346 100644
--- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -10,22 +10,27 @@
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#include "optionsDialog.h" 15#include "optionsDialog.h"
15#include "gutenbrowser.h" 16#include "gutenbrowser.h"
16//#include "NetworkDialog.h" 17//#include "NetworkDialog.h"
17#include "output.h" 18#include "output.h"
18 19
20/* OPIE */
21#include <opie2/odebug.h>
22#include <qpe/config.h>
23
24/* QT */
19#include <qprogressbar.h> 25#include <qprogressbar.h>
20#include <stdlib.h>
21#include <qurloperator.h> 26#include <qurloperator.h>
22#include <qpe/config.h>
23#include <qlistbox.h> 27#include <qlistbox.h>
24 28
29/* STD */
30#include <stdlib.h>
25#include <unistd.h> 31#include <unistd.h>
26#include <stdio.h> 32#include <stdio.h>
27#include <stdlib.h>
28 33
29// :)~ 34// :)~
30void optionsDialog::ftpSiteDlg( ) 35void optionsDialog::ftpSiteDlg( )
31{ 36{
@@ -37,9 +42,9 @@ void optionsDialog::ftpSiteDlg( )
37 QDir dir(ListFile); 42 QDir dir(ListFile);
38 if( !dir.exists()) 43 if( !dir.exists())
39 dir.mkdir(ListFile,true); 44 dir.mkdir(ListFile,true);
40 ListFile+="/ftpList"; 45 ListFile+="/ftpList";
41 qDebug("opening "+ListFile); 46 odebug << "opening "+ListFile << oendl;
42 if ( QFile(ListFile).exists() ) { 47 if ( QFile(ListFile).exists() ) {
43 openSiteList(); 48 openSiteList();
44 } else { 49 } else {
45 switch( QMessageBox::warning( this, "Gutenbrowser", 50 switch( QMessageBox::warning( this, "Gutenbrowser",
@@ -75,17 +80,17 @@ void optionsDialog::getSite()
75// NetworkDialog *NetworkDlg; 80// NetworkDialog *NetworkDlg;
76// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); 81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
77// if( NetworkDlg->exec() != 0 ) 82// if( NetworkDlg->exec() != 0 )
78// { // use new, improved, *INSTANT* network-dialog-file-getterer 83// { // use new, improved, *INSTANT* network-dialog-file-getterer
79// qDebug("gitcha!"); 84// odebug << "gitcha!" << oendl;
80// } 85// }
81// delete NetworkDlg; 86// delete NetworkDlg;
82//#ifdef Q_WS_QWS 87//#ifdef Q_WS_QWS
83 88
84// TODO qprocess here 89// TODO qprocess here
85 90
86 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; 91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
87 qDebug("Issuing the command "+cmd); 92 odebug << "Issuing the command "+cmd << oendl;
88 Output *outDlg; 93 Output *outDlg;
89 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); 94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
90 outDlg->showMaximized(); 95 outDlg->showMaximized();
91 outDlg->show(); 96 outDlg->show();
@@ -98,13 +103,13 @@ void optionsDialog::getSite()
98 while ( fgets( line, sizeof line, fp)) { 103 while ( fgets( line, sizeof line, fp)) {
99 outDlg->OutputEdit->append(line); 104 outDlg->OutputEdit->append(line);
100 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
101 } 106 }
102 pclose(fp); 107 pclose(fp);
103 outDlg->close(); 108 outDlg->close();
104 if(outDlg) 109 if(outDlg)
105 delete outDlg; 110 delete outDlg;
106 111
107// outputFile=ListFile; 112// outputFile=ListFile;
108 ftp_QListBox_1->clear(); 113 ftp_QListBox_1->clear();
109 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
110} 115}
@@ -112,9 +117,9 @@ void optionsDialog::getSite()
112bool optionsDialog::parseFtpList( QString outputFile) 117bool optionsDialog::parseFtpList( QString outputFile)
113{ 118{
114// parse ftplist html and extract just the machine names/directories 119// parse ftplist html and extract just the machine names/directories
115// TODO: add locations!! 120// TODO: add locations!!
116 qDebug("parse ftplist "+outputFile); 121 odebug << "parse ftplist "+outputFile << oendl;
117 QString ftpList, s_location; 122 QString ftpList, s_location;
118 QFile f( outputFile ); 123 QFile f( outputFile );
119 124
120 if( f.open( IO_ReadWrite )) { 125 if( f.open( IO_ReadWrite )) {
@@ -151,13 +156,13 @@ bool optionsDialog::parseFtpList( QString outputFile)
151 156
152 s = t.readLine(); 157 s = t.readLine();
153 s = t.readLine(); 158 s = t.readLine();
154 if(( start=s.find("<BR>(", 0, TRUE) ) != -1) { 159 if(( start=s.find("<BR>(", 0, TRUE) ) != -1) {
155// qDebug("%s",s.latin1()); 160// odebug << "" << s << "" << oendl;
156 end = s.find( ")", 0, TRUE)+1; 161 end = s.find( ")", 0, TRUE)+1;
157 s_location= s.mid( start+4, (end - start) ); 162 s_location= s.mid( start+4, (end - start) );
158 163
159// qDebug("%s", s_location.latin1()); 164// odebug << "" << s_location << "" << oendl;
160// ftpList += ftpSite + "\n"; 165// ftpList += ftpSite + "\n";
161// ftp_QListBox_1->sort( TRUE ); 166// ftp_QListBox_1->sort( TRUE );
162 ftpList += s_location+ " "+ftpSite+"\n"; 167 ftpList += s_location+ " "+ftpSite+"\n";
163 168
@@ -172,9 +177,9 @@ bool optionsDialog::parseFtpList( QString outputFile)
172 } // end find ftp:// 177 } // end find ftp://
173 178
174 } // end while loop 179 } // end while loop
175 QFile f2( ListFile); 180 QFile f2( ListFile);
176 if(!f2.open( IO_ReadWrite | IO_Truncate)) 181 if(!f2.open( IO_ReadWrite | IO_Truncate))
177 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n"+ListFile )) ); 182 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully.\n"+ListFile )) );
178 f2.writeBlock( ftpList, ftpList.length() ); 183 f2.writeBlock( ftpList, ftpList.length() );
179 f.close(); 184 f.close();
180 f2.close(); 185 f2.close();
@@ -189,9 +194,9 @@ bool optionsDialog::parseFtpList( QString outputFile)
189} 194}
190 195
191void optionsDialog::openSiteList() { 196void optionsDialog::openSiteList() {
192 197
193 qDebug(" just opens the ftp site list"); 198 odebug << " just opens the ftp site list" << oendl;
194// ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList"; 199// ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList";
195 QFile f( ListFile); 200 QFile f( ListFile);
196 if(!f.open( IO_ReadWrite )) { 201 if(!f.open( IO_ReadWrite )) {
197 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully." )) ); 202 QMessageBox::message( (tr("Note")), (tr("File not opened sucessfully." )) );
@@ -229,9 +234,9 @@ void optionsDialog::select_site( const char *index )
229 s_site = index; 234 s_site = index;
230 QString s_site2; 235 QString s_site2;
231// if(s_site.find("(",0,TRUE)) 236// if(s_site.find("(",0,TRUE))
232 s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) ); 237 s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) );
233qDebug("Selected ftp site is "+ s_site2); 238odebug << "Selected ftp site is "+ s_site2 << oendl;
234 int i_ftp = s_site2.find("/", 0, FALSE); 239 int i_ftp = s_site2.find("/", 0, FALSE);
235 ftp_host = s_site2.left(i_ftp ); 240 ftp_host = s_site2.left(i_ftp );
236 ftp_base_dir = s_site2.right( s_site2.length() - i_ftp); 241 ftp_base_dir = s_site2.right( s_site2.length() - i_ftp);
237 242