summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp644
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.h7
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp25
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp38
4 files changed, 352 insertions, 362 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 549c1d2..3b540c5 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -22,3 +22,3 @@
22#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23#include <opie2/odebug.h> 23//#include <opie2///odebug.h>
24 24
@@ -36,3 +36,3 @@
36 * The dialog will by default be modeless, unless you set 'modal' to 36 * The dialog will by default be modeless, unless you set 'modal' to
37 * TRUE to construct a modal dialog. */ 37 * true to construct a modal dialog. */
38LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) 38LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl )
@@ -52,9 +52,5 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
52 QString iniFile ; 52 QString iniFile ;
53 iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc"; 53 iniFile = local_library + "/gutenbrowserrc";
54 54 new_index = local_library + "/PGWHOLE.TXT";
55 new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT"; 55 old_index = local_index;
56
57 old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
59
60 // iniFile = local_library+"gutenbrowserrc"; 56 // iniFile = local_library+"gutenbrowserrc";
@@ -70,4 +66,4 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; 67 //odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,true)+1) );
73 // ftp_host=ftp_host.stripWhiteSpace(); 69 // ftp_host=ftp_host.stripWhiteSpace();
@@ -78,4 +74,4 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
78 config.setGroup("SortAuth"); 74 config.setGroup("SortAuth");
79 if( config.readEntry("authSort", "FALSE") == "TRUE") 75 if( config.readEntry("authSort", "false") == "true")
80 authBox->setChecked(TRUE); 76 authBox->setChecked(true);
81 77
@@ -83,3 +79,3 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
83 downDir =config.readEntry( "DownloadDirectory",local_library); 79 downDir =config.readEntry( "DownloadDirectory",local_library);
84 odebug << "downDir is "+downDir << oendl; 80 //odebug << "downDir is "+downDir << oendl;
85 newindexLib.setName( old_index); 81 newindexLib.setName( old_index);
@@ -94,9 +90,10 @@ LibraryDialog::~LibraryDialog()
94{ 90{
95// delete QList_Item2; 91}
96// delete QList_Item1;
97// delete QList_Item3;
98// delete QList_Item4;
99// delete QList_Item5;
100 92
101 // saveConfig(); 93void LibraryDialog::clearItems() {
94 ListView1->clear();
95 ListView2->clear();
96 ListView3->clear();
97 ListView4->clear();
98 ListView5->clear();
102} 99}
@@ -106,4 +103,5 @@ void LibraryDialog::Newlibrary()
106{ 103{
104 clearItems();
107#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 105#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
108 //odebug << "Opening new library index " << newindexLib << "" << oendl; 106 ////odebug << "Opening new library index " << newindexLib << "" << oendl;
109 if ( newindexLib.open( IO_ReadOnly) ) { 107 if ( newindexLib.open( IO_ReadOnly) ) {
@@ -116,57 +114,10 @@ void LibraryDialog::Newlibrary()
116 year = indexLine.mid(4,4); 114 year = indexLine.mid(4,4);
117 year = year.stripWhiteSpace(); 115 file = indexLine.mid( indexLine.find( "[", 0, true )+1, 12 );
118 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); 116 number = indexLine.mid( indexLine.find( "]", 0, true ) +1, indexLine.find( " ", 0, true )+1 );
119 file = file.stripWhiteSpace();
120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
121 if( year.toInt() < 1984) 117 if( year.toInt() < 1984)
122 number = number.left( number.length() -1 ); 118 number = number.left( number.length() -1 );
123 number = number.stripWhiteSpace(); 119 title = indexLine.mid( indexLine.find(" ", 26, true), indexLine.length() );
124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
125 title = title.stripWhiteSpace();
126
127 getAuthor(); // groks author
128 author = author.stripWhiteSpace();
129 if (authBox->isChecked()) { // this reverses the first name and last name of the author
130 // odebug << "Sorting last name first" << oendl;
131 QString lastName, firstName="";
132 int finder=author.findRev( ' ', -1, TRUE);
133 lastName=author.right( author.length()-finder);
134 firstName=author.left(finder);
135 lastName=lastName.stripWhiteSpace();
136 firstName=firstName.stripWhiteSpace();
137
138 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
139 author=lastName+", "+firstName;
140 }
141
142 if( !number.isEmpty()
143 && (title.find( "reserved",0, FALSE) == -1)
144 && (file.find( "]",0, TRUE) == -1)
145 && (title.find( "Audio",0, FALSE) == -1)) {
146
147 // fill string list or something to be able to resort the whole library
148 if( author.isEmpty() )
149 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
150 else {
151
152 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
153 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
154 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
155
156 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
157 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
158 QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file );
159
160 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
161 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
162 QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file );
163 120
164 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 121 addItems();
165 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
166 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
167 122
168 else
169 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
170 }
171 }
172 }// end if 123 }// end if
@@ -182,12 +133,6 @@ void LibraryDialog::Newlibrary()
182 133
183void LibraryDialog::Library() 134void LibraryDialog::Library() {
184{// old library groking method 135 clearItems();
185
186 ListView1->clear();
187 ListView2->clear();
188 ListView3->clear();
189 ListView4->clear();
190 ListView5->clear();
191 136
192 odebug << "opening GUTINDEX.ALL file" << oendl; 137 // qDebug( "opening GUTINDEX.ALL file");
193 IDontKnowWhy = ""; 138 IDontKnowWhy = "";
@@ -197,3 +142,3 @@ void LibraryDialog::Library()
197 qApp->processEvents(); 142 qApp->processEvents();
198 // int jig; 143
199 while ( !indexStream.eof() ) { 144 while ( !indexStream.eof() ) {
@@ -202,6 +147,6 @@ void LibraryDialog::Library()
202 if ( indexLine != "") { 147 if ( indexLine != "") {
203 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { 148
204 // month = indexLine.left( 3); 149 if( (indexLine.mid(4,4)).toInt() ) {
150
205 year = indexLine.mid(4,4); 151 year = indexLine.mid(4,4);
206 // title = indexLine.mid( 9, 50);
207 file = indexLine.mid(60,12); 152 file = indexLine.mid(60,12);
@@ -212,6 +157,4 @@ void LibraryDialog::Library()
212 157
213
214 if(file.find("?", 0, false) != -1 ) { 158 if(file.find("?", 0, false) != -1 ) {
215 QString tmpfile = file.replace(QRegExp("[?]"), "8"); 159 QString tmpfile = file.replace(QRegExp("[?]"), "8");
216 // qDebug( "file is now " + tmpfile );
217 file = tmpfile; 160 file = tmpfile;
@@ -219,48 +162,24 @@ void LibraryDialog::Library()
219 162
220// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
221 number = indexLine.mid(55,5); 163 number = indexLine.mid(55,5);
222 number = number.stripWhiteSpace();
223 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
224 title = indexLine.mid( 9, 50 ); 164 title = indexLine.mid( 9, 50 );
225 title = title.stripWhiteSpace();
226 //odebug << "title is "+title << oendl;
227 getAuthor(); // grok author
228 author = author.stripWhiteSpace();
229 //odebug << "author is "+author << oendl;
230 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
231 QString lastName, firstName="";
232 int finder=author.findRev( ' ', -1, TRUE);
233 lastName=author.right( author.length()-finder);
234 firstName=author.left(finder);
235 lastName=lastName.stripWhiteSpace();
236 firstName=firstName.stripWhiteSpace();
237
238 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
239 author=lastName+", "+firstName;
240 }
241 165
242 if( !number.isEmpty() 166 addItems();
243 && (title.find( "reserved",0, FALSE) == -1)
244 &&(title.find( "Audio",0, FALSE) == -1)) {
245 // fill string list or something to be able to sort by Author
246 if( author.isEmpty() )
247 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file );
248 else {
249 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
250 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
251 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file );
252 167
253 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 168 }
254 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) 169 else if ( indexLine.mid(73,5).toInt() && indexLine.mid(73,5).toInt() > 10000 ) {
255 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); 170// newer files with numbers > 100000 have new dir structure and need to be parsed differently..
171 number = indexLine.mid(73,5);
172 int num = number.toInt();
173 if(num < 10626)
174 year = "2003";
175 else if(num >= 10626 && num < 14600)
176 year = "2004";
177 else if(num >= 14600)
178 year = "2005";
256 179
257 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || 180 file = number;// + ".txt";
258 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) 181 title = indexLine.mid(0,72);
259 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
260 182
261 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || 183 addItems();
262 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) 184 //qDebug("file number is " + number + " title is " + title );
263 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
264 }
265 }
266 } 185 }
@@ -271,6 +190,6 @@ void LibraryDialog::Library()
271 QString sMsg; 190 QString sMsg;
272 sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; 191
192 sMsg = ( tr("<p>Error opening library index file. Please download a new one.</P> "));
273 QMessageBox::message( "Error",sMsg); 193 QMessageBox::message( "Error",sMsg);
274 } 194 }
275
276} //end Library() 195} //end Library()
@@ -282,7 +201,7 @@ bool LibraryDialog::getAuthor()
282{ 201{
283 if( title.contains( ", by", TRUE)) { 202 if( title.contains( ", by", true)) {
284 int auth; 203 int auth;
285 auth = title.find(", by", 0, TRUE); 204 auth = title.find(", by", 0, true);
286 author = title.right(title.length() - (auth + 4) ); 205 author = title.right(title.length() - (auth + 4) );
287 if( int finder = author.find("[", 0, TRUE)) { 206 if( int finder = author.find("[", 0, true)) {
288 author = author.left(finder); 207 author = author.left(finder);
@@ -290,7 +209,7 @@ bool LibraryDialog::getAuthor()
290 } 209 }
291 else if ( title.contains( "by, ", TRUE) ) { 210 else if ( title.contains( "by, ", true) ) {
292 int auth; 211 int auth;
293 auth = title.find("by, ", 0, TRUE); 212 auth = title.find("by, ", 0, true);
294 author = title.right(title.length() - (auth + 4) ); 213 author = title.right(title.length() - (auth + 4) );
295 if( int finder = author.find("[", 0, TRUE)) { 214 if( int finder = author.find("[", 0, true)) {
296 author = author.left( finder); 215 author = author.left( finder);
@@ -298,7 +217,7 @@ bool LibraryDialog::getAuthor()
298 } 217 }
299 else if ( title.contains( " by", TRUE) ) { 218 else if ( title.contains( " by", true) ) {
300 int auth; 219 int auth;
301 auth = title.find(" by", 0, TRUE); 220 auth = title.find(" by", 0, true);
302 author = title.right(title.length() - (auth + 3) ); 221 author = title.right(title.length() - (auth + 3) );
303 if( int finder = author.find("[", 0, TRUE)) { 222 if( int finder = author.find("[", 0, true)) {
304 author = author.left( finder); 223 author = author.left( finder);
@@ -306,7 +225,7 @@ bool LibraryDialog::getAuthor()
306 } 225 }
307 else if ( title.contains( "by ", TRUE) ) { 226 else if ( title.contains( "by ", true) ) {
308 int auth; 227 int auth;
309 auth = title.find("by ", 0, TRUE); 228 auth = title.find("by ", 0, true);
310 author = title.right(title.length() - (auth + 3) ); 229 author = title.right(title.length() - (auth + 3) );
311 if( int finder = author.find("[", 0, TRUE)) { 230 if( int finder = author.find("[", 0, true)) {
312 author = author.left( finder); 231 author = author.left( finder);
@@ -314,12 +233,12 @@ bool LibraryDialog::getAuthor()
314 } 233 }
315 else if ( title.contains( ",", TRUE) ) { 234 else if ( title.contains( ",", true) ) {
316 int auth; 235 int auth;
317 auth = title.find(",", 0, TRUE); 236 auth = title.find(",", 0, true);
318 author = title.right( title.length() - (auth + 1) ); 237 author = title.right( title.length() - (auth + 1) );
319 if ( author.contains( ",", TRUE) ) { 238 if ( author.contains( ",", true) ) {
320 int auth; 239 int auth;
321 auth = author.find(",", 0, TRUE); 240 auth = author.find(",", 0, true);
322 author = author.right( author.length() - (auth + 1) ); 241 author = author.right( author.length() - (auth + 1) );
323 } 242 }
324 if( int finder = author.find("[", 0, TRUE)) { 243 if( int finder = author.find("[", 0, true)) {
325 author = author.left( finder); 244 author = author.left( finder);
@@ -327,7 +246,7 @@ bool LibraryDialog::getAuthor()
327 } 246 }
328 else if ( title.contains( "/", TRUE) ) { 247 else if ( title.contains( "/", true) ) {
329 int auth; 248 int auth;
330 auth = title.find("/", 0, TRUE); 249 auth = title.find("/", 0, true);
331 author = title.right(title.length() - (auth + 1) ); 250 author = title.right(title.length() - (auth + 1) );
332 if( int finder = author.find("[", 0, TRUE)) { 251 if( int finder = author.find("[", 0, true)) {
333 author = author.left( finder); 252 author = author.left( finder);
@@ -335,7 +254,7 @@ bool LibraryDialog::getAuthor()
335 } 254 }
336 else if ( title.contains( "of", TRUE) ) { 255 else if ( title.contains( "of", true) ) {
337 int auth; 256 int auth;
338 auth = title.find("of", 0, TRUE); 257 auth = title.find("of", 0, true);
339 author = title.right(title.length() - (auth + 2) ); 258 author = title.right(title.length() - (auth + 2) );
340 if( int finder = author.find("[", 0, TRUE)) 259 if( int finder = author.find("[", 0, true))
341 { 260 {
@@ -348,3 +267,3 @@ bool LibraryDialog::getAuthor()
348 int auth; 267 int auth;
349 auth = author.find("et. al", 0, TRUE); 268 auth = author.find("et. al", 0, true);
350 author = author.left( auth ); 269 author = author.left( auth );
@@ -353,3 +272,3 @@ bool LibraryDialog::getAuthor()
353 int auth; 272 int auth;
354 auth = author.find("#", 0, TRUE); 273 auth = author.find("#", 0, true);
355 author = author.left( auth); 274 author = author.left( auth);
@@ -358,3 +277,3 @@ bool LibraryDialog::getAuthor()
358 int auth; 277 int auth;
359 auth = author.find("(", 0, TRUE); 278 auth = author.find("(", 0, true);
360 author = author.left( auth); 279 author = author.left( auth);
@@ -363,6 +282,6 @@ bool LibraryDialog::getAuthor()
363 int auth; 282 int auth;
364 auth = author.find("et al", 0, TRUE); 283 auth = author.find("et al", 0, true);
365 author = author.left( auth ); 284 author = author.left( auth );
366 } 285 }
367 QRegExp r = QRegExp("[0-9]", TRUE, FALSE); 286 QRegExp r = QRegExp("[0-9]", true, false);
368 if ( author.left(2).find( r) != -1 ) { 287 if ( author.left(2).find( r) != -1 ) {
@@ -370,9 +289,15 @@ bool LibraryDialog::getAuthor()
370 } 289 }
371 // if( author.contains(" ", TRUE)) {
372 // int suth = author.findRev(" ", -1, TRUE);
373 // author = author.right( author.length() - suth);
374 // }
375 290
376 // title 291 author = author.stripWhiteSpace();
377 // author 292 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
293 QString lastName, firstName="";
294 int finder = author.findRev( ' ', -1, TRUE);
295 lastName = author.right( author.length()-finder);
296 firstName = author.left(finder);
297 lastName = lastName.stripWhiteSpace();
298 firstName = firstName.stripWhiteSpace();
299
300 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
301 author = lastName+", "+firstName;
302 }
378 return true; 303 return true;
@@ -380,2 +305,33 @@ bool LibraryDialog::getAuthor()
380 305
306void LibraryDialog::addItems() {
307 cleanStrings();
308 getAuthor(); // grok author
309 if( !number.isEmpty()
310 && (title.find( "reserved",0, FALSE) == -1)
311 && (file.find( "]",0, true) == -1)
312 &&(title.find( "Audio",0, FALSE) == -1)) {
313 // qDebug("new item "+title);
314 // fill string list or something to be able to sort by Author
315 if( author.isEmpty() )
316 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file );
317 else {
318 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
319 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
320 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file );
321
322 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
323 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
324 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file );
325
326 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
327 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
328 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
329
330 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
331 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
332 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
333 }
334 }
335}
336
381 /* 337 /*
@@ -390,2 +346,3 @@ void LibraryDialog::select_title( QListViewItem * item)
390 DlglistItemFile = item->text(3); 346 DlglistItemFile = item->text(3);
347
391 switch (index) { 348 switch (index) {
@@ -415,16 +372,18 @@ void LibraryDialog::select_title( QListViewItem * item)
415 if(DlglistItemTitle.length()>2) { 372 if(DlglistItemTitle.length()>2) {
416 // DlglistItemNumber = item->text(0);
417 item = 0; 373 item = 0;
418 odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; 374 // todo check for connection here
419 odebug << "Title is "+DlglistItemTitle << oendl;
420 375
421 // check for connection here 376 bool ok = false;
422 // if( get_extext()) 377 qDebug(DlglistItemFile);
423
424 if(download_Etext()) {
425 // odebug << "get here 2" << oendl;
426 if(i_binary == 1) {
427 378
379 if(DlglistItemFile.toInt() > 10000 ) {
380 // new directory sturcture
381 if( download_newEtext())
382 ok = true;
383 } else {
384 if(download_Etext())
385 ok = true;
428 } 386 }
429 if(checkBox->isChecked () ) { 387 if(ok) {
388 if(checkBox->isChecked () )
430 accept(); 389 accept();
@@ -433,7 +392,17 @@ void LibraryDialog::select_title( QListViewItem * item)
433 } 392 }
434}
435 393
436bool LibraryDialog::download_Etext() 394bool LibraryDialog::download_newEtext()
437{ // ftp method 395{ // ftp method
438 // might have to use old gpl'd ftp for embedded!! 396 QString fileName = DlglistItemFile;
397
398 QString directory;
399 int stringlength = DlglistItemFile.length();
400 for(i = 0; i < stringlength - 1; i++ ) {
401 directory += "/"+ DlglistItemFile[i];
402 }
403
404 directory += "/" + DlglistItemFile;
405
406// qWarning(directory);
407
439 Config cfg("Gutenbrowser"); 408 Config cfg("Gutenbrowser");
@@ -443,20 +412,2 @@ bool LibraryDialog::download_Etext()
443 412
444 odebug << "about to network dialog" << oendl;
445 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
446
447 //////////////////// FIXME- if 'x' is part of real name....
448 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE));
449
450 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
451 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
452 odebug << "NewlistItemFile is now "+NewlistItemFile << oendl;
453 }
454 NewlistItemYear = DlglistItemYear.right(2);
455 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
456 odebug << NewlistItemYear << oendl;
457 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
458 NewlistItemYear = "90";
459 }
460 Edir ="etext" +NewlistItemYear;
461 dir= ftp_base_dir + "/etext" +NewlistItemYear+"/";
462 if( ftp_base_dir.find("=",0,true) ) 413 if( ftp_base_dir.find("=",0,true) )
@@ -464,32 +415,30 @@ bool LibraryDialog::download_Etext()
464 415
465 networkUrl= "ftp://"+ftp_host+dir; 416 QString dir = ftp_base_dir + directory;
417 QString outputFile = local_library + ".guten_temp";
418 QString file = fileName + ".txt";
466 419
467 outputFile=local_library+".guten_temp";
468 //odebug << "Download file:" << NewlistItemFile << "" << oendl;
469 odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl;
470 QStringList networkList; 420 QStringList networkList;
471 networkList.append((const char *)ftp_host); 421 networkList.append((const char *)ftp_host); //host
472 networkList.append((const char *)dir); 422 networkList.append((const char *)dir); //ftp base directory
473 networkList.append((const char *)outputFile); 423 networkList.append((const char *)outputFile); //output filepath
474 networkList.append((const char *)NewlistItemFile); 424 networkList.append((const char *)file); //filename
475//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
476 425
477 NetworkDialog *NetworkDlg; 426 getEtext( networkList);
478 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); 427
428 return true;
429}
479 430
431bool LibraryDialog::getEtext(const QStringList &networkList)
432{
433 NetworkDialog *NetworkDlg;
434 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList);
480 435
481 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer 436// use new, improved, *INSTANT* network-dialog-file-getterer
437 if( NetworkDlg->exec() != 0 ) {
482 File_Name= NetworkDlg->localFileName; 438 File_Name= NetworkDlg->localFileName;
483 odebug << "back to Library from Network Dialog" << oendl;
484 odebug << "Just downloaded "+NetworkDlg->localFileName << oendl;
485 439
486 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found 440 qDebug("Just downloaded " + NetworkDlg->localFileName);
487 // QString oldName=File_Name;
488 // File_Name.replace(0,local_library.length(),downDir);
489 // odebug << "File_Name now is "+File_Name << oendl;
490 441
491 // }
492 // rename .txt to .etx
493 if(NetworkDlg->successDownload) { 442 if(NetworkDlg->successDownload) {
494 odebug << "Filename is "+File_Name << oendl; 443 //odebug << "Filename is "+File_Name << oendl;
495 if(File_Name.right(4)==".txt") { 444 if(File_Name.right(4)==".txt") {
@@ -501,3 +450,3 @@ bool LibraryDialog::download_Etext()
501 450
502 odebug << "Filename is now "+File_Name << oendl; 451 //odebug << "Filename is now "+File_Name << oendl;
503 452
@@ -510,10 +459,10 @@ bool LibraryDialog::download_Etext()
510 459
511 odebug << "Setting doclink" << oendl; 460 //odebug << "Setting doclink" << oendl;
512 DocLnk lnk; 461 DocLnk lnk;
513 odebug << "name is "+name_file << oendl; 462 //odebug << "name is "+name_file << oendl;
514 lnk.setName(name_file); //sets file name 463 lnk.setName(name_file); //sets file name
515 odebug << "Title is "+DlglistItemTitle << oendl; 464 //odebug << "Title is "+DlglistItemTitle << oendl;
516 lnk.setComment(DlglistItemTitle); 465 lnk.setComment(DlglistItemTitle);
517 466
518 odebug << "Filename is "+File_Name << oendl; 467 //odebug << "Filename is "+File_Name << oendl;
519 lnk.setFile(File_Name); //sets File property 468 lnk.setFile(File_Name); //sets File property
@@ -523,3 +472,3 @@ bool LibraryDialog::download_Etext()
523 if(!lnk.writeLink()) { 472 if(!lnk.writeLink()) {
524 odebug << "Writing doclink did not work" << oendl; 473 //odebug << "Writing doclink did not work" << oendl;
525 } else { 474 } else {
@@ -530,2 +479,57 @@ bool LibraryDialog::download_Etext()
530 } 479 }
480
481 return true;
482}
483
484bool LibraryDialog::download_Etext()
485{ // ftp method
486 // might have to use old gpl'd ftp for embedded!!
487
488 Config cfg("Gutenbrowser");
489 cfg.setGroup("FTPsite");
490 ftp_host = cfg.readEntry("SiteName", "sailor.gutenberg.org");
491 ftp_base_dir = cfg.readEntry("base", "/pub/gutenberg");
492
493 qDebug( "about to network dialog");
494
495 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, /*networkUrl, */outputFile;
496
497 //////////////////// FIXME- if 'x' is part of real name....
498 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).find("x", 1, false));
499
500 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,true) ==-1 ) {
501 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
502 qDebug("NewlistItemFile is now " + NewlistItemFile);
503 }
504
505 NewlistItemYear = DlglistItemYear.right(2);
506 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
507 //odebug << NewlistItemYear << oendl;
508 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
509 NewlistItemYear = "90";
510 }
511
512 Edir ="etext" +NewlistItemYear;
513
514 dir = ftp_base_dir + "/etext" + NewlistItemYear + "/";
515
516 if( ftp_base_dir.find("=",0,true) )
517 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
518
519// networkUrl = "ftp://"+ftp_host+dir;
520
521 outputFile = local_library+".guten_temp";
522
523 qDebug( "Download file: " +NewlistItemFile);
524 qDebug("Checking: " + ftp_host + " " + dir + " " + outputFile+" " + NewlistItemFile);
525
526
527 QStringList networkList;
528 networkList.append((const char *)ftp_host); //host
529 networkList.append((const char *)dir); //ftp base directory
530 networkList.append((const char *)outputFile); //output filepath
531 networkList.append((const char *)NewlistItemFile); //filename
532//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
533 getEtext( networkList);
534
531 return true; 535 return true;
@@ -558,4 +562,4 @@ bool LibraryDialog::httpDownload()
558 QString s = t.readLine(); 562 QString s = t.readLine();
559 if (s.contains( NewlistItemFile, FALSE) && (s.contains(".txt")) ) { 563 if (s.contains( NewlistItemFile, false) && (s.contains(".txt")) ) {
560 str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6, (s.find( ".txt</A>", 0, TRUE) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, TRUE)+6 ) ); 564 str = s.mid( s.find( ".txt\">"+NewlistItemFile, 0, true)+6, (s.find( ".txt</A>", 0, true) + 4) - ( s.find( ".txt\">"+NewlistItemFile, 0, true)+6 ) );
561 httpName += "/" + str; 565 httpName += "/" + str;
@@ -590,10 +594,10 @@ bool LibraryDialog::setTitle()
590 Config config("Gutenbrowser"); 594 Config config("Gutenbrowser");
591 odebug << "setting title" << oendl; 595 //odebug << "setting title" << oendl;
592 odebug << DlglistItemTitle << oendl; 596 //odebug << DlglistItemTitle << oendl;
593 597
594 if( DlglistItemTitle.find("[",0,TRUE) != -1) 598 if( DlglistItemTitle.find("[",0,true) != -1)
595 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" ); 599 DlglistItemTitle.replace(DlglistItemTitle.find("[",0,true),1, "(" );
596 if( DlglistItemTitle.find("]",0,TRUE) !=-1) 600 if( DlglistItemTitle.find("]",0,true) !=-1)
597 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); 601 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,true),1, ")" );
598 odebug << "Title being set is "+DlglistItemTitle << oendl; 602 //odebug << "Title being set is "+DlglistItemTitle << oendl;
599 int test = 0; 603 int test = 0;
@@ -610,2 +614,5 @@ bool LibraryDialog::setTitle()
610 } 614 }
615
616 if(test == 0 ) {
617
611 config.setGroup("Files"); 618 config.setGroup("Files");
@@ -617,3 +624,3 @@ bool LibraryDialog::setTitle()
617 config.writeEntry( File_Name, DlglistItemTitle); 624 config.writeEntry( File_Name, DlglistItemTitle);
618 625 }
619 test = 0; 626 test = 0;
@@ -626,6 +633,6 @@ void LibraryDialog::saveConfig()
626 Config config("Gutenbrowser"); 633 Config config("Gutenbrowser");
627 if( httpBox->isChecked() == TRUE) { 634 if( httpBox->isChecked() == true) {
628 checked = 1; 635 checked = 1;
629 config.setGroup( "Proxy" ); 636 config.setGroup( "Proxy" );
630 config.writeEntry("IsChecked", "TRUE"); 637 config.writeEntry("IsChecked", "true");
631 } else { 638 } else {
@@ -633,10 +640,10 @@ void LibraryDialog::saveConfig()
633 config.setGroup( "Proxy" ); 640 config.setGroup( "Proxy" );
634 config.writeEntry("IsChecked", "FALSE"); 641 config.writeEntry("IsChecked", "false");
635 } 642 }
636 if (authBox->isChecked() == TRUE) { 643 if (authBox->isChecked() == true) {
637 config.setGroup("SortAuth"); 644 config.setGroup("SortAuth");
638 config.writeEntry("authSort", "TRUE"); 645 config.writeEntry("authSort", "true");
639 } else { 646 } else {
640 config.setGroup("SortAuth"); 647 config.setGroup("SortAuth");
641 config.writeEntry("authSort", "FALSE"); 648 config.writeEntry("authSort", "false");
642 } 649 }
@@ -659,6 +666,8 @@ void LibraryDialog::onButtonSearch()
659 // if( resultsList) 666 // if( resultsList)
660 searchDlg = new SearchDialog( this, "Library Search", TRUE); 667 searchDlg = new SearchDialog( this, "Library Search", true);
661 searchDlg->setCaption( tr( "Library Search" ) ); 668 searchDlg->setCaption( tr( "Library Search" ) );
662 searchDlg->setLabel( "- author or title"); 669 searchDlg->setLabel( "- author or title");
670
663 QString resultString; 671 QString resultString;
672
664 int i_berger = 0; 673 int i_berger = 0;
@@ -758,5 +767,7 @@ void LibraryDialog::onButtonSearch()
758 texter = SearchResultsDialog->selText; 767 texter = SearchResultsDialog->selText;
759 // odebug << texter << oendl; 768 // //odebug << texter << oendl;
760 resultLs= SearchResultsDialog->resultsList; 769 resultLs= SearchResultsDialog->resultsList;
761 i_berger = 1; 770 i_berger = 1;
771 } else {
772 resultLs.clear();
762 } 773 }
@@ -769,3 +780,3 @@ void LibraryDialog::onButtonSearch()
769 texter.sprintf("%s \n",(*it).latin1()); 780 texter.sprintf("%s \n",(*it).latin1());
770 // odebug << texter << oendl; 781 // //odebug << texter << oendl;
771 if( tester!=texter) 782 if( tester!=texter)
@@ -788,4 +799,4 @@ void LibraryDialog::parseSearchResults( QString resultStr)
788{ 799{
789
790 int stringLeng=resultStr.length(); 800 int stringLeng=resultStr.length();
801
791 QString my; 802 QString my;
@@ -794,58 +805,27 @@ void LibraryDialog::parseSearchResults( QString resultStr)
794 if( resultStr.length() > 2 && resultStr.length() < 130) { 805 if( resultStr.length() > 2 && resultStr.length() < 130) {
795 int titleInt = resultStr.find( " : ", 0, TRUE); 806
807 int titleInt = resultStr.find( " : ", 0, true);
796 DlglistItemTitle = resultStr.left( titleInt); 808 DlglistItemTitle = resultStr.left( titleInt);
797 int yearInt = resultStr.find( " : ", titleInt+3, TRUE); 809
810 int yearInt = resultStr.find( " : ", titleInt+3, true);
811
798 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); 812 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
813
799 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); 814 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
800 download_Etext(); 815 DlglistItemFile = DlglistItemFile.left( DlglistItemFile.length() - 2);
816
817 cleanStrings();
818
819 if(DlglistItemFile.left(1) == "/")
820 DlglistItemFile = DlglistItemFile.right( DlglistItemFile.length() - 1);
821
822
823 if(DlglistItemFile.toInt() > 10000 ) {
824 // new directory sturcture
825 download_newEtext(); //)
826 } else {
827 download_Etext(); //)
828 }
829 }
801 } 830 }
802 /*
803 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/
804}
805
806 // bool LibraryDialog::UnzipIt( QString zipFile) {
807 // //////////TODO findsome other way of dealingwithzip files.
808 // ///usr/bin/unzip";
809 // if( QFile::exists( zipFile)) {
810 // // QString thatFile = local_library +"PGWHOLE.TXT";
811 // QString cmd;
812 // #if defined(_WS_X11_)
813 // cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
814 // #endif
815 // #if defined(_WS_WIN_)
816 // QString temp= QDir::convertSeparators(local_library);
817 // zipFile=QDir::convertSeparators( zipFile);
818 // cmd = temp+"unzip.exe -o " +zipFile/*newestLibraryFile */+" -d " + temp;
819 // #endif
820 // #ifndef Q_WS_QWS
821 // // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
822 // cmd = "unzip " + zipFile;
823 // #endif
824
825 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
826 // if (exit==QMessageBox::Yes) {
827 // odebug << "Issuing the command "+cmd << oendl;
828 // #if defined(_WS_WIN_)
829 // WinExec( cmd, SW_HIDE );
830 // #endif
831 // #if defined(_WS_X11_)
832 // system( cmd);
833 // #endif
834 // #ifndef Q_WS_QWS
835 // system( cmd);
836 // #endif
837 // // printf("unzip\n");
838 // // remove( zipFile /*newestLibraryFile*/);
839 // return true;
840 // }
841 // else if(exit==QMessageBox::No) {
842 // // printf("unzip\n");
843 // return false;
844 // }
845 // } else {
846 // // QMessageBox::message( "Note",( tr("Please install unzip in your PATH")) );
847 // return false;
848 // }
849 // return true;
850 // }
851 831
@@ -860,3 +840,3 @@ bool LibraryDialog::getItem(QListViewItem *it)
860{ 840{
861 // odebug << "selected getItem" << oendl; 841 // //odebug << "selected getItem" << oendl;
862 842
@@ -878,3 +858,3 @@ bool LibraryDialog::onButtonDownload()
878{ 858{
879 // odebug << "selected onButtonDownloadz" << oendl; 859 // //odebug << "selected onButtonDownloadz" << oendl;
880 860
@@ -890,3 +870,3 @@ bool LibraryDialog::onButtonDownload()
890 getItem(it1.current()); 870 getItem(it1.current());
891 it1.current()->setSelected(FALSE); 871 it1.current()->setSelected(false);
892 } 872 }
@@ -895,3 +875,3 @@ bool LibraryDialog::onButtonDownload()
895 getItem(it2.current()); 875 getItem(it2.current());
896 it2.current()->setSelected(FALSE); 876 it2.current()->setSelected(false);
897 } 877 }
@@ -900,3 +880,3 @@ bool LibraryDialog::onButtonDownload()
900 getItem(it3.current()); 880 getItem(it3.current());
901 it3.current()->setSelected(FALSE); 881 it3.current()->setSelected(false);
902 } 882 }
@@ -905,3 +885,3 @@ bool LibraryDialog::onButtonDownload()
905 getItem(it4.current()); 885 getItem(it4.current());
906 it4.current()->setSelected(FALSE); 886 it4.current()->setSelected(false);
907 } 887 }
@@ -910,3 +890,3 @@ bool LibraryDialog::onButtonDownload()
910 getItem(it5.current()); 890 getItem(it5.current());
911 it5.current()->setSelected(FALSE); 891 it5.current()->setSelected(false);
912 } 892 }
@@ -920,8 +900,8 @@ void LibraryDialog::comboSelect(int index)
920{ 900{
921 // odebug << "we are sorting" << oendl; 901 // //odebug << "we are sorting" << oendl;
922 ListView1->setSorting( index, TRUE); 902 ListView1->setSorting( index, true);
923 ListView2->setSorting( index, TRUE); 903 ListView2->setSorting( index, true);
924 ListView3->setSorting( index, TRUE); 904 ListView3->setSorting( index, true);
925 ListView4->setSorting( index, TRUE); 905 ListView4->setSorting( index, true);
926 ListView5->setSorting( index, TRUE); 906 ListView5->setSorting( index, true);
927 907
@@ -946,8 +926,6 @@ void LibraryDialog::newList()
946 Output *outDlg; 926 Output *outDlg;
947 buttonNewList->setDown(TRUE); 927 buttonNewList->setDown(true);
948 QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser"); 928 //odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
949 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); 929 QString gutenindex1 = local_library + "/GUTINDEX.ALL";
950 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { 930
951 odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
952 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
953 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; 931 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
@@ -959,3 +937,3 @@ void LibraryDialog::newList()
959 if(result == 0) { 937 if(result == 0) {
960 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 938 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),true);
961 outDlg->showMaximized(); 939 outDlg->showMaximized();
@@ -966,3 +944,3 @@ void LibraryDialog::newList()
966 outDlg->OutputEdit->append( tr("Running wget") ); 944 outDlg->OutputEdit->append( tr("Running wget") );
967 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 945 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
968 sleep(1); 946 sleep(1);
@@ -971,3 +949,3 @@ void LibraryDialog::newList()
971 } else { 949 } else {
972 odebug << "Issuing the command\n"+cmd << oendl; 950 //odebug << "Issuing the command\n"+cmd << oendl;
973 // system(cmd); 951 // system(cmd);
@@ -975,3 +953,3 @@ void LibraryDialog::newList()
975 outDlg->OutputEdit->append(line); 953 outDlg->OutputEdit->append(line);
976 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 954 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
977 } 955 }
@@ -979,3 +957,3 @@ void LibraryDialog::newList()
979 outDlg->OutputEdit->append("Finished downloading\n"); 957 outDlg->OutputEdit->append("Finished downloading\n");
980 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 958 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
981 qApp->processEvents(); 959 qApp->processEvents();
@@ -985,3 +963,3 @@ void LibraryDialog::newList()
985 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) 963 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
986 // odebug << "renaming error" << oendl; 964 // //odebug << "renaming error" << oendl;
987 // } 965 // }
@@ -993,6 +971,4 @@ void LibraryDialog::newList()
993 } 971 }
994 buttonNewList->setDown(FALSE); 972 buttonNewList->setDown(false);
995 } else { 973
996 QMessageBox::message("Note","Could not change directories");
997 }
998 // if(outDlg) 974 // if(outDlg)
@@ -1044,3 +1020,3 @@ bool LibraryDialog::moreInfo()
1044 if(titleString.length()>2) { 1020 if(titleString.length()>2) {
1045 odebug << "Title is "+titleString << oendl; 1021 //odebug << "Title is "+titleString << oendl;
1046 titleString.replace( QRegExp("\\s"), "%20"); 1022 titleString.replace( QRegExp("\\s"), "%20");
@@ -1062,3 +1038,3 @@ void LibraryDialog::FindLibrary()
1062{ 1038{
1063 buttonLibrary->setDown(TRUE); 1039 buttonLibrary->setDown(true);
1064 1040
@@ -1068,3 +1044,3 @@ void LibraryDialog::FindLibrary()
1068 indexLib.setName( new_index); 1044 indexLib.setName( new_index);
1069 odebug << "index file is "+ new_index << oendl; 1045 //odebug << "index file is "+ new_index << oendl;
1070 Newlibrary(); 1046 Newlibrary();
@@ -1073,3 +1049,3 @@ void LibraryDialog::FindLibrary()
1073 indexLib.setName( old_index); 1049 indexLib.setName( old_index);
1074 odebug << "new index nameis "+ old_index << oendl; 1050 //odebug << "new index nameis "+ old_index << oendl;
1075 Library(); 1051 Library();
@@ -1077,6 +1053,6 @@ void LibraryDialog::FindLibrary()
1077 indexLoaded=true; 1053 indexLoaded=true;
1078 buttonSearch->setEnabled(TRUE); 1054 buttonSearch->setEnabled(true);
1079 moreInfoButton->setEnabled(TRUE); 1055 moreInfoButton->setEnabled(true);
1080 1056
1081 buttonLibrary->setDown(FALSE); 1057 buttonLibrary->setDown(false);
1082 buttonNewList->setText("Download"); 1058 buttonNewList->setText("Download");
@@ -1085 +1061,9 @@ void LibraryDialog::FindLibrary()
1085} 1061}
1062
1063void LibraryDialog::cleanStrings() {
1064 year = year.stripWhiteSpace();
1065 file = file.stripWhiteSpace();
1066 title = title.stripWhiteSpace();
1067 number = number.stripWhiteSpace();
1068
1069}
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.h b/noncore/apps/opie-gutenbrowser/LibraryDialog.h
index f5bfe08..8d6352f 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.h
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.h
@@ -108,2 +108,4 @@ public slots:
108 bool download_Etext(); 108 bool download_Etext();
109 bool download_newEtext();
110
109 void onButtonSearch(); 111 void onButtonSearch();
@@ -122,2 +124,7 @@ protected:
122// void search_slot(); 124// void search_slot();
125private:
126 void addItems();
127 void clearItems();
128 void cleanStrings();
129 bool getEtext(const QStringList &);
123 130
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
index a321952..ba583ad 100644
--- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -169,3 +169,5 @@ bool NetworkDialog::downloadFile( QString networkUrl )
169// } 169// }
170 odebug << "Requesting directory list." << oendl; 170 QString File_Name;
171
172 if( s_partialFileName.right(4) != ".txt") {
171 TextLabel3->setText("Getting directory list."); 173 TextLabel3->setText("Getting directory list.");
@@ -180,7 +182,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
180 QFile tmp("./.guten_temp"); 182 QFile tmp("./.guten_temp");
181 QString s, File_Name;
182
183 if (tmp.open(IO_ReadOnly)) { 183 if (tmp.open(IO_ReadOnly)) {
184 QTextStream t( &tmp ); // use a text stream 184 QTextStream t( &tmp ); // use a text stream
185 odebug << "Finding partial filename "+s_partialFileName << oendl; 185 //odebug << "Finding partial filename "+s_partialFileName << oendl;
186 QString s;
187
186 while ( !t.eof()) { 188 while ( !t.eof()) {
@@ -193,11 +195,5 @@ bool NetworkDialog::downloadFile( QString networkUrl )
193 File_Name = str; 195 File_Name = str;
194 odebug << "Found file_name "+ File_Name << oendl; 196 //odebug << "Found file_name "+ File_Name << oendl;
195 break; 197 break;
196 } 198 }
197// if (str.contains(".zip")) {
198// File_Name = str;
199// odebug << "Found file_name "+ File_Name << oendl;
200// break;
201// }
202
203 } 199 }
@@ -207,4 +203,7 @@ bool NetworkDialog::downloadFile( QString networkUrl )
207 } 203 }
208 else 204 } else {
209 odebug << "Error opening temp file." << oendl; 205 File_Name = s_partialFileName;
206 qDebug("new dir " + File_Name);
207 }
208
210 209
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index c7cdd83..413ab51 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -143,5 +143,5 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
143 143
144 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 QString gutenIndex = local_library + "/GUTINDEX.ALL";
145 QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL";
146 qDebug("gutenindex "+gutenIndex ); 145 qDebug("gutenindex "+gutenIndex );
146
147 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
@@ -149,3 +149,3 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
149 } else { 149 } else {
150 QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = local_library + "/PGWHOLE.TXT";
151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
@@ -199,24 +199,24 @@ void Gutenbrowser::InfoBarClick() {
199void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 199void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
200 // int eexit=0;
201 QString cmd; 200 QString cmd;
202 // config.read();
203 qApp->processEvents(); 201 qApp->processEvents();
204 QString filename = QPEApplication::qpeDir();
205 if(filename.right(1)!="/")
206 filename+="/etc/gutenbrowser/";
207 else
208 filename+="etc/gutenbrowser/";
209 odebug << "filename "+filename << oendl;
210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
211 202
212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 203 QString filename = local_library + "/GUTINDEX.ALL";
204// QString filename = old_index;
213 205
214 Config config("Gutenbrowser"); 206 // filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
215 config.setGroup( "Browser" ); 207
216 QString brow = config.readEntry("Preferred", "Opera"); 208 Config cfg("Gutenbrowser");
217 odebug << "Preferred browser is "+brow << oendl; 209 cfg.setGroup("FTPsite");
210 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
211 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
212
213 // Config config("Gutenbrowser");
214 // config.setGroup( "Browser" );
215 // QString brow = config.readEntry("Preferred", "Opera");
216 // //odebug << "Preferred browser is "+brow << oendl;
218 if(!showMsg) { //if we just get the gutenindex.all 217 if(!showMsg) { //if we just get the gutenindex.all
218// QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
219 cmd="wget -O " + filename +" " + url+" 2>&1" ; 219 cmd="wget -O " + filename +" " + url+" 2>&1" ;
220 chdir(local_library); 220 chdir(local_library);
221 odebug << "Issuing the system command: " << cmd << "" << oendl; 221 // //odebug << "Issuing the system command: " << cmd << "" << oendl;
222 222
@@ -276,3 +276,3 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
276 chdir(local_library); 276 chdir(local_library);
277 odebug << "Issuing the sys command: " << cmd << "" << oendl; 277 // //odebug << "Issuing the sys command: " << cmd << "" << oendl;
278 system(cmd); 278 system(cmd);