summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp92
1 files changed, 48 insertions, 44 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 5b22b00..270a4cf 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -14,15 +14,19 @@
14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL 14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
15 15
16#include "LibraryDialog.h"
17#include "output.h"
18
19/* OPIE */
16#include <qpe/applnk.h> 20#include <qpe/applnk.h>
17#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
18#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23#include <opie2/odebug.h>
19 24
20#include "LibraryDialog.h" 25/* QT */
21#include "output.h"
22
23#include <qpushbutton.h> 26#include <qpushbutton.h>
24#include <qmultilineedit.h> 27#include <qmultilineedit.h>
25//#include <qlayout.h> 28//#include <qlayout.h>
26 29
30/* STD */
27#include <unistd.h> 31#include <unistd.h>
28#include <stdio.h> 32#include <stdio.h>
@@ -65,5 +69,5 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, W
65 config.setGroup( "FTPsite" ); 69 config.setGroup( "FTPsite" );
66 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
67 qDebug("Library Dialog: ftp_host is "+ftp_host); 71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace(); 73 // ftp_host=ftp_host.stripWhiteSpace();
@@ -78,5 +82,5 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, W
78 config.setGroup("General"); 82 config.setGroup("General");
79 downDir =config.readEntry( "DownloadDirectory",local_library); 83 downDir =config.readEntry( "DownloadDirectory",local_library);
80 qDebug("downDir is "+downDir); 84 odebug << "downDir is "+downDir << oendl;
81 newindexLib.setName( old_index); 85 newindexLib.setName( old_index);
82 indexLib.setName( old_index); 86 indexLib.setName( old_index);
@@ -100,5 +104,5 @@ void LibraryDialog::Newlibrary()
100{ 104{
101#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 105#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
102 //qDebug("Opening new library index %s",newindexLib); 106 //odebug << "Opening new library index " << newindexLib << "" << oendl;
103 if ( newindexLib.open( IO_ReadOnly) ) { 107 if ( newindexLib.open( IO_ReadOnly) ) {
104 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 108 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
@@ -122,5 +126,5 @@ void LibraryDialog::Newlibrary()
122 author = author.stripWhiteSpace(); 126 author = author.stripWhiteSpace();
123 if (authBox->isChecked()) { // this reverses the first name and last name of the author 127 if (authBox->isChecked()) { // this reverses the first name and last name of the author
124 // qDebug("Sorting last name first"); 128 // odebug << "Sorting last name first" << oendl;
125 QString lastName, firstName=""; 129 QString lastName, firstName="";
126 int finder=author.findRev( ' ', -1, TRUE); 130 int finder=author.findRev( ' ', -1, TRUE);
@@ -181,5 +185,5 @@ void LibraryDialog::Library()
181 ListView5->clear(); 185 ListView5->clear();
182 186
183 qDebug("opening GUTINDEX.ALL file"); 187 odebug << "opening GUTINDEX.ALL file" << oendl;
184 IDontKnowWhy = ""; 188 IDontKnowWhy = "";
185 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully 189 if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
@@ -201,5 +205,5 @@ void LibraryDialog::Library()
201 if( file.find("]",0,TRUE) != -1) 205 if( file.find("]",0,TRUE) != -1)
202 file = file.left( file.find("]",0,TRUE)); 206 file = file.left( file.find("]",0,TRUE));
203 //qDebug("file is "+file); 207 //odebug << "file is "+file << oendl;
204 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 208 /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
205 number = indexLine.mid(55,5); 209 number = indexLine.mid(55,5);
@@ -208,8 +212,8 @@ void LibraryDialog::Library()
208 title = indexLine.mid( 9, 50 ); 212 title = indexLine.mid( 9, 50 );
209 title = title.stripWhiteSpace(); 213 title = title.stripWhiteSpace();
210 //qDebug("title is "+title); 214 //odebug << "title is "+title << oendl;
211 getAuthor(); // grok author 215 getAuthor(); // grok author
212 author = author.stripWhiteSpace(); 216 author = author.stripWhiteSpace();
213 //qDebug("author is "+author); 217 //odebug << "author is "+author << oendl;
214 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author 218 if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
215 QString lastName, firstName=""; 219 QString lastName, firstName="";
@@ -398,6 +402,6 @@ void LibraryDialog::select_title( QListViewItem * item)
398 // DlglistItemNumber = item->text(0); 402 // DlglistItemNumber = item->text(0);
399 item = 0; 403 item = 0;
400 qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1()); 404 odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl;
401 qDebug("Title is "+DlglistItemTitle); 405 odebug << "Title is "+DlglistItemTitle << oendl;
402 406
403 // check for connection here 407 // check for connection here
@@ -405,5 +409,5 @@ void LibraryDialog::select_title( QListViewItem * item)
405 409
406 if(download_Etext()) { 410 if(download_Etext()) {
407 // qDebug("get here 2"); 411 // odebug << "get here 2" << oendl;
408 if(i_binary == 1) { 412 if(i_binary == 1) {
409 413
@@ -424,5 +428,5 @@ bool LibraryDialog::download_Etext()
424 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg"); 428 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
425 429
426 qDebug("about to network dialog"); 430 odebug << "about to network dialog" << oendl;
427 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile; 431 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
428 432
@@ -432,9 +436,9 @@ bool LibraryDialog::download_Etext()
432 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) { 436 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
433 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); 437 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
434 qDebug("NewlistItemFile is now "+NewlistItemFile); 438 odebug << "NewlistItemFile is now "+NewlistItemFile << oendl;
435 } 439 }
436 NewlistItemYear = DlglistItemYear.right(2); 440 NewlistItemYear = DlglistItemYear.right(2);
437 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); 441 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
438 qDebug(NewlistItemYear); 442 odebug << NewlistItemYear << oendl;
439 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { 443 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
440 NewlistItemYear = "90"; 444 NewlistItemYear = "90";
@@ -448,6 +452,6 @@ bool LibraryDialog::download_Etext()
448 452
449 outputFile=local_library+".guten_temp"; 453 outputFile=local_library+".guten_temp";
450 //qDebug("Download file:%s",NewlistItemFile.latin1() ); 454 //odebug << "Download file:" << NewlistItemFile << "" << oendl;
451 qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile); 455 odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl;
452 QStringList networkList; 456 QStringList networkList;
453 networkList.append((const char *)ftp_host); 457 networkList.append((const char *)ftp_host);
@@ -463,16 +467,16 @@ bool LibraryDialog::download_Etext()
463 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer 467 if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
464 File_Name= NetworkDlg->localFileName; 468 File_Name= NetworkDlg->localFileName;
465 qDebug("back to Library from Network Dialog"); 469 odebug << "back to Library from Network Dialog" << oendl;
466 qDebug("Just downloaded "+NetworkDlg->localFileName); 470 odebug << "Just downloaded "+NetworkDlg->localFileName << oendl;
467 471
468 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found 472 // if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
469 // QString oldName=File_Name; 473 // QString oldName=File_Name;
470 // File_Name.replace(0,local_library.length(),downDir); 474 // File_Name.replace(0,local_library.length(),downDir);
471 // qDebug("File_Name now is "+File_Name); 475 // odebug << "File_Name now is "+File_Name << oendl;
472 476
473 // } 477 // }
474 // rename .txt to .etx 478 // rename .txt to .etx
475 if(NetworkDlg->successDownload) { 479 if(NetworkDlg->successDownload) {
476 qDebug("Filename is "+File_Name); 480 odebug << "Filename is "+File_Name << oendl;
477 if(File_Name.right(4)==".txt") { 481 if(File_Name.right(4)==".txt") {
478 QString s_fileName=File_Name; 482 QString s_fileName=File_Name;
@@ -482,5 +486,5 @@ bool LibraryDialog::download_Etext()
482 File_Name=s_fileName; 486 File_Name=s_fileName;
483 487
484 qDebug("Filename is now "+File_Name); 488 odebug << "Filename is now "+File_Name << oendl;
485 489
486 } 490 }
@@ -491,12 +495,12 @@ bool LibraryDialog::download_Etext()
491 name_file=name_file.left(name_file.length()-4); 495 name_file=name_file.left(name_file.length()-4);
492 496
493 qDebug("Setting doclink"); 497 odebug << "Setting doclink" << oendl;
494 DocLnk lnk; 498 DocLnk lnk;
495 qDebug("name is "+name_file); 499 odebug << "name is "+name_file << oendl;
496 lnk.setName(name_file); //sets file name 500 lnk.setName(name_file); //sets file name
497 qDebug("Title is "+DlglistItemTitle); 501 odebug << "Title is "+DlglistItemTitle << oendl;
498 lnk.setComment(DlglistItemTitle); 502 lnk.setComment(DlglistItemTitle);
499 503
500 qDebug("Filename is "+File_Name); 504 odebug << "Filename is "+File_Name << oendl;
501 lnk.setFile(File_Name); //sets File property 505 lnk.setFile(File_Name); //sets File property
502 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 506 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
@@ -504,5 +508,5 @@ bool LibraryDialog::download_Etext()
504 lnk.setIcon("gutenbrowser/Gutenbrowser"); 508 lnk.setIcon("gutenbrowser/Gutenbrowser");
505 if(!lnk.writeLink()) { 509 if(!lnk.writeLink()) {
506 qDebug("Writing doclink did not work"); 510 odebug << "Writing doclink did not work" << oendl;
507 } else { 511 } else {
508 } 512 }
@@ -571,6 +575,6 @@ bool LibraryDialog::setTitle()
571{ 575{
572 Config config("Gutenbrowser"); 576 Config config("Gutenbrowser");
573 qDebug("setting title"); 577 odebug << "setting title" << oendl;
574 qDebug(DlglistItemTitle); 578 odebug << DlglistItemTitle << oendl;
575 579
576 if( DlglistItemTitle.find("[",0,TRUE) != -1) 580 if( DlglistItemTitle.find("[",0,TRUE) != -1)
@@ -578,5 +582,5 @@ bool LibraryDialog::setTitle()
578 if( DlglistItemTitle.find("]",0,TRUE) !=-1) 582 if( DlglistItemTitle.find("]",0,TRUE) !=-1)
579 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" ); 583 DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
580 qDebug("Title being set is "+DlglistItemTitle); 584 odebug << "Title being set is "+DlglistItemTitle << oendl;
581 int test = 0; 585 int test = 0;
582 QString ramble, temp; 586 QString ramble, temp;
@@ -739,5 +743,5 @@ void LibraryDialog::onButtonSearch()
739 if( SearchResultsDialog->exec() != 0) { 743 if( SearchResultsDialog->exec() != 0) {
740 texter = SearchResultsDialog->selText; 744 texter = SearchResultsDialog->selText;
741 // qDebug(texter); 745 // odebug << texter << oendl;
742 resultLs= SearchResultsDialog->resultsList; 746 resultLs= SearchResultsDialog->resultsList;
743 i_berger = 1; 747 i_berger = 1;
@@ -750,5 +754,5 @@ void LibraryDialog::onButtonSearch()
750 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 754 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
751 texter.sprintf("%s \n",(*it).latin1()); 755 texter.sprintf("%s \n",(*it).latin1());
752 // qDebug(texter); 756 // odebug << texter << oendl;
753 if( tester!=texter) 757 if( tester!=texter)
754 parseSearchResults( texter); 758 parseSearchResults( texter);
@@ -807,5 +811,5 @@ void LibraryDialog::parseSearchResults( QString resultStr)
807 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No); 811 // int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
808 // if (exit==QMessageBox::Yes) { 812 // if (exit==QMessageBox::Yes) {
809 // qDebug("Issuing the command "+cmd); 813 // odebug << "Issuing the command "+cmd << oendl;
810 // #if defined(_WS_WIN_) 814 // #if defined(_WS_WIN_)
811 // WinExec( cmd, SW_HIDE ); 815 // WinExec( cmd, SW_HIDE );
@@ -841,5 +845,5 @@ void LibraryDialog::sort()
841bool LibraryDialog::getItem(QListViewItem *it) 845bool LibraryDialog::getItem(QListViewItem *it)
842{ 846{
843 // qDebug("selected getItem"); 847 // odebug << "selected getItem" << oendl;
844 848
845 // DlglistItemNumber = it->text(0); 849 // DlglistItemNumber = it->text(0);
@@ -859,5 +863,5 @@ bool LibraryDialog::getItem(QListViewItem *it)
859bool LibraryDialog::onButtonDownload() 863bool LibraryDialog::onButtonDownload()
860{ 864{
861 // qDebug("selected onButtonDownloadz"); 865 // odebug << "selected onButtonDownloadz" << oendl;
862 866
863 QListViewItemIterator it1( ListView1 ); 867 QListViewItemIterator it1( ListView1 );
@@ -901,5 +905,5 @@ bool LibraryDialog::onButtonDownload()
901void LibraryDialog::comboSelect(int index) 905void LibraryDialog::comboSelect(int index)
902{ 906{
903 // qDebug("we are sorting"); 907 // odebug << "we are sorting" << oendl;
904 ListView1->setSorting( index, TRUE); 908 ListView1->setSorting( index, TRUE);
905 ListView2->setSorting( index, TRUE); 909 ListView2->setSorting( index, TRUE);
@@ -931,5 +935,5 @@ void LibraryDialog::newList()
931 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true); 935 if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
932 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) { 936 if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
933 qDebug("changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser"); 937 odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
934 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 938 QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
935 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1"; 939 QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
@@ -952,5 +956,5 @@ void LibraryDialog::newList()
952 if ( !fp ) { 956 if ( !fp ) {
953 } else { 957 } else {
954 qDebug("Issuing the command\n"+cmd); 958 odebug << "Issuing the command\n"+cmd << oendl;
955 // system(cmd); 959 // system(cmd);
956 while ( fgets( line, sizeof line, fp)) { 960 while ( fgets( line, sizeof line, fp)) {
@@ -966,5 +970,5 @@ void LibraryDialog::newList()
966 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 970 // QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
967 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0) 971 // if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
968 // qDebug("renaming error"); 972 // odebug << "renaming error" << oendl;
969 // } 973 // }
970 974
@@ -1025,5 +1029,5 @@ bool LibraryDialog::moreInfo()
1025 item=0; 1029 item=0;
1026 if(titleString.length()>2) { 1030 if(titleString.length()>2) {
1027 qDebug( "Title is "+titleString ); 1031 odebug << "Title is "+titleString << oendl;
1028 titleString.replace( QRegExp("\\s"), "%20"); 1032 titleString.replace( QRegExp("\\s"), "%20");
1029 titleString.replace( QRegExp("'"), "%20"); 1033 titleString.replace( QRegExp("'"), "%20");
@@ -1049,10 +1053,10 @@ void LibraryDialog::FindLibrary()
1049 newindexLib.setName( new_index); 1053 newindexLib.setName( new_index);
1050 indexLib.setName( new_index); 1054 indexLib.setName( new_index);
1051 qDebug("index file is "+ new_index); 1055 odebug << "index file is "+ new_index << oendl;
1052 Newlibrary(); 1056 Newlibrary();
1053 } else { 1057 } else {
1054 newindexLib.setName( old_index); 1058 newindexLib.setName( old_index);
1055 indexLib.setName( old_index); 1059 indexLib.setName( old_index);
1056 qDebug("new index nameis "+ old_index); 1060 odebug << "new index nameis "+ old_index << oendl;
1057 Library(); 1061 Library();
1058 } 1062 }