summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/browserDialog.cpp9
-rw-r--r--noncore/apps/opie-gutenbrowser/config.in6
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.cpp35
-rw-r--r--noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro9
4 files changed, 32 insertions, 27 deletions
diff --git a/noncore/apps/opie-gutenbrowser/browserDialog.cpp b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
index 5c48da1..81dd516 100644
--- a/noncore/apps/opie-gutenbrowser/browserDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/browserDialog.cpp
@@ -1,83 +1,86 @@
1/**************************************************************************** 1/****************************************************************************
2copyright 2001 by L.J. Potter ljp@llornkcor.com 2copyright 2001 by L.J. Potter ljp@llornkcor.com
3 copyright : (C) 2000 -2004 by llornkcor 3 copyright : (C) 2000 -2004 by llornkcor
4 email : ljp@llornkcor.com 4 email : ljp@llornkcor.com
5 5
6****************************************************************************/ 6****************************************************************************/
7 7
8#include "optionsDialog.h" 8#include "optionsDialog.h"
9//#include "fileBrowser.h" 9//#include "fileBrowser.h"
10 10
11/* OPIE */
12#include <opie2/ofiledialog.h>
13using namespace Opie::Ui;
14
15/* QT */
11#include <qlabel.h> 16#include <qlabel.h>
12#include <qlistbox.h> 17#include <qlistbox.h>
13#include <qpushbutton.h> 18#include <qpushbutton.h>
14#include <qlayout.h> 19#include <qlayout.h>
15 20
16#include <opie/ofiledialog.h>
17
18void optionsDialog::BrowserDlg( ) 21void optionsDialog::BrowserDlg( )
19{ 22{
20// setCaption( tr( "Choose Browser" ) ); 23// setCaption( tr( "Choose Browser" ) );
21 http_ListBox1->insertItem( tr( "Opera")); 24 http_ListBox1->insertItem( tr( "Opera"));
22 http_ListBox1->insertItem( tr( "Konqueror")); 25 http_ListBox1->insertItem( tr( "Konqueror"));
23 http_ListBox1->insertItem( tr( "wget")); 26 http_ListBox1->insertItem( tr( "wget"));
24} 27}
25 28
26void optionsDialog::select_title(int) { 29void optionsDialog::select_title(int) {
27 browserName = http_ListBox1->currentText(); 30 browserName = http_ListBox1->currentText();
28 Config config("Gutenbrowser"); 31 Config config("Gutenbrowser");
29 config.setGroup( "Browser" ); 32 config.setGroup( "Browser" );
30 printf("Brow is: "+browserName+"\n"); 33 printf("Brow is: "+browserName+"\n");
31 config.writeEntry("Preferred", browserName); 34 config.writeEntry("Preferred", browserName);
32 TextLabel3_3->setText( "Current http browser: "+browserName ); 35 TextLabel3_3->setText( "Current http browser: "+browserName );
33} 36}
34 37
35void optionsDialog::BrowseSelected() { 38void optionsDialog::BrowseSelected() {
36 QString fileName; 39 QString fileName;
37 Config cfg("Gutenbrowser"); 40 Config cfg("Gutenbrowser");
38 cfg. setGroup ( "View" ); 41 cfg. setGroup ( "View" );
39 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); 42 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
40 QMap<QString, QStringList> map; 43 QMap<QString, QStringList> map;
41 map.insert(tr("All"), QStringList() ); 44 map.insert(tr("All"), QStringList() );
42 QStringList text; 45 QStringList text;
43 text << "text/*"; 46 text << "text/*";
44 map.insert(tr("Text"), text ); 47 map.insert(tr("Text"), text );
45 text << "*"; 48 text << "*";
46 map.insert(tr("All"), text ); 49 map.insert(tr("All"), text );
47 50
48 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); 51 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
49 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { 52 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
50 fileName = str; 53 fileName = str;
51// QStringList fileList=browseForFiles->fileList; 54// QStringList fileList=browseForFiles->fileList;
52// qDebug(selFile); 55// qDebug(selFile);
53// QStringList::ConstIterator f; 56// QStringList::ConstIterator f;
54// QString fileTemp,filer; 57// QString fileTemp,filer;
55// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 58// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
56 59
57// fileTemp = *f; 60// fileTemp = *f;
58// fileTemp.right( fileTemp.length()-5); 61// fileTemp.right( fileTemp.length()-5);
59// fileName = fileTemp; 62// fileName = fileTemp;
60// if( !fileName.isEmpty() ){ 63// if( !fileName.isEmpty() ){
61// filer = fileName; 64// filer = fileName;
62// } else { 65// } else {
63// QString sMsg; 66// QString sMsg;
64// sMsg = "Error opening library filelist "+fileName; 67// sMsg = "Error opening library filelist "+fileName;
65// } 68// }
66 if ( !fileName.isNull() ) { // got a file name 69 if ( !fileName.isNull() ) { // got a file name
67 // ... 70 // ...
68 } 71 }
69 } 72 }
70 73
71} 74}
72 75
73void optionsDialog::setHttp(int index) { 76void optionsDialog::setHttp(int index) {
74 Config config("Gutenbrowser"); 77 Config config("Gutenbrowser");
75 config.setGroup( "HttpServer" ); 78 config.setGroup( "HttpServer" );
76 qDebug("writing http server"); 79 qDebug("writing http server");
77 if( index== 0) { 80 if( index== 0) {
78 config.writeEntry("Preferred", "http://sailor.gutenberg.org"); 81 config.writeEntry("Preferred", "http://sailor.gutenberg.org");
79 } else { 82 } else {
80 config.writeEntry("Preferred", "http://www.prairienet.org/pg"); 83 config.writeEntry("Preferred", "http://www.prairienet.org/pg");
81 } 84 }
82 85
83} 86}
diff --git a/noncore/apps/opie-gutenbrowser/config.in b/noncore/apps/opie-gutenbrowser/config.in
index ec67d6e..d2a3033 100644
--- a/noncore/apps/opie-gutenbrowser/config.in
+++ b/noncore/apps/opie-gutenbrowser/config.in
@@ -1,4 +1,6 @@
1 config OPIE-GUTENBROWSER 1 config GUTENBROWSER
2 boolean "gutenbrowser - Gutenberg Project etext reader and selector" 2 boolean "gutenbrowser - Gutenberg Project etext reader and selector"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && FTPLIB 4 depends ( LIBQPE || LIBQPE-X11 ) && FTPLIB && LIBOPIE2CORE && LIBOPIE2UI
5 comment "gutenbrowser needs a libqpe, ftplib, libopie2core and libopie2ui"
6 depends !(( LIBQPE || LIBQPE-X11 ) && FTPLIB && LIBOPIE2CORE && LIBOPIE2UI)
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp
index 40f35d6..bd44ce6 100644
--- a/noncore/apps/opie-gutenbrowser/openetext.cpp
+++ b/noncore/apps/opie-gutenbrowser/openetext.cpp
@@ -1,517 +1,518 @@
1/*************************************************************************** 1/***************************************************************************
2 openetext.cpp - description 2 openetext.cpp - description
3 begin : Sat Dec 4 1999 3 begin : Sat Dec 4 1999
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 "gutenbrowser.h" 15#include "gutenbrowser.h"
16#include "openetext.h" 16#include "openetext.h"
17#include "editTitle.h" 17#include "editTitle.h"
18 18
19#include <qfileinfo.h> 19/* OPIE */
20#include <opie2/ofiledialog.h>
20#include <qpe/applnk.h> 21#include <qpe/applnk.h>
22#include <qpe/config.h>
21#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24using namespace Opie::Ui;
22 25
23#include <stdlib.h> 26#include <stdlib.h>
24#include <qtextstream.h> 27#include <qtextstream.h>
25#include <qpe/config.h> 28#include <qfileinfo.h>
26
27#include <opie/ofiledialog.h>
28 29
29#if defined(_WS_WIN_) 30#if defined(_WS_WIN_)
30#include <windows.h> 31#include <windows.h>
31#else 32#else
32#include <unistd.h> 33#include <unistd.h>
33#include "sys/stat.h" 34#include "sys/stat.h"
34#endif 35#endif
35 36
36OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true) 37OpenEtext::OpenEtext(QWidget *parent, QString name) : QDialog(parent,name,true)
37{ 38{
38 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
39 local_index=local_library+"GUTINDEX.ALL"; 40 local_index=local_library+"GUTINDEX.ALL";
40 initDialog(); 41 initDialog();
41 connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) ); 42 connect( QListBox_1, SIGNAL(selected ( int)),this, SLOT(select_title(int)) );
42 43
43 getTitles(); 44 getTitles();
44} 45}
45 46
46OpenEtext::~OpenEtext() 47OpenEtext::~OpenEtext()
47{ 48{
48} 49}
49 50
50void OpenEtext::getTitles() 51void OpenEtext::getTitles()
51{ 52{
52 QListBox_1->clear(); 53 QListBox_1->clear();
53 Config config("Gutenbrowser"); 54 Config config("Gutenbrowser");
54 config.setGroup( "Files" ); 55 config.setGroup( "Files" );
55 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 56 s_numofFiles = config.readEntry("NumberOfFiles", "0");
56 QLabel_1->setText( tr( 57 QLabel_1->setText( tr(
57 s_numofFiles+" etexts in your library.")); 58 s_numofFiles+" etexts in your library."));
58 int i_numofFiles = s_numofFiles.toInt(); 59 int i_numofFiles = s_numofFiles.toInt();
59 for (int i = 1; i <= i_numofFiles+1; i++) { 60 for (int i = 1; i <= i_numofFiles+1; i++) {
60 QString temp; 61 QString temp;
61 temp.setNum(i); 62 temp.setNum(i);
62 config.setGroup( "Files" ); 63 config.setGroup( "Files" );
63 QString ramble = config.readEntry(temp, "" ); 64 QString ramble = config.readEntry(temp, "" );
64 config.setGroup( "Titles" ); 65 config.setGroup( "Titles" );
65 title = config.readEntry(ramble, ""); 66 title = config.readEntry(ramble, "");
66 if( !title.isEmpty()) { 67 if( !title.isEmpty()) {
67 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1); 68 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1);
68 } 69 }
69 } 70 }
70} 71}
71 72
72/* 73/*
73 opens selected title */ 74 opens selected title */
74void OpenEtext::OpenTitle() 75void OpenEtext::OpenTitle()
75{ 76{
76 if( QListBox_1->currentItem() != -1) 77 if( QListBox_1->currentItem() != -1)
77 select_title( QListBox_1->currentItem() ); 78 select_title( QListBox_1->currentItem() );
78 else { 79 else {
79 QString sMsg; 80 QString sMsg;
80 sMsg = "You must select an Etext to open"; 81 sMsg = "You must select an Etext to open";
81 QMessageBox::message( "Error",sMsg); 82 QMessageBox::message( "Error",sMsg);
82 } 83 }
83} 84}
84 85
85void OpenEtext::select_title(int index ) 86void OpenEtext::select_title(int index )
86{ 87{
87 OpenButton->setDown(TRUE); 88 OpenButton->setDown(TRUE);
88 QString temp; 89 QString temp;
89 temp.setNum( index + 1); 90 temp.setNum( index + 1);
90 const char * title; 91 const char * title;
91 title = QListBox_1->text( index ); 92 title = QListBox_1->text( index );
92 openFileTitle = title; 93 openFileTitle = title;
93 Config config("Gutenbrowser"); 94 Config config("Gutenbrowser");
94 config.setGroup( "Files" ); 95 config.setGroup( "Files" );
95 file = config.readEntry(temp, ""); 96 file = config.readEntry(temp, "");
96 OpenEtext::accept(); 97 OpenEtext::accept();
97} 98}
98 99
99/* 100/*
100 This function imports already existing etexts into the local library list*/ 101 This function imports already existing etexts into the local library list*/
101void OpenEtext::open() 102void OpenEtext::open()
102{ 103{
103OpenFileButton->setDown(TRUE); 104OpenFileButton->setDown(TRUE);
104 title = ""; 105 title = "";
105 QString currDir=""; 106 QString currDir="";
106 QString filer; 107 QString filer;
107 QString name_file; 108 QString name_file;
108 QString local ; 109 QString local ;
109 local = (QDir::homeDirPath () +"Applications/gutenbrowser"); 110 local = (QDir::homeDirPath () +"Applications/gutenbrowser");
110 QDir library( local); 111 QDir library( local);
111 112
112// fileBrowser *browseForFiles; 113// fileBrowser *browseForFiles;
113// browseForFiles=new fileBrowser(this,"Browse for File", TRUE, 0, "guten/plain;text/plain"); 114// browseForFiles=new fileBrowser(this,"Browse for File", TRUE, 0, "guten/plain;text/plain");
114// // browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); 115// // browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
115// browseForFiles->setFileView( 0); 116// browseForFiles->setFileView( 0);
116// browseForFiles->showMaximized(); 117// browseForFiles->showMaximized();
117// browseForFiles->exec(); 118// browseForFiles->exec();
118// QString selFile= browseForFiles->selectedFileName; 119// QString selFile= browseForFiles->selectedFileName;
119// fileList=browseForFiles->fileList; 120// fileList=browseForFiles->fileList;
120 Config cfg("Gutenbrowser"); 121 Config cfg("Gutenbrowser");
121 cfg. setGroup ( "View" ); 122 cfg. setGroup ( "View" );
122 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); 123 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
123 QMap<QString, QStringList> map; 124 QMap<QString, QStringList> map;
124 map.insert(tr("All"), QStringList() ); 125 map.insert(tr("All"), QStringList() );
125 QStringList text; 126 QStringList text;
126 text << "text/*"; 127 text << "text/*";
127 map.insert(tr("Text"), text ); 128 map.insert(tr("Text"), text );
128 text << "*"; 129 text << "*";
129 map.insert(tr("All"), text ); 130 map.insert(tr("All"), text );
130 131
131 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map); 132 QString str = OFileDialog::getOpenFileName( 2, dir , QString::null, map);
132 133
133 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { 134 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
134 filer = str; 135 filer = str;
135 136
136 qDebug("Open file: "+str); 137 qDebug("Open file: "+str);
137 138
138 // QStringList::ConstIterator f; 139 // QStringList::ConstIterator f;
139// QString fileTemp; 140// QString fileTemp;
140// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 141// for ( f = fileList.begin(); f != fileList.end(); f++ ) {
141// fileTemp = *f; 142// fileTemp = *f;
142// fileTemp.right( fileTemp.length()-5); 143// fileTemp.right( fileTemp.length()-5);
143// fileName = fileTemp; 144// fileName = fileTemp;
144// if( !fileName.isEmpty() ){ 145// if( !fileName.isEmpty() ){
145// filer = fileName; 146// filer = fileName;
146// } else { //filename is empty 147// } else { //filename is empty
147// // QString sMsg; 148// // QString sMsg;
148// // sMsg = "Error opening library filelist "+fileName; 149// // sMsg = "Error opening library filelist "+fileName;
149// } 150// }
150 151
151 if( filer.right(4) == ".txt" 152 if( filer.right(4) == ".txt"
152 || filer.right(4) == ".TXT" 153 || filer.right(4) == ".TXT"
153 || filer.right(4) == ".etx" 154 || filer.right(4) == ".etx"
154 || filer.right(4) == ".ETX" 155 || filer.right(4) == ".ETX"
155 || filer.right(4) == ".etx" 156 || filer.right(4) == ".etx"
156 || filer.right(4) == ".ETX" 157 || filer.right(4) == ".ETX"
157 || filer.right(4) == ".zip" 158 || filer.right(4) == ".zip"
158 || filer.right(4) == ".ZIP" ) { 159 || filer.right(4) == ".ZIP" ) {
159 QFileInfo zipFile( filer); 160 QFileInfo zipFile( filer);
160 QString s_fileName = zipFile.fileName(); 161 QString s_fileName = zipFile.fileName();
161 QString cmd; 162 QString cmd;
162 163
163 if( s_fileName.right(4) == ".zip") { // unzip that sucker.... 164 if( s_fileName.right(4) == ".zip") { // unzip that sucker....
164 s_fileName = s_fileName.left( s_fileName.length() - 4); 165 s_fileName = s_fileName.left( s_fileName.length() - 4);
165 if( chdir((const char*)local_library.latin1())!=0) 166 if( chdir((const char*)local_library.latin1())!=0)
166 qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library; 167 qDebug("chdir failed.");// QString cmd = "gunzip -d " + filer + " -d " + local_library;
167 cmd = "gunzip -S .zip " + filer; 168 cmd = "gunzip -S .zip " + filer;
168 fileName = local_library + s_fileName + ".txt"; 169 fileName = local_library + s_fileName + ".txt";
169 system( cmd); 170 system( cmd);
170 } 171 }
171// this renames the .txt to .etx!! 172// this renames the .txt to .etx!!
172 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ { 173 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ {
173// qDebug("Filename is "+fileName); 174// qDebug("Filename is "+fileName);
174 s_fileName = fileName; 175 s_fileName = fileName;
175 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); 176 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx");
176 rename(fileName.latin1(),s_fileName.latin1()); 177 rename(fileName.latin1(),s_fileName.latin1());
177 fileName = s_fileName; 178 fileName = s_fileName;
178// qDebug("Filename is now "+fileName); 179// qDebug("Filename is now "+fileName);
179 } 180 }
180 } else 181 } else
181 fileName = str; 182 fileName = str;
182 183
183 FindTitle(fileName); 184 FindTitle(fileName);
184 185
185 QFileInfo fi( fileName); 186 QFileInfo fi( fileName);
186 name_file = fi.fileName(); 187 name_file = fi.fileName();
187 name_file = name_file.left(name_file.length() - 4); 188 name_file = name_file.left(name_file.length() - 4);
188 189
189 qDebug("Setting doclink"); 190 qDebug("Setting doclink");
190 DocLnk lnk; 191 DocLnk lnk;
191 qDebug("name is " + name_file); 192 qDebug("name is " + name_file);
192 lnk.setName(name_file); //sets file name 193 lnk.setName(name_file); //sets file name
193 qDebug("Title is "+title); 194 qDebug("Title is "+title);
194 lnk.setComment(title); 195 lnk.setComment(title);
195 196
196 QListBox_1->clear(); 197 QListBox_1->clear();
197 getTitles(); 198 getTitles();
198 qDebug("Filename is "+fileName); 199 qDebug("Filename is "+fileName);
199 lnk.setFile(fileName); //sets File property 200 lnk.setFile(fileName); //sets File property
200 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 201 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
201 lnk.setExec(fileName); 202 lnk.setExec(fileName);
202 lnk.setIcon("gutenbrowser/Gutenbrowser"); 203 lnk.setIcon("gutenbrowser/Gutenbrowser");
203 if(!lnk.writeLink()) 204 if(!lnk.writeLink())
204 qDebug("Writing doclink did not work"); 205 qDebug("Writing doclink did not work");
205 206
206 } // end of for each file name.... 207 } // end of for each file name....
207 OpenFileButton->setDown(FALSE); 208 OpenFileButton->setDown(FALSE);
208} 209}
209 210
210/* 211/*
211find the title in the config file */ 212find the title in the config file */
212bool OpenEtext::FindTitle( QString filename) 213bool OpenEtext::FindTitle( QString filename)
213{ 214{
214 Config config("Gutenbrowser"); 215 Config config("Gutenbrowser");
215 config.setGroup( "Files" ); 216 config.setGroup( "Files" );
216 QString s_numofFiles = config.readEntry("NumberOfFiles", "0"); 217 QString s_numofFiles = config.readEntry("NumberOfFiles", "0");
217 int i_numofFiles = s_numofFiles.toInt(); 218 int i_numofFiles = s_numofFiles.toInt();
218 219
219 QFileInfo fi(filename); 220 QFileInfo fi(filename);
220 name = fi.fileName(); 221 name = fi.fileName();
221 qDebug("filename to open is " + name); 222 qDebug("filename to open is " + name);
222 QFile indexLib( filename); 223 QFile indexLib( filename);
223 bool findCheck = FALSE; 224 bool findCheck = FALSE;
224 // int Titlenumber=0; 225 // int Titlenumber=0;
225 226
226 if ( indexLib.open( IO_ReadOnly) ) { 227 if ( indexLib.open( IO_ReadOnly) ) {
227 qDebug("file opened successfully"); 228 qDebug("file opened successfully");
228 QTextStream indexStream( &indexLib ); 229 QTextStream indexStream( &indexLib );
229 QString target = "Project Gutenberg Etext of"; 230 QString target = "Project Gutenberg Etext of";
230 QString target2 = "Project Gutenberg Etext"; 231 QString target2 = "Project Gutenberg Etext";
231 QString target3 = "Project Gutenberg's Etext of"; 232 QString target3 = "Project Gutenberg's Etext of";
232 QString target4 = "Project Gutenberg's Etext"; 233 QString target4 = "Project Gutenberg's Etext";
233 QString indexLine; 234 QString indexLine;
234 while ( !indexStream.eof() ) { 235 while ( !indexStream.eof() ) {
235 // until end of file.. 236 // until end of file..
236 indexLine = indexStream.readLine(); 237 indexLine = indexStream.readLine();
237 if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE; 238 if( indexLine.find(target, 0, TRUE) > -1 && !findCheck) {findCheck = TRUE;
238 title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE)); 239 title = indexLine.mid( indexLine.find(target, 0, TRUE) + (target.length()) , indexLine.find("\r", 0, TRUE));
239 title = title.left( title.find( "*",0, TRUE)); 240 title = title.left( title.find( "*",0, TRUE));
240 title = title.stripWhiteSpace (); 241 title = title.stripWhiteSpace ();
241// qDebug("Found the title 1 and it is %s", title.latin1()); 242// qDebug("Found the title 1 and it is %s", title.latin1());
242// QListBox_1->insertItem ( title); 243// QListBox_1->insertItem ( title);
243 } 244 }
244 if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) { 245 if( indexLine.find( target2, 0, TRUE) > -1 && !findCheck) {
245 findCheck = TRUE; 246 findCheck = TRUE;
246 title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) ); 247 title = indexLine.mid( indexLine.find( target2, 0, TRUE ) + ( target2.length()) , indexLine.find("\r", 0, TRUE) );
247 title = title.left( title.find( "*",0, TRUE)); 248 title = title.left( title.find( "*",0, TRUE));
248 title = title.stripWhiteSpace (); 249 title = title.stripWhiteSpace ();
249// qDebug("Found the title 2 and it is %s", title.latin1()); 250// qDebug("Found the title 2 and it is %s", title.latin1());
250// QListBox_1->insertItem ( title); 251// QListBox_1->insertItem ( title);
251 } 252 }
252 if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) { 253 if( indexLine.find( target3, 0, TRUE) > -1 && !findCheck) {
253 findCheck = TRUE; 254 findCheck = TRUE;
254 title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE)); 255 title = indexLine.mid( indexLine.find( target3, 0, TRUE) + ( target3.length()) , indexLine.find("\r", 0, TRUE));
255 title = title.left( title.find( "*",0, TRUE)); 256 title = title.left( title.find( "*",0, TRUE));
256 title = title.stripWhiteSpace (); 257 title = title.stripWhiteSpace ();
257// qDebug("Found the title 3 and it is %s", title.latin1()); 258// qDebug("Found the title 3 and it is %s", title.latin1());
258 } 259 }
259 if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) { 260 if( indexLine.find( target4, 0, TRUE) > -1 && !findCheck) {
260 findCheck = TRUE; 261 findCheck = TRUE;
261 title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE)); 262 title = indexLine.mid( indexLine.find( target4, 0, TRUE) + ( target4.length()) , indexLine.find("\r", 0, TRUE));
262 title = title.left( title.find( "*",0, TRUE)); 263 title = title.left( title.find( "*",0, TRUE));
263 title = title.stripWhiteSpace (); 264 title = title.stripWhiteSpace ();
264// qDebug("Found the title 4 and it is %s", title.latin1()); 265// qDebug("Found the title 4 and it is %s", title.latin1());
265 } 266 }
266 } //endof file 267 } //endof file
267 indexLib.close(); 268 indexLib.close();
268 269
269 if( !findCheck || title.length() < 2) { 270 if( !findCheck || title.length() < 2) {
270 qDebug("Trying hard to find title from GUTINDEX.ALL"); 271 qDebug("Trying hard to find title from GUTINDEX.ALL");
271 title = titleFromLibrary( filename); 272 title = titleFromLibrary( filename);
272 findCheck = TRUE; 273 findCheck = TRUE;
273 } 274 }
274 275
275 if ( checkConf() == false && findCheck == TRUE) { 276 if ( checkConf() == false && findCheck == TRUE) {
276 277
277 config.setGroup( "Files"); 278 config.setGroup( "Files");
278 config.writeEntry("NumberOfFiles",i_numofFiles + 1 ); 279 config.writeEntry("NumberOfFiles",i_numofFiles + 1 );
279 QString interger; 280 QString interger;
280 interger.setNum( i_numofFiles +1); 281 interger.setNum( i_numofFiles +1);
281 config.writeEntry(interger, filename); 282 config.writeEntry(interger, filename);
282 config.setGroup( "Titles" ); 283 config.setGroup( "Titles" );
283 for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file 284 for (int i = 1; i <= i_numofFiles; i++) { //find dup titles in config file
284 QString temp; 285 QString temp;
285 temp.setNum(i); 286 temp.setNum(i);
286 config.setGroup( "Files" ); 287 config.setGroup( "Files" );
287 QString ramble = config.readEntry(temp, "" ); 288 QString ramble = config.readEntry(temp, "" );
288 config.setGroup( "Titles" ); 289 config.setGroup( "Titles" );
289 QString title1 = config.readEntry(ramble, ""); 290 QString title1 = config.readEntry(ramble, "");
290 if(title1==title) 291 if(title1==title)
291 title+="1"; 292 title+="1";
292 i= i_numofFiles+1; 293 i= i_numofFiles+1;
293 } 294 }
294 if(title.length()<3) { 295 if(title.length()<3) {
295// qDebug("title is empty"); 296// qDebug("title is empty");
296 title="Unknown"; 297 title="Unknown";
297 } 298 }
298 config.writeEntry( filename,title); 299 config.writeEntry( filename,title);
299 } 300 }
300 } else { 301 } else {
301 QString sMsg; 302 QString sMsg;
302 sMsg = "Error opening library file: "+filename; 303 sMsg = "Error opening library file: "+filename;
303 printf( sMsg+"\n"); 304 printf( sMsg+"\n");
304 } 305 }
305 return true; 306 return true;
306} 307}
307 308
308QString OpenEtext::titleFromLibrary( QString fileName) 309QString OpenEtext::titleFromLibrary( QString fileName)
309{ 310{
310 QFile indexLib( local_index); 311 QFile indexLib( local_index);
311 QString target; 312 QString target;
312 int find1 = fileName.findRev("/",-1,TRUE) + 1; 313 int find1 = fileName.findRev("/",-1,TRUE) + 1;
313 int find2 = fileName.findRev(".gtn",-1,TRUE) - find1; 314 int find2 = fileName.findRev(".gtn",-1,TRUE) - find1;
314 if(find2==-1-find1) 315 if(find2==-1-find1)
315 int find2 = fileName.findRev(".etx",-1,TRUE) - find1; 316 int find2 = fileName.findRev(".etx",-1,TRUE) - find1;
316 else if(find2==-1-find1) 317 else if(find2==-1-find1)
317 int find2 = fileName.findRev(".txt",-1,TRUE) - find1; 318 int find2 = fileName.findRev(".txt",-1,TRUE) - find1;
318 319
319 target = fileName.mid( find1, find2 ); 320 target = fileName.mid( find1, find2 );
320 QString checker = target.right(1); 321 QString checker = target.right(1);
321 bool ok; 322 bool ok;
322 checker.toInt( &ok,10); 323 checker.toInt( &ok,10);
323 if( ok) { 324 if( ok) {
324 target = target.left( target.length()-1); 325 target = target.left( target.length()-1);
325 checker = target.right(1); 326 checker = target.right(1);
326 ok = FALSE; 327 ok = FALSE;
327 checker.toInt( &ok,10); 328 checker.toInt( &ok,10);
328 if( ok) { 329 if( ok) {
329 target = target.left( target.length()-1); 330 target = target.left( target.length()-1);
330 } 331 }
331 } 332 }
332 if ( indexLib.open( IO_ReadOnly) ) { 333 if ( indexLib.open( IO_ReadOnly) ) {
333 // file opened successfully 334 // file opened successfully
334 QTextStream indexStream( &indexLib ); 335 QTextStream indexStream( &indexLib );
335 QString indexLine; 336 QString indexLine;
336 bool findCheck = FALSE; 337 bool findCheck = FALSE;
337 while ( !indexStream.atEnd() ) { // until end of file.. 338 while ( !indexStream.atEnd() ) { // until end of file..
338 indexLine = indexStream.readLine(); 339 indexLine = indexStream.readLine();
339 340
340 if( indexLine.find( target,0,FALSE) > 0 ) { 341 if( indexLine.find( target,0,FALSE) > 0 ) {
341 findCheck = TRUE; 342 findCheck = TRUE;
342 title = indexLine.mid( 9, 50); 343 title = indexLine.mid( 9, 50);
343// title = indexLine.mid( 26, indexLine.length() ); 344// title = indexLine.mid( 26, indexLine.length() );
344 title = title.stripWhiteSpace (); 345 title = title.stripWhiteSpace ();
345// qDebug("Finally Found the title and it is\n %s", title.latin1()); 346// qDebug("Finally Found the title and it is\n %s", title.latin1());
346// QListBox_1->insertItem ( title); 347// QListBox_1->insertItem ( title);
347 } 348 }
348 } //end while loop 349 } //end while loop
349 } 350 }
350 else 351 else
351 qDebug("Error opening library index "+ local_index); 352 qDebug("Error opening library index "+ local_index);
352 return title; 353 return title;
353} 354}
354 355
355bool OpenEtext::checkConf() 356bool OpenEtext::checkConf()
356{ 357{
357 QString file = fileName; 358 QString file = fileName;
358 Config config("Gutenbrowser"); 359 Config config("Gutenbrowser");
359 config.setGroup( "Files" ); 360 config.setGroup( "Files" );
360 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 361 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
361 int i_numofFiles = s_numofFiles.toInt(); 362 int i_numofFiles = s_numofFiles.toInt();
362 363
363 for (int i = 1; i <= i_numofFiles; i++) { 364 for (int i = 1; i <= i_numofFiles; i++) {
364 QString temp; 365 QString temp;
365 temp.setNum(i); 366 temp.setNum(i);
366 config.setGroup( "Files"); 367 config.setGroup( "Files");
367 QString ramble = config.readEntry(temp, "" ); 368 QString ramble = config.readEntry(temp, "" );
368 369
369 if(ramble == file ) { 370 if(ramble == file ) {
370 return true; 371 return true;
371 } 372 }
372 } 373 }
373 return false; 374 return false;
374} 375}
375 376
376void OpenEtext::remove() 377void OpenEtext::remove()
377{ 378{
378 title_text = QListBox_1->text( QListBox_1->currentItem() ); 379 title_text = QListBox_1->text( QListBox_1->currentItem() );
379 title_text=title_text.stripWhiteSpace(); 380 title_text=title_text.stripWhiteSpace();
380 QString msg ="<p>Do you really want to REMOVE\n" +title_text +"?\nThis will not delete the file.</P>"; 381 QString msg ="<p>Do you really want to REMOVE\n" +title_text +"?\nThis will not delete the file.</P>";
381 switch( QMessageBox::information( this, (tr("Remove Etext")), 382 switch( QMessageBox::information( this, (tr("Remove Etext")),
382 (tr(msg)), 383 (tr(msg)),
383 (tr("&Yes")), (tr("&Cancel")), 0 )){ 384 (tr("&Yes")), (tr("&Cancel")), 0 )){
384 case 0: // Yes clicked, 385 case 0: // Yes clicked,
385 removeSelection(); 386 removeSelection();
386 QListBox_1->clear(); 387 QListBox_1->clear();
387 getTitles(); 388 getTitles();
388 break; 389 break;
389 case 1: // Cancel 390 case 1: // Cancel
390 break; 391 break;
391 }; 392 };
392} 393}
393 394
394/* 395/*
395 this removes selected title entry*/ 396 this removes selected title entry*/
396void OpenEtext::removeSelection() 397void OpenEtext::removeSelection()
397{ 398{
398 Config config("Gutenbrowser"); 399 Config config("Gutenbrowser");
399 config.setGroup( "Files" ); 400 config.setGroup( "Files" );
400 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 401 s_numofFiles = config.readEntry("NumberOfFiles", "0");
401 int rem=0; 402 int rem=0;
402 int i_numofFiles = s_numofFiles.toInt(); 403 int i_numofFiles = s_numofFiles.toInt();
403 QString fileNum2; 404 QString fileNum2;
404 QString fileNum; 405 QString fileNum;
405 406
406 for (int i = 1; i <= i_numofFiles; i++) { 407 for (int i = 1; i <= i_numofFiles; i++) {
407 fileNum.setNum(i); 408 fileNum.setNum(i);
408 config.setGroup( "Files" ); 409 config.setGroup( "Files" );
409 410
410 QString s_filename = config.readEntry(fileNum, "" ); 411 QString s_filename = config.readEntry(fileNum, "" );
411 config.setGroup( "Titles" ); 412 config.setGroup( "Titles" );
412 413
413 QString file_title = config.readEntry( s_filename, ""); 414 QString file_title = config.readEntry( s_filename, "");
414 if(title_text == file_title) { 415 if(title_text == file_title) {
415 rem=i; 416 rem=i;
416//qDebug("file title to remove is "+file_title); 417//qDebug("file title to remove is "+file_title);
417 selFile = s_filename; 418 selFile = s_filename;
418 config.removeEntry( s_filename); //removes file=title 419 config.removeEntry( s_filename); //removes file=title
419 } 420 }
420 } 421 }
421 config.setGroup( "Files" ); 422 config.setGroup( "Files" );
422 423
423 for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry 424 for(int fg = rem; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry
424 fileNum.setNum(fg); 425 fileNum.setNum(fg);
425 fileNum2.setNum( fg + 1); 426 fileNum2.setNum( fg + 1);
426 427
427 QString s_filename2 = config.readEntry(fileNum2, "" ); 428 QString s_filename2 = config.readEntry(fileNum2, "" );
428 429
429 if (!s_filename2.isEmpty()) { 430 if (!s_filename2.isEmpty()) {
430 config.writeEntry(fileNum, s_filename2 ); 431 config.writeEntry(fileNum, s_filename2 );
431 } 432 }
432 } 433 }
433 config.writeEntry("NumberOfFiles", i_numofFiles - 1 ); 434 config.writeEntry("NumberOfFiles", i_numofFiles - 1 );
434 config.removeEntry(fileNum2); 435 config.removeEntry(fileNum2);
435// remFile(); 436// remFile();
436} 437}
437 438
438/* 439/*
439 removes file title name from list and config file*/ 440 removes file title name from list and config file*/
440void OpenEtext::remFile() 441void OpenEtext::remFile()
441{ 442{
442 Config config("Gutenbrowser"); 443 Config config("Gutenbrowser");
443 config.setGroup( "Files" ); 444 config.setGroup( "Files" );
444 QString remFile; 445 QString remFile;
445 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 446 s_numofFiles = config.readEntry("NumberOfFiles", "0");
446 int i_numofFiles = s_numofFiles.toInt(); 447 int i_numofFiles = s_numofFiles.toInt();
447 for (int i = 1; i <= i_numofFiles; i++) { 448 for (int i = 1; i <= i_numofFiles; i++) {
448 QString fileNum; 449 QString fileNum;
449 fileNum.setNum(i); 450 fileNum.setNum(i);
450 QString s_filename = config.readEntry(fileNum, "" ); 451 QString s_filename = config.readEntry(fileNum, "" );
451 452
452 if( s_filename == selFile) { 453 if( s_filename == selFile) {
453 config.removeEntry(selFile); 454 config.removeEntry(selFile);
454 455
455 for(int fg = i_numofFiles - i; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry 456 for(int fg = i_numofFiles - i; fg < i_numofFiles ; fg++ ) { //this rewrites Files number entry
456 QString fileNum2; 457 QString fileNum2;
457 fileNum2.setNum( fg + 1); 458 fileNum2.setNum( fg + 1);
458 QString s_filename2 = config.readEntry(fileNum2, "" ); 459 QString s_filename2 = config.readEntry(fileNum2, "" );
459 460
460 if (!s_filename2.isEmpty()) { 461 if (!s_filename2.isEmpty()) {
461 config.writeEntry(fileNum, s_filename2 ); 462 config.writeEntry(fileNum, s_filename2 );
462 } 463 }
463 } 464 }
464 } 465 }
465 } 466 }
466 config.writeEntry("NumberOfFiles", i_numofFiles - 1 ); 467 config.writeEntry("NumberOfFiles", i_numofFiles - 1 );
467 config.removeEntry(s_numofFiles); 468 config.removeEntry(s_numofFiles);
468 469
469 QListBox_1->triggerUpdate(true); 470 QListBox_1->triggerUpdate(true);
470} 471}
471 472
472/* 473/*
473sorts the list*/ 474sorts the list*/
474void OpenEtext::scan() { 475void OpenEtext::scan() {
475 476
476 QListBox_1->sort(TRUE); 477 QListBox_1->sort(TRUE);
477 QListBox_1->triggerUpdate(true); 478 QListBox_1->triggerUpdate(true);
478} 479}
479 480
480void OpenEtext::editTitle() { 481void OpenEtext::editTitle() {
481 482
482 int currentItem=QListBox_1->currentItem(); 483 int currentItem=QListBox_1->currentItem();
483 QString title_text = QListBox_1->text( currentItem); 484 QString title_text = QListBox_1->text( currentItem);
484//qDebug("Selected "+title_text); 485//qDebug("Selected "+title_text);
485 486
486 Config config("Gutenbrowser"); 487 Config config("Gutenbrowser");
487 config.setGroup( "Files" ); 488 config.setGroup( "Files" );
488 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 489 s_numofFiles = config.readEntry("NumberOfFiles", "0");
489 int i_numofFiles = s_numofFiles.toInt(); 490 int i_numofFiles = s_numofFiles.toInt();
490 QString fileNum; 491 QString fileNum;
491 for (int i = 1; i <= i_numofFiles+1; i++) { 492 for (int i = 1; i <= i_numofFiles+1; i++) {
492 493
493 fileNum.setNum(i); 494 fileNum.setNum(i);
494 config.setGroup( "Files" ); 495 config.setGroup( "Files" );
495 QString s_filename = config.readEntry(fileNum, "" ); 496 QString s_filename = config.readEntry(fileNum, "" );
496 config.setGroup( "Titles" ); 497 config.setGroup( "Titles" );
497 QString file_title = config.readEntry( s_filename, ""); 498 QString file_title = config.readEntry( s_filename, "");
498//qDebug("file_title is "+file_title); 499//qDebug("file_title is "+file_title);
499 if(title_text == file_title ) { 500 if(title_text == file_title ) {
500 selFile = s_filename; 501 selFile = s_filename;
501//qDebug("Edit: "+ file_title ); 502//qDebug("Edit: "+ file_title );
502 i=i_numofFiles+1; 503 i=i_numofFiles+1;
503 Edit_Title *titleEdit; 504 Edit_Title *titleEdit;
504 titleEdit = new Edit_Title(this,file_title ,TRUE); 505 titleEdit = new Edit_Title(this,file_title ,TRUE);
505 if(titleEdit->exec() !=0) { 506 if(titleEdit->exec() !=0) {
506//qDebug(titleEdit->newTitle); 507//qDebug(titleEdit->newTitle);
507 config.writeEntry( s_filename, titleEdit->newTitle); 508 config.writeEntry( s_filename, titleEdit->newTitle);
508 QListBox_1->removeItem(currentItem); 509 QListBox_1->removeItem(currentItem);
509 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); 510 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem);
510 } 511 }
511 } 512 }
512 } 513 }
513 514
514// getTitles(); 515// getTitles();
515 QListBox_1->triggerUpdate(true); 516 QListBox_1->triggerUpdate(true);
516} 517}
517 518
diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro
index e34e922..5c1d0c4 100644
--- a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro
+++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.pro
@@ -1,45 +1,44 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release quick-app 2CONFIG += qt warn_on quick-app
3#CONFIG += qt warn_on release qpp
4HEADERS = LibraryDialog.h \ 3HEADERS = LibraryDialog.h \
5 SearchDialog.h \ 4 SearchDialog.h \
6 SearchResults.h \ 5 SearchResults.h \
7 helpme.h \ 6 helpme.h \
8 multiline_ex.h \ 7 multiline_ex.h \
9 openetext.h \ 8 openetext.h \
10 editTitle.h \ 9 editTitle.h \
11 fontDialog.h \ 10 fontDialog.h \
12 optionsDialog.h \ 11 optionsDialog.h \
13 helpwindow.h \ 12 helpwindow.h \
14 output.h \ 13 output.h \
15 NetworkDialog.h \ 14 NetworkDialog.h \
16 gutenbrowser.h \ 15 gutenbrowser.h \
17 resource.h 16 resource.h
18SOURCES = LibraryDialog.cpp \ 17SOURCES = LibraryDialog.cpp \
19 LibraryDialogData.cpp \ 18 LibraryDialogData.cpp \
20 SearchDialog.cpp \ 19 SearchDialog.cpp \
21 SearchResults.cpp \ 20 SearchResults.cpp \
22 browserDialog.cpp \ 21 browserDialog.cpp \
23 helpme.cpp \ 22 helpme.cpp \
24 multiline_ex.cpp \ 23 multiline_ex.cpp \
25 fontDialog.cpp \ 24 fontDialog.cpp \
26 openetext.cpp \ 25 openetext.cpp \
27 openetextdata.cpp \ 26 openetextdata.cpp \
28 editTitle.cpp \ 27 editTitle.cpp \
29 ftpsitedlg.cpp \ 28 ftpsitedlg.cpp \
30 optionsDialog.cpp \ 29 optionsDialog.cpp \
31 optionsDialogData.cpp \ 30 optionsDialogData.cpp \
32 helpwindow.cpp \ 31 helpwindow.cpp \
33 output.cpp \ 32 output.cpp \
34 NetworkDialog.cpp \ 33 NetworkDialog.cpp \
35 gutenbrowserData.cpp \ 34 gutenbrowserData.cpp \
36 gutenbrowser.cpp \ 35 gutenbrowser.cpp \
37 main.cpp 36 main.cpp
38TARGET = gutenbrowser 37TARGET = gutenbrowser
39 38
40INCLUDEPATH += $(OPIEDIR)/include 39INCLUDEPATH += $(OPIEDIR)/include
41DEPENDPATH += $(OPIEDIR)/include 40DEPENDPATH += $(OPIEDIR)/include
42DESTDIR = $(OPIEDIR)/bin 41DESTDIR = $(OPIEDIR)/bin
43LIBS += -lqpe -lpthread -lftplib -lopie 42LIBS += -lqpe -lpthread -lftplib -lopiecore2 -lopieui2
44 43
45include ( $(OPIEDIR)/include.pro ) 44include ( $(OPIEDIR)/include.pro )