summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-03-01 07:56:26 (UTC)
committer llornkcor <llornkcor>2005-03-01 07:56:26 (UTC)
commit2f2b707684582cfa97c96c5fabab2197a7c7f307 (patch) (unidiff)
tree72df20aae2b443f649f73e7f983eefe53a54109d
parente12f0049687c84c24f0b7b737b65df2ed6a500a5 (diff)
downloadopie-2f2b707684582cfa97c96c5fabab2197a7c7f307.zip
opie-2f2b707684582cfa97c96c5fabab2197a7c7f307.tar.gz
opie-2f2b707684582cfa97c96c5fabab2197a7c7f307.tar.bz2
update to new gutenberg directory structures
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
@@ -20,7 +20,7 @@
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23#include <opie2/odebug.h> 23//#include <opie2///odebug.h>
24 24
25/* QT */ 25/* QT */
26#include <qpushbutton.h> 26#include <qpushbutton.h>
@@ -34,7 +34,7 @@
34 34
35/* 35/*
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 )
39 : QDialog( parent, name, true/* modal*/, fl ) 39 : QDialog( parent, name, true/* modal*/, fl )
40{ 40{
@@ -50,13 +50,9 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
50 local_index = local_library + index; 50 local_index = local_library + index;
51 51
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";
61 // new_index = local_library + "PGWHOLE.TXT"; 57 // new_index = local_library + "PGWHOLE.TXT";
62 // old_index = local_library + "GUTINDEX.ALL"; 58 // old_index = local_library + "GUTINDEX.ALL";
@@ -68,20 +64,20 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
68 64
69 config.setGroup( "FTPsite" ); 65 config.setGroup( "FTPsite" );
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();
74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
75 71
76 i_binary = 0; 72 i_binary = 0;
77 73
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
82 config.setGroup("General"); 78 config.setGroup("General");
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);
86 indexLib.setName( old_index); 82 indexLib.setName( old_index);
87 83
@@ -92,20 +88,22 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*
92 88
93LibraryDialog::~LibraryDialog() 89LibraryDialog::~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}
103 100
104 /*This groks using PGWHOLE.TXT */ 101 /*This groks using PGWHOLE.TXT */
105void LibraryDialog::Newlibrary() 102void 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) ) {
110 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 108 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
111 QTextStream indexStream( &newindexLib ); 109 QTextStream indexStream( &newindexLib );
@@ -114,61 +112,14 @@ void LibraryDialog::Newlibrary()
114 indexLine = indexStream.readLine(); 112 indexLine = indexStream.readLine();
115 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { 113 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
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
173 }// end while 124 }// end while
174 newindexLib.close(); 125 newindexLib.close();
@@ -180,99 +131,67 @@ void LibraryDialog::Newlibrary()
180} // end Newlibrary() 131} // end Newlibrary()
181 132
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 = "";
194 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully 139 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
195 QTextStream indexStream( &indexLib ); 140 QTextStream indexStream( &indexLib );
196 QString indexLine; 141 QString indexLine;
197 qApp->processEvents(); 142 qApp->processEvents();
198 // int jig; 143
199 while ( !indexStream.eof() ) { 144 while ( !indexStream.eof() ) {
200 145
201 indexLine = indexStream.readLine(); 146 indexLine = indexStream.readLine();
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);
208 if(file.left(1).find("[",0,TRUE) != -1) 153 if(file.left(1).find("[",0,TRUE) != -1)
209 file.remove(1,1); 154 file.remove(1,1);
210 if( file.find("]",0,TRUE) != -1) 155 if( file.find("]",0,TRUE) != -1)
211 file = file.left( file.find("]",0,TRUE)); 156 file = file.left( file.find("]",0,TRUE));
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;
218 } 161 }
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 }
267 } 186 }
268 } 187 }
269 indexLib.close(); 188 indexLib.close();
270 } else { 189 } else {
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()
277 196
278 197
@@ -280,64 +199,64 @@ void LibraryDialog::Library()
280 Groks the author out of the title */ 199 Groks the author out of the title */
281bool LibraryDialog::getAuthor() 200bool 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);
289 } 208 }
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);
297 } 216 }
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);
305 } 224 }
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);
313 } 232 }
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);
326 } 245 }
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);
334 } 253 }
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 {
342 author = author.left( finder); 261 author = author.left( finder);
343 } 262 }
@@ -346,38 +265,75 @@ bool LibraryDialog::getAuthor()
346 } 265 }
347 if ( author.contains("et. al")) { 266 if ( author.contains("et. al")) {
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 );
351 } 270 }
352 if ( author.contains("#")) { 271 if ( author.contains("#")) {
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);
356 } 275 }
357 if ( author.contains("(")) { 276 if ( author.contains("(")) {
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);
361 } 280 }
362 if ( author.contains("et al")) { 281 if ( author.contains("et al")) {
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 ) {
369 author = ""; 288 author = "";
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;
379}////// end getAuthor() 304}////// end 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 /*
382 selected one etext*/ 338 selected one etext*/
383void LibraryDialog::select_title( QListViewItem * item) 339void LibraryDialog::select_title( QListViewItem * item)
@@ -388,6 +344,7 @@ void LibraryDialog::select_title( QListViewItem * item)
388 DlglistItemTitle = item->text(0); 344 DlglistItemTitle = item->text(0);
389 DlglistItemYear = item->text(2); 345 DlglistItemYear = item->text(2);
390 DlglistItemFile = item->text(3); 346 DlglistItemFile = item->text(3);
347
391 switch (index) { 348 switch (index) {
392 case 0: { 349 case 0: {
393 ListView1->clearSelection(); 350 ListView1->clearSelection();
@@ -413,85 +370,77 @@ void LibraryDialog::select_title( QListViewItem * item)
413 } 370 }
414 371
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();
431 } 390 }
432 } 391 }
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");
440 cfg.setGroup("FTPsite"); 409 cfg.setGroup("FTPsite");
441 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org"); 410 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
442 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); 411 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
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) )
463 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); 414 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
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") {
496 QString s_fileName=File_Name; 445 QString s_fileName=File_Name;
497 s_fileName.replace( s_fileName.length()-3,3,"gtn"); 446 s_fileName.replace( s_fileName.length()-3,3,"gtn");
@@ -499,7 +448,7 @@ bool LibraryDialog::download_Etext()
499 rename(File_Name.latin1(),s_fileName.latin1()); 448 rename(File_Name.latin1(),s_fileName.latin1());
500 File_Name=s_fileName; 449 File_Name=s_fileName;
501 450
502 odebug << "Filename is now "+File_Name << oendl; 451 //odebug << "Filename is now "+File_Name << oendl;
503 452
504 } 453 }
505 if(File_Name.length() > 5 ) { 454 if(File_Name.length() > 5 ) {
@@ -508,26 +457,81 @@ bool LibraryDialog::download_Etext()
508 QString name_file=fi.fileName(); 457 QString name_file=fi.fileName();
509 name_file=name_file.left(name_file.length()-4); 458 name_file=name_file.left(name_file.length()-4);
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
520 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 469 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
521 lnk.setExec(File_Name); 470 lnk.setExec(File_Name);
522 lnk.setIcon("gutenbrowser/Gutenbrowser"); 471 lnk.setIcon("gutenbrowser/Gutenbrowser");
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 {
526 } 475 }
527 } else 476 } else
528 QMessageBox::message("Note","<p>There was an error with the file</p>"); 477 QMessageBox::message("Note","<p>There was an error with the file</p>");
529 } 478 }
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;
532} 536}
533 537
@@ -556,8 +560,8 @@ bool LibraryDialog::httpDownload()
556 QTextStream t( &tmp ); // use a text stream 560 QTextStream t( &tmp ); // use a text stream
557 while ( !t.eof()) { 561 while ( !t.eof()) {
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;
562 } 566 }
563 } //end of while loop 567 } //end of while loop
@@ -588,14 +592,14 @@ void LibraryDialog::cancelIt()
588bool LibraryDialog::setTitle() 592bool LibraryDialog::setTitle()
589{ 593{
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;
600 QString ramble, temp; 604 QString ramble, temp;
601 config.setGroup("Files"); 605 config.setGroup("Files");
@@ -608,6 +612,9 @@ bool LibraryDialog::setTitle()
608 test = 1; 612 test = 1;
609 } 613 }
610 } 614 }
615
616 if(test == 0 ) {
617
611 config.setGroup("Files"); 618 config.setGroup("Files");
612 config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); 619 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
613 QString interger; 620 QString interger;
@@ -615,7 +622,7 @@ bool LibraryDialog::setTitle()
615 config.writeEntry( interger, File_Name); 622 config.writeEntry( interger, File_Name);
616 config.setGroup( "Titles" ); 623 config.setGroup( "Titles" );
617 config.writeEntry( File_Name, DlglistItemTitle); 624 config.writeEntry( File_Name, DlglistItemTitle);
618 625 }
619 test = 0; 626 test = 0;
620 return true; 627 return true;
621} 628}
@@ -624,21 +631,21 @@ bool LibraryDialog::setTitle()
624void LibraryDialog::saveConfig() 631void LibraryDialog::saveConfig()
625{ 632{
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 {
632 checked = 0; 639 checked = 0;
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 }
643 // config.write(); 650 // config.write();
644} 651}
@@ -657,10 +664,12 @@ void LibraryDialog::onButtonSearch()
657 SearchDialog* searchDlg; 664 SearchDialog* searchDlg;
658 665
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;
665 if( searchDlg->exec() != 0 ) { 674 if( searchDlg->exec() != 0 ) {
666 QString searcherStr = searchDlg->get_text(); 675 QString searcherStr = searchDlg->get_text();
@@ -756,9 +765,11 @@ void LibraryDialog::onButtonSearch()
756 SearchResultsDialog->showMaximized(); 765 SearchResultsDialog->showMaximized();
757 if( SearchResultsDialog->exec() != 0) { 766 if( SearchResultsDialog->exec() != 0) {
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 }
763 Searchlist.clear(); 774 Searchlist.clear();
764 775
@@ -767,7 +778,7 @@ void LibraryDialog::onButtonSearch()
767 QString tester; 778 QString tester;
768 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 779 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
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)
772 parseSearchResults( texter); 783 parseSearchResults( texter);
773 tester = texter; 784 tester = texter;
@@ -786,68 +797,37 @@ void LibraryDialog::onButtonSearch()
786 splits the result string and calls download for the current search result*/ 797 splits the result string and calls download for the current search result*/
787void LibraryDialog::parseSearchResults( QString resultStr) 798void LibraryDialog::parseSearchResults( QString resultStr)
788{ 799{
789
790 int stringLeng=resultStr.length(); 800 int stringLeng=resultStr.length();
801
791 QString my; 802 QString my;
792 my.setNum( stringLeng, 10); 803 my.setNum( stringLeng, 10);
793 804
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
852void LibraryDialog::sort() 832void LibraryDialog::sort()
853{ 833{
@@ -858,7 +838,7 @@ void LibraryDialog::sort()
858 Downloads the current selected listitem*/ 838 Downloads the current selected listitem*/
859bool LibraryDialog::getItem(QListViewItem *it) 839bool LibraryDialog::getItem(QListViewItem *it)
860{ 840{
861 // odebug << "selected getItem" << oendl; 841 // //odebug << "selected getItem" << oendl;
862 842
863 // DlglistItemNumber = it->text(0); 843 // DlglistItemNumber = it->text(0);
864 DlglistItemTitle = it->text(0); 844 DlglistItemTitle = it->text(0);
@@ -876,7 +856,7 @@ bool LibraryDialog::getItem(QListViewItem *it)
876 download button is pushed so we get the current items to download*/ 856 download button is pushed so we get the current items to download*/
877bool LibraryDialog::onButtonDownload() 857bool LibraryDialog::onButtonDownload()
878{ 858{
879 // odebug << "selected onButtonDownloadz" << oendl; 859 // //odebug << "selected onButtonDownloadz" << oendl;
880 860
881 QListViewItemIterator it1( ListView1 ); 861 QListViewItemIterator it1( ListView1 );
882 QListViewItemIterator it2( ListView2 ); 862 QListViewItemIterator it2( ListView2 );
@@ -888,27 +868,27 @@ bool LibraryDialog::onButtonDownload()
888 for ( ; it1.current(); ++it1 ) { 868 for ( ; it1.current(); ++it1 ) {
889 if ( it1.current()->isSelected() ) 869 if ( it1.current()->isSelected() )
890 getItem(it1.current()); 870 getItem(it1.current());
891 it1.current()->setSelected(FALSE); 871 it1.current()->setSelected(false);
892 } 872 }
893 for ( ; it2.current(); ++it2 ) { 873 for ( ; it2.current(); ++it2 ) {
894 if ( it2.current()->isSelected() ) 874 if ( it2.current()->isSelected() )
895 getItem(it2.current()); 875 getItem(it2.current());
896 it2.current()->setSelected(FALSE); 876 it2.current()->setSelected(false);
897 } 877 }
898 for ( ; it3.current(); ++it3 ) { 878 for ( ; it3.current(); ++it3 ) {
899 if ( it3.current()->isSelected() ) 879 if ( it3.current()->isSelected() )
900 getItem(it3.current()); 880 getItem(it3.current());
901 it3.current()->setSelected(FALSE); 881 it3.current()->setSelected(false);
902 } 882 }
903 for ( ; it4.current(); ++it4 ) { 883 for ( ; it4.current(); ++it4 ) {
904 if ( it4.current()->isSelected() ) 884 if ( it4.current()->isSelected() )
905 getItem(it4.current()); 885 getItem(it4.current());
906 it4.current()->setSelected(FALSE); 886 it4.current()->setSelected(false);
907 } 887 }
908 for ( ; it5.current(); ++it5 ) { 888 for ( ; it5.current(); ++it5 ) {
909 if ( it5.current()->isSelected() ) 889 if ( it5.current()->isSelected() )
910 getItem(it5.current()); 890 getItem(it5.current());
911 it5.current()->setSelected(FALSE); 891 it5.current()->setSelected(false);
912 } 892 }
913 return true; 893 return true;
914} 894}
@@ -918,12 +898,12 @@ bool LibraryDialog::onButtonDownload()
918 handles the sorting combo box */ 898 handles the sorting combo box */
919void LibraryDialog::comboSelect(int index) 899void 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
928 ListView1->sort(); 908 ListView1->sort();
929 ListView2->sort(); 909 ListView2->sort();
@@ -944,12 +924,10 @@ void LibraryDialog::newList()
944 onButtonDownload(); 924 onButtonDownload();
945 } else { 925 } else {
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";
954 932
955 int result = QMessageBox::warning( this,"Download" 933 int result = QMessageBox::warning( this,"Download"
@@ -957,33 +935,33 @@ void LibraryDialog::newList()
957 ,"Yes","No",0,0,1); 935 ,"Yes","No",0,0,1);
958 qApp->processEvents(); 936 qApp->processEvents();
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();
962 outDlg->show(); 940 outDlg->show();
963 qApp->processEvents(); 941 qApp->processEvents();
964 FILE *fp; 942 FILE *fp;
965 char line[130]; 943 char line[130];
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);
969 fp = popen( (const char *) cmd, "r"); 947 fp = popen( (const char *) cmd, "r");
970 if ( !fp ) { 948 if ( !fp ) {
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);
974 while ( fgets( line, sizeof line, fp)) { 952 while ( fgets( line, sizeof line, fp)) {
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 }
978 pclose(fp); 956 pclose(fp);
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();
982 960
983 // if( QFile(gutenindex1).exists() ) { 961 // if( QFile(gutenindex1).exists() ) {
984 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 962 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
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 // }
988 966
989 } 967 }
@@ -991,10 +969,8 @@ void LibraryDialog::newList()
991 FindLibrary(); 969 FindLibrary();
992 if(outDlg) delete outDlg; 970 if(outDlg) delete outDlg;
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)
999 // delete outDlg; 975 // delete outDlg;
1000 } 976 }
@@ -1042,7 +1018,7 @@ bool LibraryDialog::moreInfo()
1042 } 1018 }
1043 item=0; 1019 item=0;
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");
1047 titleString.replace( QRegExp("'"), "%20"); 1023 titleString.replace( QRegExp("'"), "%20");
1048 titleString.replace( QRegExp("\""), "%20"); 1024 titleString.replace( QRegExp("\""), "%20");
@@ -1060,26 +1036,34 @@ bool LibraryDialog::moreInfo()
1060 This loads the library Index*/ 1036 This loads the library Index*/
1061void LibraryDialog::FindLibrary() 1037void LibraryDialog::FindLibrary()
1062{ 1038{
1063 buttonLibrary->setDown(TRUE); 1039 buttonLibrary->setDown(true);
1064 1040
1065 qApp->processEvents(); 1041 qApp->processEvents();
1066 if( QFile( new_index).exists() /* && this->isHidden() */) { 1042 if( QFile( new_index).exists() /* && this->isHidden() */) {
1067 newindexLib.setName( new_index); 1043 newindexLib.setName( new_index);
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();
1071 } else { 1047 } else {
1072 newindexLib.setName( old_index); 1048 newindexLib.setName( old_index);
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();
1076 } 1052 }
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");
1083 qApp->processEvents(); 1059 qApp->processEvents();
1084 1060
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
@@ -106,6 +106,8 @@ public slots:
106 bool setTitle(); 106 bool setTitle();
107 void saveConfig(); 107 void saveConfig();
108 bool download_Etext(); 108 bool download_Etext();
109 bool download_newEtext();
110
109 void onButtonSearch(); 111 void onButtonSearch();
110 bool onButtonDownload(); 112 bool onButtonDownload();
111 113
@@ -120,6 +122,11 @@ protected:
120 QHBoxLayout *hbox,*hbox1,*hbox2; 122 QHBoxLayout *hbox,*hbox1,*hbox2;
121 QVBoxLayout *vbox; 123 QVBoxLayout *vbox;
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
124}; 131};
125 132
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
@@ -167,7 +167,9 @@ bool NetworkDialog::downloadFile( QString networkUrl )
167// FtpQuit(conn); 167// FtpQuit(conn);
168// return false; 168// return false;
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.");
172 qApp->processEvents(); 174 qApp->processEvents();
173 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) { 175 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
@@ -178,11 +180,11 @@ bool NetworkDialog::downloadFile( QString networkUrl )
178 return false; 180 return false;
179 } 181 }
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()) {
187 s = t.readLine(); 189 s = t.readLine();
188 190
@@ -191,22 +193,19 @@ bool NetworkDialog::downloadFile( QString networkUrl )
191 193
192 if (str.contains(".txt")) { 194 if (str.contains(".txt")) {
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 }
204 } //end of while loop 200 } //end of while loop
205 tmp.close(); 201 tmp.close();
206// tmp.remove(); ///TODO this is for release version Zaurus 202// tmp.remove(); ///TODO this is for release version Zaurus
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
211 Config cfg("Gutenbrowser"); 210 Config cfg("Gutenbrowser");
212 cfg.setGroup("General"); 211 cfg.setGroup("General");
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
@@ -141,13 +141,13 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
141 } 141 }
142 } 142 }
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() ) {
148 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
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";
152 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
153 } 153 }
@@ -197,28 +197,28 @@ void Gutenbrowser::InfoBarClick() {
197 /* 197 /*
198 download http with wget or preferred browser */ 198 download http with wget or preferred browser */
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
223 Output *outDlg; 223 Output *outDlg;
224 224
@@ -274,7 +274,7 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
274 } 274 }
275 275
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);
279 } 279 }
280} 280}