summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp6
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp2
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp4
-rw-r--r--noncore/apps/opie-gutenbrowser/helpme.cpp2
4 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 020a116..3c096ed 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -1,153 +1,153 @@
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 = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; 53 iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc";
54 54
55 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; 55 new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT";
56 56
57 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; 57 old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
59 59
60 // iniFile = local_library+"gutenbrowserrc"; 60 // iniFile = local_library+"gutenbrowserrc";
61 // new_index = local_library + "PGWHOLE.TXT"; 61 // new_index = local_library + "PGWHOLE.TXT";
62 // old_index = local_library + "GUTINDEX.ALL"; 62 // old_index = local_library + "GUTINDEX.ALL";
63 63
64 Config config("Gutenbrowser"); 64 Config config("Gutenbrowser");
65 65
66 config.setGroup( "HttpServer" ); 66 config.setGroup( "HttpServer" );
67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
68 68
69 config.setGroup( "FTPsite" ); 69 config.setGroup( "FTPsite" );
70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; 71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
72 // 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) );
73 // ftp_host=ftp_host.stripWhiteSpace(); 73 // ftp_host=ftp_host.stripWhiteSpace();
74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
75 75
76 i_binary = 0; 76 i_binary = 0;
77 77
78 config.setGroup("SortAuth"); 78 config.setGroup("SortAuth");
79 if( config.readEntry("authSort", "FALSE") == "TRUE") 79 if( config.readEntry("authSort", "FALSE") == "TRUE")
80 authBox->setChecked(TRUE); 80 authBox->setChecked(TRUE);
81 81
82 config.setGroup("General"); 82 config.setGroup("General");
83 downDir =config.readEntry( "DownloadDirectory",local_library); 83 downDir =config.readEntry( "DownloadDirectory",local_library);
84 odebug << "downDir is "+downDir << oendl; 84 odebug << "downDir is "+downDir << oendl;
85 newindexLib.setName( old_index); 85 newindexLib.setName( old_index);
86 indexLib.setName( old_index); 86 indexLib.setName( old_index);
87 87
88 new QPEDialogListener(this); 88 new QPEDialogListener(this);
89 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); 89 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) );
90 90
91} 91}
92 92
93LibraryDialog::~LibraryDialog() 93LibraryDialog::~LibraryDialog()
94{ 94{
95// delete QList_Item2; 95// delete QList_Item2;
96// delete QList_Item1; 96// delete QList_Item1;
97// delete QList_Item3; 97// delete QList_Item3;
98// delete QList_Item4; 98// delete QList_Item4;
99// delete QList_Item5; 99// delete QList_Item5;
100 100
101 // saveConfig(); 101 // saveConfig();
102} 102}
103 103
104 /*This groks using PGWHOLE.TXT */ 104 /*This groks using PGWHOLE.TXT */
105void LibraryDialog::Newlibrary() 105void LibraryDialog::Newlibrary()
106{ 106{
107#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 107#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
108 //odebug << "Opening new library index " << newindexLib << "" << oendl; 108 //odebug << "Opening new library index " << newindexLib << "" << oendl;
109 if ( newindexLib.open( IO_ReadOnly) ) { 109 if ( newindexLib.open( IO_ReadOnly) ) {
110 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 110 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
111 QTextStream indexStream( &newindexLib ); 111 QTextStream indexStream( &newindexLib );
112 QString indexLine; 112 QString indexLine;
113 while ( !indexStream.atEnd() ) { // until end of file.. 113 while ( !indexStream.atEnd() ) { // until end of file..
114 indexLine = indexStream.readLine(); 114 indexLine = indexStream.readLine();
115 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { 115 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
116 year = indexLine.mid(4,4); 116 year = indexLine.mid(4,4);
117 year = year.stripWhiteSpace(); 117 year = year.stripWhiteSpace();
118 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); 118 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 );
119 file = file.stripWhiteSpace(); 119 file = file.stripWhiteSpace();
120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
121 if( year.toInt() < 1984) 121 if( year.toInt() < 1984)
122 number = number.left( number.length() -1 ); 122 number = number.left( number.length() -1 );
123 number = number.stripWhiteSpace(); 123 number = number.stripWhiteSpace();
124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
125 title = title.stripWhiteSpace(); 125 title = title.stripWhiteSpace();
126 126
127 getAuthor(); // groks author 127 getAuthor(); // groks author
128 author = author.stripWhiteSpace(); 128 author = author.stripWhiteSpace();
129 if (authBox->isChecked()) { // this reverses the first name and last name of the author 129 if (authBox->isChecked()) { // this reverses the first name and last name of the author
130 // odebug << "Sorting last name first" << oendl; 130 // odebug << "Sorting last name first" << oendl;
131 QString lastName, firstName=""; 131 QString lastName, firstName="";
132 int finder=author.findRev( ' ', -1, TRUE); 132 int finder=author.findRev( ' ', -1, TRUE);
133 lastName=author.right( author.length()-finder); 133 lastName=author.right( author.length()-finder);
134 firstName=author.left(finder); 134 firstName=author.left(finder);
135 lastName=lastName.stripWhiteSpace(); 135 lastName=lastName.stripWhiteSpace();
136 firstName=firstName.stripWhiteSpace(); 136 firstName=firstName.stripWhiteSpace();
137 137
138 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 138 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
139 author=lastName+", "+firstName; 139 author=lastName+", "+firstName;
140 } 140 }
141 141
142 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { 142 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) {
143 143
144 // fill string list or something to be able to resort the whole library 144 // fill string list or something to be able to resort the whole library
145 if( author.isEmpty() ) 145 if( author.isEmpty() )
146 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 146 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
147 else { 147 else {
148 148
149 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 149 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
150 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 150 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
151 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); 151 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
152 152
153 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 153 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
index a9c7346..de9c72b 100644
--- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -1,137 +1,137 @@
1/*************************************************************************** 1/***************************************************************************
2 ftpsitedlg.cpp - description 2 ftpsitedlg.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 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 14
15#include "optionsDialog.h" 15#include "optionsDialog.h"
16#include "gutenbrowser.h" 16#include "gutenbrowser.h"
17//#include "NetworkDialog.h" 17//#include "NetworkDialog.h"
18#include "output.h" 18#include "output.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/odebug.h> 21#include <opie2/odebug.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24/* QT */ 24/* QT */
25#include <qprogressbar.h> 25#include <qprogressbar.h>
26#include <qurloperator.h> 26#include <qurloperator.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28 28
29/* STD */ 29/* STD */
30#include <stdlib.h> 30#include <stdlib.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <stdio.h> 32#include <stdio.h>
33 33
34// :)~ 34// :)~
35void optionsDialog::ftpSiteDlg( ) 35void optionsDialog::ftpSiteDlg( )
36{ 36{
37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); 37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" );
38// initDialog(); 38// initDialog();
39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40// ListFile = local_library + "ftpList"; 40// ListFile = local_library + "ftpList";
41 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser"; 41 ListFile = QPEApplication::qpeDir() + "etc/gutenbrowser";
42 QDir dir(ListFile); 42 QDir dir(ListFile);
43 if( !dir.exists()) 43 if( !dir.exists())
44 dir.mkdir(ListFile,true); 44 dir.mkdir(ListFile,true);
45 ListFile+="/ftpList"; 45 ListFile+="/ftpList";
46 odebug << "opening "+ListFile << oendl; 46 odebug << "opening "+ListFile << oendl;
47 if ( QFile(ListFile).exists() ) { 47 if ( QFile(ListFile).exists() ) {
48 openSiteList(); 48 openSiteList();
49 } else { 49 } else {
50 switch( QMessageBox::warning( this, "Gutenbrowser", 50 switch( QMessageBox::warning( this, "Gutenbrowser",
51 "Do you want to download \nan ftp site list?", 51 "Do you want to download \nan ftp site list?",
52 QMessageBox::Yes, QMessageBox::No)) { 52 QMessageBox::Yes, QMessageBox::No)) {
53 case QMessageBox::Yes: // yes 53 case QMessageBox::Yes: // yes
54 getSite(); 54 getSite();
55 break; 55 break;
56 case QMessageBox::No: // No 56 case QMessageBox::No: // No
57 // exit 57 // exit
58 break; 58 break;
59 } 59 }
60 60
61 } 61 }
62} 62}
63 63
64 64
65/* 65/*
66// get ftp list from web- parse it. */ 66// get ftp list from web- parse it. */
67void optionsDialog::getSite() 67void optionsDialog::getSite()
68{ 68{
69 QString file_name; 69 QString file_name;
70 QString ftp_listFileURL; 70 QString ftp_listFileURL;
71 QString outputFile; 71 QString outputFile;
72// outputFile = local_library+ "list.html"; 72// outputFile = local_library+ "list.html";
73 outputFile = ListFile + "list.html"; 73 outputFile = ListFile + "list.html";
74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; 74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html";
75//http://www.gutenberg.org/index.html"; 75//http://www.gutenberg.org/index.html";
76// QString networkUrl= "http://llornkcor.com/index.shtml"; 76// QString networkUrl= "http://llornkcor.com/index.shtml";
77// // "http://www.gutenberg.org/index.html" 77// // "http://www.gutenberg.org/index.html"
78// 78//
79//Qhttp stops working at times.... :( 79//Qhttp stops working at times.... :(
80// NetworkDialog *NetworkDlg; 80// NetworkDialog *NetworkDlg;
81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); 81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
82// if( NetworkDlg->exec() != 0 ) 82// if( NetworkDlg->exec() != 0 )
83// { // use new, improved, *INSTANT* network-dialog-file-getterer 83// { // use new, improved, *INSTANT* network-dialog-file-getterer
84// odebug << "gitcha!" << oendl; 84// odebug << "gitcha!" << oendl;
85// } 85// }
86// delete NetworkDlg; 86// delete NetworkDlg;
87//#ifdef Q_WS_QWS 87//#ifdef Q_WS_QWS
88 88
89// TODO qprocess here 89// TODO qprocess here
90 90
91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; 91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
92 odebug << "Issuing the command "+cmd << oendl; 92 odebug << "Issuing the command "+cmd << oendl;
93 Output *outDlg; 93 Output *outDlg;
94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); 94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
95 outDlg->showMaximized(); 95 outDlg->showMaximized();
96 outDlg->show(); 96 outDlg->show();
97 qApp->processEvents(); 97 qApp->processEvents();
98 FILE *fp; 98 FILE *fp;
99 char line[130]; 99 char line[130];
100 outDlg->OutputEdit->append( tr("Running wget") ); 100 outDlg->OutputEdit->append( tr("Running wget") );
101 sleep(1); 101 sleep(1);
102 fp = popen( (const char *) cmd, "r"); 102 fp = popen( (const char *) cmd, "r");
103 while ( fgets( line, sizeof line, fp)) { 103 while ( fgets( line, sizeof line, fp)) {
104 outDlg->OutputEdit->append(line); 104 outDlg->OutputEdit->append(line);
105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
106 } 106 }
107 pclose(fp); 107 pclose(fp);
108 outDlg->close(); 108 outDlg->close();
109 if(outDlg) 109 if(outDlg)
110 delete outDlg; 110 delete outDlg;
111 111
112// outputFile=ListFile; 112// outputFile=ListFile;
113 ftp_QListBox_1->clear(); 113 ftp_QListBox_1->clear();
114 parseFtpList( outputFile); // got the html list, now parse it so we can use it 114 parseFtpList( outputFile); // got the html list, now parse it so we can use it
115} 115}
116 116
117bool optionsDialog::parseFtpList( QString outputFile) 117bool optionsDialog::parseFtpList( QString outputFile)
118{ 118{
119// parse ftplist html and extract just the machine names/directories 119// parse ftplist html and extract just the machine names/directories
120// TODO: add locations!! 120// TODO: add locations!!
121 odebug << "parse ftplist "+outputFile << oendl; 121 odebug << "parse ftplist "+outputFile << oendl;
122 QString ftpList, s_location; 122 QString ftpList, s_location;
123 QFile f( outputFile ); 123 QFile f( outputFile );
124 124
125 if( f.open( IO_ReadWrite )) { 125 if( f.open( IO_ReadWrite )) {
126 QTextStream t( &f); 126 QTextStream t( &f);
127 QString countryName; 127 QString countryName;
128 bool b_gotchTest=false; 128 bool b_gotchTest=false;
129 129
130 while ( !t.eof() ) { 130 while ( !t.eof() ) {
131 QString s = t.readLine(); 131 QString s = t.readLine();
132 int start; 132 int start;
133 int end; 133 int end;
134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file 134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file
135 b_gotchTest = true; 135 b_gotchTest = true;
136 } 136 }
137 if( b_gotchTest) { 137 if( b_gotchTest) {
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index 644fae8..fac21da 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -49,198 +49,198 @@
49#include <qobjectlist.h> 49#include <qobjectlist.h>
50#include <qfontdialog.h> 50#include <qfontdialog.h>
51#include <qtextview.h> 51#include <qtextview.h>
52#include <qbrush.h> 52#include <qbrush.h>
53#include <qfile.h> 53#include <qfile.h>
54#include <qfontinfo.h> 54#include <qfontinfo.h>
55#include <qscrollview.h> 55#include <qscrollview.h>
56#include <qpoint.h> 56#include <qpoint.h>
57 57
58/* STD */ 58/* STD */
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <unistd.h> 61#include <unistd.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <fcntl.h> 63#include <fcntl.h>
64#include <errno.h> 64#include <errno.h>
65 65
66static const int nfontsizes = 9; 66static const int nfontsizes = 9;
67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; 67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
68 68
69#ifdef NOQUICKLAUNCH 69#ifdef NOQUICKLAUNCH
70Gutenbrowser::Gutenbrowser() 70Gutenbrowser::Gutenbrowser()
71 Gutenbrowser(); 71 Gutenbrowser();
72#else 72#else
73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) 73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
74#endif 74#endif
75 : QMainWindow() 75 : QMainWindow()
76{ 76{
77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
79 // e << ""; 79 // e << "";
80 // QPEApplication::grabKeyboard(); 80 // QPEApplication::grabKeyboard();
81 showMainList=TRUE; 81 showMainList=TRUE;
82 working=false; 82 working=false;
83 this->setUpdatesEnabled(TRUE); 83 this->setUpdatesEnabled(TRUE);
84 // #ifndef Q_WS_QWS 84 // #ifndef Q_WS_QWS
85 QString msg; 85 QString msg;
86 msg="You have now entered unto gutenbrowser,\n"; 86 msg="You have now entered unto gutenbrowser,\n";
87 msg+="make your self at home, sit back, relax and read something great.\n"; 87 msg+="make your self at home, sit back, relax and read something great.\n";
88 88
89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
90 setCaption("Gutenbrowser");// Embedded " VERSION); 90 setCaption("Gutenbrowser");// Embedded " VERSION);
91 this->setUpdatesEnabled(TRUE); 91 this->setUpdatesEnabled(TRUE);
92 92
93 // bool firstTime=FALSE; 93 // bool firstTime=FALSE;
94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); 94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
95 95
96 menu = new QHBoxLayout(-1,"menu"); 96 menu = new QHBoxLayout(-1,"menu");
97 buttons2 = new QHBoxLayout(-1,"buttons2"); 97 buttons2 = new QHBoxLayout(-1,"buttons2");
98 edits = new QHBoxLayout(-1,"edits"); 98 edits = new QHBoxLayout(-1,"edits");
99 99
100 useSplitter=TRUE; 100 useSplitter=TRUE;
101 101
102 initConfig(); 102 initConfig();
103 initMenuBar(); 103 initMenuBar();
104 initButtonBar(); 104 initButtonBar();
105 initStatusBar(); 105 initStatusBar();
106 initView(); 106 initView();
107 initSlots(); 107 initSlots();
108 qDebug("init finished"); 108 qDebug("init finished");
109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
110 110
111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), 111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); 112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
113 if( useIcons) 113 if( useIcons)
114 toggleButtonIcons( TRUE); 114 toggleButtonIcons( TRUE);
115 else 115 else
116 toggleButtonIcons( FALSE); 116 toggleButtonIcons( FALSE);
117 117
118 enableButtons(false); 118 enableButtons(false);
119 119
120 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
121 config.setGroup("General"); 121 config.setGroup("General");
122 122
123 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
125 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
126 126
127 QString tempFileName; 127 QString tempFileName;
128 128
129 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
130 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
131 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
132 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
133 133
134 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
135 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
136 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
137 int index = config.readNumEntry( "LineNumber", -1 ); 137 int index = config.readNumEntry( "LineNumber", -1 );
138 if( index != -1) { 138 if( index != -1) {
139 odebug << tempTitle << oendl; 139 odebug << tempTitle << oendl;
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"; 145 QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL";
146 qDebug("gutenindex "+gutenIndex ); 146 qDebug("gutenindex "+gutenIndex );
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 = QPEApplication::qpeDir()+ "etc/gutenbrowser/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");
155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
156 loadCheck = false; 156 loadCheck = false;
157 chdir(local_library); 157 chdir(local_library);
158 if(!showMainList) { 158 if(!showMainList) {
159 Lview->setFocus(); 159 Lview->setFocus();
160 // if(firstTime) 160 // if(firstTime)
161 // Bookmark(); 161 // Bookmark();
162 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
163 qDebug("Suppose we open somethin"); 163 qDebug("Suppose we open somethin");
164 if(!load(qApp->argv()[i])) return; 164 if(!load(qApp->argv()[i])) return;
165 } 165 }
166 } else { 166 } else {
167 fillWithTitles(); 167 fillWithTitles();
168 mainList->setFocus(); 168 mainList->setFocus();
169 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
170 170
171 } 171 }
172 writeConfig(); 172 writeConfig();
173 QTimer::singleShot( 250, this, SLOT(hideView()) ); 173 QTimer::singleShot( 250, this, SLOT(hideView()) );
174} //end init 174} //end init
175 175
176Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
177 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
178 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
179 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
180} 180}
181 181
182 /* 182 /*
183 Google.com search */ 183 Google.com search */
184void Gutenbrowser::InfoBarClick() { 184void Gutenbrowser::InfoBarClick() {
185 QString text; 185 QString text;
186 if( Lview->hasSelectedText()) { 186 if( Lview->hasSelectedText()) {
187 Lview->copy(); 187 Lview->copy();
188 QClipboard *cb = QApplication::clipboard(); 188 QClipboard *cb = QApplication::clipboard();
189 text = cb->text(); 189 text = cb->text();
190 } else { 190 } else {
191 // text=title; 191 // text=title;
192 text=this->caption(); 192 text=this->caption();
193 } 193 }
194 searchGoogle(text); 194 searchGoogle(text);
195} 195}
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; 200 // int eexit=0;
201 QString cmd; 201 QString cmd;
202 // config.read(); 202 // config.read();
203 qApp->processEvents(); 203 qApp->processEvents();
204 QString filename = QPEApplication::qpeDir(); 204 QString filename = QPEApplication::qpeDir();
205 if(filename.right(1)!="/") 205 if(filename.right(1)!="/")
206 filename+="/etc/gutenbrowser/"; 206 filename+="/etc/gutenbrowser/";
207 else 207 else
208 filename+="etc/gutenbrowser/"; 208 filename+="etc/gutenbrowser/";
209 odebug << "filename "+filename << oendl; 209 odebug << "filename "+filename << oendl;
210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; 210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
211 211
212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
213 213
214 Config config("Gutenbrowser"); 214 Config config("Gutenbrowser");
215 config.setGroup( "Browser" ); 215 config.setGroup( "Browser" );
216 QString brow = config.readEntry("Preferred", "Opera"); 216 QString brow = config.readEntry("Preferred", "Opera");
217 odebug << "Preferred browser is "+brow << oendl; 217 odebug << "Preferred browser is "+brow << oendl;
218 if(!showMsg) { //if we just get the gutenindex.all 218 if(!showMsg) { //if we just get the gutenindex.all
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 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); 224 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
225 outDlg->showMaximized(); 225 outDlg->showMaximized();
226 outDlg->show(); 226 outDlg->show();
227 qApp->processEvents(); 227 qApp->processEvents();
228 FILE *fp; 228 FILE *fp;
229 char line[130]; 229 char line[130];
230 outDlg->OutputEdit->append( tr("Running wget") ); 230 outDlg->OutputEdit->append( tr("Running wget") );
231 sleep(1); 231 sleep(1);
232 fp = popen( (const char *) cmd, "r"); 232 fp = popen( (const char *) cmd, "r");
233 odebug << "Issuing the command\n"+cmd << oendl; 233 odebug << "Issuing the command\n"+cmd << oendl;
234 // system(cmd); 234 // system(cmd);
235 while ( fgets( line, sizeof line, fp)) { 235 while ( fgets( line, sizeof line, fp)) {
236 outDlg->OutputEdit->append(line); 236 outDlg->OutputEdit->append(line);
237// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 237// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
238 } 238 }
239 pclose(fp); 239 pclose(fp);
240 outDlg->close(); 240 outDlg->close();
241 if(outDlg) 241 if(outDlg)
242 delete outDlg; 242 delete outDlg;
243 } else { 243 } else {
244 if( brow == "Konq") { 244 if( brow == "Konq") {
245 cmd = "konqueror "+url+" &"; 245 cmd = "konqueror "+url+" &";
246 } 246 }
diff --git a/noncore/apps/opie-gutenbrowser/helpme.cpp b/noncore/apps/opie-gutenbrowser/helpme.cpp
index 53e0236..0e23114 100644
--- a/noncore/apps/opie-gutenbrowser/helpme.cpp
+++ b/noncore/apps/opie-gutenbrowser/helpme.cpp
@@ -1,127 +1,127 @@
1/*************************************************************************** 1/***************************************************************************
2 helpme.cpp - description 2 helpme.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 begin : Sat Dec 4 1999 5 begin : Sat Dec 4 1999
6 copyright : (C) 2000 -2004 by llornkcor 6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com 7 email : ljp@llornkcor.com
8 ***************************************************************************/ 8 ***************************************************************************/
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "helpme.h" 18#include "helpme.h"
19#include "helpwindow.h" 19#include "helpwindow.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25 25
26/* QT */ 26/* QT */
27#include <qprogressdialog.h> 27#include <qprogressdialog.h>
28#include <qlayout.h> 28#include <qlayout.h>
29 29
30/* STD */ 30/* STD */
31#include <sys/stat.h> 31#include <sys/stat.h>
32#include <unistd.h> 32#include <unistd.h>
33 33
34HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name) 34HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name)
35{ 35{
36 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/"; 36 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/";
37 setCaption(tr("Gutenbrowser About " VERSION)); 37 setCaption(tr("Gutenbrowser About " VERSION));
38 38
39 QGridLayout *layout = new QGridLayout( this ); 39 QGridLayout *layout = new QGridLayout( this );
40 layout->setSpacing( 4 ); 40 layout->setSpacing( 4 );
41 layout->setMargin( 4 ); 41 layout->setMargin( 4 );
42 42
43 Edit = new QMultiLineEdit(this, ""); 43 Edit = new QMultiLineEdit(this, "");
44 Edit->setReadOnly(true); 44 Edit->setReadOnly(true);
45 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org")); 45 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org"));
46 Edit->append(tr("Much appreciation to Lee Burgess,")); 46 Edit->append(tr("Much appreciation to Lee Burgess,"));
47 Edit->append(tr("for the original idea and concept of gutenbook.\n")); 47 Edit->append(tr("for the original idea and concept of gutenbook.\n"));
48 Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n")); 48 Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n"));
49 Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email")); 49 Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email"));
50 Edit->append(tr("ljp@llornkcor.com\n")); 50 Edit->append(tr("ljp@llornkcor.com\n"));
51 Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n")); 51 Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n"));
52 Edit->append(tr("Arnold's Laws of Documentation:")); 52 Edit->append(tr("Arnold's Laws of Documentation:"));
53 Edit->append(tr("(1) If it should exist, it doesn't.")); 53 Edit->append(tr("(1) If it should exist, it doesn't."));
54 Edit->append(tr("(2) If it does exist, it's out of date.")); 54 Edit->append(tr("(2) If it does exist, it's out of date."));
55 Edit->append(tr("(3) Only documentation for")); 55 Edit->append(tr("(3) Only documentation for"));
56 Edit->append(tr("useless programs transcends the")); 56 Edit->append(tr("useless programs transcends the"));
57 Edit->append(tr("first two laws.\n")); 57 Edit->append(tr("first two laws.\n"));
58 Edit->append(tr("Everything is temporary, anyway....\n :o)")); 58 Edit->append(tr("Everything is temporary, anyway....\n :o)"));
59 Edit->setWordWrap(QMultiLineEdit::WidgetWidth); 59 Edit->setWordWrap(QMultiLineEdit::WidgetWidth);
60 QString pixDir; 60 QString pixDir;
61 pixDir=QPEApplication::qpeDir()+"/pics/"; 61 pixDir=QPEApplication::qpeDir()+"pics/";
62 QPushButton *help; 62 QPushButton *help;
63 help = new QPushButton(this); 63 help = new QPushButton(this);
64 help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png")); 64 help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png"));
65 help->setText("Help"); 65 help->setText("Help");
66 connect( help,SIGNAL(clicked()),this,SLOT( help() )); 66 connect( help,SIGNAL(clicked()),this,SLOT( help() ));
67 67
68/* QPushButton *ok; 68/* QPushButton *ok;
69 ok = new QPushButton(this); 69 ok = new QPushButton(this);
70 ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png")); 70 ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png"));
71 ok->setText("ok"); 71 ok->setText("ok");
72 connect(ok,SIGNAL(clicked()),this,SLOT(accept() )); 72 connect(ok,SIGNAL(clicked()),this,SLOT(accept() ));
73*/ 73*/
74 help->setFixedHeight(25); 74 help->setFixedHeight(25);
75// ok->setFixedHeight(25); 75// ok->setFixedHeight(25);
76 76
77// layout->addMultiCellWidget( ok, 0, 0, 4, 4 ); 77// layout->addMultiCellWidget( ok, 0, 0, 4, 4 );
78 layout->addMultiCellWidget( help, 0, 0, 4, 4 ); 78 layout->addMultiCellWidget( help, 0, 0, 4, 4 );
79 layout->addMultiCellWidget( Edit, 1, 1, 0, 4 ); 79 layout->addMultiCellWidget( Edit, 1, 1, 0, 4 );
80} 80}
81 81
82HelpMe::~HelpMe() 82HelpMe::~HelpMe()
83{ 83{
84//delete Edit; 84//delete Edit;
85 85
86} 86}
87 87
88void HelpMe::goToURL() 88void HelpMe::goToURL()
89{ 89{
90 90
91 url = "http://www.llornkcor.com/"; 91 url = "http://www.llornkcor.com/";
92 goGetit( url); 92 goGetit( url);
93} 93}
94 94
95void HelpMe::goToURL2() 95void HelpMe::goToURL2()
96{ 96{
97 url = "http://www.gutenberg.org"; 97 url = "http://www.gutenberg.org";
98 goGetit( url); 98 goGetit( url);
99} 99}
100 100
101void HelpMe::goToURL3() 101void HelpMe::goToURL3()
102{ 102{
103 url = "http://www.gutenbook.org"; 103 url = "http://www.gutenbook.org";
104 goGetit( url); 104 goGetit( url);
105} 105}
106 106
107void HelpMe::goGetit( QString url) 107void HelpMe::goGetit( QString url)
108{ 108{
109 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser"); 109 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser");
110 help->setCaption("Qt Example - Helpviewer"); 110 help->setCaption("Qt Example - Helpviewer");
111 help->showMaximized(); 111 help->showMaximized();
112 help->show(); 112 help->show();
113} 113}
114 114
115void HelpMe::help() 115void HelpMe::help()
116{ 116{
117 QString msg ; 117 QString msg ;
118 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be 118 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be
119odebug << msg << oendl; 119odebug << msg << oendl;
120 QString url = "file://"+msg; 120 QString url = "file://"+msg;
121 goGetit( url); 121 goGetit( url);
122 122
123// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" ); 123// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" );
124// e << msg; 124// e << msg;
125 125
126// goGetit( msg); 126// goGetit( msg);
127} 127}