summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/LibraryDialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp92
1 files changed, 48 insertions, 44 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 5b22b00..270a4cf 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -10,23 +10,27 @@
// * it under the terms of the GNU General Public License as published by *
// * the Free Software Foundation; either version 2 of the License, or *
// * (at your option) any later version. *
// ***************************************************************************/
//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
+#include "LibraryDialog.h"
+#include "output.h"
+
+/* OPIE */
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
+#include <opie2/odebug.h>
-#include "LibraryDialog.h"
-#include "output.h"
-
+/* QT */
#include <qpushbutton.h>
#include <qmultilineedit.h>
//#include <qlayout.h>
+/* STD */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
/*
* The dialog will by default be modeless, unless you set 'modal' to
@@ -61,26 +65,26 @@ LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, W
config.setGroup( "HttpServer" );
proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
config.setGroup( "FTPsite" );
ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
- qDebug("Library Dialog: ftp_host is "+ftp_host);
+ odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
// ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
// ftp_host=ftp_host.stripWhiteSpace();
ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
i_binary = 0;
config.setGroup("SortAuth");
if( config.readEntry("authSort", "FALSE") == "TRUE")
authBox->setChecked(TRUE);
config.setGroup("General");
downDir =config.readEntry( "DownloadDirectory",local_library);
- qDebug("downDir is "+downDir);
+ odebug << "downDir is "+downDir << oendl;
newindexLib.setName( old_index);
indexLib.setName( old_index);
new QPEDialogListener(this);
}
@@ -96,13 +100,13 @@ LibraryDialog::~LibraryDialog()
}
/*This groks using PGWHOLE.TXT */
void LibraryDialog::Newlibrary()
{
#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
- //qDebug("Opening new library index %s",newindexLib);
+ //odebug << "Opening new library index " << newindexLib << "" << oendl;
if ( newindexLib.open( IO_ReadOnly) ) {
setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
QTextStream indexStream( &newindexLib );
QString indexLine;
while ( !indexStream.atEnd() ) { // until end of file..
indexLine = indexStream.readLine();
@@ -118,13 +122,13 @@ void LibraryDialog::Newlibrary()
title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
title = title.stripWhiteSpace();
getAuthor(); // groks author
author = author.stripWhiteSpace();
if (authBox->isChecked()) { // this reverses the first name and last name of the author
- // qDebug("Sorting last name first");
+ // odebug << "Sorting last name first" << oendl;
QString lastName, firstName="";
int finder=author.findRev( ' ', -1, TRUE);
lastName=author.right( author.length()-finder);
firstName=author.left(finder);
lastName=lastName.stripWhiteSpace();
firstName=firstName.stripWhiteSpace();
@@ -177,13 +181,13 @@ void LibraryDialog::Library()
ListView1->clear();
ListView2->clear();
ListView3->clear();
ListView4->clear();
ListView5->clear();
- qDebug("opening GUTINDEX.ALL file");
+ odebug << "opening GUTINDEX.ALL file" << oendl;
IDontKnowWhy = "";
if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully
QTextStream indexStream( &indexLib );
QString indexLine;
qApp->processEvents();
// int jig;
@@ -197,23 +201,23 @@ void LibraryDialog::Library()
// title = indexLine.mid( 9, 50);
file = indexLine.mid(60,12);
if(file.left(1).find("[",0,TRUE) != -1)
file.remove(1,1);
if( file.find("]",0,TRUE) != -1)
file = file.left( file.find("]",0,TRUE));
- //qDebug("file is "+file);
+ //odebug << "file is "+file << oendl;
/// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
number = indexLine.mid(55,5);
number = number.stripWhiteSpace();
// title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
title = indexLine.mid( 9, 50 );
title = title.stripWhiteSpace();
- //qDebug("title is "+title);
+ //odebug << "title is "+title << oendl;
getAuthor(); // grok author
author = author.stripWhiteSpace();
- //qDebug("author is "+author);
+ //odebug << "author is "+author << oendl;
if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author
QString lastName, firstName="";
int finder=author.findRev( ' ', -1, TRUE);
lastName=author.right( author.length()-finder);
firstName=author.left(finder);
lastName=lastName.stripWhiteSpace();
@@ -394,20 +398,20 @@ void LibraryDialog::select_title( QListViewItem * item)
};
}
if(DlglistItemTitle.length()>2) {
// DlglistItemNumber = item->text(0);
item = 0;
- qDebug( "string from librarydialog is:%s %s %s", DlglistItemYear.latin1(),DlglistItemFile.latin1(),DlglistItemNumber.latin1());
- qDebug("Title is "+DlglistItemTitle);
+ odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl;
+ odebug << "Title is "+DlglistItemTitle << oendl;
// check for connection here
// if( get_extext())
if(download_Etext()) {
- // qDebug("get here 2");
+ // odebug << "get here 2" << oendl;
if(i_binary == 1) {
}
if(checkBox->isChecked () ) {
accept();
}
@@ -420,38 +424,38 @@ bool LibraryDialog::download_Etext()
// might have to use old gpl'd ftp for embedded!!
Config cfg("Gutenbrowser");
cfg.setGroup("FTPsite");
ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
- qDebug("about to network dialog");
+ odebug << "about to network dialog" << oendl;
QString NewlistItemNumber, NewlistItemYear, ls_result, result_line, s, dir, networkUrl, outputFile;
//////////////////// FIXME- if 'x' is part of real name....
NewlistItemFile = DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).left(DlglistItemFile.left(DlglistItemFile.find(".xxx", 1, FALSE)).find("x", 1, FALSE));
if( NewlistItemFile.find( DlglistItemFile.left(4) ,0,TRUE) ==-1 ) {
NewlistItemFile.replace( 0,4, DlglistItemFile.left(4));
- qDebug("NewlistItemFile is now "+NewlistItemFile);
+ odebug << "NewlistItemFile is now "+NewlistItemFile << oendl;
}
NewlistItemYear = DlglistItemYear.right(2);
int NewlistItemYear_Int = NewlistItemYear.toInt(0, 10);
- qDebug(NewlistItemYear);
+ odebug << NewlistItemYear << oendl;
if (NewlistItemYear_Int < 91 && NewlistItemYear_Int > 70) {
NewlistItemYear = "90";
}
Edir ="etext" +NewlistItemYear;
dir= ftp_base_dir + "/etext" +NewlistItemYear+"/";
if( ftp_base_dir.find("=",0,true) )
ftp_base_dir.remove( ftp_base_dir.find("=",0,true),1);
networkUrl= "ftp://"+ftp_host+dir;
outputFile=local_library+".guten_temp";
- //qDebug("Download file:%s",NewlistItemFile.latin1() );
- qDebug("Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile);
+ //odebug << "Download file:" << NewlistItemFile << "" << oendl;
+ odebug << "Checking: "+ftp_host+" "+dir+" "+outputFile+" "+NewlistItemFile << oendl;
QStringList networkList;
networkList.append((const char *)ftp_host);
networkList.append((const char *)dir);
networkList.append((const char *)outputFile);
networkList.append((const char *)NewlistItemFile);
//<< (char *)ftp_host << (char *)dir << (char *)outputFile << (char *)NewlistItemFile;
@@ -459,54 +463,54 @@ bool LibraryDialog::download_Etext()
NetworkDialog *NetworkDlg;
NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", TRUE, 0, networkList);
if( NetworkDlg->exec() != 0 ) { // use new, improved, *INSTANT* network-dialog-file-getterer
File_Name= NetworkDlg->localFileName;
- qDebug("back to Library from Network Dialog");
- qDebug("Just downloaded "+NetworkDlg->localFileName);
+ odebug << "back to Library from Network Dialog" << oendl;
+ odebug << "Just downloaded "+NetworkDlg->localFileName << oendl;
// if (File_Name.find( local_library, 0, TRUE) != -1 ) { //could not be found
// QString oldName=File_Name;
// File_Name.replace(0,local_library.length(),downDir);
- // qDebug("File_Name now is "+File_Name);
+ // odebug << "File_Name now is "+File_Name << oendl;
// }
// rename .txt to .etx
if(NetworkDlg->successDownload) {
- qDebug("Filename is "+File_Name);
+ odebug << "Filename is "+File_Name << oendl;
if(File_Name.right(4)==".txt") {
QString s_fileName=File_Name;
s_fileName.replace( s_fileName.length()-3,3,"gtn");
// s_fileName.replace( s_fileName.length()-3,3,"etx");
rename(File_Name.latin1(),s_fileName.latin1());
File_Name=s_fileName;
- qDebug("Filename is now "+File_Name);
+ odebug << "Filename is now "+File_Name << oendl;
}
if(File_Name.length() > 5 ) {
setTitle();
QFileInfo fi(File_Name);
QString name_file=fi.fileName();
name_file=name_file.left(name_file.length()-4);
- qDebug("Setting doclink");
+ odebug << "Setting doclink" << oendl;
DocLnk lnk;
- qDebug("name is "+name_file);
+ odebug << "name is "+name_file << oendl;
lnk.setName(name_file); //sets file name
- qDebug("Title is "+DlglistItemTitle);
+ odebug << "Title is "+DlglistItemTitle << oendl;
lnk.setComment(DlglistItemTitle);
- qDebug("Filename is "+File_Name);
+ odebug << "Filename is "+File_Name << oendl;
lnk.setFile(File_Name); //sets File property
lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
lnk.setExec(File_Name);
lnk.setIcon("gutenbrowser/Gutenbrowser");
if(!lnk.writeLink()) {
- qDebug("Writing doclink did not work");
+ odebug << "Writing doclink did not work" << oendl;
} else {
}
} else
QMessageBox::message("Note","There was an error\nwith the file");
}
}
@@ -567,20 +571,20 @@ void LibraryDialog::cancelIt()
this->reject();
}
bool LibraryDialog::setTitle()
{
Config config("Gutenbrowser");
- qDebug("setting title");
- qDebug(DlglistItemTitle);
+ odebug << "setting title" << oendl;
+ odebug << DlglistItemTitle << oendl;
if( DlglistItemTitle.find("[",0,TRUE) != -1)
DlglistItemTitle.replace(DlglistItemTitle.find("[",0,TRUE),1, "(" );
if( DlglistItemTitle.find("]",0,TRUE) !=-1)
DlglistItemTitle.replace(DlglistItemTitle.find("]",0,TRUE),1, ")" );
- qDebug("Title being set is "+DlglistItemTitle);
+ odebug << "Title being set is "+DlglistItemTitle << oendl;
int test = 0;
QString ramble, temp;
config.setGroup("Files");
QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
int i_numofFiles = s_numofFiles.toInt();
for ( int i = 0; i <= i_numofFiles; i++){
@@ -735,24 +739,24 @@ void LibraryDialog::onButtonSearch()
SearchResultsDlg* SearchResultsDialog;
SearchResultsDialog = new SearchResultsDlg( searchDlg, "Results Dialog", true, 0 , Searchlist);
SearchResultsDialog->showMaximized();
if( SearchResultsDialog->exec() != 0) {
texter = SearchResultsDialog->selText;
- // qDebug(texter);
+ // odebug << texter << oendl;
resultLs= SearchResultsDialog->resultsList;
i_berger = 1;
}
Searchlist.clear();
// if(SearchResultsDialog)
// delete SearchResultsDialog;
QString tester;
for ( QStringList::Iterator it = resultLs.begin(); it != resultLs.end(); ++it ) {
texter.sprintf("%s \n",(*it).latin1());
- // qDebug(texter);
+ // odebug << texter << oendl;
if( tester!=texter)
parseSearchResults( texter);
tester = texter;
}
if(searchDlg)
delete searchDlg;
@@ -803,13 +807,13 @@ void LibraryDialog::parseSearchResults( QString resultStr)
// // QString cmd = "gunzip -d " + zipFile /*newestLibraryFile */+" -d " + local_library;
// cmd = "unzip " + zipFile;
// #endif
// int exit=QMessageBox::information(this, "Unzip?", "Ok to unzip "+ zipFile+" ?", QMessageBox::Yes, QMessageBox::No);
// if (exit==QMessageBox::Yes) {
- // qDebug("Issuing the command "+cmd);
+ // odebug << "Issuing the command "+cmd << oendl;
// #if defined(_WS_WIN_)
// WinExec( cmd, SW_HIDE );
// #endif
// #if defined(_WS_X11_)
// system( cmd);
// #endif
@@ -837,13 +841,13 @@ void LibraryDialog::sort()
}
/*
Downloads the current selected listitem*/
bool LibraryDialog::getItem(QListViewItem *it)
{
- // qDebug("selected getItem");
+ // odebug << "selected getItem" << oendl;
// DlglistItemNumber = it->text(0);
DlglistItemTitle = it->text(0);
DlglistItemYear = it->text(2);
DlglistItemFile = it->text(3);
@@ -855,13 +859,13 @@ bool LibraryDialog::getItem(QListViewItem *it)
}
/*
download button is pushed so we get the current items to download*/
bool LibraryDialog::onButtonDownload()
{
- // qDebug("selected onButtonDownloadz");
+ // odebug << "selected onButtonDownloadz" << oendl;
QListViewItemIterator it1( ListView1 );
QListViewItemIterator it2( ListView2 );
QListViewItemIterator it3( ListView3 );
QListViewItemIterator it4( ListView4 );
QListViewItemIterator it5( ListView5 );
@@ -897,13 +901,13 @@ bool LibraryDialog::onButtonDownload()
/*
handles the sorting combo box */
void LibraryDialog::comboSelect(int index)
{
- // qDebug("we are sorting");
+ // odebug << "we are sorting" << oendl;
ListView1->setSorting( index, TRUE);
ListView2->setSorting( index, TRUE);
ListView3->setSorting( index, TRUE);
ListView4->setSorting( index, TRUE);
ListView5->setSorting( index, TRUE);
@@ -927,13 +931,13 @@ void LibraryDialog::newList()
} else {
Output *outDlg;
buttonNewList->setDown(TRUE);
QDir gutDir(QPEApplication::qpeDir()+"etc/gutenbrowser");
if(!gutDir.exists()) gutDir.mkdir(QPEApplication::qpeDir()+"etc/gutenbrowser",true);
if( chdir(QPEApplication::qpeDir()+"etc/gutenbrowser") == 0) {
- qDebug("changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser");
+ odebug << "changing dir "+QPEApplication::qpeDir()+"etc/gutenbrowser" << oendl;
QString gutenindex1 = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
int result = QMessageBox::warning( this,"Download"
,"Ok to use /'wget/' to download\na new library list?\n"
,"Yes","No",0,0,1);
@@ -948,13 +952,13 @@ void LibraryDialog::newList()
outDlg->OutputEdit->append( tr("Running wget") );
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
sleep(1);
fp = popen( (const char *) cmd, "r");
if ( !fp ) {
} else {
- qDebug("Issuing the command\n"+cmd);
+ odebug << "Issuing the command\n"+cmd << oendl;
// system(cmd);
while ( fgets( line, sizeof line, fp)) {
outDlg->OutputEdit->append(line);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
pclose(fp);
@@ -962,13 +966,13 @@ void LibraryDialog::newList()
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
qApp->processEvents();
// if( QFile(gutenindex1).exists() ) {
// QString gutenindex=QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
// if( rename(gutenindex1.latin1(),gutenindex.latin1()) !=0)
- // qDebug("renaming error");
+ // odebug << "renaming error" << oendl;
// }
}
// outDlg->close();
FindLibrary();
if(outDlg) delete outDlg;
@@ -1021,13 +1025,13 @@ bool LibraryDialog::moreInfo()
titleString = item->text(0);
ListView5->clearSelection();
item = 0;
}
item=0;
if(titleString.length()>2) {
- qDebug( "Title is "+titleString );
+ odebug << "Title is "+titleString << oendl;
titleString.replace( QRegExp("\\s"), "%20");
titleString.replace( QRegExp("'"), "%20");
titleString.replace( QRegExp("\""), "%20");
titleString.replace( QRegExp("&"), "%20");
QString cmd= "http://google.com/search?q="+titleString+"&num=30&sa=Google+Search";
cmd="opera "+cmd;
@@ -1045,18 +1049,18 @@ void LibraryDialog::FindLibrary()
buttonLibrary->setDown(TRUE);
qApp->processEvents();
if( QFile( new_index).exists() /* && this->isHidden() */) {
newindexLib.setName( new_index);
indexLib.setName( new_index);
- qDebug("index file is "+ new_index);
+ odebug << "index file is "+ new_index << oendl;
Newlibrary();
} else {
newindexLib.setName( old_index);
indexLib.setName( old_index);
- qDebug("new index nameis "+ old_index);
+ odebug << "new index nameis "+ old_index << oendl;
Library();
}
indexLoaded=true;
buttonSearch->setEnabled(TRUE);
moreInfoButton->setEnabled(TRUE);