Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 88 |
1 files changed, 45 insertions, 43 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 | |||
@@ -11,25 +11,25 @@ | |||
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 | /* |
@@ -449,73 +449,76 @@ bool LibraryDialog::download_newEtext() | |||
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 | ||
459 | bool LibraryDialog::getEtext(const QStringList &networkList) | 459 | bool 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 | File_Name = s_fileName; | 477 | << s_fileName.latin1() << oendl; |
478 | return false; | ||
479 | } | ||
478 | 480 | ||
479 | //odebug << "Filename is now "+File_Name << oendl; | 481 | File_Name = s_fileName; |
480 | 482 | ||
481 | } | 483 | //odebug << "Filename is now "+File_Name << oendl; |
482 | if(File_Name.length() > 5 ) { | ||
483 | setTitle(); | ||
484 | QFileInfo fi(File_Name); | ||
485 | QString name_file = fi.fileName(); | ||
486 | name_file = name_file.left( name_file.length() - 4); | ||
487 | |||
488 | //odebug << "Setting doclink" << oendl; | ||
489 | DocLnk lnk; | ||
490 | //odebug << "name is "+name_file << oendl; | ||
491 | lnk.setName(name_file); //sets file name | ||
492 | //odebug << "Title is "+DlglistItemTitle << oendl; | ||
493 | lnk.setComment(DlglistItemTitle); | ||
494 | 484 | ||
495 | //odebug << "Filename is "+File_Name << oendl; | ||
496 | lnk.setFile(File_Name); //sets File property | ||
497 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
498 | lnk.setExec(File_Name); | ||
499 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | ||
500 | if(!lnk.writeLink()) { | ||
501 | //odebug << "Writing doclink did not work" << oendl; | ||
502 | } else { | ||
503 | } | 485 | } |
504 | } else | 486 | if(File_Name.length() > 5 ) { |
505 | QMessageBox::message("Note","<p>There was an error with the file</p>"); | 487 | setTitle(); |
506 | } | 488 | QFileInfo fi(File_Name); |
507 | } | 489 | QString name_file = fi.fileName(); |
490 | name_file = name_file.left( name_file.length() - 4); | ||
491 | |||
492 | //odebug << "Setting doclink" << oendl; | ||
493 | DocLnk lnk; | ||
494 | //odebug << "name is "+name_file << oendl; | ||
495 | lnk.setName(name_file); //sets file name | ||
496 | //odebug << "Title is "+DlglistItemTitle << oendl; | ||
497 | lnk.setComment(DlglistItemTitle); | ||
498 | |||
499 | //odebug << "Filename is "+File_Name << oendl; | ||
500 | lnk.setFile(File_Name); //sets File property | ||
501 | lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
502 | lnk.setExec(File_Name); | ||
503 | lnk.setIcon("gutenbrowser/Gutenbrowser"); | ||
504 | if(!lnk.writeLink()) { | ||
505 | //odebug << "Writing doclink did not work" << oendl; | ||
506 | } | ||
507 | } else | ||
508 | QMessageBox::message("Note","<p>There was an error with the file</p>"); | ||
509 | } | ||
510 | } | ||
508 | 511 | ||
509 | return true; | 512 | return true; |
510 | } | 513 | } |
511 | 514 | ||
512 | bool LibraryDialog::download_Etext() | 515 | bool 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"); |
@@ -692,25 +695,24 @@ void LibraryDialog::onButtonSearch() | |||
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; |