-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 | |||
@@ -18,6 +18,4 @@ | |||
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 | ||
@@ -44,5 +42,5 @@ void optionsDialog::ftpSiteDlg( ) | |||
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(); |
@@ -72,5 +70,6 @@ void optionsDialog::getSite() | |||
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"; |
@@ -82,5 +81,5 @@ void optionsDialog::getSite() | |||
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; |
@@ -89,6 +88,6 @@ void optionsDialog::getSite() | |||
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); |
@@ -119,5 +118,5 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
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 ); |
@@ -132,45 +131,42 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
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 | } |
@@ -196,5 +192,5 @@ bool optionsDialog::parseFtpList( QString outputFile) | |||
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); |
@@ -236,5 +232,7 @@ void optionsDialog::select_site( const char *index ) | |||
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 ); |
@@ -247,5 +245,5 @@ odebug << "Selected ftp site is "+ s_site2 << oendl; | |||
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 | } |