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.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 6c246e97..7f21ab3 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -1,71 +1,71 @@
1/*************************************************************************** 1/***************************************************************************
2// LibraryDialog.cpp - description 2// LibraryDialog.cpp - description
3// ------------------- 3// -------------------
4// begin : Sat Aug 19 2000 4// begin : Sat Aug 19 2000
5// copyright : (C) 2000 - 2004 by llornkcor 5// copyright : (C) 2000 - 2004 by llornkcor
6// email : ljp@llornkcor.com 6// email : ljp@llornkcor.com
7// ***************************************************/ 7// ***************************************************/
8// /*************************************************************************** 8// /***************************************************************************
9// * This program is free software; you can redistribute it and/or modify * 9// * This program is free software; you can redistribute it and/or modify *
10// * it under the terms of the GNU General Public License as published by * 10// * it under the terms of the GNU General Public License as published by *
11// * the Free Software Foundation; either version 2 of the License, or * 11// * the Free Software Foundation; either version 2 of the License, or *
12// * (at your option) any later version. * 12// * (at your option) any later version. *
13// ***************************************************************************/ 13// ***************************************************************************/
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" 16#include "LibraryDialog.h"
17#include "output.h" 17#include "output.h"
18 18
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>
28//#include <qlayout.h> 28//#include <qlayout.h>
29 29
30/* STD */ 30/* STD */
31#include <unistd.h> 31#include <unistd.h>
32#include <stdio.h> 32#include <stdio.h>
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 = local_library + "/gutenbrowserrc"; 53 iniFile = local_library + "/gutenbrowserrc";
54 new_index = local_library + "/PGWHOLE.TXT"; 54 new_index = local_library + "/PGWHOLE.TXT";
55 old_index = local_index; 55 old_index = local_index;
56 // iniFile = local_library+"gutenbrowserrc"; 56 // iniFile = local_library+"gutenbrowserrc";
57 // new_index = local_library + "PGWHOLE.TXT"; 57 // new_index = local_library + "PGWHOLE.TXT";
58 // old_index = local_library + "GUTINDEX.ALL"; 58 // old_index = local_library + "GUTINDEX.ALL";
59 59
60 Config config("Gutenbrowser"); 60 Config config("Gutenbrowser");
61 61
62 config.setGroup( "HttpServer" ); 62 config.setGroup( "HttpServer" );
63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 63 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
64 64
65 config.setGroup( "FTPsite" ); 65 config.setGroup( "FTPsite" );
66 ftp_host = config.readEntry("SiteName", "sailor.gutenberg.org"); 66 ftp_host = config.readEntry("SiteName", "sailor.gutenberg.org");
67 //odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; 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) ); 68 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,true)+1) );
69 // ftp_host=ftp_host.stripWhiteSpace(); 69 // ftp_host=ftp_host.stripWhiteSpace();
70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 70 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
71 71
@@ -427,124 +427,127 @@ bool LibraryDialog::download_newEtext()
427 int stringlength = DlglistItemFile.length(); 427 int stringlength = DlglistItemFile.length();
428 for(i = 0; i < stringlength - 1; i++ ) { 428 for(i = 0; i < stringlength - 1; i++ ) {
429 directory += "/"+ DlglistItemFile[i]; 429 directory += "/"+ DlglistItemFile[i];
430 } 430 }
431 431
432 directory += "/" + DlglistItemFile; 432 directory += "/" + DlglistItemFile;
433 433
434// qWarning(directory); 434// qWarning(directory);
435 435
436 Config cfg("Gutenbrowser"); 436 Config cfg("Gutenbrowser");
437 cfg.setGroup("FTPsite"); 437 cfg.setGroup("FTPsite");
438 ftp_host = cfg.readEntry("SiteName", "sailor.gutenberg.org"); 438 ftp_host = cfg.readEntry("SiteName", "sailor.gutenberg.org");
439 ftp_base_dir = cfg.readEntry("base", "/pub/gutenberg"); 439 ftp_base_dir = cfg.readEntry("base", "/pub/gutenberg");
440 440
441 if( ftp_base_dir.find("=",0,true) ) 441 if( ftp_base_dir.find("=",0,true) )
442 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); 442 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
443 443
444 QString dir = ftp_base_dir + directory; 444 QString dir = ftp_base_dir + directory;
445 QString outputFile = local_library + ".guten_temp"; 445 QString outputFile = local_library + ".guten_temp";
446 QString file = fileName + ".txt"; 446 QString file = fileName + ".txt";
447 447
448 QStringList networkList; 448 QStringList networkList;
449 networkList.append((const char *)ftp_host); //host 449 networkList.append((const char *)ftp_host); //host
450 networkList.append((const char *)dir); //ftp base directory 450 networkList.append((const char *)dir); //ftp base directory
451 networkList.append((const char *)outputFile); //output filepath 451 networkList.append((const char *)outputFile); //output filepath
452 networkList.append((const char *)file); //filename 452 networkList.append((const char *)file); //filename
453 453
454 getEtext( networkList); 454 getEtext( networkList);
455 455
456 return true; 456 return true;
457} 457}
458 458
459bool LibraryDialog::getEtext(const QStringList &networkList) 459bool LibraryDialog::getEtext(const QStringList &networkList)
460{ 460{
461 NetworkDialog *NetworkDlg; 461 NetworkDialog *NetworkDlg;
462 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList); 462 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList);
463 463
464// use new, improved, *INSTANT* network-dialog-file-getterer 464// use new, improved, *INSTANT* network-dialog-file-getterer
465 if( NetworkDlg->exec() != 0 ) { 465 if( NetworkDlg->exec() != 0 ) {
466 File_Name = NetworkDlg->localFileName; 466 File_Name = NetworkDlg->localFileName;
467 467
468 qDebug("Just downloaded " + NetworkDlg->localFileName); 468 qDebug("Just downloaded " + NetworkDlg->localFileName);
469 469
470 if(NetworkDlg->successDownload) { 470 if(NetworkDlg->successDownload) {
471 //odebug << "Filename is "+File_Name << oendl; 471 //odebug << "Filename is "+File_Name << oendl;
472 if(File_Name.right(4) == ".txt") { 472 if(File_Name.right(4) == ".txt") {
473 QString s_fileName = File_Name; 473 QString s_fileName = File_Name;
474 s_fileName.replace( s_fileName.length() - 3, 3, "gtn"); 474 s_fileName.replace( s_fileName.length() - 3, 3, "gtn");
475 // s_fileName.replace( s_fileName.length()-3,3,"etx"); 475 if (rename( File_Name.latin1(), s_fileName.latin1()) == 1) {
476 rename( File_Name.latin1(), s_fileName.latin1()); 476 owarn << "Failed to rename " << File_Name.latin1() << " to "
477 << s_fileName.latin1() << oendl;
478 return false;
479 }
480
477 File_Name = s_fileName; 481 File_Name = s_fileName;
478 482
479 //odebug << "Filename is now "+File_Name << oendl; 483 //odebug << "Filename is now "+File_Name << oendl;
480 484
481 } 485 }
482 if(File_Name.length() > 5 ) { 486 if(File_Name.length() > 5 ) {
483 setTitle(); 487 setTitle();
484 QFileInfo fi(File_Name); 488 QFileInfo fi(File_Name);
485 QString name_file = fi.fileName(); 489 QString name_file = fi.fileName();
486 name_file = name_file.left( name_file.length() - 4); 490 name_file = name_file.left( name_file.length() - 4);
487 491
488 //odebug << "Setting doclink" << oendl; 492 //odebug << "Setting doclink" << oendl;
489 DocLnk lnk; 493 DocLnk lnk;
490 //odebug << "name is "+name_file << oendl; 494 //odebug << "name is "+name_file << oendl;
491 lnk.setName(name_file); //sets file name 495 lnk.setName(name_file); //sets file name
492 //odebug << "Title is "+DlglistItemTitle << oendl; 496 //odebug << "Title is "+DlglistItemTitle << oendl;
493 lnk.setComment(DlglistItemTitle); 497 lnk.setComment(DlglistItemTitle);
494 498
495 //odebug << "Filename is "+File_Name << oendl; 499 //odebug << "Filename is "+File_Name << oendl;
496 lnk.setFile(File_Name); //sets File property 500 lnk.setFile(File_Name); //sets File property
497 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 501 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
498 lnk.setExec(File_Name); 502 lnk.setExec(File_Name);
499 lnk.setIcon("gutenbrowser/Gutenbrowser"); 503 lnk.setIcon("gutenbrowser/Gutenbrowser");
500 if(!lnk.writeLink()) { 504 if(!lnk.writeLink()) {
501 //odebug << "Writing doclink did not work" << oendl; 505 //odebug << "Writing doclink did not work" << oendl;
502 } else {
503 } 506 }
504 } else 507 } else
505 QMessageBox::message("Note","<p>There was an error with the file</p>"); 508 QMessageBox::message("Note","<p>There was an error with the file</p>");
506 } 509 }
507 } 510 }
508 511
509 return true; 512 return true;
510} 513}
511 514
512bool LibraryDialog::download_Etext() 515bool LibraryDialog::download_Etext()
513{ // ftp method 516{ // ftp method
514 // might have to use old gpl'd ftp for embedded!! 517 // might have to use old gpl'd ftp for embedded!!
515 518
516 Config cfg("Gutenbrowser"); 519 Config cfg("Gutenbrowser");
517 cfg.setGroup("FTPsite"); 520 cfg.setGroup("FTPsite");
518 ftp_host = cfg.readEntry("SiteName", "sailor.gutenberg.org"); 521 ftp_host = cfg.readEntry("SiteName", "sailor.gutenberg.org");
519 ftp_base_dir = cfg.readEntry("base", "/pub/gutenberg"); 522 ftp_base_dir = cfg.readEntry("base", "/pub/gutenberg");
520 523
521 qDebug( "about to network dialog"); 524 qDebug( "about to network dialog");
522 525
523 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, /*networkUrl, */outputFile; 526 QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, /*networkUrl, */outputFile;
524 527
525 //////////////////// FIXME- if 'x' is part of real name.... 528 //////////////////// FIXME- if 'x' is part of real name....
526 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).find("x", 1, false)); 529 NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, false)).find("x", 1, false));
527 530
528 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,true) ==-1 ) { 531 if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,true) ==-1 ) {
529 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4)); 532 NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
530 qDebug("NewlistItemFile is now " + NewlistItemFile); 533 qDebug("NewlistItemFile is now " + NewlistItemFile);
531 } 534 }
532 535
533 NewlistItemYear = DlglistItemYear.right(2); 536 NewlistItemYear = DlglistItemYear.right(2);
534 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10); 537 int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
535 //odebug << NewlistItemYear << oendl; 538 //odebug << NewlistItemYear << oendl;
536 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) { 539 if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
537 NewlistItemYear = "90"; 540 NewlistItemYear = "90";
538 } 541 }
539 542
540 Edir ="etext" +NewlistItemYear; 543 Edir ="etext" +NewlistItemYear;
541 544
542 dir = ftp_base_dir + "/etext" + NewlistItemYear + "/"; 545 dir = ftp_base_dir + "/etext" + NewlistItemYear + "/";
543 546
544 if( ftp_base_dir.find("=",0,true) ) 547 if( ftp_base_dir.find("=",0,true) )
545 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1); 548 ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
546 549
547// networkUrl = "ftp://"+ftp_host+dir; 550// networkUrl = "ftp://"+ftp_host+dir;
548 551
549 outputFile = local_library+".guten_temp"; 552 outputFile = local_library+".guten_temp";
550 553
@@ -656,97 +659,96 @@ bool LibraryDialog::setTitle()
656} 659}
657 660
658 661
659void LibraryDialog::saveConfig() 662void LibraryDialog::saveConfig()
660{ 663{
661 Config config("Gutenbrowser"); 664 Config config("Gutenbrowser");
662 if( httpBox->isChecked() == true) { 665 if( httpBox->isChecked() == true) {
663 checked = 1; 666 checked = 1;
664 config.setGroup( "Proxy" ); 667 config.setGroup( "Proxy" );
665 config.writeEntry("IsChecked", "true"); 668 config.writeEntry("IsChecked", "true");
666 } else { 669 } else {
667 checked = 0; 670 checked = 0;
668 config.setGroup( "Proxy" ); 671 config.setGroup( "Proxy" );
669 config.writeEntry("IsChecked", "false"); 672 config.writeEntry("IsChecked", "false");
670 } 673 }
671 if (authBox->isChecked() == true) { 674 if (authBox->isChecked() == true) {
672 config.setGroup("SortAuth"); 675 config.setGroup("SortAuth");
673 config.writeEntry("authSort", "true"); 676 config.writeEntry("authSort", "true");
674 } else { 677 } else {
675 config.setGroup("SortAuth"); 678 config.setGroup("SortAuth");
676 config.writeEntry("authSort", "false"); 679 config.writeEntry("authSort", "false");
677 } 680 }
678 // config.write(); 681 // config.write();
679} 682}
680 683
681/* 684/*
682 searches library index for user word*/ 685 searches library index for user word*/
683void LibraryDialog::onButtonSearch() 686void LibraryDialog::onButtonSearch()
684{ 687{
685 ListView1->clearSelection(); 688 ListView1->clearSelection();
686 ListView2->clearSelection(); 689 ListView2->clearSelection();
687 ListView3->clearSelection(); 690 ListView3->clearSelection();
688 ListView4->clearSelection(); 691 ListView4->clearSelection();
689 ListView5->clearSelection(); 692 ListView5->clearSelection();
690 693
691 int curTab = tabWidget->currentPageIndex(); 694 int curTab = tabWidget->currentPageIndex();
692 SearchDialog* searchDlg; 695 SearchDialog* searchDlg;
693 696
694 // if( resultsList) 697 // if( resultsList)
695 searchDlg = new SearchDialog( this, "Library Search", true); 698 searchDlg = new SearchDialog( this, "Library Search", true);
696 searchDlg->setCaption( tr( "Library Search" ) ); 699 searchDlg->setCaption( tr( "Library Search" ) );
697 searchDlg->setLabel( "- author or title"); 700 searchDlg->setLabel( "- author or title");
698 701
699 QString resultString; 702 QString resultString;
700 703
701 int i_berger = 0; 704 int i_berger = 0;
702 if( searchDlg->exec() != 0 ) { 705 if( searchDlg->exec() != 0 ) {
703 QString searcherStr = searchDlg->get_text(); 706 QString searcherStr = searchDlg->get_text();
704 int fluff = 0;
705 707
706 bool cS; 708 bool cS;
707 if( searchDlg->caseSensitiveCheckBox->isChecked()) 709 if( searchDlg->caseSensitiveCheckBox->isChecked())
708 cS = true; //case sensitive 710 cS = true; //case sensitive
709 else 711 else
710 cS = false; 712 cS = false;
711 713
712 etext etextStruct; 714 etext etextStruct;
713 QValueList<etext>::Iterator it; 715 QValueList<etext>::Iterator it;
714 716
715 for( it = etextLibrary.begin(); it != etextLibrary.end(); ++it ) { 717 for( it = etextLibrary.begin(); it != etextLibrary.end(); ++it ) {
716 QString tempTitle = (*it).title; 718 QString tempTitle = (*it).title;
717 QString tempAuthor = (*it).author; 719 QString tempAuthor = (*it).author;
718 QString tempFile = (*it).file; 720 QString tempFile = (*it).file;
719 QString tempYear = (*it).year; 721 QString tempYear = (*it).year;
720 if(tempTitle.find( searcherStr, 0, cS) != -1 722 if(tempTitle.find( searcherStr, 0, cS) != -1
721 || tempAuthor.find( searcherStr, 0, cS) != -1) { 723 || tempAuthor.find( searcherStr, 0, cS) != -1) {
722 qWarning(tempTitle); 724 qWarning(tempTitle);
723 Searchlist.append( tempTitle + " : " + tempYear + " : " + tempFile); 725 Searchlist.append( tempTitle + " : " + tempYear + " : " + tempFile);
724 } 726 }
725 } 727 }
726 728
727 729
728 tabWidget->setCurrentPage( curTab); 730 tabWidget->setCurrentPage( curTab);
729 731
730 Searchlist.sort(); 732 Searchlist.sort();
731 SearchResultsDlg* SearchResultsDialog; 733 SearchResultsDlg* SearchResultsDialog;
732 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist); 734 SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
733 735
734 SearchResultsDialog->showMaximized(); 736 SearchResultsDialog->showMaximized();
735 if( SearchResultsDialog->exec() != 0) { 737 if( SearchResultsDialog->exec() != 0) {
736 texter = SearchResultsDialog->selText; 738 texter = SearchResultsDialog->selText;
737 // //odebug << texter << oendl; 739 // //odebug << texter << oendl;
738 resultLs = SearchResultsDialog->resultsList; 740 resultLs = SearchResultsDialog->resultsList;
739 i_berger = 1; 741 i_berger = 1;
740 } else { 742 } else {
741 resultLs.clear(); 743 resultLs.clear();
742 } 744 }
743 Searchlist.clear(); 745 Searchlist.clear();
744 746
745 QString tester; 747 QString tester;
746 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) { 748 for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
747 texter.sprintf("%s \n",(*it).latin1()); 749 texter.sprintf("%s \n",(*it).latin1());
748 // //odebug << texter << oendl; 750 // //odebug << texter << oendl;
749 if( tester!=texter) 751 if( tester!=texter)
750 parseSearchResults( texter); 752 parseSearchResults( texter);
751 tester = texter; 753 tester = texter;
752 } 754 }