summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/om3u.cpp3
-rw-r--r--libopie2/opiemm/opieexif.cpp8
-rw-r--r--noncore/apps/opie-console/filereceive.cpp4
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp4
-rw-r--r--noncore/apps/opie-console/logger.cpp4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp3
-rw-r--r--noncore/apps/opie-console/script.cpp6
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp26
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.cpp64
-rw-r--r--noncore/graphics/opie-eye/slave/bmp_slave.cpp4
-rw-r--r--noncore/net/ftplib/ftplib.c8
-rw-r--r--noncore/todayplugins/stockticker/stockticker/helpwindow.cpp42
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.cpp5
-rw-r--r--noncore/tools/opie-sh/inputdialog.cpp20
14 files changed, 109 insertions, 92 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 48aa47e..68ea015 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -34,33 +34,34 @@
#include <opie2/odebug.h>
static inline QString fullBaseName ( const QFileInfo &fi )
{
QString str = fi. fileName ( );
return str. left ( str. findRev ( '.' ));
}
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//odebug << "<<<<<<<new m3u "+filePath << oendl;
f.setName(filePath);
- f.open(mode);
+ if ( !f.open(mode) )
+ owarn << "Failed to open file " << f.name() << oendl;
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
// odebug << "<<<<<<reading m3u "+f.name() << oendl;
QTextStream t(&f);
t.setEncoding(QTextStream::UnicodeUTF8);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
// odebug << s << oendl;
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
diff --git a/libopie2/opiemm/opieexif.cpp b/libopie2/opiemm/opieexif.cpp
index de49937..653216c 100644
--- a/libopie2/opiemm/opieexif.cpp
+++ b/libopie2/opiemm/opieexif.cpp
@@ -192,33 +192,33 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
Data[0] = (uchar)lh;
Data[1] = (uchar)ll;
got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section.
if (( unsigned ) got != itemlen-2){
return false;
}
SectionsRead++;
switch(marker){
case M_SOS: // stop before hitting compressed data
// If reading entire image is requested, read the rest of the data.
if (ReadMode & READ_IMAGE){
unsigned long size;
- size = QMAX( 0ul, infile.size()-infile.at() );
+ size = infile.size()-infile.at();
Data = (uchar *)malloc(size);
if (Data == NULL){
return false;
}
got = infile.readBlock((char*)Data, size);
if (( unsigned ) got != size){
return false;
}
Sections[SectionsRead].Data = Data;
Sections[SectionsRead].Size = size;
Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER;
SectionsRead ++;
//HaveAll = 1;
}
@@ -796,33 +796,37 @@ ExifData::ExifData()
CompressionLevel = 0;
MotorolaOrder = 0;
}
ExifData::~ExifData()
{
}
//--------------------------------------------------------------------------
// process a EXIF jpeg file
//--------------------------------------------------------------------------
bool ExifData::scan(const QString & path)
{
int ret;
QFile f(path);
- f.open(IO_ReadOnly);
+ if ( !f.open(IO_ReadOnly) ) {
+ owarn << "Unable to open file " << f.name() << " readonly" << oendl;
+ DiscardData();
+ return false;
+ }
// Scan the JPEG headers.
ret = ReadJpegSections(f, READ_EXIF);
if (ret == false){
owarn << "Not JPEG file!" << oendl;
DiscardData();
f.close();
return false;
}
f.close();
DiscardData();
//now make the strings clean,
// for exmaple my Casio is a "QV-4000 "
CameraMake = CameraMake.stripWhiteSpace();
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp
index 452be60..41e6888 100644
--- a/noncore/apps/opie-console/filereceive.cpp
+++ b/noncore/apps/opie-console/filereceive.cpp
@@ -1,21 +1,22 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
+#include <opie2/odebug.h>
#include <qsocketnotifier.h>
#include "io_layer.h"
#include "procctl.h"
#include "filereceive.h"
FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir )
: ReceiveLayer(lay, dir ), m_type( t )
{
m_fd = -1;
m_not = 0l;
m_proc = 0l;
}
FileReceive::~FileReceive() {
}
void FileReceive::receive() {
@@ -135,28 +136,29 @@ void FileReceive::setupChild() {
*/
dup2( m_fd, STDIN_FILENO );
dup2( m_fd, STDOUT_FILENO );
dup2( m_comm[1], STDERR_FILENO );
}
void FileReceive::slotRead() {
QByteArray ar(4096);
int len = read(m_comm[0], ar.data(), 4096 );
for (int i = 0; i < len; i++ ) {
// printf("%c", ar[i] );
}
ar.resize( len );
QString str( ar );
}
void FileReceive::slotExec() {
char buf[2];
- ::read(m_term[0], buf, 1 );
+ if (::read(m_term[0], buf, 1 ) == -1)
+ owarn << "read of m_term[0] failed" << oendl;
delete m_proc;
delete m_not;
m_not = m_proc = 0l;
close( m_term[0] );
close( m_term[1] );
close( m_comm[0] );
close( m_comm[1] );
layer()->closeRawIO(m_fd);
emit received(QString::null);
}
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 7eebc65..6e2d2d5 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -1,22 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
+#include <opie2/odebug.h>
#include <qsocketnotifier.h>
#include "procctl.h"
#include "filetransfer.h"
FileTransfer::FileTransfer( Type t, IOLayer* lay )
: FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) {
signal(SIGPIPE, SIG_IGN );
m_pid = 0;
m_not = 0l;
m_proc = 0l;
}
FileTransfer::~FileTransfer() {
}
@@ -221,28 +222,29 @@ void FileTransfer::slotProgress( const QStringList& list ) {
min = progi[0].toInt();
sec = progi[1].toInt();
if ( prog > m_prog ) {
m_prog = prog;
emit progress(m_file, m_prog, bps, -1, min , sec );
}
}
void FileTransfer::cancel() {
if(m_pid > 0) ::kill(m_pid,9 );
}
void FileTransfer::slotExec() {
char buf[2];
- ::read(m_term[0], buf, 1 );
+ if (::read(m_term[0], buf, 1 ) == -1)
+ owarn << "read of m_term[0] failed" << oendl;
delete m_proc;
delete m_not;
m_proc = m_not = 0l;
close( m_term[0] );
close( m_term[1] );
close( m_comm[0] );
close( m_comm[1] );
layer()->closeRawIO( m_fd );
emit sent();
m_pid = 0;
}
diff --git a/noncore/apps/opie-console/logger.cpp b/noncore/apps/opie-console/logger.cpp
index 6620faf..0fdeca0 100644
--- a/noncore/apps/opie-console/logger.cpp
+++ b/noncore/apps/opie-console/logger.cpp
@@ -1,20 +1,22 @@
#include <qfile.h>
#include <qtextstream.h>
+#include <opie2/odebug.h>
#include "logger.h"
Logger::Logger() {}
Logger::Logger(const QString fileName) {
m_file.setName(fileName);
- m_file.open(IO_ReadWrite);
+ if ( !m_file.open(IO_ReadWrite) )
+ owarn << "failed to open " << m_file.name() << oendl;
}
Logger::~Logger() {
m_file.close();
}
void Logger::append(QByteArray ar) {
m_file.writeBlock(ar);
}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 18c0434..aba7244 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -811,24 +811,25 @@ void MainWindow::slotSaveHistory() {
QMap<QString, QStringList> map;
QStringList text;
text << "text/plain";
map.insert(tr("History"), text );
QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
if (filename.isEmpty() ) return;
QFileInfo info(filename);
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filename);
nf.setName(info.fileName());
QFile file(filename);
- file.open(IO_WriteOnly );
+ if ( !file.open(IO_WriteOnly ) ) return;
+
QTextStream str(&file );
if ( currentSession() )
currentSession()->emulationHandler()->emulation()->streamHistory(&str);
file.close();
nf.writeLink();
}
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp
index faea412..8d35776 100644
--- a/noncore/apps/opie-console/script.cpp
+++ b/noncore/apps/opie-console/script.cpp
@@ -1,29 +1,31 @@
#include <qfile.h>
#include "script.h"
Script::Script() {
}
Script::Script(const QString fileName) {
QFile file(fileName);
- file.open(IO_ReadOnly );
+ if ( !file.open(IO_ReadOnly ) )
+ return;
m_script = file.readAll();
}
void Script::saveTo(const QString fileName) const {
QFile file(fileName);
- file.open(IO_WriteOnly);
+ if ( !file.open(IO_WriteOnly) )
+ return;
file.writeBlock(m_script);
file.close();
}
void Script::append(const QByteArray &data) {
int size = m_script.size();
m_script.resize(size + data.size());
memcpy(m_script.data() + size, data.data(), data.size());
}
QByteArray Script::script() const {
return m_script;
}
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index 733db17..8b02f9f 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -832,48 +832,42 @@ bool Gutenbrowser::load( const char *fileName) {
// pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
//odebug << "number of pages " << pages << "" << oendl;
loadCheck = true;
enableButtons(true);
if( donateMenu->count() == 3) {
donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
}
Lview->setFocus();
// QCopEnvelope("QPE/System", "notBusy()" );
return true;
} // end load
void Gutenbrowser::Search() {
-
- // if( searchDlg->isHidden())
- {
- odebug << "Starting search dialog" << oendl;
- searchDlg = new SearchDialog( this, "Etext Search", true);
- searchDlg->setCaption( tr( "Etext Search" ));
- // searchDlg->setLabel( "- searches etext");
- connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
- connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
-
- QString resultString;
- QString string = searchDlg->searchString;
- Lview->deselect();
- searchDlg->show();
- searchDlg->result();
- }
+ odebug << "Starting search dialog" << oendl;
+ searchDlg = new SearchDialog( this, "Etext Search", true);
+ searchDlg->setCaption( tr( "Etext Search" ));
+ connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
+ connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
+
+ QString resultString;
+ QString string = searchDlg->searchString;
+ Lview->deselect();
+ searchDlg->show();
}
void Gutenbrowser::search_slot( ) {
int line, col;
if (!searchDlg /*&& !loadCheck */)
return;
Lview->getCursorPosition(&line,&col);
QString to_find_string=searchDlg->get_text();
// searchDlg->get_direction();// is true if searching backward
if ( last_search != 0 && searchDlg->get_direction() ){
col = col - pattern.length() - 1 ;
}
again:
int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp
index 4bdac02..f444a2e 100644
--- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp
+++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp
@@ -180,62 +180,55 @@ void HelpWindow::textChanged()
}
if ( !exists ) {
pathCombo->insertItem( selectedURL, 0 );
pathCombo->setCurrentItem( 0 );
mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
} else
pathCombo->setCurrentItem( i );
selectedURL = QString::null;
}
}
HelpWindow::~HelpWindow()
{
history.clear();
QMap<int, QString>::Iterator it = mHistory.begin();
for ( ; it != mHistory.end(); ++it )
- history.append( *it );
+ history.append( *it );
QFile f( QDir::currentDirPath() + "/.history" );
- f.open( IO_WriteOnly );
- QDataStream s( &f );
- s << history;
- f.close();
+ if ( f.open( IO_WriteOnly ) ) {
+ QDataStream s( &f );
+ s << history;
+ f.close();
+ }
bookmarks.clear();
QMap<int, QString>::Iterator it2 = mBookmarks.begin();
for ( ; it2 != mBookmarks.end(); ++it2 )
- bookmarks.append( *it2 );
+ bookmarks.append( *it2 );
QFile f2( QDir::currentDirPath() + "/.bookmarks" );
- f2.open( IO_WriteOnly );
+ if ( !f2.open( IO_WriteOnly ) )
+ return;
+
QDataStream s2( &f2 );
s2 << bookmarks;
f2.close();
}
-// void HelpWindow::about()
-// {
-// QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" );
-// }
-
-// void HelpWindow::aboutQt()
-// {
-// QMessageBox::aboutQt( this, "QBrowser" );
-// }
-
void HelpWindow::openFile()
{
#ifndef QT_NO_FILEDIALOG
QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
if ( !fn.isEmpty() )
browser->setSource( fn );
#endif
}
void HelpWindow::newWindow()
{
( new HelpWindow(browser->source(), "qbrowser") )->show();
}
void HelpWindow::print()
{
@@ -279,52 +272,57 @@ void HelpWindow::pathSelected( const QString &_path )
{
browser->setSource( _path );
QMap<int, QString>::Iterator it = mHistory.begin();
bool exists = FALSE;
for ( ; it != mHistory.end(); ++it ) {
if ( *it == _path ) {
exists = TRUE;
break;
}
}
if ( !exists )
mHistory[ hist->insertItem( _path ) ] = _path;
}
void HelpWindow::readHistory()
{
- if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
- QFile f( QDir::currentDirPath() + "/.history" );
- f.open( IO_ReadOnly );
- QDataStream s( &f );
- s >> history;
- f.close();
- while ( history.count() > 20 )
- history.remove( history.begin() );
- }
+ if ( !QFile::exists( QDir::currentDirPath() + "/.history" ) )
+ return;
+
+ QFile f( QDir::currentDirPath() + "/.history" );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+
+ QDataStream s( &f );
+ s >> history;
+ f.close();
+ while ( history.count() > 20 )
+ history.remove( history.begin() );
}
void HelpWindow::readBookmarks()
{
- if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
- QFile f( QDir::currentDirPath() + "/.bookmarks" );
- f.open( IO_ReadOnly );
- QDataStream s( &f );
- s >> bookmarks;
- f.close();
- }
+ if ( !QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) )
+ return;
+
+ QFile f( QDir::currentDirPath() + "/.bookmarks" );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+ QDataStream s( &f );
+ s >> bookmarks;
+ f.close();
}
void HelpWindow::histChosen( int i )
{
if ( mHistory.contains( i ) )
browser->setSource( mHistory[ i ] );
}
void HelpWindow::bookmChosen( int i )
{
if ( mBookmarks.contains( i ) )
browser->setSource( mBookmarks[ i ] );
}
void HelpWindow::addBookmark()
{
diff --git a/noncore/graphics/opie-eye/slave/bmp_slave.cpp b/noncore/graphics/opie-eye/slave/bmp_slave.cpp
index 2fa825f..0efadac 100644
--- a/noncore/graphics/opie-eye/slave/bmp_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/bmp_slave.cpp
@@ -69,36 +69,34 @@ namespace {
return "4Bit RLE Encoding";
break;
case RGB:
default:
return "No encoding";
}
}
BmpHeader::BmpHeader(const QString&fname)
: _name(fname),_inputfile(_name)
{
read_data();
}
void BmpHeader::read_data() {
memset(&m_Header,0,sizeof(pBmpHeader));
- _inputfile.open(IO_Raw|IO_ReadOnly);
- if (!_inputfile.isOpen()) {
+ if (!_inputfile.open(IO_Raw|IO_ReadOnly))
return;
- }
QDataStream s(&_inputfile);
s.setByteOrder( QDataStream::LittleEndian );
s.readRawBytes(m_Header.type,2);
if (!isBmp()) {
_inputfile.close();
return;
}
s >> m_Header.hSize;
s >> m_Header.reserved1 >> m_Header.reserved2;
s >> m_Header.Size;
if ( m_Header.Size == BmpHeader::WIN || m_Header.Size == BmpHeader::OS2 ) {
s >> m_Header.Width >> m_Header.Height >> m_Header.Planes >> m_Header.BitCount;
s >> m_Header.Compression >> m_Header.SizeImage;
s >> m_Header.XPerMeter >> m_Header.YPerMeter;
s >> m_Header.ClrUsed >> m_Header.ClrImportant;
} else {
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c
index 421f855..efcd6f0 100644
--- a/noncore/net/ftplib/ftplib.c
+++ b/noncore/net/ftplib/ftplib.c
@@ -945,33 +945,34 @@ GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData)
}
return i;
}
/*
* FtpWrite - write to a data connection
*/
GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData)
{
int i;
if (nData->dir != FTPLIB_WRITE)
return 0;
if (nData->buf)
i = writeline(buf, len, nData);
else
{
- socket_wait(nData);
+ if (socket_wait(nData) < 0)
+ fprintf(stderr, "FtpWrite: socket_wait failed with %s\n", nData->ctrl->response);
i = net_write(nData->handle, buf, len);
}
if (i == -1)
return 0;
nData->xfered += i;
if (nData->idlecb && nData->cbbytes)
{
nData->xfered1 += i;
if (nData->xfered1 > nData->cbbytes)
{
nData->idlecb(nData, nData->xfered, nData->idlearg);
nData->xfered1 = 0;
}
}
return i;
}
@@ -1326,21 +1327,24 @@ GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl)
return 0;
sprintf(cmd,"DELE %s",fnm);
if (!FtpSendCmd(cmd,'2', nControl))
return 0;
return 1;
}
/*
* FtpQuit - disconnect from remote
*
* return 1 if successful, 0 otherwise
*/
GLOBALDEF void FtpQuit(netbuf *nControl)
{
if (nControl->dir != FTPLIB_CONTROL)
return;
- FtpSendCmd("QUIT",'2',nControl);
+ if (FtpSendCmd("QUIT",'2',nControl) == 1) {
+ if (ftplib_debug > 2)
+ fprintf(stderr, "FtpQuit: FtpSendCmd(QUIT) failed\n");
+ }
net_close(nControl->handle);
free(nControl->buf);
free(nControl);
}
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
index 410d642..2498bf9 100644
--- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
@@ -166,47 +166,49 @@ void HelpWindow::textChanged()
}
if ( !exists ) {
pathCombo->insertItem( selectedURL, 0 );
pathCombo->setCurrentItem( 0 );
mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
} else
pathCombo->setCurrentItem( i );
selectedURL = QString::null;
}
}
HelpWindow::~HelpWindow()
{
history.clear();
QMap<int, QString>::Iterator it = mHistory.begin();
for ( ; it != mHistory.end(); ++it )
- history.append( *it );
+ history.append( *it );
QFile f( QDir::currentDirPath() + "/.history" );
- f.open( IO_WriteOnly );
- QDataStream s( &f );
- s << history;
- f.close();
+ if ( f.open( IO_WriteOnly ) ) {
+ QDataStream s( &f );
+ s << history;
+ f.close();
+ }
bookmarks.clear();
QMap<int, QString>::Iterator it2 = mBookmarks.begin();
for ( ; it2 != mBookmarks.end(); ++it2 )
- bookmarks.append( *it2 );
+ bookmarks.append( *it2 );
QFile f2( QDir::currentDirPath() + "/.bookmarks" );
- f2.open( IO_WriteOnly );
+ if ( !f2.open( IO_WriteOnly ) )
+ return;
QDataStream s2( &f2 );
s2 << bookmarks;
f2.close();
}
void HelpWindow::openFile()
{
#ifndef QT_NO_FILEDIALOG
QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
if ( !fn.isEmpty() )
browser->setSource( fn );
#endif
}
void HelpWindow::newWindow()
{
@@ -218,50 +220,52 @@ void HelpWindow::pathSelected( const QString &_path )
browser->setSource( _path );
QMap<int, QString>::Iterator it = mHistory.begin();
bool exists = FALSE;
for ( ; it != mHistory.end(); ++it ) {
if ( *it == _path ) {
exists = TRUE;
break;
}
}
if ( !exists )
mHistory[ hist->insertItem( _path ) ] = _path;
}
void HelpWindow::readHistory()
{
if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
- QFile f( QDir::currentDirPath() + "/.history" );
- f.open( IO_ReadOnly );
- QDataStream s( &f );
- s >> history;
- f.close();
- while ( history.count() > 20 )
- history.remove( history.begin() );
+ QFile f( QDir::currentDirPath() + "/.history" );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+ QDataStream s( &f );
+ s >> history;
+ f.close();
+ while ( history.count() > 20 )
+ history.remove( history.begin() );
}
}
void HelpWindow::readBookmarks()
{
if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
- QFile f( QDir::currentDirPath() + "/.bookmarks" );
- f.open( IO_ReadOnly );
- QDataStream s( &f );
- s >> bookmarks;
- f.close();
+ QFile f( QDir::currentDirPath() + "/.bookmarks" );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+ QDataStream s( &f );
+ s >> bookmarks;
+ f.close();
}
}
void HelpWindow::histChosen( int i )
{
if ( mHistory.contains( i ) )
browser->setSource( mHistory[ i ] );
}
void HelpWindow::bookmChosen( int i )
{
if ( mBookmarks.contains( i ) )
browser->setSource( mBookmarks[ i ] );
}
void HelpWindow::addBookmark()
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp
index fe54051..27624c5 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.cpp
+++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp
@@ -91,33 +91,34 @@ void WeatherPluginWidget::retreiveData()
localFile.append( ".TXT" );
remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
remoteFile.append( location );
remoteFile.append( ".TXT" );
QFile file( localFile );
if ( file.exists() )
{
file.remove();
}
OProcess *proc = new OProcess;
*proc << "wget" << "-q" << remoteFile << "-O" << localFile;
connect( proc, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( dataRetrieved(Opie::Core::OProcess*) ) );
- proc->start();
+ if ( !proc->start() )
+ weatherLabel->setText( tr( "Could not start wget process." ) );
}
void WeatherPluginWidget::displayWeather()
{
weatherData = QString::null;
QFile file( localFile );
if ( file.size() > 0 && file.open( IO_ReadOnly ) )
{
QTextStream data( &file );
while ( !data.eof() )
{
weatherData.append( data.readLine() );
}
file.close();
@@ -129,33 +130,33 @@ void WeatherPluginWidget::displayWeather()
getTemp( weatherData );
tmpstr.append( dataStr );
tmpstr.append( tr( " Wind: " ) );
getWind( weatherData );
tmpstr.append( dataStr );
tmpstr.append( tr( "\nPres: " ) );
getPressure( weatherData );
tmpstr.append( dataStr );
weatherLabel->setText( tmpstr );
tmpstr = "todayweatherplugin/";
getIcon( weatherData );
tmpstr.append( dataStr );
- weatherIcon->setPixmap( Opie::Core::OResource::loadPixmap( tmpstr, Opie::Core::OResource::SmallIcon ) );
+ weatherIcon->setPixmap( Opie::Core::OResource::loadPixmap( tmpstr, Opie::Core::OResource::SmallIcon ) );
}
else
{
weatherLabel->setText( tr( "Current weather data not available." ) );
}
}
void WeatherPluginWidget::getTemp( const QString &data )
{
int value;
bool ok;
int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 );
if ( pos > -1 )
{
if ( data.at( pos ) == 'M' )
diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp
index 8046795..1dd8bf7 100644
--- a/noncore/tools/opie-sh/inputdialog.cpp
+++ b/noncore/tools/opie-sh/inputdialog.cpp
@@ -27,60 +27,64 @@ InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString
layout->addSpacing(5);
layout->addWidget(label);
layout->addSpacing(5);
switch(type)
{
case 0:
lineEdit = new QLineEdit(this, "line edit");
layout->addWidget(lineEdit);
break;
case 1:
comboBox = new QComboBox(edit, this, "combo box");
layout->addWidget(comboBox);
if(!filename.isNull())
{
QFile file(filename);
- file.open(IO_ReadOnly);
- QTextStream stream(&file);
- QString string = stream.read();
+ if (file.open(IO_ReadOnly))
+ {
+ QTextStream stream(&file);
+ QString string = stream.read();
- comboBox->insertStringList(QStringList::split('\n', string));
+ comboBox->insertStringList(QStringList::split('\n', string));
+ }
}
else
{
QFile file;
file.open(IO_ReadOnly, 0);
QTextStream stream(&file);
QString string = stream.read();
comboBox->insertStringList(QStringList::split('\n', string));
}
break;
case 2:
listBox = new QListBox(this, "list box");
listBox->setSelectionMode(QListBox::Multi);
layout->addWidget(listBox);
if(!filename.isNull())
{
QFile file(filename);
- file.open(IO_ReadOnly);
- QTextStream stream(&file);
- QString string = stream.read();
+ if (file.open(IO_ReadOnly))
+ {
+ QTextStream stream(&file);
+ QString string = stream.read();
- listBox->insertStringList(QStringList::split('\n', string));
+ listBox->insertStringList(QStringList::split('\n', string));
+ }
}
else
{
QFile file;
file.open(IO_ReadOnly, 0);
QTextStream stream(&file);
QString string = stream.read();
listBox->insertStringList(QStringList::split('\n', string));
}
break;
case 3:
lineEdit = new QLineEdit(this, "line edit");
lineEdit->setEchoMode(QLineEdit::Password);
layout->addWidget(lineEdit);
break;