-rw-r--r-- | noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp index de9c72b..44ade8d 100644 --- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp +++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp | |||
@@ -17,8 +17,6 @@ | |||
17 | //#include "NetworkDialog.h" | 17 | //#include "NetworkDialog.h" |
18 | #include "output.h" | 18 | #include "output.h" |
19 | 19 | ||
20 | /* OPIE */ | ||
21 | #include <opie2/odebug.h> | ||
22 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
23 | 21 | ||
24 | /* QT */ | 22 | /* QT */ |
@@ -43,7 +41,7 @@ void optionsDialog::ftpSiteDlg( ) | |||
43 | if( !dir.exists()) | 41 | if( !dir.exists()) |
44 | dir.mkdir(ListFile,true); | 42 | dir.mkdir(ListFile,true); |
45 | ListFile+="/ftpList"; | 43 | ListFile+="/ftpList"; |
46 | odebug << "opening "+ListFile << oendl; | 44 | qDebug( "opening "+ListFile ); |
47 | if ( QFile(ListFile).exists() ) { | 45 | if ( QFile(ListFile).exists() ) { |
48 | openSiteList(); | 46 | openSiteList(); |
49 | } else { | 47 | } else { |
@@ -71,7 +69,8 @@ void optionsDialog::getSite() | |||
71 | QString outputFile; | 69 | QString outputFile; |
72 | // outputFile = local_library+ "list.html"; | 70 | // outputFile = local_library+ "list.html"; |
73 | outputFile = ListFile + "list.html"; | 71 | outputFile = ListFile + "list.html"; |
74 | QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; | 72 | QString networkUrl="http://www.gutenberg.net/catalog/world/selectpermanentmirror?fk_books=12962"; |
73 | // QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; | ||
75 | //http://www.gutenberg.org/index.html"; | 74 | //http://www.gutenberg.org/index.html"; |
76 | // QString networkUrl= "http://llornkcor.com/index.shtml"; | 75 | // QString networkUrl= "http://llornkcor.com/index.shtml"; |
77 | // // "http://www.gutenberg.org/index.html" | 76 | // // "http://www.gutenberg.org/index.html" |
@@ -81,15 +80,15 @@ void optionsDialog::getSite() | |||
81 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); | 80 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); |
82 | // if( NetworkDlg->exec() != 0 ) | 81 | // if( NetworkDlg->exec() != 0 ) |
83 | // { // use new, improved, *INSTANT* network-dialog-file-getterer | 82 | // { // use new, improved, *INSTANT* network-dialog-file-getterer |
84 | // odebug << "gitcha!" << oendl; | 83 | // qDebug( "gitcha!" ); |
85 | // } | 84 | // } |
86 | // delete NetworkDlg; | 85 | // delete NetworkDlg; |
87 | //#ifdef Q_WS_QWS | 86 | //#ifdef Q_WS_QWS |
88 | 87 | ||
89 | // TODO qprocess here | 88 | // TODO qprocess here |
90 | 89 | ||
91 | QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; | 90 | QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl;// + " 2>&1" ; |
92 | odebug << "Issuing the command "+cmd << oendl; | 91 | qDebug( "Issuing the command "+cmd ); |
93 | Output *outDlg; | 92 | Output *outDlg; |
94 | outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); | 93 | outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); |
95 | outDlg->showMaximized(); | 94 | outDlg->showMaximized(); |
@@ -118,7 +117,7 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
118 | { | 117 | { |
119 | // parse ftplist html and extract just the machine names/directories | 118 | // parse ftplist html and extract just the machine names/directories |
120 | // TODO: add locations!! | 119 | // TODO: add locations!! |
121 | odebug << "parse ftplist "+outputFile << oendl; | 120 | qDebug( "parse ftplist "+outputFile ); |
122 | QString ftpList, s_location; | 121 | QString ftpList, s_location; |
123 | QFile f( outputFile ); | 122 | QFile f( outputFile ); |
124 | 123 | ||
@@ -131,47 +130,44 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
131 | QString s = t.readLine(); | 130 | QString s = t.readLine(); |
132 | int start; | 131 | int start; |
133 | int end; | 132 | int end; |
134 | if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file | 133 | if( s.find( "Select a Default Download Site - Project Gutenberg", 0, TRUE) !=-1) { //lower end of this file |
135 | b_gotchTest = true; | 134 | b_gotchTest = true; |
136 | } | 135 | } |
137 | if( b_gotchTest) { | 136 | if( b_gotchTest) { |
138 | if(( start = s.find( "ftp://", 0, TRUE))!=-1 ) { | 137 | if(( start = s.find( "ftp://", 0, TRUE))!=-1 ) { |
139 | end = s.find( "/\"", 0, TRUE);// ==-1)) { | 138 | // qDebug(s); |
139 | // qDebug("%d", start); | ||
140 | end = s.find( "</td></tr>", 0, TRUE);// ==-1)) { | ||
140 | if( end == -1) { | 141 | if( end == -1) { |
141 | end = s.find( "\">"); | 142 | end = s.find( "\">"); |
142 | } | 143 | } |
143 | ftpSite = s.mid( start, (end - start) ); | 144 | // qDebug("end %d", end); |
145 | start =start + 6; | ||
146 | ftpSite = s.mid( start , (end - start) ); | ||
144 | if(ftpSite.right(1) != "/") { | 147 | if(ftpSite.right(1) != "/") { |
145 | // ftpSite += "/"; | 148 | // ftpSite += "/"; |
146 | } | 149 | } |
147 | ftpSite=ftpSite.right( ftpSite.length()-6); | 150 | // qDebug("ftpsite " + ftpSite); |
148 | if( ftpSite.find("\n", 0, TRUE) ) | 151 | |
149 | ftpSite.remove( ftpSite.find("\n", 0, TRUE), 1); | 152 | for (int j = 0 ; j<3;j++) { |
150 | 153 | s = t.readLine(); | |
151 | if( ftpSite.find("\"", 0, TRUE) ) | 154 | QString finder="</td><td rowspan=\"3\">"; |
152 | ftpSite.remove( ftpSite.find("\"", 0, TRUE), 1); | 155 | if(( start = s.find( finder, 0, TRUE) ) != -1) { |
153 | if( ftpSite.find("a>", 0, TRUE) ) | 156 | // qDebug( "%d" + s, start ); |
154 | ftpSite.remove( ftpSite.find("a>", 0, TRUE) -2, 4); | 157 | end = s.find( finder, start + 2, TRUE) ; |
155 | 158 | // qDebug("end %d",end); | |
156 | 159 | s_location = s.mid( start + finder.length() , (end - start)-finder.length() ); | |
157 | s = t.readLine(); | 160 | // |
158 | s = t.readLine(); | 161 | // qDebug("Location "+s_location ); |
159 | if(( start=s.find("<BR>(", 0, TRUE) ) != -1) { | ||
160 | // odebug << "" << s << "" << oendl; | ||
161 | end = s.find( ")", 0, TRUE)+1; | ||
162 | s_location= s.mid( start+4, (end - start) ); | ||
163 | |||
164 | // odebug << "" << s_location << "" << oendl; | ||
165 | // ftpList += ftpSite + "\n"; | ||
166 | // ftp_QListBox_1->sort( TRUE ); | ||
167 | ftpList += s_location+ " "+ftpSite+"\n"; | ||
168 | |||
169 | ftp_QListBox_1->sort( TRUE ); | ||
170 | QString winbug=" "; | ||
171 | ftp_QListBox_1->insertItem ( s_location.latin1() +winbug+ftpSite); | ||
172 | // ftp_QListBox_1->insertItem ( ftpSite+" "+s_location.latin1()); | ||
173 | } | ||
174 | 162 | ||
163 | ftpList += s_location+ " "+ftpSite+"\n"; | ||
164 | ftp_QListBox_1->sort( TRUE ); | ||
165 | QString winbug=" "; | ||
166 | ftp_QListBox_1->insertItem ( s_location.latin1() + winbug + ftpSite); | ||
167 | j=3; | ||
168 | // ftp_QListBox_1->insertItem ( ftpSite+" "+s_location.latin1()); | ||
169 | } | ||
170 | } | ||
175 | // ftp_QListBox_1->insertItem ( ftpSite); | 171 | // ftp_QListBox_1->insertItem ( ftpSite); |
176 | } | 172 | } |
177 | } // end find ftp:// | 173 | } // end find ftp:// |
@@ -195,7 +191,7 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
195 | 191 | ||
196 | void optionsDialog::openSiteList() { | 192 | void optionsDialog::openSiteList() { |
197 | 193 | ||
198 | odebug << " just opens the ftp site list" << oendl; | 194 | qDebug( " just opens the ftp site list" ); |
199 | // ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList"; | 195 | // ListFile = ( QDir::homeDirPath ()) +"/.gutenbrowser/ftpList"; |
200 | QFile f( ListFile); | 196 | QFile f( ListFile); |
201 | if(!f.open( IO_ReadWrite )) { | 197 | if(!f.open( IO_ReadWrite )) { |
@@ -235,7 +231,9 @@ void optionsDialog::select_site( const char *index ) | |||
235 | QString s_site2; | 231 | QString s_site2; |
236 | // if(s_site.find("(",0,TRUE)) | 232 | // if(s_site.find("(",0,TRUE)) |
237 | s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) ); | 233 | s_site2=s_site.right( s_site.length()-(s_site.find(" ",0,TRUE)+4) ); |
238 | odebug << "Selected ftp site is "+ s_site2 << oendl; | 234 | |
235 | qDebug( "Selected ftp site is "+ s_site2 ); | ||
236 | |||
239 | int i_ftp = s_site2.find("/", 0, FALSE); | 237 | int i_ftp = s_site2.find("/", 0, FALSE); |
240 | ftp_host = s_site2.left(i_ftp ); | 238 | ftp_host = s_site2.left(i_ftp ); |
241 | ftp_base_dir = s_site2.right( s_site2.length() - i_ftp); | 239 | ftp_base_dir = s_site2.right( s_site2.length() - i_ftp); |
@@ -246,7 +244,7 @@ odebug << "Selected ftp site is "+ s_site2 << oendl; | |||
246 | config.writeEntry("SiteName",ftp_host); | 244 | config.writeEntry("SiteName",ftp_host); |
247 | config.writeEntry("base",ftp_base_dir); | 245 | config.writeEntry("base",ftp_base_dir); |
248 | // config->write(); | 246 | // config->write(); |
249 | TextLabel3->setText( "Current ftp server:\n"+ftp_host /*+ ftp_base_dir*/ ); | 247 | TextLabel3->setText( "Current ftp server:\n" + ftp_host /*+ ftp_base_dir*/ ); |
250 | // optionsDialog::accept(); | 248 | // optionsDialog::accept(); |
251 | } | 249 | } |
252 | 250 | ||