summaryrefslogtreecommitdiff
path: root/noncore/apps
authorerik <erik>2007-01-31 22:06:07 (UTC)
committer erik <erik>2007-01-31 22:06:07 (UTC)
commit9395cf2a65184e493714c699bb23b02ea31feef5 (patch) (unidiff)
treeea07c026298820559c13ad32e612d51048cee0a9 /noncore/apps
parent958e042c5a4d4e38fd1baae50b78a2febfd306ab (diff)
downloadopie-9395cf2a65184e493714c699bb23b02ea31feef5.zip
opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.gz
opie-9395cf2a65184e493714c699bb23b02ea31feef5.tar.bz2
I expanded my audit to include any app I could get to compile in i386.
In that expansion a whole new crop of unchecked returns has sprung up. This commit fixes those weeds or should I say potential bugs.
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp88
-rw-r--r--noncore/apps/opie-gutenbrowser/openetext.cpp174
2 files changed, 128 insertions, 134 deletions
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 6c246e97..7f21ab3 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -22,3 +22,3 @@
22#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23//#include <opie2///odebug.h> 23#include <opie2/odebug.h>
24 24
@@ -460,51 +460,54 @@ bool LibraryDialog::getEtext(const QStringList &networkList)
460{ 460{
461 NetworkDialog *NetworkDlg; 461 NetworkDialog *NetworkDlg;
462 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList); 462 NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog", true, 0, networkList);
463 463
464// use new, improved, *INSTANT* network-dialog-file-getterer 464 // use new, improved, *INSTANT* network-dialog-file-getterer
465 if( NetworkDlg->exec() != 0 ) { 465 if( NetworkDlg->exec() != 0 ) {
466 File_Name = NetworkDlg->localFileName; 466 File_Name = NetworkDlg->localFileName;
467 467
468 qDebug("Just downloaded " + NetworkDlg->localFileName); 468 qDebug("Just downloaded " + NetworkDlg->localFileName);
469 469
470 if(NetworkDlg->successDownload) { 470 if(NetworkDlg->successDownload) {
471 //odebug << "Filename is "+File_Name << oendl; 471 //odebug << "Filename is "+File_Name << oendl;
472 if(File_Name.right(4) == ".txt") { 472 if(File_Name.right(4) == ".txt") {
473 QString s_fileName = File_Name; 473 QString s_fileName = File_Name;
474 s_fileName.replace( s_fileName.length() - 3, 3, "gtn"); 474 s_fileName.replace( s_fileName.length() - 3, 3, "gtn");
475 // s_fileName.replace( s_fileName.length()-3,3,"etx"); 475 if (rename( File_Name.latin1(), s_fileName.latin1()) == 1) {
476 rename( File_Name.latin1(), s_fileName.latin1()); 476 owarn << "Failed to rename " << File_Name.latin1() << " to "
477 File_Name = s_fileName; 477 << s_fileName.latin1() << oendl;
478 return false;
479 }
478 480
479 //odebug << "Filename is now "+File_Name << oendl; 481 File_Name = s_fileName;
480 482
481 } 483 //odebug << "Filename is now "+File_Name << oendl;
482 if(File_Name.length() > 5 ) {
483 setTitle();
484 QFileInfo fi(File_Name);
485 QString name_file = fi.fileName();
486 name_file = name_file.left( name_file.length() - 4);
487
488 //odebug << "Setting doclink" << oendl;
489 DocLnk lnk;
490 //odebug << "name is "+name_file << oendl;
491 lnk.setName(name_file); //sets file name
492 //odebug << "Title is "+DlglistItemTitle << oendl;
493 lnk.setComment(DlglistItemTitle);
494 484
495 //odebug << "Filename is "+File_Name << oendl;
496 lnk.setFile(File_Name); //sets File property
497 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
498 lnk.setExec(File_Name);
499 lnk.setIcon("gutenbrowser/Gutenbrowser");
500 if(!lnk.writeLink()) {
501 //odebug << "Writing doclink did not work" << oendl;
502 } else {
503 } 485 }
504 } else 486 if(File_Name.length() > 5 ) {
505 QMessageBox::message("Note","<p>There was an error with the file</p>"); 487 setTitle();
506 } 488 QFileInfo fi(File_Name);
507 } 489 QString name_file = fi.fileName();
490 name_file = name_file.left( name_file.length() - 4);
491
492 //odebug << "Setting doclink" << oendl;
493 DocLnk lnk;
494 //odebug << "name is "+name_file << oendl;
495 lnk.setName(name_file); //sets file name
496 //odebug << "Title is "+DlglistItemTitle << oendl;
497 lnk.setComment(DlglistItemTitle);
498
499 //odebug << "Filename is "+File_Name << oendl;
500 lnk.setFile(File_Name); //sets File property
501 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D
502 lnk.setExec(File_Name);
503 lnk.setIcon("gutenbrowser/Gutenbrowser");
504 if(!lnk.writeLink()) {
505 //odebug << "Writing doclink did not work" << oendl;
506 }
507 } else
508 QMessageBox::message("Note","<p>There was an error with the file</p>");
509 }
510 }
508 511
509 return true; 512 return true;
510} 513}
@@ -703,3 +706,2 @@ void LibraryDialog::onButtonSearch()
703 QString searcherStr = searchDlg->get_text(); 706 QString searcherStr = searchDlg->get_text();
704 int fluff = 0;
705 707
diff --git a/noncore/apps/opie-gutenbrowser/openetext.cpp b/noncore/apps/opie-gutenbrowser/openetext.cpp
index 0267416..a5d855d 100644
--- a/noncore/apps/opie-gutenbrowser/openetext.cpp
+++ b/noncore/apps/opie-gutenbrowser/openetext.cpp
@@ -59,4 +59,3 @@ void OpenEtext::getTitles()
59 s_numofFiles = config.readEntry("NumberOfFiles", "0"); 59 s_numofFiles = config.readEntry("NumberOfFiles", "0");
60 QLabel_1->setText( tr( 60 QLabel_1->setText( tr( s_numofFiles+" etexts in your library." ) );
61 s_numofFiles+" etexts in your library."));
62 int i_numofFiles = s_numofFiles.toInt(); 61 int i_numofFiles = s_numofFiles.toInt();
@@ -70,3 +69,8 @@ void OpenEtext::getTitles()
70 if( !title.isEmpty()) { 69 if( !title.isEmpty()) {
71 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), title, -1); 70 QListBox_1->insertItem ( QPixmap(
71 QPEApplication::qpeDir() +
72 "pics/gutenbrowser/gutenbrowser_sm.png"
73 ),
74 title,
75 -1);
72 } 76 }
@@ -102,4 +106,5 @@ void OpenEtext::select_title(int index )
102 106
103/* 107/*!
104 This function imports already existing etexts into the local library list*/ 108 * This function imports already existing etexts into the local library list
109 */
105void OpenEtext::open() 110void OpenEtext::open()
@@ -115,10 +120,2 @@ OpenFileButton->setDown(TRUE);
115 120
116// fileBrowser *browseForFiles;
117// browseForFiles=new fileBrowser(this,"Browse for File", TRUE, 0, "guten/plain;text/plain");
118// // browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
119// browseForFiles->setFileView( 0);
120// browseForFiles->showMaximized();
121// browseForFiles->exec();
122// QString selFile= browseForFiles->selectedFileName;
123// fileList=browseForFiles->fileList;
124 Config cfg("Gutenbrowser"); 121 Config cfg("Gutenbrowser");
@@ -136,28 +133,16 @@ OpenFileButton->setDown(TRUE);
136 133
137 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) { 134 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) {
138 filer = str; 135 filer = str;
139 136
140 odebug << "Open file: "+str << oendl; 137 odebug << "Open file: "+str << oendl;
141 138
142 // QStringList::ConstIterator f; 139 if( filer.right(4) == ".txt" ||
143// QString fileTemp; 140 filer.right(4) == ".TXT" ||
144// for ( f = fileList.begin(); f != fileList.end(); f++ ) { 141 filer.right(4) == ".etx" ||
145// fileTemp = *f; 142 filer.right(4) == ".ETX" ||
146// fileTemp.right( fileTemp.length()-5); 143 filer.right(4) == ".etx" ||
147// fileName = fileTemp; 144 filer.right(4) == ".ETX" ||
148// if( !fileName.isEmpty() ){ 145 filer.right(4) == ".zip" ||
149// filer = fileName; 146 filer.right(4) == ".ZIP" )
150// } else { //filename is empty 147 {
151// // QString sMsg;
152// // sMsg = "Error opening library filelist "+fileName;
153// }
154
155 if( filer.right(4) == ".txt"
156 || filer.right(4) == ".TXT"
157 || filer.right(4) == ".etx"
158 || filer.right(4) == ".ETX"
159 || filer.right(4) == ".etx"
160 || filer.right(4) == ".ETX"
161 || filer.right(4) == ".zip"
162 || filer.right(4) == ".ZIP" ) {
163 QFileInfo zipFile( filer); 148 QFileInfo zipFile( filer);
@@ -166,6 +151,6 @@ OpenFileButton->setDown(TRUE);
166 151
167 if( s_fileName.right(4) == ".zip") { // unzip that sucker.... 152 if( s_fileName.right(4) == ".zip") { // unzip the file
168 s_fileName = s_fileName.left( s_fileName.length() - 4); 153 s_fileName = s_fileName.left( s_fileName.length() - 4);
169 if( chdir((const char*)local_library.latin1())!=0) 154 if( chdir((const char*)local_library.latin1())!=0)
170 odebug << "chdir failed." << oendl; // QString cmd = "gunzip -d " + filer + " -d " + local_library; 155 odebug << "chdir failed." << oendl;
171 cmd = "gunzip -S .zip " + filer; 156 cmd = "gunzip -S .zip " + filer;
@@ -173,14 +158,14 @@ OpenFileButton->setDown(TRUE);
173 system( cmd); 158 system( cmd);
174 } 159 } else { // else rename .txt to .etx
175// this renames the .txt to .etx!! 160 // odebug << "Filename is "+fileName << oendl;
176 else /*if( s_fileName.right(4) == ".txt" || if( s_fileName.right(4) == ".TXT"))*/ {
177// odebug << "Filename is "+fileName << oendl;
178 s_fileName = fileName; 161 s_fileName = fileName;
179 s_fileName.replace( s_fileName.length()-3,3,"gtn");// s_fileName.replace( s_fileName.length()-3,3,"etx"); 162 s_fileName.replace( s_fileName.length()-3,3,"gtn");
180 rename(fileName.latin1(),s_fileName.latin1()); 163 if (rename(fileName.latin1(),s_fileName.latin1()) == -1)
164 owarn << "Rename of " << fileName.latin1() << " to "
165 << s_fileName.latin1() << " failed" << oendl;
181 fileName = s_fileName; 166 fileName = s_fileName;
182// odebug << "Filename is now "+fileName << oendl; 167 // odebug << "Filename is now "+fileName << oendl;
183 } 168 }
184 } else 169 } else
185 fileName = str; 170 fileName = str;
186 171
@@ -203,3 +188,6 @@ OpenFileButton->setDown(TRUE);
203 lnk.setFile(fileName); //sets File property 188 lnk.setFile(fileName); //sets File property
204 lnk.setType("guten/plain");// hey is this a REGISTERED mime type?!?!? ;D 189 // @bug This is probably not a registered MIME type. Perhaps we should
190 // set a valid MIME type here instead. Or maybe register .etx as a
191 // Gutenberge etext?
192 lnk.setType("guten/plain");
205 lnk.setExec(fileName); 193 lnk.setExec(fileName);
@@ -210,3 +198,3 @@ OpenFileButton->setDown(TRUE);
210 } // end of for each file name.... 198 } // end of for each file name....
211 OpenFileButton->setDown(FALSE); 199 OpenFileButton->setDown(FALSE);
212} 200}
@@ -226,7 +214,6 @@ bool OpenEtext::FindTitle( QString filename)
226 QFile indexLib( filename); 214 QFile indexLib( filename);
227 bool findCheck = FALSE; 215 bool findCheck = FALSE;
228 // int Titlenumber=0;
229 216
230 if ( indexLib.open( IO_ReadOnly) ) { 217 if ( indexLib.open( IO_ReadOnly) ) {
231 odebug << "file opened successfully" << oendl; 218 odebug << "file opened successfully" << oendl;
232 QTextStream indexStream( &indexLib ); 219 QTextStream indexStream( &indexLib );
@@ -238,3 +225,3 @@ bool OpenEtext::FindTitle( QString filename)
238 while ( !indexStream.eof() ) { 225 while ( !indexStream.eof() ) {
239 // until end of file.. 226 // until end of file..
240 indexLine = indexStream.readLine(); 227 indexLine = indexStream.readLine();
@@ -245,3 +232,3 @@ bool OpenEtext::FindTitle( QString filename)
245// odebug << "Found the title 1 and it is " << title << "" << oendl; 232// odebug << "Found the title 1 and it is " << title << "" << oendl;
246// QListBox_1->insertItem ( title); 233// QListBox_1->insertItem ( title);
247 } 234 }
@@ -252,4 +239,4 @@ bool OpenEtext::FindTitle( QString filename)
252 title = title.stripWhiteSpace (); 239 title = title.stripWhiteSpace ();
253// odebug << "Found the title 2 and it is " << title << "" << oendl; 240// odebug << "Found the title 2 and it is " << title << "" << oendl;
254// QListBox_1->insertItem ( title); 241// QListBox_1->insertItem ( title);
255 } 242 }
@@ -279,3 +266,2 @@ bool OpenEtext::FindTitle( QString filename)
279 if ( checkConf() == false && findCheck == TRUE) { 266 if ( checkConf() == false && findCheck == TRUE) {
280
281 config.setGroup( "Files"); 267 config.setGroup( "Files");
@@ -317,6 +303,6 @@ QString OpenEtext::titleFromLibrary( QString fileName)
317 int find2 = fileName.findRev(".gtn",-1,TRUE) - find1; 303 int find2 = fileName.findRev(".gtn",-1,TRUE) - find1;
318 if(find2==-1-find1) 304 if(find2== (-1-find1))
319 int find2 = fileName.findRev(".etx",-1,TRUE) - find1; 305 find2 = fileName.findRev(".etx",-1,TRUE) - find1;
320 else if(find2==-1-find1) 306 else if(find2==(-1-find1))
321 int find2 = fileName.findRev(".txt",-1,TRUE) - find1; 307 find2 = fileName.findRev(".txt",-1,TRUE) - find1;
322 308
@@ -336,3 +322,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
336 if ( indexLib.open( IO_ReadOnly) ) { 322 if ( indexLib.open( IO_ReadOnly) ) {
337 // file opened successfully 323 // file opened successfully
338 QTextStream indexStream( &indexLib ); 324 QTextStream indexStream( &indexLib );
@@ -340,3 +326,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
340 bool findCheck = FALSE; 326 bool findCheck = FALSE;
341 while ( !indexStream.atEnd() ) { // until end of file.. 327 while ( !indexStream.atEnd() ) { // until end of file..
342 indexLine = indexStream.readLine(); 328 indexLine = indexStream.readLine();
@@ -346,6 +332,5 @@ QString OpenEtext::titleFromLibrary( QString fileName)
346 title = indexLine.mid( 9, 50); 332 title = indexLine.mid( 9, 50);
347// title = indexLine.mid( 26, indexLine.length() );
348 title = title.stripWhiteSpace (); 333 title = title.stripWhiteSpace ();
349// odebug << "Finally Found the title and it is\n " << title << "" << oendl; 334// odebug << "Finally Found the title and it is\n " << title << "" << oendl;
350// QListBox_1->insertItem ( title); 335// QListBox_1->insertItem ( title);
351 } 336 }
@@ -354,3 +339,3 @@ QString OpenEtext::titleFromLibrary( QString fileName)
354 else 339 else
355 odebug << "Error opening library index "+ local_index << oendl; 340 odebug << "Error opening library index "+ local_index << oendl;
356 return title; 341 return title;
@@ -383,6 +368,8 @@ void OpenEtext::remove()
383 title_text=title_text.stripWhiteSpace(); 368 title_text=title_text.stripWhiteSpace();
384 QString msg ="<p>Do you really want to REMOVE\n" +title_text +"?\nThis will not delete the file.</P>"; 369 QString msg ="<p>Do you really want to REMOVE\n" + title_text +
385 switch( QMessageBox::information( this, (tr("Remove Etext")), 370 "?\nThis will not delete the file.</P>";
386 (tr(msg)), 371 switch( QMessageBox::information( this, tr("Remove Etext"),
387 (tr("&Yes")), (tr("&Cancel")), 0 )){ 372 tr(msg),
373 tr("&Yes"), tr("&Cancel"), 0 ) )
374 {
388 case 0: // Yes clicked, 375 case 0: // Yes clicked,
@@ -392,9 +379,10 @@ void OpenEtext::remove()
392 break; 379 break;
393 case 1: // Cancel 380 case 1:
394 break; 381 default:
395 }; 382 }
396} 383}
397 384
398/* 385/*!
399 this removes selected title entry*/ 386 * This removes selected title entry
387 */
400void OpenEtext::removeSelection() 388void OpenEtext::removeSelection()
@@ -419,3 +407,3 @@ void OpenEtext::removeSelection()
419 rem=i; 407 rem=i;
420//odebug << "file title to remove is "+file_title << oendl; 408 //odebug << "file title to remove is "+file_title << oendl;
421 selFile = s_filename; 409 selFile = s_filename;
@@ -438,7 +426,7 @@ void OpenEtext::removeSelection()
438 config.removeEntry(fileNum2); 426 config.removeEntry(fileNum2);
439// remFile();
440} 427}
441 428
442/* 429/*!
443 removes file title name from list and config file*/ 430 * Removes file title name from list and config file
431 */
444void OpenEtext::remFile() 432void OpenEtext::remFile()
@@ -463,5 +451,4 @@ void OpenEtext::remFile()
463 451
464 if (!s_filename2.isEmpty()) { 452 if (!s_filename2.isEmpty())
465 config.writeEntry(fileNum, s_filename2 ); 453 config.writeEntry(fileNum, s_filename2 );
466 }
467 } 454 }
@@ -475,4 +462,5 @@ void OpenEtext::remFile()
475 462
476/* 463/*!
477sorts the list*/ 464 * Sorts the list
465 */
478void OpenEtext::scan() { 466void OpenEtext::scan() {
@@ -487,3 +475,3 @@ void OpenEtext::editTitle() {
487 QString title_text = QListBox_1->text( currentItem); 475 QString title_text = QListBox_1->text( currentItem);
488//odebug << "Selected "+title_text << oendl; 476 //odebug << "Selected "+title_text << oendl;
489 477
@@ -501,6 +489,6 @@ void OpenEtext::editTitle() {
501 QString file_title = config.readEntry( s_filename, ""); 489 QString file_title = config.readEntry( s_filename, "");
502//odebug << "file_title is "+file_title << oendl; 490 //odebug << "file_title is "+file_title << oendl;
503 if(title_text == file_title ) { 491 if(title_text == file_title ) {
504 selFile = s_filename; 492 selFile = s_filename;
505//odebug << "Edit: "+ file_title << oendl; 493 //odebug << "Edit: "+ file_title << oendl;
506 i=i_numofFiles+1; 494 i=i_numofFiles+1;
@@ -509,6 +497,10 @@ void OpenEtext::editTitle() {
509 if(titleEdit->exec() !=0) { 497 if(titleEdit->exec() !=0) {
510//odebug << titleEdit->newTitle << oendl; 498 //odebug << titleEdit->newTitle << oendl;
511 config.writeEntry( s_filename, titleEdit->newTitle); 499 config.writeEntry( s_filename, titleEdit->newTitle);
512 QListBox_1->removeItem(currentItem); 500 QListBox_1->removeItem(currentItem);
513 QListBox_1->insertItem ( QPixmap( QPEApplication::qpeDir()+"pics/gutenbrowser/gutenbrowser_sm.png"), titleEdit->newTitle, currentItem); 501 QListBox_1->insertItem (
502 QPixmap( QPEApplication::qpeDir()+
503 "pics/gutenbrowser/gutenbrowser_sm.png"),
504 titleEdit->newTitle, currentItem
505 );
514 } 506 }
@@ -517,3 +509,3 @@ void OpenEtext::editTitle() {
517 509
518// getTitles(); 510 //getTitles();
519 QListBox_1->triggerUpdate(true); 511 QListBox_1->triggerUpdate(true);