summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp1854
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.h7
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp67
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp38
4 files changed, 978 insertions, 988 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
@@ -19,9 +19,9 @@
19/* OPIE */ 19/* OPIE */
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>
27#include <qmultilineedit.h> 27#include <qmultilineedit.h>
@@ -33,1053 +33,1037 @@
33#include <stdlib.h> 33#include <stdlib.h>
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{
41 if ( !name ) 41 if ( !name )
42 setName( "LibraryDialog" ); 42 setName( "LibraryDialog" );
43 indexLoaded=false; 43 indexLoaded=false;
44 initDialog(); 44 initDialog();
45 45
46 // this->setMaximumWidth(240); 46 // this->setMaximumWidth(240);
47 47
48 index = "GUTINDEX.ALL"; 48 index = "GUTINDEX.ALL";
49 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 49 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
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 new_index = local_library + "/PGWHOLE.TXT";
55 old_index = local_index;
56 // iniFile = local_library+"gutenbrowserrc";
57 // new_index = local_library + "PGWHOLE.TXT";
58 // old_index = local_library + "GUTINDEX.ALL";
54 59
55 new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT"; 60 Config config("Gutenbrowser");
56 61
57 old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 62 config.setGroup( "HttpServer" );
58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
59 64
60 // iniFile = local_library+"gutenbrowserrc"; 65 config.setGroup( "FTPsite" );
61 // new_index = local_library + "PGWHOLE.TXT"; 66 ftp_host = config.readEntry("SiteName", "sailor.gutenberg.org");
62 // old_index = local_library + "GUTINDEX.ALL"; 67 //odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,true)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace();
70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
63 71
64 Config config("Gutenbrowser"); 72 i_binary = 0;
65 73
66 config.setGroup( "HttpServer" ); 74 config.setGroup("SortAuth");
67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 75 if( config.readEntry("authSort", "false") == "true")
76 authBox->setChecked(true);
68 77
69 config.setGroup( "FTPsite" ); 78 config.setGroup("General");
70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 79 downDir = config.readEntry( "DownloadDirectory",local_library);
71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; 80 //odebug << "downDir is "+downDir << oendl;
72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 81 newindexLib.setName( old_index);
73 // ftp_host=ftp_host.stripWhiteSpace(); 82 indexLib.setName( old_index);
74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
75 83
76 i_binary = 0; 84 new QPEDialogListener(this);
77 85 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) );
78 config.setGroup("SortAuth");
79 if( config.readEntry("authSort", "FALSE") == "TRUE")
80 authBox->setChecked(TRUE);
81
82 config.setGroup("General");
83 downDir =config.readEntry( "DownloadDirectory",local_library);
84 odebug << "downDir is "+downDir << oendl;
85 newindexLib.setName( old_index);
86 indexLib.setName( old_index);
87
88 new QPEDialogListener(this);
89 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) );
90 86
91} 87}
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 );
112 QString indexLine; 110 QString indexLine;
113 while ( !indexStream.atEnd() ) { // until end of file.. 111 while ( !indexStream.atEnd() ) { // until end of file..
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(); 117 if( year.toInt() < 1984)
120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 118 number = number.left( number.length() -1 );
121 if( year.toInt() < 1984) 119 title = indexLine.mid( indexLine.find(" ", 26, true), indexLine.length() );
122 number = number.left( number.length() -1 ); 120
123 number = number.stripWhiteSpace(); 121 addItems();
124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 122
125 title = title.stripWhiteSpace(); 123 }// end if
126 124 }// end while
127 getAuthor(); // groks author 125 newindexLib.close();
128 author = author.stripWhiteSpace(); 126 }
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
164 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
165 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
166 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
167
168 else
169 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
170 }
171 }
172 }// end if
173 }// end while
174 newindexLib.close();
175 }
176#ifndef Q_WS_QWS 127#ifndef Q_WS_QWS
177 setCursor( arrowCursor); 128 setCursor( arrowCursor);
178#endif 129#endif
179#endif 130#endif
180} // end Newlibrary() 131} // end Newlibrary()
181 132
182 133
183void LibraryDialog::Library() 134void LibraryDialog::Library() {
184{// old library groking method 135 clearItems();
136
137 // qDebug( "opening GUTINDEX.ALL file");
138 IDontKnowWhy = "";
139 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
140 QTextStream indexStream( &indexLib );
141 QString indexLine;
142 qApp->processEvents();
185 143
186 ListView1->clear(); 144 while ( !indexStream.eof() ) {
187 ListView2->clear(); 145
188 ListView3->clear(); 146 indexLine = indexStream.readLine();
189 ListView4->clear(); 147 if ( indexLine != "") {
190 ListView5->clear(); 148
149 if( (indexLine.mid(4,4)).toInt() ) {
150
151 year = indexLine.mid(4,4);
152 file = indexLine.mid(60,12);
153 if(file.left(1).find("[",0,TRUE) != -1)
154 file.remove(1,1);
155 if( file.find("]",0,TRUE) != -1)
156 file = file.left( file.find("]",0,TRUE));
191 157
192 odebug << "opening GUTINDEX.ALL file" << oendl;
193 IDontKnowWhy = "";
194 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
195 QTextStream indexStream( &indexLib );
196 QString indexLine;
197 qApp->processEvents();
198 // int jig;
199 while ( !indexStream.eof() ) {
200
201 indexLine = indexStream.readLine();
202 if ( indexLine != "") {
203 if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) {
204 // month = indexLine.left( 3);
205 year = indexLine.mid(4,4);
206 // title = indexLine.mid( 9, 50);
207 file = indexLine.mid(60,12);
208 if(file.left(1).find("[",0,TRUE) != -1)
209 file.remove(1,1);
210 if( file.find("]",0,TRUE) != -1)
211 file = file.left( file.find("]",0,TRUE));
212
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 ); 160 file = tmpfile;
217 file = tmpfile;
218 } 161 }
219 162
220// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 163 number = indexLine.mid(55,5);
221 number = indexLine.mid(55,5); 164 title = indexLine.mid( 9, 50 );
222 number = number.stripWhiteSpace(); 165
223 // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 166 addItems();
224 title = indexLine.mid( 9, 50 ); 167
225 title = title.stripWhiteSpace(); 168 }
226 //odebug << "title is "+title << oendl; 169 else if ( indexLine.mid(73,5).toInt() && indexLine.mid(73,5).toInt() > 10000 ) {
227 getAuthor(); // grok author 170// newer files with numbers > 100000 have new dir structure and need to be parsed differently..
228 author = author.stripWhiteSpace(); 171 number = indexLine.mid(73,5);
229 //odebug << "author is "+author << oendl; 172 int num = number.toInt();
230 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author 173 if(num < 10626)
231 QString lastName, firstName=""; 174 year = "2003";
232 int finder=author.findRev( ' ', -1, TRUE); 175 else if(num >= 10626 && num < 14600)
233 lastName=author.right( author.length()-finder); 176 year = "2004";
234 firstName=author.left(finder); 177 else if(num >= 14600)
235 lastName=lastName.stripWhiteSpace(); 178 year = "2005";
236 firstName=firstName.stripWhiteSpace(); 179
237 180 file = number;// + ".txt";
238 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 181 title = indexLine.mid(0,72);
239 author=lastName+", "+firstName; 182
240 } 183 addItems();
241 184 //qDebug("file number is " + number + " title is " + title );
242 if( !number.isEmpty() 185 }
243 && (title.find( "reserved",0, FALSE) == -1) 186 }
244 &&(title.find( "Audio",0, FALSE) == -1)) { 187 }
245 // fill string list or something to be able to sort by Author 188 indexLib.close();
246 if( author.isEmpty() ) 189 } else {
247 QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); 190 QString sMsg;
248 else { 191
249 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 192 sMsg = ( tr("<p>Error opening library index file. Please download a new one.</P> "));
250 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 193 QMessageBox::message( "Error",sMsg);
251 QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); 194 }
252
253 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
254 (author.left(1) >= QString("g") && author.left(1) <= QString("m")) )
255 QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file );
256
257 else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) ||
258 (author.left(1) >= QString("n") && author.left(1) <= QString("r")) )
259 QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file );
260
261 else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) ||
262 (author.left(1) >= QString("s") && author.left(1) <= QString("z")) )
263 QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file );
264 }
265 }
266 }
267 }
268 }
269 indexLib.close();
270 } else {
271 QString sMsg;
272 sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index;
273 QMessageBox::message( "Error",sMsg);
274 }
275
276} //end Library() 195} //end Library()
277 196
278 197
279 /* 198/*
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 }
344 } else { 263 } else {
345 author = ""; 264 author = "";
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)) { 290
372 // int suth = author.findRev(" ", -1, TRUE); 291 author = author.stripWhiteSpace();
373 // author = author.right( author.length() - suth); 292 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
374 // } 293 QString lastName, firstName="";
375 294 int finder = author.findRev( ' ', -1, TRUE);
376 // title 295 lastName = author.right( author.length()-finder);
377 // author 296 firstName = author.left(finder);
378 return true; 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 }
303 return true;
379}////// end getAuthor() 304}////// end getAuthor()
380 305
381 /* 306void LibraryDialog::addItems() {
382 selected one etext*/ 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
337/*
338 selected one etext*/
383void LibraryDialog::select_title( QListViewItem * item) 339void LibraryDialog::select_title( QListViewItem * item)
384{ 340{
385 if(item != NULL) { 341 if(item != NULL) {
386 i++; 342 i++;
387 int index = tabWidget->currentPageIndex(); 343 int index = tabWidget->currentPageIndex();
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);
391 switch (index) { 347
392 case 0: { 348 switch (index) {
393 ListView1->clearSelection(); 349 case 0: {
394 } 350 ListView1->clearSelection();
395 break; 351 }
396 case 1: { 352 break;
397 ListView2->clearSelection(); 353 case 1: {
398 } 354 ListView2->clearSelection();
399 break; 355 }
400 case 2: { 356 break;
401 ListView3->clearSelection(); 357 case 2: {
402 } 358 ListView3->clearSelection();
403 break; 359 }
404 case 3: { 360 break;
405 ListView4->clearSelection(); 361 case 3: {
406 } 362 ListView4->clearSelection();
407 break; 363 }
408 case 4: { 364 break;
409 ListView5->clearSelection(); 365 case 4: {
410 } 366 ListView5->clearSelection();
411 break; 367 }
412 }; 368 break;
413 } 369 };
414 370 }
415 if(DlglistItemTitle.length()>2) { 371
416 // DlglistItemNumber = item->text(0); 372 if(DlglistItemTitle.length() > 2) {
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; 375
420 376 bool ok = false;
421 // check for connection here 377 qDebug(DlglistItemFile);
422 // if( get_extext()) 378
423 379 if(DlglistItemFile.toInt() > 10000 ) {
424 if(download_Etext()) { 380 // new directory sturcture
425 // odebug << "get here 2" << oendl; 381 if( download_newEtext())
426 if(i_binary == 1) { 382 ok = true;
427 383 } else {
428 } 384 if(download_Etext())
429 if(checkBox->isChecked () ) { 385 ok = true;
430 accept(); 386 }
431 } 387 if(ok) {
432 } 388 if(checkBox->isChecked () )
433 } 389 accept();
390 }
391 }
434} 392}
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;
439 Config cfg("Gutenbrowser"); 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
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; 425
426 getEtext( networkList);
427
428 return true;
429}
476 430
477 NetworkDialog *NetworkDlg; 431bool LibraryDialog::getEtext(const QStringList &networkList)
478 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList); 432{
479 433 NetworkDialog *NetworkDlg;
480 434 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList);
481 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer 435
482 File_Name= NetworkDlg->localFileName; 436// use new, improved, *INSTANT* network-dialog-file-getterer
483 odebug << "back to Library from Network Dialog" << oendl; 437 if( NetworkDlg->exec() != 0 ) {
484 odebug << "Just downloaded "+NetworkDlg->localFileName << oendl; 438 File_Name = NetworkDlg->localFileName;
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; 441
488 // File_Name.replace(0,local_library.length(),downDir); 442 if(NetworkDlg->successDownload) {
489 // odebug << "File_Name now is "+File_Name << oendl; 443 //odebug << "Filename is "+File_Name << oendl;
490 444 if(File_Name.right(4) == ".txt") {
491 // } 445 QString s_fileName = File_Name;
492 // rename .txt to .etx 446 s_fileName.replace( s_fileName.length() - 3, 3, "gtn");
493 if(NetworkDlg->successDownload) { 447 // s_fileName.replace( s_fileName.length()-3,3,"etx");
494 odebug << "Filename is "+File_Name << oendl; 448 rename( File_Name.latin1(), s_fileName.latin1());
495 if(File_Name.right(4)==".txt") { 449 File_Name = s_fileName;
496 QString s_fileName=File_Name; 450
497 s_fileName.replace( s_fileName.length()-3,3,"gtn"); 451 //odebug << "Filename is now "+File_Name << oendl;
498 // s_fileName.replace( s_fileName.length()-3,3,"etx"); 452
499 rename(File_Name.latin1(),s_fileName.latin1()); 453 }
500 File_Name=s_fileName; 454 if(File_Name.length() > 5 ) {
501 455 setTitle();
502 odebug << "Filename is now "+File_Name << oendl; 456 QFileInfo fi(File_Name);
503 457 QString name_file = fi.fileName();
504 } 458 name_file = name_file.left( name_file.length() - 4);
505 if(File_Name.length() > 5 ) { 459
506 setTitle(); 460 //odebug << "Setting doclink" << oendl;
507 QFileInfo fi(File_Name); 461 DocLnk lnk;
508 QString name_file=fi.fileName(); 462 //odebug << "name is "+name_file << oendl;
509 name_file=name_file.left(name_file.length()-4); 463 lnk.setName(name_file); //sets file name
510 464 //odebug << "Title is "+DlglistItemTitle << oendl;
511 odebug << "Setting doclink" << oendl; 465 lnk.setComment(DlglistItemTitle);
512 DocLnk lnk; 466
513 odebug << "name is "+name_file << oendl; 467 //odebug << "Filename is "+File_Name << oendl;
514 lnk.setName(name_file); //sets file name 468 lnk.setFile(File_Name); //sets File property
515 odebug << "Title is "+DlglistItemTitle << oendl; 469 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
516 lnk.setComment(DlglistItemTitle); 470 lnk.setExec(File_Name);
517 471 lnk.setIcon("gutenbrowser/Gutenbrowser");
518 odebug << "Filename is "+File_Name << oendl; 472 if(!lnk.writeLink()) {
519 lnk.setFile(File_Name); //sets File property 473 //odebug << "Writing doclink did not work" << oendl;
520 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 474 } else {
521 lnk.setExec(File_Name); 475 }
522 lnk.setIcon("gutenbrowser/Gutenbrowser"); 476 } else
523 if(!lnk.writeLink()) { 477 QMessageBox::message("Note","<p>There was an error with the file</p>");
524 odebug << "Writing doclink did not work" << oendl; 478 }
525 } else { 479 }
526 } 480
527 } else 481 return true;
528 QMessageBox::message("Note","<p>There was an error with the file</p>"); 482}
529 } 483
530 } 484bool LibraryDialog::download_Etext()
531 return true; 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
535 return true;
532} 536}
533 537
534bool LibraryDialog::httpDownload() 538bool LibraryDialog::httpDownload()
535{// httpDownload 539{// httpDownload
536#ifndef Q_WS_QWS 540#ifndef Q_WS_QWS
537 Config config("Gutenbrowser"); 541 Config config("Gutenbrowser");
538 config.setGroup( "Browser" ); 542 config.setGroup( "Browser" );
539 QString brow = config.readEntry("Preferred", ""); 543 QString brow = config.readEntry("Preferred", "");
540 QString file_name = "./.guten_temp"; 544 QString file_name = "./.guten_temp";
541 // config.setGroup( "HttpServer" ); 545 // config.setGroup( "HttpServer" );
542 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 546 // QString s_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
543 QString httpName = proxy_http + "/"+Edir; 547 QString httpName = proxy_http + "/"+Edir;
544 // progressBar->setProgress( i); 548 // progressBar->setProgress( i);
545 i++; 549 i++;
546 if ( brow != "Konq") { /////////// use lynx 550 if ( brow != "Konq") { /////////// use lynx
547 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name; 551 // QString cmd = "lynx -source " + httpName +" | cat >> " + file_name;
548 // system(cmd); 552 // system(cmd);
549 } else { //////////// use KFM 553 } else { //////////// use KFM
550 // KFM::download( httpName, file_name); 554 // KFM::download( httpName, file_name);
551 } 555 }
552 i++; 556 i++;
553 QFile tmp( file_name); 557 QFile tmp( file_name);
554 QString str; 558 QString str;
555 if (tmp.open(IO_ReadOnly)) { 559 if (tmp.open(IO_ReadOnly)) {
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
564 } 568 }
565 tmp.close(); 569 tmp.close();
566 m_getFilePath = local_library + str; 570 m_getFilePath = local_library + str;
567 i++; 571 i++;
568 if ( brow != "KFM"){ ///////// use lynx 572 if ( brow != "KFM"){ ///////// use lynx
569 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath; 573 QString cmd = "lynx -source " + httpName +" | cat >> " + m_getFilePath;
570 // QMessageBox::message("Error", cmd); 574 // QMessageBox::message("Error", cmd);
571 system(cmd); 575 system(cmd);
572 } else { ////////// use KFM 576 } else { ////////// use KFM
573 // KFM::download( httpName, m_getFilePath); 577 // KFM::download( httpName, m_getFilePath);
574 } 578 }
575 i++; 579 i++;
576#endif 580#endif
577 return false; 581 return false;
578} 582}
579 583
580void LibraryDialog::cancelIt() 584void LibraryDialog::cancelIt()
581{ 585{
582 saveConfig(); 586 saveConfig();
583 587
584 DlglistItemNumber = ""; 588 DlglistItemNumber = "";
585 this->reject(); 589 this->reject();
586} 590}
587 591
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");
602 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 606 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
603 int i_numofFiles = s_numofFiles.toInt(); 607 int i_numofFiles = s_numofFiles.toInt();
604 for ( int i = 0; i <= i_numofFiles; i++){ 608 for ( int i = 0; i <= i_numofFiles; i++){
605 temp.setNum( i); 609 temp.setNum( i);
606 ramble = config.readEntry( temp, "" ); 610 ramble = config.readEntry( temp, "" );
607 if( strcmp( ramble, File_Name) == 0){ 611 if( strcmp( ramble, File_Name) == 0){
608 test = 1; 612 test = 1;
609 } 613 }
610 } 614 }
611 config.setGroup("Files"); 615
612 config.writeEntry( "NumberOfFiles", i_numofFiles +1 ); 616 if(test == 0 ) {
613 QString interger; 617
614 interger.setNum( i_numofFiles +1); 618 config.setGroup("Files");
615 config.writeEntry( interger, File_Name); 619 config.writeEntry( "NumberOfFiles", i_numofFiles +1 );
616 config.setGroup( "Titles" ); 620 QString interger;
617 config.writeEntry( File_Name, DlglistItemTitle); 621 interger.setNum( i_numofFiles +1);
618 622 config.writeEntry( interger, File_Name);
619 test = 0; 623 config.setGroup( "Titles" );
620 return true; 624 config.writeEntry( File_Name, DlglistItemTitle);
625 }
626 test = 0;
627 return true;
621} 628}
622 629
623 630
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}
645 652
646 /* 653/*
647 searches library index for user word*/ 654 searches library index for user word*/
648void LibraryDialog::onButtonSearch() 655void LibraryDialog::onButtonSearch()
649{ 656{
650 ListView1->clearSelection(); 657 ListView1->clearSelection();
651 ListView2->clearSelection(); 658 ListView2->clearSelection();
652 ListView3->clearSelection(); 659 ListView3->clearSelection();
653 ListView4->clearSelection(); 660 ListView4->clearSelection();
654 ListView5->clearSelection(); 661 ListView5->clearSelection();
655 662
656 int curTab=tabWidget->currentPageIndex(); 663 int curTab = tabWidget->currentPageIndex();
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");
663 QString resultString; 670
664 int i_berger = 0; 671 QString resultString;
665 if( searchDlg->exec() != 0 ) { 672
666 QString searcherStr = searchDlg->get_text(); 673 int i_berger = 0;
667 int fluff=0; 674 if( searchDlg->exec() != 0 ) {
668 675 QString searcherStr = searchDlg->get_text();
669 // int tabPage = tabWidget->currentPageIndex(); 676 int fluff = 0;
670 // TODO ititerate here... struct<listViews>?? 677
671 678 // int tabPage = tabWidget->currentPageIndex();
672 QListViewItemIterator it1( ListView1 ); 679 // TODO ititerate here... struct<listViews>??
673 QListViewItemIterator it2( ListView2 ); 680
674 QListViewItemIterator it3( ListView3 ); 681 QListViewItemIterator it1( ListView1 );
675 QListViewItemIterator it4( ListView4 ); 682 QListViewItemIterator it2( ListView2 );
676 QListViewItemIterator it5( ListView5 ); 683 QListViewItemIterator it3( ListView3 );
677 684 QListViewItemIterator it4( ListView4 );
678 //// this is really pitiful work, 685 QListViewItemIterator it5( ListView5 );
679 /////// 686
680 bool cS; 687 //// this is really pitiful work,
681 if( searchDlg->caseSensitiveCheckBox->isChecked()) 688 ///////
682 cS=true; //case sensitive 689 bool cS;
683 else 690 if( searchDlg->caseSensitiveCheckBox->isChecked())
684 cS=false; 691 cS=true; //case sensitive
685 692 else
686 if(fluff==0) { 693 cS=false;
687 for ( ; it1.current(); ++it1 ) { 694
688 resultString = ( it1.current() )->text(0); 695 if(fluff==0) {
689 resultString += (" : "); 696 for ( ; it1.current(); ++it1 ) {
690 resultString += ( it1.current() )->text(2); 697 resultString = ( it1.current() )->text(0);
691 resultString += (" : "); 698 resultString += (" : ");
692 resultString += ( it1.current() )->text(3); 699 resultString += ( it1.current() )->text(2);
693 if( resultString.find( searcherStr, 0, cS) != -1) 700 resultString += (" : ");
694 { 701 resultString += ( it1.current() )->text(3);
695 Searchlist.append( resultString); 702 if( resultString.find( searcherStr, 0, cS) != -1)
696 } 703 {
697 } 704 Searchlist.append( resultString);
698 } 705 }
699 if(fluff==0) {// search routine here 706 }
700 for ( ; it2.current(); ++it2 ) { 707 }
701 resultString = ( it2.current() )->text(0); 708 if(fluff==0) {// search routine here
702 resultString += (" : "); 709 for ( ; it2.current(); ++it2 ) {
703 resultString += ( it2.current() )->text(2); 710 resultString = ( it2.current() )->text(0);
704 resultString += (" : "); 711 resultString += (" : ");
705 resultString += ( it2.current() )->text(3); 712 resultString += ( it2.current() )->text(2);
706 if( resultString.find( searcherStr, 0, cS) != -1) { 713 resultString += (" : ");
707 Searchlist.append( resultString); 714 resultString += ( it2.current() )->text(3);
708 } 715 if( resultString.find( searcherStr, 0, cS) != -1) {
709 } 716 Searchlist.append( resultString);
710 } 717 }
711 if(fluff==0) {// search routine here 718 }
712 for ( ; it3.current(); ++it3 ) { 719 }
713 resultString = ( it3.current() )->text(0); 720 if(fluff==0) {// search routine here
714 resultString += (" : "); 721 for ( ; it3.current(); ++it3 ) {
715 resultString += ( it3.current() )->text(2); 722 resultString = ( it3.current() )->text(0);
716 resultString += (" : "); 723 resultString += (" : ");
717 resultString += ( it3.current() )->text(3); 724 resultString += ( it3.current() )->text(2);
718 725 resultString += (" : ");
719 if( resultString.find( searcherStr, 0, cS) != -1) { 726 resultString += ( it3.current() )->text(3);
720 Searchlist.append( resultString); 727
721 } 728 if( resultString.find( searcherStr, 0, cS) != -1) {
722 } 729 Searchlist.append( resultString);
723 } 730 }
724 if(fluff==0) { 731 }
725 // search routine here 732 }
726 for ( ; it4.current(); ++it4 ) { 733 if(fluff==0) {
727 resultString = ( it4.current() )->text(0); 734 // search routine here
728 resultString += (" : "); 735 for ( ; it4.current(); ++it4 ) {
729 resultString += ( it4.current() )->text(2); 736 resultString = ( it4.current() )->text(0);
730 resultString += (" : "); 737 resultString += (" : ");
731 resultString += ( it4.current() )->text(3); 738 resultString += ( it4.current() )->text(2);
732 if( resultString.find( searcherStr, 0, cS) != -1) { 739 resultString += (" : ");
733 Searchlist.append( resultString); 740 resultString += ( it4.current() )->text(3);
734 } 741 if( resultString.find( searcherStr, 0, cS) != -1) {
735 } 742 Searchlist.append( resultString);
736 } 743 }
737 if(fluff==0) { // search routine here 744 }
738 for ( ; it5.current(); ++it5 ) { 745 }
739 resultString = ( it5.current() )->text(0); 746 if(fluff==0) { // search routine here
740 resultString += (" : "); 747 for ( ; it5.current(); ++it5 ) {
741 resultString += ( it5.current() )->text(2); 748 resultString = ( it5.current() )->text(0);
742 resultString += (" : "); 749 resultString += (" : ");
743 resultString += ( it5.current() )->text(3); 750 resultString += ( it5.current() )->text(2);
744 if( resultString.find( searcherStr, 0, cS) != -1) { 751 resultString += (" : ");
745 Searchlist.append( resultString); 752 resultString += ( it5.current() )->text(3);
746 } 753 if( resultString.find( searcherStr, 0, cS) != -1) {
747 } 754 Searchlist.append( resultString);
748 } 755 }
749 756 }
750 tabWidget->setCurrentPage( curTab); 757 }
751 758
752 Searchlist.sort(); 759 tabWidget->setCurrentPage( curTab);
753 SearchResultsDlg* SearchResultsDialog; 760
754 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); 761 Searchlist.sort();
755 762 SearchResultsDlg* SearchResultsDialog;
756 SearchResultsDialog->showMaximized(); 763 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
757 if( SearchResultsDialog->exec() != 0) { 764
758 texter = SearchResultsDialog->selText; 765 SearchResultsDialog->showMaximized();
759 // odebug << texter << oendl; 766 if( SearchResultsDialog->exec() != 0) {
760 resultLs= SearchResultsDialog->resultsList; 767 texter = SearchResultsDialog->selText;
761 i_berger = 1; 768 // //odebug << texter << oendl;
762 } 769 resultLs = SearchResultsDialog->resultsList;
763 Searchlist.clear(); 770 i_berger = 1;
764 771 } else {
765 // if(SearchResultsDialog) 772 resultLs.clear();
766 // delete SearchResultsDialog; 773 }
767 QString tester; 774 Searchlist.clear();
768 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 775
769 texter.sprintf("%s \n",(*it).latin1()); 776 // if(SearchResultsDialog)
770 // odebug << texter << oendl; 777 // delete SearchResultsDialog;
771 if( tester!=texter) 778 QString tester;
772 parseSearchResults( texter); 779 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
773 tester = texter; 780 texter.sprintf("%s \n",(*it).latin1());
774 } 781 // //odebug << texter << oendl;
775 if(searchDlg) 782 if( tester!=texter)
776 delete searchDlg; 783 parseSearchResults( texter);
777 } 784 tester = texter;
778 if(checkBox->isChecked() ) { 785 }
779 accept(); 786 if(searchDlg)
780 } else { 787 delete searchDlg;
781 setActiveWindow(); 788 }
782 } 789 if(checkBox->isChecked() ) {
790 accept();
791 } else {
792 setActiveWindow();
793 }
783} 794}
784 795
785 /* 796/*
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 800 int stringLeng = resultStr.length();
790 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
796 DlglistItemTitle = resultStr.left( titleInt); 807 int titleInt = resultStr.find( " : ", 0, true);
797 int yearInt = resultStr.find( " : ", titleInt+3, TRUE); 808 DlglistItemTitle = resultStr.left( titleInt);
798 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3); 809
799 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3)); 810 int yearInt = resultStr.find( " : ", titleInt+3, true);
800 download_Etext(); 811
801 } 812 DlglistItemYear = resultStr.mid( titleInt+3, (yearInt - titleInt)-3);
802 /* 813
803 printf( DlglistItemTitle+"\n"); printf( DlglistItemYear+"\n"); printf( DlglistItemFile+"\n");*/ 814 DlglistItemFile = resultStr.right( resultStr.length() - (yearInt + 3));
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 }
804} 830}
805 831
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
852void LibraryDialog::sort() 832void LibraryDialog::sort()
853{ 833{
854 834
855} 835}
856 836
857 /* 837/*
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);
865 DlglistItemYear = it->text(2); 845 DlglistItemYear = it->text(2);
866 DlglistItemFile = it->text(3); 846 DlglistItemFile = it->text(3);
867 847
868 if(download_Etext()) { 848 if(download_Etext()) {
869 if(i_binary == 1) { 849 if(i_binary == 1) {
870 } 850 }
871 } 851 }
872 return true; 852 return true;
873} 853}
874 854
875 /* 855/*
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 );
883 QListViewItemIterator it3( ListView3 ); 863 QListViewItemIterator it3( ListView3 );
884 QListViewItemIterator it4( ListView4 ); 864 QListViewItemIterator it4( ListView4 );
885 QListViewItemIterator it5( ListView5 ); 865 QListViewItemIterator it5( ListView5 );
886 866
887 // iterate through all items of the listview 867 // iterate through all items of the listview
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}
915 895
916 896
917 /* 897/*
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();
930 ListView3->sort(); 910 ListView3->sort();
931 ListView4->sort(); 911 ListView4->sort();
932 ListView5->sort(); 912 ListView5->sort();
933 913
934 // ListView1->triggerUpdate(); 914 // ListView1->triggerUpdate();
935 // ListView2->triggerUpdate(); 915 // ListView2->triggerUpdate();
936 // ListView3->triggerUpdate(); 916 // ListView3->triggerUpdate();
937 // ListView4->triggerUpdate(); 917 // ListView4->triggerUpdate();
938 // ListView5->triggerUpdate(); 918 // ListView5->triggerUpdate();
939} 919}
940 920
941void LibraryDialog::newList() 921void LibraryDialog::newList()
942{ 922{
943 if(indexLoaded) { 923 if(indexLoaded) {
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; 931 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
952 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 932
953 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; 933 int result = QMessageBox::warning( this,"Download"
954 934 ,"<p>Ok to use /'wget/' to download a new library list?</P>"
955 int result = QMessageBox::warning( this,"Download" 935 ,"Yes","No",0,0,1);
956 ,"<p>Ok to use /'wget/' to download a new library list?</P>" 936 qApp->processEvents();
957 ,"Yes","No",0,0,1); 937 if(result == 0) {
958 qApp->processEvents(); 938 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),true);
959 if(result == 0) { 939 outDlg->showMaximized();
960 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 940 outDlg->show();
961 outDlg->showMaximized(); 941 qApp->processEvents();
962 outDlg->show(); 942 FILE *fp;
963 qApp->processEvents(); 943 char line[130];
964 FILE *fp; 944 outDlg->OutputEdit->append( tr("Running wget") );
965 char line[130]; 945 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
966 outDlg->OutputEdit->append( tr("Running wget") ); 946 sleep(1);
967 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 947 fp = popen( (const char *) cmd, "r");
968 sleep(1); 948 if ( !fp ) {
969 fp = popen( (const char *) cmd, "r"); 949 } else {
970 if ( !fp ) { 950 //odebug << "Issuing the command\n"+cmd << oendl;
971 } else { 951 // system(cmd);
972 odebug << "Issuing the command\n"+cmd << oendl; 952 while ( fgets( line, sizeof line, fp)) {
973 // system(cmd); 953 outDlg->OutputEdit->append(line);
974 while ( fgets( line, sizeof line, fp)) { 954 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
975 outDlg->OutputEdit->append(line); 955 }
976 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 956 pclose(fp);
977 } 957 outDlg->OutputEdit->append("Finished downloading\n");
978 pclose(fp); 958 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,false);
979 outDlg->OutputEdit->append("Finished downloading\n"); 959 qApp->processEvents();
980 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 960
981 qApp->processEvents(); 961 // if( QFile(gutenindex1).exists() ) {
982 962 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
983 // if( QFile(gutenindex1).exists() ) { 963 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
984 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 964 // //odebug << "renaming error" << oendl;
985 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) 965 // }
986 // odebug << "renaming error" << oendl; 966
987 // } 967 }
988 968 // outDlg->close();
989 } 969 FindLibrary();
990 // outDlg->close(); 970 if(outDlg) delete outDlg;
991 FindLibrary(); 971 }
992 if(outDlg) delete outDlg; 972 buttonNewList->setDown(false);
993 } 973
994 buttonNewList->setDown(FALSE); 974 // if(outDlg)
995 } else { 975 // delete outDlg;
996 QMessageBox::message("Note","Could not change directories"); 976 }
997 }
998 // if(outDlg)
999 // delete outDlg;
1000 }
1001} 977}
1002 978
1003bool LibraryDialog::moreInfo() 979bool LibraryDialog::moreInfo()
1004{ 980{
1005 981
1006 QListViewItem * item; 982 QListViewItem * item;
1007 item = 0; 983 item = 0;
1008 QString titleString; 984 QString titleString;
1009 item = ListView1->currentItem(); 985 item = ListView1->currentItem();
1010 if( item != 0) { 986 if( item != 0) {
1011 titleString = item->text(0); 987 titleString = item->text(0);
1012 ListView1->clearSelection(); 988 ListView1->clearSelection();
1013 item = 0; 989 item = 0;
1014 } 990 }
1015 if( item == 0) 991 if( item == 0)
1016 item = ListView2->currentItem(); 992 item = ListView2->currentItem();
1017 if( item != 0) { 993 if( item != 0) {
1018 titleString = item->text(0); 994 titleString = item->text(0);
1019 ListView2->clearSelection(); 995 ListView2->clearSelection();
1020 item = 0; 996 item = 0;
1021 } 997 }
1022 if( item == 0) 998 if( item == 0)
1023 item = ListView3->currentItem(); 999 item = ListView3->currentItem();
1024 if( item != 0) { 1000 if( item != 0) {
1025 titleString = item->text(0); 1001 titleString = item->text(0);
1026 ListView3->clearSelection(); 1002 ListView3->clearSelection();
1027 item = 0; 1003 item = 0;
1028 } 1004 }
1029 if( item == 0) 1005 if( item == 0)
1030 item = ListView4->currentItem(); 1006 item = ListView4->currentItem();
1031 if( item != 0) { 1007 if( item != 0) {
1032 titleString = item->text(0); 1008 titleString = item->text(0);
1033 ListView4->clearSelection(); 1009 ListView4->clearSelection();
1034 item = 0; 1010 item = 0;
1035 } 1011 }
1036 if( item == 0) 1012 if( item == 0)
1037 item = ListView5->currentItem(); 1013 item = ListView5->currentItem();
1038 if( item != 0) { 1014 if( item != 0) {
1039 titleString = item->text(0); 1015 titleString = item->text(0);
1040 ListView5->clearSelection(); 1016 ListView5->clearSelection();
1041 item = 0; 1017 item = 0;
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");
1049 titleString.replace( QRegExp("&"), "%20"); 1025 titleString.replace( QRegExp("&"), "%20");
1050 QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search"; 1026 QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search";
1051 cmd="opera "+cmd; 1027 cmd="opera "+cmd;
1052 system(cmd); 1028 system(cmd);
1053 } else 1029 } else
1054 QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>"); 1030 QMessageBox::message( "Note","<p>If you select a title, this will search google.com for that title.</p>");
1055 return true; 1031 return true;
1056 1032
1057} 1033}
1058 1034
1059 /* 1035/*
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();
1060
1061}
1084 1062
1063void LibraryDialog::cleanStrings() {
1064 year = year.stripWhiteSpace();
1065 file = file.stripWhiteSpace();
1066 title = title.stripWhiteSpace();
1067 number = number.stripWhiteSpace();
1068
1085} 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
@@ -105,8 +105,10 @@ public slots:
105 bool httpDownload(); 105 bool httpDownload();
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
112// bool UnzipIt( QString fileName); 114// bool UnzipIt( QString fileName);
@@ -119,8 +121,13 @@ protected:
119 void initDialog(); 121 void initDialog();
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
126#endif // LIBRARYDIALOG_H 133#endif // LIBRARYDIALOG_H
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
@@ -166,48 +166,47 @@ bool NetworkDialog::downloadFile( QString networkUrl )
166// QMessageBox::message("Note",msg); 166// QMessageBox::message("Note",msg);
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 TextLabel3->setText("Getting directory list.");
172 qApp->processEvents();
173 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
174 msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
175 QMessageBox::message("Note",msg);
176 successDownload=false;
177 FtpQuit(conn);
178 return false;
179 }
180 QFile tmp("./.guten_temp");
181 QString s, File_Name;
182 171
183 if (tmp.open(IO_ReadOnly)) { 172 if( s_partialFileName.right(4) != ".txt") {
184 QTextStream t( &tmp ); // use a text stream 173 TextLabel3->setText("Getting directory list.");
185 odebug << "Finding partial filename "+s_partialFileName << oendl; 174 qApp->processEvents();
186 while ( !t.eof()) { 175 if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
187 s = t.readLine(); 176 msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
177 QMessageBox::message("Note",msg);
178 successDownload = false;
179 FtpQuit(conn);
180 return false;
181 }
182 QFile tmp("./.guten_temp");
183 if (tmp.open(IO_ReadOnly)) {
184 QTextStream t( &tmp ); // use a text stream
185 //odebug << "Finding partial filename "+s_partialFileName << oendl;
186 QString s;
188 187
189 if (s.contains(s_partialFileName, FALSE)) { 188 while ( !t.eof()) {
190 QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) ); 189 s = t.readLine();
191 190
192 if (str.contains(".txt")) { 191 if (s.contains(s_partialFileName, FALSE)) {
193 File_Name = str; 192 QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) );
194 odebug << "Found file_name "+ File_Name << oendl;
195 break;
196 }
197// if (str.contains(".zip")) {
198// File_Name = str;
199// odebug << "Found file_name "+ File_Name << oendl;
200// break;
201// }
202 193
203 } 194 if (str.contains(".txt")) {
204 } //end of while loop 195 File_Name = str;
205 tmp.close(); 196 //odebug << "Found file_name "+ File_Name << oendl;
197 break;
198 }
199 }
200 } //end of while loop
201 tmp.close();
206// tmp.remove(); ///TODO this is for release version Zaurus 202// tmp.remove(); ///TODO this is for release version Zaurus
203 }
204 } else {
205 File_Name = s_partialFileName;
206 qDebug("new dir " + File_Name);
207 } 207 }
208 else 208
209 odebug << "Error opening temp file." << oendl;
210 209
211 Config cfg("Gutenbrowser"); 210 Config cfg("Gutenbrowser");
212 cfg.setGroup("General"); 211 cfg.setGroup("General");
213 QString temp=cfg.readEntry("DownloadDirectory",local_library); 212 QString temp=cfg.readEntry("DownloadDirectory",local_library);
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
@@ -140,15 +140,15 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); 140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle);
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 }
154 qDebug("attempting new library"); 154 qDebug("attempting new library");
@@ -196,30 +196,30 @@ void Gutenbrowser::InfoBarClick() {
196 196
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
225 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 225 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
@@ -273,9 +273,9 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
273 cmd="wget -O "+tempHtml+" -q "+url; 273 cmd="wget -O "+tempHtml+" -q "+url;
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}
281 281